* Removed all of the thread cancellation cruft that is no longer necessary
[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 #include "citadel.h"
16 #include "server.h"
17 #include <time.h>
18 #include "sysdep_decls.h"
19 #include "citserver.h"
20 #include "support.h"
21 #include "config.h"
22 #include "dynloader.h"
23 #include "room_ops.h"
24 #include "policy.h"
25 #include "database.h"
26 #include "msgbase.h"
27
28 extern struct CitContext *ContextList;
29
30 void CleanupTest(void) {
31         lprintf(9, "--- test of adding an unload hook --- \n");
32         }
33
34 void NewRoomTest(void) {
35         lprintf(9, "--- test module was told we're now in a new room ---\n");
36         }
37
38 void SessionStartTest(void) {
39         lprintf(9, "--- starting up session %d ---\n",
40                 CC->cs_pid);
41         }
42
43 void SessionStopTest(void) {
44         lprintf(9, "--- ending session %d ---\n", 
45                 CC->cs_pid);
46         }
47
48 void LoginTest(void) {
49         lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
50         }
51
52
53 void Ygorl(char *username, long usernum) {
54         if (!strcasecmp(username, "Unsuspecting User")) {
55                 strcpy(username, "Flaming Asshole");
56                 }
57         }
58
59 void LogTest(char *buf) {
60         fprintf(stderr,"%c[1m%s%c[0m", 27, buf, 27);
61         fflush(stderr);
62         }
63
64
65 char *Dynamic_Module_Init(void)
66 {
67    CtdlRegisterCleanupHook(CleanupTest);
68    CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
69    CtdlRegisterSessionHook(SessionStartTest, EVT_START);
70    CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
71    CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
72    CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);
73    CtdlRegisterLogHook(LogTest, 1);
74    return "$Id$";
75 }