static int debug = 0;
+enum host {
+ HOST_TWITTER = 0,
+ HOST_IDENTICA = 1,
+};
+
struct session {
char *password;
char *account;
char *tweet;
int bash;
+ enum host host;
};
struct bti_curl_buffer {
fprintf(stdout, "options are:\n");
fprintf(stdout, " --account accountname\n");
fprintf(stdout, " --password password\n");
+ fprintf(stdout, " --host HOST\n");
fprintf(stdout, " --bash\n");
fprintf(stdout, " --debug\n");
fprintf(stdout, " --version\n");
char *temp;
char *string;
- string = zalloc(100);
+ string = zalloc(1000);
if (!string)
return NULL;
- if (!fgets(string, 99, stdin))
+ if (!fgets(string, 999, stdin))
return NULL;
temp = strchr(string, '\n');
*temp = '\0';
}
static const char *twitter_url = "https://twitter.com/statuses/update.xml";
+static const char *identica_url = "http://identi.ca/api/statuses/update.xml";
static CURL *curl_init(void)
{
CURLFORM_END);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
- curl_easy_setopt(curl, CURLOPT_URL, twitter_url);
+
+ switch (session->host) {
+ case HOST_TWITTER:
+ curl_easy_setopt(curl, CURLOPT_URL, twitter_url);
+ break;
+ case HOST_IDENTICA:
+ curl_easy_setopt(curl, CURLOPT_URL, identica_url);
+ break;
+ }
+
if (debug)
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
size_t len = 0;
char *account = NULL;
char *password = NULL;
+ char *host = NULL;
char *file;
char *home = getenv("HOME");
c += 9;
if (c[0] != '\0')
password = strdup(c);
+ } else if (!strncasecmp(c, "host", 4) &&
+ (c[4] == '=')) {
+ c += 5;
+ if (c[0] != '\0')
+ host = strdup(c);
}
} while (!feof(config_file));
if (password)
session->password = password;
if (account)
- session->account= account;
+ session->account = account;
+ if (host) {
+ if (strcasecmp(host, "twitter") == 0)
+ session->host = HOST_TWITTER;
+ if (strcasecmp(host, "identica") == 0)
+ session->host = HOST_IDENTICA;
+ free(host);
+ }
/* Free buffer and close file. */
free(line);
{ "debug", 0, NULL, 'd' },
{ "account", 1, NULL, 'a' },
{ "password", 1, NULL, 'p' },
+ { "host", 1, NULL, 'H' },
{ "help", 0, NULL, 'h' },
{ "bash", 0, NULL, 'b' },
{ "version", 0, NULL, 'v' },
parse_configfile(session);
while (1) {
- option = getopt_long_only(argc, argv, "dqe:p:a:h",
+ option = getopt_long_only(argc, argv, "dqe:p:H:a:h",
options, NULL);
if (option == -1)
break;
session->password = strdup(optarg);
dbg("password = %s\n", session->password);
break;
+ case 'H':
+ if (strcasecmp(optarg, "twitter") == 0)
+ session->host = HOST_TWITTER;
+ if (strcasecmp(optarg, "identica") == 0)
+ session->host = HOST_IDENTICA;
+ dbg("host = %d\n", session->host);
+ break;
case 'b':
session->bash= 1;
break;
dbg("account = %s\n", session->account);
dbg("password = %s\n", session->password);
dbg("tweet = %s\n", session->tweet);
+ dbg("host = %d\n", session->host);
/* fork ourself so that the main shell can get on
* with it's life as we try to connect and handle everything