Index: build/build_web_manpages ================================================================== --- build/build_web_manpages +++ build/build_web_manpages @@ -6,9 +6,9 @@ if [ ! -f libconfig.3 ]; then echo 'Could not find libconfig.3, aborting.' >&2 exit 1 fi -for file in lc_cleanup lc_geterrno lc_geterrstr lc_seterrstr lc_process lc_process_file lc_register_callback lc_register_var libconfig; do +for file in lc_cleanup lc_geterrno lc_geterrstr lc_seterrstr lc_process lc_process_file lc_register_callback lc_register_var libconfig lc_handle_type; do man2html -H "REPLACE" -M "/ME" < ${file}.3 | grep -iv '^Content-Type:' | sed 's@"http://REPLACE/ME?\([0-9]*\)+\([^"]*\)"@"\2.htm"@;s@http://REPLACE/ME@@g' > /web/rkeene/docs/oss/libconfig/${file}.htm done Index: configure ================================================================== --- configure +++ configure @@ -1,9 +1,9 @@ #! /bin/sh # From configure.ac Revision . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for libconfig 0.2.0. +# Generated by GNU Autoconf 2.59 for libconfig 0.2.1. # # 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.2.0' -PACKAGE_STRING='libconfig 0.2.0' +PACKAGE_VERSION='0.2.1' +PACKAGE_STRING='libconfig 0.2.1' 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.2.0 to adapt to many kinds of systems. +\`configure' configures libconfig 0.2.1 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,11 +837,11 @@ _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libconfig 0.2.0:";; + short | recursive ) echo "Configuration of libconfig 0.2.1:";; esac cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) @@ -958,11 +958,11 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -libconfig configure 0.2.0 +libconfig configure 0.2.1 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. @@ -972,11 +972,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.2.0, which was +It was created by libconfig $as_me 0.2.1, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF @@ -17089,11 +17089,11 @@ for obj in $LIBOBJS; do SHLIBOBJS="$SHLIBOBJS `echo $obj | sed 's/\.o$/_shr.o/g'`" done - 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" + ac_config_files="$ac_config_files Makefile lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_seterrstr.3 lc_register_callback.3 lc_cleanup.3 lc_process_file.3 libconfig.3 lc_handle_type.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 @@ -17452,11 +17452,11 @@ ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by libconfig $as_me 0.2.0, which was +This file was extended by libconfig $as_me 0.2.1, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS @@ -17512,11 +17512,11 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -libconfig config.status 0.2.0 +libconfig config.status 0.2.1 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 @@ -17620,14 +17620,16 @@ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "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_seterrstr.3" ) CONFIG_FILES="$CONFIG_FILES lc_seterrstr.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" ;; + "lc_handle_type.3" ) CONFIG_FILES="$CONFIG_FILES lc_handle_type.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; }; };; esac Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1,7 +1,7 @@ AC_REVISION($Revision $) -AC_INIT(libconfig, 0.2.0) +AC_INIT(libconfig, 0.2.1) AC_CONFIG_HEADER(config.h) dnl Find out about the host OS DC_CHK_OS_INFO @@ -42,6 +42,6 @@ AC_CHECK_FUNCS(getpwuid) dnl This MUST be last. DC_SYNC_SHLIBOBJS -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) +AC_OUTPUT(Makefile lc_geterrno.3 lc_process.3 lc_register_var.3 lc_geterrstr.3 lc_seterrstr.3 lc_register_callback.3 lc_cleanup.3 lc_process_file.3 libconfig.3 lc_handle_type.3) Index: lc_cleanup.3.in ================================================================== --- lc_cleanup.3.in +++ lc_cleanup.3.in @@ -66,10 +66,11 @@ .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), -.BR lc_seterrstr (3), +.BR lc_geterrno (3), .BR lc_geterrstr (3), -.BR lc_geterrno (3), -.BR lc_process_file (3), -.BR lc_process (3) +.BR lc_seterrstr (3), +.BR lc_handle_type (3), +.BR lc_process (3), +.BR lc_process_file (3) Index: lc_geterrno.3.in ================================================================== --- lc_geterrno.3.in +++ lc_geterrno.3.in @@ -88,8 +88,9 @@ .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), -.BR lc_cleanup (3), +.BR lc_handle_type (3), +.BR lc_process (3), .BR lc_process_file (3), -.BR lc_process (3) +.BR lc_cleanup (3) Index: lc_geterrstr.3.in ================================================================== --- lc_geterrstr.3.in +++ lc_geterrstr.3.in @@ -53,11 +53,12 @@ .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), -.BR lc_register_callback (3), -.BR lc_seterrstr (3), -.BR lc_geterrno (3), -.BR lc_cleanup (3), -.BR lc_process_file (3), -.BR lc_process (3) +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_seterrstr (3), +.BR lc_handle_type (3), +.BR lc_process (3), +.BR lc_process_file (3), +.BR lc_cleanup (3) Index: lc_handle_type.3.in ================================================================== --- lc_handle_type.3.in +++ lc_handle_type.3.in @@ -1,57 +1,72 @@ -.TH LIBCONFIG 3 "25 Oct 04" "@PACKAGE_STRING@" +.TH LC_HANDLE_TYPE 3 "25 Oct 04" "@PACKAGE_STRING@" .SH NAME -libconfig \- Consistent configuration library. +lc_handle_type \- Convert string representation of a value to its correct type .SH SYNOPSIS .B #include .sp -.BI "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 ");" - -.BI "int lc_register_var(const char *" var ", lc_var_type_t " type ", void *" data ", char " opt ");" - -.BI "int lc_process(int " argc ", char **" argv ", const char *" appname ", lc_conf_type_t " type ", const char *" extra ");" - -.BI "lc_err_t lc_geterrno(void);" - -.BI "char *lc_geterrstr(void);" - -.BI "void lc_geterrstr(const char *" errstr ");" +.BI "int lc_handle_type(lc_var_type_t " type ", const char *" value ", void *" data ");" .SH DESCRIPTION -Libconfig is a library to provide easy access to configuration data in a consistent and logical manner. Variables (registered through +.BR lc_handle_type (3) +converts the string +.I value +to the correct type specified by the +.I type +parameter. The result is stored in the memory region passed as +.IR data , +which should be of the correct type. For possible values for +.I type +and the corresponding +.I data +type, see the .BR lc_register_var (3) -or -.BR lc_register_callback (3)) -are processed with the -.BR lc_process (3) -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. +man page. + +.SH "RETURN VALUE" +On success 0 is returned, otherwise -1 is returned. The memory pointed to by +.I data +may be altered in either case. .SH EXAMPLE .nf #include #include #include + +int callback_size(const char *shortvar, const char *var, + const char *arguments, const char *value, + lc_flags_t flags, void *extra) { + size_t size; + int lc_ht_ret; + + if (value == NULL) { + lc_seterrstr("You must specify an argument to \\ + Size."); + return(LC_CBRET_ERROR); + } + + lc_ht_ret = lc_handle_type(LC_VAR_SIZE_SIZE_T, value, &size); + if (lc_ht_ret != 0) { + lc_seterrstr("Invalid size specified."); + return(LC_CBRET_ERROR); + } + + printf("Size: %lu\\n", (unsigned long) size); + + return(LC_CBRET_OKAY); +} 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()); + int lc_rc_ret, lc_p_ret; + + lc_rc_ret = lc_register_callback("Size", 0, LC_VAR_SIZE_SIZE_T, + callback_size, NULL); + + if (lc_rc_ret != 0) { + fprintf(stderr, "Error registering callback.\\n"); return(EXIT_FAILURE); } lc_p_ret = lc_process(argc, argv, "example", LC_CONF_APACHE, NULL); @@ -62,24 +77,20 @@ fprintf(stderr, "Error processing configuration: \\ %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 libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), -.BR lc_geterr (3), +.BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), -.BR lc_cleanup (3), .BR lc_process (3), -.BR lc_process_file (3) +.BR lc_process_file (3), +.BR lc_cleanup (3) Index: lc_process.3.in ================================================================== --- lc_process.3.in +++ lc_process.3.in @@ -99,11 +99,12 @@ .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), -.BR lc_register_callback (3), -.BR lc_geterrno (3), -.BR lc_seterrstr (3), -.BR lc_geterrstr (3), -.BR lc_cleanup (3), -.BR lc_process_file (3) +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_geterrstr (3), +.BR lc_seterrstr (3), +.BR lc_handle_type (3), +.BR lc_process_file (3), +.BR lc_cleanup (3) Index: lc_process_file.3.in ================================================================== --- lc_process_file.3.in +++ lc_process_file.3.in @@ -61,11 +61,12 @@ .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), -.BR lc_register_callback (3), -.BR lc_geterrno (3), -.BR lc_geterrstr (3), -.BR lc_seterrstr (3), -.BR lc_cleanup (3), -.BR lc_process (3) +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_geterrstr (3), +.BR lc_seterrstr (3), +.BR lc_handle_type (3), +.BR lc_process (3), +.BR lc_cleanup (3) Index: lc_register_callback.3.in ================================================================== --- lc_register_callback.3.in +++ lc_register_callback.3.in @@ -220,11 +220,12 @@ Memory could not be allocated to create the needed internal structures. .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), -.BR lc_geterrno (3), -.BR lc_geterrstr (3), -.BR lc_seterrstr (3), -.BR lc_cleanup (3), -.BR lc_process_file (3), -.BR lc_process (3) +.BR lc_geterrno (3), +.BR lc_geterrstr (3), +.BR lc_seterrstr (3), +.BR lc_handle_type (3), +.BR lc_process (3), +.BR lc_process_file (3), +.BR lc_cleanup (3) Index: lc_register_var.3.in ================================================================== --- lc_register_var.3.in +++ lc_register_var.3.in @@ -148,12 +148,13 @@ } .fi .SH "SEE ALSO" .BR libconfig (3), -.BR lc_register_callback (3), -.BR lc_geterrno (3), -.BR lc_geterrstr (3), -.BR lc_seterrstr (3), -.BR lc_cleanup (3), -.BR lc_process_file (3), -.BR lc_process (3) +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_geterrstr (3), +.BR lc_seterrstr (3), +.BR lc_handle_type (3), +.BR lc_process (3), +.BR lc_process_file (3), +.BR lc_cleanup (3) Index: lc_seterrstr.3.in ================================================================== --- lc_seterrstr.3.in +++ lc_seterrstr.3.in @@ -1,8 +1,8 @@ -.TH LC_GETERRSTR 3 "25 Oct 04" "@PACKAGE_STRING@" +.TH LC_SETERRSTR 3 "25 Oct 04" "@PACKAGE_STRING@" .SH NAME -lc_geterrstr \- Set an error message from a callback. +lc_seterrstr \- Set an error message from a callback. .SH SYNOPSIS .B #include .sp .BI "void lc_seterrstr(const char *" errstr ");" @@ -15,11 +15,12 @@ function when an error is returned from a callback function. The value is ignored if the error is not related to a callback. .SH "SEE ALSO" .BR libconfig (3), .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_file (3), -.BR lc_process (3) +.BR lc_register_callback (3), +.BR lc_geterrno (3), +.BR lc_geterrstr (3), +.BR lc_handle_type (3), +.BR lc_process (3), +.BR lc_process_file (3), +.BR lc_cleanup (3) Index: libconfig.3.in ================================================================== --- libconfig.3.in +++ libconfig.3.in @@ -13,11 +13,15 @@ .BI "lc_err_t lc_geterrno(void);" .BI "char *lc_geterrstr(void);" -.BI "void lc_geterrstr(const char *" errstr ");" +.BI "void lc_seterrstr(const char *" errstr ");" + +.BI "int lc_handle_type(lc_var_type_t " type ", const char *" value ", void *" data ");" + +.BI "void lc_cleanup(void);" .SH DESCRIPTION Libconfig is a library to provide easy access to configuration data in a consistent and logical manner. Variables (registered through .BR lc_register_var (3) or @@ -75,11 +79,12 @@ .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), -.BR lc_geterr (3), +.BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), -.BR lc_cleanup (3), +.BR lc_handle_type (3), .BR lc_process (3), -.BR lc_process_file (3) +.BR lc_process_file (3), +.BR lc_cleanup (3)