* Remove leading '|' from references if present
[citadel.git] / webcit / mk_module_init.sh
blob4f58db1e395a29983611314ef6df8d41520fd233
1 #!/bin/sh
3 # Script to generate $C_FILE
6 ECHO=/usr/bin/printf
8 #MINUS_e=X`$ECHO -n -e`
9 #if [ $MINUS_e != "X" ] ; then
10 # MINUS_e=""
11 #else
12 # MINUS_e="-e"
13 #fi
15 #MINUS_E=X`$ECHO -n -E`
16 #if [ $MINUS_E != "X" ] ; then
17 # MINUS_E=""
18 #else
19 # MINUS_E="-E"
20 #fi
23 CUR_DIR=`pwd`
24 C_FILE="$CUR_DIR/modules_init.c"
25 H_FILE="$CUR_DIR/modules_init.h"
26 MOD_FILE="$CUR_DIR/Make_modules"
27 SRC_FILE="$CUR_DIR/Make_sources"
28 U_FILE="$CUR_DIR/modules_upgrade.c"
30 /usr/bin/printf "Scanning extension modules for entry points.\n"
33 #start of the files which inturn removes any existing file
36 # start the Makefile included file for $SERV_MODULES
37 cat <<EOF >$MOD_FILE
39 # Make_modules
40 # This file is to be included by Makefile to dynamically add modules to the build process
41 # THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
44 EOF
46 # start the Makefile included file for $SOURCES
47 cat <<EOF >$SRC_FILE
49 # Make_sources
50 # This file is to be included by Makefile to dynamically add modules to the build process
51 # THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
54 EOF
56 # start the c file
57 cat <<EOF >$C_FILE
59 * $C_FILE
60 * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
65 #include "sysdep.h"
66 #include <stdlib.h>
67 #include <time.h>
68 #include <ctype.h>
69 #include <stdio.h>
70 #include <sys/types.h>
71 #include <unistd.h>
72 #include <libcitadel.h>
73 #include "webcit.h"
74 #include "modules_init.h"
75 #include "webserver.h"
77 void LogPrintMessages(long err);
78 extern long DetailErrorFlags;
82 void initialise_modules (void)
85 EOF
88 #start the header file
89 cat <<EOF > $H_FILE
90 /*
91 * $H_FILE
92 * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
96 #ifndef MODULES_INIT_H
97 #define MODULES_INIT_H
98 extern size_t nSizErrmsg;
99 void initialise_modules (void);
105 INIT_FUNCS=`grep InitModule_ *.c |sed "s;.*:;;"`
107 for HOOK in $INIT_FUNCS; do
108 HOOKNAME=`echo $HOOK |sed "s;InitModule_;;"`
109 # Add this entry point to the .c file
110 cat <<EOF >> $C_FILE
111 #ifdef DBG_PRINNT_HOOKS_AT_START
112 lprintf (CTDL_INFO, "Initializing $HOOKNAME\n");
113 #endif
114 $HOOK();
116 # Add this entry point to the .h file
117 cat <<EOF >> $H_FILE
118 extern void $HOOK(void);
120 done
123 /usr/bin/printf "}\n" >> $C_FILE
125 /usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE