From 4dccd0c800ba6970c989455133a84a51eeefc6b0 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Mon, 12 Jan 2009 21:38:36 +0000 Subject: [PATCH] [svn-upgrade] Integrating new upstream version, bti (010) --- ChangeLog | 13 +++++++++++++ Makefile | 2 +- RELEASE-NOTES | 6 ++++++ bti.1 | 18 +++++++++++++++++- bti.c | 26 ++++++++++++++++++++++++-- bti.xml | 24 +++++++++++++++++++++++- 6 files changed, 84 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 74674cb..1336d79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Summary of changes from v009 to v010 +============================================ + +Greg Kroah-Hartman (3): + add --proxy support to command line + check in changes to bti.1 from previous xml changes + document the order that config options are handled + +gregor herrmann (2): + Fix up documentation of proxy option + use the http_proxy environment variable if it is present + + Summary of changes from v008 to v009 ============================================ diff --git a/Makefile b/Makefile index 4cfa826..7fc3a7b 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ # # -VERSION = 009 +VERSION = 010 PROGRAM = bti diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0d167b5..a268118 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,3 +1,9 @@ +bti 010 +============= +Fix up HTTP proxy support, thanks to gregor herrmann: + - command line option now works + - http_proxy environment variable is now handled + bti 009 ============= Initial attempt for HTTP proxy support. diff --git a/bti.1 b/bti.1 index 4c2fd45..3fe86d9 100644 --- a/bti.1 +++ b/bti.1 @@ -199,7 +199,7 @@ If no host is specified, the default is to send to twitter\&.com\&. .RS 4 Specify a http proxy value\&. This is not a required option, and only needed by systems that are behind a http proxy\&. .sp -If no host is specified, the default is to send to twitter\&.com\&. +If \-\-proxy is not specified but the environment variable \'http_proxy\' is set the latter will be used\&. .RE .PP \fB\-\-debug\fR @@ -266,6 +266,22 @@ The http proxy needed to send data out to the Internet\&. There is an example config file called \FCbti\&.example\F[] in the source tree that shows the structure of the file if you need an example to work off of\&. +.PP +Configuration options have the following priority: +.PP +.RS 4 +command line option +.RE +.PP +.RS 4 +config file option +.RE +.PP +.RS 4 +environment variables +.RE +.PP +For example, command line options always override any config file option, or any environment variables\&. .SH "AUTHOR" .PP Written by Greg Kroah\-Hartman diff --git a/bti.c b/bti.c index f3fc64c..a06c818 100644 --- a/bti.c +++ b/bti.c @@ -336,8 +336,11 @@ static void parse_configfile(struct session *session) session->host = HOST_IDENTICA; free(host); } - if (proxy) + if (proxy) { + if (session->proxy) + free(session->proxy); session->proxy = proxy; + } /* Free buffer and close file. */ free(line); @@ -351,6 +354,7 @@ int main(int argc, char *argv[], char *envp[]) { "account", 1, NULL, 'a' }, { "password", 1, NULL, 'p' }, { "host", 1, NULL, 'H' }, + { "proxy", 1, NULL, 'P' }, { "help", 0, NULL, 'h' }, { "bash", 0, NULL, 'b' }, { "version", 0, NULL, 'v' }, @@ -361,6 +365,7 @@ int main(int argc, char *argv[], char *envp[]) char *tweet; int retval; int option; + char *http_proxy; #if 0 char *home = getenv("HOME"); char *pwd = getenv("PWD"); @@ -373,10 +378,21 @@ int main(int argc, char *argv[], char *envp[]) } curl_global_init(CURL_GLOBAL_ALL); + + /* Set environment variables first, before reading command line options + * or config file values. */ + http_proxy = getenv("http_proxy"); + if (http_proxy) { + if (session->proxy) + free(session->proxy); + session->proxy = strdup(http_proxy); + dbg("http_proxy = %s\n", session->proxy); + } + parse_configfile(session); while (1) { - option = getopt_long_only(argc, argv, "dqe:p:H:a:h", + option = getopt_long_only(argc, argv, "dqe:p:P:H:a:h", options, NULL); if (option == -1) break; @@ -396,6 +412,12 @@ int main(int argc, char *argv[], char *envp[]) session->password = strdup(optarg); dbg("password = %s\n", session->password); break; + case 'P': + if (session->proxy) + free(session->proxy); + session->proxy = strdup(optarg); + dbg("proxy = %s\n", session->proxy); + break; case 'H': if (strcasecmp(optarg, "twitter") == 0) session->host = HOST_TWITTER; diff --git a/bti.xml b/bti.xml index d4d73fd..96f424a 100644 --- a/bti.xml +++ b/bti.xml @@ -81,7 +81,8 @@ only needed by systems that are behind a http proxy. - If no host is specified, the default is to send to twitter.com. + If --proxy is not specified but the environment variable + 'http_proxy' is set the latter will be used. @@ -203,6 +204,27 @@ bti.example in the source tree that shows the structure of the file if you need an example to work off of. + + Configuration options have the following priority: + + + + + command line option + + + + config file option + + + + environment variables + + + + For example, command line options always override any config file + option, or any environment variables. + AUTHOR -- 2.20.1