2 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
3 * Copyright (C) 2009 Bart Trojanowski <bart@jukie.net>
4 * Copyright (C) 2009 Amir Mohammad Saied <amirsaied@gmail.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33 #include <sys/types.h>
35 #include <curl/curl.h>
36 #include <readline/readline.h>
37 #include <libxml/xmlmemory.h>
38 #include <libxml/parser.h>
39 #include <libxml/tree.h>
44 #define zalloc(size) calloc(size, 1)
46 #define dbg(format, arg...) \
49 fprintf(stdout, "bti: %s: " format , __func__ , \
93 struct bti_curl_buffer {
99 static void display_help(void)
101 fprintf(stdout, "bti - send tweet to twitter or identi.ca\n");
102 fprintf(stdout, "Version: " VERSION "\n");
103 fprintf(stdout, "Usage:\n");
104 fprintf(stdout, " bti [options]\n");
105 fprintf(stdout, "options are:\n");
106 fprintf(stdout, " --account accountname\n");
107 fprintf(stdout, " --password password\n");
108 fprintf(stdout, " --action action\n");
109 fprintf(stdout, " ('update', 'friends', 'public', 'replies', "
110 "'group' or 'user')\n");
111 fprintf(stdout, " --user screenname\n");
112 fprintf(stdout, " --group groupname\n");
113 fprintf(stdout, " --proxy PROXY:PORT\n");
114 fprintf(stdout, " --host HOST\n");
115 fprintf(stdout, " --logfile logfile\n");
116 fprintf(stdout, " --shrink-urls\n");
117 fprintf(stdout, " --page PAGENUMBER\n");
118 fprintf(stdout, " --bash\n");
119 fprintf(stdout, " --debug\n");
120 fprintf(stdout, " --verbose\n");
121 fprintf(stdout, " --dry-run\n");
122 fprintf(stdout, " --version\n");
123 fprintf(stdout, " --help\n");
126 static void display_version(void)
128 fprintf(stdout, "bti - version %s\n", VERSION);
131 static struct session *session_alloc(void)
133 struct session *session;
135 session = zalloc(sizeof(*session));
141 static void session_free(struct session *session)
145 free(session->password);
146 free(session->account);
147 free(session->tweet);
148 free(session->proxy);
150 free(session->homedir);
152 free(session->group);
153 free(session->hosturl);
154 free(session->hostname);
158 static struct bti_curl_buffer *bti_curl_buffer_alloc(enum action action)
160 struct bti_curl_buffer *buffer;
162 buffer = zalloc(sizeof(*buffer));
166 /* start out with a data buffer of 1 byte to
167 * make the buffer fill logic simpler */
168 buffer->data = zalloc(1);
174 buffer->action = action;
178 static void bti_curl_buffer_free(struct bti_curl_buffer *buffer)
186 static const char *twitter_host = "https://twitter.com/statuses";
187 static const char *identica_host = "https://identi.ca/api/statuses";
188 static const char *twitter_name = "twitter";
189 static const char *identica_name = "identi.ca";
191 static const char *user_uri = "/user_timeline/";
192 static const char *update_uri = "/update.xml";
193 static const char *public_uri = "/public_timeline.xml";
194 static const char *friends_uri = "/friends_timeline.xml";
195 static const char *replies_uri = "/replies.xml";
196 static const char *group_uri = "/../laconica/groups/timeline/";
198 static CURL *curl_init(void)
202 curl = curl_easy_init();
204 fprintf(stderr, "Can not init CURL!\n");
207 /* some ssl sanity checks on the connection we are making */
208 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
209 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
213 static void parse_statuses(xmlDocPtr doc, xmlNodePtr current)
215 xmlChar *text = NULL;
216 xmlChar *user = NULL;
217 xmlChar *created = NULL;
220 current = current->xmlChildrenNode;
221 while (current != NULL) {
222 if (current->type == XML_ELEMENT_NODE) {
223 if (!xmlStrcmp(current->name, (const xmlChar *)"created_at"))
224 created = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
225 if (!xmlStrcmp(current->name, (const xmlChar *)"text"))
226 text = xmlNodeListGetString(doc, current->xmlChildrenNode, 1);
227 if (!xmlStrcmp(current->name, (const xmlChar *)"user")) {
228 userinfo = current->xmlChildrenNode;
229 while (userinfo != NULL) {
230 if ((!xmlStrcmp(userinfo->name, (const xmlChar *)"screen_name"))) {
233 user = xmlNodeListGetString(doc, userinfo->xmlChildrenNode, 1);
235 userinfo = userinfo->next;
239 if (user && text && created) {
241 printf("[%s] (%.16s) %s\n",
242 user, created, text);
254 current = current->next;
260 static void parse_timeline(char *document)
265 doc = xmlReadMemory(document, strlen(document), "timeline.xml",
266 NULL, XML_PARSE_NOERROR);
270 current = xmlDocGetRootElement(doc);
271 if (current == NULL) {
272 fprintf(stderr, "empty document\n");
277 if (xmlStrcmp(current->name, (const xmlChar *) "statuses")) {
278 fprintf(stderr, "unexpected document type\n");
283 current = current->xmlChildrenNode;
284 while (current != NULL) {
285 if ((!xmlStrcmp(current->name, (const xmlChar *)"status")))
286 parse_statuses(doc, current);
287 current = current->next;
294 static size_t curl_callback(void *buffer, size_t size, size_t nmemb,
297 struct bti_curl_buffer *curl_buf = userp;
298 size_t buffer_size = size * nmemb;
301 if ((!buffer) || (!buffer_size) || (!curl_buf))
304 /* add to the data we already have */
305 temp = zalloc(curl_buf->length + buffer_size + 1);
309 memcpy(temp, curl_buf->data, curl_buf->length);
310 free(curl_buf->data);
311 curl_buf->data = temp;
312 memcpy(&curl_buf->data[curl_buf->length], (char *)buffer, buffer_size);
313 curl_buf->length += buffer_size;
314 if (curl_buf->action)
315 parse_timeline(curl_buf->data);
317 dbg("%s\n", curl_buf->data);
322 static int send_request(struct session *session)
325 char user_password[500];
327 struct bti_curl_buffer *curl_buf;
330 struct curl_httppost *formpost = NULL;
331 struct curl_httppost *lastptr = NULL;
332 struct curl_slist *slist = NULL;
337 curl_buf = bti_curl_buffer_alloc(session->action);
345 switch (session->action) {
347 snprintf(user_password, sizeof(user_password), "%s:%s",
348 session->account, session->password);
349 snprintf(data, sizeof(data), "status=\"%s\"", session->tweet);
350 curl_formadd(&formpost, &lastptr,
351 CURLFORM_COPYNAME, "status",
352 CURLFORM_COPYCONTENTS, session->tweet,
355 curl_formadd(&formpost, &lastptr,
356 CURLFORM_COPYNAME, "source",
357 CURLFORM_COPYCONTENTS, "bti",
360 curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
361 slist = curl_slist_append(slist, "Expect:");
362 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
364 sprintf(endpoint, "%s%s", session->hosturl, update_uri);
365 curl_easy_setopt(curl, CURLOPT_URL, endpoint);
366 curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
370 snprintf(user_password, sizeof(user_password), "%s:%s",
371 session->account, session->password);
372 sprintf(endpoint, "%s%s?page=%d", session->hosturl,
373 friends_uri, session->page);
374 curl_easy_setopt(curl, CURLOPT_URL, endpoint);
375 curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
379 sprintf(endpoint, "%s%s%s.xml?page=%d", session->hosturl,
380 user_uri, session->user, session->page);
381 curl_easy_setopt(curl, CURLOPT_URL, endpoint);
385 snprintf(user_password, sizeof(user_password), "%s:%s",
386 session->account, session->password);
387 sprintf(endpoint, "%s%s?page=%d", session->hosturl, replies_uri,
389 curl_easy_setopt(curl, CURLOPT_URL, endpoint);
390 curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
394 sprintf(endpoint, "%s%s?page=%d", session->hosturl, public_uri,
396 curl_easy_setopt(curl, CURLOPT_URL, endpoint);
400 sprintf(endpoint, "%s%s%s.xml?page=%d", session->hosturl,
401 group_uri, session->group, session->page);
402 curl_easy_setopt(curl, CURLOPT_URL, endpoint);
410 curl_easy_setopt(curl, CURLOPT_PROXY, session->proxy);
413 curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
415 dbg("user_password = %s\n", user_password);
416 dbg("data = %s\n", data);
417 dbg("proxy = %s\n", session->proxy);
419 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_callback);
420 curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf);
421 if (!session->dry_run) {
422 res = curl_easy_perform(curl);
423 if (res && !session->bash) {
424 fprintf(stderr, "error(%d) trying to perform "
430 curl_easy_cleanup(curl);
431 if (session->action == ACTION_UPDATE)
432 curl_formfree(formpost);
433 bti_curl_buffer_free(curl_buf);
437 static void parse_configfile(struct session *session)
442 char *account = NULL;
443 char *password = NULL;
446 char *logfile = NULL;
452 /* config file is ~/.bti */
453 file = alloca(strlen(session->homedir) + 7);
455 sprintf(file, "%s/.bti", session->homedir);
457 config_file = fopen(file, "r");
459 /* No error if file does not exist or is unreadable. */
460 if (config_file == NULL)
464 ssize_t n = getline(&line, &len, config_file);
467 if (line[n - 1] == '\n')
469 /* Parse file. Format is the usual value pairs:
472 # is a comment character
474 *strchrnul(line, '#') = '\0';
478 /* Ignore blank lines. */
482 if (!strncasecmp(c, "account", 7) && (c[7] == '=')) {
486 } else if (!strncasecmp(c, "password", 8) &&
490 password = strdup(c);
491 } else if (!strncasecmp(c, "host", 4) &&
496 } else if (!strncasecmp(c, "proxy", 5) &&
501 } else if (!strncasecmp(c, "logfile", 7) &&
506 } else if (!strncasecmp(c, "action", 6) &&
511 } else if (!strncasecmp(c, "user", 4) &&
516 } else if (!strncasecmp(c, "shrink-urls", 11) &&
519 if (!strncasecmp(c, "true", 4) ||
520 !strncasecmp(c, "yes", 3))
522 } else if (!strncasecmp(c, "verbose", 7) &&
525 if (!strncasecmp(c, "true", 4) ||
526 !strncasecmp(c, "yes", 3))
529 } while (!feof(config_file));
532 session->password = password;
534 session->account = account;
536 if (strcasecmp(host, "twitter") == 0) {
537 session->host = HOST_TWITTER;
538 session->hosturl = strdup(twitter_host);
539 session->hostname = strdup(twitter_name);
540 } else if (strcasecmp(host, "identica") == 0) {
541 session->host = HOST_IDENTICA;
542 session->hosturl = strdup(identica_host);
543 session->hostname = strdup(identica_name);
545 session->host = HOST_CUSTOM;
546 session->hosturl = strdup(host);
547 session->hostname = strdup(host);
553 free(session->proxy);
554 session->proxy = proxy;
557 session->logfile = logfile;
559 if (strcasecmp(action, "update") == 0)
560 session->action = ACTION_UPDATE;
561 else if (strcasecmp(action, "friends") == 0)
562 session->action = ACTION_FRIENDS;
563 else if (strcasecmp(action, "user") == 0)
564 session->action = ACTION_USER;
565 else if (strcasecmp(action, "replies") == 0)
566 session->action = ACTION_REPLIES;
567 else if (strcasecmp(action, "public") == 0)
568 session->action = ACTION_PUBLIC;
569 else if (strcasecmp(action, "group") == 0)
570 session->action = ACTION_GROUP;
572 session->action = ACTION_UNKNOWN;
576 session->user = user;
577 session->shrink_urls = shrink_urls;
579 /* Free buffer and close file. */
584 static void log_session(struct session *session, int retval)
589 /* Only log something if we have a log file set */
590 if (!session->logfile)
593 filename = alloca(strlen(session->homedir) +
594 strlen(session->logfile) + 3);
596 sprintf(filename, "%s/%s", session->homedir, session->logfile);
598 log_file = fopen(filename, "a+");
599 if (log_file == NULL)
602 switch (session->action) {
605 fprintf(log_file, "%s: host=%s tweet failed\n",
606 session->time, session->hostname);
608 fprintf(log_file, "%s: host=%s tweet=%s\n",
609 session->time, session->hostname, session->tweet);
612 fprintf(log_file, "%s: host=%s retrieving friends timeline\n",
613 session->time, session->hostname);
616 fprintf(log_file, "%s: host=%s retrieving %s's timeline\n",
617 session->time, session->hostname, session->user);
620 fprintf(log_file, "%s: host=%s retrieving replies\n",
621 session->time, session->hostname);
624 fprintf(log_file, "%s: host=%s retrieving public timeline\n",
625 session->time, session->hostname);
628 fprintf(log_file, "%s: host=%s retrieving group timeline\n",
629 session->time, session->hostname);
638 static char *get_string_from_stdin(void)
643 string = zalloc(1000);
647 if (!fgets(string, 999, stdin))
649 temp = strchr(string, '\n');
654 static void read_password(char *buf, size_t len, char *host)
664 tp.c_lflag &= (~ECHO);
665 tcsetattr(0, TCSANOW, &tp);
667 fprintf(stdout, "Enter password for %s: ", host);
670 retval = scanf("%79s", pwd);
672 fprintf(stdout, "\n");
674 tcsetattr(0, TCSANOW, &old);
676 strncpy(buf, pwd, len);
680 static int find_urls(const char *tweet, int **pranges)
683 * magic obtained from
684 * http://www.geekpedia.com/KB65_How-to-validate-an-URL-using-RegEx-in-Csharp.html
686 static const char *re_magic =
687 "(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)/{1,3}"
688 "[0-9a-zA-Z;/~?:@&=+$\\.\\-_'()%]+)"
689 "(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?";
693 int ovector[10] = {0,};
694 const size_t ovsize = sizeof(ovector)/sizeof(*ovector);
695 int startoffset, tweetlen;
699 int *ranges = malloc(sizeof(int) * rbound);
701 re = pcre_compile(re_magic,
702 PCRE_NO_AUTO_CAPTURE,
703 &errptr, &erroffset, NULL);
705 fprintf(stderr, "pcre_compile @%u: %s\n", erroffset, errptr);
709 tweetlen = strlen(tweet);
710 for (startoffset = 0; startoffset < tweetlen; ) {
712 rc = pcre_exec(re, NULL, tweet, strlen(tweet), startoffset, 0,
714 if (rc == PCRE_ERROR_NOMATCH)
718 fprintf(stderr, "pcre_exec @%u: %s\n",
723 for (i = 0; i < rc; i += 2) {
724 if ((rcount+2) == rbound) {
726 ranges = realloc(ranges, sizeof(int) * rbound);
729 ranges[rcount++] = ovector[i];
730 ranges[rcount++] = ovector[i+1];
733 startoffset = ovector[1];
743 * bidirectional popen() call
745 * @param rwepipe - int array of size three
746 * @param exe - program to run
747 * @param argv - argument list
748 * @return pid or -1 on error
750 * The caller passes in an array of three integers (rwepipe), on successful
751 * execution it can then write to element 0 (stdin of exe), and read from
752 * element 1 (stdout) and 2 (stderr).
754 static int popenRWE(int *rwepipe, const char *exe, const char *const argv[])
784 } else if (pid == 0) {
796 execvp(exe, (char **)argv);
816 static int pcloseRWE(int pid, int *rwepipe)
822 rc = waitpid(pid, &status, 0);
826 static char *shrink_one_url(int *rwepipe, char *big)
828 int biglen = strlen(big);
833 rc = dprintf(rwepipe[0], "%s\n", big);
837 smalllen = biglen + 128;
838 small = malloc(smalllen);
842 rc = read(rwepipe[1], small, smalllen);
843 if (rc < 0 || rc > biglen)
844 goto error_free_small;
846 if (strncmp(small, "http://", 7))
847 goto error_free_small;
850 while (smalllen && isspace(small[smalllen-1]))
851 small[--smalllen] = 0;
861 static char *shrink_urls(char *text)
868 const char *const shrink_args[] = {
874 int inlen = strlen(text);
876 dbg("before len=%u\n", inlen);
878 shrink_pid = popenRWE(shrink_pipe, shrink_args[0], shrink_args);
882 rcount = find_urls(text, &ranges);
886 for (i = 0; i < rcount; i += 2) {
887 int url_start = ranges[i];
888 int url_end = ranges[i+1];
889 int long_url_len = url_end - url_start;
890 char *url = strndup(text + url_start, long_url_len);
892 int not_url_len = url_start - inofs;
894 dbg("long url[%u]: %s\n", long_url_len, url);
895 url = shrink_one_url(shrink_pipe, url);
896 short_url_len = url ? strlen(url) : 0;
897 dbg("short url[%u]: %s\n", short_url_len, url);
899 if (!url || short_url_len >= long_url_len) {
900 /* The short url ended up being too long
903 strncpy(text + outofs, text + inofs,
904 not_url_len + long_url_len);
906 inofs += not_url_len + long_url_len;
907 outofs += not_url_len + long_url_len;
910 /* copy the unmodified block */
911 strncpy(text + outofs, text + inofs, not_url_len);
912 inofs += not_url_len;
913 outofs += not_url_len;
915 /* copy the new url */
916 strncpy(text + outofs, url, short_url_len);
917 inofs += long_url_len;
918 outofs += short_url_len;
924 /* copy the last block after the last match */
926 int tail = inlen - inofs;
928 strncpy(text + outofs, text + inofs, tail);
935 (void)pcloseRWE(shrink_pid, shrink_pipe);
938 dbg("after len=%u\n", outofs);
942 int main(int argc, char *argv[], char *envp[])
944 static const struct option options[] = {
945 { "debug", 0, NULL, 'd' },
946 { "verbose", 0, NULL, 'V' },
947 { "account", 1, NULL, 'a' },
948 { "password", 1, NULL, 'p' },
949 { "host", 1, NULL, 'H' },
950 { "proxy", 1, NULL, 'P' },
951 { "action", 1, NULL, 'A' },
952 { "user", 1, NULL, 'u' },
953 { "group", 1, NULL, 'G' },
954 { "logfile", 1, NULL, 'L' },
955 { "shrink-urls", 0, NULL, 's' },
956 { "help", 0, NULL, 'h' },
957 { "bash", 0, NULL, 'b' },
958 { "dry-run", 0, NULL, 'n' },
959 { "page", 1, NULL, 'g' },
960 { "version", 0, NULL, 'v' },
963 struct session *session;
966 static char password[80];
975 rl_bind_key('\t', rl_insert);
977 session = session_alloc();
979 fprintf(stderr, "no more memory...\n");
983 /* get the current time so that we can log it later */
985 session->time = strdup(ctime(&t));
986 session->time[strlen(session->time)-1] = 0x00;
988 session->homedir = strdup(getenv("HOME"));
990 curl_global_init(CURL_GLOBAL_ALL);
992 /* Set environment variables first, before reading command line options
993 * or config file values. */
994 http_proxy = getenv("http_proxy");
997 free(session->proxy);
998 session->proxy = strdup(http_proxy);
999 dbg("http_proxy = %s\n", session->proxy);
1002 parse_configfile(session);
1005 option = getopt_long_only(argc, argv, "dp:P:H:a:A:u:hg:G:snVv",
1017 if (session->account)
1018 free(session->account);
1019 session->account = strdup(optarg);
1020 dbg("account = %s\n", session->account);
1023 page_nr = atoi(optarg);
1024 dbg("page = %d\n", page_nr);
1025 session->page = page_nr;
1028 if (session->password)
1029 free(session->password);
1030 session->password = strdup(optarg);
1031 dbg("password = %s\n", session->password);
1035 free(session->proxy);
1036 session->proxy = strdup(optarg);
1037 dbg("proxy = %s\n", session->proxy);
1040 if (strcasecmp(optarg, "update") == 0)
1041 session->action = ACTION_UPDATE;
1042 else if (strcasecmp(optarg, "friends") == 0)
1043 session->action = ACTION_FRIENDS;
1044 else if (strcasecmp(optarg, "user") == 0)
1045 session->action = ACTION_USER;
1046 else if (strcasecmp(optarg, "replies") == 0)
1047 session->action = ACTION_REPLIES;
1048 else if (strcasecmp(optarg, "public") == 0)
1049 session->action = ACTION_PUBLIC;
1050 else if (strcasecmp(optarg, "group") == 0)
1051 session->action = ACTION_GROUP;
1053 session->action = ACTION_UNKNOWN;
1054 dbg("action = %d\n", session->action);
1058 free(session->user);
1059 session->user = strdup(optarg);
1060 dbg("user = %s\n", session->user);
1065 free(session->group);
1066 session->group = strdup(optarg);
1067 dbg("group = %s\n", session->group);
1070 if (session->logfile)
1071 free(session->logfile);
1072 session->logfile = strdup(optarg);
1073 dbg("logfile = %s\n", session->logfile);
1076 session->shrink_urls = 1;
1079 if (session->hosturl)
1080 free(session->hosturl);
1081 if (session->hostname)
1082 free(session->hostname);
1083 if (strcasecmp(optarg, "twitter") == 0) {
1084 session->host = HOST_TWITTER;
1085 session->hosturl = strdup(twitter_host);
1086 session->hostname = strdup(twitter_name);
1087 } else if (strcasecmp(optarg, "identica") == 0) {
1088 session->host = HOST_IDENTICA;
1089 session->hosturl = strdup(identica_host);
1090 session->hostname = strdup(identica_name);
1092 session->host = HOST_CUSTOM;
1093 session->hosturl = strdup(optarg);
1094 session->hostname = strdup(optarg);
1096 dbg("host = %d\n", session->host);
1105 session->dry_run = 1;
1117 * Show the version to make it easier to determine what
1123 if (session->action == ACTION_UNKNOWN) {
1124 fprintf(stderr, "Unknown action, valid actions are:\n");
1125 fprintf(stderr, "'update', 'friends', 'public', "
1126 "'replies', 'group' or 'user'.\n");
1130 if (!session->host) {
1131 fprintf(stderr, "You need to provide a host either in ~/.bti or with --host.\n");
1135 if (session->host == HOST_TWITTER && session->action == ACTION_GROUP) {
1136 fprintf(stderr, "Groups only work in Identi.ca.\n");
1140 if (session->action == ACTION_GROUP && !session->group) {
1141 fprintf(stdout, "Enter group name: ");
1142 session->group = readline(NULL);
1145 if (!session->account) {
1146 fprintf(stdout, "Enter account for %s: ", session->hostname);
1147 session->account = readline(NULL);
1150 if (!session->password) {
1151 read_password(password, sizeof(password), session->hostname);
1152 session->password = strdup(password);
1155 if (session->action == ACTION_UPDATE) {
1157 tweet = get_string_from_stdin();
1159 tweet = readline("tweet: ");
1160 if (!tweet || strlen(tweet) == 0) {
1165 if (session->shrink_urls)
1166 tweet = shrink_urls(tweet);
1168 session->tweet = zalloc(strlen(tweet) + 10);
1170 sprintf(session->tweet, "%c %s",
1171 getuid() ? '$' : '#', tweet);
1173 sprintf(session->tweet, "%s", tweet);
1176 dbg("tweet = %s\n", session->tweet);
1180 session->user = strdup(session->account);
1182 if (session->page == 0)
1184 dbg("account = %s\n", session->account);
1185 dbg("password = %s\n", session->password);
1186 dbg("host = %d\n", session->host);
1187 dbg("action = %d\n", session->action);
1189 /* fork ourself so that the main shell can get on
1190 * with it's life as we try to connect and handle everything
1192 if (session->bash) {
1195 dbg("child is %d\n", child);
1200 retval = send_request(session);
1201 if (retval && !session->bash)
1202 fprintf(stderr, "operation failed\n");
1204 log_session(session, retval);
1206 session_free(session);