]> code.citadel.org Git - citadel.git/blob - citadel/serv_test.c
* Server modules are now labelled with their RCS ID instead of a complex and
[citadel.git] / citadel / serv_test.c
1 /* $Id$ */
2 #include "sysdep.h"
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <stdio.h>
6 #include <fcntl.h>
7 #include <signal.h>
8 #include <pwd.h>
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <sys/time.h>
12 #include <sys/wait.h>
13 #include <string.h>
14 #include <limits.h>
15 #ifdef HAVE_PTHREAD_H
16 #include <pthread.h>
17 #endif
18 #include "citadel.h"
19 #include "server.h"
20 #include <syslog.h>
21 #include <time.h>
22 #include "sysdep_decls.h"
23 #include "citserver.h"
24 #include "support.h"
25 #include "config.h"
26 #include "dynloader.h"
27 #include "room_ops.h"
28 #include "policy.h"
29 #include "database.h"
30 #include "msgbase.h"
31
32 extern struct CitContext *ContextList;
33
34 void CleanupTest(void) {
35         lprintf(9, "--- test of adding an unload hook --- \n");
36         }
37
38 void NewRoomTest(void) {
39         lprintf(9, "--- test module was told we're now in %s ---\n",
40                 CC->cs_room);
41         }
42
43 void SessionStartTest(void) {
44         lprintf(9, "--- starting up session %d ---\n",
45                 CC->cs_pid);
46         }
47
48 void SessionStopTest(void) {
49         lprintf(9, "--- ending session %d ---\n", 
50                 CC->cs_pid);
51         }
52
53 void LoginTest(void) {
54         lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
55         }
56
57
58 void Ygorl(char *username, long usernum) {
59         if (!strcasecmp(username, "Unsuspecting User")) {
60                 strcpy(username, "Flaming Asshole");
61                 }
62         }
63
64 void LogTest(char *buf) {
65         fprintf(stderr,"%c[1m%s%c[0m", 27, buf, 27);
66         fflush(stderr);
67         }
68
69
70 char *Dynamic_Module_Init(void)
71 {
72    CtdlRegisterCleanupHook(CleanupTest);
73    CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
74    CtdlRegisterSessionHook(SessionStartTest, EVT_START);
75    CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
76    CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
77    CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);
78    CtdlRegisterLogHook(LogTest, 1);
79    return "$Id$";
80 }