]> code.citadel.org Git - citadel.git/blob - citadel/serv_test.c
Built some more of the message expiry infrastructure
[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 #include "room_ops.h"
23
24 extern struct CitContext *ContextList;
25
26 #define MODULE_NAME     "Dummy test module"
27 #define MODULE_AUTHOR   "Art Cancro"
28 #define MODULE_EMAIL    "ajc@uncnsrd.mt-kisco.ny.us"
29 #define MAJOR_VERSION   0
30 #define MINOR_VERSION   2
31
32 static struct DLModule_Info info = {
33   MODULE_NAME,
34   MODULE_AUTHOR,
35   MODULE_EMAIL,
36   MAJOR_VERSION,
37   MINOR_VERSION
38 };
39
40 void CleanupTest(void) {
41         lprintf(9, "--- test of adding an unload hook --- \n");
42         }
43
44 void NewRoomTest(void) {
45         lprintf(9, "--- test module was told we're now in %s ---\n",
46                 CC->cs_room);
47         }
48
49 void SessionStartTest(void) {
50         lprintf(9, "--- starting up session %d ---\n",
51                 CC->cs_pid);
52         }
53
54 void SessionStopTest(void) {
55         lprintf(9, "--- ending session %d ---\n", 
56                 CC->cs_pid);
57         }
58
59 void LoginTest(void) {
60         lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
61         }
62
63
64 void Ygorl(char *username, long usernum) {
65         if (!strcasecmp(username, "Hexslinger")) {
66                 strcpy(username, "Flaming Asshole");
67                 }
68         }
69
70
71
72 void DoPurgeMessages(struct quickroom *qrbuf) {
73         struct ExpirePolicy epbuf;
74
75         GetExpirePolicy(&epbuf, qrbuf);
76         
77         lprintf(9, "ExpirePolicy for <%s> is <%d> <%ld>\n",
78                 qrbuf->QRname, epbuf.expire_mode, epbuf.expire_value);
79         }
80
81 void PurgeMessages(void) {
82         ForEachRoom(DoPurgeMessages);
83         }
84
85 struct DLModule_Info *Dynamic_Module_Init(void)
86 {
87    CtdlRegisterCleanupHook(CleanupTest);
88    CtdlRegisterCleanupHook(PurgeMessages);
89    CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
90    CtdlRegisterSessionHook(SessionStartTest, EVT_START);
91    CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
92    CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
93    CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);
94    return &info;
95 }