[ekg2-commit] ekg2: sniff.c (HEAD) [darkjames]
CVS commit
cvs w toxygen.net
Wto, 22 Maj 2007, 12:34:47 CEST
Module name: ekg2
Changes by: darkjames 2007-05-22 12:34:44
Modified files:
sniff.c
Log message:
implement timestamp in sniffed messages...
Index: sniff.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/sniff/sniff.c,v
diff -d -u -r1.46 -r1.47
--- sniff.c 3 May 2007 09:45:11 -0000 1.46
+++ sniff.c 22 May 2007 10:34:44 -0000 1.47
@@ -292,14 +292,24 @@
}
/* ****************************************************** */
-static void sniff_gg_print_message(session_t *s, const connection_t *hdr, uint32_t recpt, enum msgclass_t type, const char *msg) {
+static void sniff_gg_print_message(session_t *s, const connection_t *hdr, uint32_t recpt, enum msgclass_t type, const char *msg, time_t sent) {
+ struct tm *tm_msg;
+ char timestamp[100] = { '\0' };
+ const char *timestamp_f;
+
const char *sender = build_gg_uid(recpt);
+ tm_msg = localtime(&sent);
+ timestamp_f = format_find((type == EKG_MSGCLASS_CHAT) ? "sent_timestamp" : "chat_timestamp");
+
+ if (timestamp_f[0] && !strftime(timestamp, sizeof(timestamp), timestamp_f, tm_msg))
+ xstrcpy(timestamp, "TOOLONG");
+
print_window(build_windowip_name(type == EKG_MSGCLASS_CHAT ? hdr->dstip : hdr->srcip) /* ip and/or gg# */, s, 1,
type == EKG_MSGCLASS_CHAT ? "message" : "sent", /* formatka */
format_user(s, sender), /* do kogo */
- "timestamp", /* XXX timestamp */
+ timestamp, /* timestamp */
msg, /* wiadomosc */
get_nickname(s, sender), /* jego nickname */
sender, /* jego uid */
@@ -378,7 +388,7 @@
CHECK_LEN(sizeof(gg_recv_msg)) len -= sizeof(gg_recv_msg);
msg = gg_cp_to_iso(xstrndup(pkt->msg_data, len));
- sniff_gg_print_message(s, hdr, pkt->sender, EKG_MSGCLASS_CHAT, msg);
+ sniff_gg_print_message(s, hdr, pkt->sender, EKG_MSGCLASS_CHAT, msg, pkt->time);
xfree(msg);
return 0;
}
@@ -388,7 +398,7 @@
CHECK_LEN(sizeof(gg_send_msg)) len -= sizeof(gg_send_msg);
msg = gg_cp_to_iso(xstrndup(pkt->msg_data, len));
- sniff_gg_print_message(s, hdr, pkt->recipient, EKG_MSGCLASS_SENT_CHAT, msg);
+ sniff_gg_print_message(s, hdr, pkt->recipient, EKG_MSGCLASS_SENT_CHAT, msg, time(NULL));
xfree(msg);
return 0;
Więcej informacji o liście dyskusyjnej ekg2-commit