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