Back to index

citadel  8.12
serv_test.c
Go to the documentation of this file.
00001 /*
00002  * A skeleton module to test the dynamic loader.
00003  *
00004  * Copyright (c) 1998-2012 by the citadel.org team
00005  *
00006  * This program is open source software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License version 3.
00008  * 
00009  * 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * 
00017  * 
00018  * 
00019  */
00020 
00021 #include "sysdep.h"
00022 #include <stdlib.h>
00023 #include <unistd.h>
00024 #include <stdio.h>
00025 #include <fcntl.h>
00026 #include <signal.h>
00027 #include <pwd.h>
00028 #include <errno.h>
00029 #include <sys/types.h>
00030 
00031 #if TIME_WITH_SYS_TIME
00032 # include <sys/time.h>
00033 # include <time.h>
00034 #else
00035 # if HAVE_SYS_TIME_H
00036 #  include <sys/time.h>
00037 # else
00038 #  include <time.h>
00039 # endif
00040 #endif
00041 
00042 #include <sys/wait.h>
00043 #include <string.h>
00044 #include <limits.h>
00045 #include "ctdl_module.h"
00046 
00047 
00048 void CleanupTest(void) {
00049        syslog(LOG_DEBUG, "--- test of adding an unload hook --- \n");
00050        }
00051 
00052 void NewRoomTest(void) {
00053        syslog(LOG_DEBUG, "--- test module was told we're now in a new room ---\n");
00054        }
00055 
00056 void SessionStartTest(void) {
00057        syslog(LOG_DEBUG, "--- starting up session %d ---\n",
00058               CC->cs_pid);
00059        }
00060 
00061 void SessionStopTest(void) {
00062        syslog(LOG_DEBUG, "--- ending session %d ---\n", 
00063               CC->cs_pid);
00064        }
00065 
00066 void LoginTest(void) {
00067        syslog(LOG_DEBUG, "--- Hello, %s ---\n", CC->curr_user);
00068        }
00069 
00070 /* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */
00071 CTDL_MODULE_INIT(test)
00072 {
00073 #if 0
00074        if (!threading)
00075        {
00076               CtdlRegisterCleanupHook(CleanupTest);
00077               CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM, 1);
00078               CtdlRegisterSessionHook(SessionStartTest, EVT_START, 1);
00079               CtdlRegisterSessionHook(SessionStopTest, EVT_STOP, 1);
00080               CtdlRegisterSessionHook(LoginTest, EVT_LOGIN, 1);
00081        }
00082 #endif
00083 
00084    /* return our module name for the log */
00085    return "test";
00086 }