"Fossies" - the Fresh Open Source Software Archive

Member "citadel/scripts/mk_module_init.sh" (5 Jun 2021, 5099 Bytes) of package /linux/www/citadel.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "mk_module_init.sh": 8.24_vs_9.01.

    1 #!/bin/sh
    2 #
    3 # Script to generate $C_FILE
    4 #
    5 
    6 ECHO=/usr/bin/printf
    7 SED=/bin/sed
    8 
    9 #MINUS_e=X`$ECHO -n -e`
   10 #if [ $MINUS_e != "X" ] ; then
   11 #   MINUS_e=""
   12 #else
   13 #   MINUS_e="-e"
   14 #fi
   15 
   16 #MINUS_E=X`$ECHO -n -E`
   17 #if [ $MINUS_E != "X" ] ; then
   18 #   MINUS_E=""
   19 #else
   20 #   MINUS_E="-E"
   21 #fi
   22 
   23 
   24 CUR_DIR=`pwd`
   25 C_FILE="$CUR_DIR/modules_init.c"
   26 H_FILE="$CUR_DIR/modules_init.h"
   27 MOD_FILE="$CUR_DIR/Make_modules"
   28 SRC_FILE="$CUR_DIR/Make_sources"
   29 U_FILE="$CUR_DIR/modules_upgrade.c"
   30 
   31 /usr/bin/printf "Scanning extension modules for entry points.\n"
   32 
   33 STATIC_FIRST_MODULES="control modules euidindex msgbase database"
   34 DYNAMIC_MODULES=`grep CTDL_MODULE_INIT modules/*/*.c |$SED 's;.*(\(.*\));\1;'`
   35 if test -d user_modules; then 
   36     USER_MODULES=`grep CTDL_MODULE_INIT user_modules/*/*.c |$SED 's;.*(\(.*\));\1;'`
   37 else
   38     USER_MODULES=
   39 fi
   40 STATIC_LAST_MODULES="netconfig"
   41 
   42 ###############################################################################
   43 #                        start the c file                                     #
   44 ###############################################################################
   45 
   46 cat <<EOF  >$C_FILE
   47 /*
   48  * $C_FILE
   49  * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
   50  */
   51 
   52 
   53 
   54 #include "sysdep.h"
   55 #include <stdlib.h>
   56 #include <time.h>
   57 #include <ctype.h>
   58 #include <stdio.h>
   59 #include <sys/types.h>
   60 #include <unistd.h>
   61 #include <libcitadel.h>
   62 #include "citadel.h"
   63 #include "modules_init.h"
   64 #include "sysdep_decls.h"
   65 #include "serv_extensions.h"
   66 
   67 
   68 void LogPrintMessages(long err);
   69 extern long DetailErrorFlags;
   70 
   71 void initialise_modules (int threading)
   72 {
   73     long filter;
   74     const char *pMod;
   75 
   76     syslog(LOG_DEBUG, "modules: initializing, CtdlThreads %s", (threading ? "enabled" : "not yet enabled"));
   77 
   78 EOF
   79 
   80 
   81 for i in ${STATIC_FIRST_MODULES} ${DYNAMIC_MODULES} ${USER_MODULES} ${STATIC_LAST_MODULES}; do 
   82 cat <<EOF >> $C_FILE
   83     pMod = CTDL_INIT_CALL($i);
   84     syslog(LOG_DEBUG, "modules: loaded %s", pMod);
   85 EOF
   86 
   87 done
   88 cat <<EOF >> $C_FILE
   89 
   90     for (filter = 1; filter != 0; filter = filter << 1)
   91         if ((filter & DetailErrorFlags) != 0)
   92             LogPrintMessages(filter);
   93 }
   94 
   95 EOF
   96 
   97 
   98 
   99 
  100 
  101 ###############################################################################
  102 #                        start the header file                                #
  103 ###############################################################################
  104 cat <<EOF > $H_FILE
  105 /* 
  106  * $H_FILE
  107  * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
  108  */
  109 
  110 
  111 #ifndef MODULES_INIT_H
  112 #define MODULES_INIT_H
  113 #include "ctdl_module.h"
  114 extern size_t nSizErrmsg;
  115 void initialise_modules (int threading);
  116 void upgrade_modules(void);
  117 
  118 EOF
  119 
  120 for i in ${STATIC_FIRST_MODULES} ${DYNAMIC_MODULES} ${USER_MODULES} ${STATIC_LAST_MODULES}; do 
  121 # Add this entry point to the .h file
  122 cat <<EOF >> $H_FILE
  123     CTDL_MODULE_INIT($i);
  124 EOF
  125 done
  126 
  127 grep CTDL_MODULE_UPGRADE *.c modules/*/*.c  |$SED 's;.*(\(.*\));\CTDL_MODULE_UPGRADE(\1)\;\n;' >> $H_FILE
  128 
  129 cat <<EOF >> $H_FILE
  130 
  131 
  132 #endif /* MODULES_INIT_H */
  133 
  134 EOF
  135 
  136 
  137 ###############################################################################
  138 #             u start the Makefile included file for $SERV_MODULES            #
  139 ###############################################################################
  140 cat <<EOF  >$MOD_FILE
  141 #
  142 # Make_modules
  143 # This file is to be included by Makefile to dynamically add modules to the build process
  144 # THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
  145 #
  146 
  147 SERV_MODULES = \\
  148 EOF
  149 
  150 echo modules/*/*.c | $SED -e "s;\.c ;.o \\\\\n;g" -e "s;\.c;.o;" >> $MOD_FILE
  151 echo >> $MOD_FILE
  152 
  153 
  154 ###############################################################################
  155 #       start of the files which inturn removes any existing file             #
  156 ###############################################################################
  157 
  158 
  159 # start the Makefile included file for $SOURCES
  160 cat <<EOF  >$SRC_FILE
  161 #
  162 # Make_sources
  163 # This file is to be included by Makefile to dynamically add modules to the build process
  164 # THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
  165 #
  166 
  167 SOURCES = \\
  168 EOF
  169 
  170 echo modules/*/*.c | $SED "s;\.c ;.c \\\\\n;g" >> $SRC_FILE
  171 echo >> $SRC_FILE
  172 
  173 
  174 
  175 ###############################################################################
  176 #                     start the upgrade file                                  #
  177 ###############################################################################
  178 cat <<EOF  >$U_FILE
  179 /*
  180  * $U_FILE
  181  * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
  182  */
  183 
  184 
  185 
  186 #include "sysdep.h"
  187 #include <stdlib.h>
  188 #include <unistd.h>
  189 #include <time.h>
  190 #include <ctype.h>
  191 #include <stdio.h>
  192 #include <sys/types.h>
  193 #include <unistd.h>
  194 #include <libcitadel.h>
  195 #include "citadel.h"
  196 #include "modules_init.h"
  197 #include "sysdep_decls.h"
  198 #include "serv_extensions.h"
  199 
  200 
  201 
  202 void upgrade_modules (void)
  203 {
  204         const char *pMod;
  205 
  206         syslog(LOG_INFO, "modules: upgrading.");
  207 
  208 EOF
  209 
  210 # Add this entry point to the .c file
  211 
  212 grep CTDL_MODULE_UPGRADE *.c modules/*/*.c  |$SED 's;.*(\(.*\));\tpMod = CTDL_UPGRADE_CALL(\1)\;\n\tsyslog(LOG_INFO, "modules: %s\\n", pMod)\;\n;' >> $U_FILE
  213 
  214 #close the upgrade file
  215 /usr/bin/printf "}\n" >> $U_FILE