* Fixed a multiselect bug in the mailbox view. Ctrl-click was selecting a message...
[citadel.git] / citadel / mk_module_init.sh
blob4969208d57340435469df0ed6d66bf66f75b9b64
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 upgrade file
57 cat <<EOF >$U_FILE
59 * $U_FILE
60 * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
65 #include "sysdep.h"
66 #include <stdlib.h>
67 #include <unistd.h>
68 #include <time.h>
69 #include <ctype.h>
70 #include <stdio.h>
71 #include <sys/types.h>
72 #include <unistd.h>
73 #include <libcitadel.h>
74 #include "citadel.h"
75 #include "modules_init.h"
76 #include "sysdep_decls.h"
81 void upgrade_modules (void)
84 CtdlLogPrintf (CTDL_INFO, "Upgrade modules.\n");
86 EOF
88 # start the c file
89 cat <<EOF >$C_FILE
91 * $C_FILE
92 * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
97 #include "sysdep.h"
98 #include <stdlib.h>
99 #include <time.h>
100 #include <ctype.h>
101 #include <stdio.h>
102 #include <sys/types.h>
103 #include <unistd.h>
104 #include <libcitadel.h>
105 #include "citadel.h"
106 #include "modules_init.h"
107 #include "sysdep_decls.h"
110 void LogPrintMessages(long err);
111 extern long DetailErrorFlags;
115 void initialise_modules (int threading)
117 long filter;
118 nSizErrmsg = 0;
120 if (threading)
121 CtdlLogPrintf (CTDL_INFO, "Initialise modules, CtdlThreads enabled.\n");
122 else
123 CtdlLogPrintf (CTDL_INFO, "Initialise modules, CtdlThreads not yet enabled.\n");
127 #start the header file
128 cat <<EOF > $H_FILE
130 * $H_FILE
131 * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
135 #ifndef MODULES_INIT_H
136 #define MODULES_INIT_H
137 #include "ctdl_module.h"
138 extern size_t nSizErrmsg;
139 void initialise_modules (int threading);
140 void upgrade_modules(void);
143 for i in serv_*.c
145 RES=X`grep CTDL_MODULE_INIT $i | cut -f2 -d\( | cut -f1 -d\)`
146 if [ $RES != "X" ] ; then
147 RES_OUT=`echo $RES | cut -b2-`
148 /usr/bin/printf "Found entry point in file $i\n"
149 cat <<EOF >> $C_FILE
150 CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
153 cat <<EOF >>$H_FILE
154 CTDL_MODULE_INIT($RES_OUT);
157 RES=X`grep CTDL_MODULE_UPGRADE $i | cut -f2 -d\( | cut -f1 -d\)`
158 if [ $RES != "X" ] ; then
159 RES_OUT=`echo $RES | cut -b2-`
160 /usr/bin/printf "Found upgrade point in file $i\n"
161 cat <<EOF >> $U_FILE
162 CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
165 cat <<EOF >>$H_FILE
166 CTDL_MODULE_UPGRADE($RES_OUT);
169 done
172 if [ -d "modules" ] ; then
173 cd modules
174 for j in *
176 if [ -d $j ] ; then
177 cd $j
178 for k in *.c
180 if [ -f "$k" ] ; then
181 # Add this .c file to the Makefile included list of SOURCES
182 cat <<EOF >> $SRC_FILE
183 SOURCES += modules/$j/$k
186 # Generate a .o file name
187 O_FILE=`basename $k .c`
188 O_FILE="$O_FILE.o"
189 # Add this .o file to the Makefile included list of SERV_MODULES
190 cat <<EOF >> $MOD_FILE
191 SERV_MODULES += modules/$j/$O_FILE
194 RES=X`grep CTDL_MODULE_INIT $k | cut -f2 -d\( | cut -f1 -d\)`
195 if [ $RES != "X" ] ; then
196 RES_OUT=`echo $RES | cut -b2-`
197 /usr/bin/printf "Found entry point in file modules/$j/$k\n"
198 # Add this entry point to the .c file
199 cat <<EOF >> $C_FILE
200 CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
202 # Add this entry point to the .h file
203 cat <<EOF >> $H_FILE
204 CTDL_MODULE_INIT($RES_OUT);
207 RES=X`grep CTDL_MODULE_UPGRADE $k | cut -f2 -d\( | cut -f1 -d\)`
208 if [ $RES != "X" ] ; then
209 RES_OUT=`echo $RES | cut -b2-`
210 /usr/bin/printf "Found upgrade point in file modules/$j/$k\n"
211 # Add this entry point to the .c file
212 cat <<EOF >> $U_FILE
213 CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
215 # Add this entry point to the .h file
216 cat <<EOF >> $H_FILE
217 CTDL_MODULE_UPGRADE($RES_OUT);
221 done
222 cd ..
224 done
227 cd $CUR_DIR
229 if [ -d "user_modules" ] ; then
230 cd user_modules
231 for j in *
233 if [ -d $j ] ; then
234 cd $j
235 for k in *.c
237 if [ -f "$k" ] ; then
238 # Add this .c file to the Makefile included list of SOURCES
239 cat <<EOF >> $SRC_FILE
240 SOURCES=\$(SOURCES) user_modules/$j/$k
243 # Generate a .o file name
244 O_FILE=`basename $k .c`
245 O_FILE="$O_FILE.o"
246 # Add this .o file to the Makefile included list of SERV_MODULES
247 cat <<EOF >> $MOD_FILE
248 SERV_MODULES += user_modules/$j/$O_FILE
251 RES=X`grep CTDL_MODULE_INIT $k | cut -f2 -d\( | cut -f1 -d\)`
252 if [ $RES != "X" ] ; then
253 RES_OUT=`echo $RES | cut -b2-`
254 /usr/bin/printf "Found entry point in file user_modules/$j/$k\n"
255 cat <<EOF >> $C_FILE
256 CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
258 cat <<EOF >> $H_FILE
259 CTDL_MODULE_INIT($RES_OUT);
262 RES=X`grep CTDL_MODULE_UPGRADE $k | cut -f2 -d\( | cut -f1 -d\)`
263 if [ $RES != "X" ] ; then
264 RES_OUT=`echo $RES | cut -b2-`
265 /usr/bin/printf "Found upgrade point in file user_modules/$j/$k\n"
266 cat <<EOF >> $U_FILE
267 CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
269 cat <<EOF >> $H_FILE
270 CTDL_MODULE_UPGRADE($RES_OUT);
274 done
275 cd ..
277 done
280 cd $CUR_DIR
282 /usr/bin/printf "\n\n" >> $C_FILE
283 /usr/bin/printf "\tfor (filter = 1; filter != 0; filter = filter << 1)\n" >> $C_FILE
284 /usr/bin/printf "\t\tif ((filter & DetailErrorFlags) != 0)\n" >> $C_FILE
285 /usr/bin/printf "\t\t\tLogPrintMessages(filter);\n" >> $C_FILE
286 /usr/bin/printf "}\n" >> $C_FILE
288 #close the upgrade file
289 /usr/bin/printf "}\n" >> $U_FILE
291 /usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE