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