[mw-devel] MW3 r1079 - trunk/src

arthur at sucs.org arthur at sucs.org
Tue Mar 17 20:36:12 GMT 2009


Author: arthur
Date: 2009-03-17 20:36:12 +0000 (Tue, 17 Mar 2009)
New Revision: 1079

Modified:
   trunk/src/log.c
   trunk/src/log.h
   trunk/src/newmain.c
Log:
might as well record the status/doing string as well, closes #37


Modified: trunk/src/log.c
===================================================================
--- trunk/src/log.c	2009-03-16 18:30:52 UTC (rev 1078)
+++ trunk/src/log.c	2009-03-17 20:36:12 UTC (rev 1079)
@@ -343,3 +343,23 @@
 	free(tag);
 	return NULL;
 }
+
+/* store the doing/status string in the db */
+void catchdoing(const char *what)
+{
+	char path[1024];
+	struct db_result *res;
+
+	snprintf(path,sizeof(path),"%s/mwuri.db", STATEDIR);
+	char *query = sqlite3_mprintf("INSERT INTO mwdoing (user, added, doing) values (%Q,datetime('now'),%Q)", user->name, what);
+	res = db_query(path, query, 1);
+	if (res == NULL) {
+		res = db_query(path, "CREATE TABLE mwdoing (id INTEGER PRIMARY KEY AUTOINCREMENT, user text, added text, doing text )", 0);
+		if (res != NULL) {
+			db_free(res);
+			res = db_query(path, query, 0);
+		}
+	}
+	db_free(res);
+	sqlite3_free(query);
+}

Modified: trunk/src/log.h
===================================================================
--- trunk/src/log.h	2009-03-16 18:30:52 UTC (rev 1078)
+++ trunk/src/log.h	2009-03-17 20:36:12 UTC (rev 1079)
@@ -1,2 +1,3 @@
 /* log.c */
 void catchuri(const char *what);
+void catchdoing(const char *what);

Modified: trunk/src/newmain.c
===================================================================
--- trunk/src/newmain.c	2009-03-16 18:30:52 UTC (rev 1078)
+++ trunk/src/newmain.c	2009-03-17 20:36:12 UTC (rev 1079)
@@ -18,6 +18,7 @@
 #include "talker_privs.h"
 #include "special.h"
 #include "ipc.h"
+#include "log.h"
 
 #include "alias.h"
 extern Alias alias_list;
@@ -463,6 +464,7 @@
 		user->dowhen = time(0);
 		update_user(user,userposn);
 		broadcast(5, "%s %s", user->name, user->doing);
+		catchdoing(user->doing);
 	} else {
 		user->doing[0] = 0;
 		user->dowhen = time(0);





More information about the mw-devel mailing list