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