X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmk_module_init.sh;h=ae1cd375133a4c594c57fc073610fed36459eab6;hb=4b4dc864ede7c5d8d956febe4a0afb422b78e7c4;hp=bf38637b306bfa4b3e51ebceeb1e10c7010ded9d;hpb=76f23da782e9e80dad0a8ae1336230da5a6fa124;p=citadel.git diff --git a/webcit/mk_module_init.sh b/webcit/mk_module_init.sh index bf38637b3..ae1cd3751 100755 --- a/webcit/mk_module_init.sh +++ b/webcit/mk_module_init.sh @@ -29,6 +29,71 @@ U_FILE="$CUR_DIR/modules_upgrade.c" /usr/bin/printf "Scanning extension modules for entry points.\n" +rm -f $C_FILE $H_FILE + +# server lifetime: +START_FUNCS=`grep ServerStartModule_ *.c |sed "s;.*:;;" |sort -u` +INIT_FUNCS=`grep InitModule_ *.c |sed "s;.*:;;" |sort -u` +INIT2_FUNCS=`grep InitModule2_ *.c |sed "s;.*:;;" |sort -u` +FINALIZE_FUNCS=`grep FinalizeModule_ *.c |sed "s;.*:;;" |sort -u` +SHUTDOWN_FUNCS=`grep ServerShutdownModule_ *.c |sed "s;.*:;;" |sort -u` + +# session hooks: +SESS_NEW_FUNCS=`grep SessionNewModule_ *.c |sed "s;.*:;;" |sort -u` +SESS_ATTACH_FUNCS=`grep SessionAttachModule_ *.c |sed "s;.*:;;" |sort -u` +SESS_DETACH_FUNCS=`grep SessionDetachModule_ *.c |sed "s;.*:;;" |sort -u` +SESS_DESTROY_FUNCS=`grep SessionDestroyModule_ *.c |sed "s;.*:;;" |sort -u` + +HTTP_NEW_FUNCS=`grep HttpNewModule_ *.c |sed "s;.*:;;" |sort -u` +HTTP_DETACH_FUNCS=`grep HttpDetachModule_ *.c |sed "s;.*:;;" |sort -u` +HTTP_DESTROY_FUNCS=`grep HttpDestroyModule_ *.c |sed "s;.*:;;" |sort -u` + + +#SESS_NEW_FUNCS=`grep SessionNewModule_ *.c |sed "s;.*:;;" |sort -u` + + +#start the header file +cat < $H_FILE +/* + * $H_FILE + * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE + */ + + +#ifndef MODULES_INIT_H +#define MODULES_INIT_H +extern size_t nSizErrmsg; + + +/* + * server lifetime: + */ +void initialise_modules (void); +void initialise2_modules (void); +void start_modules (void); +void shutdown_modules (void); + + +/* + * Session lifetime: + */ +void session_new_modules (wcsession *sess); +void session_attach_modules (wcsession *sess); +void session_detach_modules (wcsession *sess); +void session_destroy_modules (wcsession **sess); + +void http_new_modules (ParsedHttpHdrs *httpreq); +void http_detach_modules (ParsedHttpHdrs *httpreq); +void http_destroy_modules (ParsedHttpHdrs *httpreq); + + + +/* + * forwards... + */ + +EOF + #start of the files which inturn removes any existing file # @@ -77,47 +142,362 @@ cat <$C_FILE void LogPrintMessages(long err); extern long DetailErrorFlags; +void start_modules (void) +{ +EOF +#******************************************************************************** +# server ******** start ******** module logic. +#******************************************************************************** +cat <> $H_FILE + +/* Server Start Hooks: */ +EOF +for HOOK in $START_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;ServerStartModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Starting $HOOKNAME\n"); +#endif + $HOOK(); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(void); +EOF +done + + +#******************************************************************************** +# server module ******** initialisation ******** logic. +#******************************************************************************** +cat <> $H_FILE + +/* Server Init Hooks: */ +EOF + +cat <>$C_FILE +} void initialise_modules (void) { EOF +for HOOK in $INIT_FUNCS; do + HOOKNAME=`echo $HOOK |sed "s;InitModule_;;"` +# Add this entry point to the .c file + cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Initializing $HOOKNAME\n"); +#endif + $HOOK(); +EOF +# Add this entry point to the .h file + cat <> $H_FILE +extern void $HOOK(void); +EOF +done +#******************************************************************************** +# server module ******** initialisation ******** second stage. +#******************************************************************************** +cat <> $H_FILE -#start the header file -cat < $H_FILE -/* - * $H_FILE - * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE - */ +/* Server Init Hooks: */ +EOF +cat <>$C_FILE +} -#ifndef MODULES_INIT_H -#define MODULES_INIT_H -extern size_t nSizErrmsg; -void initialise_modules (void); +void initialise2_modules (void) +{ EOF +for HOOK in $INIT2_FUNCS; do + HOOKNAME=`echo $HOOK |sed "s;InitModule2_;;"` +# Add this entry point to the .c file + cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Initializing $HOOKNAME\n"); +#endif + $HOOK(); +EOF +# Add this entry point to the .h file + cat <> $H_FILE +extern void $HOOK(void); +EOF +done -INIT_FUNCS=`grep InitModule_ *.c |sed "s;.*:;;"` -for HOOK in $INIT_FUNCS; do -HOOKNAME=`echo $HOOK |sed "s;InitModule_;;"` +#******************************************************************************** +# server module ***** shutdown ***** logic. +#******************************************************************************** +cat <> $H_FILE + +/* Server shutdown Hooks: */ +EOF +cat <>$C_FILE +} + + +void shutdown_modules (void) +{ + +EOF +for HOOK in $SHUTDOWN_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;ServerShutdownModule_;;"` # Add this entry point to the .c file cat <> $C_FILE - lprintf (CTDL_INFO, "Initializing $HOOKNAME\n"); +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Shutting down $HOOKNAME\n"); +#endif $HOOK(); EOF # Add this entry point to the .h file cat <> $H_FILE - extern void $HOOK(void); +extern void $HOOK(void); +EOF +done + + + + +#******************************************************************************** +# NEW-session module logic. +#******************************************************************************** +cat <> $H_FILE + +/* Session New Hooks: */ +EOF +cat <>$C_FILE +} + + +void session_new_modules (wcsession *sess) +{ + +EOF +for HOOK in $SESS_NEW_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;SessionNewModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Initializing $HOOKNAME\n"); +#endif + $HOOK(sess); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(wcsession *sess); +EOF +done + + + +#******************************************************************************** +# ATTACH-Session module logic. +#******************************************************************************** +cat <> $H_FILE + +/* Session Attach Hooks: */ +EOF +cat <>$C_FILE +} + + +void session_attach_modules (wcsession *sess) +{ + +EOF +for HOOK in $SESS_ATTACH_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;SessionAttachModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Attaching Session; $HOOKNAME\n"); +#endif + $HOOK(sess); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(wcsession *sess); EOF done -/usr/bin/printf "}\n" >> $C_FILE -/usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE +#******************************************************************************** +# DETACH-Session module logic. +#******************************************************************************** +cat <> $H_FILE + +/* Session detach Hooks: */ +EOF +cat <>$C_FILE +} + + +void session_detach_modules (wcsession *sess) +{ + +EOF +for HOOK in $SESS_DETACH_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;SessionDetachModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Initializing $HOOKNAME\n"); +#endif + $HOOK(sess); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(wcsession *sess); +EOF +done + + + + +#******************************************************************************** +# DESTROY-Session module logic. +#******************************************************************************** +cat <> $H_FILE + +/* Session destroy Hooks: */ +EOF +cat <>$C_FILE +} + + +void session_destroy_modules (wcsession **sess) +{ + +EOF +for HOOK in $SESS_DESTROY_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;SessionDestroyModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Initializing $HOOKNAME\n"); +#endif + $HOOK(*sess); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(wcsession *sess); +EOF +done + + +cat <>$C_FILE + free((*sess)); + (*sess) = NULL; +} + + +EOF + + + + + +#******************************************************************************** +# NEW-Httprequest module logic. +#******************************************************************************** +cat <> $C_FILE + +void http_new_modules (ParsedHttpHdrs *httpreq) +{ +EOF + +for HOOK in $HTTP_NEW_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;HttpNewModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "NEW $HOOKNAME\n"); +#endif + $HOOK(httpreq); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(ParsedHttpHdrs *httpreq); +EOF +done + +cat <>$C_FILE +} +EOF + +#******************************************************************************** +# DETACH-Httprequest module logic. +#******************************************************************************** +cat <> $C_FILE + +void http_detach_modules (ParsedHttpHdrs *httpreq) +{ +EOF + +for HOOK in $HTTP_DETACH_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;HttpDetachModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Detaching $HOOKNAME\n"); +#endif + $HOOK(httpreq); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(ParsedHttpHdrs *httpreq); +EOF +done + +cat <>$C_FILE +} +EOF + + +#******************************************************************************** +# DESTROY-Httprequest module logic. +#******************************************************************************** +cat <> $C_FILE + +void http_destroy_modules (ParsedHttpHdrs *httpreq) +{ +EOF + +for HOOK in $HTTP_DESTROY_FUNCS; do +HOOKNAME=`echo $HOOK |sed "s;HttpDestroyModule_;;"` +# Add this entry point to the .c file +cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Destructing $HOOKNAME\n"); +#endif + $HOOK(httpreq); +EOF +# Add this entry point to the .h file +cat <> $H_FILE +extern void $HOOK(ParsedHttpHdrs *httpreq); +EOF +done + +cat <>$C_FILE +} +EOF + + + + + + + +cat <> $H_FILE + +#endif /* MODULES_INIT_H */ + +EOF