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