diff -uNbr dotconf-1.0.3/ChangeLog dotconf-1.0.4/ChangeLog --- dotconf-1.0.3/ChangeLog Wed Jun 20 00:09:00 2001 +++ dotconf-1.0.4/ChangeLog Tue Jul 3 12:59:03 2001 @@ -1,3 +1,9 @@ +[2001 07 03] [v1.0.4] + Stephen W. Boyer of caldera.com sent in patches which add + - support for apache compatible wildcard-matching for Include statements + (e.g. now you can use "Include /etc/httpd/modules/*.conf") + - an extern "C" {} block to FIX libpool.h for C++ projects + [2001 06 20] [v1.0.3] Christian Keller of multilink.de sent in patches to correct these bugs: - FIXED: usage of ContextChecker and/or ErrorHandler for Included files. @@ -10,19 +16,19 @@ [2001 03 23] [v1.0.2] - Shane Wegner sent in patches to correct these errors: + Shane Wegner of debian.org sent in patches to correct these errors: - fix an autoconf build issue - fix an index glitch in the CFG_TOGGLE macro - fix dotconf-config to report the correct version number now [2001 02 21] [v1.0.0 (stable)] - enhanced version of the context example (examples/context/*) - this version shows how to create options that are _only_ available in global - context. - - applied an aix compile time fix patch submitted by Eduardo Marcel Macan - - - fixed the behaviour when more than CFG_VALUES arguments where passed, which - would overflow the parameter buffer. + this version shows how to create options that are _only_ available in + global context. + - applied an aix compile time fix patch submitted by + Eduardo Marcel Macan + - fixed the behaviour when more than CFG_VALUES arguments where passed, + which would overflow the parameter buffer. - update documentation (doc/*.txt) - the manpage is hopelessly outdated and will not be installed anymore @@ -136,4 +142,5 @@ [1999 12 30] [v0.1] - initial release v0.1 -Author: Lukas Schröder +Author: Lukas Schroeder + diff -uNbr dotconf-1.0.3/Makefile.am dotconf-1.0.4/Makefile.am --- dotconf-1.0.3/Makefile.am Wed Jan 24 01:25:04 2001 +++ dotconf-1.0.4/Makefile.am Tue Jul 3 13:05:48 2001 @@ -10,3 +10,4 @@ dist-hook: cp -r $(top_srcdir)/examples $(top_distdir)/ + rm -irf `find $(top_distdir) -type d -name "CVS"` diff -uNbr dotconf-1.0.3/Makefile.in dotconf-1.0.4/Makefile.in --- dotconf-1.0.3/Makefile.in Wed Jun 20 00:13:11 2001 +++ dotconf-1.0.4/Makefile.in Tue Jul 3 13:09:15 2001 @@ -420,6 +420,7 @@ dist-hook: cp -r $(top_srcdir)/examples $(top_distdir)/ + rm -irf `find $(top_distdir) -type d -name "CVS"` # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -uNbr dotconf-1.0.3/README dotconf-1.0.4/README --- dotconf-1.0.3/README Sat Mar 24 19:59:50 2001 +++ dotconf-1.0.4/README Tue Jul 3 13:09:11 2001 @@ -1,4 +1,4 @@ -dot.conf v1.0.2 http://www.azzit.de/dotconf/ +dot.conf v1.0.4 http://www.azzit.de/dotconf/ ===================================================================== please refer to the API documentation in the doc/ directory of the @@ -10,13 +10,15 @@ ,--- | Extended Parser `--------> - - indented comments [*new*] - - comments starting anywhere on the line [*new*] - - line continuation (\-Escaped newline) [*new*] - - escaping (via \) [*new*] + - indented comments + - comments starting anywhere on the line + - line continuation (\-Escaped newline) + - escaping (via \) - here documents - substitution of environment variables - both styles of quoting (' and ") + - Apache compatible wildcard-matching for Include's [*new*] + (added in v1.0.4, written by Stephen W. Boyer ) Now the parser is Apache compatible (whoohoo ;) and supports some neat additional features. @@ -24,9 +26,9 @@ ,--- | Extended Core API `--------> - - each configuration file works in its own environment [*new*] - - context sensitivity framework [*new*] - - new API to allow customization of (almost) everything [*new*] + - each configuration file works in its own environment + - context sensitivity framework + - new API to allow customization of (almost) everything - module support - some builtin commands (Include, IncludePath) @@ -42,5 +44,4 @@ This is free software licensed with the GNU Lesser General Public License 2.1. -- lukas schroeder - diff -uNbr dotconf-1.0.3/aclocal.m4 dotconf-1.0.4/aclocal.m4 --- dotconf-1.0.3/aclocal.m4 Wed Jun 20 00:06:24 2001 +++ dotconf-1.0.4/aclocal.m4 Tue Jul 3 12:43:50 2001 @@ -580,35 +580,31 @@ ]) # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl convenience library and INCLTDL to the include flags for -# the libltdl header and adds --enable-ltdl-convenience to the -# configure arguments. Note that LIBLTDL and INCLTDL are not -# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not -# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed -# with '${top_builddir}/' and INCLTDL will be prefixed with -# '${top_srcdir}/' (note the single quotes!). If your package is not -# flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. +# the libltdl convenience library, adds --enable-ltdl-convenience to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl case "$enable_ltdl_convenience" in no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la - INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) ]) # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for -# the libltdl installable library and INCLTDL to the include flags for -# the libltdl header and adds --enable-ltdl-install to the configure -# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is -# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed -# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will -# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed -# with '${top_srcdir}/' (note the single quotes!). If your package is -# not flat and you're not using automake, define top_builddir and -# top_srcdir appropriately in the Makefiles. +# the libltdl installable library, and adds --enable-ltdl-install to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. # In the future, this macro may have to be called after AC_PROG_LIBTOOL. AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_CHECK_LIB(ltdl, main, @@ -621,8 +617,8 @@ ]) if test x"$enable_ltdl_install" = x"yes"; then ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la - INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) else ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL="-lltdl" diff -uNbr dotconf-1.0.3/configure dotconf-1.0.4/configure --- dotconf-1.0.3/configure Wed Jun 20 00:06:26 2001 +++ dotconf-1.0.4/configure Tue Jul 3 12:43:52 2001 @@ -545,9 +545,9 @@ # DOTCONF_MAJOR_VERSION=1 DOTCONF_MINOR_VERSION=0 -DOTCONF_MICRO_VERSION=3 -DOTCONF_INTERFACE_AGE=3 -DOTCONF_BINARY_AGE=3 +DOTCONF_MICRO_VERSION=4 +DOTCONF_INTERFACE_AGE=4 +DOTCONF_BINARY_AGE=4 DOTCONF_VERSION=$DOTCONF_MAJOR_VERSION.$DOTCONF_MINOR_VERSION.$DOTCONF_MICRO_VERSION @@ -737,7 +737,7 @@ PACKAGE=dotconf -VERSION=1.0.3 +VERSION=1.0.4 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff -uNbr dotconf-1.0.3/configure.in dotconf-1.0.4/configure.in --- dotconf-1.0.3/configure.in Wed Jun 20 00:05:56 2001 +++ dotconf-1.0.4/configure.in Tue Jul 3 11:52:58 2001 @@ -10,9 +10,9 @@ # DOTCONF_MAJOR_VERSION=1 DOTCONF_MINOR_VERSION=0 -DOTCONF_MICRO_VERSION=3 -DOTCONF_INTERFACE_AGE=3 -DOTCONF_BINARY_AGE=3 +DOTCONF_MICRO_VERSION=4 +DOTCONF_INTERFACE_AGE=4 +DOTCONF_BINARY_AGE=4 DOTCONF_VERSION=$DOTCONF_MAJOR_VERSION.$DOTCONF_MINOR_VERSION.$DOTCONF_MICRO_VERSION AC_SUBST(DOTCONF_MAJOR_VERSION) @@ -32,7 +32,7 @@ AC_SUBST(LT_REVISION) AC_SUBST(LT_AGE) -AM_INIT_AUTOMAKE(dotconf, 1.0.3) +AM_INIT_AUTOMAKE(dotconf, 1.0.4) AM_CONFIG_HEADER(config.h) AC_CANONICAL_HOST Binary files dotconf-1.0.3/examples/caseinsensitive/caseinsensitive.o and dotconf-1.0.4/examples/caseinsensitive/caseinsensitive.o differ diff -uNbr dotconf-1.0.3/libpool/libpool.h dotconf-1.0.4/libpool/libpool.h --- dotconf-1.0.3/libpool/libpool.h Wed Jan 24 01:25:15 2001 +++ dotconf-1.0.4/libpool/libpool.h Sat Jun 30 13:05:35 2001 @@ -1,6 +1,10 @@ #ifndef ST_HAVE_POOL_H #define ST_HAVE_POOL_H +#ifdef __cplusplus +extern "C" { +#endif + typedef struct pool pool_t; /* ------ pool_new - create and return a new pool; make a sub-pool of p if p is non-NULL -------- */ @@ -27,5 +31,10 @@ /* duplicate the first n non-null characters beginning at str */ char *pool_strndup(struct pool *pool, const char *str, int n); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif #endif diff -uNbr dotconf-1.0.3/mkinstalldirs dotconf-1.0.4/mkinstalldirs --- dotconf-1.0.3/mkinstalldirs Wed Jan 24 01:25:15 2001 +++ dotconf-1.0.4/mkinstalldirs Sat Jun 30 12:59:12 2001 @@ -4,7 +4,7 @@ # Created: 1993-05-16 # Public domain -# $Id: mkinstalldirs,v 1.1.1.1 2000/01/29 12:56:44 lukas Exp $ +# $Id: mkinstalldirs,v 1.1.1.1 2001/06/30 10:59:12 lukas Exp $ errstatus=0 diff -uNbr dotconf-1.0.3/src/dotconf.c dotconf-1.0.4/src/dotconf.c --- dotconf-1.0.3/src/dotconf.c Wed Jun 20 00:12:13 2001 +++ dotconf-1.0.4/src/dotconf.c Tue Jul 3 11:52:16 2001 @@ -24,10 +24,24 @@ #include #include +/* Added by Stephen W. Boyer + * for wildcard support in Include file paths + */ +#include +#include +#include +#include +#include +#include + /* -- AIX 4.3 compile time fix * by Eduardo Marcel Macan + * + * modified by Stephen W. Boyer + * for Unixware and OpenServer */ -#ifdef _AIX43 + +#if defined (_AIX43) || defined(UNIXWARE) || defined(OSR5) #include #endif @@ -664,6 +678,511 @@ free(configfile); } +/* ------ internal utility function that verifies if a character is in the WILDCARDS list -- */ +int dotconf_is_wild_card(char value) +{ + int retval = 0; + int i; + int wildcards_len = strlen(WILDCARDS); + + for (i=0;i 0 && path != NULL && pre != NULL && ext != NULL ) + { + prefix_len = strcspn(filename,WILDCARDS); /* find any wildcard in WILDCARDS */ + + if ( prefix_len < len ) /* Wild card found */ + { + tmp = filename + prefix_len; + tmp_count = prefix_len + 1; + + while ( tmp != filename && *(tmp) != '/' ) + { + tmp--; + tmp_count--; + } + + if ( *(tmp) == '/' ) + { + *path = (char*)malloc(tmp_count+1); + found_path = 1; + + } else + + *path = (char*)malloc(1); + + *pre = (char*)malloc((prefix_len-(tmp_count-(found_path?0:1)))+1); + + if ( *path && *pre ) + { + if (found_path) + strncpy(*path,filename,tmp_count); + (*path)[tmp_count] = '\0'; + + strncpy(*pre,(tmp+(found_path?1:0)), + (prefix_len-(tmp_count-(found_path?0:1)))); + (*pre)[(prefix_len-(tmp_count-(found_path?0:1)))] = '\0'; + + *ext = filename + prefix_len; + *wildcard = (**ext); + (*ext)++; + + retval = prefix_len; + + } + + } + + } + + return retval; +} + +/* ------ internal utility function that compares two stings from back to front -- */ +int dotconf_strcmp_from_back(const char* s1, const char* s2) +{ + int retval = 0; + int i,j; + int len_1 = strlen(s1); + int len_2 = strlen(s2); + + for (i=len_1,j=len_2;(i>=0 && j>=0);i--,j--) + { + if (s1[i] != s2[j]) + { + retval = -1; + break; + } + } + + return retval; +} + +/* ------ internal utility function that determins if a string matches the '?' criteria -- */ +int dotconf_question_mark_match(char* dir_name, char* pre, char* ext) +{ + int retval = -1; + int dir_name_len = strlen(dir_name); + int pre_len = strlen(pre); + int ext_len = strlen(ext); + int w_card_check = strcspn(ext,WILDCARDS); + + if ( (w_card_check < ext_len) && (strncmp(dir_name,pre,pre_len) == 0) + && (strcmp(dir_name,".") != 0 ) && (strcmp(dir_name,"..") != 0) ) + { + retval = 1; /* Another wildcard found */ + + } else { + + if ((dir_name_len >= pre_len) && + (strncmp(dir_name,pre,pre_len) == 0) && + (strcmp(dir_name,".") != 0 ) && + (strcmp(dir_name,"..") != 0)) + { + retval = 0; /* Matches no other wildcards */ + } + + } + + return retval; +} + +/* ------ internal utility function that determins if a string matches the '*' criteria -- */ +int dotconf_star_match(char* dir_name, char* pre, char* ext) +{ + int retval = -1; + int dir_name_len = strlen(dir_name); + int pre_len = strlen(pre); + int ext_len = strlen(ext); + int w_card_check = strcspn(ext,WILDCARDS); + + if ( (w_card_check < ext_len) && (strncmp(dir_name,pre,pre_len) == 0) + && (strcmp(dir_name,".") != 0 ) && (strcmp(dir_name,"..") != 0) ) + { + retval = 1; /* Another wildcard found */ + + } else { + + if ((dir_name_len >= (ext_len + pre_len)) && + (dotconf_strcmp_from_back(dir_name,ext) == 0) && + (strncmp(dir_name,pre,pre_len) == 0) && + (strcmp(dir_name,".") != 0 ) && + (strcmp(dir_name,"..") != 0)) + { + retval = 0; /* Matches no other wildcards */ + } + + } + + return retval; +} + +/* ------ internal utility function that determins matches for filenames with -- */ +/* ------ a '?' in name and calls the Internal Include function on that filename -- */ +int dotconf_handle_question_mark(command_t* cmd, char* path, char* pre, char* ext) +{ + configfile_t *included; + DIR* dh = 0; + struct dirent* dirptr = 0; + + char new_pre[CFG_MAX_FILENAME]; + char already_matched[CFG_MAX_FILENAME]; + + char wc = '\0'; + + char* new_path = 0; + char* wc_path = 0; + char* wc_pre = 0; + char* wc_ext = 0; + + int pre_len; + int new_path_len; + int name_len = 0; + int alloced = 0; + int match_state = 0; + + pre_len = strlen(pre); + + if ((dh = opendir(path)) != NULL) + { + while ( (dirptr = readdir(dh)) != NULL ) + { + match_state = dotconf_question_mark_match(dirptr->d_name,pre,ext); + + if (match_state >= 0) + { + name_len = strlen(dirptr->d_name); + new_path_len = strlen(path) + name_len + strlen(ext) + 1; + + if ( !alloced ) + { + if ((new_path = (char*)malloc(new_path_len)) == NULL ) + { + return -1; + } + + alloced = new_path_len; + + } else { + + if ( new_path_len > alloced ) + { + if ( realloc(new_path,new_path_len) == NULL ) + { + free(new_path); + return -1; + } + + } + + } + + if (match_state == 1) + { + + strncpy(new_pre,dirptr->d_name,(name_len > pre_len)?(pre_len+1):pre_len); + new_pre[(name_len > pre_len)?(pre_len+1):pre_len] = '\0'; + + sprintf(new_path,"%s%s%s",path,new_pre,ext); + + if (strcmp(new_path,already_matched) == 0) + { + continue; /* Already searched this expression */ + + } else { + + strcpy(already_matched,new_path); + + } + + if (dotconf_find_wild_card(new_path,&wc,&wc_path,&wc_pre,&wc_ext) >= 0) + { + if ( dotconf_handle_wild_card(cmd,wc,wc_path,wc_pre,wc_ext) < 0) + { + dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, + "Error occured while processing wildcard %c\n" + "Filename is '%s'\n", wc, new_path); + + free(new_path); + dotconf_wild_card_cleanup(wc_path,wc_pre); + return -1; + } + + dotconf_wild_card_cleanup(wc_path,wc_pre); + continue; + } + + } + + sprintf(new_path,"%s%s",path,dirptr->d_name); + + if (access(new_path, R_OK)) + { + dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, + "Cannot open %s for inclusion.\n" + "IncludePath is '%s'\n", new_path, cmd->configfile->includepath); + return -1; + } + + included = dotconf_create(new_path, cmd->configfile->config_options[1], + cmd->configfile->context, cmd->configfile->flags); + if (included) + { + included->errorhandler = cmd->configfile->errorhandler; + included->contextchecker = cmd->configfile->contextchecker; + dotconf_command_loop(included); + dotconf_cleanup(included); + } + + } + + } + + closedir(dh); + free(new_path); + + } + + return 0; +} + +/* ------ internal utility function that determins matches for filenames with --- */ +/* ------ a '*' in name and calls the Internal Include function on that filename -- */ +int dotconf_handle_star(command_t* cmd, char* path, char* pre, char* ext) +{ + configfile_t *included; + DIR* dh = 0; + struct dirent* dirptr = 0; + + char new_pre[CFG_MAX_FILENAME]; + char new_ext[CFG_MAX_FILENAME]; + char already_matched[CFG_MAX_FILENAME]; + + char wc = '\0'; + + char* new_path = 0; + char* s_ext = 0; + char* t_ext = 0; + char* sub = 0; + char* wc_path = 0; + char* wc_pre = 0; + char* wc_ext = 0; + + int pre_len; + int new_path_len; + int name_len = 0; + int alloced = 0; + int match_state = 0; + int t_ext_count = 0; + int sub_count = 0; + + pre_len = strlen(pre); + memset(already_matched,0,CFG_MAX_FILENAME); + s_ext = ext; + + while (dotconf_is_wild_card(*s_ext)) /* remove trailing wild-cards proceeded by * */ + { + s_ext++; + } + + t_ext = s_ext; + + while(t_ext != NULL && !(dotconf_is_wild_card(*t_ext)) && *t_ext != '\0') + { + t_ext++; /* find non-wild-card string */ + t_ext_count++; + } + + strncpy(new_ext,s_ext,t_ext_count); + new_ext[t_ext_count] = '\0'; + + if ((dh = opendir(path)) != NULL) + { + while ( (dirptr = readdir(dh)) != NULL ) + { + sub_count = 0; + t_ext_count = 0; + + match_state = dotconf_star_match(dirptr->d_name,pre,s_ext); + + if (match_state >= 0) + { + name_len = strlen(dirptr->d_name); + new_path_len = strlen(path) + name_len + strlen(s_ext) + 1; + + if ( !alloced ) + { + if ((new_path = (char*)malloc(new_path_len)) == NULL ) + { + return -1; + } + + alloced = new_path_len; + + } else { + + if ( new_path_len > alloced ) + { + if ( realloc(new_path,new_path_len) == NULL ) + { + free(new_path); + return -1; + } + + } + + } + + if (match_state == 1) + { + + if ((sub = strstr((dirptr->d_name+pre_len),new_ext)) == NULL) + { + continue; + } + + while (sub != dirptr->d_name) + { + sub--; + sub_count++; + } + + if (sub_count + t_ext_count > name_len) + { + continue; + } + + strncpy(new_pre,dirptr->d_name,(sub_count+t_ext_count)); + new_pre[sub_count+t_ext_count] = '\0'; + strcat(new_pre,new_ext); + + sprintf(new_path,"%s%s%s",path,new_pre,t_ext); + + if (strcmp(new_path,already_matched) == 0) + { + continue; /* Already searched this expression */ + + } else { + + strcpy(already_matched,new_path); + + } + + if (dotconf_find_wild_card(new_path,&wc,&wc_path,&wc_pre,&wc_ext) >= 0) + { + if ( dotconf_handle_wild_card(cmd,wc,wc_path,wc_pre,wc_ext) < 0) + { + dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, + "Error occured while processing wildcard %c\n" + "Filename is '%s'\n", wc, new_path); + + free(new_path); + dotconf_wild_card_cleanup(wc_path,wc_pre); + return -1; + } + + dotconf_wild_card_cleanup(wc_path,wc_pre); + continue; + } + + } + + sprintf(new_path,"%s%s",path,dirptr->d_name); + + if (access(new_path, R_OK)) + { + dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, + "Cannot open %s for inclusion.\n" + "IncludePath is '%s'\n", new_path, cmd->configfile->includepath); + return -1; + } + + included = dotconf_create(new_path, cmd->configfile->config_options[1], + cmd->configfile->context, cmd->configfile->flags); + if (included) + { + included->errorhandler = cmd->configfile->errorhandler; + included->contextchecker = cmd->configfile->contextchecker; + dotconf_command_loop(included); + dotconf_cleanup(included); + } + + } + + } + + closedir(dh); + free(new_path); + + } + + return 0; +} /* ------ callbacks of the internal option (Include, IncludePath) ------------------------------- */ DOTCONF_CB(dotconf_cb_include) @@ -671,6 +1190,12 @@ char *filename = 0; configfile_t *included; + char wild_card; + char* path = 0; + char* pre = 0; + char* ext = 0; + + if (cmd->configfile->includepath && cmd->data.str[0] != '/' && cmd->configfile->includepath[0] != '\0') { @@ -700,6 +1225,21 @@ } else /* fully qualified, or no includepath */ filename = strdup(cmd->data.str); + + /* Added wild card support here */ + if (dotconf_find_wild_card(filename,&wild_card,&path,&pre,&ext) >= 0) + { + if ( dotconf_handle_wild_card(cmd,wild_card,path,pre,ext) < 0) + { + dotconf_warning(cmd->configfile, DCLOG_WARNING, ERR_INCLUDE_ERROR, + "Error occured while attempting to process %s for inclusion.\n" + "IncludePath is '%s'\n", filename, cmd->configfile->includepath); + } + + dotconf_wild_card_cleanup(path,pre); + free(filename); + return NULL; + } if (access(filename, R_OK)) { diff -uNbr dotconf-1.0.3/src/dotconf.h dotconf-1.0.4/src/dotconf.h --- dotconf-1.0.3/src/dotconf.h Sat Jun 2 14:06:35 2001 +++ dotconf-1.0.4/src/dotconf.h Tue Jul 3 11:52:16 2001 @@ -18,6 +18,7 @@ #define CFG_VALUES 16 /* max # of arguments an option takes */ #define CFG_INCLUDEPATH_ENV "DC_INCLUDEPATH" +#define WILDCARDS "*?" /* list of supported wild-card characters */ /* constants for type of option */ #define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */ @@ -215,6 +216,37 @@ /* ------ dotconf_substitute_env() - handle the substitution on environment variables ----------- */ char *dotconf_substitute_env(configfile_t *, char *); + +/* ------ internal utility function that verifies if a character is in the WILDCARDS list -- */ +int dotconf_is_wild_card(char value); + +/* ------ internal utility function that calls the appropriate routine for the wildcard passed in -- */ +int dotconf_handle_wild_card(command_t* cmd, char wild_card, char* path, char* pre, char* ext); + +/* ------ internal utility function that frees allocated memory from dotcont_find_wild_card -- */ +void dotconf_wild_card_cleanup(char* path, char* pre); + +/* ------ internal utility function to check for wild cards in file path -- */ +/* ------ path and pre must be freed by the developer ( dotconf_wild_card_cleanup) -- */ +int dotconf_find_wild_card(char* filename, char* wildcard, char** path, char** pre, char** ext); + +/* ------ internal utility function that compares two stings from back to front -- */ +int dotconf_strcmp_from_back(const char* s1, const char* s2); + +/* ------ internal utility function that determins if a string matches the '?' criteria -- */ +int dotconf_question_mark_match(char* dir_name, char* pre, char* ext); + +/* ------ internal utility function that determins if a string matches the '*' criteria -- */ +int dotconf_star_match(char* dir_name, char* pre, char* ext); + +/* ------ internal utility function that determins matches for filenames with -- */ +/* ------ a '?' in name and calls the Internal Include function on that filename -- */ +int dotconf_handle_question_mark(command_t* cmd, char* path, char* pre, char* ext); + +/* ------ internal utility function that determins matches for filenames with -- */ +/* ------ a '*' in name and calls the Internal Include function on that filename -- */ +int dotconf_handle_star(command_t* cmd, char* path, char* pre, char* ext); + #ifdef __cplusplus