]> code.citadel.org Git - citadel.git/blob - citadel/serv_test.c
Fixes for Cygwin (see ChangeLog)
[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 #ifdef HAVE_PTHREAD_H
16 #include <pthread.h>
17 #endif
18 #include "citadel.h"
19 #include "server.h"
20 #include <syslog.h>
21 #include <time.h>
22 #include "sysdep_decls.h"
23 #include "citserver.h"
24 #include "support.h"
25 #include "config.h"
26 #include "dynloader.h"
27 #include "room_ops.h"
28 #include "policy.h"
29 #include "database.h"
30 #include "msgbase.h"
31
32 extern struct CitContext *ContextList;
33
34 #define MODULE_NAME     "Dummy test module"
35 #define MODULE_AUTHOR   "Art Cancro"
36 #define MODULE_EMAIL    "ajc@uncnsrd.mt-kisco.ny.us"
37 #define MAJOR_VERSION   0
38 #define MINOR_VERSION   4
39
40 static struct DLModule_Info info = {
41         MODULE_NAME,
42         MODULE_AUTHOR,
43         MODULE_EMAIL,
44         MAJOR_VERSION,
45         MINOR_VERSION
46         };
47
48 void CleanupTest(void) {
49         lprintf(9, "--- test of adding an unload hook --- \n");
50         }
51
52 void NewRoomTest(void) {
53         lprintf(9, "--- test module was told we're now in %s ---\n",
54                 CC->cs_room);
55         }
56
57 void SessionStartTest(void) {
58         lprintf(9, "--- starting up session %d ---\n",
59                 CC->cs_pid);
60         }
61
62 void SessionStopTest(void) {
63         lprintf(9, "--- ending session %d ---\n", 
64                 CC->cs_pid);
65         }
66
67 void LoginTest(void) {
68         lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
69         }
70
71
72 void Ygorl(char *username, long usernum) {
73         if (!strcasecmp(username, "Unsuspecting User")) {
74                 strcpy(username, "Flaming Asshole");
75                 }
76         }
77
78 void LogTest(char *buf) {
79         fprintf(stderr,"%c[1m%s%c[0m", 27, buf, 27);
80         fflush(stderr);
81         }
82
83
84 struct DLModule_Info *Dynamic_Module_Init(void)
85 {
86    CtdlRegisterCleanupHook(CleanupTest);
87    CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
88    CtdlRegisterSessionHook(SessionStartTest, EVT_START);
89    CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
90    CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
91    CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);
92    CtdlRegisterLogHook(LogTest, 1);
93    return &info;
94 }