Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -56,11 +56,11 @@ .PHONY: clean distclean install clean: rm -f *.o $(BINS) $(LIBS) libconfig.h *~ test-lc distclean: clean - rm -f Makefile config.h config.status config.log lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 + rm -f Makefile config.h config.status config.log lc_geterrno.3 lc_process.3 lc_cleanup.3 lc_process_file.3 lc_register_var.3 lc_geterrstr.3 lc_register_callback.3 libconfig.3 install: all libconfig.h -$(INSTALL) -d $(mandir) -$(INSTALL) -d $(mandir)/man3 Index: README ================================================================== --- README +++ README @@ -4,5 +4,6 @@ NetBSD 1.6.1 FreeBSD 4.8 OpenBSD 3.4 SunOS 5.9 Linux (Slackware, RedHat, Fedora Core, Debian) + IRIX 6.5 Index: config.h.in ================================================================== --- config.h.in +++ config.h.in @@ -10,11 +10,11 @@ #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 */ +/* Define to 1 if you have fopen_net from libopennet */ #undef HAVE_LIBOPENNET /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H Index: configure ================================================================== --- configure +++ configure @@ -15669,13 +15669,13 @@ 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 "$as_me:$LINENO: checking for fopen_net in -lopennet" >&5 +echo $ECHO_N "checking for fopen_net in -lopennet... $ECHO_C" >&6 +if test "${ac_cv_lib_opennet_fopen_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 @@ -15689,15 +15689,15 @@ #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 (); +char fopen_net (); int main () { -open_net (); +fopen_net (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext @@ -15720,24 +15720,24 @@ { (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 + ac_cv_lib_opennet_fopen_net=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_opennet_open_net=no +ac_cv_lib_opennet_fopen_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 +echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_fopen_net" >&5 +echo "${ECHO_T}$ac_cv_lib_opennet_fopen_net" >&6 +if test $ac_cv_lib_opennet_fopen_net = yes; then OLDCPPFLAGS="$CPPFLAGS" OLDCFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS $LIBSPECCFLAGS" CFLAGS="$CFLAGS $LIBSPECCFLAGS" @@ -15912,13 +15912,13 @@ 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 "$as_me:$LINENO: checking for fopen_net in -lopennet" >&5 +echo $ECHO_N "checking for fopen_net in -lopennet... $ECHO_C" >&6 +if test "${ac_cv_lib_opennet_fopen_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 @@ -15932,15 +15932,15 @@ #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 (); +char fopen_net (); int main () { -open_net (); +fopen_net (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext @@ -15963,24 +15963,24 @@ { (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 + ac_cv_lib_opennet_fopen_net=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_opennet_open_net=no +ac_cv_lib_opennet_fopen_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 +echo "$as_me:$LINENO: result: $ac_cv_lib_opennet_fopen_net" >&5 +echo "${ECHO_T}$ac_cv_lib_opennet_fopen_net" >&6 +if test $ac_cv_lib_opennet_fopen_net = yes; then OLDCFLAGS="$CFLAGS" OLDCPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS ${LIBSPECCFLAGS}" CFLAGS="$CFLAGS ${LIBSPECCFLAGS}" Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -25,11 +25,11 @@ 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) +DC_ASK_OPTLIB(opennet, fopen_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. Index: lc_geterrno.3.in ================================================================== --- lc_geterrno.3.in +++ lc_geterrno.3.in @@ -63,10 +63,13 @@ 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); } Index: lc_geterrstr.3.in ================================================================== --- lc_geterrstr.3.in +++ lc_geterrstr.3.in @@ -31,10 +31,13 @@ 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); } Index: lc_process.3.in ================================================================== --- lc_process.3.in +++ lc_process.3.in @@ -9,10 +9,54 @@ .SH DESCRIPTION The .BR lc_process (3) function begins processing of the command line arguments, environment variables, and command line options. +The +.I argc +and +.I argv +parameters should be in the same format as passed to the +.B main +function of your program. +The +.I appname +parameter should be a reasonable form of the name of the application. +The +.I type +parameter should describe the format of the configuration file (see below). +The +.I extra +parameter should list any extra configuration files to process. + +Valid type parameter values: +.TP +LC_CONF_SECTION +This type of configuration file is similar to the Windows INI-file style. +An example configuration file: +.nf + [section] + variable = value +.fi + +.TP +LC_CONF_APACHE +This type of configuration file is similar to the Apache configuration file. +An example configuration file: +.nf +
+ variable value +
+.fi + +.TP +LC_CONF_SPACE +This is a simple, flat configuration file. It has no section headers. +An example configuration file: +.nf + variable value +.fi .SH "RETURN VALUE" On success 0 is returned, otherwise -1 is returned. .SH EXAMPLE @@ -33,10 +77,13 @@ 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); } Index: lc_process_file.3.in ================================================================== --- lc_process_file.3.in +++ lc_process_file.3.in @@ -0,0 +1,69 @@ +.TH LC_PROCESS_FILE 3 "25 Oct 04" "@PACKAGE_STRING@" +.SH NAME +lc_process_file \- Process a specific file + +.SH SYNOPSIS +.B #include +.sp +.BI "int lc_process_file(const char *" appname ", const char *" pathname ", lc_conf_type_t " type ");" + +.SH DESCRIPTION +The +.BR lc_process_file (3) +function processes exactly one configuration file. The file is specified by the +.I pathname +argument and should be in the format specified by the +.I type +argument. The +.I appname +argument should be a reasonable form of the name of the application. + +.SH "RETURN VALUE" +On success 0 is returned, otherwise -1 is returned. + +.SH EXAMPLE +.nf +#include +#include +#include + +int main(int argc, char **argv) { + int lc_p_ret, lc_rv_ret; + char *filename = NULL; + + lc_rv_ret = lc_register_var("File", LC_VAR_STRING, + &filename, 'f'); + if (lc_rv_ret != 0) { + fprintf(stderr, "Error registering variable: %i.\\n", + lc_geterrno()); + return(EXIT_FAILURE); + } + + lc_p_ret = lc_process_file("example", "/data/extra.conf", + LC_CONF_APACHE); + + lc_cleanup(); + + if (lc_p_ret != 0) { + fprintf(stderr, "Error processing configuration file: \\ + %s\\n", lc_geterrstr()); + return(EXIT_FAILURE); + } + + if (filename != NULL) { + printf("File specified was: %s\\n", filename); + } else { + printf("No filename specified.\\n"); + } + + return(EXIT_SUCCESS); +} +.fi + +.SH "SEE ALSO" +.BR lc_register_var (3), +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_geterrstr (3), +.BR lc_cleanup (3), +.BR lc_process (3) Index: lc_register_callback.3.in ================================================================== --- lc_register_callback.3.in +++ lc_register_callback.3.in @@ -204,10 +204,13 @@ 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); } Index: lc_register_var.3.in ================================================================== --- lc_register_var.3.in +++ lc_register_var.3.in @@ -115,10 +115,13 @@ 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); } Index: libconfig.3.in ================================================================== --- libconfig.3.in +++ libconfig.3.in @@ -51,10 +51,11 @@ 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());