Changeover to new room structure. See ChangeLog for details.
[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 <limits.h>
13 #include <pthread.h>
14 #include "citadel.h"
15 #include "server.h"
16 #include <syslog.h>
17 #include "sysdep_decls.h"
18 #include "citserver.h"
19 #include "support.h"
20 #include "config.h"
21 #include "dynloader.h"
22
23 extern struct CitContext *ContextList;
24
25 #define MODULE_NAME     "Dummy test module"
26 #define MODULE_AUTHOR   "Art Cancro"
27 #define MODULE_EMAIL    "ajc@uncnsrd.mt-kisco.ny.us"
28 #define MAJOR_VERSION   0
29 #define MINOR_VERSION   2
30
31 static struct DLModule_Info info = {
32   MODULE_NAME,
33   MODULE_AUTHOR,
34   MODULE_EMAIL,
35   MAJOR_VERSION,
36   MINOR_VERSION
37 };
38
39 void CleanupTest(void) {
40         lprintf(9, "--- test of adding an unload hook --- \n");
41         }
42
43 void NewRoomTest(void) {
44         lprintf(9, "--- test module was told we're now in %s ---\n",
45                 CC->cs_room);
46         }
47
48 void SessionStartTest(void) {
49         lprintf(9, "--- starting up session %d ---\n",
50                 CC->cs_pid);
51         }
52
53 void SessionStopTest(void) {
54         lprintf(9, "--- ending session %d ---\n", 
55                 CC->cs_pid);
56         }
57
58 void LoginTest(void) {
59         lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
60         }
61
62
63 void Ygorl(char *username, long usernum) {
64         if (!strcasecmp(username, "Hexslinger")) {
65                 strcpy(username, "Flaming Asshole");
66                 }
67         }
68
69
70 struct DLModule_Info *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    return &info;
79 }