From 01cc19a4c2da27b4db0e980ccd3ca54d834319c8 Mon Sep 17 00:00:00 2001 From: Dave West Date: Thu, 26 Jul 2007 07:46:53 +0000 Subject: [PATCH] Moved to new module init structure. Added file include/ctdl_module.h Added script mk_modules_init.sh to build files modules_init.c and modules_init.h removed #include "serv_extensions.h" from files that don't need it Begun creation of new module dir structure. davew. --- citadel/Makefile.in | 13 ++-- citadel/citserver.c | 1 - citadel/clientsocket.c | 1 - citadel/config.c | 1 - citadel/control.c | 1 - citadel/database_sleepycat.c | 4 +- citadel/euidindex.c | 1 - citadel/file_ops.c | 1 - citadel/ft_wordbreaker.c | 1 - citadel/html.c | 1 - citadel/imap_acl.c | 1 - citadel/imap_fetch.c | 1 - citadel/imap_list.c | 1 - citadel/imap_metadata.c | 1 - citadel/imap_misc.c | 1 - citadel/imap_search.c | 1 - citadel/imap_store.c | 1 - citadel/include/ctdl_module.h | 65 ++++++++++++++++++ citadel/internet_addressing.c | 1 - citadel/journaling.c | 3 +- citadel/locate_host.c | 1 - citadel/mime_parser.c | 1 - citadel/mk_module_init.sh | 120 +++++++++++++++++++++++++++++++++ citadel/policy.c | 1 - citadel/room_ops.c | 1 - citadel/sendcommand.c | 1 - citadel/serv_autocompletion.c | 6 +- citadel/serv_bio.c | 6 +- citadel/serv_calendar.c | 7 +- citadel/serv_chat.c | 9 ++- citadel/serv_crypto.c | 5 +- citadel/serv_expire.c | 7 +- citadel/serv_extensions.c | 11 +-- citadel/serv_extensions.h | 64 +----------------- citadel/serv_fulltext.c | 8 ++- citadel/serv_funambol.c | 10 ++- citadel/serv_imap.c | 8 ++- citadel/serv_inetcfg.c | 5 +- citadel/serv_ldap.c | 9 ++- citadel/serv_listsub.c | 8 ++- citadel/serv_managesieve.c | 21 +++--- citadel/serv_mrtg.c | 7 +- citadel/serv_netfilter.c | 8 ++- citadel/serv_network.c | 9 ++- citadel/serv_newuser.c | 9 ++- citadel/serv_notes.c | 7 +- citadel/serv_pas2.c | 7 +- citadel/serv_pop3.c | 7 +- citadel/serv_rwho.c | 6 +- citadel/serv_sieve.c | 23 ++++--- citadel/serv_smtp.c | 9 ++- citadel/serv_spam.c | 7 +- citadel/serv_test.c | 17 ++--- citadel/serv_upgrade.c | 6 +- citadel/serv_vandelay.c | 10 ++- citadel/serv_vcard.c | 26 +++---- citadel/server_main.c | 10 +++ citadel/sysdep.c | 1 - citadel/sysdep_decls.h | 5 ++ citadel/techdoc/test_suite.txt | 45 +++++++++++++ citadel/user_ops.c | 1 - 61 files changed, 417 insertions(+), 213 deletions(-) create mode 100644 citadel/include/ctdl_module.h create mode 100755 citadel/mk_module_init.sh create mode 100644 citadel/techdoc/test_suite.txt diff --git a/citadel/Makefile.in b/citadel/Makefile.in index c51cf122b..7cfddeb59 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -64,7 +64,8 @@ SERV_MODULES=serv_chat.o \ ical_dezonify.o \ serv_ldap.o \ serv_autocompletion.o \ - serv_funambol.o + serv_funambol.o \ + serv_test.o UTIL_TARGETS=aidepost msgform \ citmail userlist sendcommand \ @@ -119,7 +120,7 @@ SOURCES=aidepost.c auth.c base64.c chkpwd.c chkpw.c citadel.c citadel_ipc.c \ whobbs.c vcard.c serv_notes.c serv_fulltext.c ft_wordbreaker.c \ crc16.c journaling.c citadel_dirs.c imap_list.c imap_metadata.c -DEP_FILES=$(SOURCES:.c=.d) +DEP_FILES=$(SOURCES:.c=.d) modules_init.d client: $(CLIENT_TARGETS) @@ -144,6 +145,9 @@ citadel$(EXEEXT): citadel.o citadel_ipc.o client_chat.o client_passwords.o \ parsedate.o: parsedate.c +modules_init.c: mk_module_init.sh $(SOURCES) + $(srcdir)/mk_module_init.sh + SERV_OBJS = server_main.o \ user_ops.o citserver.o sysdep.o serv_extensions.o \ tools.o $(DATABASE:.c=.o) domain.o \ @@ -152,7 +156,7 @@ SERV_OBJS = server_main.o \ locate_host.o housekeeping.o mime_parser.o html.o \ internet_addressing.o journaling.o \ serv_crypto.o parsedate.o genstamp.o \ - clientsocket.o $(AUTH) $(SERV_MODULES) + clientsocket.o modules_init.o $(AUTH) $(SERV_MODULES) citserver: $(SERV_OBJS) $(CC) $(SERV_OBJS) $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) $(SERVER_LIBS) $(RESOLV) -o citserver @@ -336,10 +340,11 @@ install-exec-new: all done clean: - rm -f *.o + rm -f *.o cleaner: clean rm -rf $(CLIENT_TARGETS) $(SERVER_TARGETS) $(UTIL_TARGETS) $(UTILBIN_TARGETS) database_cleanup.sh *.la + rm -rf modules_init.c modules_init.h distclean: cleaner find . -name '*~' -o -name '.#*' | xargs rm -f diff --git a/citadel/citserver.c b/citadel/citserver.c index 8c2c4cde4..39f0fb66d 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -38,7 +38,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "citserver.h" #include "config.h" diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index 83f06ad6c..cd375db2d 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -25,7 +25,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" #endif diff --git a/citadel/config.c b/citadel/config.c index d938065a2..a8d4ca6b7 100644 --- a/citadel/config.c +++ b/citadel/config.c @@ -16,7 +16,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "config.h" struct config config; diff --git a/citadel/control.c b/citadel/control.c index a6d61f82d..83c1eb086 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -32,7 +32,6 @@ #include "citadel.h" #include "server.h" #include "control.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "support.h" #include "config.h" diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index c5d6c4b8e..e01c0adad 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -46,13 +46,15 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "citserver.h" #include "database.h" #include "msgbase.h" #include "sysdep_decls.h" #include "config.h" +#include "ctdl_module.h" + + static DB *dbp[MAXCDB]; /* One DB handle for each Citadel database */ static DB_ENV *dbenv; /* The DB environment (global) */ diff --git a/citadel/euidindex.c b/citadel/euidindex.c index 752437777..5f25615f9 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -31,7 +31,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "database.h" #include "msgbase.h" #include "support.h" diff --git a/citadel/file_ops.c b/citadel/file_ops.c index a6cf80b7a..015e989ea 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -30,7 +30,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "config.h" #include "file_ops.h" #include "sysdep_decls.h" diff --git a/citadel/ft_wordbreaker.c b/citadel/ft_wordbreaker.c index a58087915..6b9fb2d24 100644 --- a/citadel/ft_wordbreaker.c +++ b/citadel/ft_wordbreaker.c @@ -37,7 +37,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "database.h" #include "msgbase.h" #include "control.h" diff --git a/citadel/html.c b/citadel/html.c index c0359a6a7..6a86d323a 100644 --- a/citadel/html.c +++ b/citadel/html.c @@ -30,7 +30,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "control.h" #include "sysdep_decls.h" #include "support.h" diff --git a/citadel/imap_acl.c b/citadel/imap_acl.c index 1281fa30f..1632532db 100644 --- a/citadel/imap_acl.c +++ b/citadel/imap_acl.c @@ -37,7 +37,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/imap_fetch.c b/citadel/imap_fetch.c index bc0aaf41e..66d5b44ad 100644 --- a/citadel/imap_fetch.c +++ b/citadel/imap_fetch.c @@ -38,7 +38,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/imap_list.c b/citadel/imap_list.c index edfa1ddb0..be01c99a7 100644 --- a/citadel/imap_list.c +++ b/citadel/imap_list.c @@ -39,7 +39,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/imap_metadata.c b/citadel/imap_metadata.c index 2b0b5fc28..3266c27ce 100644 --- a/citadel/imap_metadata.c +++ b/citadel/imap_metadata.c @@ -40,7 +40,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index 58c649c31..350f9ad10 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -36,7 +36,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/imap_search.c b/citadel/imap_search.c index 3dd552192..1c647774b 100644 --- a/citadel/imap_search.c +++ b/citadel/imap_search.c @@ -36,7 +36,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/imap_store.c b/citadel/imap_store.c index e4204cfc3..7e163787b 100644 --- a/citadel/imap_store.c +++ b/citadel/imap_store.c @@ -37,7 +37,6 @@ #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h new file mode 100644 index 000000000..ed8e7c9c7 --- /dev/null +++ b/citadel/include/ctdl_module.h @@ -0,0 +1,65 @@ +/* $Id:$ */ + +#ifndef CTDL_MODULE_H +#define CTDL_MODULE_H + + +#include "server.h" +#include "sysdep_decls.h" +/* + * define macros for module init stuff + */ + + +#define CTDL_MODULE_INIT(module_name) char *ctdl_module_##module_name##_init (void) + +#define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init () + +void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType); +void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType); + +void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType); +void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType); + +void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order); +void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order); + +void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *), + int EventType); +void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *), + int EventType); + +void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ); +void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ); + +void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) ); +void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) ); + +void CtdlRegisterDeleteHook(void (*handler)(char *, long) ); +void CtdlUnregisterDeleteHook(void (*handler)(char *, long) ); + +void CtdlRegisterCleanupHook(void (*fcn_ptr)(void)); +void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void)); + +void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc); +void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd); + +void CtdlRegisterServiceHook(int tcp_port, + char *sockpath, + void (*h_greeting_function) (void), + void (*h_command_function) (void), + void (*h_async_function) (void) +); +void CtdlUnregisterServiceHook(int tcp_port, + char *sockpath, + void (*h_greeting_function) (void), + void (*h_command_function) (void), + void (*h_async_function) (void) +); + +void CtdlRegisterFixedOutputHook(char *content_type, + void (*output_function) (char *supplied_data, int len) +); +void CtdlUnRegisterFixedOutputHook(char *content_type); + +#endif /* CTDL_MODULE_H */ diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 3bbf82454..123b5280d 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -32,7 +32,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "citserver.h" #include "support.h" diff --git a/citadel/journaling.c b/citadel/journaling.c index 38629ab41..4d18623c5 100644 --- a/citadel/journaling.c +++ b/citadel/journaling.c @@ -1,5 +1,5 @@ /* - * $Id: $ + * $Id$ * * Message journaling functions. * @@ -31,7 +31,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "database.h" #include "msgbase.h" #include "support.h" diff --git a/citadel/locate_host.c b/citadel/locate_host.c index da0594df4..bb2463dae 100644 --- a/citadel/locate_host.c +++ b/citadel/locate_host.c @@ -19,7 +19,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "locate_host.h" #include "sysdep_decls.h" #include "config.h" diff --git a/citadel/mime_parser.c b/citadel/mime_parser.c index 869327ecb..f7b9681a0 100644 --- a/citadel/mime_parser.c +++ b/citadel/mime_parser.c @@ -20,7 +20,6 @@ #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "tools.h" diff --git a/citadel/mk_module_init.sh b/citadel/mk_module_init.sh new file mode 100755 index 000000000..3b8a2ed60 --- /dev/null +++ b/citadel/mk_module_init.sh @@ -0,0 +1,120 @@ +#!/bin/sh +# +# Script to generate $C_FILE +# + + + +CUR_DIR=`pwd` +C_FILE="$CUR_DIR/modules_init.c" +H_FILE="$CUR_DIR/modules_init.h" + +echo -e "Scanning extension modules for entry points." + + +#start ofs the files which inturn removes any existing file +# +echo -e "/*" > $C_FILE +echo -e " * $C_FILE" >> $C_FILE +echo -e " * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE" >> $C_FILE +echo -e " */\n\n\n" >> $C_FILE + +#echo -e "#include \"sysdep.h\"\n" >> $C_FILE +echo -e "#include \n" >> $C_FILE +#echo -e "#include \n" >> $C_FILE +#echo -e "#include \"citadel.h\"\n" >> $C_FILE +echo -e "#include \"modules_init.h\"\n" >> $C_FILE +echo -e "#include \"sysdep_decls.h\"\n" >> $C_FILE +echo -e "\n\n\n" >> $C_FILE +echo -e "void LogPrintMessages(long err);" >> $C_FILE +echo -e "static long DetailErrorFlags;" >> $C_FILE +echo -e "\n\n\n" >> $C_FILE + +echo -e "void initialise_modules (void)" >> $C_FILE +echo -e "{" >> $C_FILE +echo -e "\tlong filter;\n\n" >> $C_FILE +echo -e -n "\t" >> $C_FILE +echo -E "lprintf(CTDL_INFO, \"New citadel module init proceedure.\n\");" >> $C_FILE + +#start the header file +echo -e "/*" > $H_FILE +echo -e " * $H_FILE" >> $H_FILE +echo -e " * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE" >> $H_FILE +echo -e " */\n\n\n" >> $H_FILE +echo -e "#ifndef MODULES_INIT_H" >> $H_FILE +echo -e "#define MODULES_INIT_H\n" >> $H_FILE +echo -e "#include \"ctdl_module.h\"\n" >> $H_FILE +echo -e "void initialise_modules (void) ;\n" >> $H_FILE + + +for i in serv_*.c +do + RES=X`grep CTDL_MODULE_INIT $i | cut -f2 -d\( | cut -f1 -d\)` + if [ $RES != "X" ] ; then + RES_OUT=`echo $RES | cut -b2-` + echo -e "Found entry point in file $i" + echo -e -n "\t" >> $C_FILE + echo -E "lprintf (CTDL_INFO, \"%s\n\", CTDL_INIT_CALL($RES_OUT));" >> $C_FILE + echo -E "CTDL_MODULE_INIT($RES_OUT) ;" >> $H_FILE + fi +done + + +if [ -d "modules" ] ; then + cd modules + for j in * + do + if [ -d $j ] ; then + cd $j + for k in *.c + do + if [ -f "$k" ] ; then + RES=X`grep CTDL_MODULE_INIT $k | cut -f2 -d\( | cut -f1 -d\)` + if [ $RES != "X" ] ; then + RES_OUT=`echo $RES | cut -b2-` + echo -e "Found entry point in file modules/$j/$k" + echo -n "\t" >> $C_FILE + echo -E "lprintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));" >> $C_FILE + echo -E "CTDL_MODULE_INIT($RES_OUT) ;" >> $H_FILE + fi + fi + done + fi + done +fi + +cd $CUR_DIR + +if [ -d "user_modules" ] ; then + cd user_modules + for j in * + do + if [ -d $j ] ; then + cd $j + for k in *.c + do + if [ -f "$k" ] ; then + RES=X`grep CTDL_MODULE_INIT $k | cut -f2 -d\( | cut -f1 -d\)` + if [ $RES != "X" ] ; then + RES_OUT=`echo $RES | cut -b2-` + echo -e "Found entry point in file user_modules/$j/$k" + echo -n "\t" >> $C_FILE + echo -E "lprintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));" >> $C_FILE + echo -E "CTDL_MODULE_INIT($RES_OUT) ;" >> $H_FILE + fi + fi + done + fi + done +fi + +cd $CUR_DIR + +echo -e "\n\n" >> $C_FILE +echo -e "\tfor (filter = 1; filter != 0; filter = filter << 1)" >> $C_FILE +echo -e "\t\tif ((filter & DetailErrorFlags) != 0)" >> $C_FILE +echo -e "\t\t\tLogPrintMessages(filter);" >> $C_FILE +echo -e "}" >> $C_FILE + + +echo -e "\n#endif /* MODULES_INIT_H */" >> $H_FILE diff --git a/citadel/policy.c b/citadel/policy.c index 079c3cda0..804416e71 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -26,7 +26,6 @@ #include "citadel.h" #include "server.h" #include "database.h" -#include "serv_extensions.h" #include "config.h" #include "room_ops.h" #include "sysdep_decls.h" diff --git a/citadel/room_ops.c b/citadel/room_ops.c index d2ce223e1..93e8b4486 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -28,7 +28,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "database.h" #include "config.h" #include "room_ops.h" diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index d1619fea5..cc47df4af 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -33,7 +33,6 @@ #include "tools.h" #include "citadel_ipc.h" #include "server.h" -#include "serv_extensions.h" #include "config.h" #define LOCKFILE "/tmp/LCK.sendcommand" diff --git a/citadel/serv_autocompletion.c b/citadel/serv_autocompletion.c index 239985c65..ddea4f0dc 100644 --- a/citadel/serv_autocompletion.c +++ b/citadel/serv_autocompletion.c @@ -31,8 +31,6 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" @@ -45,6 +43,8 @@ #include "serv_fulltext.h" #include "serv_autocompletion.h" +#include "ctdl_module.h" + #ifndef HAVE_SNPRINTF #include "snprintf.h" @@ -250,7 +250,7 @@ void cmd_auto(char *argbuf) { } -char *serv_autocompletion_init(void) { +CTDL_MODULE_INIT(autocompletion) { CtdlRegisterProtoHook(cmd_auto, "AUTO", "Do recipient autocompletion"); /* return our Subversion id for the Log */ diff --git a/citadel/serv_bio.c b/citadel/serv_bio.c index 19820a956..9f5589b3b 100644 --- a/citadel/serv_bio.c +++ b/citadel/serv_bio.c @@ -32,12 +32,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -46,7 +44,7 @@ #include "tools.h" #include "citadel_dirs.h" - +#include "ctdl_module.h" /* * enter user bio @@ -134,7 +132,7 @@ void cmd_lbio(char *cmdbuf) { -char *serv_bio_init(void) +CTDL_MODULE_INIT(bio) { CtdlRegisterProtoHook(cmd_ebio, "EBIO", "Enter your bio"); CtdlRegisterProtoHook(cmd_rbio, "RBIO", "Read a user's bio"); diff --git a/citadel/serv_calendar.c b/citadel/serv_calendar.c index 2171f381b..de3504441 100644 --- a/citadel/serv_calendar.c +++ b/citadel/serv_calendar.c @@ -22,10 +22,8 @@ #include "citadel.h" #include "server.h" #include "citserver.h" -#include "sysdep_decls.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "user_ops.h" #include "room_ops.h" #include "tools.h" @@ -34,12 +32,15 @@ #include "internet_addressing.h" #include "serv_calendar.h" #include "euidindex.h" +#include "ctdl_module.h" #ifdef CITADEL_WITH_CALENDAR_SERVICE #include #include "ical_dezonify.h" + + struct ical_respond_data { char desired_partnum[SIZ]; icalcomponent *cal; @@ -2136,7 +2137,7 @@ void ical_fixed_output(char *ptr, int len) { /* * Register this module with the Citadel server. */ -char *serv_calendar_init(void) +CTDL_MODULE_INIT(calendar) { #ifdef CITADEL_WITH_CALENDAR_SERVICE CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE); diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index 765d486d9..a34f7efc3 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -31,9 +31,7 @@ #include #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "serv_chat.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" @@ -46,6 +44,11 @@ #include "snprintf.h" #endif + +#include "ctdl_module.h" + + + struct ChatLine *ChatQueue = NULL; int ChatLastMsg = 0; @@ -810,7 +813,7 @@ void cmd_reqt(char *argbuf) { -char *serv_chat_init(void) +CTDL_MODULE_INIT(chat) { CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat"); CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for instant messages"); diff --git a/citadel/serv_crypto.c b/citadel/serv_crypto.c index 0db01ac47..a9dd5934b 100644 --- a/citadel/serv_crypto.c +++ b/citadel/serv_crypto.c @@ -35,11 +35,14 @@ #include "server.h" #include "serv_crypto.h" #include "sysdep_decls.h" -#include "serv_extensions.h" #include "citadel.h" #include "config.h" +#include "ctdl_module.h" +/* TODO: should we use the standard module init stuff to start this? */ +/* TODO: should we register an event handler to call destruct_ssl? */ + #ifdef HAVE_OPENSSL SSL_CTX *ssl_ctx; /* SSL context */ pthread_mutex_t **SSLCritters; /* Things needing locking */ diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index ab0a95214..66b46570d 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -51,11 +51,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "policy.h" #include "database.h" @@ -66,6 +64,9 @@ #include "tools.h" +#include "ctdl_module.h" + + struct PurgeList { struct PurgeList *next; char name[ROOMNAMELEN]; /* use the larger of username or roomname */ @@ -836,7 +837,7 @@ void cmd_fsck(char *argbuf) { /*****************************************************************************/ -char *serv_expire_init(void) +CTDL_MODULE_INIT(expire) { CtdlRegisterSessionHook(purge_databases, EVT_TIMER); CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts"); diff --git a/citadel/serv_extensions.c b/citadel/serv_extensions.c index 1b1390f59..1acd40e09 100644 --- a/citadel/serv_extensions.c +++ b/citadel/serv_extensions.c @@ -249,13 +249,14 @@ int DLoader_Exec_Cmd(char *cmdbuf) return 0; } +#if 0 void initialize_server_extensions(void) { long filter; nSizErrmsg = 0; - lprintf(CTDL_INFO, "%s\n", serv_bio_init()); + /*lprintf(CTDL_INFO, "%s\n", serv_bio_init()); lprintf(CTDL_INFO, "%s\n", serv_calendar_init()); lprintf(CTDL_INFO, "%s\n", serv_notes_init()); lprintf(CTDL_INFO, "%s\n", serv_ldap_init()); @@ -273,22 +274,22 @@ void initialize_server_extensions(void) lprintf(CTDL_INFO, "%s\n", serv_smtp_init()); lprintf(CTDL_INFO, "%s\n", serv_pop3_init()); lprintf(CTDL_INFO, "%s\n", serv_rwho_init()); - lprintf(CTDL_INFO, "%s\n", serv_spam_init()); + lprintf(CTDL_INFO, "%s\n", serv_spam_init());*/ /* lprintf(CTDL_INFO, "%s\n", serv_test_init()); */ - lprintf(CTDL_INFO, "%s\n", serv_vandelay_init()); + /*lprintf(CTDL_INFO, "%s\n", serv_vandelay_init()); lprintf(CTDL_INFO, "%s\n", serv_vcard_init()); lprintf(CTDL_INFO, "%s\n", serv_fulltext_init()); lprintf(CTDL_INFO, "%s\n", serv_autocompletion_init()); lprintf(CTDL_INFO, "%s\n", serv_postfix_tcpdict()); lprintf(CTDL_INFO, "%s\n", serv_sieve_init()); lprintf(CTDL_INFO, "%s\n", serv_managesieve_init()); - lprintf(CTDL_INFO, "%s\n", serv_funambol_init()); + lprintf(CTDL_INFO, "%s\n", serv_funambol_init());*/ for (filter = 1; filter != 0; filter = filter << 1) if ((filter & DetailErrorFlags) != 0) LogPrintMessages(filter); } - +#endif void CtdlRegisterCleanupHook(void (*fcn_ptr) (void)) { diff --git a/citadel/serv_extensions.h b/citadel/serv_extensions.h index ccdd95979..f0e1cedb0 100644 --- a/citadel/serv_extensions.h +++ b/citadel/serv_extensions.h @@ -10,35 +10,9 @@ * We'll probably start moving these to a more sane location in the near * future. For now, this just shuts up the compiler. */ -char *serv_bio_init(void); -char *serv_calendar_init(void); void serv_calendar_destroy(void); -char *serv_notes_init(void); -char *serv_ldap_init(void); -char *serv_chat_init(void); -char *serv_expire_init(void); -char *serv_imap_init(void); -char *serv_inetcfg_init(void); -char *serv_listsub_init(void); -char *serv_mrtg_init(void); -char *serv_netfilter_init(void); -char *serv_network_init(void); -char *serv_newuser_init(void); -char *serv_pas2_init(void); -char *serv_pop3_init(void); -char *serv_rwho_init(void); -char *serv_smtp_init(void); -char *serv_spam_init(void); char *serv_test_init(void); -char *serv_upgrade_init(void); -char *serv_vandelay_init(void); -char *serv_vcard_init(void); -char *serv_fulltext_init(void); -char *serv_autocompletion_init(void); char *serv_postfix_tcpdict(void); -char *serv_managesieve_init(void); -char *serv_sieve_init(void); -char *serv_funambol_init(void); /* */ @@ -46,72 +20,38 @@ void initialize_server_extensions(void); int DLoader_Exec_Cmd(char *cmdbuf); char *Dynamic_Module_Init(void); -void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType); -void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType); void CtdlDestroySessionHooks(void); void PerformSessionHooks(int EventType); -void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType); -void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType); void CtdlDestroyUserHooks(void); void PerformUserHooks(struct ctdluser *usbuf, int EventType); -void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order); -void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order); int PerformXmsgHooks(char *, char *, char *); void CtdlDestroyXmsgHooks(void); -void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *), - int EventType); -void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *), - int EventType); void CtdlDestroyMessageHook(void); int PerformMessageHooks(struct CtdlMessage *, int EventType); -void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ); -void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ); void CtdlDestroyNetprocHooks(void); int PerformNetprocHooks(struct CtdlMessage *, char *); -void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) ); -void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) ); void CtdlDestroyRoomHooks(void); int PerformRoomHooks(struct ctdlroom *); -void CtdlRegisterDeleteHook(void (*handler)(char *, long) ); -void CtdlUnregisterDeleteHook(void (*handler)(char *, long) ); void CtdlDestroyDeleteHooks(void); void PerformDeleteHooks(char *, long); -void CtdlRegisterCleanupHook(void (*fcn_ptr)(void)); -void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void)); void CtdlDestroyCleanupHooks(void); -void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc); -void CtdlUnregisterProtoHook(void (*handler)(char *), char *cmd); + void CtdlDestroyProtoHooks(void); -void CtdlRegisterServiceHook(int tcp_port, - char *sockpath, - void (*h_greeting_function) (void), - void (*h_command_function) (void), - void (*h_async_function) (void) -); -void CtdlUnregisterServiceHook(int tcp_port, - char *sockpath, - void (*h_greeting_function) (void), - void (*h_command_function) (void), - void (*h_async_function) (void) -); + void CtdlDestroyServiceHook(void); -void CtdlRegisterFixedOutputHook(char *content_type, - void (*output_function) (char *supplied_data, int len) -); -void CtdlUnRegisterFixedOutputHook(char *content_type); void CtdlDestroyFixedOutputHooks(void); int PerformFixedOutputHooks(char *, char *, int); diff --git a/citadel/serv_fulltext.c b/citadel/serv_fulltext.c index 028f95868..f6e2c672a 100644 --- a/citadel/serv_fulltext.c +++ b/citadel/serv_fulltext.c @@ -32,11 +32,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "database.h" #include "msgbase.h" #include "control.h" @@ -46,6 +44,10 @@ #include "ft_wordbreaker.h" +#include "ctdl_module.h" + + + long ft_newhighest = 0L; long *ft_newmsgs = NULL; int ft_num_msgs = 0; @@ -467,7 +469,7 @@ void initialize_ft_cache(void) { /*****************************************************************************/ -char *serv_fulltext_init(void) +CTDL_MODULE_INIT(fulltext) { initialize_ft_cache(); CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search"); diff --git a/citadel/serv_funambol.c b/citadel/serv_funambol.c index 9e0601246..561be0986 100644 --- a/citadel/serv_funambol.c +++ b/citadel/serv_funambol.c @@ -31,12 +31,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -47,6 +45,12 @@ #include "domain.h" #include "clientsocket.h" #include "serv_funambol.h" + + + +#include "ctdl_module.h" + + /* * Create the notify message queue */ @@ -219,7 +223,7 @@ void notify_funambol(long msgnum, void *userdata) { -char *serv_funambol_init(void) +CTDL_MODULE_INIT(funambol) { create_notify_queue(); CtdlRegisterSessionHook(do_notify_queue, EVT_TIMER); diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index 9599d19ed..be4132ea3 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -37,11 +37,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -63,6 +61,10 @@ #include "serv_crypto.h" #endif + +#include "ctdl_module.h" + + /* imap_rename() uses this struct containing list of rooms to rename */ struct irl { struct irl *next; @@ -1587,7 +1589,7 @@ void imap_command_loop(void) /* * This function is called to register the IMAP extension with Citadel. */ -char *serv_imap_init(void) +CTDL_MODULE_INIT(imap) { CtdlRegisterServiceHook(config.c_imap_port, NULL, imap_greeting, imap_command_loop, NULL); diff --git a/citadel/serv_inetcfg.c b/citadel/serv_inetcfg.c index d5623d989..eaab32d37 100644 --- a/citadel/serv_inetcfg.c +++ b/citadel/serv_inetcfg.c @@ -34,11 +34,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -50,6 +48,7 @@ #include "domain.h" +#include "ctdl_module.h" void inetcfg_setTo(struct CtdlMessage *msg) { @@ -177,7 +176,7 @@ void inetcfg_init(void) { /*****************************************************************************/ -char *serv_inetcfg_init(void) +CTDL_MODULE_INIT(inetcfg) { CtdlRegisterMessageHook(inetcfg_aftersave, EVT_AFTERSAVE); inetcfg_init(); diff --git a/citadel/serv_ldap.c b/citadel/serv_ldap.c index 6d8acc1f7..f3e5a774a 100644 --- a/citadel/serv_ldap.c +++ b/citadel/serv_ldap.c @@ -31,11 +31,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "policy.h" #include "database.h" @@ -44,6 +42,11 @@ #include "vcard.h" #include "tools.h" + +#include "ctdl_module.h" + + + #ifdef HAVE_LDAP #include @@ -587,7 +590,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { /* * Initialize the LDAP connector module ... or don't, if we don't have LDAP. */ -char *serv_ldap_init(void) +CTDL_MODULE_INIT(ldap) { #ifdef HAVE_LDAP CtdlRegisterCleanupHook(serv_ldap_cleanup); diff --git a/citadel/serv_listsub.c b/citadel/serv_listsub.c index be0953728..93e93553b 100644 --- a/citadel/serv_listsub.c +++ b/citadel/serv_listsub.c @@ -35,11 +35,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -56,6 +54,10 @@ #endif + +#include "ctdl_module.h" + + /* * Generate a randomizationalisticized token to use for authentication of * a subscribe or unsubscribe request. @@ -562,7 +564,7 @@ void cmd_subs(char *cmdbuf) { /* * Module entry point */ -char *serv_listsub_init(void) +CTDL_MODULE_INIT(listsub) { CtdlRegisterProtoHook(cmd_subs, "SUBS", "List subscribe/unsubscribe"); diff --git a/citadel/serv_managesieve.c b/citadel/serv_managesieve.c index 9b53968e1..c43d8aa19 100644 --- a/citadel/serv_managesieve.c +++ b/citadel/serv_managesieve.c @@ -40,12 +40,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -68,6 +66,11 @@ #include "snprintf.h" #endif + +#include "ctdl_module.h" + + + #ifdef HAVE_LIBSIEVE #include "serv_sieve.h" @@ -571,27 +574,27 @@ void managesieve_command_loop(void) { } +#endif /* HAVE_LIBSIEVE */ -char *serv_managesieve_init(void) +CTDL_MODULE_INIT(managesieve) { +#ifdef HAVE_LIBSIEVE + CtdlRegisterServiceHook(config.c_managesieve_port, /* MGSVE */ NULL, managesieve_greeting, managesieve_command_loop, NULL); - return "$Id$"; -} - #else /* HAVE_LIBSIEVE */ -char *serv_managesieve_init(void) -{ lprintf(CTDL_INFO, "This server is missing libsieve. Managesieve protocol is disabled..\n"); +#endif /* HAVE_LIBSIEVE */ + /* return our Subversion id for the Log */ return "$Id$"; } -#endif /* HAVE_LIBSIEVE */ + diff --git a/citadel/serv_mrtg.c b/citadel/serv_mrtg.c index ec2493d76..12e09f0f0 100644 --- a/citadel/serv_mrtg.c +++ b/citadel/serv_mrtg.c @@ -35,12 +35,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -49,6 +47,9 @@ #include "tools.h" +#include "ctdl_module.h" + + /* * Other functions call this one to output data in MRTG format */ @@ -127,7 +128,7 @@ void cmd_mrtg(char *argbuf) { } -char *serv_mrtg_init(void) +CTDL_MODULE_INIT(mrtg) { CtdlRegisterProtoHook(cmd_mrtg, "MRTG", "Supply stats to MRTG"); diff --git a/citadel/serv_netfilter.c b/citadel/serv_netfilter.c index 4f6f53bd0..31fced57b 100644 --- a/citadel/serv_netfilter.c +++ b/citadel/serv_netfilter.c @@ -32,12 +32,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -46,6 +44,10 @@ #include "serv_network.h" #include "tools.h" + +#include "ctdl_module.h" + + /* * This handler detects whether an incoming network message is from some * moron user who the site operator has elected to filter out. If a match @@ -103,7 +105,7 @@ int filter_the_idiots(struct CtdlMessage *msg, char *target_room) { } -char *serv_netfilter_init(void) +CTDL_MODULE_INIT(netfilter) { CtdlRegisterNetprocHook(filter_the_idiots); diff --git a/citadel/serv_network.c b/citadel/serv_network.c index 840ebd508..1c8260b9b 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -50,11 +50,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -71,6 +69,11 @@ #include "snprintf.h" #endif + +#include "ctdl_module.h" + + + /* Nonzero while we are doing network processing */ static int doing_queue = 0; @@ -2064,7 +2067,7 @@ int network_room_handler (struct ctdlroom *room) /* * Module entry point */ -char *serv_network_init(void) +CTDL_MODULE_INIT(network) { create_spool_dirs(); CtdlRegisterProtoHook(cmd_gnet, "GNET", "Get network config"); diff --git a/citadel/serv_newuser.c b/citadel/serv_newuser.c index ffde5e3b2..ac47feb10 100644 --- a/citadel/serv_newuser.c +++ b/citadel/serv_newuser.c @@ -38,17 +38,20 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" #include "database.h" #include "msgbase.h" + +#include "ctdl_module.h" + + + extern struct CitContext *ContextList; @@ -92,7 +95,7 @@ void CopyNewUserGreetings(void) { } -char *serv_newuser_init(void) +CTDL_MODULE_INIT(newuser) { CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN); diff --git a/citadel/serv_notes.c b/citadel/serv_notes.c index 23a8d5832..47e968b03 100644 --- a/citadel/serv_notes.c +++ b/citadel/serv_notes.c @@ -31,11 +31,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -43,6 +41,9 @@ #include "msgbase.h" #include "tools.h" +#include "ctdl_module.h" + + /* * If we are in a "notes" view room, and the client has sent an RFC822 @@ -102,7 +103,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg) } -char *serv_notes_init(void) +CTDL_MODULE_INIT(notes) { CtdlRegisterMessageHook(serv_notes_beforesave, EVT_BEFORESAVE); diff --git a/citadel/serv_pas2.c b/citadel/serv_pas2.c index f2bc4e62f..fd7fbf246 100644 --- a/citadel/serv_pas2.c +++ b/citadel/serv_pas2.c @@ -21,17 +21,18 @@ #include #include #include -#include "sysdep_decls.h" #include "citadel.h" #include "server.h" #include "citserver.h" #include "support.h" -#include "serv_extensions.h" #include "user_ops.h" #include "md5.h" #include "tools.h" +#include "ctdl_module.h" + + void cmd_pas2(char *argbuf) { char pw[256]; @@ -85,7 +86,7 @@ void cmd_pas2(char *argbuf) -char *serv_pas2_init(void) +CTDL_MODULE_INIT(pas2) { CtdlRegisterProtoHook(cmd_pas2, "PAS2", "APOP-based login"); diff --git a/citadel/serv_pop3.c b/citadel/serv_pop3.c index a03c6ee6e..c49c5cad9 100644 --- a/citadel/serv_pop3.c +++ b/citadel/serv_pop3.c @@ -43,11 +43,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -63,6 +61,9 @@ #endif +#include "ctdl_module.h" + + /* * This cleanup function blows away the temporary memory and files used by @@ -710,7 +711,7 @@ void pop3_command_loop(void) { -char *serv_pop3_init(void) +CTDL_MODULE_INIT(pop3) { CtdlRegisterServiceHook(config.c_pop3_port, NULL, diff --git a/citadel/serv_rwho.c b/citadel/serv_rwho.c index 6af26ab09..553049c9b 100644 --- a/citadel/serv_rwho.c +++ b/citadel/serv_rwho.c @@ -32,12 +32,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -46,6 +44,8 @@ #include "tools.h" +#include "ctdl_module.h" + /* * display who's online @@ -253,7 +253,7 @@ void cmd_stel(char *cmdbuf) -char *serv_rwho_init(void) +CTDL_MODULE_INIT(rwho) { CtdlRegisterProtoHook(cmd_rwho, "RWHO", "Display who is online"); CtdlRegisterProtoHook(cmd_hchg, "HCHG", "Masquerade hostname"); diff --git a/citadel/serv_sieve.c b/citadel/serv_sieve.c index 525bafb2d..508f8d218 100644 --- a/citadel/serv_sieve.c +++ b/citadel/serv_sieve.c @@ -33,11 +33,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "room_ops.h" #include "policy.h" #include "database.h" @@ -45,6 +43,10 @@ #include "internet_addressing.h" #include "tools.h" + +#include "ctdl_module.h" + + #ifdef HAVE_LIBSIEVE #include "serv_sieve.h" @@ -1247,9 +1249,13 @@ int serv_sieve_room(struct ctdlroom *room) return 0; } +#endif /* HAVE_LIBSIEVE */ -char *serv_sieve_init(void) +CTDL_MODULE_INIT(sieve) { + +#ifdef HAVE_LIBSIEVE + ctdl_sieve_init(); CtdlRegisterProtoHook(cmd_msiv, "MSIV", "Manage Sieve scripts"); @@ -1257,18 +1263,13 @@ char *serv_sieve_init(void) CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE); - /* return our Subversion id for the Log */ - return "$Id$"; -} - #else /* HAVE_LIBSIEVE */ -char *serv_sieve_init(void) -{ lprintf(CTDL_INFO, "This server is missing libsieve. Mailbox filtering will be disabled.\n"); - /* return our Subversion id for the Log */ +#endif /* HAVE_LIBSIEVE */ + + /* return our Subversion id for the Log */ return "$Id$"; } -#endif /* HAVE_LIBSIEVE */ diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 65476a9f4..bfd4f9d50 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -57,12 +57,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -86,6 +84,11 @@ #include "snprintf.h" #endif + +#include "ctdl_module.h" + + + struct citsmtp { /* Information about the current session */ int command_state; char helo_node[SIZ]; @@ -1810,7 +1813,7 @@ void smtp_cleanup_function(void) { -char *serv_smtp_init(void) +CTDL_MODULE_INIT(smtp) { CtdlRegisterServiceHook(config.c_smtp_port, /* SMTP MTA */ diff --git a/citadel/serv_spam.c b/citadel/serv_spam.c index 468a09737..64ad1f5cb 100644 --- a/citadel/serv_spam.c +++ b/citadel/serv_spam.c @@ -36,12 +36,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -53,6 +51,9 @@ #include "clientsocket.h" +#include "ctdl_module.h" + + /* * Connect to the SpamAssassin server and scan a message. @@ -145,7 +146,7 @@ bail: close(sock); -char *serv_spam_init(void) +CTDL_MODULE_INIT(spam) { CtdlRegisterMessageHook(spam_assassin, EVT_SMTPSCAN); diff --git a/citadel/serv_test.c b/citadel/serv_test.c index c79e6aace..356b167b5 100644 --- a/citadel/serv_test.c +++ b/citadel/serv_test.c @@ -29,17 +29,7 @@ #include #include #include -#include "citadel.h" -#include "server.h" -#include "sysdep_decls.h" -#include "citserver.h" -#include "support.h" -#include "config.h" -#include "serv_extensions.h" -#include "room_ops.h" -#include "policy.h" -#include "database.h" -#include "msgbase.h" +#include "ctdl_module.h" extern struct CitContext *ContextList; @@ -65,13 +55,16 @@ void LoginTest(void) { lprintf(CTDL_DEBUG, "--- Hello, %s ---\n", CC->curr_user); } -char *serv_test_init(void) +/* To insert this module into the server activate the next block by changing the #if 0 to #if 1 */ +CTDL_MODULE_INIT(test) { +#if 0 CtdlRegisterCleanupHook(CleanupTest); CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM); CtdlRegisterSessionHook(SessionStartTest, EVT_START); CtdlRegisterSessionHook(SessionStopTest, EVT_STOP); CtdlRegisterSessionHook(LoginTest, EVT_LOGIN); +#endif /* return our Subversion id for the Log */ return "$Id$"; diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index 1c3012a51..2956e79a0 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -31,12 +31,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "database.h" #include "room_ops.h" #include "user_ops.h" @@ -46,6 +44,8 @@ #include "euidindex.h" +#include "ctdl_module.h" + /* * Back end processing function for cmd_bmbx @@ -226,7 +226,7 @@ void check_server_upgrades(void) { } -char *serv_upgrade_init(void) +CTDL_MODULE_INIT(upgrade) { check_server_upgrades(); diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index f5451a555..b1c3630c0 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -32,11 +32,9 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" -#include "serv_extensions.h" #include "database.h" #include "msgbase.h" #include "tools.h" @@ -45,6 +43,12 @@ #include "control.h" #include "euidindex.h" + +#include "ctdl_module.h" + + + + #define END_OF_MESSAGE "---eom---dbd---" char artv_tempfilename1[PATH_MAX]; @@ -726,7 +730,7 @@ void cmd_artv(char *cmdbuf) { -char *serv_vandelay_init(void) +CTDL_MODULE_INIT(vandelay) { CtdlRegisterProtoHook(cmd_artv, "ARTV", "import/export data store"); diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index b8f7a4a0c..ba292dfeb 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -49,12 +49,10 @@ #include #include "citadel.h" #include "server.h" -#include "sysdep_decls.h" #include "citserver.h" #include "support.h" #include "config.h" #include "control.h" -#include "serv_extensions.h" #include "room_ops.h" #include "user_ops.h" #include "policy.h" @@ -67,6 +65,11 @@ #include "serv_ldap.h" #include "serv_vcard.h" + +#include "ctdl_module.h" + + + /* * set global flag calling for an aide to validate new users */ @@ -1326,19 +1329,9 @@ void vcard_fixed_output(char *ptr, int len) { } -char *serv_postfix_tcpdict(void) -{ - CtdlRegisterServiceHook(config.c_pftcpdict_port, /* Postfix */ - NULL, - check_get_greeting, - check_get, - NULL); - return "$Id$"; -} - -char *serv_vcard_init(void) +CTDL_MODULE_INIT(vcard) { struct ctdlroom qr; char filename[256]; @@ -1384,6 +1377,13 @@ char *serv_vcard_init(void) chown(filename, CTDLUID, (-1)); } + /* for postfix tcpdict */ + CtdlRegisterServiceHook(config.c_pftcpdict_port, /* Postfix */ + NULL, + check_get_greeting, + check_get, + NULL); + /* return our Subversion id for the Log */ return "$Id$"; } diff --git a/citadel/server_main.c b/citadel/server_main.c index e4c72ab42..2d2309b09 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -58,6 +58,9 @@ #include "tools.h" #include "citadel_dirs.c" +#include "modules_init.h" + + #ifdef HAVE_SYS_SELECT_H #include #endif @@ -235,7 +238,14 @@ int main(int argc, char **argv) */ lprintf(CTDL_INFO, "Initializing server extensions\n"); size = strlen(ctdl_home_directory) + 9; + +/* initialize_server_extensions(); +*/ + + initialise_modules(); + + /* * If we need host auth, start our chkpwd daemon. diff --git a/citadel/sysdep.c b/citadel/sysdep.c index ae90340fc..761b225c7 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -54,7 +54,6 @@ #endif #include "citadel.h" #include "server.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "citserver.h" #include "support.h" diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index 1efd903e3..f77d6e4a5 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -1,5 +1,7 @@ /* $Id$ */ +#ifndef SYSDEP_DECLS_H +#define SYSDEP_DECLS_H /* * Uncomment this #define if you are a Citadel developer tracking @@ -13,6 +15,7 @@ #include "sysdep.h" #include "server.h" + /* Logging levels - correspond to syslog(3) */ enum LogLevel { /* When about to exit the server for an unrecoverable error */ @@ -103,3 +106,5 @@ void dump_heap(void); void create_maintenance_threads(void); extern pthread_t indexer_thread_tid; extern pthread_t checkpoint_thread_tid; + +#endif /* SYSDEP_DECLS_H */ diff --git a/citadel/techdoc/test_suite.txt b/citadel/techdoc/test_suite.txt new file mode 100644 index 000000000..bb975e6aa --- /dev/null +++ b/citadel/techdoc/test_suite.txt @@ -0,0 +1,45 @@ +SYSTEM TESTING PROPOSAL + +This document is intended as a discussion of possible automated tests. It does +not describe any existing tests. + + +--- + + +First we should create a client that leverages expect (or something similar) to +perform automated testing of the client interface. Tests can be written as +expect scripts. + +Each system being tested will need to create an aide level user for the test +client to connect as. + +The test client will create another user to carry out the tests. This allows the +aide level user to vary the level of the test user and check the access level +code. + +---- + + +For a first step each test site should create a test user that can send internet +mail. +This test user needs some sieve rules to forward mail around (eventually this +will be created automatically by the test client). These rules will forward mail +to other test users at other sites participating in the test system and to a +networked room. +Each system participating in the test should share some rooms. + +The idea is: + 1. A test site posts a message to its test user using citmail or some +other email prog. + 2. The sieve rules forward the message to each of the other test users +at the other sites. + 3. The sieve rules for the other test users detect that the message was +forwarded to them and they file it into a networked room + 4. By virtue of the networked room the message returns to the +originating system where the administrator can see it. + +Once I (davew) have written my module to alter the message body we can have it +add text to the message to indicate the full path of the message. + + diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 4c29bd692..02639007f 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -38,7 +38,6 @@ #include "server.h" #include "database.h" #include "user_ops.h" -#include "serv_extensions.h" #include "sysdep_decls.h" #include "support.h" #include "room_ops.h" -- 2.30.2