char *password;
char *account;
char *tweet;
+ char *proxy;
int bash;
enum host host;
};
fprintf(stdout, "options are:\n");
fprintf(stdout, " --account accountname\n");
fprintf(stdout, " --password password\n");
+ fprintf(stdout, " --proxy PROXY:PORT\n");
fprintf(stdout, " --host HOST\n");
fprintf(stdout, " --bash\n");
fprintf(stdout, " --debug\n");
free(session->password);
free(session->account);
free(session->tweet);
+ free(session->proxy);
free(session);
}
CURLcode res;
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
+ struct curl_slist *slist = NULL;
if (!session)
return -EINVAL;
switch (session->host) {
case HOST_TWITTER:
curl_easy_setopt(curl, CURLOPT_URL, twitter_url);
+ /*
+ * twitter doesn't like the "Expect: 100-continue" header
+ * anymore, so turn it off.
+ */
+ slist = curl_slist_append(slist, "Expect:");
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
break;
case HOST_IDENTICA:
curl_easy_setopt(curl, CURLOPT_URL, identica_url);
break;
}
+ if (session->proxy)
+ curl_easy_setopt(curl, CURLOPT_PROXY, session->proxy);
+
if (debug)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
dbg("user_password = %s\n", user_password);
dbg("data = %s\n", data);
+ dbg("proxy = %s\n", session->proxy);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf);
char *account = NULL;
char *password = NULL;
char *host = NULL;
+ char *proxy = NULL;
char *file;
char *home = getenv("HOME");
c += 5;
if (c[0] != '\0')
host = strdup(c);
+ } else if (!strncasecmp(c, "proxy", 5) &&
+ (c[5] == '=')) {
+ c += 6;
+ if (c[0] != '\0')
+ proxy = strdup(c);
}
} while (!feof(config_file));
session->host = HOST_IDENTICA;
free(host);
}
+ if (proxy) {
+ if (session->proxy)
+ free(session->proxy);
+ session->proxy = proxy;
+ }
/* Free buffer and close file. */
free(line);
{ "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' },
char *tweet;
int retval;
int option;
+ char *http_proxy;
#if 0
char *home = getenv("HOME");
char *pwd = getenv("PWD");
}
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;
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;