#include <sys/types.h> #include <stdio.h> #include <unistd.h> #include <sys/stat.h> #include <string.h> #include <stdarg.h> #include <ctype.h> #include <stdlib.h> #include "mud.h" /* * MySQL_log_logins() * * Logs commings and goings in database vand_logins. * Nify if you ask me, expandable =) */ void MySQL_log_logins(char * txt, ...) { char query[MAX_BUFFER]; char buf[MAX_BUFFER]; va_list args; va_start(args, txt); vsprintf(buf, txt, args); va_end(args); snprintf(query, sizeof(query) + 1, "INSERT INTO `vand_logins` ( `id` , `time` , `whowhat` ) VALUES ( NULL , NOW( ) , '%s' );", buf); MySQLQuery(query); return; } /* * MySQL_clear_logins() * * Clears login data. */ void MySQL_clear_logins (void) { char query[MAX_BUFFER]; snprintf(query, sizeof(query) + 1, "TRUNCATE TABLE `vand_logins` "); MySQLQuery(query); return; } /* * MySQL_log_chat() * * Logs chat messages, requires text, who and channel. */ void MySQL_log_chat(char * who, char * channel, char * txt) { char query[MAX_BUFFER]; snprintf(query, sizeof(query) + 1, "INSERT INTO `vand_chatlog` ( `id` , `who` , `channel` , `text` , `time` ) VALUES ( NULL , '%s', '%s', '%s', NOW( ) );", who, channel, txt); MySQLQuery(query); return; } /* * MySQL_clear_logins() * * Clears login data. */ void MySQL_clear_chatlog (void) { char query[MAX_BUFFER]; snprintf(query, sizeof(query) + 1, "TRUNCATE TABLE `vand_chatlog` "); MySQLQuery(query); return; }