19c3a4f88f66bc551be473dfceb70d47dcede038
[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
51 void CleanupTest(void) {
52         CtdlLogPrintf(CTDL_DEBUG, "--- test of adding an unload hook --- \n");
53         }
54
55 void NewRoomTest(void) {
56         CtdlLogPrintf(CTDL_DEBUG, "--- test module was told we're now in a new room ---\n");
57         }
58
59 void SessionStartTest(void) {
60         CtdlLogPrintf(CTDL_DEBUG, "--- starting up session %d ---\n",
61                 CC->cs_pid);
62         }
63
64 void SessionStopTest(void) {
65         CtdlLogPrintf(CTDL_DEBUG, "--- ending session %d ---\n", 
66                 CC->cs_pid);
67         }
68
69 void LoginTest(void) {
70         CtdlLogPrintf(CTDL_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
71         }
72
73 /* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */
74 CTDL_MODULE_INIT(test)
75 {
76 #if 0
77         if (!threading)
78         {
79                 CtdlRegisterCleanupHook(CleanupTest);
80                 CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
81                 CtdlRegisterSessionHook(SessionStartTest, EVT_START);
82                 CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
83                 CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
84         }
85 #endif
86
87    /* return our Subversion id for the Log */
88    return "$Id$";
89 }