stable now but there are GIANT PIECES MISSING
[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-2016 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 #include <time.h>
26 #include <sys/wait.h>
27 #include <string.h>
28 #include <limits.h>
29 #include "ctdl_module.h"
30
31
32 void CleanupTest(void) {
33         syslog(LOG_DEBUG, "--- test of adding an unload hook --- \n");
34 }
35
36 void NewRoomTest(void) {
37         syslog(LOG_DEBUG, "--- test module was told we're now in a new room ---\n");
38 }
39
40 void SessionStartTest(void) {
41         syslog(LOG_DEBUG, "--- starting up session %d ---\n", CC->cs_pid);
42 }
43
44 void SessionStopTest(void) {
45         syslog(LOG_DEBUG, "--- ending session %d ---\n", CC->cs_pid);
46 }
47
48 void LoginTest(void) {
49         syslog(LOG_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
50 }
51
52 /* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */
53 CTDL_MODULE_INIT(test)
54 {
55 #if 0
56         if (!threading)
57         {
58                 CtdlRegisterCleanupHook(CleanupTest);
59                 CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM, 1);
60                 CtdlRegisterSessionHook(SessionStartTest, EVT_START, 1);
61                 CtdlRegisterSessionHook(SessionStopTest, EVT_STOP, 1);
62                 CtdlRegisterSessionHook(LoginTest, EVT_LOGIN, 1);
63         }
64 #endif
65
66 /* return our module name for the log */
67 return "test";
68 }