comparison mcabber/src/histolog.c @ 184:b5aa2b9c425a

[/trunk] Changeset 196 by mikael * Don't use a char* as prefix, but split it to timestamp + flags. * Don't use a boolean for timestamp, use a time_t (actually we always use a timestamp so the bool made no sense...).
author mikael
date Thu, 05 May 2005 19:38:44 +0000
parents c658c131ea10
children 888ad9f15346
comparison
equal deleted inserted replaced
183:c658c131ea10 184:b5aa2b9c425a
99 // hlog_read_history() 99 // hlog_read_history()
100 // Reads the jid's history logfile 100 // Reads the jid's history logfile
101 void hlog_read_history(const char *jid, GList **p_buddyhbuf, guint width) 101 void hlog_read_history(const char *jid, GList **p_buddyhbuf, guint width)
102 { 102 {
103 char *filename; 103 char *filename;
104 time_t timestamp;
105 guchar type, info; 104 guchar type, info;
106 char *data, *tail; 105 char *data, *tail;
106 time_t timestamp;
107 guint prefix_flags;
107 guint len; 108 guint len;
108 FILE *fp; 109 FILE *fp;
109 char prefix[32];
110 110
111 if (!FileLoadLogs) return; 111 if (!FileLoadLogs) return;
112 112
113 data = g_new(char, HBB_BLOCKSIZE+32); 113 data = g_new(char, HBB_BLOCKSIZE+32);
114 if (!data) { 114 if (!data) {
153 } 153 }
154 if ((tail > data+18) && (*(tail-1) == '\n')) 154 if ((tail > data+18) && (*(tail-1) == '\n'))
155 *(tail-1) = 0; 155 *(tail-1) = 0;
156 156
157 if (type == 'M') { 157 if (type == 'M') {
158 strftime(prefix, 12, "[%H:%M] ", localtime(&timestamp));
159 if (info == 'S') 158 if (info == 'S')
160 strcat(prefix, "--> "); 159 prefix_flags = HBB_PREFIX_OUT;
161 else 160 else
162 strcat(prefix, "<== "); 161 prefix_flags = HBB_PREFIX_IN;
163 hbuf_add_line(p_buddyhbuf, &data[18], prefix, width); 162 hbuf_add_line(p_buddyhbuf, &data[18], timestamp, prefix_flags, width);
164 } 163 }
165 } 164 }
166 fclose(fp); 165 fclose(fp);
167 g_free(data); 166 g_free(data);
168 } 167 }