#include <libxml/parser.h>
#include <libxml/tree.h>
#include <pcre.h>
+#include <termios.h>
#define zalloc(size) calloc(size, 1)
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
slist = curl_slist_append(slist, "Expect:");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
-
+
sprintf(endpoint, "%s%s", session->hosturl, update_uri);
curl_easy_setopt(curl, CURLOPT_URL, endpoint);
curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
break;
case ACTION_USER:
- sprintf(endpoint, "%s%s%s.xml?page=%d", session->hosturl, user_uri,
- session->user, session->page);
+ sprintf(endpoint, "%s%s%s.xml?page=%d", session->hosturl,
+ user_uri, session->user, session->page);
curl_easy_setopt(curl, CURLOPT_URL, endpoint);
break;
case ACTION_REPLIES:
snprintf(user_password, sizeof(user_password), "%s:%s",
session->account, session->password);
- sprintf(endpoint, "%s%s?page=%d", session->hosturl, replies_uri, session->page);
+ sprintf(endpoint, "%s%s?page=%d", session->hosturl, replies_uri,
+ session->page);
curl_easy_setopt(curl, CURLOPT_URL, endpoint);
curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
break;
case ACTION_PUBLIC:
- sprintf(endpoint, "%s%s?page=%d", session->hosturl, public_uri, session->page);
+ sprintf(endpoint, "%s%s?page=%d", session->hosturl, public_uri,
+ session->page);
curl_easy_setopt(curl, CURLOPT_URL, endpoint);
break;
if (!strncasecmp(c, "true", 4) ||
!strncasecmp(c, "yes", 3))
shrink_urls = 1;
- }
- else if (!strncasecmp(c, "verbose", 7) &&
+ } else if (!strncasecmp(c, "verbose", 7) &&
(c[7] == '=')) {
c += 8;
if (!strncasecmp(c, "true", 4) ||
!strncasecmp(c, "yes", 3))
verbose = 1;
- }
+ }
} while (!feof(config_file));
if (password)
return string;
}
+static void read_password(char *buf, size_t len)
+{
+ char pwd[80];
+ int retval;
+ struct termios old;
+ struct termios tp;
+
+ tcgetattr(0, &tp);
+ old = tp;
+
+ tp.c_lflag &= (~ECHO);
+ tcsetattr(0, TCSANOW, &tp);
+
+ fprintf(stdout, "Enter twitter password: ");
+ fflush(stdout);
+ tcflow(0, TCOOFF);
+ retval = scanf("%79s", pwd);
+ tcflow(0, TCOON);
+ fprintf(stdout, "\n");
+
+ tcsetattr(0, TCSANOW, &old);
+
+ strncpy(buf, pwd, len);
+ buf[len-1] = '\0';
+}
+
static int find_urls(const char *tweet, int **pranges)
{
/*
struct session *session;
pid_t child;
char *tweet;
+ static char password[80];
int retval = 0;
int option;
char *http_proxy;
* Show the version to make it easier to determine what
* is going on here
*/
- if (debug) {
+ if (debug)
display_version();
- fprintf(stderr, session->group);
- }
if (session->action == ACTION_UNKNOWN) {
fprintf(stderr, "Unknown action, valid actions are:\n");
}
if (!session->password) {
- fprintf(stdout, "Enter twitter password: ");
- session->password = readline(NULL);
+ read_password(password, sizeof(password));
+ session->password = strdup(password);
}
if (session->action == ACTION_UPDATE) {
session->tweet = zalloc(strlen(tweet) + 10);
if (session->bash)
- sprintf(session->tweet, "%c %s", getuid() ? '$' : '#', tweet);
+ sprintf(session->tweet, "%c %s",
+ getuid() ? '$' : '#', tweet);
else
sprintf(session->tweet, "%s", tweet);