Added an entry point to the modules init stuff.
[citadel.git] / citadel / mk_module_init.sh
index aaa13f145b7e037b82585f1d4e4fce54211a3c4e..63a23fddc81f3fcd67891f787d6789ca163c498a 100755 (executable)
@@ -25,7 +25,7 @@ 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"
 
@@ -53,6 +53,36 @@ cat <<EOF  >$SRC_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 <time.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.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
 /*
@@ -104,7 +134,7 @@ cat <<EOF > $H_FILE
 #include "ctdl_module.h"
 extern size_t nSizErrmsg;
 void initialise_modules (int threading);
-
+void upgrade_modules(void);
 EOF
 
 for i in serv_*.c
@@ -114,11 +144,23 @@ do
                RES_OUT=`echo $RES | cut -b2-`
                /usr/bin/printf "Found entry point in file $i\n"
 cat <<EOF  >> $C_FILE
-       lprintf (CTDL_INFO, "%%s\n", CTDL_INIT_CALL($RES_OUT));
+       lprintf (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
+       lprintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+
+EOF
+cat <<EOF >>$H_FILE
+CTDL_MODULE_UPGRADE($RES_OUT);
 EOF
        fi
 done
@@ -157,6 +199,19 @@ 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
+       lprintf (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
@@ -199,6 +254,17 @@ cat <<EOF >> $C_FILE
 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
+       lprintf (CTDL_INFO, "%s\n", CTDL_UPGRADE_CALL($RES_OUT));
+EOF
+cat <<EOF >> $H_FILE
+CTDL_MODULE_UPGRADE($RES_OUT);
 EOF
                                        fi
                                fi
@@ -216,5 +282,7 @@ cd $CUR_DIR
 /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