+static void log_session(struct session *session, int retval)
+{
+ FILE *log_file;
+ char *filename;
+ char *host;
+
+ /* logfile is ~/.bti.log */
+ filename = alloca(strlen(session->homedir) + 10);
+
+ sprintf(filename, "%s/.bti.log", session->homedir);
+
+ log_file = fopen(filename, "a+");
+ if (log_file == NULL)
+ return;
+ switch (session->host) {
+ case HOST_TWITTER:
+ host = "twitter";
+ break;
+ case HOST_IDENTICA:
+ host = "identi.ca";
+ break;
+ default:
+ host = "unknown";
+ break;
+ }
+
+ if (retval)
+ fprintf(log_file, "%s: host=%s tweet failed\n", session->time, host);
+ else
+ fprintf(log_file, "%s: host=%s tweet=%s\n", session->time, host, session->tweet);
+
+ fclose(log_file);
+}
+