4f58db1e395a29983611314ef6df8d41520fd233
[citadel.git] / webcit / mk_module_init.sh
1 #!/bin/sh
2 #
3 # Script to generate $C_FILE
4 #
5
6 ECHO=/usr/bin/printf
7
8 #MINUS_e=X`$ECHO -n -e`
9 #if [ $MINUS_e != "X" ] ; then
10 #       MINUS_e=""
11 #else
12 #       MINUS_e="-e"
13 #fi
14
15 #MINUS_E=X`$ECHO -n -E`
16 #if [ $MINUS_E != "X" ] ; then
17 #       MINUS_E=""
18 #else
19 #       MINUS_E="-E"
20 #fi
21
22
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"
29
30 /usr/bin/printf "Scanning extension modules for entry points.\n"
31
32
33 #start of the files which inturn removes any existing file
34 #
35
36 # start the Makefile included file for $SERV_MODULES
37 cat <<EOF  >$MOD_FILE
38 #
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
42 #
43
44 EOF
45
46 # start the Makefile included file for $SOURCES
47 cat <<EOF  >$SRC_FILE
48 #
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
52 #
53
54 EOF
55
56 # start the c file
57 cat <<EOF  >$C_FILE
58 /*
59  * $C_FILE
60  * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
61  */
62
63
64
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"
76
77 void LogPrintMessages(long err);
78 extern long DetailErrorFlags;
79
80
81
82 void initialise_modules (void)
83 {
84
85 EOF
86
87
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
93  */
94
95
96 #ifndef MODULES_INIT_H
97 #define MODULES_INIT_H
98 extern size_t nSizErrmsg;
99 void initialise_modules (void);
100
101
102 EOF
103
104
105 INIT_FUNCS=`grep InitModule_ *.c |sed "s;.*:;;"`
106
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();
115 EOF
116 # Add this entry point to the .h file
117 cat <<EOF >> $H_FILE
118         extern void $HOOK(void);
119 EOF
120 done
121
122
123 /usr/bin/printf "}\n" >> $C_FILE
124
125 /usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE