update comments in serv_test.c
[citadel.git] / citadel / modules / test / serv_test.c
1 /*
2  * This is an empty skeleton of a Citadel server module, included to demonstrate
3  * how to add a new module to the system and how to activate it in the server.
4  * 
5  * Copyright (c) 1998-2012 by the citadel.org team
6  *
7  * This program is open source software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 3.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15
16 #include "sysdep.h"
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <fcntl.h>
21 #include <signal.h>
22 #include <pwd.h>
23 #include <errno.h>
24 #include <sys/types.h>
25
26 #if TIME_WITH_SYS_TIME
27 # include <sys/time.h>
28 # include <time.h>
29 #else
30 # if HAVE_SYS_TIME_H
31 #  include <sys/time.h>
32 # else
33 #  include <time.h>
34 # endif
35 #endif
36
37 #include <sys/wait.h>
38 #include <string.h>
39 #include <limits.h>
40 #include "ctdl_module.h"
41
42
43 void CleanupTest(void) {
44         syslog(LOG_DEBUG, "--- test of adding an unload hook --- \n");
45         }
46
47 void NewRoomTest(void) {
48         syslog(LOG_DEBUG, "--- test module was told we're now in a new room ---\n");
49         }
50
51 void SessionStartTest(void) {
52         syslog(LOG_DEBUG, "--- starting up session %d ---\n",
53                 CC->cs_pid);
54         }
55
56 void SessionStopTest(void) {
57         syslog(LOG_DEBUG, "--- ending session %d ---\n", 
58                 CC->cs_pid);
59         }
60
61 void LoginTest(void) {
62         syslog(LOG_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
63         }
64
65 /* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */
66 CTDL_MODULE_INIT(test)
67 {
68 #if 0
69         if (!threading)
70         {
71                 CtdlRegisterCleanupHook(CleanupTest);
72                 CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM, 1);
73                 CtdlRegisterSessionHook(SessionStartTest, EVT_START, 1);
74                 CtdlRegisterSessionHook(SessionStopTest, EVT_STOP, 1);
75                 CtdlRegisterSessionHook(LoginTest, EVT_LOGIN, 1);
76         }
77 #endif
78
79    /* return our module name for the log */
80    return "test";
81 }