1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
|
#!/bin/sh
#
# Script to generate $C_FILE
#
ECHO=/usr/bin/printf
#MINUS_e=X`$ECHO -n -e`
#if [ $MINUS_e != "X" ] ; then
# MINUS_e=""
#else
# MINUS_e="-e"
#fi
#MINUS_E=X`$ECHO -n -E`
#if [ $MINUS_E != "X" ] ; then
# MINUS_E=""
#else
# MINUS_E="-E"
#fi
CUR_DIR=`pwd`
C_FILE="$CUR_DIR/modules_init.c"
H_FILE="$CUR_DIR/modules_init.h"
MOD_FILE="$CUR_DIR/Make_modules"
SRC_FILE="$CUR_DIR/Make_sources"
U_FILE="$CUR_DIR/modules_upgrade.c"
/usr/bin/printf "Scanning extension modules for entry points.\n"
#start of the files which inturn removes any existing file
#
# start the Makefile included file for $SERV_MODULES
cat <<EOF >$MOD_FILE
#
# Make_modules
# This file is to be included by Makefile to dynamically add modules to the build process
# THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
#
EOF
# start the Makefile included file for $SOURCES
cat <<EOF >$SRC_FILE
#
# Make_sources
# This file is to be included by Makefile to dynamically add modules to the build process
# THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
#
EOF
# start the upgrade file
cat <<EOF >$U_FILE
/*
* $U_FILE
* Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
*/
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <libcitadel.h>
#include "citadel.h"
#include "modules_init.h"
#include "sysdep_decls.h"
void upgrade_modules (void)
{
CtdlLogPrintf (CTDL_INFO, "Upgrade modules.\n");
EOF
# start the c file
cat <<EOF >$C_FILE
/*
* $C_FILE
* Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
*/
#include "sysdep.h"
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <libcitadel.h>
#include "citadel.h"
#include "modules_init.h"
#include "sysdep_decls.h"
void LogPrintMessages(long err);
extern long DetailErrorFlags;
void initialise_modules (int threading)
{
long filter;
nSizErrmsg = 0;
if (threading)
CtdlLogPrintf (CTDL_INFO, "Initialise modules, CtdlThreads enabled.\n");
else
CtdlLogPrintf (CTDL_INFO, "Initialise modules, CtdlThreads not yet enabled.\n");
/* static server initialization: */
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(citserver));
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(control));
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(euidindex));
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(file_ops));
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(msgbase));
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(room_ops));
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL(user_ops));
/* dynamic modules: */
EOF
#start the header file
cat <<EOF > $H_FILE
/*
* $H_FILE
* Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
*/
#ifndef MODULES_INIT_H
#define MODULES_INIT_H
#include "ctdl_module.h"
extern size_t nSizErrmsg;
void initialise_modules (int threading);
void upgrade_modules(void);
CTDL_MODULE_INIT(citserver);
CTDL_MODULE_INIT(control);
CTDL_MODULE_INIT(euidindex);
CTDL_MODULE_INIT(file_ops);
CTDL_MODULE_INIT(msgbase);
CTDL_MODULE_INIT(room_ops);
CTDL_MODULE_INIT(user_ops);
EOF
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-`
/usr/bin/printf "Found entry point in file $i\n"
cat <<EOF >> $C_FILE
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
EOF
cat <<EOF >>$H_FILE
CTDL_MODULE_INIT($RES_OUT);
EOF
fi
RES=X`grep CTDL_MODULE_UPGRADE $i | cut -f2 -d\( | cut -f1 -d\)`
if [ $RES != "X" ] ; then
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found upgrade point in file $i\n"
cat <<EOF >> $U_FILE
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
EOF
cat <<EOF >>$H_FILE
CTDL_MODULE_UPGRADE($RES_OUT);
EOF
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
# Add this .c file to the Makefile included list of SOURCES
cat <<EOF >> $SRC_FILE
SOURCES += modules/$j/$k
EOF
# Generate a .o file name
O_FILE=`basename $k .c`
O_FILE="$O_FILE.o"
# Add this .o file to the Makefile included list of SERV_MODULES
cat <<EOF >> $MOD_FILE
SERV_MODULES += modules/$j/$O_FILE
EOF
RES=X`grep CTDL_MODULE_INIT $k | cut -f2 -d\( | cut -f1 -d\)`
if [ $RES != "X" ] ; then
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found entry point in file modules/$j/$k\n"
# Add this entry point to the .c file
cat <<EOF >> $C_FILE
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
EOF
# Add this entry point to the .h file
cat <<EOF >> $H_FILE
CTDL_MODULE_INIT($RES_OUT);
EOF
fi
RES=X`grep CTDL_MODULE_UPGRADE $k | cut -f2 -d\( | cut -f1 -d\)`
if [ $RES != "X" ] ; then
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found upgrade point in file modules/$j/$k\n"
# Add this entry point to the .c file
cat <<EOF >> $U_FILE
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
EOF
# Add this entry point to the .h file
cat <<EOF >> $H_FILE
CTDL_MODULE_UPGRADE($RES_OUT);
EOF
fi
fi
done
cd ..
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
# Add this .c file to the Makefile included list of SOURCES
cat <<EOF >> $SRC_FILE
SOURCES += user_modules/$j/$k
EOF
# Generate a .o file name
O_FILE=`basename $k .c`
O_FILE="$O_FILE.o"
# Add this .o file to the Makefile included list of SERV_MODULES
cat <<EOF >> $MOD_FILE
SERV_MODULES += user_modules/$j/$O_FILE
EOF
RES=X`grep CTDL_MODULE_INIT $k | cut -f2 -d\( | cut -f1 -d\)`
if [ $RES != "X" ] ; then
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found entry point in file user_modules/$j/$k\n"
cat <<EOF >> $C_FILE
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_INIT_CALL($RES_OUT));
EOF
cat <<EOF >> $H_FILE
CTDL_MODULE_INIT($RES_OUT);
EOF
fi
RES=X`grep CTDL_MODULE_UPGRADE $k | cut -f2 -d\( | cut -f1 -d\)`
if [ $RES != "X" ] ; then
RES_OUT=`echo $RES | cut -b2-`
/usr/bin/printf "Found upgrade point in file user_modules/$j/$k\n"
cat <<EOF >> $U_FILE
CtdlLogPrintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
EOF
cat <<EOF >> $H_FILE
CTDL_MODULE_UPGRADE($RES_OUT);
EOF
fi
fi
done
cd ..
fi
done
fi
cd $CUR_DIR
/usr/bin/printf "\n\n" >> $C_FILE
/usr/bin/printf "\tfor (filter = 1; filter != 0; filter = filter << 1)\n" >> $C_FILE
/usr/bin/printf "\t\tif ((filter & DetailErrorFlags) != 0)\n" >> $C_FILE
/usr/bin/printf "\t\t\tLogPrintMessages(filter);\n" >> $C_FILE
/usr/bin/printf "}\n" >> $C_FILE
#close the upgrade file
/usr/bin/printf "}\n" >> $U_FILE
/usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE
|