8b8c5383529772c32cf11823ec1fca163ca3108f
[citadel.git] / citadel / serv_test.c
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <fcntl.h>
5 #include <signal.h>
6 #include <pwd.h>
7 #include <errno.h>
8 #include <sys/types.h>
9 #include <sys/time.h>
10 #include <sys/wait.h>
11 #include <string.h>
12 #include <pthread.h>
13 #include "citadel.h"
14 #include "server.h"
15 #include <syslog.h>
16 #include "sysdep_decls.h"
17 #include "citserver.h"
18 #include "support.h"
19 #include "config.h"
20 #include "dynloader.h"
21
22 extern struct CitContext *ContextList;
23
24 #define MODULE_NAME     "Dummy test module"
25 #define MODULE_AUTHOR   "Art Cancro"
26 #define MODULE_EMAIL    "ajc@uncnsrd.mt-kisco.ny.us"
27 #define MAJOR_VERSION   0
28 #define MINOR_VERSION   2
29
30 static struct DLModule_Info info = {
31   MODULE_NAME,
32   MODULE_AUTHOR,
33   MODULE_EMAIL,
34   MAJOR_VERSION,
35   MINOR_VERSION
36 };
37
38 void CleanupTest(void) {
39         lprintf(9, "--- test of adding an unload hook --- \n");
40         }
41
42 void NewRoomTest(void) {
43         lprintf(9, "--- test module was told we're now in %s ---\n",
44                 CC->cs_room);
45         }
46
47 void SessionStartTest(void) {
48         lprintf(9, "--- starting up session %d ---\n",
49                 CC->cs_pid);
50         }
51
52 void SessionStopTest(void) {
53         lprintf(9, "--- ending session %d ---\n", 
54                 CC->cs_pid);
55         }
56
57 void LoginTest(void) {
58         lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
59         }
60
61
62 void Ygorl(char *username, long usernum) {
63         if (!strcasecmp(username, "Hexslinger")) {
64                 strcpy(username, "Flaming Asshole");
65                 }
66         }
67
68
69 struct DLModule_Info *Dynamic_Module_Init(void)
70 {
71    CtdlRegisterCleanupHook(CleanupTest);
72    CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
73    CtdlRegisterSessionHook(SessionStartTest, EVT_START);
74    CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
75    CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
76    CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);
77    return &info;
78 }