From 429e46051dba814e7d6c74368eb1bba550222cbe Mon Sep 17 00:00:00 2001 From: Jonathan McCrohan Date: Thu, 1 Dec 2011 22:56:23 +0000 Subject: Imported Upstream version 1.4.8 --- contrib/README | 3 + contrib/cmake/1_configure.sh | 5 + contrib/cmake/2_make.sh | 4 + contrib/cmake/CMakeCache.txt | 292 +++++++++ contrib/cmake/CMakeFiles/CMakeCCompiler.cmake | 36 ++ contrib/cmake/CMakeFiles/CMakeCXXCompiler.cmake | 36 ++ .../CMakeFiles/CMakeDetermineCompilerABI_C.bin | Bin 0 -> 8328 bytes .../CMakeFiles/CMakeDetermineCompilerABI_CXX.bin | Bin 0 -> 8466 bytes contrib/cmake/CMakeFiles/CMakeOutput.log | 89 +++ contrib/cmake/CMakeFiles/CMakeSystem.cmake | 15 + .../CMakeFiles/CompilerIdC/CMakeCCompilerId.c | 182 ++++++ contrib/cmake/CMakeFiles/CompilerIdC/a.out | Bin 0 -> 8337 bytes .../CompilerIdCXX/CMakeCXXCompilerId.cpp | 169 +++++ contrib/cmake/CMakeFiles/CompilerIdCXX/a.out | Bin 0 -> 8466 bytes contrib/cmake/CMakeFiles/cmake.check_cache | 1 + contrib/cmake/CMakeLists.txt | 22 + contrib/cmake/cmake_work/FindConfig++.cmake | 23 + contrib/cmake/cmake_work/FindConfig.cmake | 23 + contrib/cmake/cmake_work/cmake_uninstall.cmake.in | 36 ++ contrib/cmake/src/CMakeLists.txt | 6 + contrib/cmake/src/main.cpp | 13 + contrib/copy_setting.c | 161 +++++ contrib/libconfig-ruby/README | 76 +++ contrib/libconfig-ruby/Rakefile | 17 + contrib/libconfig-ruby/ext/extconf.rb | 11 + contrib/libconfig-ruby/ext/rconfig.c | 700 +++++++++++++++++++++ 26 files changed, 1920 insertions(+) create mode 100644 contrib/README create mode 100755 contrib/cmake/1_configure.sh create mode 100755 contrib/cmake/2_make.sh create mode 100644 contrib/cmake/CMakeCache.txt create mode 100644 contrib/cmake/CMakeFiles/CMakeCCompiler.cmake create mode 100644 contrib/cmake/CMakeFiles/CMakeCXXCompiler.cmake create mode 100755 contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_C.bin create mode 100755 contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin create mode 100644 contrib/cmake/CMakeFiles/CMakeOutput.log create mode 100644 contrib/cmake/CMakeFiles/CMakeSystem.cmake create mode 100644 contrib/cmake/CMakeFiles/CompilerIdC/CMakeCCompilerId.c create mode 100755 contrib/cmake/CMakeFiles/CompilerIdC/a.out create mode 100644 contrib/cmake/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp create mode 100755 contrib/cmake/CMakeFiles/CompilerIdCXX/a.out create mode 100644 contrib/cmake/CMakeFiles/cmake.check_cache create mode 100644 contrib/cmake/CMakeLists.txt create mode 100644 contrib/cmake/cmake_work/FindConfig++.cmake create mode 100644 contrib/cmake/cmake_work/FindConfig.cmake create mode 100644 contrib/cmake/cmake_work/cmake_uninstall.cmake.in create mode 100644 contrib/cmake/src/CMakeLists.txt create mode 100644 contrib/cmake/src/main.cpp create mode 100644 contrib/copy_setting.c create mode 100644 contrib/libconfig-ruby/README create mode 100644 contrib/libconfig-ruby/Rakefile create mode 100644 contrib/libconfig-ruby/ext/extconf.rb create mode 100644 contrib/libconfig-ruby/ext/rconfig.c (limited to 'contrib') diff --git a/contrib/README b/contrib/README new file mode 100644 index 0000000..7437f0c --- /dev/null +++ b/contrib/README @@ -0,0 +1,3 @@ +These files are not maintained by me; they are user +contributions. They are not guaranteed to work with this release of +libconfig. diff --git a/contrib/cmake/1_configure.sh b/contrib/cmake/1_configure.sh new file mode 100755 index 0000000..fe678f8 --- /dev/null +++ b/contrib/cmake/1_configure.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +mkdir release +cd release +cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release .. diff --git a/contrib/cmake/2_make.sh b/contrib/cmake/2_make.sh new file mode 100755 index 0000000..1717d77 --- /dev/null +++ b/contrib/cmake/2_make.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd release +make \ No newline at end of file diff --git a/contrib/cmake/CMakeCache.txt b/contrib/cmake/CMakeCache.txt new file mode 100644 index 0000000..5f44c4c --- /dev/null +++ b/contrib/cmake/CMakeCache.txt @@ -0,0 +1,292 @@ +# This is the CMakeCache file. +# For build in directory: /home/markl/download/libconfig_test_app +# It was generated by CMake: /usr/bin/cmake +# You can edit this file to change values found and used by cmake. +# If you do not want to change any of the values, simply exit the editor. +# If you do want to change a value, simply edit, save, and exit the editor. +# The syntax for the file is as follows: +# KEY:TYPE=VALUE +# KEY is the name of a variable in the cache. +# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!. +# VALUE is the current value for the KEY. + +######################## +# EXTERNAL cache entries +######################## + +//Path to a program. +CMAKE_AR:FILEPATH=/usr/bin/ar + +//For backwards compatibility, what version of CMake commands and +// syntax should this version of CMake try to support. +CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4 + +//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or +// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. +CMAKE_BUILD_TYPE:STRING=Release + +//Enable/Disable color output during build. +CMAKE_COLOR_MAKEFILE:BOOL=ON + +//CXX compiler. +CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ + +//Flags used by the compiler during all build types. +CMAKE_CXX_FLAGS:STRING= + +//Flags used by the compiler during debug builds. +CMAKE_CXX_FLAGS_DEBUG:STRING=-g + +//Flags used by the compiler during release minsize builds. +CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the compiler during release builds (/MD /Ob1 /Oi +// /Ot /Oy /Gs will produce slightly less optimized but smaller +// files). +CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the compiler during Release with Debug Info builds. +CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g + +//C compiler. +CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc + +//Flags used by the compiler during all build types. +CMAKE_C_FLAGS:STRING= + +//Flags used by the compiler during debug builds. +CMAKE_C_FLAGS_DEBUG:STRING=-g + +//Flags used by the compiler during release minsize builds. +CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG + +//Flags used by the compiler during release builds (/MD /Ob1 /Oi +// /Ot /Oy /Gs will produce slightly less optimized but smaller +// files). +CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG + +//Flags used by the compiler during Release with Debug Info builds. +CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g + +//Flags used by the linker. +CMAKE_EXE_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Install path prefix, prepended onto install directories. +CMAKE_INSTALL_PREFIX:PATH=/usr/local + +//Path to a program. +CMAKE_LINKER:FILEPATH=/usr/bin/ld + +//Path to a program. +CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make + +//Flags used by the linker during the creation of modules. +CMAKE_MODULE_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//Path to a program. +CMAKE_NM:FILEPATH=/usr/bin/nm + +//Path to a program. +CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy + +//Path to a program. +CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump + +//Path to a program. +CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib + +//Flags used by the linker during the creation of dll's. +CMAKE_SHARED_LINKER_FLAGS:STRING= + +//Flags used by the linker during debug builds. +CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING= + +//Flags used by the linker during release minsize builds. +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING= + +//Flags used by the linker during release builds. +CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING= + +//Flags used by the linker during Release with Debug Info builds. +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING= + +//If set, runtime paths are not added when using shared libraries. +CMAKE_SKIP_RPATH:BOOL=NO + +//Path to a program. +CMAKE_STRIP:FILEPATH=/usr/bin/strip + +//If true, cmake will use relative paths in makefiles and projects. +CMAKE_USE_RELATIVE_PATHS:BOOL=OFF + +//If this value is on, makefiles will be generated without the +// .SILENT directive, and all commands will be echoed to the console +// during the make. This is useful for debugging only. With Visual +// Studio IDE projects all commands are done without /nologo. +CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE + +//Path to a file. +CONFIG_INCLUDE_DIR:PATH=CONFIG_INCLUDE_DIR-NOTFOUND + +//Path to a library. +CONFIG_LIBRARY:FILEPATH=CONFIG_LIBRARY-NOTFOUND + +//Single output directory for building all executables. +EXECUTABLE_OUTPUT_PATH:PATH= + +//Single output directory for building all libraries. +LIBRARY_OUTPUT_PATH:PATH= + +//Value Computed by CMake +libconfig_test_app_BINARY_DIR:STATIC=/home/markl/download/libconfig_test_app/src + +//Value Computed by CMake +libconfig_test_app_SOURCE_DIR:STATIC=/home/markl/download/libconfig_test_app/src + + +######################## +# INTERNAL cache entries +######################## + +//Advanced flag for variable: CMAKE_AR +CMAKE_AR-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_BUILD_TOOL +CMAKE_BUILD_TOOL-ADVANCED:INTERNAL=1 +//What is the target build tool cmake is generating for. +CMAKE_BUILD_TOOL:INTERNAL=/usr/bin/make +//This is the directory where this CMakeCahe.txt was created +CMAKE_CACHEFILE_DIR:INTERNAL=/home/markl/download/libconfig_test_app +//Major version of cmake used to create the current loaded cache +CMAKE_CACHE_MAJOR_VERSION:INTERNAL=2 +//Minor version of cmake used to create the current loaded cache +CMAKE_CACHE_MINOR_VERSION:INTERNAL=6 +//Major version of cmake used to create the current loaded cache +CMAKE_CACHE_RELEASE_VERSION:INTERNAL=patch 4 +//Advanced flag for variable: CMAKE_COLOR_MAKEFILE +CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1 +//Path to CMake executable. +CMAKE_COMMAND:INTERNAL=/usr/bin/cmake +//Path to cpack program executable. +CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack +//Path to ctest program executable. +CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest +//Advanced flag for variable: CMAKE_CXX_COMPILER +CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1 +CMAKE_CXX_COMPILER_WORKS:INTERNAL=1 +//Advanced flag for variable: CMAKE_CXX_FLAGS +CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_CXX_FLAGS_DEBUG +CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_CXX_FLAGS_MINSIZEREL +CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_CXX_FLAGS_RELEASE +CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO +CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_C_COMPILER +CMAKE_C_COMPILER-ADVANCED:INTERNAL=1 +CMAKE_C_COMPILER_WORKS:INTERNAL=1 +//Advanced flag for variable: CMAKE_C_FLAGS +CMAKE_C_FLAGS-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_C_FLAGS_DEBUG +CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_C_FLAGS_MINSIZEREL +CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_C_FLAGS_RELEASE +CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_C_FLAGS_RELWITHDEBINFO +CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Result of TRY_COMPILE +CMAKE_DETERMINE_CXX_ABI_COMPILED:INTERNAL=TRUE +//Result of TRY_COMPILE +CMAKE_DETERMINE_C_ABI_COMPILED:INTERNAL=TRUE +//Executable file format +CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF +//Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS +CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG +CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL +CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE +CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Name of generator. +CMAKE_GENERATOR:INTERNAL=Unix Makefiles +//Start directory with the top level CMakeLists.txt file for this +// project +CMAKE_HOME_DIRECTORY:INTERNAL=/home/markl/download/libconfig_test_app +//Install .so files without execute permission. +CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1 +//Advanced flag for variable: CMAKE_LINKER +CMAKE_LINKER-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_MAKE_PROGRAM +CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS +CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG +CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL +CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE +CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_NM +CMAKE_NM-ADVANCED:INTERNAL=1 +//number of local generators +CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=2 +//Advanced flag for variable: CMAKE_OBJCOPY +CMAKE_OBJCOPY-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_OBJDUMP +CMAKE_OBJDUMP-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_RANLIB +CMAKE_RANLIB-ADVANCED:INTERNAL=1 +//Path to CMake installation. +CMAKE_ROOT:INTERNAL=/usr/share/cmake-2.6 +//Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS +CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG +CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL +CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE +CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO +CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_SKIP_RPATH +CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_STRIP +CMAKE_STRIP-ADVANCED:INTERNAL=1 +//uname command +CMAKE_UNAME:INTERNAL=/bin/uname +//Advanced flag for variable: CMAKE_USE_RELATIVE_PATHS +CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1 +//Advanced flag for variable: CMAKE_VERBOSE_MAKEFILE +CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1 + diff --git a/contrib/cmake/CMakeFiles/CMakeCCompiler.cmake b/contrib/cmake/CMakeFiles/CMakeCCompiler.cmake new file mode 100644 index 0000000..26afd10 --- /dev/null +++ b/contrib/cmake/CMakeFiles/CMakeCCompiler.cmake @@ -0,0 +1,36 @@ +SET(CMAKE_C_COMPILER "/usr/bin/gcc") +SET(CMAKE_C_COMPILER_ARG1 "") +SET(CMAKE_C_COMPILER_ID "GNU") +SET(CMAKE_C_PLATFORM_ID "Linux") +SET(CMAKE_AR "/usr/bin/ar") +SET(CMAKE_RANLIB "/usr/bin/ranlib") +SET(CMAKE_COMPILER_IS_GNUCC 1) +SET(CMAKE_C_COMPILER_LOADED 1) +SET(CMAKE_COMPILER_IS_MINGW ) +SET(CMAKE_COMPILER_IS_CYGWIN ) +IF(CMAKE_COMPILER_IS_CYGWIN) + SET(CYGWIN 1) + SET(UNIX 1) +ENDIF(CMAKE_COMPILER_IS_CYGWIN) + +SET(CMAKE_C_COMPILER_ENV_VAR "CC") + +IF(CMAKE_COMPILER_IS_MINGW) + SET(MINGW 1) +ENDIF(CMAKE_COMPILER_IS_MINGW) +SET(CMAKE_C_COMPILER_ID_RUN 1) +SET(CMAKE_C_SOURCE_FILE_EXTENSIONS c) +SET(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_C_LINKER_PREFERENCE 10) + +# Save compiler ABI information. +SET(CMAKE_C_SIZEOF_DATA_PTR "4") +SET(CMAKE_C_COMPILER_ABI "ELF") + +IF(CMAKE_C_SIZEOF_DATA_PTR) + SET(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") +ENDIF(CMAKE_C_SIZEOF_DATA_PTR) + +IF(CMAKE_C_COMPILER_ABI) + SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") +ENDIF(CMAKE_C_COMPILER_ABI) diff --git a/contrib/cmake/CMakeFiles/CMakeCXXCompiler.cmake b/contrib/cmake/CMakeFiles/CMakeCXXCompiler.cmake new file mode 100644 index 0000000..62c36c9 --- /dev/null +++ b/contrib/cmake/CMakeFiles/CMakeCXXCompiler.cmake @@ -0,0 +1,36 @@ +SET(CMAKE_CXX_COMPILER "/usr/bin/c++") +SET(CMAKE_CXX_COMPILER_ARG1 "") +SET(CMAKE_CXX_COMPILER_ID "GNU") +SET(CMAKE_CXX_PLATFORM_ID "Linux") +SET(CMAKE_AR "/usr/bin/ar") +SET(CMAKE_RANLIB "/usr/bin/ranlib") +SET(CMAKE_COMPILER_IS_GNUCXX 1) +SET(CMAKE_CXX_COMPILER_LOADED 1) +SET(CMAKE_COMPILER_IS_MINGW ) +SET(CMAKE_COMPILER_IS_CYGWIN ) +IF(CMAKE_COMPILER_IS_CYGWIN) + SET(CYGWIN 1) + SET(UNIX 1) +ENDIF(CMAKE_COMPILER_IS_CYGWIN) + +SET(CMAKE_CXX_COMPILER_ENV_VAR "CXX") + +IF(CMAKE_COMPILER_IS_MINGW) + SET(MINGW 1) +ENDIF(CMAKE_COMPILER_IS_MINGW) +SET(CMAKE_CXX_COMPILER_ID_RUN 1) +SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm) +SET(CMAKE_CXX_LINKER_PREFERENCE 30) + +# Save compiler ABI information. +SET(CMAKE_CXX_SIZEOF_DATA_PTR "4") +SET(CMAKE_CXX_COMPILER_ABI "ELF") + +IF(CMAKE_CXX_SIZEOF_DATA_PTR) + SET(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") +ENDIF(CMAKE_CXX_SIZEOF_DATA_PTR) + +IF(CMAKE_CXX_COMPILER_ABI) + SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") +ENDIF(CMAKE_CXX_COMPILER_ABI) diff --git a/contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_C.bin b/contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_C.bin new file mode 100755 index 0000000..da7f565 Binary files /dev/null and b/contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_C.bin differ diff --git a/contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin b/contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin new file mode 100755 index 0000000..52505ce Binary files /dev/null and b/contrib/cmake/CMakeFiles/CMakeDetermineCompilerABI_CXX.bin differ diff --git a/contrib/cmake/CMakeFiles/CMakeOutput.log b/contrib/cmake/CMakeFiles/CMakeOutput.log new file mode 100644 index 0000000..9314bb2 --- /dev/null +++ b/contrib/cmake/CMakeFiles/CMakeOutput.log @@ -0,0 +1,89 @@ +The system is: Linux - 2.6.31-20-generic-pae - i686 +Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. +Compiler: /usr/bin/gcc +Build flags: +Id flags: + +The output was: +0 + + +Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" + +The C compiler identification is GNU, found in "/home/markl/download/libconfig_test_app/CMakeFiles/CompilerIdC/a.out" + +Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. +Compiler: /usr/bin/c++ +Build flags: +Id flags: + +The output was: +0 +CMakeCXXCompilerId.cpp:67: warning: deprecated conversion from string constant to 'char*' +CMakeCXXCompilerId.cpp:157: warning: deprecated conversion from string constant to 'char*' + + +Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" + +The CXX compiler identification is GNU, found in "/home/markl/download/libconfig_test_app/CMakeFiles/CompilerIdCXX/a.out" + +Determining if the C compiler works passed with the following output: +Change Dir: /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp/testCCompiler.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' + + +Detecting C compiler ABI info compiled with the following output: +Change Dir: /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building C object CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o +/usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-2.6/Modules/CMakeCCompilerABI.c +Linking C executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/CMakeCCompilerABI.c.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' + + +Determining if the CXX compiler works passed with the following output: +Change Dir: /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building CXX object CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o +/usr/bin/c++ -o CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -c /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp/testCXXCompiler.cxx +Linking CXX executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/c++ CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' + + +Detecting CXX compiler ABI info compiled with the following output: +Change Dir: /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp + +Run Build Command:/usr/bin/make "cmTryCompileExec/fast" +/usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build +make[1]: Entering directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' +/usr/bin/cmake -E cmake_progress_report /home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp/CMakeFiles 1 +Building CXX object CMakeFiles/cmTryCompileExec.dir/CMakeCXXCompilerABI.cpp.o +/usr/bin/c++ -o CMakeFiles/cmTryCompileExec.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-2.6/Modules/CMakeCXXCompilerABI.cpp +Linking CXX executable cmTryCompileExec +/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1 +/usr/bin/c++ CMakeFiles/cmTryCompileExec.dir/CMakeCXXCompilerABI.cpp.o -o cmTryCompileExec -rdynamic +make[1]: Leaving directory `/home/markl/download/libconfig_test_app/CMakeFiles/CMakeTmp' + + diff --git a/contrib/cmake/CMakeFiles/CMakeSystem.cmake b/contrib/cmake/CMakeFiles/CMakeSystem.cmake new file mode 100644 index 0000000..24477a5 --- /dev/null +++ b/contrib/cmake/CMakeFiles/CMakeSystem.cmake @@ -0,0 +1,15 @@ + + +SET(CMAKE_SYSTEM "Linux-2.6.31-20-generic-pae") +SET(CMAKE_SYSTEM_NAME "Linux") +SET(CMAKE_SYSTEM_VERSION "2.6.31-20-generic-pae") +SET(CMAKE_SYSTEM_PROCESSOR "i686") + +SET(CMAKE_HOST_SYSTEM "Linux-2.6.31-20-generic-pae") +SET(CMAKE_HOST_SYSTEM_NAME "Linux") +SET(CMAKE_HOST_SYSTEM_VERSION "2.6.31-20-generic-pae") +SET(CMAKE_HOST_SYSTEM_PROCESSOR "i686") + +SET(CMAKE_CROSSCOMPILING "FALSE") + +SET(CMAKE_SYSTEM_LOADED 1) diff --git a/contrib/cmake/CMakeFiles/CompilerIdC/CMakeCCompilerId.c b/contrib/cmake/CMakeFiles/CompilerIdC/CMakeCCompilerId.c new file mode 100644 index 0000000..7fd0088 --- /dev/null +++ b/contrib/cmake/CMakeFiles/CompilerIdC/CMakeCCompilerId.c @@ -0,0 +1,182 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for C." +#endif + +#if defined(__18CXX) +# define ID_VOID_MAIN +#endif + +#if defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + +#elif defined(__WATCOMC__) +# define COMPILER_ID "Watcom" + +#elif defined(__SUNPRO_C) +# define COMPILER_ID "SunPro" + +#elif defined(__HP_cc) +# define COMPILER_ID "HP" + +#elif defined(__DECC) +# define COMPILER_ID "Compaq" + +#elif defined(__IBMC__) +# define COMPILER_ID "VisualAge" + +#elif defined(__PGI) +# define COMPILER_ID "PGI" + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + +#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) +/* Analog Devices C++ compiler for Blackfin, TigerSHARC and + SHARC (21000) DSPs */ +# define COMPILER_ID "ADSP" + +/* IAR Systems compiler for embedded systems. + http://www.iar.com + Not supported yet by CMake +#elif defined(__IAR_SYSTEMS_ICC__) +# define COMPILER_ID "IAR" */ + +/* sdcc, the small devices C compiler for embedded systems, + http://sdcc.sourceforge.net */ +#elif defined(SDCC) +# define COMPILER_ID "SDCC" + +#elif defined(_COMPILER_VERSION) +# define COMPILER_ID "MIPSpro" + +/* This compiler is either not known or is too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__sgi) +# define COMPILER_ID "MIPSpro" + +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" + +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) +# define PLATFORM_ID "IRIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU) +# define PLATFORM_ID "Haiku" +/* Haiku also defines __BEOS__ so we must + put it prior to the check for __BEOS__ +*/ + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#else /* unknown platform */ +# define PLATFORM_ID "" + +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; + + +/*--------------------------------------------------------------------------*/ + +#ifdef ID_VOID_MAIN +void main() {} +#else +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + (void)argv; + return require; +} +#endif diff --git a/contrib/cmake/CMakeFiles/CompilerIdC/a.out b/contrib/cmake/CMakeFiles/CompilerIdC/a.out new file mode 100755 index 0000000..b18090c Binary files /dev/null and b/contrib/cmake/CMakeFiles/CompilerIdC/a.out differ diff --git a/contrib/cmake/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp b/contrib/cmake/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp new file mode 100644 index 0000000..f8c041f --- /dev/null +++ b/contrib/cmake/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp @@ -0,0 +1,169 @@ +/* This source file must have a .cpp extension so that all C++ compilers + recognize the extension without flags. Borland does not know .cxx for + example. */ +#ifndef __cplusplus +# error "A C compiler has been selected for C++." +#endif + +#if defined(__COMO__) +# define COMPILER_ID "Comeau" + +#elif defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + +#elif defined(__WATCOMC__) +# define COMPILER_ID "Watcom" + +#elif defined(__SUNPRO_CC) +# define COMPILER_ID "SunPro" + +#elif defined(__HP_aCC) +# define COMPILER_ID "HP" + +#elif defined(__DECCXX) +# define COMPILER_ID "Compaq" + +#elif defined(__IBMCPP__) +# define COMPILER_ID "VisualAge" + +#elif defined(__PGI) +# define COMPILER_ID "PGI" + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + +#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) +/* Analog Devices C++ compiler for Blackfin, TigerSHARC and + SHARC (21000) DSPs */ +# define COMPILER_ID "ADSP" + +#elif defined(_COMPILER_VERSION) +# define COMPILER_ID "MIPSpro" + +/* This compiler is either not known or is too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__sgi) +# define COMPILER_ID "MIPSpro" + +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" + +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) +# define PLATFORM_ID "IRIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU) +# define PLATFORM_ID "Haiku" +/* Haiku also defines __BEOS__ so we must + put it prior to the check for __BEOS__ +*/ + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#else /* unknown platform */ +# define PLATFORM_ID "" + +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; + + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + (void)argv; + return require; +} diff --git a/contrib/cmake/CMakeFiles/CompilerIdCXX/a.out b/contrib/cmake/CMakeFiles/CompilerIdCXX/a.out new file mode 100755 index 0000000..74b17e6 Binary files /dev/null and b/contrib/cmake/CMakeFiles/CompilerIdCXX/a.out differ diff --git a/contrib/cmake/CMakeFiles/cmake.check_cache b/contrib/cmake/CMakeFiles/cmake.check_cache new file mode 100644 index 0000000..3dccd73 --- /dev/null +++ b/contrib/cmake/CMakeFiles/cmake.check_cache @@ -0,0 +1 @@ +# This file is generated by cmake for dependency checking of the CMakeCache.txt file diff --git a/contrib/cmake/CMakeLists.txt b/contrib/cmake/CMakeLists.txt new file mode 100644 index 0000000..716888f --- /dev/null +++ b/contrib/cmake/CMakeLists.txt @@ -0,0 +1,22 @@ +#cmake_minimum_required(VERSION 2.8) + +PROJECT(libconfig_test_app) + +add_subdirectory(src) + +#add cmake script files +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_work") + +#check if libconfig is present (FindConfig.cmake and FindConfig++.cmake files) +FIND_PACKAGE(Config REQUIRED) +FIND_PACKAGE(Config++ REQUIRED) + +#add undelete support +CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_work/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_work/cmake_uninstall.cmake" + IMMEDIATE @ONLY) +ADD_CUSTOM_TARGET(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_work/cmake_uninstall.cmake") + + diff --git a/contrib/cmake/cmake_work/FindConfig++.cmake b/contrib/cmake/cmake_work/FindConfig++.cmake new file mode 100644 index 0000000..f6d11a3 --- /dev/null +++ b/contrib/cmake/cmake_work/FindConfig++.cmake @@ -0,0 +1,23 @@ +FIND_PATH(CONFIG++_INCLUDE_DIR libconfig.h++ /usr/include /usr/local/include) + +FIND_LIBRARY(CONFIG++_LIBRARY NAMES config++ PATH /usr/lib /usr/local/lib) + +IF (CONFIG++_INCLUDE_DIR AND CONFIG++_LIBRARY) + SET(CONFIG++_FOUND TRUE) +ENDIF ( CONFIG++_INCLUDE_DIR AND CONFIG++_LIBRARY) + +IF (CONFIG++_FOUND) + IF (NOT CONFIG++_FIND_QUIETLY) + MESSAGE(STATUS "Found Config++: ${CONFIG++_LIBRARY}") + ENDIF (NOT CONFIG++_FIND_QUIETLY) +ELSE(CONFIG++_FOUND) + IF (Config++_FIND_REQUIRED) + IF(NOT CONFIG++_INCLUDE_DIR) + MESSAGE(FATAL_ERROR "Could not find LibConfig++ header file!") + ENDIF(NOT CONFIG++_INCLUDE_DIR) + + IF(NOT CONFIG++_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find LibConfig++ library file!") + ENDIF(NOT CONFIG++_LIBRARY) + ENDIF (Config++_FIND_REQUIRED) +ENDIF (CONFIG++_FOUND) \ No newline at end of file diff --git a/contrib/cmake/cmake_work/FindConfig.cmake b/contrib/cmake/cmake_work/FindConfig.cmake new file mode 100644 index 0000000..5361d96 --- /dev/null +++ b/contrib/cmake/cmake_work/FindConfig.cmake @@ -0,0 +1,23 @@ +FIND_PATH(CONFIG_INCLUDE_DIR libconfig.h /usr/include /usr/local/include) + +FIND_LIBRARY(CONFIG_LIBRARY NAMES config PATH /usr/lib /usr/local/lib) + +IF (CONFIG_INCLUDE_DIR AND CONFIG_LIBRARY) + SET(CONFIG_FOUND TRUE) +ENDIF ( CONFIG_INCLUDE_DIR AND CONFIG_LIBRARY) + +IF (CONFIG_FOUND) + IF (NOT CONFIG_FIND_QUIETLY) + MESSAGE(STATUS "Found Config: ${CONFIG_LIBRARY}") + ENDIF (NOT CONFIG_FIND_QUIETLY) +ELSE(CONFIG_FOUND) + IF (Config_FIND_REQUIRED) + IF(NOT CONFIG_INCLUDE_DIR) + MESSAGE(FATAL_ERROR "Could not find LibConfig header file!") + ENDIF(NOT CONFIG_INCLUDE_DIR) + + IF(NOT CONFIG_LIBRARY) + MESSAGE(FATAL_ERROR "Could not find LibConfig library file!") + ENDIF(NOT CONFIG_LIBRARY) + ENDIF (Config_FIND_REQUIRED) +ENDIF (CONFIG_FOUND) \ No newline at end of file diff --git a/contrib/cmake/cmake_work/cmake_uninstall.cmake.in b/contrib/cmake/cmake_work/cmake_uninstall.cmake.in new file mode 100644 index 0000000..10a2937 --- /dev/null +++ b/contrib/cmake/cmake_work/cmake_uninstall.cmake.in @@ -0,0 +1,36 @@ +# Copyright 2006-2008 The FLWOR Foundation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + IF(EXISTS "$ENV{DESTDIR}${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF("${rm_retval}" STREQUAL 0) + ELSE("${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + ENDIF("${rm_retval}" STREQUAL 0) + ELSE(EXISTS "$ENV{DESTDIR}${file}") + MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + ENDIF(EXISTS "$ENV{DESTDIR}${file}") +ENDFOREACH(file) diff --git a/contrib/cmake/src/CMakeLists.txt b/contrib/cmake/src/CMakeLists.txt new file mode 100644 index 0000000..b10b7da --- /dev/null +++ b/contrib/cmake/src/CMakeLists.txt @@ -0,0 +1,6 @@ +PROJECT(libconfig_test_app) + +ADD_EXECUTABLE(libconfig_test_app main.cpp) + +target_link_libraries(libconfig_test_app config++) + diff --git a/contrib/cmake/src/main.cpp b/contrib/cmake/src/main.cpp new file mode 100644 index 0000000..a563249 --- /dev/null +++ b/contrib/cmake/src/main.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +using namespace std; +using namespace libconfig; + +int main ( int argc, char **argv ) +{ + Config cfg; + + return (0); +} \ No newline at end of file diff --git a/contrib/copy_setting.c b/contrib/copy_setting.c new file mode 100644 index 0000000..1b20e59 --- /dev/null +++ b/contrib/copy_setting.c @@ -0,0 +1,161 @@ +void config_setting_copy_simple(config_setting_t * parent, const config_setting_t * src); +void config_setting_copy_elem(config_setting_t * parent, const config_setting_t * src); + +void config_setting_copy_aggregate(config_setting_t * parent, const config_setting_t * src); +int config_setting_copy(config_setting_t * parent, const config_setting_t * src); + +void config_setting_copy_simple(config_setting_t * parent, const config_setting_t * src) +{ + if(config_setting_is_aggregate(src)) + { + config_setting_copy_aggregate(parent, src); + } + else + { + config_setting_t * set; + + set = config_setting_add(parent, config_setting_name(src), config_setting_type(src)); + + if(CONFIG_TYPE_INT == config_setting_type(src)) + { + config_setting_set_int(set, config_setting_get_int(src)); + config_setting_set_format(set, src->format); + } + else if(CONFIG_TYPE_INT64 == config_setting_type(src)) + { + config_setting_set_int64(set, config_setting_get_int64(src)); + config_setting_set_format(set, src->format); + } + else if(CONFIG_TYPE_FLOAT == config_setting_type(src)) + config_setting_set_float(set, config_setting_get_float(src)); + else if(CONFIG_TYPE_STRING == config_setting_type(src)) + config_setting_set_string(set, config_setting_get_string(src)); + else if(CONFIG_TYPE_BOOL == config_setting_type(src)) + config_setting_set_bool(set, config_setting_get_bool(src)); + } +} + +void config_setting_copy_elem(config_setting_t * parent, const config_setting_t * src) +{ + config_setting_t * set; + + set = NULL; + if(config_setting_is_aggregate(src)) + config_setting_copy_aggregate(parent, src); + else if(CONFIG_TYPE_INT == config_setting_type(src)) + { + set = config_setting_set_int_elem(parent, -1, config_setting_get_int(src)); + config_setting_set_format(set, src->format); + } + else if(CONFIG_TYPE_INT64 == config_setting_type(src)) + { + set = config_setting_set_int64_elem(parent, -1, config_setting_get_int64(src)); + config_setting_set_format(set, src->format); + } + else if(CONFIG_TYPE_FLOAT == config_setting_type(src)) + set = config_setting_set_float_elem(parent, -1, config_setting_get_float(src)); + else if(CONFIG_TYPE_STRING == config_setting_type(src)) + set = config_setting_set_string_elem(parent, -1, config_setting_get_string(src)); + else if(CONFIG_TYPE_BOOL == config_setting_type(src)) + set = config_setting_set_bool_elem(parent, -1, config_setting_get_bool(src)); +} + +void config_setting_copy_aggregate(config_setting_t * parent, const config_setting_t * src) +{ + config_setting_t * newAgg; + int i, n; + + newAgg = config_setting_add(parent, config_setting_name(src), config_setting_type(src)); + + n = config_setting_length(src); + for(i = 0; i < n; i++) + { + if(config_setting_is_group(src)) + { + config_setting_copy_simple(newAgg, config_setting_get_elem(src, i)); + } + else + { + config_setting_copy_elem(newAgg, config_setting_get_elem(src, i)); + } + } +} + +int config_setting_copy(config_setting_t * parent, const config_setting_t * src) +{ + if((!config_setting_is_group(parent)) && + (!config_setting_is_list(parent))) + return CONFIG_FALSE; + + if(config_setting_is_aggregate(src)) + { + config_setting_copy_aggregate(parent, src); + } + else + { + config_setting_copy_simple(parent, src); + } + + return CONFIG_TRUE; +} + + +//Some sample code + +//----------------------------------------------------------------------------- +int main(int argc, char *argv[]) +//----------------------------------------------------------------------------- +{ + config_t cfgSrc; + config_t cfgSrcCopy; + config_t cfgDst; + + + config_init(&cfgSrc); + config_init(&cfgSrcCopy); + config_init(&cfgDst); + + if(CONFIG_FALSE == config_read_file(&cfgSrc, "/data/menu/cfgSrc.cfg")) + { + fprintf(stderr, "Failed to open cfgSrc.cfg\n"); + } + if(CONFIG_FALSE == config_read_file(&cfgDst, "/data/menu/cfgDst.cfg")) + { + fprintf(stderr, "Failed to open cfgDst.cfg\n"); + } + + /* + printf("Dump cfgSrc.cfg\n"); + DumpCfgSetting(config_root_setting(&cfgSrc)); + + printf("Dump cfgDst.cfg\n"); + DumpCfgSetting(config_root_setting(&cfgDst)); + */ + + config_setting_t * src; + config_setting_t * dst; + + dst = config_lookup(&cfgDst, "grp1"); + + if((0 != (dst = config_lookup(&cfgDst, "grp1"))) && + (0 != (src = config_lookup(&cfgSrc, "application.window")))) + //(0 != (src = config_lookup(&cfgSrc, "list")))) + + { + if(CONFIG_FALSE == config_setting_copy(dst, src)) + { + printf("Failed to copy src to dst\n"); + } + } + + config_setting_copy(config_root_setting(&cfgSrcCopy), config_root_setting(&cfgSrc)); + + config_write_file(&cfgDst, "/data/menu/cfgDstMod.cfg"); + config_write_file(&cfgSrcCopy, "/data/menu/cfgSrcCpy.cfg"); + config_write_file(&cfgSrc, "/data/menu/cfgSrcOrig.cfg"); + + config_destroy(&cfgSrc); + config_destroy(&cfgDst); + + return 0; +} diff --git a/contrib/libconfig-ruby/README b/contrib/libconfig-ruby/README new file mode 100644 index 0000000..1a45477 --- /dev/null +++ b/contrib/libconfig-ruby/README @@ -0,0 +1,76 @@ +# << Usage >> + +# you can feed this README to irb and see the result +# $ irb README + +# IMPORTANT NOTICE: +# be careful with big *fixnum* (plain int) values in configs +# int is 32 bit, but ruby fixnum is only 31! +# For example, 2100000000 will be read as -47483648. + +require 'rconfig' +c = Config.new + +c.read!('test.cfg') +# => IOError +c.read('test.cfg') +# => false + +p c['some_var'] +# => SettingNotFoundError +# note: Config#lookup is alias for Config#[] + +c.append 'fixnum', Config::Fixnum.new(150) +# # + +f1 = Config::Fixnum.new(1) +c.append 'another_fixnum', f1 + +f2 = Config::Fixnum.new(256) +c.append 'next_fixnum', f2 + +p c.size +# => 3 + +c.delete(f1) # by element +c.delete(0) # by index +c.delete('next_fixnum') # by name +# note: (at now) you cannot delete nested elements by Config#delete +# you can do c['nested.element'].parent.delete(c['nested.element']) + +p c.size +# => 0 + +l = Config::List.new +c.append 'the_list', l + +l.append Config::String.new("abcdef") +l << Config::Float.new(3.14) +# note: Config::List#append and Config::Array#append both have +# aliases Config::[Aggregate]#<< + +p l.name +# => "the_list" + +p l.index +# => 0 + +p l.root? +# => false + +p l.size +# => 3 + +l[0].format = Config::FORMAT_HEX + +p l[1].value +# => 3.14 + +l[1].value = 2.71828 + +c.write 'test.cfg' + +# you will get test.cfg with following contents: +# +# the_list = ( "abcdef", 2.71828, 0x2A ); +# diff --git a/contrib/libconfig-ruby/Rakefile b/contrib/libconfig-ruby/Rakefile new file mode 100644 index 0000000..62dc34d --- /dev/null +++ b/contrib/libconfig-ruby/Rakefile @@ -0,0 +1,17 @@ +require 'rubygems' +require 'rake/gempackagetask' + +spec = Gem::Specification.new do |s| + s.name = "rconfig" + s.version = "1.0" + s.author = "Peter Zotov" + s.email = "whitequark@whitequark.ru" + s.platform = Gem::Platform::RUBY + s.summary = "libconfig bindings" + s.files = [ File.join('ext', 'extconf.rb'), File.join('ext', 'rconfig.c') ].to_a + s.extensions = 'ext/extconf.rb' +end + +Rake::GemPackageTask.new(spec) do |pkg| +end + diff --git a/contrib/libconfig-ruby/ext/extconf.rb b/contrib/libconfig-ruby/ext/extconf.rb new file mode 100644 index 0000000..e6d65ca --- /dev/null +++ b/contrib/libconfig-ruby/ext/extconf.rb @@ -0,0 +1,11 @@ +#!/usr/bin/ruby +require "mkmf" + +unless pkg_config('libconfig') + puts 'failure: need libconfig' + exit 1 +end + +have_func('rb_block_call', 'ruby/ruby.h') + +create_makefile("rconfig") diff --git a/contrib/libconfig-ruby/ext/rconfig.c b/contrib/libconfig-ruby/ext/rconfig.c new file mode 100644 index 0000000..c111cd6 --- /dev/null +++ b/contrib/libconfig-ruby/ext/rconfig.c @@ -0,0 +1,700 @@ +#include +#include + +static VALUE cConfig, cConfigBaseSetting, cConfigSetting, cConfigAggregate; +static VALUE cConfigFormatDefault, cConfigFormatHex; +static VALUE cConfigFixnum, cConfigBignum, cConfigFloat, cConfigBoolean, cConfigString; +static VALUE cConfigGroup, cConfigList, cConfigArray; + +static VALUE rSettingNameRegexp; +static VALUE aConfigSettings, aConfigScalars, aConfigAggregates; +static VALUE eConfigParseError, eSettingNotFoundError, eSettingFormatError, eSettingNameError; + +static VALUE rconfig_wrap_value(config_setting_t* setting) +{ + switch(config_setting_type(setting)) { + case CONFIG_TYPE_INT: + return LONG2FIX(config_setting_get_int(setting)); + + case CONFIG_TYPE_INT64: + return rb_ll2inum(config_setting_get_int64(setting)); + + case CONFIG_TYPE_FLOAT: + return rb_float_new(config_setting_get_float(setting)); + + case CONFIG_TYPE_STRING: + return rb_str_new2(config_setting_get_string(setting)); + + case CONFIG_TYPE_BOOL: + return config_setting_get_bool(setting) ? Qtrue : Qfalse; + + default: + rb_bug("unknown value type %d", config_setting_type(setting)); + } +} + +static void rconfig_free_setting(config_setting_t* setting) +{ + // dummy +} + +static VALUE rconfig_prepare_setting(config_setting_t* setting) +{ + VALUE wrapper = Data_Wrap_Struct(rb_cObject, 0, rconfig_free_setting, setting); + config_setting_set_hook(setting, (void*) wrapper); + return wrapper; +} + +static void rconfig_destroy_setting(void* hook) +{ + if(hook != NULL) { + VALUE wrapper = (VALUE) hook; + rb_iv_set(wrapper, "@setting", Qnil); + } +} + +static VALUE rconfig_wrap_setting(config_setting_t* setting) +{ + VALUE rbSetting = rconfig_prepare_setting(setting); + + switch(config_setting_type(setting)) { + case CONFIG_TYPE_INT: + return rb_funcall(cConfigFixnum, rb_intern("new"), 2, LONG2FIX(config_setting_get_int(setting)), rbSetting); + + case CONFIG_TYPE_INT64: + return rb_funcall(cConfigBignum, rb_intern("new"), 2, rb_ll2inum(config_setting_get_int64(setting)), rbSetting); + + case CONFIG_TYPE_FLOAT: + return rb_funcall(cConfigFloat, rb_intern("new"), 2, rb_float_new(config_setting_get_float(setting)), rbSetting); + + case CONFIG_TYPE_STRING: + return rb_funcall(cConfigString, rb_intern("new"), 2, rb_str_new2(config_setting_get_string(setting)), rbSetting); + + case CONFIG_TYPE_BOOL: + return rb_funcall(cConfigBoolean, rb_intern("new"), 2, config_setting_get_bool(setting) ? Qtrue : Qfalse, rbSetting); + + case CONFIG_TYPE_ARRAY: + return rb_funcall(cConfigArray, rb_intern("new"), 2, Qnil, rbSetting); + + case CONFIG_TYPE_LIST: + return rb_funcall(cConfigList, rb_intern("new"), 1, rbSetting); + + case CONFIG_TYPE_GROUP: + return rb_funcall(cConfigGroup, rb_intern("new"), 1, rbSetting); + + default: + rb_bug("[r] unknown setting type %d", config_setting_type(setting)); + } +} + +static void rconfig_update_setting(config_setting_t* setting, VALUE value) +{ + switch(config_setting_type(setting)) { + case CONFIG_TYPE_INT: + config_setting_set_int(setting, FIX2LONG(value)); + break; + + case CONFIG_TYPE_INT64: + if(TYPE(value) == T_BIGNUM) + config_setting_set_int64(setting, rb_big2ll(value)); + else // T_FIXNUM + config_setting_set_int64(setting, FIX2INT(value)); + break; + + case CONFIG_TYPE_FLOAT: +// ruby1.9 check +#if HAVE_RB_BLOCK_CALL + config_setting_set_float(setting, RFLOAT(value)->float_value); +#else + config_setting_set_float(setting, RFLOAT(value)->value); +#endif + break; + + case CONFIG_TYPE_STRING: + config_setting_set_string(setting, RSTRING_PTR(value)); + break; + + case CONFIG_TYPE_BOOL: + config_setting_set_bool(setting, value == Qtrue); + break; + + default: + rb_bug("[w] unknown setting type %d", config_setting_type(setting)); + } +} + +static void rconfig_check_setting_type(VALUE object, VALUE value) +{ + if(rb_obj_class(object) == cConfigFixnum) { + Check_Type(value, T_FIXNUM); + } else if(rb_obj_class(object) == cConfigBignum) { + if(TYPE(value) != T_BIGNUM && TYPE(value) != T_FIXNUM) + rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or Bignum)", rb_obj_classname(value)); + } else if(rb_obj_class(object) == cConfigFloat) { + Check_Type(value, T_FLOAT); + } else if(rb_obj_class(object) == cConfigString) { + Check_Type(value, T_STRING); + } else if(rb_obj_class(object) == cConfigBoolean) { + if(value != Qtrue && value != Qfalse) + rb_raise(rb_eTypeError, "wrong argument type %s (expected boolean)", rb_obj_classname(value)); + } else { + rb_raise(rb_eException, "never use Config::Setting itself"); + } +} + +static int rconfig_do_append(config_setting_t* setting, VALUE target, VALUE name) +{ + int type; + if(rb_obj_class(target) == cConfigFixnum) + type = CONFIG_TYPE_INT; + else if(rb_obj_class(target) == cConfigBignum) + type = CONFIG_TYPE_INT64; + else if(rb_obj_class(target) == cConfigFloat) + type = CONFIG_TYPE_FLOAT; + else if(rb_obj_class(target) == cConfigString) + type = CONFIG_TYPE_STRING; + else if(rb_obj_class(target) == cConfigBoolean) + type = CONFIG_TYPE_BOOL; + else if(rb_obj_class(target) == cConfigGroup) + type = CONFIG_TYPE_GROUP; + else if(rb_obj_class(target) == cConfigList) + type = CONFIG_TYPE_LIST; + else if(rb_obj_class(target) == cConfigArray) + type = CONFIG_TYPE_ARRAY; + else + rb_bug("unknown setting class %s", rb_obj_classname(target)); + + config_setting_t* new_setting; + if(name == Qnil) { + new_setting = config_setting_add(setting, NULL, type); + } else { + Check_Type(name, T_STRING); + new_setting = config_setting_add(setting, RSTRING_PTR(name), type); + } + + if(new_setting == NULL) + return 0; + + VALUE rbNewSetting = rconfig_prepare_setting(new_setting); + rb_iv_set(target, "@setting", rbNewSetting); + + if(rb_ary_includes(aConfigScalars, rb_obj_class(target)) == Qtrue) + rconfig_update_setting(new_setting, rb_iv_get(target, "@value")); + + if(rb_ary_includes(aConfigAggregates, rb_obj_class(target)) == Qtrue) { + if(rb_obj_class(target) == cConfigGroup) { + VALUE hash = rb_iv_get(target, "@hash"); + VALUE children = rb_funcall(hash, rb_intern("keys"), 0); + int i; + for(i = 0; i < RARRAY_LEN(children); i++) { + VALUE key = RARRAY_PTR(children)[i]; + rconfig_do_append(new_setting, rb_hash_aref(hash, key), key); + } + } else { + VALUE children = rb_iv_get(target, "@list"); + int i; + for(i = 0; i < RARRAY_LEN(children); i++) { + rconfig_do_append(new_setting, RARRAY_PTR(children)[i], Qnil); + } + } + } + + return 1; +} + +static VALUE rbConfigBaseSetting_initialize(VALUE self, VALUE setting) +{ + if(setting != Qnil) + Check_Type(setting, T_DATA); + rb_iv_set(self, "@setting", setting); + + return self; +} + +static VALUE rbConfigBaseSetting_name(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting = NULL; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return rb_str_new2(config_setting_name(setting)); + } else { + return Qnil; + } +} + +static VALUE rbConfigBaseSetting_parent(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting = NULL; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return rconfig_wrap_setting(config_setting_parent(setting)); + } else { + return Qnil; + } +} + +static VALUE rbConfigBaseSetting_is_root(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting = NULL; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return config_setting_is_root(setting) ? Qtrue : Qfalse; + } else { + return Qnil; + } +} + +static VALUE rbConfigBaseSetting_index(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting = NULL; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return INT2FIX(config_setting_index(setting)); + } else { + return Qnil; + } +} + +static VALUE rbConfigBaseSetting_line(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting = NULL; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return INT2FIX(config_setting_source_line(setting)); + } else { + return Qnil; + } +} + +static VALUE rbConfigSetting_initialize(int argc, VALUE* argv, VALUE self) +{ + VALUE value, setting; + rb_scan_args(argc, argv, "11", &value, &setting); + + rb_call_super(1, &setting); + + rconfig_check_setting_type(self, value); + rb_iv_set(self, "@value", value); + + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* c_setting = NULL; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, c_setting); + rb_iv_set(self, "@format", INT2FIX(config_setting_get_format(c_setting))); + } else { + rb_iv_set(self, "@format", cConfigFormatDefault); + } + + return self; +} + +static VALUE rbConfigSetting_get_value(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return rconfig_wrap_value(setting); + } else { + return rb_iv_get(self, "@value"); + } +} + +static VALUE rbConfigSetting_set_value(VALUE self, VALUE new_value) +{ + rconfig_check_setting_type(self, new_value); + + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + rconfig_update_setting(setting, new_value); + } + + rb_iv_set(self, "@value", new_value); + + return new_value; +} + +static VALUE rbConfigSetting_get_format(VALUE self) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + return INT2FIX(config_setting_get_format(setting)); + } else { + return rb_iv_get(self, "format"); + } +} + +static VALUE rbConfigSetting_set_format(VALUE self, VALUE new_format) +{ + if(rb_iv_get(self, "@setting") != Qnil) { + config_setting_t* setting; + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + if(!config_setting_set_format(setting, FIX2INT(new_format))) + rb_raise(eSettingFormatError, "invalid setting format %d", FIX2INT(new_format)); + } + + rb_iv_set(self, "@format", new_format); + + return new_format; +} + +static VALUE rbConfigAggregate_get(VALUE self, VALUE index); + +static VALUE rbConfigAggregate_initialize(int argc, VALUE* argv, VALUE self) +{ + VALUE setting = Qnil; + if(rb_obj_class(self) == cConfigGroup || rb_obj_class(self) == cConfigList) { + rb_scan_args(argc, argv, "01", &setting); + } else if(rb_obj_class(self) == cConfigArray) { + VALUE type = Qnil; + rb_scan_args(argc, argv, "02", &type, &setting); + + if(type != Qnil && rb_ary_includes(aConfigScalars, type) != Qtrue) + rb_raise(rb_eTypeError, "invalid setting array type %s", rb_class2name(type)); + + rb_iv_set(self, "@type", type); + } else { + rb_raise(rb_eException, "never create Config::Aggregate itself"); + } + + rb_call_super(1, &setting); + + rb_iv_set(self, "@list", rb_ary_new()); + if(rb_obj_class(self) == cConfigGroup) + rb_iv_set(self, "@hash", rb_hash_new()); + + if(setting != Qnil && rb_obj_class(self) == cConfigArray) { + config_setting_t* c_setting; + Data_Get_Struct(setting, config_setting_t, c_setting); + if(config_setting_length(c_setting) > 0) + rb_iv_set(self, "@type", rb_obj_class(rbConfigAggregate_get(self, INT2FIX(0)))); + } + + return self; +} + +static VALUE rbConfigAggregate_size(VALUE self) +{ + config_setting_t* setting = NULL; + if(rb_iv_get(self, "@setting") != Qnil) + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + + if(setting) + return INT2FIX(config_setting_length(setting)); + else + return INT2FIX(RARRAY_LEN(rb_iv_get(self, "@list"))); +} + +static VALUE rbConfigAggregate_get(VALUE self, VALUE index) +{ + config_setting_t* setting = NULL; + if(rb_iv_get(self, "@setting") != Qnil) + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + + VALUE rbTarget = Qnil; + + if(TYPE(index) == T_STRING && rb_obj_class(self) == cConfigGroup) { + if(setting) { + config_setting_t* target = config_setting_get_member(setting, RSTRING_PTR(index)); + if(target) + rbTarget = rconfig_wrap_setting(target); + } else { + rbTarget = rb_hash_aref(rb_iv_get(self, "@hash"), index); + } + } else if(TYPE(index) == T_FIXNUM) { + if(setting) { + config_setting_t* target = config_setting_get_elem(setting, FIX2INT(index)); + if(target) + rbTarget = rconfig_wrap_setting(target); + } else { + rbTarget = rb_ary_entry(rb_iv_get(self, "@list"), FIX2INT(index)); + } + } else { + rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Fixnum)", rb_obj_classname(index)); + } + + if(rbTarget == Qnil) + if(TYPE(index) == T_STRING) + rb_raise(eSettingNotFoundError, "setting `%s' not found", RSTRING_PTR(index)); + else + rb_raise(eSettingNotFoundError, "setting [%d] not found", FIX2INT(index)); + + return rbTarget; +} + +static VALUE rbConfigAggregate_append(VALUE self, VALUE target) +{ + config_setting_t* setting = NULL; + if(rb_iv_get(self, "@setting") != Qnil) + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + + Check_Type(target, T_OBJECT); + + VALUE type = rb_iv_get(self, "@type"); + if(rb_obj_class(self) == cConfigArray) { + if(type != Qnil && type != rb_obj_class(target)) + rb_raise(rb_eTypeError, "wrong argument type %s (expected %s)", rb_obj_classname(target), rb_class2name(type)); + if(type == Qnil && rb_ary_includes(aConfigScalars, rb_obj_class(target)) != Qtrue) + rb_raise(rb_eTypeError, "invalid setting array type %s", rb_obj_classname(target)); + } + + if(rb_ary_includes(aConfigSettings, rb_obj_class(target)) == Qtrue) { + if(setting) + rconfig_do_append(setting, target, Qnil); + rb_ary_push(rb_iv_get(self, "@list"), target); + } else { + rb_raise(rb_eTypeError, "wrong argument type %s (expected Config::BaseSetting)", rb_obj_classname(target)); + } + + if(rb_obj_class(self) == cConfigArray && type == Qnil) + rb_iv_set(self, "@type", rb_obj_class(target)); + + return target; +} + +static VALUE rbConfigGroup_append(VALUE self, VALUE name, VALUE target) +{ + Check_Type(name, T_STRING); + Check_Type(target, T_OBJECT); + + config_setting_t* setting = NULL; + if(rb_iv_get(self, "@setting") != Qnil) + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + + if(rb_ary_includes(aConfigSettings, rb_obj_class(target)) == Qtrue) { + if(rb_reg_match(rSettingNameRegexp, name) == Qnil) + rb_raise(eSettingNameError, "setting name `%s' contains invalid characters", RSTRING_PTR(name)); + if(setting) { + if(!rconfig_do_append(setting, target, name)) + rb_raise(eSettingNameError, "setting `%s' already exists", RSTRING_PTR(name)); + } else if(rb_hash_aref(rb_iv_get(self, "@hash"), name) != Qnil) { + rb_raise(eSettingNameError, "setting `%s' already exists", RSTRING_PTR(name)); + } + rb_ary_push(rb_iv_get(self, "@list"), target); + rb_hash_aset(rb_iv_get(self, "@hash"), name, target); + } else { + rb_raise(rb_eTypeError, "wrong argument type %s (expected Config::BaseSetting)", rb_obj_classname(target)); + } + + return target; +} + +static VALUE rbConfigAggregate_delete(VALUE self, VALUE target) +{ + config_setting_t* setting = NULL; + if(rb_iv_get(self, "@setting") != Qnil) + Data_Get_Struct(rb_iv_get(self, "@setting"), config_setting_t, setting); + + VALUE hash = rb_iv_get(self, "@hash"), list = rb_iv_get(self, "@list"); + + if(TYPE(target) == T_STRING && rb_obj_class(self) == cConfigGroup) { + if(setting) + config_setting_remove(setting, RSTRING_PTR(target)); + + rb_ary_delete_at(list, rb_hash_aref(hash, target)); + rb_hash_delete(hash, target); + } else if(TYPE(target) == T_FIXNUM) { + int index = FIX2INT(target); + if(setting) + config_setting_remove_elem(setting, index); + + if(rb_obj_class(self) == cConfigGroup) + rb_hash_delete(hash, rbConfigBaseSetting_name(rb_ary_entry(list, index))); + rb_ary_delete_at(list, index); + } else if(rb_ary_includes(aConfigSettings, rb_obj_class(target)) == Qtrue) { + VALUE name = rbConfigBaseSetting_name(target); + if(setting) + config_setting_remove(setting, RSTRING_PTR(name)); + + if(rb_obj_class(self) == cConfigGroup) + rb_hash_delete(hash, name); + rb_ary_delete(list, target); + } else { + if(rb_obj_class(self) == cConfigGroup) + rb_raise(rb_eTypeError, "wrong argument type %s (expected String, Fixnum or Config::BaseSetting)", rb_obj_classname(target)); + else + rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or Config::BaseSetting)", rb_obj_classname(target)); + } + + return Qnil; +} + +static VALUE rbConfig_initialize(VALUE self) +{ + config_t* config = (config_t*) malloc(sizeof(config_t)); + config_init(config); + config_set_destructor(config, &rconfig_destroy_setting); + + VALUE rbConfig = Data_Wrap_Struct(rb_cObject, 0, config_destroy, config); + rb_iv_set(self, "@config", rbConfig); + + return self; +} + +static VALUE rbConfig_read_bang(VALUE self, VALUE path) +{ + Check_Type(path, T_STRING); + + config_t* config; + Data_Get_Struct(rb_iv_get(self, "@config"), config_t, config); + + if(!config_read_file(config, RSTRING_PTR(path))) { + if(config_error_line(config) == 0) + rb_raise(rb_eIOError, "cannot load config: I/O error"); + else + rb_raise(eConfigParseError, "cannot parse config on line %d: `%s'", + config_error_line(config), config_error_text(config)); + } + + return Qtrue; +} + +static VALUE rbConfig_write_bang(VALUE self, VALUE path) +{ + Check_Type(path, T_STRING); + + config_t* config; + Data_Get_Struct(rb_iv_get(self, "@config"), config_t, config); + + if(!config_write_file(config, RSTRING_PTR(path))) + rb_raise(rb_eIOError, "cannot save config: I/O error"); + + return Qtrue; +} + +static VALUE rbConfig_read(VALUE self, VALUE path) +{ + Check_Type(path, T_STRING); + + config_t* config; + Data_Get_Struct(rb_iv_get(self, "@config"), config_t, config); + + return config_read_file(config, RSTRING_PTR(path)) ? Qtrue : Qfalse; +} + +static VALUE rbConfig_write(VALUE self, VALUE path) +{ + Check_Type(path, T_STRING); + + config_t* config; + Data_Get_Struct(rb_iv_get(self, "@config"), config_t, config); + + return config_write_file(config, RSTRING_PTR(path)) ? Qtrue : Qfalse; +} + +static VALUE rbConfig_root(VALUE self) +{ + config_t* config; + Data_Get_Struct(rb_iv_get(self, "@config"), config_t, config); + + return rconfig_wrap_setting(config_root_setting(config)); +} + +static VALUE rbConfig_lookup(VALUE self, VALUE handle) +{ + if(TYPE(handle) == T_STRING) { + config_t* config; + Data_Get_Struct(rb_iv_get(self, "@config"), config_t, config); + + config_setting_t* setting; + setting = config_lookup(config, RSTRING_PTR(handle)); + + if(setting == NULL) + rb_raise(eSettingNotFoundError, "setting `%s' not found", RSTRING_PTR(handle)); + + return rconfig_wrap_setting(setting); + } else if(TYPE(handle) == T_FIXNUM) { + return rbConfigAggregate_get(rbConfig_root(self), handle); + } else { + rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Fixnum)", rb_obj_classname(handle)); + } +} + +static VALUE rbConfig_append(VALUE self, VALUE name, VALUE target) +{ + return rbConfigGroup_append(rbConfig_root(self), name, target); +} + +static VALUE rbConfig_delete(VALUE self, VALUE name) +{ + return rbConfigAggregate_delete(rbConfig_root(self), name); +} + +static VALUE rbConfig_size(VALUE self) +{ + return rbConfigAggregate_size(rbConfig_root(self)); +} + +void Init_rconfig() +{ + cConfig = rb_define_class("Config", rb_cObject); + rb_define_method(cConfig, "initialize", rbConfig_initialize, 0); + rb_define_method(cConfig, "read!", rbConfig_read_bang, 1); + rb_define_method(cConfig, "write!", rbConfig_write_bang, 1); + rb_define_method(cConfig, "read", rbConfig_read, 1); + rb_define_method(cConfig, "write", rbConfig_write, 1); + rb_define_method(cConfig, "root", rbConfig_root, 0); + rb_define_method(cConfig, "lookup", rbConfig_lookup, 1); + rb_define_method(cConfig, "[]", rbConfig_lookup, 1); + rb_define_method(cConfig, "append", rbConfig_append, 2); + rb_define_method(cConfig, "delete", rbConfig_delete, 1); + rb_define_method(cConfig, "size", rbConfig_size, 0); + + cConfigBaseSetting = rb_define_class_under(cConfig, "BaseSetting", rb_cObject); + rb_define_method(cConfigBaseSetting, "initialize", rbConfigBaseSetting_initialize, 1); + rb_define_method(cConfigBaseSetting, "name", rbConfigBaseSetting_name, 0); + rb_define_method(cConfigBaseSetting, "parent", rbConfigBaseSetting_parent, 0); + rb_define_method(cConfigBaseSetting, "root?", rbConfigBaseSetting_is_root, 0); + rb_define_method(cConfigBaseSetting, "index", rbConfigBaseSetting_index, 0); + rb_define_method(cConfigBaseSetting, "line", rbConfigBaseSetting_line, 0); + + cConfigSetting = rb_define_class_under(cConfig, "Setting", cConfigBaseSetting); + rb_define_method(cConfigSetting, "initialize", rbConfigSetting_initialize, -1); + rb_define_method(cConfigSetting, "value", rbConfigSetting_get_value, 0); + rb_define_method(cConfigSetting, "value=", rbConfigSetting_set_value, 1); + rb_define_method(cConfigSetting, "format", rbConfigSetting_get_format, 0); + rb_define_method(cConfigSetting, "format=", rbConfigSetting_set_format, 1); + + cConfigFormatDefault = INT2FIX(CONFIG_FORMAT_DEFAULT); + rb_define_const(cConfig, "FORMAT_DEFAULT", cConfigFormatDefault); + cConfigFormatHex = INT2FIX(CONFIG_FORMAT_HEX); + rb_define_const(cConfig, "FORMAT_HEX", cConfigFormatHex); + + cConfigFixnum = rb_define_class_under(cConfig, "Fixnum", cConfigSetting); + cConfigBignum = rb_define_class_under(cConfig, "Bignum", cConfigSetting); + cConfigFloat = rb_define_class_under(cConfig, "Float", cConfigSetting); + cConfigBoolean = rb_define_class_under(cConfig, "Boolean", cConfigSetting); + cConfigString = rb_define_class_under(cConfig, "String", cConfigSetting); + + cConfigAggregate = rb_define_class_under(cConfig, "Aggregate", cConfigBaseSetting); + rb_define_method(cConfigAggregate, "initialize", rbConfigAggregate_initialize, -1); + rb_define_method(cConfigAggregate, "size", rbConfigAggregate_size, 0); + rb_define_method(cConfigAggregate, "get", rbConfigAggregate_get, 1); + rb_define_method(cConfigAggregate, "[]", rbConfigAggregate_get, 1); + rb_define_method(cConfigAggregate, "delete", rbConfigAggregate_delete, 1); + + cConfigGroup = rb_define_class_under(cConfig, "Group", cConfigAggregate); + rb_define_method(cConfigGroup, "append", rbConfigGroup_append, 2); + cConfigArray = rb_define_class_under(cConfig, "Array", cConfigAggregate); + rb_define_method(cConfigArray, "append", rbConfigAggregate_append, 1); + rb_define_method(cConfigArray, "<<", rbConfigAggregate_append, 1); + cConfigList = rb_define_class_under(cConfig, "List", cConfigAggregate); + rb_define_method(cConfigList, "append", rbConfigAggregate_append, 1); + rb_define_method(cConfigList, "<<", rbConfigAggregate_append, 1); + + aConfigScalars = rb_ary_new3(5, cConfigFixnum, cConfigBignum, cConfigFloat, cConfigBoolean, cConfigString); + aConfigAggregates = rb_ary_new3(3, cConfigGroup, cConfigArray, cConfigList); + aConfigSettings = rb_ary_plus(aConfigScalars, aConfigAggregates); + + rb_define_const(cConfig, "SCALARS", aConfigScalars); + rb_define_const(cConfig, "AGGREGATES", aConfigAggregates); + rb_define_const(cConfig, "SETTINGS", aConfigSettings); + + char* settingNameRegexp = "^[A-Za-z*][A-Za-z\\-_*]*$"; + rSettingNameRegexp = rb_reg_new(settingNameRegexp, strlen(settingNameRegexp), 0); + + eConfigParseError = rb_define_class("ConfigParseError", rb_eException); + eSettingNotFoundError = rb_define_class("SettingNotFoundError", rb_eException); + eSettingFormatError = rb_define_class("SettingFormatError", rb_eException); + eSettingNameError = rb_define_class("SettingNameError", rb_eException); +} -- cgit v1.2.3