diff -r edb5591e2e64 -r 8ac67e951eab mcabber/src/histolog.c --- a/mcabber/src/histolog.c Sun Apr 24 17:38:48 2005 +0000 +++ b/mcabber/src/histolog.c Sun Apr 24 20:24:18 2005 +0000 @@ -22,8 +22,13 @@ #include #include #include +#include +#include +#include +#include #include "histolog.h" +#include "jabglue.h" #include "screen.h" static guint UseFileLogging; @@ -47,12 +52,13 @@ // write() // Adds a history (multi-)line to the jid's history logfile -static void write(const char *jid, - time_t timestamp, guchar type, guchar info, char *data) +static void write_histo_line(const char *jid, + time_t timestamp, guchar type, guchar info, const char *data) { guint len = 0; + FILE *fp; time_t ts; - char *p; + const char *p; char *filename = user_histo_file(jid); if (!filename) @@ -80,8 +86,11 @@ * We don't check them, we'll trust the caller. */ - scr_LogPrint("Log to [%s]:", filename); - scr_LogPrint("%c %c %10d %03d %s", type, info, ts, len, data); + fp = fopen(filename, "a"); + if (!fp) + return; + fprintf(fp, "%c %c %10u %03d %s\n", type, info, (unsigned int)ts, len, data); + fclose(fp); } // hlog_enable() @@ -121,3 +130,18 @@ } } +inline void hlog_write_message(const char *jid, time_t timestamp, int sent, + const char *msg) +{ + write_histo_line(jid, timestamp, 'M', ((sent) ? 'S' : 'R'), msg); +} + +inline void hlog_write_status(const char *jid, time_t timestamp, + enum imstatus status) +{ + // #1 XXX Check status value? + // #2 We could add a user-readable comment + write_histo_line(jid, timestamp, 'S', toupper(imstatus2char[status]), + NULL); +} +