--------------------- PatchSet 1568 Date: 2001/02/14 11:57:26 Author: rbcollins Branch: generic_modules Tag: (none) Log: module code from rbcollins.filters Members: configure.in:1.17->1.17.4.1 doc/debug-sections.txt:1.3->1.3.10.1 src/Makefile.in:1.7->1.7.4.1 src/cache_cf.c:1.18->1.18.4.1 src/cf.data.pre:1.21->1.21.4.1 src/defines.h:1.8->1.8.8.1 src/enums.h:1.14->1.14.4.1 src/protos.h:1.18->1.18.4.1 src/structs.h:1.24->1.24.4.1 src/typedefs.h:1.15->1.15.4.1 Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.17 retrieving revision 1.17.4.1 diff -u -r1.17 -r1.17.4.1 --- squid/configure.in 1 Feb 2001 09:31:56 -0000 1.17 +++ squid/configure.in 14 Feb 2001 11:57:26 -0000 1.17.4.1 @@ -3,13 +3,13 @@ dnl dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl -dnl $Id: configure.in,v 1.17 2001/02/01 09:31:56 hno Exp $ +dnl $Id: configure.in,v 1.17.4.1 2001/02/14 11:57:26 rbcollins Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) -AC_REVISION($Revision: 1.17 $)dnl +AC_REVISION($Revision: 1.17.4.1 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(cfgaux) @@ -812,6 +812,36 @@ fi AC_SUBST(DIGEST_AUTH_HELPERS) +dnl Select generic modules to build +AC_ARG_ENABLE(modules, +[ --enable-modules=\"list of modules\" + This option selects which generic modules to build. + Generic modules can plugin into several parts of squid + and autoregister their capabilities with squid. For a list + of available modules see the src/modules directory.], +[ case "$enableval" in + yes) + for module in $srcdir/src/modules/*; do + if test -f $module/Makefile.in; then + CONF_MODULES="$CONF_MODULES `basename $module`" + fi + done + ;; + no) + ;; + *) + CONF_MODULES="`echo $enableval|sed -e 's/,/ /g;s/ */ /g'`" + esac +]) +if test -n "$CONF_MODULES"; then + echo "Generic modules built: $CONF_MODULES" + AC_SUBST(CONF_MODULES) + CONF_MODULE_OBJS="modules/`echo $CONF_MODULES|sed -e's% %.a modules/%g'`.a" + AC_SUBST(CONF_MODULE_OBJS) + CONF_MODULE_LIBS="`echo $CONF_MODULE_OBJS|sed -e's%module/%%g'`" + AC_SUBST(CONF_MODULE_LIBS) +fi + dnl Disable "unlinkd" code AC_ARG_ENABLE(unlinkd, [ --disable-unlinkd Do not use unlinkd], @@ -1828,6 +1858,15 @@ fi done +MOD_MAKEFILES="" +for module in `find $srcdir/src/modules -type d -print`; do + if test -f $module/Makefile.in; then + dir=`echo $module | sed -e "s|^$srcdir/||"` + MOD_MAKEFILES="$MOD_MAKEFILES ./$dir/Makefile" + fi +done + + AC_OUTPUT(\ ./makefile \ ./lib/Makefile \ @@ -1842,6 +1881,7 @@ $REPL_MAKEFILES \ ./src/auth/Makefile \ $AUTH_MAKEFILES \ + $MOD_MAKEFILES \ ./contrib/Makefile \ $SNMP_MAKEFILE \ ./icons/Makefile \ Index: squid/doc/debug-sections.txt =================================================================== RCS file: /cvsroot/squid-sf//squid/doc/debug-sections.txt,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -r1.3 -r1.3.10.1 --- squid/doc/debug-sections.txt 7 Jan 2001 23:53:36 -0000 1.3 +++ squid/doc/debug-sections.txt 14 Feb 2001 11:57:26 -0000 1.3.10.1 @@ -86,3 +86,6 @@ section 79 HTTP Meter Header section 80 WCCP section 81 Store Removal/Replacement policy +section 82 Transfer-encoding Routines +section 83 Data processing Filters +section 84 Generic Module Routines Index: squid/src/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/Makefile.in,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -u -r1.7 -r1.7.4.1 --- squid/src/Makefile.in 10 Feb 2001 16:49:03 -0000 1.7 +++ squid/src/Makefile.in 14 Feb 2001 11:57:27 -0000 1.7.4.1 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.7 2001/02/10 16:49:03 hno Exp $ +# $Id: Makefile.in,v 1.7.4.1 2001/02/14 11:57:27 rbcollins Exp $ # # Uncomment and customize the following to suit your needs: # @@ -18,7 +18,7 @@ srcdir = @srcdir@ VPATH = @srcdir@ -SUBDIRS = fs repl auth +SUBDIRS = fs repl auth modules # Gotta love the DOS legacy # @@ -49,6 +49,8 @@ AUTH_OBJS = @AUTH_OBJS@ AUTH_MODULES = @AUTH_MODULES@ +CONF_MODULE_OBJS = @CONF_MODULE_OBJS@ +CONF_MODULES = @CONF_MODULES@ CC = @CC@ MAKEDEPEND = @MAKEDEPEND@ INSTALL = @INSTALL@ @@ -103,6 +105,7 @@ client_side.o \ comm.o \ comm_select.o \ + conf_modules.o \ debug.o \ @DELAY_OBJS@ \ disk.o \ @@ -144,6 +147,7 @@ MemPool.o \ MemBuf.o \ mime.o \ + modules.o \ multicast.o \ neighbors.o \ net_db.o \ @@ -210,8 +214,8 @@ $(SNMP_OBJS): ../snmplib/libsnmp.a $(top_srcdir)/include/cache_snmp.h -$(SQUID_EXE): $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(AUTH_OBJS) - $(CC) -o $@ $(LDFLAGS) $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(AUTH_OBJS) $(SQUID_LIBS) +$(SQUID_EXE): $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(AUTH_OBJS) $(CONF_MODULE_OBJS) + $(CC) -o $@ $(LDFLAGS) $(OBJS) $(STORE_OBJS) $(REPL_OBJS) $(AUTH_OBJS) $(CONF_MODULE_OBJS) $(SQUID_LIBS) globals.o: globals.c Makefile $(CC) -c globals.c $(CFLAGS) -I$(srcdir) $(DEFAULTS) @@ -309,6 +313,15 @@ $(AUTH_OBJS): @sh -c "cd `dirname $@` && $(MAKE) $(MFLAGS) `basename $@`" +conf_modules.c: conf_modules.sh Makefile + sh $(srcdir)/conf_modules.sh $(CONF_MODULES) >conf_modules.c + +conf_modules.o: conf_modules.c + $(CC) -c conf_modules.c $(CFLAGS) -I$(srcdir) + +$(CONF_MODULE_OBJS): + @sh -c "cd `dirname $@` && $(MAKE) $(MFLAGS) `basename $@`" + install-mkdirs: -@if test ! -d $(prefix); then \ echo "mkdir $(prefix)"; \ @@ -417,7 +430,7 @@ clean: -rm -rf *.o *pure_* core $(PROGS) $(UTILS) $(CGIPROGS) $(SUID_UTILS) -rm -f cf_gen cf_gen_defines.h cf_parser.c cf.data globals.c string_arrays.c - -rm -f store_modules.c repl_modules.c auth_modules.c squid.conf + -rm -f store_modules.c repl_modules.c auth_modules.c conf_modules.c squid.conf @for dir in $(SUBDIRS); do \ echo "Making $@ in $$dir..."; \ (cd $$dir ; $(MAKE) $(MFLAGS) prefix="$(prefix)" $@) || exit 1; \ Index: squid/src/cache_cf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_cf.c,v retrieving revision 1.18 retrieving revision 1.18.4.1 diff -u -r1.18 -r1.18.4.1 --- squid/src/cache_cf.c 10 Feb 2001 16:49:03 -0000 1.18 +++ squid/src/cache_cf.c 14 Feb 2001 11:57:27 -0000 1.18.4.1 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.c,v 1.18 2001/02/10 16:49:03 hno Exp $ + * $Id: cache_cf.c,v 1.18.4.1 2001/02/14 11:57:27 rbcollins Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -996,6 +996,102 @@ } } + +CBDATA_TYPE(modNode); +/* Operation of modNode cbdata: + config allocates the record, and free frees it. + any configuration that depends on the record + locks it and + any matching free configuration + unlocks it +*/ + +const char * +mod_type_str(const mod_t type) +{ + switch (type) { + case MOD_INTERNAL: + return "internal"; + break; + case MOD_EXTERNAL: + return "external"; + break; + default: + return "unknown"; + break; + } +} + + +/* TODO: write a cbdataFree handler for modNode's. */ +static void +parse_mod_install(modConfig * cfg) { + char *type_str=NULL, *name_str=NULL; + mod_t type=MOD_NONE; + modNode *node= NULL; + int rv; + + if ((type_str = strtok(NULL, w_space)) == NULL) + self_destruct(); + + if ((name_str = strtok(NULL, w_space)) == NULL) + self_destruct(); + + + + if (strcasecmp(type_str,"internal")==0) { + /* internal module */ + type=MOD_INTERNAL; + } else if (strcasecmp(type_str,"external")==0) { + /* external module */ + debug(3,0)("external modules not supported yet\n"); + } + if (type==MOD_NONE) + self_destruct(); + + CBDATA_INIT_TYPE(modNode); + node=CBDATA_ALLOC(modNode, NULL); + assert(node); + node->type=type; + node->namestr=xstrdup(name_str); + if (type==MOD_INTERNAL) + rv = mod_internal_install(node->namestr, node); +#if 0 + else if (type==MOD_EXTERNAL) + rv = mod_external_install(node->namestr, node); +#endif + else + rv=0; + if (rv) + dlinkAddTail(node,&node->node,&cfg->modules); + else { + safe_free(node->namestr); + cbdataFree(node); + } + +} + +static void +free_mod_install(modConfig * cfg) { + dlink_node *node,*tmpnode; + modNode *module; + node=cfg->modules.head; + while (node) { + tmpnode=node; + module=node->data; + node=node->next; + dlinkDelete(tmpnode,&cfg->modules); + module->uninstall(module->namestr); + cbdataFree(module); + } + cfg->modules.head=NULL; + cfg->modules.tail=NULL; +} + +static void +dump_mod_install(StoreEntry * entry, const char *name, modConfig cfg){ +} + void allocate_new_swapdir(cacheSwap * swap) { Index: squid/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cf.data.pre,v retrieving revision 1.21 retrieving revision 1.21.4.1 diff -u -r1.21 -r1.21.4.1 --- squid/src/cf.data.pre 10 Feb 2001 16:49:04 -0000 1.21 +++ squid/src/cf.data.pre 14 Feb 2001 11:57:27 -0000 1.21.4.1 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.21 2001/02/10 16:49:04 hno Exp $ +# $Id: cf.data.pre,v 1.21.4.1 2001/02/14 11:57:27 rbcollins Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -49,6 +49,25 @@ COMMENT_END COMMENT_START + MODULE OPTIONS + ----------------------------------------------------------------------------- + Squid's module architecture allows dynamic addition and removal + of code from the code base. Modules _must_ be registered before they + are used or referenced (even from other config lines). +COMMENT_END + +NAME: mod_register +TYPE: mod_install +DEFAULT: none +LOC: Config.modules +DOC_START + usage: mod_register internal|external modulename + + External modules are not implemented yet. +DOC_END + + +COMMENT_START NETWORK OPTIONS ----------------------------------------------------------------------------- COMMENT_END Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.8 retrieving revision 1.8.8.1 diff -u -r1.8 -r1.8.8.1 --- squid/src/defines.h 12 Jan 2001 08:20:32 -0000 1.8 +++ squid/src/defines.h 14 Feb 2001 11:57:27 -0000 1.8.8.1 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.8 2001/01/12 08:20:32 hno Exp $ + * $Id: defines.h,v 1.8.8.1 2001/02/14 11:57:27 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -292,3 +292,5 @@ #ifndef O_BINARY #define O_BINARY 0 #endif + + Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/enums.h,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -u -r1.14 -r1.14.4.1 --- squid/src/enums.h 9 Feb 2001 19:52:05 -0000 1.14 +++ squid/src/enums.h 14 Feb 2001 11:57:27 -0000 1.14.4.1 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.14 2001/02/09 19:52:05 hno Exp $ + * $Id: enums.h,v 1.14.4.1 2001/02/14 11:57:27 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -149,6 +149,12 @@ }; typedef enum { + MOD_NONE, + MOD_INTERNAL, + MOD_EXTERNAL +} mod_t; + +typedef enum { PEER_NONE, PEER_SIBLING, PEER_PARENT, Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.18 retrieving revision 1.18.4.1 diff -u -r1.18 -r1.18.4.1 --- squid/src/protos.h 10 Feb 2001 16:49:04 -0000 1.18 +++ squid/src/protos.h 14 Feb 2001 11:57:27 -0000 1.18.4.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.18 2001/02/10 16:49:04 hno Exp $ + * $Id: protos.h,v 1.18.4.1 2001/02/14 11:57:27 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1293,3 +1293,9 @@ * hack to allow snmp access to the statistics counters */ extern StatCounters *snmpStatGet(int); + +/* conf_modules.sh */ +extern int mod_internal_install(const char *, modNode *); +/* modules.c */ +extern void mod_register(const char * namestr, MOD_INSTALL *, MOD_UNINSTALL *, modNode *); + Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.24 retrieving revision 1.24.4.1 diff -u -r1.24 -r1.24.4.1 --- squid/src/structs.h 10 Feb 2001 16:49:04 -0000 1.24 +++ squid/src/structs.h 14 Feb 2001 11:57:27 -0000 1.24.4.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.24 2001/02/10 16:49:04 hno Exp $ + * $Id: structs.h,v 1.24.4.1 2001/02/14 11:57:27 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -292,6 +292,17 @@ sockaddr_in_list *next; }; +struct _modNode { + dlink_node node; + char *namestr; + mod_t type; + MOD_INSTALL *install; + MOD_UNINSTALL *uninstall; +}; + +struct _modConfig { + dlink_list modules; +}; #if DELAY_POOLS struct _delaySpec { @@ -324,6 +335,7 @@ }; struct _SquidConfig { + modConfig modules; struct { size_t maxSize; int highWaterMark; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -u -r1.15 -r1.15.4.1 --- squid/src/typedefs.h 7 Feb 2001 19:11:48 -0000 1.15 +++ squid/src/typedefs.h 14 Feb 2001 11:57:27 -0000 1.15.4.1 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.15 2001/02/07 19:11:48 hno Exp $ + * $Id: typedefs.h,v 1.15.4.1 2001/02/14 11:57:27 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -353,4 +353,13 @@ typedef int STDIRSELECT(const StoreEntry *); +/* modules.c */ +typedef struct _modConfig modConfig; +typedef struct _modNode modNode; + +/* name to register under */ +typedef void MOD_INSTALL(const char *); +typedef void MOD_UNINSTALL(const char *); + + #endif /* _TYPEDEFS_H_ */