Index: Makefile.in ================================================================== --- Makefile.in +++ Makefile.in @@ -54,11 +54,11 @@ test-lc: $(LIBS) test-lc.c $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $(filter %.c, $?) $(LDFLAGS) -Wl,-R -Wl,. -L. -lconfig .PHONY: clean distclean install clean: - rm -f *.o $(BINS) $(LIBS) libconfig.h *~ test-lc + rm -f *.o $(BINS) $(LIBS) libconfig.h *~ test-lc *.dll.a *.dll.def *.dll distclean: clean 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 ADDED build/build_win32.sh Index: build/build_win32.sh ================================================================== --- /dev/null +++ build/build_win32.sh @@ -0,0 +1,16 @@ +#! /bin/sh + +if [ ! -x configure ]; then cd ../; fi +WIN32="${HOME}/root/windows-i386" +CFLAGS="-I${WIN32}/include" +CPPFLAGS="${CFLAGS}" +LDFLAGS="-L${WIN32}/lib" +DATE="`date +%Y%m%d%H%M`" +CROSS=i586-mingw32msvc +if [ ! -z "${CROSS}" ]; then + CROSSCMD="${CROSS}-" +fi +export CFLAGS LDFLAGS CPPFLAGS +make distclean +./configure --host=${CROSS} && \ +make || exit 1 Index: compat.h ================================================================== --- compat.h +++ compat.h @@ -10,10 +10,13 @@ #ifndef LC_LINEBUF_LEN #define LC_LINEBUF_LEN 1024 #endif +#ifndef HAVE_GETUID +#include "getuid.h" +#endif #ifndef HAVE_STRTOLL #include "strtoll.h" #endif #ifndef HAVE_STRSEP #include "strsep.h" Index: config.h.in ================================================================== --- config.h.in +++ config.h.in @@ -6,10 +6,13 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the `getpwuid' function. */ #undef HAVE_GETPWUID + +/* Define to 1 if you have the `getuid' function. */ +#undef HAVE_GETUID /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have fopen_net from libopennet */ 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.1.6. +# Generated by GNU Autoconf 2.59 for libconfig 0.1.7. # # 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.6' -PACKAGE_STRING='libconfig 0.1.6' +PACKAGE_VERSION='0.1.7' +PACKAGE_STRING='libconfig 0.1.7' 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.6 to adapt to many kinds of systems. +\`configure' configures libconfig 0.1.7 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.1.6:";; + short | recursive ) echo "Configuration of libconfig 0.1.7:";; esac cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -953,11 +953,11 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -libconfig configure 0.1.6 +libconfig configure 0.1.7 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. @@ -967,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.6, which was +It was created by libconfig $as_me 0.1.7, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF @@ -15441,11 +15441,12 @@ done -for ac_func in strsep strtoll + +for ac_func in strsep strtoll getuid do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then @@ -17207,11 +17208,11 @@ ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by libconfig $as_me 0.1.6, which was +This file was extended by libconfig $as_me 0.1.7, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS @@ -17267,11 +17268,11 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -libconfig config.status 0.1.6 +libconfig config.status 0.1.7 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 Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -1,7 +1,7 @@ AC_REVISION($Revision $) -AC_INIT(libconfig, 0.1.6) +AC_INIT(libconfig, 0.1.7) AC_CONFIG_HEADER(config.h) dnl Find out about the host OS DC_CHK_OS_INFO @@ -22,11 +22,11 @@ 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_REPLACE_FUNCS(strsep strtoll getuid) AC_CHECK_FUNCS(getpwuid) DC_ASK_OPTLIB(opennet, fopen_net, opennet.h, [ Enable opennet support], libopennet, HAVE_LIBOPENNET, HAVE_OPENNET_H) dnl Checks for Win32 specific things. ADDED getuid.c Index: getuid.c ================================================================== --- /dev/null +++ getuid.c @@ -0,0 +1,5 @@ +#include "getuid.h" + +uid_t getuid(void) { + return(0); +} ADDED getuid.h Index: getuid.h ================================================================== --- /dev/null +++ getuid.h @@ -0,0 +1,8 @@ +#ifndef _LC_GETUID_H +#define _LC_GETUID_H + +typedef int uid_t; + +uid_t getuid(void); + +#endif Index: lc_cleanup.3.in ================================================================== --- lc_cleanup.3.in +++ lc_cleanup.3.in @@ -0,0 +1,73 @@ +.TH LC_GETERRNO 3 "25 Oct 04" "@PACKAGE_STRING@" +.SH NAME +lc_cleanup \- Clean up internal structures after processing data. + +.SH SYNOPSIS +.B #include +.sp +.BI "void lc_cleanup(void);" + +.SH DESCRIPTION +The +.BR lc_cleanup (3) +function cleans up the internal structures created by calling +.BR lc_register_var (3) +or +.BR lc_register_callback (3) +and returns the memory to the application. It is not strictly required, however memory concious programmers will still want to call this after finishing processing configuration files. + +After you call +.BR lc_cleanup (3) +calling +.BR lc_process (3) +or +.BR lc_process_file (3) +will generally cause errors since the registered variables and callbacks have been unregistered. + +.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(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); + } + + 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_geterrstr (3), +.BR lc_geterrno (3), +.BR lc_process_file (3), +.BR lc_process (3) Index: libconfig.c ================================================================== --- libconfig.c +++ libconfig.c @@ -815,16 +815,18 @@ snprintf(configfiles[1][9], sizeof(**configfiles) - 1, "/usr/local/etc/%s.conf", appname); snprintf(configfiles[1][10], sizeof(**configfiles) - 1, "/usr/local/etc/%s/%s.cfg", appname, appname); snprintf(configfiles[1][11], sizeof(**configfiles) - 1, "/usr/local/etc/%s/%s.conf", appname, appname); if (getuid() != 0) { homedir = getenv("HOME"); +#ifdef HAVE_GETPWUID if (homedir == NULL) { pwinfo = getpwuid(getuid()); if (pwinfo != NULL) { homedir = pwinfo->pw_dir; } } +#endif if (homedir != NULL) { if (strcmp(homedir, "/") != 0 && access(homedir, R_OK|W_OK|X_OK) == 0) { snprintf(configfiles[2][0], sizeof(**configfiles) - 1, "%s/.%src", homedir, appname); snprintf(configfiles[2][1], sizeof(**configfiles) - 1, "%s/.%s.cfg", homedir, appname); snprintf(configfiles[2][2], sizeof(**configfiles) - 1, "%s/.%s.conf", homedir, appname);