Index: INSTALL ================================================================== --- INSTALL +++ INSTALL @@ -5,5 +5,13 @@ $ ./configure $ make $ make install (note that `make' must not be BSD make, all other makes work fine.) + + +OPTIONAL DEPENDENCIES: + * libopennet (http://www.rkeene.org/oss/libopennet/) + Libopennet allows URLs to be opened as easily as files, if it is + available (and the --without-libopennet argument isn't passed to + the `configure' script) libconfig will be able to process config + files that are passed as URLs. Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -68,11 +68,13 @@ -$(INSTALL) -d $(includedir) $(INSTALL) -m 755 libconfig.$(SHOBJEXT) $(libdir)/libconfig.$(SHOBJEXT).$(PKGVERS) $(INSTALL) -m 644 libconfig.$(AREXT) $(libdir)/libconfig.$(AREXT) $(INSTALL) -m 644 lc_register_callback.3 $(mandir)/man3/lc_register_callback.3 $(INSTALL) -m 644 lc_register_var.3 $(mandir)/man3/lc_register_var.3 + $(INSTALL) -m 644 lc_process_file.3 $(mandir)/man3/lc_process_file.3 $(INSTALL) -m 644 lc_geterrstr.3 $(mandir)/man3/lc_geterrstr.3 $(INSTALL) -m 644 lc_geterrno.3 $(mandir)/man3/lc_geterrno.3 $(INSTALL) -m 644 lc_process.3 $(mandir)/man3/lc_process.3 + $(INSTALL) -m 644 lc_cleanup.3 $(mandir)/man3/lc_cleanup.3 $(INSTALL) -m 644 libconfig.h $(includedir)/libconfig.h -( cd $(libdir) && rm -f libconfig.$(SHOBJEXT).$(PKGVERSMAJOR) && $(LN_S) libconfig.$(SHOBJEXT).$(PKGVERS) libconfig.$(SHOBJEXT).$(PKGVERSMAJOR) ) -( cd $(libdir) && rm -f libconfig.$(SHOBJEXT) && $(LN_S) libconfig.$(SHOBJEXT).$(PKGVERS) libconfig.$(SHOBJEXT) ) Index: aclocal.m4 ================================================================== --- aclocal.m4 +++ aclocal.m4 @@ -113,5 +113,67 @@ SHOBJLDFLAGS='-shared -Wl,--enable-auto-image-base -Wl,--output-def,$[@].def,--out-implib,$[@].a' ;; esac ]) + +AC_DEFUN(DC_ASK_OPTLIB, [ + AC_ARG_WITH($5, [ --with-$5 $4], [ +# Specified + LIBSPEC=$withval + ], [ +# Not specified + LIBSPECFLAGS=`pkg-config --libs $5 2>/dev/null` + LIBSPECCFLAGS=`pkg-config --cflags $5 2>/dev/null` + AC_CHECK_LIB($1, $2, [ + OLDCPPFLAGS="$CPPFLAGS" + OLDCFLAGS="$CFLAGS" + CPPFLAGS="$CPPFLAGS $LIBSPECCFLAGS" + CFLAGS="$CFLAGS $LIBSPECCFLAGS" + AC_CHECK_HEADER($3, [ + LIBSPEC=yes + ], [ + LIBSPEC=no + ]) + CPPFLAGS="$OLDCPPFLAGS" + CFLAGS="$OLDCFLAGS" + ], [ + LIBSPEC=no + AC_MSG_WARN(Didn't find $5) + ], $LIBSPECFLAGS) + ]) + case $LIBSPEC in + no) + AC_MSG_WARN(Support for $5 disabled) + ;; + *) + if test "${LIBSPEC}" = "yes"; then + true + else + LIBSPECFLAGS="-L${LIBSPEC}/lib ${LIBSPECFLAGS}" + LIBSPECCFLAGS="-I${LIBSPEC}/include ${LIBSPECCFLAGS}" + fi + AC_CHECK_LIB($1, $2, [ + OLDCFLAGS="$CFLAGS" + OLDCPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS ${LIBSPECCFLAGS}" + CFLAGS="$CFLAGS ${LIBSPECCFLAGS}" + AC_CHECK_HEADER($3, [ + if test -n "$7"; then + AC_DEFINE($7, [1], [Define to 1 if you have the <$3> header file.]) + fi + if test -n "$6"; then + AC_DEFINE($6, [1], [Define to 1 if you have $2 from $5]) + fi + LDFLAGS="$LDFLAGS $LIBSPECFLAGS" + LIBS="$LIBS -l$1" + ], [ + CFLAGS="$OLDCFLAGS" + CPPFLAGS="$OLDCPPFLAGS" + AC_MSG_ERROR(Could not find $3) + ]) + ], [ + AC_MSG_ERROR(Could not find $5) + ], $LIBSPECFLAGS) + ;; + esac +]) Index: compat.h ================================================================== --- compat.h +++ compat.h @@ -77,7 +77,16 @@ #include #else #include #endif #endif + +#ifdef HAVE_OPENNET_H +#include +#endif +#ifdef HAVE_LIBOPENNET +#define lc_fopen(path, mode) fopen_net(path, mode) +#else +#define lc_fopen(path, mode) fopen(path, mode) +#endif #endif Index: conf_apache.c ================================================================== --- conf_apache.c +++ conf_apache.c @@ -100,11 +100,11 @@ if (configfile == NULL) { lc_errno = LC_ERR_INVDATA; return(-1); } - configfp = fopen(configfile, "r"); + configfp = lc_fopen(configfile, "r"); if (configfp == NULL) { lc_errno = LC_ERR_CANTOPEN; return(-1); } Index: conf_section.c ================================================================== --- conf_section.c +++ conf_section.c @@ -26,11 +26,11 @@ if (appname == NULL || configfile == NULL) { lc_errno = LC_ERR_INVDATA; return(-1); } - configfp = fopen(configfile, "r"); + configfp = lc_fopen(configfile, "r"); if (configfp == NULL) { lc_errno = LC_ERR_CANTOPEN; return(-1); } Index: conf_space.c ================================================================== --- conf_space.c +++ conf_space.c @@ -23,11 +23,11 @@ if (appname == NULL || configfile == NULL) { lc_errno = LC_ERR_INVDATA; return(-1); } - configfp = fopen(configfile, "r"); + configfp = lc_fopen(configfile, "r"); if (configfp == NULL) { lc_errno = LC_ERR_CANTOPEN; return(-1); } Index: config.h.in ================================================================== --- config.h.in +++ config.h.in @@ -1,6 +1,6 @@ -/* config.h.in. Generated from configure.in by autoheader. */ +/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the header file. */ @@ -9,13 +9,19 @@ /* Define to 1 if you have the `getpwuid' function. */ #undef HAVE_GETPWUID /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H + +/* Define to 1 if you have open_net from libopennet */ +#undef HAVE_LIBOPENNET /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENNET_H /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H /* Define to 1 if you have the header file. */ Index: configure ================================================================== --- configure +++ configure @@ -1,9 +1,9 @@ #! /bin/sh -# From configure.in Revision . +# From configure.ac Revision . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for libconfig 0.1.4. +# Generated by GNU Autoconf 2.59 for libconfig 0.1.5. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -266,12 +266,12 @@ : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME='libconfig' PACKAGE_TARNAME='libconfig' -PACKAGE_VERSION='0.1.4' -PACKAGE_STRING='libconfig 0.1.4' +PACKAGE_VERSION='0.1.5' +PACKAGE_STRING='libconfig 0.1.5' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. ac_includes_default="\ #include @@ -776,11 +776,11 @@ # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libconfig 0.1.4 to adapt to many kinds of systems. +\`configure' configures libconfig 0.1.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. @@ -837,14 +837,19 @@ _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libconfig 0.1.4:";; + short | recursive ) echo "Configuration of libconfig 0.1.5:";; esac cat <<\_ACEOF +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-libopennet Enable opennet support + Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory @@ -948,11 +953,11 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -libconfig configure 0.1.4 +libconfig configure 0.1.5 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -962,11 +967,11 @@ exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libconfig $as_me 0.1.4, which was +It was created by libconfig $as_me 0.1.5, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF @@ -15652,10 +15657,517 @@ done +# Check whether --with-libopennet or --without-libopennet was given. +if test "${with_libopennet+set}" = set; then + withval="$with_libopennet" + +# Specified + LIBSPEC=$withval + +else + +# Not specified + LIBSPECFLAGS=`pkg-config --libs libopennet 2>/dev/null` + LIBSPECCFLAGS=`pkg-config --cflags libopennet 2>/dev/null` + echo "$as_me:$LINENO: checking for open_net in -lopennet" >&5 +echo $ECHO_N "checking for open_net in -lopennet... $ECHO_C" >&6 +if test "${ac_cv_lib_opennet_open_net+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lopennet $LIBSPECFLAGS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char open_net (); +int +main () +{ +open_net (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_opennet_open_net=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_opennet_open_net=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_open_net" >&5 +echo "${ECHO_T}$ac_cv_lib_opennet_open_net" >&6 +if test $ac_cv_lib_opennet_open_net = yes; then + + OLDCPPFLAGS="$CPPFLAGS" + OLDCFLAGS="$CFLAGS" + CPPFLAGS="$CPPFLAGS $LIBSPECCFLAGS" + CFLAGS="$CFLAGS $LIBSPECCFLAGS" + if test "${ac_cv_header_opennet_h+set}" = set; then + echo "$as_me:$LINENO: checking for opennet.h" >&5 +echo $ECHO_N "checking for opennet.h... $ECHO_C" >&6 +if test "${ac_cv_header_opennet_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_opennet_h" >&5 +echo "${ECHO_T}$ac_cv_header_opennet_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking opennet.h usability" >&5 +echo $ECHO_N "checking opennet.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking opennet.h presence" >&5 +echo $ECHO_N "checking opennet.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: opennet.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: opennet.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: opennet.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: opennet.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: opennet.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: opennet.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: opennet.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: opennet.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: opennet.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: opennet.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to the libconfig lists. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for opennet.h" >&5 +echo $ECHO_N "checking for opennet.h... $ECHO_C" >&6 +if test "${ac_cv_header_opennet_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_opennet_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_opennet_h" >&5 +echo "${ECHO_T}$ac_cv_header_opennet_h" >&6 + +fi +if test $ac_cv_header_opennet_h = yes; then + + LIBSPEC=yes + +else + + LIBSPEC=no + +fi + + + CPPFLAGS="$OLDCPPFLAGS" + CFLAGS="$OLDCFLAGS" + +else + + LIBSPEC=no + { echo "$as_me:$LINENO: WARNING: Didn't find libopennet" >&5 +echo "$as_me: WARNING: Didn't find libopennet" >&2;} + +fi + + +fi; + case $LIBSPEC in + no) + { echo "$as_me:$LINENO: WARNING: Support for libopennet disabled" >&5 +echo "$as_me: WARNING: Support for libopennet disabled" >&2;} + ;; + *) + if test "${LIBSPEC}" = "yes"; then + true + else + LIBSPECFLAGS="-L${LIBSPEC}/lib ${LIBSPECFLAGS}" + LIBSPECCFLAGS="-I${LIBSPEC}/include ${LIBSPECCFLAGS}" + fi + echo "$as_me:$LINENO: checking for open_net in -lopennet" >&5 +echo $ECHO_N "checking for open_net in -lopennet... $ECHO_C" >&6 +if test "${ac_cv_lib_opennet_open_net+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lopennet $LIBSPECFLAGS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char open_net (); +int +main () +{ +open_net (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_opennet_open_net=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_opennet_open_net=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_open_net" >&5 +echo "${ECHO_T}$ac_cv_lib_opennet_open_net" >&6 +if test $ac_cv_lib_opennet_open_net = yes; then + + OLDCFLAGS="$CFLAGS" + OLDCPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS ${LIBSPECCFLAGS}" + CFLAGS="$CFLAGS ${LIBSPECCFLAGS}" + if test "${ac_cv_header_opennet_h+set}" = set; then + echo "$as_me:$LINENO: checking for opennet.h" >&5 +echo $ECHO_N "checking for opennet.h... $ECHO_C" >&6 +if test "${ac_cv_header_opennet_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_opennet_h" >&5 +echo "${ECHO_T}$ac_cv_header_opennet_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking opennet.h usability" >&5 +echo $ECHO_N "checking opennet.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking opennet.h presence" >&5 +echo $ECHO_N "checking opennet.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: opennet.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: opennet.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: opennet.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: opennet.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: opennet.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: opennet.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: opennet.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: opennet.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: opennet.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: opennet.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: opennet.h: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to the libconfig lists. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for opennet.h" >&5 +echo $ECHO_N "checking for opennet.h... $ECHO_C" >&6 +if test "${ac_cv_header_opennet_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_opennet_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_opennet_h" >&5 +echo "${ECHO_T}$ac_cv_header_opennet_h" >&6 + +fi +if test $ac_cv_header_opennet_h = yes; then + + if test -n "HAVE_OPENNET_H"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_OPENNET_H 1 +_ACEOF + + fi + if test -n "HAVE_LIBOPENNET"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBOPENNET 1 +_ACEOF + + fi + LDFLAGS="$LDFLAGS $LIBSPECFLAGS" + LIBS="$LIBS -lopennet" + +else + + CFLAGS="$OLDCFLAGS" + CPPFLAGS="$OLDCPPFLAGS" + { { echo "$as_me:$LINENO: error: Could not find opennet.h" >&5 +echo "$as_me: error: Could not find opennet.h" >&2;} + { (exit 1); exit 1; }; } + +fi + + + +else + + { { echo "$as_me:$LINENO: error: Could not find libopennet" >&5 +echo "$as_me: error: Could not find libopennet" >&2;} + { (exit 1); exit 1; }; } + +fi + + ;; + esac + + + + for ac_header in windows.h windowsx.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then @@ -16332,11 +16844,11 @@ echo "$as_me:$LINENO: result: $SHOBJLDFLAGS $SHOBJFLAGS" >&5 echo "${ECHO_T}$SHOBJLDFLAGS $SHOBJFLAGS" >&6 - ac_config_files="$ac_config_files Makefile lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 libconfig.3" + ac_config_files="$ac_config_files Makefile lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 lc_cleanup.3 lc_process_file.3 libconfig.3" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't @@ -16695,11 +17207,11 @@ ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by libconfig $as_me 0.1.4, which was +This file was extended by libconfig $as_me 0.1.5, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS @@ -16755,11 +17267,11 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -libconfig config.status 0.1.4 +libconfig config.status 0.1.5 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation @@ -16864,10 +17376,12 @@ "lc_geterrno.3" ) CONFIG_FILES="$CONFIG_FILES lc_geterrno.3" ;; "lc_process.3" ) CONFIG_FILES="$CONFIG_FILES lc_process.3" ;; "lc_register_var.3" ) CONFIG_FILES="$CONFIG_FILES lc_register_var.3" ;; "lc_geterrstr.3" ) CONFIG_FILES="$CONFIG_FILES lc_geterrstr.3" ;; "lc_register_callback.3" ) CONFIG_FILES="$CONFIG_FILES lc_register_callback.3" ;; + "lc_cleanup.3" ) CONFIG_FILES="$CONFIG_FILES lc_cleanup.3" ;; + "lc_process_file.3" ) CONFIG_FILES="$CONFIG_FILES lc_process_file.3" ;; "libconfig.3" ) CONFIG_FILES="$CONFIG_FILES libconfig.3" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; ADDED configure.ac Index: configure.ac ================================================================== --- /dev/null +++ configure.ac @@ -0,0 +1,38 @@ +AC_REVISION($Revision $) +AC_INIT(libconfig, 0.1.5) +AC_CONFIG_HEADER(config.h) + +dnl Find out about the host OS +DC_CHK_OS_INFO + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_MAKE_SET +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_RANLIB +AC_AIX +AC_CHECK_TOOL(AR, ar, true) + +AC_CHECK_HEADERS(ctype.h dirent.h pwd.h stdio.h stdlib.h string.h sys/stat.h sys/time.h sys/types.h time.h unistd.h) +AC_HEADER_TIME + +DC_DO_TYPE(uint64_t, unsigned, 8) +DC_DO_TYPE(int64_t, signed, 8) +DC_DO_TYPE(uint32_t, unsigned, 4) +DC_DO_TYPE(int32_t, signed, 4) +DC_DO_TYPE(uint16_t, unsigned, 2) +DC_DO_TYPE(int16_t, signed, 2) + +AC_REPLACE_FUNCS(strsep strtoll) +AC_CHECK_FUNCS(getpwuid) + +DC_ASK_OPTLIB(opennet, open_net, opennet.h, [ Enable opennet support], libopennet, HAVE_LIBOPENNET, HAVE_OPENNET_H) + +dnl Checks for Win32 specific things. +DC_DO_WIN32 + +dnl This must be last. +DC_GET_SHOBJFLAGS + +AC_OUTPUT(Makefile lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 lc_cleanup.3 lc_process_file.3 libconfig.3) DELETED configure.in Index: configure.in ================================================================== --- configure.in +++ /dev/null @@ -1,36 +0,0 @@ -AC_REVISION($Revision $) -AC_INIT(libconfig, 0.1.4) -AC_CONFIG_HEADER(config.h) - -dnl Find out about the host OS -DC_CHK_OS_INFO - -dnl Checks for programs. -AC_PROG_CC -AC_PROG_MAKE_SET -AC_PROG_INSTALL -AC_PROG_LN_S -AC_PROG_RANLIB -AC_AIX -AC_CHECK_TOOL(AR, ar, true) - -AC_CHECK_HEADERS(ctype.h dirent.h pwd.h stdio.h stdlib.h string.h sys/stat.h sys/time.h sys/types.h time.h unistd.h) -AC_HEADER_TIME - -DC_DO_TYPE(uint64_t, unsigned, 8) -DC_DO_TYPE(int64_t, signed, 8) -DC_DO_TYPE(uint32_t, unsigned, 4) -DC_DO_TYPE(int32_t, signed, 4) -DC_DO_TYPE(uint16_t, unsigned, 2) -DC_DO_TYPE(int16_t, signed, 2) - -AC_REPLACE_FUNCS(strsep strtoll) -AC_CHECK_FUNCS(getpwuid) - -dnl Checks for Win32 specific things. -DC_DO_WIN32 - -dnl This must be last. -DC_GET_SHOBJFLAGS - -AC_OUTPUT(Makefile lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 libconfig.3) ADDED lc_cleanup.3.in Index: lc_cleanup.3.in ================================================================== --- /dev/null +++ lc_cleanup.3.in Index: lc_geterrno.3.in ================================================================== --- lc_geterrno.3.in +++ lc_geterrno.3.in @@ -83,6 +83,8 @@ .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrstr (3), +.BR lc_cleanup (3), +.BR lc_process_file (3), .BR lc_process (3) Index: lc_geterrstr.3.in ================================================================== --- lc_geterrstr.3.in +++ lc_geterrstr.3.in @@ -51,6 +51,8 @@ .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), +.BR lc_cleanup (3), +.BR lc_process_file (3), .BR lc_process (3) Index: lc_process.3.in ================================================================== --- lc_process.3.in +++ lc_process.3.in @@ -53,6 +53,8 @@ .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), -.BR lc_geterrstr (3) +.BR lc_geterrstr (3), +.BR lc_cleanup (3), +.BR lc_process_file (3) ADDED lc_process_file.3.in Index: lc_process_file.3.in ================================================================== --- /dev/null +++ lc_process_file.3.in Index: lc_register_callback.3.in ================================================================== --- lc_register_callback.3.in +++ lc_register_callback.3.in @@ -223,6 +223,8 @@ .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), +.BR lc_cleanup (3), +.BR lc_process_file (3), .BR lc_process (3) Index: lc_register_var.3.in ================================================================== --- lc_register_var.3.in +++ lc_register_var.3.in @@ -141,6 +141,8 @@ .SH "SEE ALSO" .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), +.BR lc_cleanup (3), +.BR lc_process_file (3), .BR lc_process (3) Index: libconfig.3.in ================================================================== --- libconfig.3.in +++ libconfig.3.in @@ -20,14 +20,19 @@ .BR lc_register_var (3) or .BR lc_register_callback (3)) are processed with the .BR lc_process (3) -function. Errors can be examined through +and +.BR lc_process_file (3) +functions. Errors can be examined through .BR lc_geterrno (3) and .BR lc_geterrstr (3). +Clean-up may be performed using the +.BR lc_cleanup (3) +function. .SH EXAMPLE .nf #include #include @@ -46,10 +51,12 @@ return(EXIT_FAILURE); } lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, NULL); + lc_cleanup(); + if (lc_p_ret != 0) { fprintf(stderr, "Error processing configuration: \\ %s\\n", lc_geterrstr()); return(EXIT_FAILURE); } @@ -67,6 +74,8 @@ .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterr (3), .BR lc_geterrstr (3), -.BR lc_process (3) +.BR lc_cleanup (3), +.BR lc_process (3), +.BR lc_process_file (3) Index: libconfig.c ================================================================== --- libconfig.c +++ libconfig.c @@ -759,11 +759,11 @@ varhandlers = newhandler; return(0); } -static int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type) { +int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type) { int chkretval = 0; switch (type) { case LC_CONF_SECTION: chkretval = lc_process_conf_section(appname, pathname); @@ -852,11 +852,11 @@ } return(retval); } -static void lc_cleanup(void) { +void lc_cleanup(void) { struct lc_varhandler_st *handler = NULL, *next = NULL; handler = varhandlers; while (handler != NULL) { if (handler->var != NULL) { @@ -892,13 +892,10 @@ chkretval = lc_process_cmdline(argc, argv); if (chkretval < 0) { retval = -1; } - /* Free our structures. */ - lc_cleanup(); - return(retval); } lc_err_t lc_geterrno(void) { Index: libconfig.h.in ================================================================== --- libconfig.h.in +++ libconfig.h.in @@ -71,10 +71,12 @@ int lc_process(int argc, char **argv, const char *appname, lc_conf_type_t type, const char *extra); int lc_register_callback(const char *var, char opt, lc_var_type_t type, int (*callback)(const char *, const char *, const char *, const char *, lc_flags_t, void *), void *extra); int lc_register_var(const char *var, lc_var_type_t type, void *data, char opt); lc_err_t lc_geterrno(void); char *lc_geterrstr(void); +int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type); +void lc_cleanup(void); __BLANK_LINE__ !define LC_CBRET_IGNORESECTION (255) !define LC_CBRET_OKAY (0) Index: test-lc.c ================================================================== --- test-lc.c +++ test-lc.c @@ -46,11 +46,13 @@ lc_register_var("long", LC_VAR_BOOL_BY_EXISTANCE, &onoff2, 'l'); lc_register_var("ipaddr", LC_VAR_IP, &ipaddr, 'i'); lc_register_callback("sally", 0, LC_VAR_STRING, sally_cmd, NULL); lc_register_callback("HELP", 'h', LC_VAR_NONE, help_cmd, NULL); lc_register_callback("*.ifmodule", 0, LC_VAR_NONE, cmd_ifmodule, NULL); + lcpret = lc_process_file("testapp", "http://10.8.0.2/test.conf", LC_CONF_APACHE); lcpret = lc_process(argc, argv, "testapp", LC_CONF_APACHE, "test.cfg"); + lc_cleanup(); if (lcpret < 0) { fprintf(stderr, "Error processing config file: %s\n", lc_geterrstr()); return(EXIT_FAILURE); }