aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 22:56:23 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 22:56:23 +0000
commit429e46051dba814e7d6c74368eb1bba550222cbe (patch)
treeed1dd43cd23c69f156aae2165006a16a66262cef /lib
parent58bf1382be0cbcf3f9649286fd2719b789a1595f (diff)
downloadlibconfig-429e46051dba814e7d6c74368eb1bba550222cbe.tar.gz
Imported Upstream version 1.4.8upstream/1.4.8
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am80
-rw-r--r--lib/Makefile.in793
-rw-r--r--lib/grammar.c2001
-rw-r--r--lib/grammar.h113
-rw-r--r--lib/grammar.y395
-rw-r--r--lib/libconfig++.pc.in14
-rw-r--r--lib/libconfig++.vcproj237
-rw-r--r--lib/libconfig.c1616
-rw-r--r--lib/libconfig.h321
-rw-r--r--lib/libconfig.h++459
-rw-r--r--lib/libconfig.hh23
-rw-r--r--lib/libconfig.pc.in14
-rw-r--r--lib/libconfig.vcproj224
-rw-r--r--lib/libconfigcpp.c++1167
-rw-r--r--lib/libconfigcpp.cc23
-rw-r--r--lib/parsectx.h48
-rw-r--r--lib/scanctx.c171
-rw-r--r--lib/scanctx.h62
-rw-r--r--lib/scanner.c2362
-rw-r--r--lib/scanner.h326
-rw-r--r--lib/scanner.l190
-rw-r--r--lib/strbuf.c58
-rw-r--r--lib/strbuf.h40
-rw-r--r--lib/wincompat.h90
24 files changed, 10827 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..240c519
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,80 @@
+
+lib_LTLIBRARIES = libconfig.la
+
+if BUILDCXX
+lib_LTLIBRARIES += libconfig++.la
+endif
+
+# Versioning rules ( C:R:A )
+#
+# Perform EACH step that applies.
+#
+# 1. Start with version 0:0:0.
+# 2. If any of the sources have changed, increment R. This is a new revision
+# of the current interface.
+# 3. If the interface has changed, increment C and set R to 0. This is the
+# first revision of a new interface.
+# 4. If the new interface is a superset of the previous interface
+# (that is, if the previous interface has not been broken by the
+# changes in this new release), increment A. This release is backwards
+# compatible with the previous release.
+# 5. If the new interface has removed elements with respect to the
+# previous interface, then backward compatibility is broken; set A to 0.
+# This release has a new, but backwards incompatible interface.
+#
+# For more info see section 6.3 of the GNU Libtool Manual.
+
+VERINFO = -version-info 10:2:1
+
+PARSER_PREFIX = libconfig_yy
+
+libconfig_la_LDFLAGS = $(VERINFO) -no-undefined
+
+libconfig___la_LDFLAGS = $(VERINFO) -no-undefined
+
+libsrc = libconfig.c scanner.l grammar.y parsectx.h wincompat.h \
+ scanctx.c scanctx.h strbuf.c strbuf.h
+libinc = libconfig.h
+
+libsrc_cpp = $(libsrc) libconfigcpp.c++
+libinc_cpp = libconfig.h++
+
+BUILT_SOURCES = scanner.c scanner.h grammar.c grammar.h
+
+libconfig_la_SOURCES = $(libsrc)
+
+libconfig___la_SOURCES = $(libsrc_cpp)
+
+libcppflags = -D_REENTRANT
+libcppxxflags = -D_REENTRANT
+
+if GNU_WIN
+libcppflags += -DLIBCONFIG_EXPORTS
+libcppxxflags += -DLIBCONFIGXX_EXPORTS -DLIBCONFIG_STATIC
+endif
+
+libconfig_la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppflags)
+libconfig___la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppxxflags)
+
+include_HEADERS = $(libinc)
+
+if BUILDCXX
+include_HEADERS += $(libinc_cpp)
+endif
+
+AM_YFLAGS = -d -p $(PARSER_PREFIX)
+
+AM_LFLAGS = --header-file=scanner.h --prefix=$(PARSER_PREFIX)
+
+EXTRA_DIST = \
+ $(BUILT_SOURCES) \
+ libconfigcpp.cc libconfig.hh \
+ *.vcproj
+
+pkgconfigdir = $(libdir)/pkgconfig
+
+pkgconfig_DATA = libconfig.pc
+
+if BUILDCXX
+pkgconfig_DATA += libconfig++.pc
+endif
diff --git a/lib/Makefile.in b/lib/Makefile.in
new file mode 100644
index 0000000..059644c
--- /dev/null
+++ b/lib/Makefile.in
@@ -0,0 +1,793 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@BUILDCXX_TRUE@am__append_1 = libconfig++.la
+@GNU_WIN_TRUE@am__append_2 = -DLIBCONFIG_EXPORTS
+@GNU_WIN_TRUE@am__append_3 = -DLIBCONFIGXX_EXPORTS -DLIBCONFIG_STATIC
+@BUILDCXX_TRUE@am__append_4 = $(libinc_cpp)
+@BUILDCXX_TRUE@am__append_5 = libconfig++.pc
+subdir = lib
+DIST_COMMON = $(am__include_HEADERS_DIST) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/libconfig++.pc.in \
+ $(srcdir)/libconfig.pc.in grammar.c grammar.h scanner.c
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/aux-build/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/ac_config.h
+CONFIG_CLEAN_FILES = libconfig.pc libconfig++.pc
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \
+ "$(DESTDIR)$(includedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libconfig___la_LIBADD =
+am__objects_1 = libconfig___la-libconfig.lo libconfig___la-scanner.lo \
+ libconfig___la-grammar.lo libconfig___la-scanctx.lo \
+ libconfig___la-strbuf.lo
+am__objects_2 = $(am__objects_1) libconfig___la-libconfigcpp.lo
+am_libconfig___la_OBJECTS = $(am__objects_2)
+libconfig___la_OBJECTS = $(am_libconfig___la_OBJECTS)
+libconfig___la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(libconfig___la_LDFLAGS) $(LDFLAGS) -o $@
+@BUILDCXX_TRUE@am_libconfig___la_rpath = -rpath $(libdir)
+libconfig_la_LIBADD =
+am__objects_3 = libconfig_la-libconfig.lo libconfig_la-scanner.lo \
+ libconfig_la-grammar.lo libconfig_la-scanctx.lo \
+ libconfig_la-strbuf.lo
+am_libconfig_la_OBJECTS = $(am__objects_3)
+libconfig_la_OBJECTS = $(am_libconfig_la_OBJECTS)
+libconfig_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libconfig_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/aux-build/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+LTLEXCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS)
+YLWRAP = $(top_srcdir)/aux-build/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS)
+SOURCES = $(libconfig___la_SOURCES) $(libconfig_la_SOURCES)
+DIST_SOURCES = $(libconfig___la_SOURCES) $(libconfig_la_SOURCES)
+DATA = $(pkgconfig_DATA)
+am__include_HEADERS_DIST = libconfig.h libconfig.h++
+HEADERS = $(include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+lib_LTLIBRARIES = libconfig.la $(am__append_1)
+
+# Versioning rules ( C:R:A )
+#
+# Perform EACH step that applies.
+#
+# 1. Start with version 0:0:0.
+# 2. If any of the sources have changed, increment R. This is a new revision
+# of the current interface.
+# 3. If the interface has changed, increment C and set R to 0. This is the
+# first revision of a new interface.
+# 4. If the new interface is a superset of the previous interface
+# (that is, if the previous interface has not been broken by the
+# changes in this new release), increment A. This release is backwards
+# compatible with the previous release.
+# 5. If the new interface has removed elements with respect to the
+# previous interface, then backward compatibility is broken; set A to 0.
+# This release has a new, but backwards incompatible interface.
+#
+# For more info see section 6.3 of the GNU Libtool Manual.
+VERINFO = -version-info 10:2:1
+PARSER_PREFIX = libconfig_yy
+libconfig_la_LDFLAGS = $(VERINFO) -no-undefined
+libconfig___la_LDFLAGS = $(VERINFO) -no-undefined
+libsrc = libconfig.c scanner.l grammar.y parsectx.h wincompat.h \
+ scanctx.c scanctx.h strbuf.c strbuf.h
+
+libinc = libconfig.h
+libsrc_cpp = $(libsrc) libconfigcpp.c++
+libinc_cpp = libconfig.h++
+BUILT_SOURCES = scanner.c scanner.h grammar.c grammar.h
+libconfig_la_SOURCES = $(libsrc)
+libconfig___la_SOURCES = $(libsrc_cpp)
+libcppflags = -D_REENTRANT $(am__append_2)
+libcppxxflags = -D_REENTRANT $(am__append_3)
+libconfig_la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppflags)
+libconfig___la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppxxflags)
+include_HEADERS = $(libinc) $(am__append_4)
+AM_YFLAGS = -d -p $(PARSER_PREFIX)
+AM_LFLAGS = --header-file=scanner.h --prefix=$(PARSER_PREFIX)
+EXTRA_DIST = \
+ $(BUILT_SOURCES) \
+ libconfigcpp.cc libconfig.hh \
+ *.vcproj
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libconfig.pc $(am__append_5)
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .c++ .l .lo .o .obj .y
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu lib/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+libconfig.pc: $(top_builddir)/config.status $(srcdir)/libconfig.pc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+libconfig++.pc: $(top_builddir)/config.status $(srcdir)/libconfig++.pc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+grammar.h: grammar.c
+ @if test ! -f $@; then \
+ rm -f grammar.c; \
+ $(MAKE) $(AM_MAKEFLAGS) grammar.c; \
+ else :; fi
+libconfig++.la: $(libconfig___la_OBJECTS) $(libconfig___la_DEPENDENCIES)
+ $(libconfig___la_LINK) $(am_libconfig___la_rpath) $(libconfig___la_OBJECTS) $(libconfig___la_LIBADD) $(LIBS)
+libconfig.la: $(libconfig_la_OBJECTS) $(libconfig_la_DEPENDENCIES)
+ $(libconfig_la_LINK) -rpath $(libdir) $(libconfig_la_OBJECTS) $(libconfig_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-grammar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-libconfig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-libconfigcpp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-scanctx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-scanner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-strbuf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-grammar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-libconfig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-scanctx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-scanner.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-strbuf.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+libconfig___la-libconfig.lo: libconfig.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-libconfig.lo -MD -MP -MF $(DEPDIR)/libconfig___la-libconfig.Tpo -c -o libconfig___la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-libconfig.Tpo $(DEPDIR)/libconfig___la-libconfig.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libconfig.c' object='libconfig___la-libconfig.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c
+
+libconfig___la-scanner.lo: scanner.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-scanner.lo -MD -MP -MF $(DEPDIR)/libconfig___la-scanner.Tpo -c -o libconfig___la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-scanner.Tpo $(DEPDIR)/libconfig___la-scanner.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanner.c' object='libconfig___la-scanner.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c
+
+libconfig___la-grammar.lo: grammar.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-grammar.lo -MD -MP -MF $(DEPDIR)/libconfig___la-grammar.Tpo -c -o libconfig___la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-grammar.Tpo $(DEPDIR)/libconfig___la-grammar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='grammar.c' object='libconfig___la-grammar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c
+
+libconfig___la-scanctx.lo: scanctx.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-scanctx.lo -MD -MP -MF $(DEPDIR)/libconfig___la-scanctx.Tpo -c -o libconfig___la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-scanctx.Tpo $(DEPDIR)/libconfig___la-scanctx.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanctx.c' object='libconfig___la-scanctx.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c
+
+libconfig___la-strbuf.lo: strbuf.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-strbuf.lo -MD -MP -MF $(DEPDIR)/libconfig___la-strbuf.Tpo -c -o libconfig___la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-strbuf.Tpo $(DEPDIR)/libconfig___la-strbuf.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strbuf.c' object='libconfig___la-strbuf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c
+
+libconfig_la-libconfig.lo: libconfig.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-libconfig.lo -MD -MP -MF $(DEPDIR)/libconfig_la-libconfig.Tpo -c -o libconfig_la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-libconfig.Tpo $(DEPDIR)/libconfig_la-libconfig.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libconfig.c' object='libconfig_la-libconfig.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c
+
+libconfig_la-scanner.lo: scanner.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-scanner.lo -MD -MP -MF $(DEPDIR)/libconfig_la-scanner.Tpo -c -o libconfig_la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-scanner.Tpo $(DEPDIR)/libconfig_la-scanner.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanner.c' object='libconfig_la-scanner.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c
+
+libconfig_la-grammar.lo: grammar.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-grammar.lo -MD -MP -MF $(DEPDIR)/libconfig_la-grammar.Tpo -c -o libconfig_la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-grammar.Tpo $(DEPDIR)/libconfig_la-grammar.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='grammar.c' object='libconfig_la-grammar.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c
+
+libconfig_la-scanctx.lo: scanctx.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-scanctx.lo -MD -MP -MF $(DEPDIR)/libconfig_la-scanctx.Tpo -c -o libconfig_la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-scanctx.Tpo $(DEPDIR)/libconfig_la-scanctx.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanctx.c' object='libconfig_la-scanctx.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c
+
+libconfig_la-strbuf.lo: strbuf.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-strbuf.lo -MD -MP -MF $(DEPDIR)/libconfig_la-strbuf.Tpo -c -o libconfig_la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-strbuf.Tpo $(DEPDIR)/libconfig_la-strbuf.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strbuf.c' object='libconfig_la-strbuf.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c
+
+.c++.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.c++.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c++.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+libconfig___la-libconfigcpp.lo: libconfigcpp.c++
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libconfig___la-libconfigcpp.lo -MD -MP -MF $(DEPDIR)/libconfig___la-libconfigcpp.Tpo -c -o libconfig___la-libconfigcpp.lo `test -f 'libconfigcpp.c++' || echo '$(srcdir)/'`libconfigcpp.c++
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-libconfigcpp.Tpo $(DEPDIR)/libconfig___la-libconfigcpp.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='libconfigcpp.c++' object='libconfig___la-libconfigcpp.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libconfig___la-libconfigcpp.lo `test -f 'libconfigcpp.c++' || echo '$(srcdir)/'`libconfigcpp.c++
+
+.l.c:
+ $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.y.c:
+ $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pkgconfigDATA: $(pkgconfig_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+ done
+
+uninstall-pkgconfigDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+ @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
+ done
+
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(includedir)" && rm -f $$files
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -rm -f grammar.c
+ -rm -f grammar.h
+ -rm -f scanner.c
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-includeHEADERS install-pkgconfigDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
+ uninstall-pkgconfigDATA
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-includeHEADERS install-info \
+ install-info-am install-libLTLIBRARIES install-man install-pdf \
+ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-includeHEADERS uninstall-libLTLIBRARIES \
+ uninstall-pkgconfigDATA
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/lib/grammar.c b/lib/grammar.c
new file mode 100644
index 0000000..e95a569
--- /dev/null
+++ b/lib/grammar.c
@@ -0,0 +1,2001 @@
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "2.4.1"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 1
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+/* Substitute the variable and function names. */
+#define yyparse libconfig_yyparse
+#define yylex libconfig_yylex
+#define yyerror libconfig_yyerror
+#define yylval libconfig_yylval
+#define yychar libconfig_yychar
+#define yydebug libconfig_yydebug
+#define yynerrs libconfig_yynerrs
+
+
+/* Copy the first part of user declarations. */
+
+/* Line 189 of yacc.c */
+#line 32 "grammar.y"
+
+#include <string.h>
+#include <stdlib.h>
+#include "libconfig.h"
+#ifdef WIN32
+#include "wincompat.h"
+
+/* prevent warnings about redefined malloc/free in generated code: */
+#ifndef _STDLIB_H
+#define _STDLIB_H
+#endif
+
+#include <malloc.h>
+#endif
+#include "parsectx.h"
+#include "scanctx.h"
+
+/* these delcarations are provided to suppress compiler warnings */
+extern int libconfig_yylex();
+extern int libconfig_yyget_lineno();
+
+static const char *err_array_elem_type = "mismatched element type in array";
+static const char *err_duplicate_setting = "duplicate setting name";
+
+#define _delete(P) free((void *)(P))
+
+#define IN_ARRAY() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
+
+#define IN_LIST() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST))
+
+static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
+ config_setting_t *setting)
+{
+ setting->line = (unsigned int)libconfig_yyget_lineno(scanner);
+ setting->file = scanctx_current_filename(scan_ctx);
+}
+
+#define CAPTURE_PARSE_POS(S) \
+ capture_parse_pos(scanner, scan_ctx, (S))
+
+void libconfig_yyerror(void *scanner, struct parse_context *ctx,
+ struct scan_context *scan_ctx, char const *s)
+{
+ if(ctx->config->error_text) return;
+ ctx->config->error_line = libconfig_yyget_lineno(scanner);
+ ctx->config->error_text = s;
+}
+
+
+
+/* Line 189 of yacc.c */
+#line 134 "grammar.c"
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* Enabling the token table. */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TOK_BOOLEAN = 258,
+ TOK_INTEGER = 259,
+ TOK_HEX = 260,
+ TOK_INTEGER64 = 261,
+ TOK_HEX64 = 262,
+ TOK_FLOAT = 263,
+ TOK_STRING = 264,
+ TOK_NAME = 265,
+ TOK_EQUALS = 266,
+ TOK_NEWLINE = 267,
+ TOK_ARRAY_START = 268,
+ TOK_ARRAY_END = 269,
+ TOK_LIST_START = 270,
+ TOK_LIST_END = 271,
+ TOK_COMMA = 272,
+ TOK_GROUP_START = 273,
+ TOK_GROUP_END = 274,
+ TOK_SEMICOLON = 275,
+ TOK_GARBAGE = 276,
+ TOK_ERROR = 277
+ };
+#endif
+/* Tokens. */
+#define TOK_BOOLEAN 258
+#define TOK_INTEGER 259
+#define TOK_HEX 260
+#define TOK_INTEGER64 261
+#define TOK_HEX64 262
+#define TOK_FLOAT 263
+#define TOK_STRING 264
+#define TOK_NAME 265
+#define TOK_EQUALS 266
+#define TOK_NEWLINE 267
+#define TOK_ARRAY_START 268
+#define TOK_ARRAY_END 269
+#define TOK_LIST_START 270
+#define TOK_LIST_END 271
+#define TOK_COMMA 272
+#define TOK_GROUP_START 273
+#define TOK_GROUP_END 274
+#define TOK_SEMICOLON 275
+#define TOK_GARBAGE 276
+#define TOK_ERROR 277
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 214 of yacc.c */
+#line 85 "grammar.y"
+
+ int ival;
+ long long llval;
+ double fval;
+ char *sval;
+
+
+
+/* Line 214 of yacc.c */
+#line 223 "grammar.c"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 264 of yacc.c */
+#line 235 "grammar.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(msgid) dgettext ("bison-runtime", msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int yyi)
+#else
+static int
+YYID (yyi)
+ int yyi;
+#endif
+{
+ return yyi;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined _STDLIB_H \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef _STDLIB_H
+# define _STDLIB_H 1
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 6
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 35
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 23
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 20
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 39
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 47
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 277
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const yytype_uint8 yyprhs[] =
+{
+ 0, 0, 3, 4, 6, 8, 11, 12, 14, 15,
+ 17, 19, 20, 26, 27, 32, 33, 38, 40, 42,
+ 44, 46, 48, 51, 53, 55, 57, 59, 61, 63,
+ 65, 67, 71, 72, 74, 76, 80, 81, 83, 84
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 24, 0, -1, -1, 25, -1, 28, -1, 25, 28,
+ -1, -1, 25, -1, -1, 20, -1, 17, -1, -1,
+ 10, 29, 11, 34, 27, -1, -1, 13, 31, 40,
+ 14, -1, -1, 15, 33, 38, 16, -1, 36, -1,
+ 30, -1, 32, -1, 41, -1, 9, -1, 35, 9,
+ -1, 3, -1, 4, -1, 6, -1, 5, -1, 7,
+ -1, 8, -1, 35, -1, 34, -1, 37, 17, 34,
+ -1, -1, 37, -1, 36, -1, 39, 17, 36, -1,
+ -1, 39, -1, -1, 18, 42, 26, 19, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 100, 100, 102, 106, 107, 110, 112, 115, 117,
+ 118, 123, 122, 142, 141, 165, 164, 187, 188, 189,
+ 190, 194, 195, 199, 219, 241, 263, 285, 307, 325,
+ 353, 354, 357, 359, 363, 364, 367, 369, 374, 373
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_HEX",
+ "TOK_INTEGER64", "TOK_HEX64", "TOK_FLOAT", "TOK_STRING", "TOK_NAME",
+ "TOK_EQUALS", "TOK_NEWLINE", "TOK_ARRAY_START", "TOK_ARRAY_END",
+ "TOK_LIST_START", "TOK_LIST_END", "TOK_COMMA", "TOK_GROUP_START",
+ "TOK_GROUP_END", "TOK_SEMICOLON", "TOK_GARBAGE", "TOK_ERROR", "$accept",
+ "configuration", "setting_list", "setting_list_optional",
+ "setting_terminator", "setting", "$@1", "array", "$@2", "list", "$@3",
+ "value", "string", "simple_value", "value_list", "value_list_optional",
+ "simple_value_list", "simple_value_list_optional", "group", "$@4", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 23, 24, 24, 25, 25, 26, 26, 27, 27,
+ 27, 29, 28, 31, 30, 33, 32, 34, 34, 34,
+ 34, 35, 35, 36, 36, 36, 36, 36, 36, 36,
+ 37, 37, 38, 38, 39, 39, 40, 40, 42, 41
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 0, 1, 1, 2, 0, 1, 0, 1,
+ 1, 0, 5, 0, 4, 0, 4, 1, 1, 1,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 3, 0, 1, 1, 3, 0, 1, 0, 4
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 2, 11, 0, 3, 4, 0, 1, 5, 0, 23,
+ 24, 26, 25, 27, 28, 21, 13, 15, 38, 18,
+ 19, 8, 29, 17, 20, 36, 32, 6, 10, 9,
+ 12, 22, 34, 37, 0, 30, 33, 0, 7, 0,
+ 0, 14, 0, 16, 39, 35, 31
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 2, 3, 39, 30, 4, 5, 19, 25, 20,
+ 26, 21, 22, 23, 36, 37, 33, 34, 24, 27
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -26
+static const yytype_int8 yypact[] =
+{
+ -8, -26, 12, -8, -26, 5, -26, -26, 0, -26,
+ -26, -26, -26, -26, -26, -26, -26, -26, -26, -26,
+ -26, -6, 10, -26, -26, 23, 0, -8, -26, -26,
+ -26, -26, -26, 3, 7, -26, 6, 8, -8, 14,
+ 23, -26, 0, -26, -26, -26, -26
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -26, -26, -5, -26, -26, -3, -26, -26, -26, -26,
+ -26, -25, -26, -15, -26, -26, -26, -26, -26, -26
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -1
+static const yytype_uint8 yytable[] =
+{
+ 7, 35, 1, 9, 10, 11, 12, 13, 14, 15,
+ 32, 28, 6, 16, 29, 17, 8, 46, 18, 31,
+ 40, 41, 38, 42, 43, 45, 9, 10, 11, 12,
+ 13, 14, 15, 44, 0, 7
+};
+
+static const yytype_int8 yycheck[] =
+{
+ 3, 26, 10, 3, 4, 5, 6, 7, 8, 9,
+ 25, 17, 0, 13, 20, 15, 11, 42, 18, 9,
+ 17, 14, 27, 17, 16, 40, 3, 4, 5, 6,
+ 7, 8, 9, 19, -1, 38
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 10, 24, 25, 28, 29, 0, 28, 11, 3,
+ 4, 5, 6, 7, 8, 9, 13, 15, 18, 30,
+ 32, 34, 35, 36, 41, 31, 33, 42, 17, 20,
+ 27, 9, 36, 39, 40, 34, 37, 38, 25, 26,
+ 17, 14, 17, 16, 19, 36, 34
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+
+#define YYFAIL goto yyerrlab
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ yytoken = YYTRANSLATE (yychar); \
+ YYPOPSTACK (1); \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (scanner, ctx, scan_ctx, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (YYID (N)) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (YYID (0))
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (&yylval, YYLEX_PARAM)
+#else
+# define YYLEX yylex (&yylval, scanner)
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value, scanner, ctx, scan_ctx); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+ void *scanner;
+ struct parse_context *ctx;
+ struct scan_context *scan_ctx;
+#endif
+{
+ if (!yyvaluep)
+ return;
+ YYUSE (scanner);
+ YYUSE (ctx);
+ YYUSE (scan_ctx);
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+ YYUSE (yyoutput);
+# endif
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+ void *scanner;
+ struct parse_context *ctx;
+ struct scan_context *scan_ctx;
+#endif
+{
+ if (yytype < YYNTOKENS)
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx);
+ YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
+#else
+static void
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule, scanner, ctx, scan_ctx)
+ YYSTYPE *yyvsp;
+ int yyrule;
+ void *scanner;
+ struct parse_context *ctx;
+ struct scan_context *scan_ctx;
+#endif
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ , scanner, ctx, scan_ctx);
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule, scanner, ctx, scan_ctx); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+ const char *yystr;
+#endif
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+#endif
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+ YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ including the terminating null byte. If YYRESULT is null, do not
+ copy anything; just return the number of bytes that would be
+ copied. As a special case, return 0 if an ordinary "syntax error"
+ message will do. Return YYSIZE_MAXIMUM if overflow occurs during
+ size calculation. */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
+{
+ int yyn = yypact[yystate];
+
+ if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+ return 0;
+ else
+ {
+ int yytype = YYTRANSLATE (yychar);
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize = yysize0;
+ YYSIZE_T yysize1;
+ int yysize_overflow = 0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ int yyx;
+
+# if 0
+ /* This is so xgettext sees the translatable formats that are
+ constructed on the fly. */
+ YY_("syntax error, unexpected %s");
+ YY_("syntax error, unexpected %s, expecting %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+ char *yyfmt;
+ char const *yyf;
+ static char const yyunexpected[] = "syntax error, unexpected %s";
+ static char const yyexpecting[] = ", expecting %s";
+ static char const yyor[] = " or %s";
+ char yyformat[sizeof yyunexpected
+ + sizeof yyexpecting - 1
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+ * (sizeof yyor - 1))];
+ char const *yyprefix = yyexpecting;
+
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yycount = 1;
+
+ yyarg[0] = yytname[yytype];
+ yyfmt = yystpcpy (yyformat, yyunexpected);
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ yyformat[sizeof yyunexpected - 1] = '\0';
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+ yyfmt = yystpcpy (yyfmt, yyprefix);
+ yyprefix = yyor;
+ }
+
+ yyf = YY_(yyformat);
+ yysize1 = yysize + yystrlen (yyf);
+ yysize_overflow |= (yysize1 < yysize);
+ yysize = yysize1;
+
+ if (yysize_overflow)
+ return YYSIZE_MAXIMUM;
+
+ if (yyresult)
+ {
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ char *yyp = yyresult;
+ int yyi = 0;
+ while ((*yyp = *yyf) != '\0')
+ {
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyf += 2;
+ }
+ else
+ {
+ yyp++;
+ yyf++;
+ }
+ }
+ }
+ return yysize;
+ }
+}
+#endif /* YYERROR_VERBOSE */
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep, scanner, ctx, scan_ctx)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+ void *scanner;
+ struct parse_context *ctx;
+ struct scan_context *scan_ctx;
+#endif
+{
+ YYUSE (yyvaluep);
+ YYUSE (scanner);
+ YYUSE (ctx);
+ YYUSE (scan_ctx);
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+/* Prevent warnings from -Wmissing-prototypes. */
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+
+
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+ || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
+#else
+int
+yyparse (scanner, ctx, scan_ctx)
+ void *scanner;
+ struct parse_context *ctx;
+ struct scan_context *scan_ctx;
+#endif
+#endif
+{
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+ /* Number of syntax errors so far. */
+ int yynerrs;
+
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yyn == YYPACT_NINF)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+
+ yystate = yyn;
+ *++yyvsp = yylval;
+
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 11:
+
+/* Line 1455 of yacc.c */
+#line 123 "grammar.y"
+ {
+ ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE);
+
+ if(ctx->setting == NULL)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(ctx->setting);
+ }
+ }
+ break;
+
+ case 13:
+
+/* Line 1455 of yacc.c */
+#line 142 "grammar.y"
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_ARRAY);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_ARRAY;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ break;
+
+ case 14:
+
+/* Line 1455 of yacc.c */
+#line 157 "grammar.y"
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ break;
+
+ case 15:
+
+/* Line 1455 of yacc.c */
+#line 165 "grammar.y"
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_LIST);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_LIST;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ break;
+
+ case 16:
+
+/* Line 1455 of yacc.c */
+#line 180 "grammar.y"
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ break;
+
+ case 21:
+
+/* Line 1455 of yacc.c */
+#line 194 "grammar.y"
+ { parsectx_append_string(ctx, (yyvsp[(1) - (1)].sval)); free((yyvsp[(1) - (1)].sval)); }
+ break;
+
+ case 22:
+
+/* Line 1455 of yacc.c */
+#line 195 "grammar.y"
+ { parsectx_append_string(ctx, (yyvsp[(2) - (2)].sval)); free((yyvsp[(2) - (2)].sval)); }
+ break;
+
+ case 23:
+
+/* Line 1455 of yacc.c */
+#line 200 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1,
+ (int)(yyvsp[(1) - (1)].ival));
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_bool(ctx->setting, (int)(yyvsp[(1) - (1)].ival));
+ }
+ break;
+
+ case 24:
+
+/* Line 1455 of yacc.c */
+#line 220 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival));
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int(ctx->setting, (yyvsp[(1) - (1)].ival));
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
+ }
+ }
+ break;
+
+ case 25:
+
+/* Line 1455 of yacc.c */
+#line 242 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval));
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int64(ctx->setting, (yyvsp[(1) - (1)].llval));
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
+ }
+ }
+ break;
+
+ case 26:
+
+/* Line 1455 of yacc.c */
+#line 264 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival));
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_HEX);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int(ctx->setting, (yyvsp[(1) - (1)].ival));
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
+ }
+ }
+ break;
+
+ case 27:
+
+/* Line 1455 of yacc.c */
+#line 286 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval));
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_HEX);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int64(ctx->setting, (yyvsp[(1) - (1)].llval));
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
+ }
+ }
+ break;
+
+ case 28:
+
+/* Line 1455 of yacc.c */
+#line 308 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, (yyvsp[(1) - (1)].fval));
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_float(ctx->setting, (yyvsp[(1) - (1)].fval));
+ }
+ break;
+
+ case 29:
+
+/* Line 1455 of yacc.c */
+#line 326 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ const char *s = parsectx_take_string(ctx);
+ config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
+ _delete(s);
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ const char *s = parsectx_take_string(ctx);
+ config_setting_set_string(ctx->setting, s);
+ _delete(s);
+ }
+ }
+ break;
+
+ case 38:
+
+/* Line 1455 of yacc.c */
+#line 374 "grammar.y"
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_GROUP);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_GROUP;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ break;
+
+ case 39:
+
+/* Line 1455 of yacc.c */
+#line 389 "grammar.y"
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ break;
+
+
+
+/* Line 1455 of yacc.c */
+#line 1788 "grammar.c"
+ default: break;
+ }
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (scanner, ctx, scan_ctx, YY_("syntax error"));
+#else
+ {
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+ if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+ {
+ YYSIZE_T yyalloc = 2 * yysize;
+ if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+ yyalloc = YYSTACK_ALLOC_MAXIMUM;
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+ if (yymsg)
+ yymsg_alloc = yyalloc;
+ else
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ }
+ }
+
+ if (0 < yysize && yysize <= yymsg_alloc)
+ {
+ (void) yysyntax_error (yymsg, yystate, yychar);
+ yyerror (scanner, ctx, scan_ctx, yymsg);
+ }
+ else
+ {
+ yyerror (scanner, ctx, scan_ctx, YY_("syntax error"));
+ if (yysize != 0)
+ goto yyexhaustedlab;
+ }
+ }
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval, scanner, ctx, scan_ctx);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (yyn != YYPACT_NINF)
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp, scanner, ctx, scan_ctx);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ *++yyvsp = yylval;
+
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined(yyoverflow) || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (scanner, ctx, scan_ctx, YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval, scanner, ctx, scan_ctx);
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp, scanner, ctx, scan_ctx);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+
+/* Line 1675 of yacc.c */
+#line 395 "grammar.y"
+
+
diff --git a/lib/grammar.h b/lib/grammar.h
new file mode 100644
index 0000000..2ce199d
--- /dev/null
+++ b/lib/grammar.h
@@ -0,0 +1,113 @@
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ TOK_BOOLEAN = 258,
+ TOK_INTEGER = 259,
+ TOK_HEX = 260,
+ TOK_INTEGER64 = 261,
+ TOK_HEX64 = 262,
+ TOK_FLOAT = 263,
+ TOK_STRING = 264,
+ TOK_NAME = 265,
+ TOK_EQUALS = 266,
+ TOK_NEWLINE = 267,
+ TOK_ARRAY_START = 268,
+ TOK_ARRAY_END = 269,
+ TOK_LIST_START = 270,
+ TOK_LIST_END = 271,
+ TOK_COMMA = 272,
+ TOK_GROUP_START = 273,
+ TOK_GROUP_END = 274,
+ TOK_SEMICOLON = 275,
+ TOK_GARBAGE = 276,
+ TOK_ERROR = 277
+ };
+#endif
+/* Tokens. */
+#define TOK_BOOLEAN 258
+#define TOK_INTEGER 259
+#define TOK_HEX 260
+#define TOK_INTEGER64 261
+#define TOK_HEX64 262
+#define TOK_FLOAT 263
+#define TOK_STRING 264
+#define TOK_NAME 265
+#define TOK_EQUALS 266
+#define TOK_NEWLINE 267
+#define TOK_ARRAY_START 268
+#define TOK_ARRAY_END 269
+#define TOK_LIST_START 270
+#define TOK_LIST_END 271
+#define TOK_COMMA 272
+#define TOK_GROUP_START 273
+#define TOK_GROUP_END 274
+#define TOK_SEMICOLON 275
+#define TOK_GARBAGE 276
+#define TOK_ERROR 277
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+{
+
+/* Line 1676 of yacc.c */
+#line 85 "grammar.y"
+
+ int ival;
+ long long llval;
+ double fval;
+ char *sval;
+
+
+
+/* Line 1676 of yacc.c */
+#line 105 "grammar.h"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+
+
diff --git a/lib/grammar.y b/lib/grammar.y
new file mode 100644
index 0000000..f578897
--- /dev/null
+++ b/lib/grammar.y
@@ -0,0 +1,395 @@
+/* -*- mode: C -*- */
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+%defines
+%output="y.tab.c"
+%pure-parser
+%lex-param{void *scanner}
+%parse-param{void *scanner}
+%parse-param{struct parse_context *ctx}
+%parse-param{struct scan_context *scan_ctx}
+
+%{
+#include <string.h>
+#include <stdlib.h>
+#include "libconfig.h"
+#ifdef WIN32
+#include "wincompat.h"
+
+/* prevent warnings about redefined malloc/free in generated code: */
+#ifndef _STDLIB_H
+#define _STDLIB_H
+#endif
+
+#include <malloc.h>
+#endif
+#include "parsectx.h"
+#include "scanctx.h"
+
+/* these delcarations are provided to suppress compiler warnings */
+extern int libconfig_yylex();
+extern int libconfig_yyget_lineno();
+
+static const char *err_array_elem_type = "mismatched element type in array";
+static const char *err_duplicate_setting = "duplicate setting name";
+
+#define _delete(P) free((void *)(P))
+
+#define IN_ARRAY() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
+
+#define IN_LIST() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST))
+
+static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
+ config_setting_t *setting)
+{
+ setting->line = (unsigned int)libconfig_yyget_lineno(scanner);
+ setting->file = scanctx_current_filename(scan_ctx);
+}
+
+#define CAPTURE_PARSE_POS(S) \
+ capture_parse_pos(scanner, scan_ctx, (S))
+
+void libconfig_yyerror(void *scanner, struct parse_context *ctx,
+ struct scan_context *scan_ctx, char const *s)
+{
+ if(ctx->config->error_text) return;
+ ctx->config->error_line = libconfig_yyget_lineno(scanner);
+ ctx->config->error_text = s;
+}
+
+%}
+
+%union
+{
+ int ival;
+ long long llval;
+ double fval;
+ char *sval;
+}
+
+%token <ival> TOK_BOOLEAN TOK_INTEGER TOK_HEX
+%token <llval> TOK_INTEGER64 TOK_HEX64
+%token <fval> TOK_FLOAT
+%token <sval> TOK_STRING TOK_NAME
+%token TOK_EQUALS TOK_NEWLINE TOK_ARRAY_START TOK_ARRAY_END TOK_LIST_START TOK_LIST_END TOK_COMMA TOK_GROUP_START TOK_GROUP_END TOK_SEMICOLON TOK_GARBAGE TOK_ERROR
+
+%%
+
+configuration:
+ /* empty */
+ | setting_list
+ ;
+
+setting_list:
+ setting
+ | setting_list setting
+ ;
+
+setting_list_optional:
+ /* empty */
+ | setting_list
+ ;
+
+setting_terminator:
+ /* empty */
+ | TOK_SEMICOLON
+ | TOK_COMMA
+ ;
+
+setting:
+ TOK_NAME
+ {
+ ctx->setting = config_setting_add(ctx->parent, $1, CONFIG_TYPE_NONE);
+
+ if(ctx->setting == NULL)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(ctx->setting);
+ }
+ }
+
+ TOK_EQUALS value setting_terminator
+ ;
+
+array:
+ TOK_ARRAY_START
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_ARRAY);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_ARRAY;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ simple_value_list_optional
+ TOK_ARRAY_END
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ ;
+
+list:
+ TOK_LIST_START
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_LIST);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_LIST;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ value_list_optional
+ TOK_LIST_END
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ ;
+
+value:
+ simple_value
+ | array
+ | list
+ | group
+ ;
+
+string:
+ TOK_STRING { parsectx_append_string(ctx, $1); free($1); }
+ | string TOK_STRING { parsectx_append_string(ctx, $2); free($2); }
+ ;
+
+simple_value:
+ TOK_BOOLEAN
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1,
+ (int)$1);
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_bool(ctx->setting, (int)$1);
+ }
+ | TOK_INTEGER
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
+ }
+ }
+ | TOK_INTEGER64
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int64(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
+ }
+ }
+ | TOK_HEX
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_HEX);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
+ }
+ }
+ | TOK_HEX64
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_HEX);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int64(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
+ }
+ }
+ | TOK_FLOAT
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_float(ctx->setting, $1);
+ }
+ | string
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ const char *s = parsectx_take_string(ctx);
+ config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
+ _delete(s);
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ const char *s = parsectx_take_string(ctx);
+ config_setting_set_string(ctx->setting, s);
+ _delete(s);
+ }
+ }
+ ;
+
+value_list:
+ value
+ | value_list TOK_COMMA value
+ ;
+
+value_list_optional:
+ /* empty */
+ | value_list
+ ;
+
+simple_value_list:
+ simple_value
+ | simple_value_list TOK_COMMA simple_value
+ ;
+
+simple_value_list_optional:
+ /* empty */
+ | simple_value_list
+ ;
+
+group:
+ TOK_GROUP_START
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_GROUP);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_GROUP;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ setting_list_optional
+ TOK_GROUP_END
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ ;
+
+%%
diff --git a/lib/libconfig++.pc.in b/lib/libconfig++.pc.in
new file mode 100644
index 0000000..2771cc9
--- /dev/null
+++ b/lib/libconfig++.pc.in
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libconfig++
+Description: C++ Configuration File Library
+Version: @VERSION@
+URL: http://www.hyperrealm.com/main.php?s=libconfig
+Requires:
+Conflicts:
+Libs: -L${libdir} -lconfig++
+Libs.private: @LIBS@
+Cflags: -I${includedir}
diff --git a/lib/libconfig++.vcproj b/lib/libconfig++.vcproj
new file mode 100644
index 0000000..98464a7
--- /dev/null
+++ b/lib/libconfig++.vcproj
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libconfig++"
+ ProjectGUID="{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
+ RootNamespace="libconfig_c"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="lib"
+ PreprocessorDefinitions="LIBCONFIGXX_EXPORTS;LIBCONFIG_STATIC;YY_NO_UNISTD_H;YY_USE_CONST;WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)_d.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="lib"
+ PreprocessorDefinitions="LIBCONFIGXX_EXPORTS;LIBCONFIG_STATIC;YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_STDLIB_H"
+ RuntimeLibrary="2"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\grammar.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libconfig.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libconfigcpp.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\scanctx.c"
+ >
+ </File>
+ <File
+ RelativePath=".\scanner.c"
+ >
+ </File>
+ <File
+ RelativePath=".\strbuf.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\ac_config.h"
+ >
+ </File>
+ <File
+ RelativePath=".\grammar.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libconfig.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libconfig.hh"
+ >
+ </File>
+ <File
+ RelativePath=".\parsectx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\scanctx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\scanner.h"
+ >
+ </File>
+ <File
+ RelativePath=".\win32\stdint.h"
+ >
+ </File>
+ <File
+ RelativePath=".\wincompat.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/lib/libconfig.c b/lib/libconfig.c
new file mode 100644
index 0000000..f301c8c
--- /dev/null
+++ b/lib/libconfig.c
@@ -0,0 +1,1616 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "ac_config.h"
+#endif
+
+#include "libconfig.h"
+#include "grammar.h"
+#include "scanner.h"
+#include "scanctx.h"
+#include "parsectx.h"
+#include "wincompat.h"
+
+#include <locale.h>
+
+#ifdef HAVE_XLOCALE_H
+#include <xlocale.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#define PATH_TOKENS ":./"
+#define CHUNK_SIZE 16
+#define FLOAT_PRECISION 10
+
+#define _new(T) (T *)calloc(sizeof(T), 1) /* zeroed */
+#define _delete(P) free((void *)(P))
+
+/* ------------------------------------------------------------------------- */
+
+#ifndef LIBCONFIG_STATIC
+#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__))
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ return(TRUE);
+}
+
+#endif /* WIN32 */
+#endif /* LIBCONFIG_STATIC */
+
+/* ------------------------------------------------------------------------- */
+
+static const char *__io_error = "file I/O error";
+
+static void __config_list_destroy(config_list_t *list);
+static void __config_write_setting(const config_setting_t *setting,
+ FILE *stream, int depth,
+ unsigned short tab_width);
+
+extern int libconfig_yyparse(void *scanner, struct parse_context *ctx,
+ struct scan_context *scan_ctx);
+extern int libconfig_yylex_init_extra(struct scan_context *scan_ctx,
+ yyscan_t *scanner);
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_locale_override(void)
+{
+#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
+ && ! defined(__MINGW32__)
+
+ _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+ setlocale(LC_NUMERIC, "C");
+
+#elif defined(__APPLE__)
+
+ locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL);
+ uselocale(loc);
+
+#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE))
+
+ locale_t loc = newlocale(LC_NUMERIC, "C", NULL);
+ uselocale(loc);
+
+#else
+
+#warning "No way to modify calling thread's locale!"
+
+#endif
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_locale_restore(void)
+{
+#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
+ && ! defined(__MINGW32__)
+
+ _configthreadlocale(_DISABLE_PER_THREAD_LOCALE);
+
+#elif ((defined HAVE_USELOCALE) && (defined HAVE_FREELOCALE))
+
+ locale_t loc = uselocale(LC_GLOBAL_LOCALE);
+ freelocale(loc);
+
+#else
+
+#warning "No way to modify calling thread's locale!"
+
+#endif
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_name_compare(const char *a, const char *b)
+{
+ const char *p, *q;
+
+ for(p = a, q = b; ; p++, q++)
+ {
+ int pd = ((! *p) || strchr(PATH_TOKENS, *p));
+ int qd = ((! *q) || strchr(PATH_TOKENS, *q));
+
+ if(pd && qd)
+ break;
+ else if(pd)
+ return(-1);
+ else if(qd)
+ return(1);
+ else if(*p < *q)
+ return(-1);
+ else if(*p > *q)
+ return(1);
+ }
+
+ return(0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_indent(FILE *stream, int depth, unsigned short w)
+{
+ if(w)
+ fprintf(stream, "%*s", (depth - 1) * w, " ");
+ else
+ {
+ int i;
+ for(i = 0; i < (depth - 1); ++i)
+ fputc('\t', stream);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_write_value(const config_value_t *value, int type,
+ int format, int depth,
+ unsigned short tab_width, FILE *stream)
+{
+ char fbuf[64];
+
+ switch(type)
+ {
+ /* boolean */
+ case CONFIG_TYPE_BOOL:
+ fputs(value->ival ? "true" : "false", stream);
+ break;
+
+ /* int */
+ case CONFIG_TYPE_INT:
+ switch(format)
+ {
+ case CONFIG_FORMAT_HEX:
+ fprintf(stream, "0x%X", value->ival);
+ break;
+
+ case CONFIG_FORMAT_DEFAULT:
+ default:
+ fprintf(stream, "%d", value->ival);
+ break;
+ }
+ break;
+
+ /* 64-bit int */
+ case CONFIG_TYPE_INT64:
+ switch(format)
+ {
+ case CONFIG_FORMAT_HEX:
+ fprintf(stream, "0x" INT64_HEX_FMT "L", value->llval);
+ break;
+
+ case CONFIG_FORMAT_DEFAULT:
+ default:
+ fprintf(stream, INT64_FMT "L", value->llval);
+ break;
+ }
+ break;
+
+ /* float */
+ case CONFIG_TYPE_FLOAT:
+ {
+ char *q;
+
+ snprintf(fbuf, sizeof(fbuf) - 3, "%.*g", FLOAT_PRECISION, value->fval);
+
+ /* check for exponent */
+ q = strchr(fbuf, 'e');
+ if(! q)
+ {
+ /* no exponent */
+ if(! strchr(fbuf, '.')) /* no decimal point */
+ strcat(fbuf, ".0");
+ else
+ {
+ /* has decimal point */
+ char *p;
+
+ for(p = fbuf + strlen(fbuf) - 1; p > fbuf; --p)
+ {
+ if(*p != '0')
+ {
+ *(++p) = '\0';
+ break;
+ }
+ }
+ }
+ }
+
+ fputs(fbuf, stream);
+ break;
+ }
+
+ /* string */
+ case CONFIG_TYPE_STRING:
+ {
+ char *p;
+
+ fputc('\"', stream);
+
+ if(value->sval)
+ {
+ for(p = value->sval; *p; p++)
+ {
+ int c = (int)*p & 0xFF;
+ switch(c)
+ {
+ case '\"':
+ case '\\':
+ fputc('\\', stream);
+ fputc(c, stream);
+ break;
+
+ case '\n':
+ fputs("\\n", stream);
+ break;
+
+ case '\r':
+ fputs("\\r", stream);
+ break;
+
+ case '\f':
+ fputs("\\f", stream);
+ break;
+
+ case '\t':
+ fputs("\\t", stream);
+ break;
+
+ default:
+ if(c >= ' ')
+ fputc(c, stream);
+ else
+ fprintf(stream, "\\x%02X", c);
+ }
+ }
+ }
+ fputc('\"', stream);
+ break;
+ }
+
+ /* list */
+ case CONFIG_TYPE_LIST:
+ {
+ config_list_t *list = value->list;
+
+ fprintf(stream, "( ");
+
+ if(list)
+ {
+ int len = list->length;
+ config_setting_t **s;
+
+ for(s = list->elements; len--; s++)
+ {
+ __config_write_value(&((*s)->value), (*s)->type,
+ config_setting_get_format(*s),
+ depth + 1, tab_width, stream);
+
+ if(len)
+ fputc(',', stream);
+
+ fputc(' ', stream);
+ }
+ }
+
+ fputc(')', stream);
+ break;
+ }
+
+ /* array */
+ case CONFIG_TYPE_ARRAY:
+ {
+ config_list_t *list = value->list;
+
+ fprintf(stream, "[ ");
+
+ if(list)
+ {
+ int len = list->length;
+ config_setting_t **s;
+
+ for(s = list->elements; len--; s++)
+ {
+ __config_write_value(&((*s)->value), (*s)->type,
+ config_setting_get_format(*s),
+ depth + 1, tab_width, stream);
+
+ if(len)
+ fputc(',', stream);
+
+ fputc(' ', stream);
+ }
+ }
+
+ fputc(']', stream);
+ break;
+ }
+
+ /* group */
+ case CONFIG_TYPE_GROUP:
+ {
+ config_list_t *list = value->list;
+
+ if(depth > 0)
+ {
+#ifdef K_AND_R_STYLE /* Horrendous, but many people like it. */
+ fputc(' ', stream);
+#else
+ fputc('\n', stream);
+
+ if(depth > 1)
+ __config_indent(stream, depth, tab_width);
+#endif
+ fprintf(stream, "{\n");
+ }
+
+ if(list)
+ {
+ int len = list->length;
+ config_setting_t **s;
+
+ for(s = list->elements; len--; s++)
+ __config_write_setting(*s, stream, depth + 1, tab_width);
+ }
+
+ if(depth > 1)
+ __config_indent(stream, depth, tab_width);
+
+ if(depth > 0)
+ fputc('}', stream);
+
+ break;
+ }
+
+ default:
+ /* this shouldn't happen, but handle it gracefully... */
+ fputs("???", stream);
+ break;
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_list_add(config_list_t *list, config_setting_t *setting)
+{
+ if((list->length % CHUNK_SIZE) == 0)
+ {
+ list->elements = (config_setting_t **)realloc(
+ list->elements,
+ (list->length + CHUNK_SIZE) * sizeof(config_setting_t *));
+ }
+
+ list->elements[list->length] = setting;
+ list->length++;
+}
+
+/* ------------------------------------------------------------------------- */
+
+static config_setting_t *__config_list_search(config_list_t *list,
+ const char *name,
+ unsigned int *idx)
+{
+ config_setting_t **found = NULL;
+ unsigned int i;
+
+ if(! list)
+ return(NULL);
+
+ for(i = 0, found = list->elements; i < list->length; i++, found++)
+ {
+ if(! (*found)->name)
+ continue;
+
+ if(! __config_name_compare(name, (*found)->name))
+ {
+ if(idx)
+ *idx = i;
+
+ return(*found);
+ }
+ }
+
+ return(NULL);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static config_setting_t *__config_list_remove(config_list_t *list, int idx)
+{
+ config_setting_t *removed = *(list->elements + idx);
+ int offset = (idx * sizeof(config_setting_t *));
+ int len = list->length - 1 - idx;
+ char *base = (char *)list->elements + offset;
+
+ memmove(base, base + sizeof(config_setting_t *),
+ len * sizeof(config_setting_t *));
+
+ list->length--;
+
+ /* possibly realloc smaller? */
+
+ return(removed);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_setting_destroy(config_setting_t *setting)
+{
+ if(setting)
+ {
+ if(setting->name)
+ _delete(setting->name);
+
+ if(setting->type == CONFIG_TYPE_STRING)
+ _delete(setting->value.sval);
+
+ else if((setting->type == CONFIG_TYPE_GROUP)
+ || (setting->type == CONFIG_TYPE_ARRAY)
+ || (setting->type == CONFIG_TYPE_LIST))
+ {
+ if(setting->value.list)
+ __config_list_destroy(setting->value.list);
+ }
+
+ if(setting->hook && setting->config->destructor)
+ setting->config->destructor(setting->hook);
+
+ _delete(setting);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_list_destroy(config_list_t *list)
+{
+ config_setting_t **p;
+ unsigned int i;
+
+ if(! list)
+ return;
+
+ if(list->elements)
+ {
+ for(p = list->elements, i = 0; i < list->length; p++, i++)
+ __config_setting_destroy(*p);
+
+ _delete(list->elements);
+ }
+
+ _delete(list);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_vector_checktype(const config_setting_t *vector, int type)
+{
+ /* if the array is empty, then it has no type yet */
+
+ if(! vector->value.list)
+ return(CONFIG_TRUE);
+
+ if(vector->value.list->length == 0)
+ return(CONFIG_TRUE);
+
+ /* if it's a list, any type is allowed */
+
+ if(vector->type == CONFIG_TYPE_LIST)
+ return(CONFIG_TRUE);
+
+ /* otherwise the first element added determines the type of the array */
+
+ return((vector->value.list->elements[0]->type == type)
+ ? CONFIG_TRUE : CONFIG_FALSE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_validate_name(const char *name)
+{
+ const char *p = name;
+
+ if(*p == '\0')
+ return(CONFIG_FALSE);
+
+ if(! isalpha(*p) && (*p != '*'))
+ return(CONFIG_FALSE);
+
+ for(++p; *p; ++p)
+ {
+ if(! (isalpha(*p) || isdigit(*p) || strchr("*_-", (int)*p)))
+ return(CONFIG_FALSE);
+ }
+
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_read(config_t *config, FILE *stream, const char *filename,
+ const char *str)
+{
+ yyscan_t scanner;
+ struct scan_context scan_ctx;
+ struct parse_context parse_ctx;
+ YY_BUFFER_STATE buffer = NULL;
+ int r;
+
+ /* Reinitialize the config */
+ void (*destructor)(void *) = config->destructor;
+ const char *include_dir = config->include_dir;
+ unsigned short tab_width = config->tab_width;
+ unsigned short flags = config->flags;
+
+ config->include_dir = NULL;
+ config_destroy(config);
+ config_init(config);
+
+ config->destructor = destructor;
+ config->include_dir = include_dir;
+ config->tab_width = tab_width;
+ config->flags = flags;
+
+ parsectx_init(&parse_ctx);
+ parse_ctx.config = config;
+ parse_ctx.parent = config->root;
+ parse_ctx.setting = config->root;
+
+ __config_locale_override();
+
+ scanctx_init(&scan_ctx, filename);
+ scan_ctx.config = config;
+ libconfig_yylex_init_extra(&scan_ctx, &scanner);
+
+ if(stream)
+ libconfig_yyrestart(stream, scanner);
+ else /* read from string */
+ buffer = libconfig_yy_scan_string(str, scanner);
+
+ libconfig_yyset_lineno(1, scanner);
+ r = libconfig_yyparse(scanner, &parse_ctx, &scan_ctx);
+
+ if(r != 0)
+ {
+ YY_BUFFER_STATE buf;
+
+ config->error_file = scanctx_current_filename(&scan_ctx);
+ config->error_type = CONFIG_ERR_PARSE;
+
+ /* Unwind the include stack, freeing the buffers and closing the files. */
+ while((buf = (YY_BUFFER_STATE)scanctx_pop_include(&scan_ctx)) != NULL)
+ libconfig_yy_delete_buffer(buf, scanner);
+ }
+
+ libconfig_yylex_destroy(scanner);
+ config->filenames = scanctx_cleanup(&scan_ctx, &(config->num_filenames));
+ parsectx_cleanup(&parse_ctx);
+
+ __config_locale_restore();
+
+ return(r == 0 ? CONFIG_TRUE : CONFIG_FALSE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_read(config_t *config, FILE *stream)
+{
+ return(__config_read(config, stream, NULL, NULL));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_read_string(config_t *config, const char *str)
+{
+ return(__config_read(config, NULL, NULL, str));
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_write_setting(const config_setting_t *setting,
+ FILE *stream, int depth,
+ unsigned short tab_width)
+{
+ if(depth > 1)
+ __config_indent(stream, depth, tab_width);
+
+ if(setting->name)
+ {
+ fputs(setting->name, stream);
+ fprintf(stream, " %c ", (setting->type == CONFIG_TYPE_GROUP ? ':' : '='));
+ }
+
+ __config_write_value(&(setting->value), setting->type,
+ config_setting_get_format(setting),
+ depth, tab_width, stream);
+
+ if(depth > 0)
+ {
+ fputc(';', stream);
+ fputc('\n', stream);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_write(const config_t *config, FILE *stream)
+{
+ __config_locale_override();
+
+ __config_write_setting(config->root, stream, 0, config->tab_width);
+
+ __config_locale_restore();
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_read_file(config_t *config, const char *filename)
+{
+ int ret;
+ FILE *stream = fopen(filename, "rt");
+ if(! stream)
+ {
+ config->error_text = __io_error;
+ config->error_type = CONFIG_ERR_FILE_IO;
+ return(CONFIG_FALSE);
+ }
+
+ ret = __config_read(config, stream, filename, NULL);
+ fclose(stream);
+
+ return(ret);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_write_file(config_t *config, const char *filename)
+{
+ FILE *f = fopen(filename, "wt");
+ if(! f)
+ {
+ config->error_text = __io_error;
+ config->error_type = CONFIG_ERR_FILE_IO;
+ return(CONFIG_FALSE);
+ }
+
+ config_write(config, f);
+ fclose(f);
+ config->error_type = CONFIG_ERR_NONE;
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_destroy(config_t *config)
+{
+ unsigned int count = config->num_filenames;
+ const char **f;
+
+ __config_setting_destroy(config->root);
+
+ for(f = config->filenames; count > 0; ++f, --count)
+ _delete(*f);
+
+ _delete(config->filenames);
+ _delete(config->include_dir);
+
+ memset((void *)config, 0, sizeof(config_t));
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_init(config_t *config)
+{
+ memset((void *)config, 0, sizeof(config_t));
+
+ config->root = _new(config_setting_t);
+ config->root->type = CONFIG_TYPE_GROUP;
+ config->root->config = config;
+ config->tab_width = 2;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_set_auto_convert(config_t *config, int flag)
+{
+ if(flag)
+ config->flags |= CONFIG_OPTION_AUTOCONVERT;
+ else
+ config->flags &= ~CONFIG_OPTION_AUTOCONVERT;
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_get_auto_convert(const config_t *config)
+{
+ return((config->flags & CONFIG_OPTION_AUTOCONVERT) != 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static config_setting_t *config_setting_create(config_setting_t *parent,
+ const char *name, int type)
+{
+ config_setting_t *setting;
+ config_list_t *list;
+
+ if((parent->type != CONFIG_TYPE_GROUP)
+ && (parent->type != CONFIG_TYPE_ARRAY)
+ && (parent->type != CONFIG_TYPE_LIST))
+ return(NULL);
+
+ setting = _new(config_setting_t);
+ setting->parent = parent;
+ setting->name = (name == NULL) ? NULL : strdup(name);
+ setting->type = type;
+ setting->config = parent->config;
+ setting->hook = NULL;
+ setting->line = 0;
+
+ list = parent->value.list;
+
+ if(! list)
+ list = parent->value.list = _new(config_list_t);
+
+ __config_list_add(list, setting);
+
+ return(setting);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_setting_get_int(const config_setting_t *setting,
+ int *value)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_INT:
+ *value = setting->value.ival;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_INT64:
+ if((setting->value.llval > INT32_MAX)
+ || (setting->value.llval < INT32_MIN))
+ *value = 0;
+ else
+ *value = (int)(setting->value.llval);
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_FLOAT:
+ if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0)
+ {
+ *value = (int)(setting->value.fval);
+ return(CONFIG_TRUE);
+ }
+ else
+ { /* fall through */ }
+
+ default:
+ return(CONFIG_FALSE);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_get_int(const config_setting_t *setting)
+{
+ int value = 0;
+ __config_setting_get_int(setting, &value);
+ return(value);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_setting_get_int64(const config_setting_t *setting,
+ long long *value)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_INT64:
+ *value = setting->value.llval;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_INT:
+ *value = (long long)(setting->value.ival);
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_FLOAT:
+ if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0)
+ {
+ *value = (long long)(setting->value.fval);
+ return(CONFIG_TRUE);
+ }
+ else
+ { /* fall through */ }
+
+ default:
+ return(CONFIG_FALSE);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+long long config_setting_get_int64(const config_setting_t *setting)
+{
+ long long value = 0;
+ __config_setting_get_int64(setting, &value);
+ return(value);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_lookup_int(const config_setting_t *setting,
+ const char *name, int *value)
+{
+ config_setting_t *member = config_setting_get_member(setting, name);
+ if(! member)
+ return(CONFIG_FALSE);
+
+ return(__config_setting_get_int(member, value));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_lookup_int64(const config_setting_t *setting,
+ const char *name, long long *value)
+{
+ config_setting_t *member = config_setting_get_member(setting, name);
+ if(! member)
+ return(CONFIG_FALSE);
+
+ return(__config_setting_get_int64(member, value));
+}
+
+/* ------------------------------------------------------------------------- */
+
+static int __config_setting_get_float(const config_setting_t *setting,
+ double *value)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_FLOAT:
+ *value = setting->value.fval;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_INT:
+ if(config_get_auto_convert(setting->config))
+ {
+ *value = (double)(setting->value.ival);
+ return(CONFIG_TRUE);
+ }
+ else
+ return(CONFIG_FALSE);
+
+ case CONFIG_TYPE_INT64:
+ if(config_get_auto_convert(setting->config))
+ {
+ *value = (double)(setting->value.llval);
+ return(CONFIG_TRUE);
+ }
+ else
+ { /* fall through */ }
+
+ default:
+ return(CONFIG_FALSE);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+double config_setting_get_float(const config_setting_t *setting)
+{
+ double value = 0.0;
+ __config_setting_get_float(setting, &value);
+ return(value);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_lookup_float(const config_setting_t *setting,
+ const char *name, double *value)
+{
+ config_setting_t *member = config_setting_get_member(setting, name);
+ if(! member)
+ return(CONFIG_FALSE);
+
+ return(__config_setting_get_float(member, value));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_lookup_string(const config_setting_t *setting,
+ const char *name, const char **value)
+{
+ config_setting_t *member = config_setting_get_member(setting, name);
+ if(! member)
+ return(CONFIG_FALSE);
+
+ if(config_setting_type(member) != CONFIG_TYPE_STRING)
+ return(CONFIG_FALSE);
+
+ *value = config_setting_get_string(member);
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_lookup_bool(const config_setting_t *setting,
+ const char *name, int *value)
+{
+ config_setting_t *member = config_setting_get_member(setting, name);
+ if(! member)
+ return(CONFIG_FALSE);
+
+ if(config_setting_type(member) != CONFIG_TYPE_BOOL)
+ return(CONFIG_FALSE);
+
+ *value = config_setting_get_bool(member);
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_int(config_setting_t *setting, int value)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_NONE:
+ setting->type = CONFIG_TYPE_INT;
+ /* fall through */
+
+ case CONFIG_TYPE_INT:
+ setting->value.ival = value;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_FLOAT:
+ if(config_get_auto_convert(setting->config))
+ {
+ setting->value.fval = (float)value;
+ return(CONFIG_TRUE);
+ }
+ else
+ return(CONFIG_FALSE);
+
+ default:
+ return(CONFIG_FALSE);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_int64(config_setting_t *setting, long long value)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_NONE:
+ setting->type = CONFIG_TYPE_INT64;
+ /* fall through */
+
+ case CONFIG_TYPE_INT64:
+ setting->value.llval = value;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_INT:
+ if((value > INT32_MAX) || (value < INT32_MIN))
+ setting->value.ival = 0;
+ else
+ setting->value.ival = (int)value;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_FLOAT:
+ if(config_get_auto_convert(setting->config))
+ {
+ setting->value.fval = (float)value;
+ return(CONFIG_TRUE);
+ }
+ else
+ return(CONFIG_FALSE);
+
+ default:
+ return(CONFIG_FALSE);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_float(config_setting_t *setting, double value)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_NONE:
+ setting->type = CONFIG_TYPE_FLOAT;
+ /* fall through */
+
+ case CONFIG_TYPE_FLOAT:
+ setting->value.fval = value;
+ return(CONFIG_TRUE);
+
+ case CONFIG_TYPE_INT:
+ if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0)
+ {
+ setting->value.ival = (int)value;
+ return(CONFIG_TRUE);
+ }
+ else
+ return(CONFIG_FALSE);
+
+ case CONFIG_TYPE_INT64:
+ if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0)
+ {
+ setting->value.llval = (long long)value;
+ return(CONFIG_TRUE);
+ }
+ else
+ return(CONFIG_FALSE);
+
+ default:
+ return(CONFIG_FALSE);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_get_bool(const config_setting_t *setting)
+{
+ return((setting->type == CONFIG_TYPE_BOOL) ? setting->value.ival : 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_bool(config_setting_t *setting, int value)
+{
+ if(setting->type == CONFIG_TYPE_NONE)
+ setting->type = CONFIG_TYPE_BOOL;
+ else if(setting->type != CONFIG_TYPE_BOOL)
+ return(CONFIG_FALSE);
+
+ setting->value.ival = value;
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+const char *config_setting_get_string(const config_setting_t *setting)
+{
+ return((setting->type == CONFIG_TYPE_STRING) ? setting->value.sval : NULL);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_string(config_setting_t *setting, const char *value)
+{
+ if(setting->type == CONFIG_TYPE_NONE)
+ setting->type = CONFIG_TYPE_STRING;
+ else if(setting->type != CONFIG_TYPE_STRING)
+ return(CONFIG_FALSE);
+
+ if(setting->value.sval)
+ _delete(setting->value.sval);
+
+ setting->value.sval = (value == NULL) ? NULL : strdup(value);
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_format(config_setting_t *setting, short format)
+{
+ if(((setting->type != CONFIG_TYPE_INT)
+ && (setting->type != CONFIG_TYPE_INT64))
+ || ((format != CONFIG_FORMAT_DEFAULT) && (format != CONFIG_FORMAT_HEX)))
+ return(CONFIG_FALSE);
+
+ setting->format = format;
+
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+short config_setting_get_format(const config_setting_t *setting)
+{
+ return(setting->format != 0 ? setting->format
+ : setting->config->default_format);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_lookup_from(config_setting_t *setting,
+ const char *path)
+{
+ const char *p = path;
+ config_setting_t *found;
+
+ for(;;)
+ {
+ while(*p && strchr(PATH_TOKENS, *p))
+ p++;
+
+ if(! *p)
+ break;
+
+ if(*p == '[')
+ found = config_setting_get_elem(setting, atoi(++p));
+ else
+ found = config_setting_get_member(setting, p);
+
+ if(! found)
+ break;
+
+ setting = found;
+
+ while(! strchr(PATH_TOKENS, *p))
+ p++;
+ }
+
+ return(*p ? NULL : setting);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_lookup(const config_t *config, const char *path)
+{
+ return(config_lookup_from(config->root, path));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_lookup_string(const config_t *config, const char *path,
+ const char **value)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(CONFIG_FALSE);
+
+ if(config_setting_type(s) != CONFIG_TYPE_STRING)
+ return(CONFIG_FALSE);
+
+ *value = config_setting_get_string(s);
+
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_lookup_int(const config_t *config, const char *path,
+ int *value)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(CONFIG_FALSE);
+
+ return(__config_setting_get_int(s, value));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_lookup_int64(const config_t *config, const char *path,
+ long long *value)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(CONFIG_FALSE);
+
+ return(__config_setting_get_int64(s, value));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_lookup_float(const config_t *config, const char *path,
+ double *value)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(CONFIG_FALSE);
+
+ return(__config_setting_get_float(s, value));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_lookup_bool(const config_t *config, const char *path, int *value)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(CONFIG_FALSE);
+
+ if(config_setting_type(s) != CONFIG_TYPE_BOOL)
+ return(CONFIG_FALSE);
+
+ *value = config_setting_get_bool(s);
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_get_int_elem(const config_setting_t *vector, int idx)
+{
+ const config_setting_t *element = config_setting_get_elem(vector, idx);
+
+ return(element ? config_setting_get_int(element) : 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_set_int_elem(config_setting_t *vector,
+ int idx, int value)
+{
+ config_setting_t *element = NULL;
+
+ if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
+ return(NULL);
+
+ if(idx < 0)
+ {
+ if(! __config_vector_checktype(vector, CONFIG_TYPE_INT))
+ return(NULL);
+
+ element = config_setting_create(vector, NULL, CONFIG_TYPE_INT);
+ }
+ else
+ {
+ element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(NULL);
+ }
+
+ if(! config_setting_set_int(element, value))
+ return(NULL);
+
+ return(element);
+}
+
+/* ------------------------------------------------------------------------- */
+
+long long config_setting_get_int64_elem(const config_setting_t *vector,
+ int idx)
+{
+ const config_setting_t *element = config_setting_get_elem(vector, idx);
+
+ return(element ? config_setting_get_int64(element) : 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_set_int64_elem(config_setting_t *vector,
+ int idx, long long value)
+{
+ config_setting_t *element = NULL;
+
+ if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
+ return(NULL);
+
+ if(idx < 0)
+ {
+ if(! __config_vector_checktype(vector, CONFIG_TYPE_INT64))
+ return(NULL);
+
+ element = config_setting_create(vector, NULL, CONFIG_TYPE_INT64);
+ }
+ else
+ {
+ element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(NULL);
+ }
+
+ if(! config_setting_set_int64(element, value))
+ return(NULL);
+
+ return(element);
+}
+
+/* ------------------------------------------------------------------------- */
+
+double config_setting_get_float_elem(const config_setting_t *vector, int idx)
+{
+ config_setting_t *element = config_setting_get_elem(vector, idx);
+
+ return(element ? config_setting_get_float(element) : 0.0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_set_float_elem(config_setting_t *vector,
+ int idx, double value)
+{
+ config_setting_t *element = NULL;
+
+ if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
+ return(NULL);
+
+ if(idx < 0)
+ {
+ if(! __config_vector_checktype(vector, CONFIG_TYPE_FLOAT))
+ return(NULL);
+
+ element = config_setting_create(vector, NULL, CONFIG_TYPE_FLOAT);
+ }
+ else
+ element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(NULL);
+
+ if(! config_setting_set_float(element, value))
+ return(NULL);
+
+ return(element);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_get_bool_elem(const config_setting_t *vector, int idx)
+{
+ config_setting_t *element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(CONFIG_FALSE);
+
+ if(element->type != CONFIG_TYPE_BOOL)
+ return(CONFIG_FALSE);
+
+ return(element->value.ival);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_set_bool_elem(config_setting_t *vector,
+ int idx, int value)
+{
+ config_setting_t *element = NULL;
+
+ if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
+ return(NULL);
+
+ if(idx < 0)
+ {
+ if(! __config_vector_checktype(vector, CONFIG_TYPE_BOOL))
+ return(NULL);
+
+ element = config_setting_create(vector, NULL, CONFIG_TYPE_BOOL);
+ }
+ else
+ element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(NULL);
+
+ if(! config_setting_set_bool(element, value))
+ return(NULL);
+
+ return(element);
+}
+
+/* ------------------------------------------------------------------------- */
+
+const char *config_setting_get_string_elem(const config_setting_t *vector,
+ int idx)
+{
+ config_setting_t *element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(NULL);
+
+ if(element->type != CONFIG_TYPE_STRING)
+ return(NULL);
+
+ return(element->value.sval);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_set_string_elem(config_setting_t *vector,
+ int idx, const char *value)
+{
+ config_setting_t *element = NULL;
+
+ if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
+ return(NULL);
+
+ if(idx < 0)
+ {
+ if(! __config_vector_checktype(vector, CONFIG_TYPE_STRING))
+ return(NULL);
+
+ element = config_setting_create(vector, NULL, CONFIG_TYPE_STRING);
+ }
+ else
+ element = config_setting_get_elem(vector, idx);
+
+ if(! element)
+ return(NULL);
+
+ if(! config_setting_set_string(element, value))
+ return(NULL);
+
+ return(element);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_get_elem(const config_setting_t *vector,
+ unsigned int idx)
+{
+ config_list_t *list = vector->value.list;
+
+ if(((vector->type != CONFIG_TYPE_ARRAY)
+ && (vector->type != CONFIG_TYPE_LIST)
+ && (vector->type != CONFIG_TYPE_GROUP)) || ! list)
+ return(NULL);
+
+ if(idx >= list->length)
+ return(NULL);
+
+ return(list->elements[idx]);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_get_member(const config_setting_t *setting,
+ const char *name)
+{
+ if(setting->type != CONFIG_TYPE_GROUP)
+ return(NULL);
+
+ return(__config_list_search(setting->value.list, name, NULL));
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_set_destructor(config_t *config, void (*destructor)(void *))
+{
+ config->destructor = destructor;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_set_include_dir(config_t *config, const char *include_dir)
+{
+ _delete(config->include_dir);
+ config->include_dir = strdup(include_dir);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_length(const config_setting_t *setting)
+{
+ if((setting->type != CONFIG_TYPE_GROUP)
+ && (setting->type != CONFIG_TYPE_ARRAY)
+ && (setting->type != CONFIG_TYPE_LIST))
+ return(0);
+
+ if(! setting->value.list)
+ return(0);
+
+ return(setting->value.list->length);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_setting_set_hook(config_setting_t *setting, void *hook)
+{
+ setting->hook = hook;
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_setting_add(config_setting_t *parent,
+ const char *name, int type)
+{
+ if((type < CONFIG_TYPE_NONE) || (type > CONFIG_TYPE_LIST))
+ return(NULL);
+
+ if(! parent)
+ return(NULL);
+
+ if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST))
+ name = NULL;
+
+ if(name)
+ {
+ if(! __config_validate_name(name))
+ return(NULL);
+ }
+
+ if(config_setting_get_member(parent, name) != NULL)
+ return(NULL); /* already exists */
+
+ return(config_setting_create(parent, name, type));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_remove(config_setting_t *parent, const char *name)
+{
+ unsigned int idx;
+ config_setting_t *setting;
+
+ if(! parent)
+ return(CONFIG_FALSE);
+
+ if(parent->type != CONFIG_TYPE_GROUP)
+ return(CONFIG_FALSE);
+
+ if(! (setting = __config_list_search(parent->value.list, name, &idx)))
+ return(CONFIG_FALSE);
+
+ __config_list_remove(parent->value.list, idx);
+ __config_setting_destroy(setting);
+
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_remove_elem(config_setting_t *parent, unsigned int idx)
+{
+ config_list_t *list;
+ config_setting_t *removed = NULL;
+
+ if(! parent)
+ return(CONFIG_FALSE);
+
+ list = parent->value.list;
+
+ if(((parent->type != CONFIG_TYPE_ARRAY)
+ && (parent->type != CONFIG_TYPE_LIST)
+ && (parent->type != CONFIG_TYPE_GROUP)) || ! list)
+ return(CONFIG_FALSE);
+
+ if(idx >= list->length)
+ return(CONFIG_FALSE);
+
+ removed = __config_list_remove(list, idx);
+ __config_setting_destroy(removed);
+
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_index(const config_setting_t *setting)
+{
+ config_setting_t **found = NULL;
+ config_list_t *list;
+ int i;
+
+ if(! setting->parent)
+ return(-1);
+
+ list = setting->parent->value.list;
+
+ for(i = 0, found = list->elements; i < (int)list->length; ++i, ++found)
+ {
+ if(*found == setting)
+ return(i);
+ }
+
+ return(-1);
+}
+
+/* ------------------------------------------------------------------------- */
+/* eof */
diff --git a/lib/libconfig.h b/lib/libconfig.h
new file mode 100644
index 0000000..cc079db
--- /dev/null
+++ b/lib/libconfig.h
@@ -0,0 +1,321 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_h
+#define __libconfig_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+#if defined(LIBCONFIG_STATIC)
+#define LIBCONFIG_API
+#elif defined(LIBCONFIG_EXPORTS)
+#define LIBCONFIG_API __declspec(dllexport)
+#else /* ! LIBCONFIG_EXPORTS */
+#define LIBCONFIG_API __declspec(dllimport)
+#endif /* LIBCONFIG_STATIC */
+#else /* ! WIN32 */
+#define LIBCONFIG_API
+#endif /* WIN32 */
+
+#define LIBCONFIG_VER_MAJOR 1
+#define LIBCONFIG_VER_MINOR 4
+#define LIBCONFIG_VER_REVISION 8
+
+#include <stdio.h>
+
+#define CONFIG_TYPE_NONE 0
+#define CONFIG_TYPE_GROUP 1
+#define CONFIG_TYPE_INT 2
+#define CONFIG_TYPE_INT64 3
+#define CONFIG_TYPE_FLOAT 4
+#define CONFIG_TYPE_STRING 5
+#define CONFIG_TYPE_BOOL 6
+#define CONFIG_TYPE_ARRAY 7
+#define CONFIG_TYPE_LIST 8
+
+#define CONFIG_FORMAT_DEFAULT 0
+#define CONFIG_FORMAT_HEX 1
+
+#define CONFIG_OPTION_AUTOCONVERT 0x01
+
+#define CONFIG_TRUE (1)
+#define CONFIG_FALSE (0)
+
+typedef union config_value_t
+{
+ int ival;
+ long long llval;
+ double fval;
+ char *sval;
+ struct config_list_t *list;
+} config_value_t;
+
+typedef struct config_setting_t
+{
+ char *name;
+ short type;
+ short format;
+ config_value_t value;
+ struct config_setting_t *parent;
+ struct config_t *config;
+ void *hook;
+ unsigned int line;
+ const char *file;
+} config_setting_t;
+
+typedef enum
+{
+ CONFIG_ERR_NONE = 0,
+ CONFIG_ERR_FILE_IO = 1,
+ CONFIG_ERR_PARSE = 2
+} config_error_t;
+
+typedef struct config_list_t
+{
+ unsigned int length;
+ config_setting_t **elements;
+} config_list_t;
+
+typedef struct config_t
+{
+ config_setting_t *root;
+ void (*destructor)(void *);
+ unsigned short flags;
+ unsigned short tab_width;
+ short default_format;
+ const char *include_dir;
+ const char *error_text;
+ const char *error_file;
+ int error_line;
+ config_error_t error_type;
+ const char **filenames;
+ unsigned int num_filenames;
+} config_t;
+
+extern LIBCONFIG_API int config_read(config_t *config, FILE *stream);
+extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream);
+
+extern LIBCONFIG_API void config_set_default_format(config_t *config,
+ short format);
+
+extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int flag);
+extern LIBCONFIG_API int config_get_auto_convert(const config_t *config);
+
+extern LIBCONFIG_API int config_read_string(config_t *config, const char *str);
+
+extern LIBCONFIG_API int config_read_file(config_t *config,
+ const char *filename);
+extern LIBCONFIG_API int config_write_file(config_t *config,
+ const char *filename);
+
+extern LIBCONFIG_API void config_set_destructor(config_t *config,
+ void (*destructor)(void *));
+extern LIBCONFIG_API void config_set_include_dir(config_t *config,
+ const char *include_dir);
+
+extern LIBCONFIG_API void config_init(config_t *config);
+extern LIBCONFIG_API void config_destroy(config_t *config);
+
+extern LIBCONFIG_API int config_setting_get_int(
+ const config_setting_t *setting);
+extern LIBCONFIG_API long long config_setting_get_int64(
+ const config_setting_t *setting);
+extern LIBCONFIG_API double config_setting_get_float(
+ const config_setting_t *setting);
+extern LIBCONFIG_API int config_setting_get_bool(
+ const config_setting_t *setting);
+extern LIBCONFIG_API const char *config_setting_get_string(
+ const config_setting_t *setting);
+
+extern LIBCONFIG_API int config_setting_lookup_int(
+ const config_setting_t *setting, const char *name, int *value);
+extern LIBCONFIG_API int config_setting_lookup_int64(
+ const config_setting_t *setting, const char *name, long long *value);
+extern LIBCONFIG_API int config_setting_lookup_float(
+ const config_setting_t *setting, const char *name, double *value);
+extern LIBCONFIG_API int config_setting_lookup_bool(
+ const config_setting_t *setting, const char *name, int *value);
+extern LIBCONFIG_API int config_setting_lookup_string(
+ const config_setting_t *setting, const char *name, const char **value);
+
+extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting,
+ int value);
+extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting,
+ long long value);
+extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting,
+ double value);
+extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting,
+ int value);
+extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting,
+ const char *value);
+
+extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting,
+ short format);
+extern LIBCONFIG_API short config_setting_get_format(
+ const config_setting_t *setting);
+
+extern LIBCONFIG_API int config_setting_get_int_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API long long config_setting_get_int64_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API double config_setting_get_float_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API int config_setting_get_bool_elem(
+ const config_setting_t *setting, int idx);
+extern LIBCONFIG_API const char *config_setting_get_string_elem(
+ const config_setting_t *setting, int idx);
+
+extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem(
+ config_setting_t *setting, int idx, int value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem(
+ config_setting_t *setting, int idx, long long value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem(
+ config_setting_t *setting, int idx, double value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem(
+ config_setting_t *setting, int idx, int value);
+extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem(
+ config_setting_t *setting, int idx, const char *value);
+
+#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \
+ ((C)->include_dir)
+
+#define /* int */ config_setting_type(/* const config_setting_t * */ S) \
+ ((S)->type)
+
+#define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \
+ ((S)->type == CONFIG_TYPE_GROUP)
+#define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \
+ ((S)->type == CONFIG_TYPE_ARRAY)
+#define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \
+ ((S)->type == CONFIG_TYPE_LIST)
+
+#define /* int */ config_setting_is_aggregate( \
+ /* const config_setting_t * */ S) \
+ (((S)->type == CONFIG_TYPE_GROUP) || ((S)->type == CONFIG_TYPE_LIST) \
+ || ((S)->type == CONFIG_TYPE_ARRAY))
+
+#define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \
+ (((S)->type == CONFIG_TYPE_INT) \
+ || ((S)->type == CONFIG_TYPE_INT64) \
+ || ((S)->type == CONFIG_TYPE_FLOAT))
+
+#define /* int */ config_setting_is_scalar(/* const config_setting_t * */ S) \
+ (((S)->type == CONFIG_TYPE_BOOL) || ((S)->type == CONFIG_TYPE_STRING) \
+ || config_setting_is_number(S))
+
+#define /* const char * */ config_setting_name( \
+ /* const config_setting_t * */ S) \
+ ((S)->name)
+
+#define /* config_setting_t * */ config_setting_parent( \
+ /* const config_setting_t * */ S) \
+ ((S)->parent)
+
+#define /* int */ config_setting_is_root( \
+ /* const config_setting_t * */ S) \
+ ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE)
+
+extern LIBCONFIG_API int config_setting_index(const config_setting_t *setting);
+
+extern LIBCONFIG_API int config_setting_length(
+ const config_setting_t *setting);
+extern LIBCONFIG_API config_setting_t *config_setting_get_elem(
+ const config_setting_t *setting, unsigned int idx);
+
+extern LIBCONFIG_API config_setting_t *config_setting_get_member(
+ const config_setting_t *setting, const char *name);
+
+extern LIBCONFIG_API config_setting_t *config_setting_add(
+ config_setting_t *parent, const char *name, int type);
+extern LIBCONFIG_API int config_setting_remove(config_setting_t *parent,
+ const char *name);
+extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent,
+ unsigned int idx);
+extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting,
+ void *hook);
+
+#define config_setting_get_hook(S) ((S)->hook)
+
+extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config,
+ const char *path);
+extern LIBCONFIG_API config_setting_t *config_lookup_from(
+ config_setting_t *setting, const char *path);
+
+extern LIBCONFIG_API int config_lookup_int(const config_t *config,
+ const char *path, int *value);
+extern LIBCONFIG_API int config_lookup_int64(const config_t *config,
+ const char *path,
+ long long *value);
+extern LIBCONFIG_API int config_lookup_float(const config_t *config,
+ const char *path, double *value);
+extern LIBCONFIG_API int config_lookup_bool(const config_t *config,
+ const char *path, int *value);
+extern LIBCONFIG_API int config_lookup_string(const config_t *config,
+ const char *path,
+ const char **value);
+
+#define /* config_setting_t * */ config_root_setting( \
+ /* const config_t * */ C) \
+ ((C)->root)
+
+#define /* void */ config_set_default_format(/* config_t * */ C, \
+ /* short */ F) \
+ (C)->default_format = (F)
+
+#define /* short */ config_get_default_format(/* config_t * */ C) \
+ ((C)->default_format)
+
+#define /* void */ config_set_tab_width(/* config_t * */ C, \
+ /* unsigned short */ W) \
+ (C)->tab_width = ((W) & 0x0F)
+
+#define /* unsigned char */ config_get_tab_width(/* const config_t * */ C) \
+ ((C)->tab_width)
+
+#define /* unsigned short */ config_setting_source_line( \
+ /* const config_setting_t * */ S) \
+ ((S)->line)
+
+#define /* const char */ config_setting_source_file( \
+ /* const config_setting_t * */ S) \
+ ((S)->file)
+
+#define /* const char * */ config_error_text(/* const config_t * */ C) \
+ ((C)->error_text)
+
+#define /* const char * */ config_error_file(/* const config_t * */ C) \
+ ((C)->error_file)
+
+#define /* int */ config_error_line(/* const config_t * */ C) \
+ ((C)->error_line)
+
+#define /* config_error_t */ config_error_type(/* const config_t * */ C) \
+ ((C)->error_type)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __libconfig_h */
diff --git a/lib/libconfig.h++ b/lib/libconfig.h++
new file mode 100644
index 0000000..dfc7939
--- /dev/null
+++ b/lib/libconfig.h++
@@ -0,0 +1,459 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_hpp
+#define __libconfig_hpp
+
+#include <stdio.h>
+#include <exception>
+#include <string>
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+#if defined(LIBCONFIGXX_STATIC)
+#define LIBCONFIGXX_API
+#elif defined(LIBCONFIGXX_EXPORTS)
+#define LIBCONFIGXX_API __declspec(dllexport)
+#else /* ! LIBCONFIGXX_EXPORTS */
+#define LIBCONFIGXX_API __declspec(dllimport)
+#endif /* LIBCONFIGXX_STATIC */
+#else /* ! WIN32 */
+#define LIBCONFIGXX_API
+#endif /* WIN32 */
+
+#define LIBCONFIGXX_VER_MAJOR 1
+#define LIBCONFIGXX_VER_MINOR 4
+#define LIBCONFIGXX_VER_REVISION 8
+
+struct config_t; // fwd decl
+struct config_setting_t; // fwd decl
+
+namespace libconfig {
+
+class LIBCONFIGXX_API ConfigException : public std::exception { };
+
+class Setting; // fwd decl
+
+class LIBCONFIGXX_API SettingException : public ConfigException
+{
+ friend class Config;
+
+ public:
+
+ SettingException(const SettingException &other);
+ SettingException& operator=(const SettingException &other);
+
+ virtual ~SettingException() throw();
+
+ const char *getPath() const;
+
+ virtual const char *what() const throw();
+
+ protected:
+
+ SettingException(const Setting &setting);
+ SettingException(const Setting &setting, int idx);
+ SettingException(const Setting &setting, const char *name);
+ SettingException(const char *path);
+
+ private:
+
+ char *_path;
+};
+
+class LIBCONFIGXX_API SettingTypeException : public SettingException
+{
+ friend class Config;
+ friend class Setting;
+
+ public:
+
+ const char *what() const throw();
+
+ private:
+
+ SettingTypeException(const Setting &setting);
+ SettingTypeException(const Setting &setting, int idx);
+ SettingTypeException(const Setting &setting, const char *name);
+};
+
+class LIBCONFIGXX_API SettingNotFoundException : public SettingException
+{
+ friend class Config;
+ friend class Setting;
+
+ public:
+
+ const char *what() const throw();
+
+ private:
+
+ SettingNotFoundException(const Setting &setting, int idx);
+ SettingNotFoundException(const Setting &setting, const char *name);
+ SettingNotFoundException(const char *path);
+};
+
+class LIBCONFIGXX_API SettingNameException : public SettingException
+{
+ friend class Config;
+ friend class Setting;
+
+ public:
+
+ const char *what() const throw();
+
+ private:
+
+ SettingNameException(const Setting &setting, const char *name);
+};
+
+class LIBCONFIGXX_API FileIOException : public ConfigException
+{
+ public:
+
+ const char *what() const throw();
+};
+
+class LIBCONFIGXX_API ParseException : public ConfigException
+{
+ friend class Config;
+
+ public:
+
+ ParseException(const ParseException &other);
+
+ virtual ~ParseException() throw();
+
+ inline const char *getFile() const throw()
+ { return(_file); }
+
+ inline int getLine() const throw()
+ { return(_line); }
+
+ inline const char *getError() const throw()
+ { return(_error); }
+
+ const char *what() const throw();
+
+ private:
+
+ ParseException(const char *file, int line, const char *error);
+
+ const char *_file;
+ int _line;
+ const char *_error;
+};
+
+class LIBCONFIGXX_API Setting
+{
+ friend class Config;
+
+ public:
+
+ enum Type
+ {
+ TypeNone = 0,
+ // scalar types
+ TypeInt,
+ TypeInt64,
+ TypeFloat,
+ TypeString,
+ TypeBoolean,
+ // aggregate types
+ TypeGroup,
+ TypeArray,
+ TypeList
+ };
+
+ enum Format
+ {
+ FormatDefault = 0,
+ FormatHex = 1
+ };
+
+ private:
+
+ config_setting_t *_setting;
+ Type _type;
+ Format _format;
+
+ Setting(config_setting_t *setting);
+
+ void assertType(Type type) const
+ throw(SettingTypeException);
+ static Setting & wrapSetting(config_setting_t *setting);
+
+ Setting(const Setting& other); // not supported
+ Setting& operator=(const Setting& other); // not supported
+
+ public:
+
+ virtual ~Setting() throw();
+
+ inline Type getType() const throw() { return(_type); }
+
+ inline Format getFormat() const throw() { return(_format); }
+ void setFormat(Format format) throw();
+
+ operator bool() const throw(SettingTypeException);
+ operator int() const throw(SettingTypeException);
+ operator unsigned int() const throw(SettingTypeException);
+ operator long() const throw(SettingTypeException);
+ operator unsigned long() const throw(SettingTypeException);
+ operator long long() const throw(SettingTypeException);
+ operator unsigned long long() const throw(SettingTypeException);
+ operator double() const throw(SettingTypeException);
+ operator float() const throw(SettingTypeException);
+ operator const char *() const throw(SettingTypeException);
+ operator std::string() const throw(SettingTypeException);
+
+ inline const char *c_str() const throw(SettingTypeException)
+ { return operator const char*(); }
+
+ Setting & operator=(bool value) throw(SettingTypeException);
+ Setting & operator=(int value) throw(SettingTypeException);
+ Setting & operator=(long value) throw(SettingTypeException);
+ Setting & operator=(const long long &value) throw(SettingTypeException);
+ Setting & operator=(const double &value) throw(SettingTypeException);
+ Setting & operator=(float value) throw(SettingTypeException);
+ Setting & operator=(const char *value) throw(SettingTypeException);
+ Setting & operator=(const std::string &value) throw(SettingTypeException);
+
+ Setting & operator[](const char *key) const
+ throw(SettingTypeException, SettingNotFoundException);
+
+ inline Setting & operator[](const std::string &key) const
+ throw(SettingTypeException, SettingNotFoundException)
+ { return(operator[](key.c_str())); }
+
+ Setting & operator[](int index) const
+ throw(SettingTypeException, SettingNotFoundException);
+
+ bool lookupValue(const char *name, bool &value) const throw();
+ bool lookupValue(const char *name, int &value) const throw();
+ bool lookupValue(const char *name, unsigned int &value) const throw();
+ bool lookupValue(const char *name, long long &value) const throw();
+ bool lookupValue(const char *name, unsigned long long &value)
+ const throw();
+ bool lookupValue(const char *name, double &value) const throw();
+ bool lookupValue(const char *name, float &value) const throw();
+ bool lookupValue(const char *name, const char *&value) const throw();
+ bool lookupValue(const char *name, std::string &value) const throw();
+
+ inline bool lookupValue(const std::string &name, bool &value)
+ const throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, int &value)
+ const throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, unsigned int &value)
+ const throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, long long &value)
+ const throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name,
+ unsigned long long &value) const throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, double &value) const
+ throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, float &value) const
+ throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, const char *&value) const
+ throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, std::string &value) const
+ throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ void remove(const char *name)
+ throw(SettingTypeException, SettingNotFoundException);
+
+ inline void remove(const std::string & name)
+ throw(SettingTypeException, SettingNotFoundException)
+ { remove(name.c_str()); }
+
+ void remove(unsigned int idx)
+ throw(SettingTypeException, SettingNotFoundException);
+
+ inline Setting & add(const std::string & name, Type type)
+ throw(SettingNameException, SettingTypeException)
+ { return(add(name.c_str(), type)); }
+
+ Setting & add(const char *name, Type type)
+ throw(SettingNameException, SettingTypeException);
+
+ Setting & add(Type type) throw(SettingTypeException);
+
+ inline bool exists(const std::string &name) const throw()
+ { return(exists(name.c_str())); }
+
+ bool exists(const char *name) const throw();
+
+ int getLength() const throw();
+ const char *getName() const throw();
+ std::string getPath() const;
+ int getIndex() const throw();
+
+ const Setting & getParent() const throw(SettingNotFoundException);
+ Setting & getParent() throw(SettingNotFoundException);
+
+ bool isRoot() const throw();
+
+ inline bool isGroup() const throw()
+ { return(_type == TypeGroup); }
+
+ inline bool isArray() const throw()
+ { return(_type == TypeArray); }
+
+ inline bool isList() const throw()
+ { return(_type == TypeList); }
+
+ inline bool isAggregate() const throw()
+ { return(_type >= TypeGroup); }
+
+ inline bool isScalar() const throw()
+ { return((_type > TypeNone) && (_type < TypeGroup)); }
+
+ inline bool isNumber() const throw()
+ { return((_type == TypeInt) || (_type == TypeInt64)
+ || (_type == TypeFloat)); }
+
+ unsigned int getSourceLine() const throw();
+ const char *getSourceFile() const throw();
+};
+
+class LIBCONFIGXX_API Config
+{
+ private:
+
+ config_t *_config;
+
+ static void ConfigDestructor(void *arg);
+ Config(const Config& other); // not supported
+ Config& operator=(const Config& other); // not supported
+
+ public:
+
+ Config();
+ virtual ~Config();
+
+ void setAutoConvert(bool flag);
+ bool getAutoConvert() const;
+
+ void setDefaultFormat(Setting::Format format);
+ inline Setting::Format getDefaultFormat() const
+ { return(_defaultFormat); }
+
+ void setTabWidth(unsigned short width) throw();
+ unsigned short getTabWidth() const throw();
+
+ void setIncludeDir(const char *includeDir) throw();
+ const char *getIncludeDir() const throw();
+
+ void read(FILE *stream) throw(ParseException);
+ void write(FILE *stream) const;
+
+ void readString(const char *str) throw(ParseException);
+ inline void readString(const std::string &str) throw(ParseException)
+ { return(readString(str.c_str())); }
+
+ void readFile(const char *filename) throw(FileIOException, ParseException);
+ void writeFile(const char *filename) throw(FileIOException);
+
+ inline Setting & lookup(const std::string &path) const
+ throw(SettingNotFoundException)
+ { return(lookup(path.c_str())); }
+
+ Setting & lookup(const char *path) const throw(SettingNotFoundException);
+
+ inline bool exists(const std::string & path) const throw()
+ { return(exists(path.c_str())); }
+
+ bool exists(const char *path) const throw();
+
+ bool lookupValue(const char *path, bool &value) const throw();
+ bool lookupValue(const char *path, int &value) const throw();
+ bool lookupValue(const char *path, unsigned int &value) const throw();
+ bool lookupValue(const char *path, long long &value) const throw();
+ bool lookupValue(const char *path, unsigned long long &value)
+ const throw();
+ bool lookupValue(const char *path, double &value) const throw();
+ bool lookupValue(const char *path, float &value) const throw();
+ bool lookupValue(const char *path, const char *&value) const throw();
+ bool lookupValue(const char *path, std::string &value) const throw();
+
+ inline bool lookupValue(const std::string &path, bool &value) const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, int &value) const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, unsigned int &value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, long long &value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path,
+ unsigned long long &value) const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, double &value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, float &value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, const char *&value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, std::string &value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ Setting & getRoot() const;
+
+ private:
+
+ Setting::Format _defaultFormat;
+
+ void handleError() const;
+};
+
+} // namespace libconfig
+
+#endif // __libconfig_hpp
diff --git a/lib/libconfig.hh b/lib/libconfig.hh
new file mode 100644
index 0000000..6883a31
--- /dev/null
+++ b/lib/libconfig.hh
@@ -0,0 +1,23 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A structured configuration file parsing library
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ----------------------------------------------------------------------------
+*/
+
+#include <libconfig.h++>
diff --git a/lib/libconfig.pc.in b/lib/libconfig.pc.in
new file mode 100644
index 0000000..4f7628b
--- /dev/null
+++ b/lib/libconfig.pc.in
@@ -0,0 +1,14 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libconfig
+Description: C Configuration File Library
+Version: @VERSION@
+URL: http://www.hyperrealm.com/main.php?s=libconfig
+Requires:
+Conflicts:
+Libs: -L${libdir} -lconfig
+Libs.private: @LIBS@
+Cflags: -I${includedir}
diff --git a/lib/libconfig.vcproj b/lib/libconfig.vcproj
new file mode 100644
index 0000000..90a520e
--- /dev/null
+++ b/lib/libconfig.vcproj
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libconfig"
+ ProjectGUID="{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
+ RootNamespace="libconfig"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions="LIBCONFIG_EXPORTS;YY_NO_UNISTD_H;YY_USE_CONST;WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ RuntimeLibrary="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)_d.dll"
+ GenerateDebugInformation="true"
+ GenerateMapFile="true"
+ MapExports="true"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="LIBCONFIG_EXPORTS;YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_STDLIB_H"
+ RuntimeLibrary="2"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\grammar.c"
+ >
+ </File>
+ <File
+ RelativePath=".\libconfig.c"
+ >
+ </File>
+ <File
+ RelativePath=".\scanctx.c"
+ >
+ </File>
+ <File
+ RelativePath=".\scanner.c"
+ >
+ </File>
+ <File
+ RelativePath=".\strbuf.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\ac_config.h"
+ >
+ </File>
+ <File
+ RelativePath=".\grammar.h"
+ >
+ </File>
+ <File
+ RelativePath=".\libconfig.h"
+ >
+ </File>
+ <File
+ RelativePath=".\parsectx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\private.h"
+ >
+ </File>
+ <File
+ RelativePath=".\scanctx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\scanner.h"
+ >
+ </File>
+ <File
+ RelativePath=".\win32\stdint.h"
+ >
+ </File>
+ <File
+ RelativePath=".\wincompat.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/lib/libconfigcpp.c++ b/lib/libconfigcpp.c++
new file mode 100644
index 0000000..846c067
--- /dev/null
+++ b/lib/libconfigcpp.c++
@@ -0,0 +1,1167 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#include "libconfig.h++"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#include "wincompat.h"
+#include "libconfig.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <sstream>
+
+namespace libconfig {
+
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(const char *file, int line, const char *error)
+ : _file(file ? ::strdup(file) : NULL), _line(line), _error(error)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(const ParseException &other)
+ : _file(other._file ? ::strdup(other._file) : NULL),
+ _line(other._line),
+ _error(other._error)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::~ParseException() throw()
+{
+ ::free((void *)_file);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *ParseException::what() const throw()
+{
+ return("ParseException");
+}
+
+// ---------------------------------------------------------------------------
+
+static int __toTypeCode(Setting::Type type)
+{
+ int typecode;
+
+ switch(type)
+ {
+ case Setting::TypeGroup:
+ typecode = CONFIG_TYPE_GROUP;
+ break;
+
+ case Setting::TypeInt:
+ typecode = CONFIG_TYPE_INT;
+ break;
+
+ case Setting::TypeInt64:
+ typecode = CONFIG_TYPE_INT64;
+ break;
+
+ case Setting::TypeFloat:
+ typecode = CONFIG_TYPE_FLOAT;
+ break;
+
+ case Setting::TypeString:
+ typecode = CONFIG_TYPE_STRING;
+ break;
+
+ case Setting::TypeBoolean:
+ typecode = CONFIG_TYPE_BOOL;
+ break;
+
+ case Setting::TypeArray:
+ typecode = CONFIG_TYPE_ARRAY;
+ break;
+
+ case Setting::TypeList:
+ typecode = CONFIG_TYPE_LIST;
+ break;
+
+ default:
+ typecode = CONFIG_TYPE_NONE;
+ }
+
+ return(typecode);
+}
+
+// ---------------------------------------------------------------------------
+
+static void __constructPath(const Setting &setting,
+ std::stringstream &path)
+{
+ // head recursion to print path from root to target
+
+ if(! setting.isRoot())
+ {
+ __constructPath(setting.getParent(), path);
+ if(path.tellp() > 0)
+ path << '.';
+
+ const char *name = setting.getName();
+ if(name)
+ path << name;
+ else
+ path << '[' << setting.getIndex() << ']';
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting)
+{
+ std::stringstream sstr;
+ __constructPath(setting, sstr);
+
+ _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, int idx)
+{
+ std::stringstream sstr;
+ __constructPath(setting, sstr);
+ sstr << ".[" << idx << "]";
+
+ _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const Setting &setting, const char *name)
+{
+ std::stringstream sstr;
+ __constructPath(setting, sstr);
+ sstr << '.' << name;
+
+ _path = ::strdup(sstr.str().c_str());
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const char *path)
+{
+ _path = ::strdup(path);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::getPath() const
+{
+ return(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException(const SettingException &other)
+{
+ _path = ::strdup(other._path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException &SettingException::operator=(const SettingException &other)
+{
+ ::free(_path);
+ _path = ::strdup(other._path);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingException::what() const throw()
+{
+ return("SettingException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingException::~SettingException() throw()
+{
+ ::free(_path);
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting)
+ : SettingException(setting)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting, int idx)
+ : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException(const Setting &setting,
+ const char *name)
+ : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingTypeException::what() const throw()
+{
+ return("SettingTypeException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+ int idx)
+ : SettingException(setting, idx)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const Setting &setting,
+ const char *name)
+ : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException(const char *path)
+ : SettingException(path)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNotFoundException::what() const throw()
+{
+ return("SettingNotFoundException");
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNameException::SettingNameException(const Setting &setting,
+ const char *name)
+ : SettingException(setting, name)
+{
+}
+
+// ---------------------------------------------------------------------------
+
+const char *SettingNameException::what() const throw()
+{
+ return("SettingNameException");
+}
+
+// ---------------------------------------------------------------------------
+
+const char *FileIOException::what() const throw()
+{
+ return("FileIOException");
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::ConfigDestructor(void *arg)
+{
+ delete reinterpret_cast<Setting *>(arg);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::Config()
+ : _defaultFormat(Setting::FormatDefault)
+{
+ _config = new config_t;
+ config_init(_config);
+ config_set_destructor(_config, ConfigDestructor);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::~Config()
+{
+ config_destroy(_config);
+ delete _config;
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setAutoConvert(bool flag)
+{
+ config_set_auto_convert(_config, (flag ? CONFIG_TRUE : CONFIG_FALSE));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::getAutoConvert() const
+{
+ return(config_get_auto_convert(_config) != CONFIG_FALSE);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setDefaultFormat(Setting::Format format)
+{
+ if(format == Setting::FormatHex)
+ _defaultFormat = Setting::FormatHex;
+ else
+ _defaultFormat = Setting::FormatDefault;
+
+ config_set_default_format(_config, static_cast<short>(_defaultFormat));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setTabWidth(unsigned short width) throw()
+{
+ config_set_tab_width(_config, width);
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned short Config::getTabWidth() const throw()
+{
+ return(config_get_tab_width(_config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::setIncludeDir(const char *includeDir) throw()
+{
+ config_set_include_dir(_config, includeDir);
+}
+
+// ---------------------------------------------------------------------------
+
+const char *Config::getIncludeDir() const throw()
+{
+ return(config_get_include_dir(_config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::handleError() const
+{
+ switch(config_error_type(_config))
+ {
+ case CONFIG_ERR_NONE:
+ break;
+
+ case CONFIG_ERR_PARSE:
+ throw ParseException(config_error_file(_config),
+ config_error_line(_config),
+ config_error_text(_config));
+ break;
+
+ case CONFIG_ERR_FILE_IO:
+ default:
+ throw FileIOException();
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::read(FILE *stream) throw(ParseException)
+{
+ if(! config_read(_config, stream))
+ handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readString(const char *str) throw(ParseException)
+{
+ if(! config_read_string(_config, str))
+ handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::write(FILE *stream) const
+{
+ config_write(_config, stream);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readFile(const char *filename) throw(FileIOException,
+ ParseException)
+{
+ if(! config_read_file(_config, filename))
+ handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::writeFile(const char *filename) throw(FileIOException)
+{
+ if(! config_write_file(_config, filename))
+ handleError();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::lookup(const char *path) const
+ throw(SettingNotFoundException)
+{
+ config_setting_t *s = config_lookup(_config, path);
+ if(! s)
+ throw SettingNotFoundException(path);
+
+ return(Setting::wrapSetting(s));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::exists(const char *path) const throw()
+{
+ config_setting_t *s = config_lookup(_config, path);
+
+ return(s != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+#define CONFIG_LOOKUP_NO_EXCEPTIONS(P, T, V) \
+ try \
+ { \
+ Setting &s = lookup(P); \
+ V = (T)s; \
+ return(true); \
+ } \
+ catch(ConfigException) \
+ { \
+ return(false); \
+ }
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, bool &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, int &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned int &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, long long &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned long long &value)
+ const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, double &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, float &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, const char *&value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, std::string &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::getRoot() const
+{
+ return(Setting::wrapSetting(config_root_setting(_config)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::Setting(config_setting_t *setting)
+ : _setting(setting)
+{
+ switch(config_setting_type(setting))
+ {
+ case CONFIG_TYPE_GROUP:
+ _type = TypeGroup;
+ break;
+
+ case CONFIG_TYPE_INT:
+ _type = TypeInt;
+ break;
+
+ case CONFIG_TYPE_INT64:
+ _type = TypeInt64;
+ break;
+
+ case CONFIG_TYPE_FLOAT:
+ _type = TypeFloat;
+ break;
+
+ case CONFIG_TYPE_STRING:
+ _type = TypeString;
+ break;
+
+ case CONFIG_TYPE_BOOL:
+ _type = TypeBoolean;
+ break;
+
+ case CONFIG_TYPE_ARRAY:
+ _type = TypeArray;
+ break;
+
+ case CONFIG_TYPE_LIST:
+ _type = TypeList;
+ break;
+
+ case CONFIG_TYPE_NONE:
+ default:
+ _type = TypeNone;
+ break;
+ }
+
+ switch(config_setting_get_format(setting))
+ {
+ case CONFIG_FORMAT_HEX:
+ _format = FormatHex;
+ break;
+
+ case CONFIG_FORMAT_DEFAULT:
+ default:
+ _format = FormatDefault;
+ break;
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::~Setting() throw()
+{
+ _setting = NULL;
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::setFormat(Format format) throw()
+{
+ if((_type == TypeInt) || (_type == TypeInt64))
+ {
+ if(format == FormatHex)
+ _format = FormatHex;
+ else
+ _format = FormatDefault;
+ }
+ else
+ _format = FormatDefault;
+
+ config_setting_set_format(_setting, static_cast<short>(_format));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator bool() const throw(SettingTypeException)
+{
+ assertType(TypeBoolean);
+
+ return(config_setting_get_bool(_setting) ? true : false);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator int() const throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ return(config_setting_get_int(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned int() const throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ int v = config_setting_get_int(_setting);
+
+ if(v < 0)
+ v = 0;
+
+ return(static_cast<unsigned int>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long() const throw(SettingTypeException)
+{
+ if(sizeof(long) == sizeof(long long))
+ return operator long long();
+ else
+ return operator int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long() const throw(SettingTypeException)
+{
+ if(sizeof(long) == sizeof(long long))
+ return operator unsigned long long();
+ else
+ return operator unsigned int();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long long() const throw(SettingTypeException)
+{
+ assertType(TypeInt64);
+
+ return(config_setting_get_int64(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long long() const throw(SettingTypeException)
+{
+ assertType(TypeInt64);
+
+ long long v = config_setting_get_int64(_setting);
+
+ if(v < INT64_CONST(0))
+ v = INT64_CONST(0);
+
+ return(static_cast<unsigned long long>(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator double() const throw(SettingTypeException)
+{
+ assertType(TypeFloat);
+
+ return(config_setting_get_float(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator float() const throw(SettingTypeException)
+{
+ assertType(TypeFloat);
+
+ // may cause loss of precision:
+ return(static_cast<float>(config_setting_get_float(_setting)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator const char *() const throw(SettingTypeException)
+{
+ assertType(TypeString);
+
+ return(config_setting_get_string(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator std::string() const throw(SettingTypeException)
+{
+ assertType(TypeString);
+
+ const char *s = config_setting_get_string(_setting);
+
+ std::string str;
+ if(s)
+ str = s;
+
+ return(str);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(bool value) throw(SettingTypeException)
+{
+ assertType(TypeBoolean);
+
+ config_setting_set_bool(_setting, value);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(int value) throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ config_setting_set_int(_setting, value);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(long value) throw(SettingTypeException)
+{
+ if(sizeof(long) == sizeof(long long))
+ return(operator=(static_cast<long long>(value)));
+ else
+ return(operator=(static_cast<int>(value)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const long long &value)
+ throw(SettingTypeException)
+{
+ assertType(TypeInt64);
+
+ config_setting_set_int64(_setting, value);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const double &value) throw(SettingTypeException)
+{
+ assertType(TypeFloat);
+
+ config_setting_set_float(_setting, value);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(float value) throw(SettingTypeException)
+{
+ assertType(TypeFloat);
+
+ double cvalue = static_cast<double>(value);
+
+ config_setting_set_float(_setting, cvalue);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const char *value) throw(SettingTypeException)
+{
+ assertType(TypeString);
+
+ config_setting_set_string(_setting, value);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(const std::string &value)
+ throw(SettingTypeException)
+{
+ assertType(TypeString);
+
+ config_setting_set_string(_setting, value.c_str());
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](int i) const
+ throw(SettingTypeException, SettingNotFoundException)
+{
+ if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+ throw SettingTypeException(*this, i);
+
+ config_setting_t *setting = config_setting_get_elem(_setting, i);
+
+ if(! setting)
+ throw SettingNotFoundException(*this, i);
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator[](const char *key) const
+ throw(SettingTypeException, SettingNotFoundException)
+{
+ assertType(TypeGroup);
+
+ config_setting_t *setting = config_setting_get_member(_setting, key);
+
+ if(! setting)
+ throw SettingNotFoundException(*this, key);
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+#define SETTING_LOOKUP_NO_EXCEPTIONS(K, T, V) \
+ try \
+ { \
+ Setting &s = operator[](K); \
+ V = (T)s; \
+ return(true); \
+ } \
+ catch(ConfigException) \
+ { \
+ return(false); \
+ }
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, bool &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, bool, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, int &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned int &value)
+ const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned int, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, long long &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned long long &value)
+ const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, double &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, double, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, float &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, float, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, const char *&value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, std::string &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, const char *, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::exists(const char *name) const throw()
+{
+ if(_type != TypeGroup)
+ return(false);
+
+ config_setting_t *setting = config_setting_get_member(_setting, name);
+
+ return(setting != NULL);
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getLength() const throw()
+{
+ return(config_setting_length(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char * Setting::getName() const throw()
+{
+ return(config_setting_name(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+std::string Setting::getPath() const
+{
+ std::stringstream path;
+
+ __constructPath(*this, path);
+
+ return(path.str());
+}
+
+// ---------------------------------------------------------------------------
+
+const Setting & Setting::getParent() const throw(SettingNotFoundException)
+{
+ config_setting_t *setting = config_setting_parent(_setting);
+
+ if(! setting)
+ throw SettingNotFoundException(NULL);
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::getParent() throw(SettingNotFoundException)
+{
+ config_setting_t *setting = config_setting_parent(_setting);
+
+ if(! setting)
+ throw SettingNotFoundException(NULL);
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+unsigned int Setting::getSourceLine() const throw()
+{
+ return(config_setting_source_line(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+const char *Setting::getSourceFile() const throw()
+{
+ return(config_setting_source_file(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::isRoot() const throw()
+{
+ return(config_setting_is_root(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+int Setting::getIndex() const throw()
+{
+ return(config_setting_index(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(const char *name)
+ throw(SettingTypeException, SettingNotFoundException)
+{
+ assertType(TypeGroup);
+
+ if(! config_setting_remove(_setting, name))
+ throw SettingNotFoundException(*this, name);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(unsigned int idx)
+ throw(SettingTypeException, SettingNotFoundException)
+{
+ if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+ throw SettingTypeException(*this, idx);
+
+ if(! config_setting_remove_elem(_setting, idx))
+ throw SettingNotFoundException(*this, idx);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(const char *name, Setting::Type type)
+ throw(SettingNameException, SettingTypeException)
+{
+ assertType(TypeGroup);
+
+ int typecode = __toTypeCode(type);
+
+ if(typecode == CONFIG_TYPE_NONE)
+ throw SettingTypeException(*this, name);
+
+ config_setting_t *setting = config_setting_add(_setting, name, typecode);
+
+ if(! setting)
+ throw SettingNameException(*this, name);
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(Setting::Type type) throw(SettingTypeException)
+{
+ if((_type != TypeArray) && (_type != TypeList))
+ throw SettingTypeException(*this);
+
+ if(_type == TypeArray)
+ {
+ int idx = getLength();
+
+ if(idx > 0)
+ {
+ Setting::Type atype = operator[](0).getType();
+ if(type != atype)
+ throw SettingTypeException(*this, idx);
+ }
+ else
+ {
+ if((type != TypeInt) && (type != TypeInt64) && (type != TypeFloat)
+ && (type != TypeString) && (type != TypeBoolean))
+ throw SettingTypeException(*this, idx);
+ }
+ }
+
+ int typecode = __toTypeCode(type);
+ config_setting_t *s = config_setting_add(_setting, NULL, typecode);
+
+ Setting &ns = wrapSetting(s);
+
+ switch(type)
+ {
+ case TypeInt:
+ ns = 0;
+ break;
+
+ case TypeInt64:
+ ns = INT64_CONST(0);
+ break;
+
+ case TypeFloat:
+ ns = 0.0;
+ break;
+
+ case TypeString:
+ ns = (char *)NULL;
+ break;
+
+ case TypeBoolean:
+ ns = false;
+ break;
+
+ default:
+ // won't happen
+ break;
+ }
+
+ return(ns);
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::assertType(Setting::Type type) const throw(SettingTypeException)
+{
+ if(type != _type)
+ {
+ if(!(isNumber() && config_get_auto_convert(_setting->config)
+ && ((type == TypeInt) || (type == TypeInt64) || (type == TypeFloat))))
+ throw SettingTypeException(*this);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::wrapSetting(config_setting_t *s)
+{
+ Setting *setting = NULL;
+
+ void *hook = config_setting_get_hook(s);
+ if(! hook)
+ {
+ setting = new Setting(s);
+ config_setting_set_hook(s, reinterpret_cast<void *>(setting));
+ }
+ else
+ setting = reinterpret_cast<Setting *>(hook);
+
+ return(*setting);
+}
+
+// ---------------------------------------------------------------------------
+
+}; // namespace libconfig
+
+// eof
diff --git a/lib/libconfigcpp.cc b/lib/libconfigcpp.cc
new file mode 100644
index 0000000..9431146
--- /dev/null
+++ b/lib/libconfigcpp.cc
@@ -0,0 +1,23 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A structured configuration file parsing library
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ----------------------------------------------------------------------------
+*/
+
+#include "libconfigcpp.c++"
diff --git a/lib/parsectx.h b/lib/parsectx.h
new file mode 100644
index 0000000..af09b56
--- /dev/null
+++ b/lib/parsectx.h
@@ -0,0 +1,48 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_parsectx_h
+#define __libconfig_parsectx_h
+
+#include "libconfig.h"
+#include "strbuf.h"
+
+struct parse_context
+{
+ config_t *config;
+ config_setting_t *parent;
+ config_setting_t *setting;
+ char *name;
+ strbuf_t string;
+};
+
+#define parsectx_init(C) \
+ memset((C), 0, sizeof(struct parse_context))
+#define parsectx_cleanup(C) \
+ free((void *)(strbuf_release(&((C)->string))))
+
+#define parsectx_append_string(C, S) \
+ strbuf_append(&((C)->string), (S))
+#define parsectx_take_string(C) \
+ strbuf_release(&((C)->string))
+
+#endif /* __libconfig_parsectx_h */
diff --git a/lib/scanctx.c b/lib/scanctx.c
new file mode 100644
index 0000000..f287fdf
--- /dev/null
+++ b/lib/scanctx.c
@@ -0,0 +1,171 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#include "scanctx.h"
+#include "wincompat.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define STRING_BLOCK_SIZE 64
+#define CHUNK_SIZE 32
+
+/* ------------------------------------------------------------------------- */
+
+static const char *err_bad_include = "cannot open include file";
+static const char *err_include_too_deep = "include file nesting too deep";
+
+/* ------------------------------------------------------------------------- */
+
+static const char *__scanctx_add_filename(struct scan_context *ctx,
+ const char *filename)
+{
+ unsigned int count = ctx->num_filenames;
+ const char **f;
+
+ for(f = ctx->filenames; count > 0; ++f, --count)
+ {
+ if(!strcmp(*f, filename))
+ {
+ free((void *)filename);
+ return(*f); /* already in list */
+ }
+ }
+
+ if((ctx->num_filenames % CHUNK_SIZE) == 0)
+ {
+ ctx->filenames = (const char **)realloc(
+ (void *)ctx->filenames,
+ (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *));
+ }
+
+ ctx->filenames[ctx->num_filenames] = filename;
+ ++ctx->num_filenames;
+ return(filename);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void scanctx_init(struct scan_context *ctx, const char *top_filename)
+{
+ memset(ctx, 0, sizeof(struct scan_context));
+ if(top_filename)
+ ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename));
+}
+
+/* ------------------------------------------------------------------------- */
+
+const char **scanctx_cleanup(struct scan_context *ctx,
+ unsigned int *num_filenames)
+{
+ int i;
+
+ for(i = 0; i < ctx->depth; ++i)
+ fclose(ctx->streams[i]);
+
+ free((void *)(strbuf_release(&(ctx->string))));
+
+ *num_filenames = ctx->num_filenames;
+ return(ctx->filenames);
+}
+
+/* ------------------------------------------------------------------------- */
+
+FILE *scanctx_push_include(struct scan_context *ctx, void *buffer,
+ const char **error)
+{
+ FILE *fp = NULL;
+ const char *file;
+ char *full_file = NULL;
+
+ *error = NULL;
+
+ if(ctx->depth == MAX_INCLUDE_DEPTH)
+ {
+ *error = err_include_too_deep;
+ return(NULL);
+ }
+
+ file = scanctx_take_string(ctx);
+ if(ctx->config->include_dir)
+ {
+ full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file)
+ + 2);
+ strcpy(full_file, ctx->config->include_dir);
+ strcat(full_file, FILE_SEPARATOR);
+ strcat(full_file, file);
+ }
+
+ fp = fopen(full_file ? full_file : file, "rt");
+ free((void *)full_file);
+
+ if(fp)
+ {
+ ctx->streams[ctx->depth] = fp;
+ ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file);
+ ctx->buffers[ctx->depth] = buffer;
+ ++(ctx->depth);
+ }
+ else
+ {
+ free((void *)file);
+ *error = err_bad_include;
+ }
+
+ return(fp);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void *scanctx_pop_include(struct scan_context *ctx)
+{
+ void *buffer;
+
+ if(ctx->depth == 0)
+ return(NULL); /* stack underflow */
+
+ --(ctx->depth);
+ buffer = ctx->buffers[ctx->depth];
+ fclose(ctx->streams[ctx->depth]);
+
+ return(buffer);
+}
+
+/* ------------------------------------------------------------------------- */
+
+char *scanctx_take_string(struct scan_context *ctx)
+{
+ char *r = strbuf_release(&(ctx->string));
+
+ return(r ? r : strdup(""));
+}
+
+/* ------------------------------------------------------------------------- */
+
+const char *scanctx_current_filename(struct scan_context *ctx)
+{
+ return((ctx->depth == 0) ? ctx->top_filename : ctx->files[ctx->depth - 1]);
+}
+
+/* ------------------------------------------------------------------------- */
+/* eof */
diff --git a/lib/scanctx.h b/lib/scanctx.h
new file mode 100644
index 0000000..8ff934e
--- /dev/null
+++ b/lib/scanctx.h
@@ -0,0 +1,62 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_scanctx_h
+#define __libconfig_scanctx_h
+
+#include "libconfig.h"
+#include "strbuf.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#define MAX_INCLUDE_DEPTH 10
+
+struct scan_context
+{
+ config_t *config;
+ const char *top_filename;
+ const char *files[MAX_INCLUDE_DEPTH];
+ void *buffers[MAX_INCLUDE_DEPTH];
+ FILE *streams[MAX_INCLUDE_DEPTH];
+ int depth;
+ strbuf_t string;
+ const char **filenames;
+ unsigned int num_filenames;
+};
+
+extern void scanctx_init(struct scan_context *ctx, const char *top_filename);
+extern const char **scanctx_cleanup(struct scan_context *ctx,
+ unsigned int *num_filenames);
+
+extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer,
+ const char **error);
+extern void *scanctx_pop_include(struct scan_context *ctx);
+
+#define scanctx_append_string(C, S) \
+ strbuf_append(&((C)->string), (S))
+
+extern char *scanctx_take_string(struct scan_context *ctx);
+
+extern const char *scanctx_current_filename(struct scan_context *ctx);
+
+#endif /* __libconfig_scanctx_h */
diff --git a/lib/scanner.c b/lib/scanner.c
new file mode 100644
index 0000000..c2eb7d1
--- /dev/null
+++ b/lib/scanner.c
@@ -0,0 +1,2362 @@
+#line 2 "scanner.c"
+
+#line 4 "scanner.c"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yyg->yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yyg->yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE libconfig_yyrestart(yyin ,yyscanner )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE libconfig_yylex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-yylineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < yyleng; ++yyl )\
+ if ( yytext[yyl] == '\n' )\
+ --yylineno;\
+ }while(0)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = yyg->yy_hold_char; \
+ YY_RESTORE_YY_MORE_OFFSET \
+ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via libconfig_yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
+ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
+
+void libconfig_yyrestart (FILE *input_file ,yyscan_t yyscanner );
+void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
+void libconfig_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void libconfig_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+void libconfig_yypop_buffer_state (yyscan_t yyscanner );
+
+static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner );
+static void libconfig_yy_load_buffer_state (yyscan_t yyscanner );
+static void libconfig_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+
+#define YY_FLUSH_BUFFER libconfig_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+
+YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+
+void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner );
+void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
+void libconfig_yyfree (void * ,yyscan_t yyscanner );
+
+#define yy_new_buffer libconfig_yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ libconfig_yyensure_buffer_stack (yyscanner); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ libconfig_yyensure_buffer_stack (yyscanner); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+#define libconfig_yywrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+typedef int yy_state_type;
+
+#define yytext_ptr yytext_r
+
+static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
+static int yy_get_next_buffer (yyscan_t yyscanner );
+static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ yyg->yytext_ptr = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ yyg->yy_hold_char = *yy_cp; \
+ *yy_cp = '\0'; \
+ yyg->yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 41
+#define YY_END_OF_BUFFER 42
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[103] =
+ { 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 42, 40,
+ 21, 20, 20, 5, 40, 36, 37, 28, 40, 23,
+ 29, 40, 30, 30, 22, 38, 28, 28, 34, 35,
+ 24, 25, 21, 40, 3, 4, 3, 6, 14, 41,
+ 16, 19, 41, 21, 0, 39, 28, 29, 30, 29,
+ 0, 1, 0, 29, 0, 31, 0, 28, 28, 21,
+ 0, 0, 2, 6, 12, 0, 11, 10, 7, 8,
+ 9, 16, 18, 17, 0, 29, 29, 0, 0, 29,
+ 31, 32, 28, 28, 0, 0, 0, 29, 33, 28,
+ 26, 0, 13, 33, 27, 0, 0, 0, 0, 0,
+
+ 15, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 4, 5, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 6, 7, 1, 1, 1, 1, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 18, 19, 1,
+ 20, 1, 1, 21, 22, 23, 23, 23, 24, 25,
+ 26, 26, 26, 26, 26, 27, 26, 26, 26, 26,
+ 26, 28, 29, 30, 31, 26, 26, 32, 26, 26,
+ 33, 34, 35, 1, 36, 1, 22, 23, 37, 38,
+
+ 39, 40, 26, 26, 41, 26, 26, 42, 26, 43,
+ 26, 26, 26, 44, 29, 45, 46, 26, 26, 32,
+ 26, 26, 47, 1, 48, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst flex_int32_t yy_meta[49] =
+ { 0,
+ 1, 1, 1, 1, 1, 2, 1, 1, 1, 3,
+ 1, 1, 3, 1, 1, 4, 4, 1, 1, 1,
+ 1, 4, 4, 4, 4, 3, 3, 3, 3, 3,
+ 3, 3, 1, 2, 1, 3, 4, 4, 4, 4,
+ 3, 3, 3, 3, 3, 3, 1, 1
+ } ;
+
+static yyconst flex_int16_t yy_base[113] =
+ { 0,
+ 0, 47, 47, 48, 46, 47, 48, 49, 203, 204,
+ 200, 204, 204, 204, 198, 204, 204, 0, 45, 204,
+ 47, 50, 60, 74, 204, 204, 178, 28, 204, 204,
+ 204, 204, 64, 158, 204, 204, 183, 0, 204, 63,
+ 0, 204, 83, 195, 193, 204, 0, 88, 102, 98,
+ 62, 204, 190, 104, 119, 162, 0, 67, 65, 121,
+ 127, 124, 204, 0, 204, 0, 204, 204, 204, 204,
+ 204, 0, 204, 204, 108, 117, 122, 134, 132, 136,
+ 204, 139, 136, 116, 126, 0, 140, 142, 135, 130,
+ 0, 102, 204, 204, 0, 85, 72, 63, 98, 158,
+
+ 204, 204, 169, 173, 177, 181, 183, 187, 191, 89,
+ 66, 63
+ } ;
+
+static yyconst flex_int16_t yy_def[113] =
+ { 0,
+ 102, 1, 103, 103, 104, 104, 105, 105, 102, 102,
+ 102, 102, 102, 102, 106, 102, 102, 107, 102, 102,
+ 102, 102, 102, 102, 102, 102, 107, 107, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 108, 102, 102,
+ 109, 102, 102, 102, 106, 102, 107, 102, 102, 102,
+ 102, 102, 106, 102, 102, 102, 110, 107, 107, 102,
+ 102, 102, 102, 108, 102, 111, 102, 102, 102, 102,
+ 102, 109, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 110, 107, 107, 102, 112, 102, 102, 102, 107,
+ 107, 102, 102, 102, 107, 102, 102, 102, 102, 102,
+
+ 102, 0, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102
+ } ;
+
+static yyconst flex_int16_t yy_nxt[253] =
+ { 0,
+ 10, 11, 12, 13, 13, 14, 15, 16, 17, 18,
+ 19, 20, 19, 21, 22, 23, 24, 25, 26, 25,
+ 10, 18, 18, 18, 27, 18, 18, 18, 18, 28,
+ 18, 18, 29, 10, 30, 10, 18, 18, 18, 27,
+ 18, 18, 18, 18, 28, 18, 31, 32, 33, 36,
+ 36, 39, 39, 42, 42, 59, 37, 37, 48, 52,
+ 49, 49, 50, 50, 53, 60, 93, 34, 65, 86,
+ 51, 59, 75, 54, 75, 49, 49, 76, 76, 40,
+ 40, 43, 43, 55, 61, 51, 56, 54, 73, 49,
+ 49, 57, 82, 83, 66, 84, 67, 55, 55, 100,
+
+ 56, 99, 68, 50, 50, 69, 70, 71, 83, 98,
+ 84, 51, 55, 50, 50, 54, 74, 49, 49, 77,
+ 77, 51, 60, 76, 76, 55, 51, 78, 56, 79,
+ 97, 79, 76, 76, 80, 80, 51, 77, 77, 91,
+ 55, 61, 78, 96, 87, 78, 87, 80, 80, 88,
+ 88, 80, 80, 95, 91, 88, 88, 88, 88, 100,
+ 78, 94, 92, 101, 90, 89, 85, 62, 95, 35,
+ 35, 35, 35, 38, 38, 38, 38, 41, 41, 41,
+ 41, 45, 45, 45, 45, 47, 47, 64, 81, 64,
+ 64, 72, 46, 72, 72, 46, 44, 63, 62, 58,
+
+ 46, 44, 102, 9, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102
+ } ;
+
+static yyconst flex_int16_t yy_chk[253] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 4, 5, 6, 7, 8, 28, 3, 4, 19, 22,
+ 19, 19, 21, 21, 22, 33, 112, 2, 40, 111,
+ 21, 28, 51, 23, 51, 23, 23, 51, 51, 5,
+ 6, 7, 8, 23, 33, 21, 23, 24, 43, 24,
+ 24, 23, 110, 58, 40, 59, 40, 24, 23, 99,
+
+ 24, 98, 40, 48, 48, 40, 40, 40, 58, 97,
+ 59, 48, 24, 50, 50, 49, 43, 49, 49, 54,
+ 54, 50, 60, 75, 75, 49, 48, 54, 49, 55,
+ 96, 55, 76, 76, 55, 55, 50, 77, 77, 84,
+ 49, 60, 54, 92, 78, 77, 78, 79, 79, 78,
+ 78, 80, 80, 90, 84, 87, 87, 88, 88, 100,
+ 77, 89, 85, 100, 83, 82, 62, 61, 90, 103,
+ 103, 103, 103, 104, 104, 104, 104, 105, 105, 105,
+ 105, 106, 106, 106, 106, 107, 107, 108, 56, 108,
+ 108, 109, 53, 109, 109, 45, 44, 37, 34, 27,
+
+ 15, 11, 9, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
+ 102, 102
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[42] =
+ { 0,
+0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, };
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+#line 1 "scanner.l"
+/* -*- mode: C -*- */
+/* --------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+#define YY_NO_UNISTD_H 1
+#line 35 "scanner.l"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "grammar.h"
+#include "wincompat.h"
+#include "parsectx.h"
+#include "scanctx.h"
+
+#define YY_NO_INPUT // Suppress generation of useless input() function
+
+static unsigned long long fromhex(const char *s)
+{
+#ifdef __MINGW32__
+
+ /* MinGW's strtoull() seems to be broken; it only returns the lower
+ * 32 bits...
+ */
+
+ const char *p = s;
+ unsigned long long val = 0;
+
+ if(*p != '0')
+ return(0);
+
+ ++p;
+
+ if(*p != 'x' && *p != 'X')
+ return(0);
+
+ for(++p; isxdigit(*p); ++p)
+ {
+ val <<= 4;
+ val |= ((*p < 'A') ? (*p & 0xF) : (9 + (*p & 0x7)));
+ }
+
+ return(val);
+
+#else /* ! __MINGW32__ */
+
+ return(strtoull(s, NULL, 16));
+
+#endif /* __MINGW32__ */
+}
+
+
+#line 626 "scanner.c"
+
+#define INITIAL 0
+#define COMMENT 1
+#define STRING 2
+#define INCLUDE 3
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#define YY_EXTRA_TYPE struct scan_context *
+
+/* Holds the entire state of the reentrant scanner. */
+struct yyguts_t
+ {
+
+ /* User-defined. Not touched by flex. */
+ YY_EXTRA_TYPE yyextra_r;
+
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
+ FILE *yyin_r, *yyout_r;
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+ char yy_hold_char;
+ int yy_n_chars;
+ int yyleng_r;
+ char *yy_c_buf_p;
+ int yy_init;
+ int yy_start;
+ int yy_did_buffer_switch_on_eof;
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int *yy_start_stack;
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ int yylineno_r;
+ int yy_flex_debug_r;
+
+ char *yytext_r;
+ int yy_more_flag;
+ int yy_more_len;
+
+ YYSTYPE * yylval_r;
+
+ }; /* end struct yyguts_t */
+
+static int yy_init_globals (yyscan_t yyscanner );
+
+ /* This must go here because YYSTYPE and YYLTYPE are included
+ * from bison output in section 1.*/
+ # define yylval yyg->yylval_r
+
+int libconfig_yylex_init (yyscan_t* scanner);
+
+int libconfig_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int libconfig_yylex_destroy (yyscan_t yyscanner );
+
+int libconfig_yyget_debug (yyscan_t yyscanner );
+
+void libconfig_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+
+YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner );
+
+void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+
+FILE *libconfig_yyget_in (yyscan_t yyscanner );
+
+void libconfig_yyset_in (FILE * in_str ,yyscan_t yyscanner );
+
+FILE *libconfig_yyget_out (yyscan_t yyscanner );
+
+void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner );
+
+int libconfig_yyget_leng (yyscan_t yyscanner );
+
+char *libconfig_yyget_text (yyscan_t yyscanner );
+
+int libconfig_yyget_lineno (yyscan_t yyscanner );
+
+void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner );
+
+YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner );
+
+void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int libconfig_yywrap (yyscan_t yyscanner );
+#else
+extern int libconfig_yywrap (yyscan_t yyscanner );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (yyscan_t yyscanner );
+#else
+static int input (yyscan_t yyscanner );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int libconfig_yylex \
+ (YYSTYPE * yylval_param ,yyscan_t yyscanner);
+
+#define YY_DECL int libconfig_yylex \
+ (YYSTYPE * yylval_param , yyscan_t yyscanner)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ if ( yyleng > 0 ) \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
+ (yytext[yyleng - 1] == '\n'); \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+#line 100 "scanner.l"
+
+
+#line 869 "scanner.c"
+
+ yylval = yylval_param;
+
+ if ( !yyg->yy_init )
+ {
+ yyg->yy_init = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! yyg->yy_start )
+ yyg->yy_start = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ libconfig_yyensure_buffer_stack (yyscanner);
+ YY_CURRENT_BUFFER_LVALUE =
+ libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ }
+
+ libconfig_yy_load_buffer_state(yyscanner );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = yyg->yy_c_buf_p;
+
+ /* Support of yytext. */
+ *yy_cp = yyg->yy_hold_char;
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = yyg->yy_start;
+ yy_current_state += YY_AT_BOL();
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 103 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_base[yy_current_state] != 204 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+ if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ {
+ int yyl;
+ for ( yyl = 0; yyl < yyleng; ++yyl )
+ if ( yytext[yyl] == '\n' )
+
+ do{ yylineno++;
+ yycolumn=0;
+ }while(0)
+;
+ }
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = yyg->yy_hold_char;
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 102 "scanner.l"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 103 "scanner.l"
+{ BEGIN INITIAL; }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 104 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 4:
+/* rule 4 can match eol */
+YY_RULE_SETUP
+#line 105 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 107 "scanner.l"
+{ BEGIN STRING; }
+ YY_BREAK
+case 6:
+/* rule 6 can match eol */
+YY_RULE_SETUP
+#line 108 "scanner.l"
+{ scanctx_append_string(yyextra, yytext); }
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 109 "scanner.l"
+{ scanctx_append_string(yyextra, "\n"); }
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 110 "scanner.l"
+{ scanctx_append_string(yyextra, "\r"); }
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 111 "scanner.l"
+{ scanctx_append_string(yyextra, "\t"); }
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 112 "scanner.l"
+{ scanctx_append_string(yyextra, "\f"); }
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 113 "scanner.l"
+{ scanctx_append_string(yyextra, "\\"); }
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 114 "scanner.l"
+{ scanctx_append_string(yyextra, "\""); }
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 115 "scanner.l"
+{
+ char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF),
+ 0 };
+ scanctx_append_string(yyextra, c);
+ }
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 120 "scanner.l"
+{
+ yylval->sval = scanctx_take_string(yyextra);
+ BEGIN INITIAL;
+ return(TOK_STRING);
+ }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 126 "scanner.l"
+{ BEGIN INCLUDE; }
+ YY_BREAK
+case 16:
+/* rule 16 can match eol */
+YY_RULE_SETUP
+#line 127 "scanner.l"
+{ scanctx_append_string(yyextra, yytext); }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 128 "scanner.l"
+{ scanctx_append_string(yyextra, "\\"); }
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 129 "scanner.l"
+{ scanctx_append_string(yyextra, "\""); }
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 130 "scanner.l"
+{
+ const char *error;
+ FILE *fp = scanctx_push_include(yyextra,
+ (void *)YY_CURRENT_BUFFER,
+ &error);
+ if(fp)
+ {
+ yyin = fp;
+ libconfig_yy_switch_to_buffer(libconfig_yy_create_buffer(yyin,YY_BUF_SIZE,yyscanner),yyscanner);
+ }
+ else
+ {
+ yyextra->config->error_text = error;
+ yyextra->config->error_file = scanctx_current_filename(
+ yyextra);
+ yyextra->config->error_line = libconfig_yyget_lineno(
+ yyscanner);
+ return TOK_ERROR;
+ }
+ BEGIN INITIAL;
+ }
+ YY_BREAK
+case 20:
+/* rule 20 can match eol */
+YY_RULE_SETUP
+#line 154 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 155 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 157 "scanner.l"
+{ return(TOK_EQUALS); }
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 158 "scanner.l"
+{ return(TOK_COMMA); }
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 159 "scanner.l"
+{ return(TOK_GROUP_START); }
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 160 "scanner.l"
+{ return(TOK_GROUP_END); }
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 161 "scanner.l"
+{ yylval->ival = 1; return(TOK_BOOLEAN); }
+ YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 162 "scanner.l"
+{ yylval->ival = 0; return(TOK_BOOLEAN); }
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 163 "scanner.l"
+{ yylval->sval = yytext; return(TOK_NAME); }
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 164 "scanner.l"
+{ yylval->fval = atof(yytext); return(TOK_FLOAT); }
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 165 "scanner.l"
+{ yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 166 "scanner.l"
+{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 167 "scanner.l"
+{
+ yylval->ival = strtoul(yytext, NULL, 16);
+ return(TOK_HEX);
+ }
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 171 "scanner.l"
+{ yylval->llval = fromhex(yytext); return(TOK_HEX64); }
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 172 "scanner.l"
+{ return(TOK_ARRAY_START); }
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 173 "scanner.l"
+{ return(TOK_ARRAY_END); }
+ YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 174 "scanner.l"
+{ return(TOK_LIST_START); }
+ YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 175 "scanner.l"
+{ return(TOK_LIST_END); }
+ YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 176 "scanner.l"
+{ return(TOK_SEMICOLON); }
+ YY_BREAK
+case 39:
+*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
+yyg->yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 177 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 178 "scanner.l"
+{ return(TOK_GARBAGE); }
+ YY_BREAK
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+case YY_STATE_EOF(STRING):
+case YY_STATE_EOF(INCLUDE):
+#line 180 "scanner.l"
+{
+ YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
+ yyextra);
+ if(buf)
+ {
+ libconfig_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner);
+ libconfig_yy_switch_to_buffer(buf,yyscanner);
+ }
+ else
+ yyterminate();
+ }
+ YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 191 "scanner.l"
+ECHO;
+ YY_BREAK
+#line 1227 "scanner.c"
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = yyg->yy_hold_char;
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * libconfig_yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( yyscanner );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
+
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++yyg->yy_c_buf_p;
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = yyg->yy_c_buf_p;
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( yyscanner ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ yyg->yy_did_buffer_switch_on_eof = 0;
+
+ if ( libconfig_yywrap(yyscanner ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yyg->yy_c_buf_p =
+ yyg->yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( yyscanner );
+
+ yy_cp = yyg->yy_c_buf_p;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ yyg->yy_c_buf_p =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
+
+ yy_current_state = yy_get_previous_state( yyscanner );
+
+ yy_cp = yyg->yy_c_buf_p;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of libconfig_yylex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = yyg->yytext_ptr;
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ libconfig_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ yyg->yy_n_chars, (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ }
+
+ if ( yyg->yy_n_chars == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ libconfig_yyrestart(yyin ,yyscanner);
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) libconfig_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ yyg->yy_n_chars += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ yy_current_state = yyg->yy_start;
+ yy_current_state += YY_AT_BOL();
+
+ for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 103 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
+{
+ register int yy_is_jam;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
+ register char *yy_cp = yyg->yy_c_buf_p;
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 103 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 102);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (yyscan_t yyscanner)
+#else
+ static int input (yyscan_t yyscanner)
+#endif
+
+{
+ int c;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+
+ if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+ /* This was really a NUL. */
+ *yyg->yy_c_buf_p = '\0';
+
+ else
+ { /* need more input */
+ int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ ++yyg->yy_c_buf_p;
+
+ switch ( yy_get_next_buffer( yyscanner ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ libconfig_yyrestart(yyin ,yyscanner);
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( libconfig_yywrap(yyscanner ) )
+ return EOF;
+
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput(yyscanner);
+#else
+ return input(yyscanner);
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
+ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
+ yyg->yy_hold_char = *++yyg->yy_c_buf_p;
+
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol )
+
+ do{ yylineno++;
+ yycolumn=0;
+ }while(0)
+;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * @param yyscanner The scanner object.
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void libconfig_yyrestart (FILE * input_file , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if ( ! YY_CURRENT_BUFFER ){
+ libconfig_yyensure_buffer_stack (yyscanner);
+ YY_CURRENT_BUFFER_LVALUE =
+ libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ }
+
+ libconfig_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
+ libconfig_yy_load_buffer_state(yyscanner );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * @param yyscanner The scanner object.
+ */
+ void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * libconfig_yypop_buffer_state();
+ * libconfig_yypush_buffer_state(new_buffer);
+ */
+ libconfig_yyensure_buffer_stack (yyscanner);
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ libconfig_yy_load_buffer_state(yyscanner );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (libconfig_yywrap()) processing, but the only time this flag
+ * is looked at is after libconfig_yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ yyg->yy_did_buffer_switch_on_eof = 1;
+}
+
+static void libconfig_yy_load_buffer_state (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ yyg->yy_hold_char = *yyg->yy_c_buf_p;
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * @param yyscanner The scanner object.
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE libconfig_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) libconfig_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) libconfig_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ libconfig_yy_init_buffer(b,file ,yyscanner);
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with libconfig_yy_create_buffer()
+ * @param yyscanner The scanner object.
+ */
+ void libconfig_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ libconfig_yyfree((void *) b->yy_ch_buf ,yyscanner );
+
+ libconfig_yyfree((void *) b ,yyscanner );
+}
+
+#ifndef __cplusplus
+extern int isatty (int );
+#endif /* __cplusplus */
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a libconfig_yyrestart() or at EOF.
+ */
+ static void libconfig_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+
+{
+ int oerrno = errno;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ libconfig_yy_flush_buffer(b ,yyscanner);
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then libconfig_yy_init_buffer was _probably_
+ * called from libconfig_yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * @param yyscanner The scanner object.
+ */
+ void libconfig_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ libconfig_yy_load_buffer_state(yyscanner );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ * @param yyscanner The scanner object.
+ */
+void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if (new_buffer == NULL)
+ return;
+
+ libconfig_yyensure_buffer_stack(yyscanner);
+
+ /* This block is copied from libconfig_yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ yyg->yy_buffer_stack_top++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from libconfig_yy_switch_to_buffer. */
+ libconfig_yy_load_buffer_state(yyscanner );
+ yyg->yy_did_buffer_switch_on_eof = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ * @param yyscanner The scanner object.
+ */
+void libconfig_yypop_buffer_state (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ libconfig_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if (yyg->yy_buffer_stack_top > 0)
+ --yyg->yy_buffer_stack_top;
+
+ if (YY_CURRENT_BUFFER) {
+ libconfig_yy_load_buffer_state(yyscanner );
+ yyg->yy_did_buffer_switch_on_eof = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner)
+{
+ int num_to_alloc;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (!yyg->yy_buffer_stack) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)libconfig_yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ , yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in libconfig_yyensure_buffer_stack()" );
+
+ memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ yyg->yy_buffer_stack_max = num_to_alloc;
+ yyg->yy_buffer_stack_top = 0;
+ return;
+ }
+
+ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)libconfig_yyrealloc
+ (yyg->yy_buffer_stack,
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ , yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in libconfig_yyensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
+ yyg->yy_buffer_stack_max = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE libconfig_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) libconfig_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ libconfig_yy_switch_to_buffer(b ,yyscanner );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to libconfig_yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * libconfig_yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+{
+
+ return libconfig_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to libconfig_yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) libconfig_yyalloc(n ,yyscanner );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = libconfig_yy_scan_buffer(buf,n ,yyscanner);
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in libconfig_yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = yyg->yy_hold_char; \
+ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
+ yyg->yy_hold_char = *yyg->yy_c_buf_p; \
+ *yyg->yy_c_buf_p = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the user-defined data for this scanner.
+ * @param yyscanner The scanner object.
+ */
+YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyextra;
+}
+
+/** Get the current line number.
+ * @param yyscanner The scanner object.
+ */
+int libconfig_yyget_lineno (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+
+ return yylineno;
+}
+
+/** Get the current column number.
+ * @param yyscanner The scanner object.
+ */
+int libconfig_yyget_column (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+
+ return yycolumn;
+}
+
+/** Get the input stream.
+ * @param yyscanner The scanner object.
+ */
+FILE *libconfig_yyget_in (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyin;
+}
+
+/** Get the output stream.
+ * @param yyscanner The scanner object.
+ */
+FILE *libconfig_yyget_out (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyout;
+}
+
+/** Get the length of the current token.
+ * @param yyscanner The scanner object.
+ */
+int libconfig_yyget_leng (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyleng;
+}
+
+/** Get the current token.
+ * @param yyscanner The scanner object.
+ */
+
+char *libconfig_yyget_text (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yytext;
+}
+
+/** Set the user-defined data. This data is never touched by the scanner.
+ * @param user_defined The data to be associated with this scanner.
+ * @param yyscanner The scanner object.
+ */
+void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyextra = user_defined ;
+}
+
+/** Set the current line number.
+ * @param line_number
+ * @param yyscanner The scanner object.
+ */
+void libconfig_yyset_lineno (int line_number , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* lineno is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ yy_fatal_error( "libconfig_yyset_lineno called with no buffer" , yyscanner);
+
+ yylineno = line_number;
+}
+
+/** Set the current column.
+ * @param line_number
+ * @param yyscanner The scanner object.
+ */
+void libconfig_yyset_column (int column_no , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* column is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ yy_fatal_error( "libconfig_yyset_column called with no buffer" , yyscanner);
+
+ yycolumn = column_no;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * @param yyscanner The scanner object.
+ * @see libconfig_yy_switch_to_buffer
+ */
+void libconfig_yyset_in (FILE * in_str , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyin = in_str ;
+}
+
+void libconfig_yyset_out (FILE * out_str , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyout = out_str ;
+}
+
+int libconfig_yyget_debug (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yy_flex_debug;
+}
+
+void libconfig_yyset_debug (int bdebug , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yy_flex_debug = bdebug ;
+}
+
+/* Accessor methods for yylval and yylloc */
+
+YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yylval;
+}
+
+void libconfig_yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yylval = yylval_param;
+}
+
+/* User-visible API */
+
+/* libconfig_yylex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+
+int libconfig_yylex_init(yyscan_t* ptr_yy_globals)
+
+{
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) libconfig_yyalloc ( sizeof( struct yyguts_t ), NULL );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+/* libconfig_yylex_init_extra has the same functionality as libconfig_yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to libconfig_yyalloc in
+ * the yyextra field.
+ */
+
+int libconfig_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
+
+{
+ struct yyguts_t dummy_yyguts;
+
+ libconfig_yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) libconfig_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ libconfig_yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+static int yy_init_globals (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from libconfig_yylex_destroy(), so don't allocate here.
+ */
+
+ yyg->yy_buffer_stack = 0;
+ yyg->yy_buffer_stack_top = 0;
+ yyg->yy_buffer_stack_max = 0;
+ yyg->yy_c_buf_p = (char *) 0;
+ yyg->yy_init = 0;
+ yyg->yy_start = 0;
+
+ yyg->yy_start_stack_ptr = 0;
+ yyg->yy_start_stack_depth = 0;
+ yyg->yy_start_stack = NULL;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
+#else
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * libconfig_yylex_init()
+ */
+ return 0;
+}
+
+/* libconfig_yylex_destroy is for both reentrant and non-reentrant scanners. */
+int libconfig_yylex_destroy (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ libconfig_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ libconfig_yypop_buffer_state(yyscanner);
+ }
+
+ /* Destroy the stack itself. */
+ libconfig_yyfree(yyg->yy_buffer_stack ,yyscanner);
+ yyg->yy_buffer_stack = NULL;
+
+ /* Destroy the start condition stack. */
+ libconfig_yyfree(yyg->yy_start_stack ,yyscanner );
+ yyg->yy_start_stack = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * libconfig_yylex() is called, initialization will occur. */
+ yy_init_globals( yyscanner);
+
+ /* Destroy the main struct (reentrant only). */
+ libconfig_yyfree ( yyscanner , yyscanner );
+ yyscanner = NULL;
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *libconfig_yyalloc (yy_size_t size , yyscan_t yyscanner)
+{
+ return (void *) malloc( size );
+}
+
+void *libconfig_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void libconfig_yyfree (void * ptr , yyscan_t yyscanner)
+{
+ free( (char *) ptr ); /* see libconfig_yyrealloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 191 "scanner.l"
diff --git a/lib/scanner.h b/lib/scanner.h
new file mode 100644
index 0000000..baa6f77
--- /dev/null
+++ b/lib/scanner.h
@@ -0,0 +1,326 @@
+#ifndef libconfig_yyHEADER_H
+#define libconfig_yyHEADER_H 1
+#define libconfig_yyIN_HEADER 1
+
+#line 6 "scanner.h"
+
+#line 8 "scanner.h"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 33
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
+int libconfig_yylex_init (yyscan_t* scanner);
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+void libconfig_yyrestart (FILE *input_file ,yyscan_t yyscanner );
+void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
+void libconfig_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void libconfig_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
+void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
+void libconfig_yypop_buffer_state (yyscan_t yyscanner );
+
+YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+
+void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner );
+void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
+void libconfig_yyfree (void * ,yyscan_t yyscanner );
+
+#define libconfig_yywrap(n) 1
+#define YY_SKIP_YYWRAP
+
+#define yytext_ptr yytext_r
+
+#ifdef YY_HEADER_EXPORT_START_CONDITIONS
+#define INITIAL 0
+#define COMMENT 1
+
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int libconfig_yylex_destroy (yyscan_t yyscanner );
+
+int libconfig_yyget_debug (yyscan_t yyscanner );
+
+void libconfig_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+
+YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner );
+
+void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+
+FILE *libconfig_yyget_in (yyscan_t yyscanner );
+
+void libconfig_yyset_in (FILE * in_str ,yyscan_t yyscanner );
+
+FILE *libconfig_yyget_out (yyscan_t yyscanner );
+
+void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner );
+
+int libconfig_yyget_leng (yyscan_t yyscanner );
+
+char *libconfig_yyget_text (yyscan_t yyscanner );
+
+int libconfig_yyget_lineno (yyscan_t yyscanner );
+
+void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner );
+
+YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner );
+
+void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int libconfig_yywrap (yyscan_t yyscanner );
+#else
+extern int libconfig_yywrap (yyscan_t yyscanner );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+#endif
+
+#ifndef YY_NO_INPUT
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int libconfig_yylex (YYSTYPE * yylval_param ,yyscan_t yyscanner);
+
+#define YY_DECL int libconfig_yylex (YYSTYPE * yylval_param , yyscan_t yyscanner)
+#endif /* !YY_DECL */
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+
+#line 130 "scanner.l"
+
+#line 325 "scanner.h"
+#undef libconfig_yyIN_HEADER
+#endif /* libconfig_yyHEADER_H */
diff --git a/lib/scanner.l b/lib/scanner.l
new file mode 100644
index 0000000..2703eb6
--- /dev/null
+++ b/lib/scanner.l
@@ -0,0 +1,190 @@
+/* -*- mode: C -*- */
+/* --------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+%option nounistd
+%option reentrant
+%option noyywrap
+%option yylineno
+%option nounput
+%option bison-bridge
+%option header-file="scanner.h"
+%option outfile="lex.yy.c"
+%option extra-type="struct scan_context *"
+
+%{
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "grammar.h"
+#include "wincompat.h"
+#include "parsectx.h"
+#include "scanctx.h"
+
+#define YY_NO_INPUT // Suppress generation of useless input() function
+
+static unsigned long long fromhex(const char *s)
+{
+#ifdef __MINGW32__
+
+ /* MinGW's strtoull() seems to be broken; it only returns the lower
+ * 32 bits...
+ */
+
+ const char *p = s;
+ unsigned long long val = 0;
+
+ if(*p != '0')
+ return(0);
+
+ ++p;
+
+ if(*p != 'x' && *p != 'X')
+ return(0);
+
+ for(++p; isxdigit(*p); ++p)
+ {
+ val <<= 4;
+ val |= ((*p < 'A') ? (*p & 0xF) : (9 + (*p & 0x7)));
+ }
+
+ return(val);
+
+#else /* ! __MINGW32__ */
+
+ return(strtoull(s, NULL, 16));
+
+#endif /* __MINGW32__ */
+}
+
+%}
+
+true [Tt][Rr][Uu][Ee]
+false [Ff][Aa][Ll][Ss][Ee]
+name [A-Za-z\*][-A-Za-z0-9_\*]*
+integer [-+]?[0-9]+
+integer64 [-+]?[0-9]+L(L)?
+hex 0[Xx][0-9A-Fa-f]+
+hex64 0[Xx][0-9A-Fa-f]+L(L)?
+hexchar \\[Xx][0-9A-Fa-f]{2}
+float ([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]?([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)
+comment (#|\/\/).*$
+include_open ^[ \t]*@include[ \t]+\"
+
+%x COMMENT STRING INCLUDE
+
+%%
+
+\/\* { BEGIN COMMENT; }
+<COMMENT>\*\/ { BEGIN INITIAL; }
+<COMMENT>. { /* ignore */ }
+<COMMENT>\n { /* ignore */ }
+
+\" { BEGIN STRING; }
+<STRING>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
+<STRING>\\n { scanctx_append_string(yyextra, "\n"); }
+<STRING>\\r { scanctx_append_string(yyextra, "\r"); }
+<STRING>\\t { scanctx_append_string(yyextra, "\t"); }
+<STRING>\\f { scanctx_append_string(yyextra, "\f"); }
+<STRING>\\\\ { scanctx_append_string(yyextra, "\\"); }
+<STRING>\\\" { scanctx_append_string(yyextra, "\""); }
+<STRING>{hexchar} {
+ char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF),
+ 0 };
+ scanctx_append_string(yyextra, c);
+ }
+<STRING>\" {
+ yylval->sval = scanctx_take_string(yyextra);
+ BEGIN INITIAL;
+ return(TOK_STRING);
+ }
+
+{include_open} { BEGIN INCLUDE; }
+<INCLUDE>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
+<INCLUDE>\\\\ { scanctx_append_string(yyextra, "\\"); }
+<INCLUDE>\\\" { scanctx_append_string(yyextra, "\""); }
+<INCLUDE>\" {
+ const char *error;
+ FILE *fp = scanctx_push_include(yyextra,
+ (void *)YY_CURRENT_BUFFER,
+ &error);
+ if(fp)
+ {
+ yyin = fp;
+ yy_switch_to_buffer(
+ yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner),
+ yyscanner);
+ }
+ else
+ {
+ yyextra->config->error_text = error;
+ yyextra->config->error_file = scanctx_current_filename(
+ yyextra);
+ yyextra->config->error_line = libconfig_yyget_lineno(
+ yyscanner);
+ return TOK_ERROR;
+ }
+ BEGIN INITIAL;
+ }
+
+\n|\r|\f { /* ignore */ }
+[ \t]+ { /* ignore */ }
+
+\=|\: { return(TOK_EQUALS); }
+, { return(TOK_COMMA); }
+\{ { return(TOK_GROUP_START); }
+\} { return(TOK_GROUP_END); }
+{true} { yylval->ival = 1; return(TOK_BOOLEAN); }
+{false} { yylval->ival = 0; return(TOK_BOOLEAN); }
+{name} { yylval->sval = yytext; return(TOK_NAME); }
+{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); }
+{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
+{hex} {
+ yylval->ival = strtoul(yytext, NULL, 16);
+ return(TOK_HEX);
+ }
+{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
+\[ { return(TOK_ARRAY_START); }
+\] { return(TOK_ARRAY_END); }
+\( { return(TOK_LIST_START); }
+\) { return(TOK_LIST_END); }
+; { return(TOK_SEMICOLON); }
+{comment} { /* ignore */ }
+. { return(TOK_GARBAGE); }
+
+<<EOF>> {
+ YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
+ yyextra);
+ if(buf)
+ {
+ yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
+ yy_switch_to_buffer(buf, yyscanner);
+ }
+ else
+ yyterminate();
+ }
diff --git a/lib/strbuf.c b/lib/strbuf.c
new file mode 100644
index 0000000..f7f48d3
--- /dev/null
+++ b/lib/strbuf.c
@@ -0,0 +1,58 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#include "strbuf.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#define STRING_BLOCK_SIZE 64
+
+/* ------------------------------------------------------------------------- */
+
+char *strbuf_release(strbuf_t *buf)
+{
+ char *r = buf->string;
+ memset(buf, 0, sizeof(strbuf_t));
+ return(r);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void strbuf_append(strbuf_t *buf, const char *text)
+{
+ static const size_t mask = ~(STRING_BLOCK_SIZE - 1);
+ size_t len = strlen(text);
+ size_t newlen = buf->length + len + 1; /* add 1 for NUL */
+
+ if(newlen > buf->capacity)
+ {
+ buf->capacity = (newlen + (STRING_BLOCK_SIZE - 1)) & mask;
+ buf->string = (char *)realloc(buf->string, buf->capacity);
+ }
+
+ strcpy(buf->string + buf->length, text);
+ buf->length += len;
+}
+
+/* ------------------------------------------------------------------------- */
+/* eof */
diff --git a/lib/strbuf.h b/lib/strbuf.h
new file mode 100644
index 0000000..62cd782
--- /dev/null
+++ b/lib/strbuf.h
@@ -0,0 +1,40 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_strbuf_h
+#define __libconfig_strbuf_h
+
+#include <string.h>
+#include <sys/types.h>
+
+typedef struct
+{
+ char *string;
+ size_t length;
+ size_t capacity;
+} strbuf_t;
+
+char *strbuf_release(strbuf_t *buf);
+
+void strbuf_append(strbuf_t *buf, const char *text);
+
+#endif /* __libconfig_strbuf_h */
diff --git a/lib/wincompat.h b/lib/wincompat.h
new file mode 100644
index 0000000..23d7379
--- /dev/null
+++ b/lib/wincompat.h
@@ -0,0 +1,90 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __wincompat_h
+#define __wincompat_h
+
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define snprintf _snprintf
+
+#ifndef __MINGW32__
+#define atoll _atoi64
+#define strtoull _strtoui64
+#endif /* __MINGW32__ */
+
+#endif
+
+#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
+ || defined(__MINGW32__))
+
+/* Why does gcc on MinGW use the Visual C++ style format directives
+ * for 64-bit integers? Inquiring minds want to know....
+ */
+
+#define INT64_FMT "%I64d"
+#define UINT64_FMT "%I64u"
+
+#define INT64_HEX_FMT "%I64X"
+
+#define FILE_SEPARATOR "\\"
+
+#else /* defined(WIN32) || defined(__MINGW32__) */
+
+#define INT64_FMT "%lld"
+#define UINT64_FMT "%llu"
+
+#define INT64_HEX_FMT "%llX"
+
+#define FILE_SEPARATOR "/"
+
+#endif /* defined(WIN32) || defined(__MINGW32__) */
+
+#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
+ && ! defined(__MINGW32__)
+
+#define INT64_CONST(I) (I ## i64)
+#define UINT64_CONST(I) (I ## Ui64)
+
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+
+#else /* defined(WIN32) && ! defined(__MINGW32__) */
+
+#define INT64_CONST(I) (I ## LL)
+#define UINT64_CONST(I) (I ## ULL)
+
+#endif /* defined(WIN32) && ! defined(__MINGW32__) */
+
+#endif /* __wincompat_h */