Index: /tags/2.0-rc2/external/SConscript
===================================================================
--- /tags/2.0-rc2/external/SConscript (revision 1299)
+++ /tags/2.0-rc2/external/SConscript (revision 1299)
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2007-2008 Arnold Krille
+# Copyright (C) 2007-2008 Pieter Palmers
+#
+# This file is part of FFADO
+# FFADO = Free Firewire (pro-)audio drivers for linux
+#
+# FFADO is based upon FreeBoB.
+#
+# 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 2 of the License, or
+# (at your option) version 3 of the License.
+#
+# 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 .
+#
+
+Import( 'env' )
+
+env = env.Clone()
+
+env.SConscript( dirs=["dbus", "libconfig"], exports="env" )
+
Index: /tags/2.0-rc2/external/libconfig/libconfig.html
===================================================================
--- /tags/2.0-rc2/external/libconfig/libconfig.html (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/libconfig.html (revision 1304)
@@ -0,0 +1,2527 @@
+
+
+libconfig
+
+
+
+
+
+
+
+
+
+libconfig
+
+A Library For Processing Structured Configuration Files
+Version 1.3
+6 April 2008
+
+Mark A. Lindner
+
+
+
+
+
+
+
+
+libconfig
+
+
+
+
+
+
+
+
+1 Introduction
+
+Libconfig is a library for reading, manipulating, and writing
+structured configuration files. The library features a fully
+reentrant parser and includes bindings for both the C and C++
+programming languages.
+
+
The library runs on modern POSIX-compilant systems, such as Linux,
+Solaris, and Mac OS X (Darwin), as well as on Microsoft Windows
+2000/XP and later (with either Microsoft Visual Studio 2005 or later,
+or the GNU toolchain via the MinGW environment).
+
+
+
+
+1.1 Why Another Configuration File Library?
+
+There are several open-source configuration file libraries available
+as of this writing. This library was written because each of those
+libraries falls short in one or more ways. The main features of
+libconfig that set it apart from the other libraries are:
+
+
+A fully reentrant parser. Independent configurations can be parsed in concurrent threads at the same time.
+
+ Both C and C++ bindings, as well as hooks to allow for the creation of wrappers in other languages.
+
+ A simple, structured configuration file format that is more
+readable and compact than XML and more flexible than the obsolete but
+prevalent Windows “INI” file format.
+
+ A low-footprint implementation (just 38K for the C library and 66K for the C++ library) that is suitable for memory-constrained systems.
+
+ Proper documentation.
+
+
+
+
+
+
+1.2 Using the Library from a C Program
+
+To use the library from C code, include the following preprocessor
+directive in your source files:
+
+
+
+
+ #include <libconfig.h>
+
+
+
+
+
+To link with the library, specify `-lconfig ' as an argument to the
+linker.
+
+
+
+
+1.3 Using the Library from a C++ Program
+
+To use the library from C++, include the following preprocessor
+directive in your source files:
+
+
+
+
+ #include <libconfig.h++>
+
+
+
+
+
+Or, alternatively:
+
+
+
+
+ #include <libconfig.hh>
+
+
+
+
+
+The C++ API classes are defined in the namespace `libconfig ', hence the
+following statement may optionally be used:
+
+
+
+
+ using namespace libconfig;
+
+
+
+
+
+To link with the library, specify `-lconfig++ ' as an argument to
+the linker.
+
+
+
+
+1.4 Multithreading Issues
+
+Libconfig is fully reentrant ; the functions in the library
+do not make use of global variables and do not maintain state between
+successive calls. Therefore two independent configurations may be safely
+manipulated concurrently by two distinct threads.
+
+
Libconfig is not thread-safe . The library is not aware of
+the presence of threads and knows nothing about the host system's
+threading model. Therefore, if an instance of a configuration is to be
+accessed from multiple threads, it must be suitably protected by
+synchronization mechanisms like read-write locks or mutexes; the
+standard rules for safe multithreaded access to shared data must be
+observed.
+
+
Libconfig is not async-safe . Calls should not be made into
+the library from signal handlers, because some of the C library
+routines that it uses may not be async-safe.
+
+
Libconfig is not guaranteed to be cancel-safe . Since it is
+not aware of the host system's threading model, the library does not
+contain any thread cancellation points. In most cases this will not be
+an issue for multithreaded programs. However, be aware that some of
+the routines in the library (namely those that read/write
+configurations from/to files or streams) perform I/O using C library
+routines which may potentially block; whether these C library routines
+are cancel-safe or not depends on the host system.
+
+
+
+
+1.5 Compiling Using pkg-config
+
+On UNIX systems you can use the pkg-config utility (version 0.20
+or later) to automatically select the appropriate compiler and linker
+switches for libconfig . Ensure that the environment variable
+`PKG_CONFIG_PATH ' contains the absolute path to the
+lib/pkgconfig subdirectory of the libconfig installation. Then,
+you can link C programs with libconfig as follows:
+
+
gcc `pkg-config --cflags libconfig` myprogram.c -o myprogram \
+ `pkg-config --libs libconfig`
+
+
+
+
+
+And similarly, for C++ programs:
+
+ g++ `pkg-config --cflags libconfig++` myprogram.cpp -o myprogram \
+ `pkg-config --libs libconfig++`
+
+
+
+
+Note the backticks in the above examples.
+
+
+
+
+
+
+2 Configuration Files
+
+Libconfig supports structured, hierarchical configurations. These
+configurations can be read from and written to files and manipulated
+in memory.
+
+
A configuration consists of a group of settings , which
+associate names with values. A value can be one of the
+following:
+
+
+A scalar value : integer, 64-bit integer, floating-point number, boolean,
+or string
+ An array , which is a sequence of scalar values, all of which must have the same type
+ A group , which is a collection of settings
+ A list , which is a sequence of values of any type, including other lists
+
+
+ Consider the following configuration file for a hypothetical GUI
+application, which illustrates all of the elements of the configuration
+file grammar.
+
+
+
+
+
+ # Example application configuration file
+
+ version = "1.0";
+
+ application:
+ {
+ window:
+ {
+ title = "My Application";
+ size = { w = 640; h = 480; };
+ pos = { x = 350; y = 250; };
+ };
+
+ list = ( ( "abc", 123, true ), 1.234, ( /* an empty list */) );
+
+ books = ( { title = "Treasure Island";
+ author = "Robert Louis Stevenson";
+ price = 29.95;
+ qty = 5; },
+ { title = "Snow Crash";
+ author = "Neal Stephenson";
+ price = 9.99;
+ qty = 8; } );
+
+ misc:
+ {
+ pi = 3.141592654;
+ bigint = 9223372036854775807L;
+ columns = [ "Last Name", "First Name", "MI" ];
+ bitmask = 0x1FC3;
+ };
+ };
+
+
+
+
+
+
+
+ Settings can be uniquely identified within the configuration by a
+path . The path is a dot-separated sequence of names, beginning
+at a top-level group and ending at the setting itself. Each name in
+the path is either the name of a setting; if the setting has no name
+because it is an element in a list or array, an integer index in
+square brackets can be used as the name.
+
+ For example, in our hypothetical configuration file, the path to the
+x
setting is application.window.pos.x
; the path to the
+version
setting is simply version
; and the path to the
+title
setting of the second book in the books
list is
+application.books.[1].title
.
+
+
The datatype of a value is determined from the format of the value
+itself. If the value is enclosed in double quotes, it is treated as a
+string. If it looks like an integer or floating point number, it is
+treated as such. If it is one of the values TRUE
, true
,
+FALSE
, or false
(or any other mixed-case version of
+those tokens, e.g., True
or FaLsE
), it is treated as a
+boolean. If it consists of a comma-separated list of values enclosed
+in square brackets, it is treated as an array. And if it consists of a
+comma-separated list of values enclosed in parentheses, it is treated
+as a list. Any value which does not meet any of these conditions is
+considered invalid and results in a parse error.
+
+
All names are case-sensitive. They may consist only of alphanumeric
+characters, dashes (`- '), underscores (`_ '), and asterisks
+(`* '), and must begin with a letter or asterisk. No other
+characters are allowed.
+
+
In C and C++, integer, 64-bit integer, floating point, and string
+values are mapped to the types long
, long long
,
+double
, and const char *
, respectively. The boolean type
+is mapped to int
in C and bool
in C++.
+
+
The following sections describe the elements of the configuration file
+grammar in additional detail.
+
+
+
+
+2.1 Settings
+
+A setting has the form:
+
+
name = value ;
+
+
or:
+
+
name : value ;
+
+
The trailing semicolon is required. Whitespace is not significant.
+
+
The value may be a scalar value, an array, a group, or a list.
+
+
+
+
+2.2 Groups
+
+A group has the form:
+
+
{
+ settings ...
+}
+
+
Groups can contain any number of settings, but each setting must have
+a unique name within the group.
+
+
+
+
+2.3 Arrays
+
+An array has the form:
+
+
[ value , value ... ]
+
+
An array may have zero or more elements, but the elements must all be
+scalar values of the same type.
+
+
+
+
+2.4 Lists
+
+A list has the form:
+
+
( value , value ... )
+
+
A list may have zero or more elements, each of which can be a scalar
+value, an array, a group, or another list.
+
+
+
+
+2.5 Integer Values
+
+Integers can be represented in one of two ways: as a series of one or
+more decimal digits (`0 ' - `9 '), with an optional leading
+sign character (`+ ' or `- '); or as a hexadecimal value
+consisting of the characters `0x ' followed by a series of one or
+more hexadecimal digits (`0 ' - `9 ', `A ' - `F ',
+`a ' - `f ').
+
+
+
+
+2.6 64-bit Integer Values
+
+Long long (64-bit) integers are represented identically to integers,
+except that an 'L' character is appended to indicate a 64-bit
+value. For example, `0L ' indicates a 64-bit integer value 0.
+
+
+
+
+2.7 Floating Point Values
+
+Floating point values consist of a series of one or more digits, one
+decimal point, an optional leading sign character (`+ ' or
+`- '), and an optional exponent. An exponent consists of the
+letter `E ' or `e ', an optional sign character, and a series
+of one or more digits.
+
+
+
+
+2.8 Boolean Values
+
+Boolean values may have one of the following values: `true ',
+`false ', or any mixed-case variation thereof.
+
+
+
+
+2.9 String Values
+
+String values consist of arbitrary text delimited by double
+quotes. Literal double quotes can be escaped by preceding them with a
+backslash: `\" '. The escape sequences `\\ ', `\f ',
+`\n ', `\r ', and `\t ' are also recognized, and have the
+usual meaning. No other escape sequences are currently supported.
+
+
Adjacent strings are automatically concatenated, as in C/C++ source
+code. This is useful for formatting very long strings as sequences of
+shorter strings. For example, the following constructs are equivalent:
+
+
+"The quick brown fox jumped over the lazy dog."
+
+ "The quick brown fox"
+" jumped over the lazy dog."
+
+ "The quick" /* comment */ " brown fox " // another comment
+"jumped over the lazy dog."
+
+
+
+
+
+
+2.10 Comments
+
+Three types of comments are allowed within a configuration:
+
+
+Script-style comments. All text beginning with a `# ' character
+to the end of the line is ignored.
+
+ C-style comments. All text, including line breaks, between a starting
+`/* ' sequence and an ending `*/ ' sequence is ignored.
+
+ C++-style comments. All text beginning with a `// ' sequence to the
+end of the line is ignored.
+
+
+
+ As expected, comment delimiters appearing within quoted strings are
+treated as literal text.
+
+
Comments are ignored when the configuration is read in, so they are
+not treated as part of the configuration. Therefore if the
+configuration is written back out to a stream, any comments that were
+present in the original configuration will be lost.
+
+
+
+
+3 The C API
+
+ This chapter describes the C library API. The type config_t
+represents a configuration, and the type config_setting_t represents
+a configuration setting.
+
+
The boolean values CONFIG_TRUE
and CONFIG_FALSE
are
+macros defined as (1)
and (0)
, respectively.
+
+
+— Function: void
config_init (
config_t * config )
+— Function: void
config_destroy (
config_t * config )
+
+These functions initialize and destroy the configuration object config .
+
+
config_init()
initializes config as a new, empty
+configuration.
+
+
config_destroy()
destroys the configuration config ,
+deallocating all memory associated with the configuration, but not
+including the config_t structure itself.
+
+
+
+
+— Function: int
config_read (
config_t * config, FILE * stream )
+
+This function reads and parses a configuration from the given
+stream into the configuration object config . It returns
+CONFIG_TRUE
on success, or CONFIG_FALSE
on failure; the
+config_error_text()
and config_error_line()
+functions, described below, can be used to obtain information about the
+error.
+
+
+
+
+— Function: int
config_read_file (
config_t * config, const char * filename )
+
+This function reads and parses a configuration from the file named
+filename into the configuration object config . It returns
+CONFIG_TRUE
on success, or CONFIG_FALSE
on failure; the
+config_error_text()
and config_error_line()
functions,
+described below, can be used to obtain information about the error.
+
+
+
+
+— Function: void
config_write (
const config_t * config, FILE * stream )
+
+This function writes the configuration config to the given
+stream .
+
+
+
+
+— Function: int
config_write_file (
config_t * config, const char * filename )
+
+This function writes the configuration config to the file named
+filename . It returns CONFIG_TRUE
on success, or
+CONFIG_FALSE
on failure.
+
+
+
+
+— Function: const char *
config_error_text (
const config_t * config )
+— Function: int
config_error_line (
const config_t * config )
+
+These functions, which are implemented as macros, return the text and
+line number of the parse error, if one occurred during a call to
+config_read()
or config_read_file()
. Storage for the
+string returned by config_error_text()
is managed by the
+library and released automatically when the configuration is
+destroyed; the string must not be freed by the caller.
+
+
+
+
+— Function: void
config_set_auto_convert (
config_t *config, int flag )
+— Function: int
config_get_auto_convert (
const config_t *config )
+
+config_set_auto_convert()
enables number auto-conversion for
+the configuration config if flag is non-zero, and disables
+it otherwise. When this feature is enabled, an attempt to retrieve a
+floating point setting's value into an integer (or vice versa), or
+store an integer to a floating point setting's value (or vice versa)
+will cause the library to silently perform the necessary conversion
+(possibly leading to loss of data), rather than reporting failure. By
+default this feature is disabled.
+
+
config_get_auto_convert()
returns CONFIG_TRUE
if number
+auto-conversion is currently enabled for config ; otherwise it
+returns CONFIG_FALSE
.
+
+
+
+
+— Function: long
config_lookup_int (
const config_t * config, const char * path )
+— Function: long long
config_lookup_int64 (
const config_t * config, const char * path )
+— Function: double
config_lookup_float (
const config_t * config, const char * path )
+— Function: int
config_lookup_bool (
const config_t * config, const char * path )
+— Function: const char *
config_lookup_string (
const config_t * config, const char * path )
+
+These functions locate the setting in the configuration config
+specified by the path path . They return the value of the setting
+on success, or a 0 or NULL
value if the setting was not found or
+if the type of the value did not match the type requested.
+
+
Storage for the string returned by config_lookup_string()
is
+managed by the library and released automatically when the setting is
+destroyed or when the setting's value is changed; the string must not
+be freed by the caller.
+
+
+
+
+— Function: config_setting_t *
config_lookup (
const config_t * config, const char * path )
+
+This function locates the setting in the configuration config
+specified by the path path . It returns a pointer to the
+config_setting_t
structure on success, or NULL
if the
+setting was not found.
+
+
+
+
+— Function: long
config_setting_get_int (
const config_setting_t * setting )
+— Function: long long
config_setting_get_int64 (
const config_setting_t * setting )
+— Function: double
config_setting_get_float (
const config_setting_t * setting )
+— Function: int
config_setting_get_bool (
const config_setting_t * setting )
+— Function: const char *
config_setting_get_string (
const config_setting_t * setting )
+
+These functions return the value of the given setting . If the
+type of the setting does not match the type requested, a 0 or
+NULL
value is returned. Storage for the string returned by
+config_setting_get_string()
is managed by the library and
+released automatically when the setting is destroyed or when the
+setting's value is changed; the string must not be freed by the
+caller.
+
+
+
+
+— Function: int
config_setting_set_int (
config_setting_t * setting, long value )
+— Function: int
config_setting_set_int64 (
config_setting_t * setting, long long value )
+— Function: int
config_setting_set_float (
config_setting_t * setting, double value )
+— Function: int
config_setting_set_bool (
config_setting_t * setting, int value )
+— Function: int
config_setting_set_string (
config_setting_t * setting, const char * value )
+
+These functions set the value of the given setting to
+value . On success, they return CONFIG_TRUE
. If
+the setting does not match the type of the value, they return
+CONFIG_FALSE
. config_setting_set_string()
makes a copy
+of the passed string value , so it may be subsequently freed or
+modified by the caller without affecting the value of the setting.
+
+
+
+
+— Function: short
config_setting_get_format (
config_setting_t * setting )
+— Function: int
config_setting_set_format (
config_setting_t * setting, short format )
+
+These functions get and set the external format for the setting setting .
+
+
+The format must be one of the constants
+CONFIG_FORMAT_DEFAULT
or CONFIG_FORMAT_HEX
. All settings
+support the CONFIG_FORMAT_DEFAULT
format. The
+CONFIG_FORMAT_HEX
format specifies hexadecimal formatting for
+integer values, and hence only applies to settings of type
+CONFIG_TYPE_INT
and CONFIG_TYPE_INT64
. If format
+is invalid for the given setting, it is ignored.
+
+
config_setting_set_format()
returns CONFIG_TRUE
on
+success and CONFIG_FALSE
on failure.
+
+
+
+
+— Function: config_setting_t *
config_setting_get_member (
config_setting_t * setting, const char * name )
+
+This function fetches the child setting named name from the group
+setting . It returns the requested setting on success, or
+NULL
if the setting was not found or if setting is not a
+group.
+
+
+
+
+— Function: config_setting_t *
config_setting_get_elem (
const config_setting_t * setting, unsigned int idx )
+
+This function fetches the element at the given index idx in the
+setting setting , which must be an array, list, or group. It returns the
+requested setting on success, or NULL
if idx is out of
+range or if setting is not an array, list, or group.
+
+
+
+
+— Function: long
config_setting_get_int_elem (
const config_setting_t * setting, int idx )
+— Function: long long
config_setting_get_int64_elem (
const config_setting_t * setting, int idx )
+— Function: double
config_setting_get_float_elem (
const config_setting_t * setting, int idx )
+— Function: int
config_setting_get_bool_elem (
const config_setting_t * setting, int idx )
+— Function: const char *
config_setting_get_string_elem (
const config_setting_t * setting, int idx )
+
+These functions return the value at the specified index idx in the
+setting setting . If the setting is not an array or list, or if
+the type of the element does not match the type requested, or if
+idx is out of range, they return 0 or NULL
. Storage for
+the string returned by config_setting_get_string_elem()
is
+managed by the library and released automatically when the setting is
+destroyed or when its value is changed; the string must not be freed
+by the caller.
+
+
+
+— Function: config_setting_t *
config_setting_set_int_elem (
config_setting_t * setting, int idx, long value )
+— Function: config_setting_t *
config_setting_set_int64_elem (
config_setting_t * setting, int idx, long long value )
+— Function: config_setting_t *
config_setting_set_float_elem (
config_setting_t * setting, int idx, double value )
+— Function: config_setting_t *
config_setting_set_bool_elem (
config_setting_t * setting, int idx, int value )
+— Function: config_setting_t *
config_setting_set_string_elem (
config_setting_t * setting, int idx, const char * value )
+
+These functions set the value at the specified index idx in the
+setting setting to value . If idx is negative, a
+new element is added to the end of the array or list. On success,
+these functions return a pointer to the setting representing the
+element. If the setting is not an array or list, or if the setting is
+an array and the type of the array does not match the type of the
+value, or if idx is out of range, they return
+NULL
. config_setting_set_string_elem()
makes a copy of
+the passed string value , so it may be subsequently freed or
+modified by the caller without affecting the value of the setting.
+
+
+
+— Function: config_setting_t *
config_setting_add (
config_setting_t * parent, const char * name, int type )
+
+This function adds a new child setting or element to the setting
+parent , which must be a group, array, or list. If parent
+is an array or list, the name parameter is ignored and may be
+NULL
.
+
+
The function returns the new setting on success, or NULL
if
+parent is not a group, array, or list; or if there is already a
+child setting of parent named name ; or if type is
+invalid.
+
+
+
+— Function: int
config_setting_remove (
config_setting_t * parent, const char * name )
+
+This function removes and destroys the setting named name from
+the parent setting parent , which must be a group. Any child
+settings of the setting are recursively destroyed as well.
+
+
The function returns CONFIG_TRUE
on success. If parent is
+not a group, or if it has no setting with the given name, it returns
+CONFIG_FALSE
.
+
+
+
+
+— Function: int
config_setting_remove_elem (
config_setting_t * parent, unsigned int idx )
+
+This function removes the child setting at the given index idx from
+the setting parent , which must be a group, list, or array. Any
+child settings of the removed setting are recursively destroyed as
+well.
+
+
The function returns CONFIG_TRUE
on success. If parent is
+not a group, list, or array, or if idx is out of range, it returns
+CONFIG_FALSE
.
+
+
+
+
+— Function: config_setting_t *
config_root_setting (
const config_t * config )
+
+This function returns the root setting for the configuration
+config . The root setting is a group.
+
+
+
+
+— Function: const char *
config_setting_name (
const config_setting_t * setting )
+
+This function returns the name of the given setting , or
+NULL
if the setting has no name. Storage for the returned
+string is managed by the library and released automatically when the
+setting is destroyed; the string must not be freed by the caller.
+
+
+
+
+— Function: config_setting_t *
config_setting_parent (
const config_setting_t * setting )
+
+This function returns the parent setting of the given setting ,
+or NULL
if setting is the root setting.
+
+
+
+
+— Function: int
config_setting_is_root (
const config_setting_t * setting )
+
+This function returns CONFIG_TRUE
if the given setting is
+the root setting, and CONFIG_FALSE
otherwise.
+
+
+
+
+— Function: int
config_setting_index (
const config_setting_t * setting )
+
+This function returns the index of the given setting within its
+parent setting. If setting is the root setting, this function
+returns -1.
+
+
+
+
+— Function: int
config_setting_length (
const config_setting_t * setting )
+
+This function returns the number of settings in a group, or the number of
+elements in a list or array. For other types of settings, it returns
+0.
+
+
+
+
+— Function: int
config_setting_type (
const config_setting_t * setting )
+
+This function returns the type of the given setting . The return
+value is one of the constants
+CONFIG_TYPE_INT
, CONFIG_TYPE_INT64
, CONFIG_TYPE_FLOAT
,
+CONFIG_TYPE_STRING
, CONFIG_TYPE_BOOL
,
+CONFIG_TYPE_ARRAY
, CONFIG_TYPE_LIST
, or CONFIG_TYPE_GROUP
.
+
+
+
+
+— Function: int
config_setting_is_group (
const config_setting_t * setting )
+— Function: int
config_setting_is_array (
const config_setting_t * setting )
+— Function: int
config_setting_is_list (
const config_setting_t * setting )
+
+These convenience functions, which are implemented as macros, test if
+the setting setting is of a given type. They return
+CONFIG_TRUE
or CONFIG_FALSE
.
+
+
+
+
+— Function: int
config_setting_is_aggregate (
const config_setting_t * setting )
+— Function: int
config_setting_is_scalar (
const config_setting_t * setting )
+— Function: int
config_setting_is_number (
const config_setting_t * setting )
+
+These convenience functions, which are implemented as macros, test if
+the setting setting is of an aggregate type (a group, array, or
+list), of a scalar type (integer, 64-bit integer, floating point,
+boolean, or string), and of a number (integer, 64-bit integer, or
+floating point), respectively. They return CONFIG_TRUE
or
+CONFIG_FALSE
.
+
+
+
+
+— Function: unsigned int
config_setting_source_line (
const config_setting_t * setting )
+
+This function returns the line number of the configuration file or
+stream at which the setting setting was parsed. This information
+is useful for reporting application-level errors. If the setting was
+not read from a file or stream, or if the line number is otherwise
+unavailable, the function returns 0.
+
+
+
+
+— Function: void
config_setting_set_hook (
config_setting_t * setting, void * hook )
+— Function: void *
config_setting_get_hook (
const config_setting_t * setting )
+
+These functions make it possible to attach arbitrary data to each
+setting structure, for instance a “wrapper” or “peer” object written in
+another programming language. The destructor function, if one has been
+supplied via a call to config_set_destructor()
, will be called
+by the library to dispose of this data when the setting itself is
+destroyed. There is no default destructor.
+
+
+
+
+— Function: void
config_set_destructor (
config_t * config, void (* destructor)(void *) )
+
+This function assigns the destructor function destructor for the
+configuration config . This function accepts a single void
+*
argument and has no return value. See
+config_setting_set_hook()
above for more information.
+
+
+
+
+
+
+4 The C++ API
+
+ This chapter describes the C++ library API. The class Config
+represents a configuration, and the class Setting
represents a
+configuration setting. Note that by design, neither of these classes
+provides a public copy constructor or assignment operator. Therefore,
+instances of these classes may only be passed between functions via
+references or pointers.
+
+
The library defines a group of exceptions, all of which extend the
+common base exception ConfigException
.
+
+
A SettingTypeException
is thrown when the type of a setting's
+value does not match the type requested.
+
+
A SettingNotFoundException
is thrown when a setting is not found.
+
+
A SettingNameException
is thrown when an attempt is made to add
+a new setting with a non-unique or invalid name.
+
+
A ParseException
is thrown when a parse error occurs while
+reading a configuration from a stream.
+
+
A FileIOException
is thrown when an I/O error occurs while
+reading/writing a configuration from/to a file.
+
+
The remainder of this chapter describes the methods for manipulating
+configurations and configuration settings.
+
+
+— Method on Config:
Config ()
+— Method on Config:
~Config ()
+
+These methods create and destroy Config
objects.
+
+
+
+
+— Method on Config: void
read (
FILE * stream )
+— Method on Config: void
write (
FILE * stream )
+
+The read()
method reads and parses a configuration from the given
+stream . A ParseException
is thrown if a parse error occurs.
+
+
The write()
method writes the configuration to the given stream .
+
+
+
+
+— Method on Config: void
readFile (
const char * filename )
+— Method on Config: void
writeFile (
const char * filename )
+
+The readFile()
method reads and parses a configuration from the file
+named filename . A ParseException
is thrown if a parse error occurs. A
+FileIOException
is thrown if the file cannot be read.
+
+
The writeFile()
method writes the configuration to the file
+named filename . A FileIOException
is thrown if the file cannot
+be written.
+
+
+
+
+— Method on ParseException: const char *
getError ()
+— Method on ParseException: int
getLine ()
+
+If a call to readFile()
or read()
resulted in a
+ParseException
, these methods can be called on the exception
+object to obtain the text and line number of the parse error. Storage
+for the string returned by getError()
is managed by the
+library; the string must not be freed by the caller.
+
+
+
+
+— Method on Config: void
setAutoConvert (
bool flag )
+— Method on Config: bool
getAutoConvert ()
+
+setAutoConvert()
enables number auto-conversion for the
+configuration if flag is true
, and disables it
+otherwise. When this feature is enabled, an attempt to assign a
+floating point setting to an integer (or vice versa), or
+assign an integer to a floating point setting (or vice versa) will
+cause the library to silently perform the necessary conversion
+(possibly leading to loss of data), rather than throwing a
+SettingTypeException
. By default this feature is disabled.
+
+
getAutoConvert()
returns true
if number auto-conversion
+is currently enabled for the configuration; otherwise it returns
+false
.
+
+
+
+
+— Method on Config: Setting &
getRoot ()
+
+This method returns the root setting for the configuration, which is a group.
+
+
+
+
+— Method on Config: Setting &
lookup (
const std::string &path )
+— Method on Config: Setting &
lookup (
const char * path )
+
+These methods locate the setting specified by the path path . If
+the requested setting is not found, a SettingNotFoundException
is
+thrown.
+
+
+
+
+— Method on Config: bool
exists (
const std::string &path )
+— Method on Config: bool
exists (
const char *path )
+
+These methods test if a setting with the given path exists in
+the configuration. They return true
if the setting exists, and
+false otherwise. These methods do not throw exceptions.
+
+
+
+
+— Method on Config: bool
lookupValue (
const char *path, bool &value )
+— Method on Config: bool
lookupValue (
const std::string &path, bool &value )
+
+— Method on Config: bool
lookupValue (
const char *path, int &value )
+— Method on Config: bool
lookupValue (
const std::string &path, int &value )
+
+— Method on Config: bool
lookupValue (
const char *path, unsigned int &value )
+— Method on Config: bool
lookupValue (
const std::string &path, unsigned int &value )
+
+— Method on Config: bool
lookupValue (
const char *path, long &value )
+— Method on Config: bool
lookupValue (
const std::string &path, long &value )
+
+— Method on Config: bool
lookupValue (
const char *path, long long &value )
+— Method on Config: bool
lookupValue (
const std::string &path, long long &value )
+
+— Method on Config: bool
lookupValue (
const char *path, unsigned long &value )
+— Method on Config: bool
lookupValue (
const std::string &path, unsigned long &value )
+
+— Method on Config: bool
lookupValue (
const char *path, float &value )
+— Method on Config: bool
lookupValue (
const std::string &path, float &value )
+
+— Method on Config: bool
lookupValue (
const char *path, double &value )
+— Method on Config: bool
lookupValue (
const std::string &path, double &value )
+
+— Method on Config: bool
lookupValue (
const char *path, const char *&value )
+— Method on Config: bool
lookupValue (
const std::string &path, const char *&value )
+
+— Method on Config: bool
lookupValue (
const char *path, std::string &value )
+— Method on Config: bool
lookupValue (
const std::string &path, std::string &value )
+
+These are convenience methods for looking up the value of a setting
+with the given path . If the setting is found and is of an
+appropriate type, the value is stored in value and the method
+returns true
. Otherwise, value is left unmodified and the
+method returns false . These methods do not throw exceptions.
+
+
Storage for const char * values is managed by the library and
+released automatically when the setting is destroyed or when its value
+is changed; the string must not be freed by the caller. For safety and
+convenience, always assigning string values to a std::string
is
+suggested.
+
+
Since these methods have boolean return values and do not throw
+exceptions, they can be used within boolean logic expressions. The following
+example presents a concise way to look up three values at once and
+perform error handling if any of them are not found or are of the
+wrong type:
+
+
+
+
+
+ int var1;
+ double var2;
+ const char *var3;
+
+ if(config.lookupValue("values.var1", var1)
+ && config.lookupValue("values.var2", var2)
+ && config.lookupValue("values.var3", var3))
+ {
+ // use var1, var2, var3
+ }
+ else
+ {
+ // error handling here
+ }
+
+
+
+ This approach also takes advantage of the short-circuit evaluation rules
+of C++, i.e., if the first lookup fails (returning false
), the
+remaining lookups are skipped entirely.
+
+
+
+
+— Method on Setting:
operator bool()
+— Method on Setting:
operator int()
+— Method on Setting:
operator unsigned int()
+— Method on Setting:
operator long()
+— Method on Setting:
operator unsigned long()
+— Method on Setting:
operator long long()
+— Method on Setting:
operator unsigned long long()
+— Method on Setting:
operator float()
+— Method on Setting:
operator double()
+— Method on Setting:
operator const char *()
+— Method on Setting:
operator std::string()
+
+These cast operators allow a Setting
object to be assigned to a
+variable of type bool if it is of type TypeBoolean
;
+int , unsigned int , long , or unsigned long if it is of
+type TypeInt
; long long
or unsigned long long
if
+it is of type TypeInt64
, float or double if it is of type
+TypeFloat
; or const char * or std::string if it is
+of type TypeString
.
+
+
Storage for const char * return values is managed by the
+library and released automatically when the setting is destroyed or
+when its value is changed; the string must not be freed by the
+caller. For safety and convenience, always assigning string return
+values to a std::string
is suggested.
+
+
The following examples demonstrate this usage:
+
+
+ long width = config.lookup("application.window.size.w");
+
+ bool splashScreen = config.lookup("application.splash_screen");
+
+ std::string title = config.lookup("application.window.title");
+
+
+
+ Note that certain conversions can lead to loss of precision or
+clipping of values, e.g., assigning a negative value to an unsigned
+int (in which case the value will be treated as 0), or a
+double-precision value to a float . The library does not treat
+these lossy conversions as errors.
+
+
Perhaps surprisingly, the following code in particular will cause a
+compiler error:
+
+
+ std::string title;
+ .
+ .
+ .
+ title = config.lookup("application.window.title");
+
+
+
+ This is because the assignment operator of std::string
is being
+invoked with a Setting &
as an argument. The compiler is unable
+to make an implicit conversion because both the const char *
+and the std::string
cast operators of Setting
are
+equally appropriate. This is not a bug in libconfig ; providing
+only the const char *
cast operator would resolve this
+particular ambiguity, but would cause assignments to
+std::string
like the one in the previous example to produce a
+compiler error. (To understand why, see section 11.4.1 of The C++
+Programming Language .)
+
+
The solution to this problem is to use an explicit conversion that
+avoids the construction of an intermediate std::string
object,
+as follows:
+
+
+ std::string title;
+ .
+ .
+ .
+ title = (const char *)config.lookup("application.window.title");
+
+
+
+ If the assignment is invalid due to a type mismatch, a
+SettingTypeException
is thrown.
+
+
+
+
+— Method on Setting: Setting &
operator= (
bool value )
+— Method on Setting: Setting &
operator= (
int value )
+— Method on Setting: Setting &
operator= (
long value )
+— Method on Setting: Setting &
operator= (
const long long &value )
+— Method on Setting: Setting &
operator= (
float value )
+— Method on Setting: Setting &
operator= (
const double &value )
+— Method on Setting: Setting &
operator= (
const char *value )
+— Method on Setting: Setting &
operator= (
const std::string &value )
+
+These assignment operators allow values of type bool , int ,
+long , long long , float , double , const char * , and
+std::string to be assigned to a setting. In the case of strings,
+the library makes a copy of the passed string value , so it may
+be subsequently freed or modified by the caller without affecting the
+value of the setting.
+
+
If the assignment is invalid due to a type mismatch, a
+SettingTypeException
is thrown.
+
+
+
+
+— Method on Setting: Setting &
operator[] (
int idx )
+— Method on Setting: Setting &
operator[] (
const std::string &name )
+— Method on Setting: Setting &
operator[] (
const char *name )
+
+A Setting
object may be subscripted with an integer index
+idx if it is an array or list, or with either a string
+name or an integer index idx if it is a group. For example,
+the following code would produce the string `Last Name ' when
+applied to the example configuration in Configuration Files .
+
+
+ Setting& setting = config.lookup("application.misc");
+ const char *s = setting["columns"][0];
+
+
+
+ If the setting is not an array, list, or group, a
+SettingTypeException
is thrown. If the subscript (idx
+or name ) does not refer to a valid element, a
+SettingNotFoundException
is thrown.
+
+
Iterating over a group's child settings with an integer index will
+return the settings in the same order that they appear in the
+configuration.
+
+
+
+
+— Method on Setting: bool
lookupValue (
const char *name, bool &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, bool &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, int &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, int &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, unsigned int &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, unsigned int &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, long long &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, long long &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, unsigned long long &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, unsigned long long &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, long &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, long &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, unsigned long &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, unsigned long &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, float &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, float &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, double &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, double &value )
+
+— Method on Setting: bool
lookupValue (
const char *name, const char *&value )
+— Method on Setting: bool
lookupValue (
const std::string &name, const char *&value )
+
+— Method on Setting: bool
lookupValue (
const char *name, std::string &value )
+— Method on Setting: bool
lookupValue (
const std::string &name, std::string &value )
+
+These are convenience methods for looking up the value of a child setting
+with the given name . If the setting is found and is of an
+appropriate type, the value is stored in value and the method
+returns true
. Otherwise, value is left unmodified and the
+method returns false . These methods do not throw exceptions.
+
+
Storage for const char * values is managed by the library and
+released automatically when the setting is destroyed or when its value
+is changed; the string must not be freed by the caller. For safety and
+convenience, always assigning string values to a std::string
is
+suggested.
+
+
Since these methods have boolean return values and do not throw
+exceptions, they can be used within boolean logic expressions. The following
+example presents a concise way to look up three values at once and
+perform error handling if any of them are not found or are of the
+wrong type:
+
+
+
+
+
+ int var1;
+ double var2;
+ const char *var3;
+
+ if(setting.lookupValue("var1", var1)
+ && setting.lookupValue("var2", var2)
+ && setting.lookupValue("var3", var3))
+ {
+ // use var1, var2, var3
+ }
+ else
+ {
+ // error handling here
+ }
+
+
+
+ This approach also takes advantage of the short-circuit evaluation
+rules of C++, e.g., if the first lookup fails (returning false
), the
+remaining lookups are skipped entirely.
+
+
+
+
+— Method on Setting: Setting &
add (
const std::string &name, Setting::Type type )
+— Method on Setting: Setting &
add (
const char *name, Setting::Type type )
+
+These methods add a new child setting with the given name and
+type to the setting, which must be a group. They return a
+reference to the new setting. If the setting already has a child
+setting with the given name, or if the name is invalid, a
+SettingNameException
is thrown. If the setting is not a group,
+a SettingTypeException
is thrown.
+
+
Once a setting has been created, neither its name nor type can be
+changed.
+
+
+
+
+— Method on Setting: Setting &
add (
Setting::Type type )
+
+This method adds a new element to the setting, which must be of type
+TypeArray
or TypeList
. If the setting is an array which
+currently has zero elements, the type parameter (which must be
+TypeInt
, TypeInt64
, TypeFloat
, TypeBool
,
+or TypeString
) determines the type for the array; otherwise it
+must match the type of the existing elements in the array.
+
+
The method returns the new setting on success. If type is a
+scalar type, the new setting will have a default value of 0, 0.0,
+false
, or NULL
, depending on the type.
+
+
The method throws a SettingTypeException
if the setting is not
+an array or list, or if type is invalid.
+
+
+
+
+— Method on Setting: void
remove (
const std::string &name )
+— Method on Setting: void
remove (
const char *name )
+
+These methods remove the child setting with the given name from
+the setting, which must be a group. Any child settings of the removed
+setting are recursively destroyed as well.
+
+
If the setting is not a group, a SettingTypeException
is
+thrown. If the setting does not have a child setting with the given
+name, a SettingNotFoundException
is thrown.
+
+
+
+
+— Method on Setting: void
remove (
unsigned int idx )
+
+This method removes the child setting at the given index idx from
+the setting, which must be a group, list, or array. Any child settings
+of the removed setting are recursively destroyed as well.
+
+
If the setting is not a group, list, or array, a
+SettingTypeException
is thrown. If idx is out of range,
+a SettingNotFoundException
is thrown.
+
+
+
+
+— Method on Setting: const char *
getName ()
+
+This method returns the name of the setting, or NULL
if the
+setting has no name. Storage for the returned string is managed by the
+library and released automatically when the setting is destroyed; the
+string must not be freed by the caller. For safety and convenience,
+consider assigning the return value to a std::string
.
+
+
+
+
+— Method on Setting: std::string
getPath ()
+
+This method returns the complete dot-separated path to the
+setting. Settings which do not have a name (list and array elements)
+are represented by their index in square brackets.
+
+
+
+
+— Method on Setting: Setting &
getParent ()
+
+This method returns the parent setting of the setting. If the setting
+is the root setting, a SettingNotFoundException
is thrown.
+
+
+
+
+— Method on Setting: bool
isRoot ()
+
+This method returns true if the setting is the root setting, and
+false otherwise.
+
+
+
+
+— Method on Setting: int
getIndex ()
+
+This method returns the index of the setting within its parent
+setting. When applied to the root setting, this method returns -1.
+
+
+
+
+— Method on Setting: Setting::Type
getType ()
+
+ This method returns the type of the setting. The
+Setting::Type
enumeration consists of the following constants:
+TypeInt
, TypeInt64
, TypeFloat
, TypeString
,
+TypeBoolean
, TypeArray
, TypeList
, or
+TypeGroup
.
+
+
+
+
+— Method on Setting: Setting::Format
getFormat ()
+— Method on Setting: void
setFormat (
Setting::Format format )
+
+These methods get and set the external format for the setting.
+
+
The Setting::Format enumeration consists of the following
+constants: FormatDefault
, FormatHex
. All settings
+support the FormatDefault
format. The FormatHex
format
+specifies hexadecimal formatting for integer values, and hence only
+applies to settings of type TypeInt
and TypeInt64
. If
+format is invalid for the given setting, it is ignored.
+
+
+
+
+— Method on Setting: bool
exists (
const std::string &name )
+— Method on Setting: bool
exists (
const char *name )
+
+These methods test if the setting has a child setting with the given
+name . They return true
if the setting exists, and
+false otherwise. These methods do not throw exceptions.
+
+
+
+
+— Method on Setting: int
getLength ()
+
+This method returns the number of settings in a group, or the number of
+elements in a list or array. For other types of settings, it returns
+0.
+
+
+
+
+— Method on Setting: bool
isGroup ()
+— Method on Setting: bool
isArray ()
+— Method on Setting: bool
isList ()
+
+These convenience methods test if a setting is of a given type.
+
+
+
+
+— Method on Setting: bool
isAggregate ()
+— Method on Setting: bool
isScalar ()
+— Method on Setting: bool
isNumber ()
+
+These convenience methods test if a setting is of an aggregate type (a
+group, array, or list), of a scalar type (integer, 64-bit integer,
+floating point, boolean, or string), and of a number (integer or
+floating point), respectively.
+
+
+
+
+— Method on Setting: unsigned int
getSourceLine ()
+
+This method returns the line number of the configuration file or
+stream at which the setting was parsed. This information is useful for
+reporting application-level errors. If the setting was not read from a
+file or stream, or if the line number is otherwise unavailable, the
+method returns 0.
+
+
+
+
+
+
+5 Configuration File Grammar
+
+Below is the BNF grammar for configuration files. Comments are not part
+of the grammar, and hence are not included here.
+
+
+
+
+ configuration = setting-list | empty
+
+ empty =
+
+ setting-list = setting | setting-list setting
+
+ setting = name (":" | "=") value ";"
+
+ value = scalar-value | array | list | group
+
+ value-list = value | value-list "," value
+
+ scalar-value = boolean | integer | integer64 | hex | hex64 | float
+ | string
+
+ scalar-value-list = scalar-value | scalar-value-list "," scalar-value
+
+ array = "[" (scalar-value-list | empty) "]"
+
+ list = "(" (value-list | empty) ")"
+
+ group = "{" (setting-list | empty) "}"
+
+
+
+
+
+Terminals are defined below as regular expressions:
+
+
+
+
boolean
+([Tt][Rr][Uu][Ee])|([Ff][Aa][Ll][Ss][Ee])
+ string
+\"([^\"\\]|\\.)*\"
+ 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)?
+ float
+([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)
+
+
+
+
+
+Appendix A License
+
+
+
+
+GNU LESSER GENERAL PUBLIC LICENSE
+Version 2.1, February 1999
+
+
+
+
+
+Copyright © 1991, 1999 Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+
[This is the first released version of the Lesser GPL. It also counts
+as the successor of the GNU Library Public License, version 2, hence the
+version number 2.1.]
+
+
+
+
+Preamble
+
+
+
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public Licenses are
+intended to guarantee your freedom to share and change free software–to
+make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages–typically libraries–of the Free
+Software Foundation and other authors who decide to use it. You can use
+it too, but we suggest you first think carefully about whether this
+license or the ordinary General Public License is the better strategy to
+use in any particular case, based on the explanations below.
+
+
When we speak of free software, we are referring to freedom of use, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish); that you receive source code or can get it if
+you want it; that you can change the software and use pieces of it in
+new free programs; and that you are informed that you can do these
+things.
+
+
To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+
For example, if you distribute copies of the library, whether gratis or
+for a fee, you must give the recipients all the rights that we gave you.
+You must make sure that they, too, receive or can get the source code.
+If you link other code with the library, you must provide complete
+object files to the recipients, so that they can relink them with the
+library after making changes to the library and recompiling it. And you
+must show them these terms so they know their rights.
+
+
We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+
To protect each distributor, we want to make it very clear that there is
+no warranty for the free library. Also, if the library is modified by
+someone else and passed on, the recipients should know that what they
+have is not the original version, so that the original author's
+reputation will not be affected by problems that might be introduced by
+others.
+
+
Finally, software patents pose a constant threat to the existence of any
+free program. We wish to make sure that a company cannot effectively
+restrict the users of a free program by obtaining a restrictive license
+from a patent holder. Therefore, we insist that any patent license
+obtained for a version of the library must be consistent with the full
+freedom of use specified in this license.
+
+
Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License. This license, the GNU Lesser General Public
+License, applies to certain designated libraries, and is quite different
+from the ordinary General Public License. We use this license for
+certain libraries in order to permit linking those libraries into
+non-free programs.
+
+
When a program is linked with a library, whether statically or using a
+shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the entire
+combination fits its criteria of freedom. The Lesser General Public
+License permits more lax criteria for linking other code with the
+library.
+
+
We call this license the “Lesser” General Public License because it does
+Less to protect the user's freedom than the ordinary General Public
+License. It also provides other free software developers Less of an
+advantage over competing non-free programs. These disadvantages are the
+reason we use the ordinary General Public License for many libraries.
+However, the Lesser license provides advantages in certain special
+circumstances.
+
+
For example, on rare occasions, there may be a special need to encourage
+the widest possible use of a certain library, so that it becomes a
+de-facto standard. To achieve this, non-free programs must be allowed
+to use the library. A more frequent case is that a free library does
+the same job as widely used non-free libraries. In this case, there is
+little to gain by limiting the free library to free software only, so we
+use the Lesser General Public License.
+
+
In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of free
+software. For example, permission to use the GNU C Library in non-free
+programs enables many more people to use the whole GNU operating system,
+as well as its variant, the GNU/Linux operating system.
+
+
Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is linked
+with the Library has the freedom and the wherewithal to run that program
+using a modified version of the Library.
+
+
The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+“work based on the library” and a “work that uses the library”. The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+
GNU LESSER GENERAL PUBLIC LICENSE
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+
+
+
+
+
+ This License Agreement applies to any software library or other program
+which contains a notice placed by the copyright holder or other
+authorized party saying it may be distributed under the terms of this
+Lesser General Public License (also called “this License”). Each
+licensee is addressed as “you”.
+
+ A “library” means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+
The “Library”, below, refers to any such software library or work which
+has been distributed under these terms. A “work based on the Library”
+means either the Library or any derivative work under copyright law:
+that is to say, a work containing the Library or a portion of it, either
+verbatim or with modifications and/or translated straightforwardly into
+another language. (Hereinafter, translation is included without
+limitation in the term “modification”.)
+
+
“Source code” for a work means the preferred form of the work for making
+modifications to it. For a library, complete source code means all the
+source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and
+installation of the library.
+
+
Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of running
+a program using the Library is not restricted, and output from such a
+program is covered only if its contents constitute a work based on the
+Library (independent of the use of the Library in a tool for writing
+it). Whether that is true depends on what the Library does and what the
+program that uses the Library does.
+
+
+
+
+ You may copy and distribute verbatim copies of the Library's complete
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the notices
+that refer to this License and to the absence of any warranty; and
+distribute a copy of this License along with the Library.
+
+ You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+
+
+
+ You may modify your copy or copies of the Library or any portion of it,
+thus forming a work based on the Library, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that
+you also meet all of these conditions:
+
+
+
+ The modified work must itself be a software library.
+
+
+
+
+ You must cause the files modified to carry prominent notices stating
+that you changed the files and the date of any change.
+
+
+
+
+ You must cause the whole of the work to be licensed at no charge to all
+third parties under the terms of this License.
+
+
+
+
+ If a facility in the modified Library refers to a function or a table of
+data to be supplied by an application program that uses the facility,
+other than as an argument passed when the facility is invoked, then you
+must make a good faith effort to ensure that, in the event an
+application does not supply such function or table, the facility still
+operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a
+purpose that is entirely well-defined independent of the application.
+Therefore, Subsection 2d requires that any application-supplied function
+or table used by this function must be optional: if the application does
+not supply it, the square root function must still compute square
+roots.)
+
+
+
+ These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library, and
+can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based on
+the Library, the distribution of the whole must be on the terms of this
+License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
+
+
Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+
In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of a
+storage or distribution medium does not bring the other work under the
+scope of this License.
+
+
+
+
+ You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so that
+they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for that
+copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+
This option is useful when you wish to copy part of the code of the
+Library into a program that is not a library.
+
+
+
+
+ You may copy and distribute the Library (or a portion or derivative of
+it, under Section 2) in object code or executable form under the terms
+of Sections 1 and 2 above provided that you accompany it with the
+complete corresponding machine-readable source code, which must be
+distributed under the terms of Sections 1 and 2 above on a medium
+customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy from a
+designated place, then offering equivalent access to copy the source
+code from the same place satisfies the requirement to distribute the
+source code, even though third parties are not compelled to copy the
+source along with the object code.
+
+
+
+
+ A program that contains no derivative of any portion of the Library, but
+is designed to work with the Library by being compiled or linked with
+it, is called a “work that uses the Library”. Such a work, in
+isolation, is not a derivative work of the Library, and therefore falls
+outside the scope of this License.
+
+ However, linking a “work that uses the Library” with the Library creates
+an executable that is a derivative of the Library (because it contains
+portions of the Library), rather than a “work that uses the library”.
+The executable is therefore covered by this License. Section 6 states
+terms for distribution of such executables.
+
+
When a “work that uses the Library” uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be linked
+without the Library, or if the work is itself a library. The threshold
+for this to be true is not precisely defined by law.
+
+
If such an object file uses only numerical parameters, data structure
+layouts and accessors, and small macros and small inline functions (ten
+lines or less in length), then the use of the object file is
+unrestricted, regardless of whether it is legally a derivative work.
+(Executables containing this object code plus portions of the Library
+will still fall under Section 6.)
+
+
Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6, whether
+or not they are linked directly with the Library itself.
+
+
+
+
+ As an exception to the Sections above, you may also combine or link a
+“work that uses the Library” with the Library to produce a work
+containing portions of the Library, and distribute that work under terms
+of your choice, provided that the terms permit modification of the work
+for the customer's own use and reverse engineering for debugging such
+modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+
+
+
+
+
+ Accompany the work with the complete corresponding machine-readable
+source code for the Library including whatever changes were used in the
+work (which must be distributed under Sections 1 and 2 above); and, if
+the work is an executable linked with the Library, with the complete
+machine-readable “work that uses the Library”, as object code and/or
+source code, so that the user can modify the Library and then relink to
+produce a modified executable containing the modified Library. (It is
+understood that the user who changes the contents of definitions files
+in the Library will not necessarily be able to recompile the application
+to use the modified definitions.)
+
+
+
+
+ Use a suitable shared library mechanism for linking with the Library. A
+suitable mechanism is one that (1) uses at run time a copy of the
+library already present on the user's computer system, rather than
+copying library functions into the executable, and (2) will operate
+properly with a modified version of the library, if the user installs
+one, as long as the modified version is interface-compatible with the
+version that the work was made with.
+
+
+
+
+ Accompany the work with a written offer, valid for at least three years,
+to give the same user the materials specified in Subsection 6a, above,
+for a charge no more than the cost of performing this distribution.
+
+
+
+
+ If distribution of the work is made by offering access to copy from a
+designated place, offer equivalent access to copy the above specified
+materials from the same place.
+
+
+
+
+ Verify that the user has already received a copy of these materials or
+that you have already sent this user a copy.
+
+
+
+ For an executable, the required form of the “work that uses the Library”
+must include any data and utility programs needed for reproducing the
+executable from it. However, as a special exception, the materials to
+be distributed need not include anything that is normally distributed
+(in either source or binary form) with the major components (compiler,
+kernel, and so on) of the operating system on which the executable runs,
+unless that component itself accompanies the executable.
+
+
It may happen that this requirement contradicts the license restrictions
+of other proprietary libraries that do not normally accompany the
+operating system. Such a contradiction means you cannot use both them
+and the Library together in an executable that you distribute.
+
+
+
+
+ You may place library facilities that are a work based on the Library
+side-by-side in a single library together with other library facilities
+not covered by this License, and distribute such a combined library,
+provided that the separate distribution of the work based on the Library
+and of the other library facilities is otherwise permitted, and provided
+that you do these two things:
+
+
+
+
+
+
+ Accompany the combined library with a copy of the same work based on the
+Library, uncombined with any other library facilities. This must be
+distributed under the terms of the Sections above.
+
+
+
+
+ Give prominent notice with the combined library of the fact that part of
+it is a work based on the Library, and explaining where to find the
+accompanying uncombined form of the same work.
+
+
+
+
+
+
+ You may not copy, modify, sublicense, link with, or distribute the
+Library except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, link with, or distribute the
+Library is void, and will automatically terminate your rights under this
+License. However, parties who have received copies, or rights, from you
+under this License will not have their licenses terminated so long as
+such parties remain in full compliance.
+
+
+
+
+ You are not required to accept this License, since you have not signed
+it. However, nothing else grants you permission to modify or distribute
+the Library or its derivative works. These actions are prohibited by
+law if you do not accept this License. Therefore, by modifying or
+distributing the Library (or any work based on the Library), you
+indicate your acceptance of this License to do so, and all its terms and
+conditions for copying, distributing or modifying the Library or works
+based on it.
+
+
+
+
+ Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+
+
+
+ If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent license
+would not permit royalty-free redistribution of the Library by all those
+who receive copies directly or indirectly through you, then the only way
+you could satisfy both it and this License would be to refrain entirely
+from distribution of the Library.
+
+ If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+
It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is implemented
+by public license practices. Many people have made generous
+contributions to the wide range of software distributed through that
+system in reliance on consistent application of that system; it is up to
+the author/donor to decide if he or she is willing to distribute
+software through any other system and a licensee cannot impose that
+choice.
+
+
This section is intended to make thoroughly clear what is believed to be
+a consequence of the rest of this License.
+
+
+
+
+ If the distribution and/or use of the Library is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Library under this License may add an
+explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+
+
+
+ The Free Software Foundation may publish revised and/or new versions of
+the Lesser General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in
+detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and “any
+later version”, you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a license
+version number, you may choose any version ever published by the Free
+Software Foundation.
+
+
+
+
+ If you wish to incorporate parts of the Library into other free programs
+whose distribution conditions are incompatible with these, write to the
+author to ask for permission. For software which is copyrighted by the
+Free Software Foundation, write to the Free Software Foundation; we
+sometimes make exceptions for this. Our decision will be guided by the
+two goals of preserving the free status of all derivatives of our free
+software and of promoting the sharing and reuse of software generally.
+
+
+
+
+ NO WARRANTY
+
+
+
+
+ BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE LIBRARY “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH
+YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+
+
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY
+(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
+INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
+THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR
+OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+
+
+
+
+END OF TERMS AND CONDITIONS
+
+
+
+
+How to Apply These Terms to Your New Libraries
+
+If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of
+the ordinary General Public License).
+
+
To apply these terms, attach the following notices to the library. It
+is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should have
+at least the “copyright” line and a pointer to where the full notice is
+found.
+
+
+<one line to give the library's name and a brief idea of what it does.>
+Copyright (C) <year> <name of author>
+
+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 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
+
+
+ Also add information on how to contact you by electronic and paper mail.
+
+
You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a “copyright disclaimer” for the library, if
+necessary. Here is a sample; alter the names:
+
+
+Yoyodyne, Inc., hereby disclaims all copyright interest in the
+library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+<signature of Ty Coon>, 1 April 1990
+Ty Coon, President of Vice
+
+
+ That's all there is to it!
+
+
+
+
+
+Function Index
+
+
+
+
+Type Index
+
+
+
+
+
+
+Concept Index
+
+
+
+
+
Index: /tags/2.0-rc2/external/libconfig/scanner.h
===================================================================
--- /tags/2.0-rc2/external/libconfig/scanner.h (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/scanner.h (revision 1304)
@@ -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
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . 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
+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 */
Index: /tags/2.0-rc2/external/libconfig/libconfigcpp.cpp
===================================================================
--- /tags/2.0-rc2/external/libconfig/libconfigcpp.cpp (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/libconfigcpp.cpp (revision 1304)
@@ -0,0 +1,969 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2008 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
+ .
+ ----------------------------------------------------------------------------
+*/
+
+#include "libconfigpp.h"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#include "wincompat.h"
+
+using namespace libconfig;
+
+#include
+
+// ---------------------------------------------------------------------------
+
+SettingException::SettingException()
+{
+}
+
+SettingException::~SettingException()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingTypeException::SettingTypeException()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNotFoundException::SettingNotFoundException()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+SettingNameException::SettingNameException()
+{
+}
+
+// ---------------------------------------------------------------------------
+
+ParseException::ParseException(int line, const char *error)
+ : _line(line), _error(error)
+{
+}
+
+ParseException::~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())
+ path << '.';
+
+ const char *name = setting.getName();
+ if(name)
+ path << name;
+ else
+ path << '[' << setting.getIndex() << ']';
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::ConfigDestructor(void *arg)
+{
+ delete reinterpret_cast(arg);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::Config()
+{
+ config_init(& _config);
+ config_set_destructor(& _config, ConfigDestructor);
+}
+
+// ---------------------------------------------------------------------------
+
+Config::~Config()
+{
+ config_destroy(& _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::read(FILE *stream) throw(ParseException)
+{
+ if(! config_read(& _config, stream))
+ throw ParseException(config_error_line(& _config),
+ config_error_text(& _config));
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::write(FILE *stream) const
+{
+ config_write(& _config, stream);
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::readFile(const char *filename) throw(FileIOException,
+ ParseException)
+{
+ FILE *f = fopen(filename, "rt");
+ if(f == NULL)
+ throw FileIOException();
+ try
+ {
+ read(f);
+ fclose(f);
+ }
+ catch(ParseException& p)
+ {
+ fclose(f);
+ throw p;
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+void Config::writeFile(const char *filename) throw(FileIOException)
+{
+ if(! config_write_file(& _config, filename))
+ throw FileIOException();
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Config::lookup(const char *path) const
+ throw(SettingNotFoundException)
+{
+ config_setting_t *s = config_lookup(& _config, path);
+ if(! s)
+ throw SettingNotFoundException();
+
+ 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, long &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Config::lookupValue(const char *path, unsigned long &value) const throw()
+{
+ CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long, 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;
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator bool() const throw(SettingTypeException)
+{
+ assertType(TypeBoolean);
+
+ return(config_setting_get_bool(_setting) ? true : false);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator long() const throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ return(config_setting_get_int(_setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned long() const throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ long v = config_setting_get_int(_setting);
+
+ if(v < 0)
+ v = 0;
+
+ return(static_cast(v));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator int() const throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ // may cause loss of precision:
+ return(static_cast(config_setting_get_int(_setting)));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting::operator unsigned int() const throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ long v = config_setting_get_int(_setting);
+
+ if(v < 0)
+ v = 0;
+
+ return(static_cast(v));
+}
+
+// ---------------------------------------------------------------------------
+
+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(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(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=(long value) throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ config_setting_set_int(_setting, value);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::operator=(int value) throw(SettingTypeException)
+{
+ assertType(TypeInt);
+
+ long cvalue = static_cast(value);
+
+ config_setting_set_int(_setting, cvalue);
+
+ return(*this);
+}
+
+// ---------------------------------------------------------------------------
+
+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(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();
+
+ config_setting_t *setting = config_setting_get_elem(_setting, i);
+
+ if(! setting)
+ throw SettingNotFoundException();
+
+ 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();
+
+ 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, long &value) const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, long, value);
+}
+
+// ---------------------------------------------------------------------------
+
+bool Setting::lookupValue(const char *name, unsigned long &value)
+ const throw()
+{
+ SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long, 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();
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::getParent() throw(SettingNotFoundException)
+{
+ config_setting_t *setting = config_setting_parent(_setting);
+
+ if(! setting)
+ throw SettingNotFoundException();
+
+ return(wrapSetting(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();
+}
+
+// ---------------------------------------------------------------------------
+
+void Setting::remove(unsigned int idx)
+ throw(SettingTypeException, SettingNotFoundException)
+{
+ if((_type != TypeArray) && (_type != TypeGroup) && (_type != TypeList))
+ throw SettingTypeException();
+
+ if(! config_setting_remove_elem(_setting, idx))
+ throw SettingNotFoundException();
+}
+
+// ---------------------------------------------------------------------------
+
+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();
+
+ config_setting_t *setting = config_setting_add(_setting, name, typecode);
+
+ if(! setting)
+ throw SettingNameException();
+
+ return(wrapSetting(setting));
+}
+
+// ---------------------------------------------------------------------------
+
+Setting & Setting::add(Setting::Type type) throw(SettingTypeException)
+{
+ if((_type != TypeArray) && (_type != TypeList))
+ throw SettingTypeException();
+
+ if(_type == TypeArray)
+ {
+ if(getLength() > 0)
+ {
+ Setting::Type atype = operator[](0).getType();
+ if(type != atype)
+ throw SettingTypeException();
+ }
+ else
+ {
+ if((type != TypeInt) && (type != TypeFloat) && (type != TypeString)
+ && (type != TypeBoolean))
+ throw SettingTypeException();
+ }
+ }
+
+ 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 == TypeFloat))))
+ throw SettingTypeException();
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+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(setting));
+ }
+ else
+ setting = reinterpret_cast(hook);
+
+ return(*setting);
+}
+
+// ---------------------------------------------------------------------------
+// eof
Index: /tags/2.0-rc2/external/libconfig/private.h
===================================================================
--- /tags/2.0-rc2/external/libconfig/private.h (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/private.h (revision 1304)
@@ -0,0 +1,37 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A structured configuration file parsing library
+ Copyright (C) 2005 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
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_private_h
+#define __libconfig_private_h
+
+#include "libconfig.h"
+
+struct parse_context
+{
+ config_t *config;
+ config_setting_t *parent;
+ config_setting_t *setting;
+ char *name;
+};
+
+// ---------------------------------------------------------------------------
+#endif // __libconfig_private_h
Index: /tags/2.0-rc2/external/libconfig/libconfig.h
===================================================================
--- /tags/2.0-rc2/external/libconfig/libconfig.h (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/libconfig.h (revision 1304)
@@ -0,0 +1,253 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2008 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
+ .
+ ----------------------------------------------------------------------------
+*/
+
+#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 */
+
+#include
+
+#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
+{
+ long 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;
+} config_setting_t;
+
+typedef struct config_list_t
+{
+ unsigned int length;
+ unsigned int capacity;
+ config_setting_t **elements;
+} config_list_t;
+
+typedef struct config_t
+{
+ config_setting_t *root;
+ void (*destructor)(void *);
+ int flags;
+ const char *error_text;
+ int error_line;
+} 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_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_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_init(config_t *config);
+extern LIBCONFIG_API void config_destroy(config_t *config);
+
+extern LIBCONFIG_API long 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_set_int(config_setting_t *setting,
+ long 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(config_setting_t *setting);
+
+extern LIBCONFIG_API long 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, long 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 /* 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 long config_lookup_int(const config_t *config,
+ const char *path);
+extern LIBCONFIG_API long long config_lookup_int64(const config_t *config,
+ const char *path);
+extern LIBCONFIG_API double config_lookup_float(const config_t *config,
+ const char *path);
+extern LIBCONFIG_API int config_lookup_bool(const config_t *config,
+ const char *path);
+extern LIBCONFIG_API const char *config_lookup_string(const config_t *config,
+ const char *path);
+
+#define /* config_setting_t * */ config_root_setting( \
+ /* const config_t * */ C) \
+ ((C)->root)
+
+#define /* unsigned short */ config_setting_source_line( \
+ /* const config_t */ C) \
+ ((C)->line)
+
+#define /* const char * */ config_error_text(/* const config_t * */ C) \
+ ((C)->error_text)
+
+#define /* int */ config_error_line(/* const config_t * */ C) \
+ ((C)->error_line)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __libconfig_h */
Index: /tags/2.0-rc2/external/libconfig/libconfigpp.h
===================================================================
--- /tags/2.0-rc2/external/libconfig/libconfigpp.h (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/libconfigpp.h (revision 1304)
@@ -0,0 +1,383 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2008 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
+ .
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __libconfig_hpp
+#define __libconfig_hpp
+
+#include
+#include
+#include
+
+namespace libconfig
+{
+
+#include "libconfig.h"
+
+ class LIBCONFIG_API ConfigException { };
+
+ class LIBCONFIG_API SettingException : public ConfigException
+ {
+ public:
+
+ SettingException();
+ virtual ~SettingException();
+ };
+
+ class LIBCONFIG_API SettingTypeException : public SettingException
+ {
+ public:
+
+ SettingTypeException();
+ };
+
+ class LIBCONFIG_API SettingNotFoundException : public SettingException
+ {
+ public:
+
+ SettingNotFoundException();
+ };
+
+ class LIBCONFIG_API SettingNameException : public SettingException
+ {
+ public:
+
+ SettingNameException();
+ };
+
+ class LIBCONFIG_API FileIOException : public ConfigException { };
+
+ class LIBCONFIG_API ParseException : public ConfigException
+ {
+ friend class Config;
+
+ public:
+
+ virtual ~ParseException();
+
+ inline int getLine() throw()
+ { return(_line); }
+
+ inline const char *getError() throw()
+ { return(_error); }
+
+ private:
+
+ ParseException(int line, const char *error);
+
+ int _line;
+ const char *_error;
+ };
+
+ class LIBCONFIG_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 long() const throw(SettingTypeException);
+ operator unsigned long() const throw(SettingTypeException);
+ operator int() const throw(SettingTypeException);
+ operator unsigned int() 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);
+
+ Setting & operator=(bool value) throw(SettingTypeException);
+ Setting & operator=(long value) throw(SettingTypeException);
+ Setting & operator=(int 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, long &value) const throw();
+ bool lookupValue(const char *name, unsigned long &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, long &value)
+ const throw()
+ { return(lookupValue(name.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &name, unsigned long &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)); }
+
+ inline unsigned int getSourceLine() const throw()
+ { return(config_setting_source_line(_setting)); }
+ };
+
+ class LIBCONFIG_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 read(FILE *stream) throw(ParseException);
+ void write(FILE *stream) const;
+
+ 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, long &value) const throw();
+ bool lookupValue(const char *path, unsigned long &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, long &value)
+ const throw()
+ { return(lookupValue(path.c_str(), value)); }
+
+ inline bool lookupValue(const std::string &path, unsigned long &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;
+ };
+
+} // namespace libconfig
+
+#endif // __libconfig_hpp
Index: /tags/2.0-rc2/external/libconfig/SConscript
===================================================================
--- /tags/2.0-rc2/external/libconfig/SConscript (revision 1478)
+++ /tags/2.0-rc2/external/libconfig/SConscript (revision 1478)
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2007 Arnold Krille
+# Copyright (C) 2007 Pieter Palmers
+#
+# This file is part of FFADO
+# FFADO = Free Firewire (pro-)audio drivers for linux
+#
+# FFADO is based upon FreeBoB.
+#
+# 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 .
+#
+
+Import( 'env' )
+env = env.Clone()
+
+env.AppendUnique( CPPPATH=["#/external/libconfig"] )
+
+sources = [
+ 'grammar.c',
+ 'libconfig.c',
+ 'libconfigcpp.cpp',
+ 'scanner.c',
+]
+
+if env.has_key('DEBUG') and env['DEBUG']:
+ env.AppendUnique( CCFLAGS=["-DDEBUG","-g"] )
+
+env.AppendUnique( CCFLAGS=["-DYY_NO_INPUT"] )
+
+libconfig = env.StaticLibrary('libconfigpp', sources)
Index: /tags/2.0-rc2/external/libconfig/grammar.c
===================================================================
--- /tags/2.0-rc2/external/libconfig/grammar.c (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/grammar.c (revision 1304)
@@ -0,0 +1,1928 @@
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* 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 2, 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* 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.3"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 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
+
+
+/* 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_END = 275,
+ TOK_GARBAGE = 276
+ };
+#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_END 275
+#define TOK_GARBAGE 276
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 31 "grammar.y"
+
+#include
+#include
+#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
+#endif
+#include "private.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 IN_ARRAY() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
+
+#define IN_LIST() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST))
+
+#define CAPTURE_PARSE_POS(S) \
+ (S)->line = (unsigned int)libconfig_yyget_lineno(scanner)
+
+void libconfig_yyerror(void *scanner, struct parse_context *ctx,
+ char const *s)
+{
+ ctx->config->error_line = libconfig_yyget_lineno(scanner);
+ ctx->config->error_text = s;
+}
+
+
+
+/* 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
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+#line 73 "grammar.y"
+{
+ long ival;
+ long long llval;
+ double fval;
+ char *sval;
+}
+/* Line 187 of yacc.c. */
+#line 194 "grammar.c"
+ YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+/* Copy the second part of user declarations. */
+
+
+/* Line 216 of yacc.c. */
+#line 207 "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 /* 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 /* 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 i)
+#else
+static int
+YYID (i)
+ int i;
+#endif
+{
+ return i;
+}
+#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 /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include /* 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 /* 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 /* 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;
+ YYSTYPE yyvs;
+ };
+
+/* 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) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
+ Stack = &yyptr->Stack; \
+ 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 32
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 22
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 18
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 34
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 43
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 276
+
+#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
+};
+
+#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,
+ 21, 22, 27, 28, 33, 35, 37, 39, 41, 43,
+ 45, 47, 49, 51, 53, 55, 57, 61, 62, 64,
+ 66, 70, 71, 73, 74
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const yytype_int8 yyrhs[] =
+{
+ 23, 0, -1, -1, 24, -1, 26, -1, 24, 26,
+ -1, -1, 24, -1, -1, 10, 27, 11, 32, 20,
+ -1, -1, 13, 29, 37, 14, -1, -1, 15, 31,
+ 35, 16, -1, 33, -1, 28, -1, 30, -1, 38,
+ -1, 3, -1, 4, -1, 6, -1, 5, -1, 7,
+ -1, 8, -1, 9, -1, 32, -1, 34, 17, 32,
+ -1, -1, 34, -1, 33, -1, 36, 17, 33, -1,
+ -1, 36, -1, -1, 18, 39, 25, 19, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 88, 88, 90, 94, 95, 98, 100, 105, 104,
+ 125, 124, 148, 147, 170, 171, 172, 173, 177, 197,
+ 219, 241, 263, 285, 303, 330, 331, 334, 336, 340,
+ 341, 344, 346, 351, 350
+};
+#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_END", "TOK_GARBAGE", "$accept", "configuration",
+ "setting_list", "setting_list_optional", "setting", "@1", "array", "@2",
+ "list", "@3", "value", "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
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 22, 23, 23, 24, 24, 25, 25, 27, 26,
+ 29, 28, 31, 30, 32, 32, 32, 32, 33, 33,
+ 33, 33, 33, 33, 33, 34, 34, 35, 35, 36,
+ 36, 37, 37, 39, 38
+};
+
+/* 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, 5,
+ 0, 4, 0, 4, 1, 1, 1, 1, 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, 8, 0, 3, 4, 0, 1, 5, 0, 18,
+ 19, 21, 20, 22, 23, 24, 10, 12, 33, 15,
+ 16, 0, 14, 17, 31, 27, 6, 9, 29, 32,
+ 0, 25, 28, 0, 7, 0, 0, 11, 0, 13,
+ 34, 30, 26
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int8 yydefgoto[] =
+{
+ -1, 2, 3, 35, 4, 5, 19, 24, 20, 25,
+ 21, 22, 32, 33, 29, 30, 23, 26
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -18
+static const yytype_int8 yypact[] =
+{
+ -1, -18, 12, -1, -18, 3, -18, -18, -2, -18,
+ -18, -18, -18, -18, -18, -18, -18, -18, -18, -18,
+ -18, -5, -18, -18, 20, -2, -1, -18, -18, 0,
+ 4, -18, 2, 14, -1, 1, 20, -18, -2, -18,
+ -18, -18, -18
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const yytype_int8 yypgoto[] =
+{
+ -18, -18, 6, -18, -3, -18, -18, -18, -18, -18,
+ -17, -14, -18, -18, -18, -18, -18, -18
+};
+
+/* 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, 9, 10, 11, 12, 13, 14, 15, 31, 1,
+ 28, 16, 6, 17, 8, 27, 18, 36, 37, 38,
+ 40, 42, 41, 9, 10, 11, 12, 13, 14, 15,
+ 39, 7, 34
+};
+
+static const yytype_uint8 yycheck[] =
+{
+ 3, 3, 4, 5, 6, 7, 8, 9, 25, 10,
+ 24, 13, 0, 15, 11, 20, 18, 17, 14, 17,
+ 19, 38, 36, 3, 4, 5, 6, 7, 8, 9,
+ 16, 34, 26
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 10, 23, 24, 26, 27, 0, 26, 11, 3,
+ 4, 5, 6, 7, 8, 9, 13, 15, 18, 28,
+ 30, 32, 33, 38, 29, 31, 39, 20, 33, 36,
+ 37, 32, 34, 35, 24, 25, 17, 14, 17, 16,
+ 19, 33, 32
+};
+
+#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, 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 /* 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); \
+ 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)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+ void *scanner;
+ struct parse_context *ctx;
+#endif
+{
+ if (!yyvaluep)
+ return;
+ YYUSE (scanner);
+ YYUSE (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)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE const * const yyvaluep;
+ void *scanner;
+ struct parse_context *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);
+ 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 *bottom, yytype_int16 *top)
+#else
+static void
+yy_stack_print (bottom, top)
+ yytype_int16 *bottom;
+ yytype_int16 *top;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; bottom <= top; ++bottom)
+ YYFPRINTF (stderr, " %d", *bottom);
+ 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)
+#else
+static void
+yy_reduce_print (yyvsp, yyrule, scanner, ctx)
+ YYSTYPE *yyvsp;
+ int yyrule;
+ void *scanner;
+ struct parse_context *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++)
+ {
+ fprintf (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ , scanner, ctx);
+ fprintf (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, Rule, scanner, 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)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep, scanner, ctx)
+ const char *yymsg;
+ int yytype;
+ YYSTYPE *yyvaluep;
+ void *scanner;
+ struct parse_context *ctx;
+#endif
+{
+ YYUSE (yyvaluep);
+ YYUSE (scanner);
+ YYUSE (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);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#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)
+#else
+int
+yyparse (scanner, ctx)
+ void *scanner;
+ struct parse_context *ctx;
+#endif
+#endif
+{
+ /* The look-ahead symbol. */
+int yychar;
+
+/* The semantic value of the look-ahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+ int yystate;
+ int yyn;
+ int yyresult;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+ /* Look-ahead token as an internal (translated) token number. */
+ int yytoken = 0;
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+ /* Three stacks and their tools:
+ `yyss': related to states,
+ `yyvs': related to semantic values,
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss = yyssa;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs = yyvsa;
+ YYSTYPE *yyvsp;
+
+
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ YYSIZE_T yystacksize = YYINITDEPTH;
+
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ 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);
+ YYSTACK_RELOCATE (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));
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ look-ahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to look-ahead token. */
+ yyn = yypact[yystate];
+ if (yyn == YYPACT_NINF)
+ goto yydefault;
+
+ /* Not known => get a look-ahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead 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;
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the look-ahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token unless it is eof. */
+ if (yychar != YYEOF)
+ 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 8:
+#line 105 "grammar.y"
+ {
+ ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE);
+ free((yyvsp[(1) - (1)].sval));
+
+ if(ctx->setting == NULL)
+ {
+ libconfig_yyerror(scanner, ctx, err_duplicate_setting);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(ctx->setting);
+ }
+ }
+ break;
+
+ case 10:
+#line 125 "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 11:
+#line 140 "grammar.y"
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ break;
+
+ case 12:
+#line 148 "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 13:
+#line 163 "grammar.y"
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ break;
+
+ case 18:
+#line 178 "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, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_bool(ctx->setting, (int)(yyvsp[(1) - (1)].ival));
+ }
+ break;
+
+ case 19:
+#line 198 "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, 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 20:
+#line 220 "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, 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 21:
+#line 242 "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, 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 22:
+#line 264 "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, 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 23:
+#line 286 "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, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_float(ctx->setting, (yyvsp[(1) - (1)].fval));
+ }
+ break;
+
+ case 24:
+#line 304 "grammar.y"
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1,
+ (yyvsp[(1) - (1)].sval));
+ free((yyvsp[(1) - (1)].sval));
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_string(ctx->setting, (yyvsp[(1) - (1)].sval));
+ free((yyvsp[(1) - (1)].sval));
+ }
+ }
+ break;
+
+ case 33:
+#line 351 "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 34:
+#line 366 "grammar.y"
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ break;
+
+
+/* Line 1267 of yacc.c. */
+#line 1713 "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, 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, yymsg);
+ }
+ else
+ {
+ yyerror (scanner, ctx, YY_("syntax error"));
+ if (yysize != 0)
+ goto yyexhaustedlab;
+ }
+ }
+#endif
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse look-ahead 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);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse look-ahead 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);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ *++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;
+
+#ifndef yyoverflow
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (scanner, ctx, YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEOF && yychar != YYEMPTY)
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval, scanner, 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);
+ 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 372 "grammar.y"
+
+
Index: /tags/2.0-rc2/external/libconfig/wincompat.h
===================================================================
--- /tags/2.0-rc2/external/libconfig/wincompat.h (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/wincompat.h (revision 1304)
@@ -0,0 +1,67 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2008 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
+ .
+ ----------------------------------------------------------------------------
+*/
+
+#ifndef __wincompat_h
+#define __wincompat_h
+
+#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
+
+#include
+
+#define atoll _atoi64
+#define strtoull _strtoui64
+#define snprintf _snprintf
+
+#endif
+
+#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
+ && ! defined(__MINGW32__)
+
+#define INT64_FMT "%I64d"
+#define UINT64_FMT "%I64u"
+
+#define INT64_HEX_FMT "%I64X"
+
+#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_FMT "%lld"
+#define UINT64_FMT "%llu"
+
+#define INT64_HEX_FMT "%llX"
+
+#define INT64_CONST(I) (I ## LL)
+#define UINT64_CONST(I) (I ## ULL)
+
+#endif // defined(WIN32) && ! defined(__MINGW32__)
+
+#endif // __wincompat_h
Index: /tags/2.0-rc2/external/libconfig/scanner.c
===================================================================
--- /tags/2.0-rc2/external/libconfig/scanner.c (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/scanner.c (revision 1304)
@@ -0,0 +1,2284 @@
+#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 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
+#include
+#include
+#include
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have . 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
+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
+
+/* 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
+
+int libconfig_yylex_init (yyscan_t* scanner);
+
+/* 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
+#define YY_BUF_SIZE 16384
+#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 )
+
+/* 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;
+
+#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 26
+#define YY_END_OF_BUFFER 27
+/* 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[117] =
+ { 0,
+ 0, 0, 0, 0, 27, 25, 5, 5, 25, 25,
+ 21, 22, 12, 25, 7, 13, 25, 14, 14, 6,
+ 23, 12, 12, 19, 20, 8, 9, 3, 4, 3,
+ 5, 0, 18, 0, 0, 24, 12, 13, 14, 13,
+ 0, 1, 0, 13, 0, 15, 0, 12, 12, 2,
+ 0, 0, 0, 0, 0, 13, 13, 0, 0, 13,
+ 15, 16, 12, 12, 0, 18, 0, 0, 0, 0,
+ 0, 13, 17, 12, 10, 0, 0, 17, 11, 0,
+ 0, 0, 0, 0, 0, 18, 0, 0, 0, 0,
+ 0, 0, 0, 0, 18, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 18, 0, 0, 0, 0, 0, 0,
+ 0, 18, 0, 0, 0, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 5, 1, 1, 1, 1, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 16, 17, 1,
+ 18, 1, 1, 1, 19, 20, 20, 20, 21, 22,
+ 23, 23, 23, 23, 23, 24, 23, 23, 23, 23,
+ 23, 25, 26, 27, 28, 23, 23, 29, 23, 23,
+ 30, 31, 32, 1, 33, 1, 19, 20, 20, 20,
+
+ 21, 22, 23, 23, 23, 23, 23, 34, 23, 23,
+ 23, 23, 23, 25, 26, 27, 28, 23, 23, 29,
+ 23, 23, 35, 1, 36, 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[37] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 2, 1, 1,
+ 2, 1, 1, 3, 3, 1, 1, 1, 3, 3,
+ 3, 3, 2, 2, 2, 2, 2, 2, 2, 1,
+ 1, 1, 2, 2, 1, 1
+ } ;
+
+static yyconst flex_int16_t yy_base[128] =
+ { 0,
+ 0, 0, 34, 35, 199, 503, 37, 42, 37, 195,
+ 503, 503, 0, 34, 503, 36, 39, 57, 41, 503,
+ 503, 163, 150, 503, 503, 503, 503, 503, 503, 152,
+ 56, 56, 71, 160, 151, 503, 0, 49, 68, 76,
+ 84, 503, 150, 86, 94, 128, 0, 43, 118, 503,
+ 108, 57, 125, 106, 101, 103, 108, 116, 118, 120,
+ 503, 102, 98, 99, 75, 134, 101, 99, 138, 88,
+ 130, 134, 70, 64, 0, 58, 142, 503, 0, 154,
+ 166, 156, 158, 164, 172, 202, 177, 170, 180, 181,
+ 178, 214, 244, 256, 286, 189, 220, 316, 328, 192,
+
+ 206, 218, 231, 340, 262, 222, 264, 229, 352, 382,
+ 412, 442, 270, 294, 358, 503, 473, 476, 479, 481,
+ 51, 484, 487, 490, 493, 496, 499
+ } ;
+
+static yyconst flex_int16_t yy_def[128] =
+ { 0,
+ 116, 1, 117, 117, 116, 116, 116, 116, 118, 119,
+ 116, 116, 120, 116, 116, 116, 116, 116, 116, 116,
+ 116, 120, 120, 116, 116, 116, 116, 116, 116, 116,
+ 116, 118, 116, 118, 119, 116, 120, 116, 116, 116,
+ 116, 116, 119, 116, 116, 116, 121, 120, 120, 116,
+ 116, 122, 123, 116, 116, 116, 116, 116, 116, 116,
+ 116, 121, 120, 120, 122, 116, 122, 123, 116, 124,
+ 116, 116, 116, 120, 120, 124, 124, 116, 120, 124,
+ 124, 125, 126, 124, 125, 124, 125, 125, 126, 126,
+ 124, 125, 126, 125, 125, 127, 125, 126, 124, 127,
+
+ 126, 126, 127, 126, 127, 127, 125, 126, 127, 127,
+ 125, 127, 127, 127, 127, 0, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116
+ } ;
+
+static yyconst flex_int16_t yy_nxt[540] =
+ { 0,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 14, 16, 17, 18, 19, 20, 21, 20, 13, 13,
+ 13, 22, 13, 13, 13, 13, 23, 13, 13, 24,
+ 6, 25, 6, 13, 26, 27, 29, 29, 31, 31,
+ 33, 30, 30, 31, 31, 38, 42, 39, 39, 40,
+ 40, 43, 44, 62, 39, 39, 41, 31, 31, 33,
+ 66, 45, 40, 40, 46, 77, 63, 34, 44, 41,
+ 39, 39, 51, 51, 52, 53, 63, 45, 66, 44,
+ 46, 39, 39, 54, 79, 47, 34, 67, 45, 40,
+ 40, 46, 55, 78, 55, 77, 41, 56, 56, 57,
+
+ 57, 69, 59, 116, 59, 67, 58, 60, 60, 51,
+ 51, 52, 53, 70, 56, 56, 56, 56, 53, 75,
+ 54, 57, 57, 74, 71, 73, 71, 69, 58, 72,
+ 72, 60, 60, 60, 60, 51, 51, 52, 53, 51,
+ 51, 52, 53, 72, 72, 64, 54, 72, 72, 77,
+ 54, 61, 36, 36, 80, 81, 81, 82, 83, 86,
+ 80, 77, 116, 87, 50, 90, 84, 81, 81, 82,
+ 83, 91, 76, 77, 49, 86, 83, 87, 84, 87,
+ 86, 48, 80, 80, 87, 77, 88, 90, 90, 92,
+ 80, 92, 104, 93, 92, 104, 105, 36, 116, 105,
+
+ 116, 116, 88, 81, 81, 82, 83, 88, 80, 77,
+ 116, 116, 116, 90, 84, 94, 94, 95, 96, 106,
+ 80, 87, 106, 86, 80, 108, 97, 107, 116, 105,
+ 101, 80, 96, 92, 104, 116, 90, 116, 105, 116,
+ 116, 93, 116, 116, 88, 98, 99, 100, 101, 116,
+ 88, 90, 116, 116, 116, 116, 102, 94, 94, 95,
+ 96, 106, 116, 87, 92, 104, 116, 86, 97, 105,
+ 116, 87, 92, 104, 109, 116, 92, 105, 116, 116,
+ 116, 116, 116, 116, 116, 116, 88, 94, 94, 95,
+ 96, 116, 106, 87, 88, 116, 92, 104, 97, 116,
+
+ 106, 115, 116, 116, 116, 116, 113, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 88, 98, 99, 100,
+ 101, 116, 116, 90, 106, 116, 116, 116, 102, 81,
+ 81, 82, 83, 116, 116, 77, 116, 116, 116, 116,
+ 84, 98, 99, 100, 101, 116, 116, 90, 116, 116,
+ 116, 116, 102, 110, 111, 112, 113, 116, 116, 105,
+ 92, 104, 116, 116, 114, 105, 116, 116, 116, 116,
+ 109, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 106, 110, 111, 112, 113, 116, 106, 105,
+ 116, 116, 116, 116, 114, 116, 116, 116, 116, 116,
+
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 106, 94, 94, 95, 96, 116, 116, 87,
+ 116, 116, 116, 116, 97, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 88, 110, 111, 112, 113, 116, 116, 105,
+ 116, 116, 116, 116, 114, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 106, 28, 28, 28, 32, 32, 32, 35,
+ 35, 35, 37, 37, 65, 65, 65, 68, 68, 68,
+ 76, 76, 76, 85, 85, 85, 89, 89, 89, 103,
+
+ 103, 103, 5, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116
+ } ;
+
+static yyconst flex_int16_t yy_chk[540] =
+ { 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, 3, 4, 7, 7,
+ 9, 3, 4, 8, 8, 14, 17, 14, 14, 16,
+ 16, 17, 19, 121, 19, 19, 16, 31, 31, 32,
+ 52, 19, 38, 38, 19, 76, 48, 9, 18, 38,
+ 18, 18, 33, 33, 33, 33, 48, 18, 65, 39,
+ 18, 39, 39, 33, 74, 18, 32, 52, 39, 40,
+ 40, 39, 41, 73, 41, 70, 40, 41, 41, 44,
+
+ 44, 68, 45, 67, 45, 65, 44, 45, 45, 51,
+ 51, 51, 51, 54, 55, 55, 56, 56, 54, 64,
+ 51, 57, 57, 63, 58, 62, 58, 53, 57, 58,
+ 58, 59, 59, 60, 60, 66, 66, 66, 66, 69,
+ 69, 69, 69, 71, 71, 49, 66, 72, 72, 77,
+ 69, 46, 43, 35, 77, 80, 80, 80, 80, 82,
+ 83, 80, 34, 82, 30, 83, 80, 81, 81, 81,
+ 81, 84, 88, 81, 23, 85, 84, 88, 81, 85,
+ 87, 22, 89, 90, 87, 91, 82, 89, 90, 87,
+ 91, 96, 96, 90, 100, 100, 96, 10, 5, 100,
+
+ 0, 0, 85, 86, 86, 86, 86, 87, 101, 86,
+ 0, 0, 0, 101, 86, 92, 92, 92, 92, 96,
+ 102, 92, 100, 97, 106, 102, 92, 97, 0, 106,
+ 102, 108, 97, 103, 103, 0, 108, 0, 103, 0,
+ 0, 108, 0, 0, 92, 93, 93, 93, 93, 0,
+ 97, 93, 0, 0, 0, 0, 93, 94, 94, 94,
+ 94, 103, 0, 94, 105, 105, 0, 107, 94, 105,
+ 0, 107, 113, 113, 105, 0, 107, 113, 0, 0,
+ 0, 0, 0, 0, 0, 0, 94, 95, 95, 95,
+ 95, 0, 105, 95, 107, 0, 114, 114, 95, 0,
+
+ 113, 114, 0, 0, 0, 0, 114, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 95, 98, 98, 98,
+ 98, 0, 0, 98, 114, 0, 0, 0, 98, 99,
+ 99, 99, 99, 0, 0, 99, 0, 0, 0, 0,
+ 99, 104, 104, 104, 104, 0, 0, 104, 0, 0,
+ 0, 0, 104, 109, 109, 109, 109, 0, 0, 109,
+ 115, 115, 0, 0, 109, 115, 0, 0, 0, 0,
+ 115, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 109, 110, 110, 110, 110, 0, 115, 110,
+ 0, 0, 0, 0, 110, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 110, 111, 111, 111, 111, 0, 0, 111,
+ 0, 0, 0, 0, 111, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 111, 112, 112, 112, 112, 0, 0, 112,
+ 0, 0, 0, 0, 112, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 112, 117, 117, 117, 118, 118, 118, 119,
+ 119, 119, 120, 120, 122, 122, 122, 123, 123, 123,
+ 124, 124, 124, 125, 125, 125, 126, 126, 126, 127,
+
+ 127, 127, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116, 116,
+ 116, 116, 116, 116, 116, 116, 116, 116, 116
+ } ;
+
+/* Table of booleans, true if rule could match eol. */
+static yyconst flex_int32_t yy_rule_can_match_eol[27] =
+ { 0,
+0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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-2008 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
+ .
+ ----------------------------------------------------------------------------
+*/
+#line 25 "scanner.l"
+#define YY_EXTRA_TYPE void*
+#define YY_NO_UNISTD_H 1
+#line 38 "scanner.l"
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#include
+#include
+#include "grammar.h"
+#include "wincompat.h"
+
+/* this is somewhat kludgy, but I wanted to avoid building strings
+ dynamically during scanning */
+
+static char *make_string(char *s)
+{
+ char *r = ++s;
+ char *p, *q = r;
+ size_t len = strlen(r);
+ int esc = 0;
+
+ *(r + --len) = 0;
+
+ for(p = r; *p; p++)
+ {
+ if(*p == '\\')
+ {
+ if(! esc)
+ {
+ esc = 1;
+ continue;
+ }
+ }
+
+ if(esc)
+ {
+ if(*p == 'n')
+ *(q++) = '\n';
+ else if(*p == 'r')
+ *(q++) = '\r';
+ else if(*p == 'f')
+ *(q++) = '\f';
+ else if(*p == 't')
+ *(q++) = '\t';
+ else
+ *(q++) = *p;
+
+ esc = 0;
+ }
+
+ else if(*p == '\"') /* if we reached the end of a string segment, ... */
+ {
+ /* This construction allows for C-style string concatenation.
+ We don't bother to check for end-of-string here, as we depend
+ on the {string} definition to ensure a new opening quote exists.
+ We do, however, check for and discard all forms of comments
+ [that is, (#...$|//...$|[/][*]...[*][/])] between string segments. */
+
+ while (*++p != '\"') /* ... look for the start of the next segment */
+ {
+ if(*p == '#') /* check for #...$ comment */
+ {
+ while(*++p != '\n')
+ {
+ /* skip the rest of the line */
+ }
+ }
+ else if (*p == '/')
+ {
+ if(*++p == '/') /* check for //...$ comment */
+ {
+ while (*++p != '\n')
+ {
+ /* skip the rest of the line */
+ }
+ }
+ else /* must be '*', lead-in to an old C-style comment */
+ {
+ while (*++p != '*' || *(p+1) != '/')
+ {
+ /* skip all comment content */
+ }
+ ++p; /* step to the trailing slash, to skip it as well */
+ }
+ }
+ }
+ }
+ else
+ *(q++) = *p;
+ }
+
+ *q = 0;
+
+ return(r);
+}
+
+
+#line 734 "scanner.c"
+
+#define INITIAL 0
+#define COMMENT 1
+
+#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
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* 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
+
+/* 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
+#define YY_READ_BUF_SIZE 8192
+#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 (void) fwrite( yytext, yyleng, 1, yyout )
+#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 \
+ 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 160 "scanner.l"
+
+
+#line 963 "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_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 >= 117 )
+ 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] != 503 );
+
+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 162 "scanner.l"
+{ BEGIN COMMENT; }
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 163 "scanner.l"
+{ BEGIN INITIAL; }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 164 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 4:
+/* rule 4 can match eol */
+YY_RULE_SETUP
+#line 165 "scanner.l"
+{ }
+ YY_BREAK
+case 5:
+/* rule 5 can match eol */
+YY_RULE_SETUP
+#line 167 "scanner.l"
+{ /* skip */ }
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 169 "scanner.l"
+{ return(TOK_EQUALS); }
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 170 "scanner.l"
+{ return(TOK_COMMA); }
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 171 "scanner.l"
+{ return(TOK_GROUP_START); }
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 172 "scanner.l"
+{ return(TOK_GROUP_END); }
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 173 "scanner.l"
+{ yylval->ival = 1; return(TOK_BOOLEAN); }
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 174 "scanner.l"
+{ yylval->ival = 0; return(TOK_BOOLEAN); }
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 175 "scanner.l"
+{ yylval->sval = strdup(yytext); return(TOK_NAME); }
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 176 "scanner.l"
+{ yylval->fval = atof(yytext); return(TOK_FLOAT); }
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 177 "scanner.l"
+{ yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 178 "scanner.l"
+{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 179 "scanner.l"
+{ yylval->ival = strtoul(yytext, NULL, 16); return(TOK_HEX); }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 180 "scanner.l"
+{ yylval->llval = strtoull(yytext, NULL, 16); return(TOK_HEX64); }
+ YY_BREAK
+case 18:
+/* rule 18 can match eol */
+YY_RULE_SETUP
+#line 181 "scanner.l"
+{ yylval->sval = strdup(make_string(yytext)); return(TOK_STRING); }
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 182 "scanner.l"
+{ return(TOK_ARRAY_START); }
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 183 "scanner.l"
+{ return(TOK_ARRAY_END); }
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 184 "scanner.l"
+{ return(TOK_LIST_START); }
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 185 "scanner.l"
+{ return(TOK_LIST_END); }
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 186 "scanner.l"
+{ return(TOK_END); }
+ YY_BREAK
+case 24:
+*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 187 "scanner.l"
+{ /* ignore */ }
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 188 "scanner.l"
+{ return(TOK_GARBAGE); }
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 189 "scanner.l"
+ECHO;
+ YY_BREAK
+#line 1196 "scanner.c"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(COMMENT):
+ yyterminate();
+
+ 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, 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;
+
+ 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;
+
+ 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 >= 117 )
+ 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 >= 117 )
+ 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 == 116);
+
+ 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;
+
+ if ( c == '\n' )
+
+ 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);
+
+ 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);
+
+ /* 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 str 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 bytes the byte buffer to scan
+ * @param 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 );
+}
+
+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 189 "scanner.l"
Index: /tags/2.0-rc2/external/libconfig/grammar.h
===================================================================
--- /tags/2.0-rc2/external/libconfig/grammar.h (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/grammar.h (revision 1304)
@@ -0,0 +1,105 @@
+/* A Bison parser, made by GNU Bison 2.3. */
+
+/* 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 2, 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
+
+/* 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_END = 275,
+ TOK_GARBAGE = 276
+ };
+#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_END 275
+#define TOK_GARBAGE 276
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+#line 73 "grammar.y"
+{
+ long ival;
+ long long llval;
+ double fval;
+ char *sval;
+}
+/* Line 1489 of yacc.c. */
+#line 98 "grammar.h"
+ YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
Index: /tags/2.0-rc2/external/libconfig/libconfig.c
===================================================================
--- /tags/2.0-rc2/external/libconfig/libconfig.c (revision 1304)
+++ /tags/2.0-rc2/external/libconfig/libconfig.c (revision 1304)
@@ -0,0 +1,1310 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2008 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
+ .
+ ----------------------------------------------------------------------------
+*/
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include
+#endif
+
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+#endif
+
+#include "libconfig.h"
+#include "grammar.h"
+#include "scanner.h"
+#include "private.h"
+#include "wincompat.h"
+
+#include
+#include
+
+#define PATH_TOKENS ":./"
+#define CHUNK_SIZE 10
+#define FLOAT_PRECISION 10
+
+#define _new(T) (T *)calloc(sizeof(T), 1) /* zeroed */
+#define _delete(P) free((void *)(P))
+
+/* ------------------------------------------------------------------------- */
+
+#ifdef WIN32
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ return(TRUE);
+}
+
+#endif
+
+/* ------------------------------------------------------------------------- */
+
+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);
+
+extern int libconfig_yyparse(void *scanner, struct parse_context *ctx);
+
+/* ------------------------------------------------------------------------- */
+
+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_write_value(const config_value_t *value, int type,
+ int format, int depth, 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%lX", value->ival);
+ break;
+
+ case CONFIG_FORMAT_DEFAULT:
+ default:
+ fprintf(stream, "%ld", 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);
+
+ 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++)
+ {
+ switch(*p)
+ {
+ case '\"':
+ case '\\':
+ fputc('\\', stream);
+ fputc(*p, 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:
+ fputc(*p, stream);
+ }
+ }
+ }
+ 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, (*s)->format,
+ depth + 1, 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, (*s)->format,
+ depth + 1, stream);
+
+ if(len)
+ fputc(',', stream);
+
+ fputc(' ', stream);
+ }
+ }
+
+ fputc(']', stream);
+ break;
+ }
+
+ /* group */
+ case CONFIG_TYPE_GROUP:
+ {
+ config_list_t *list = value->list;
+
+ if(depth > 0)
+ {
+ fputc('\n', stream);
+
+ if(depth > 1)
+ fprintf(stream, "%*s", (depth - 1) * 2, " ");
+ 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);
+ }
+
+ if(depth > 1)
+ fprintf(stream, "%*s", (depth - 1) * 2, " ");
+
+ 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 == list->capacity)
+ {
+ list->capacity += CHUNK_SIZE;
+ list->elements = (config_setting_t **)realloc(
+ list->elements, list->capacity * 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 void __config_list_remove(config_list_t *list, int 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--;
+
+ if((list->capacity - list->length) >= CHUNK_SIZE)
+ {
+ /* realloc smaller? */
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+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);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_read(config_t *config, FILE *stream)
+{
+ yyscan_t scanner;
+ struct parse_context ctx;
+ int r;
+
+ /* Reinitialize the config (keep the destructor) */
+ void (*destructor)(void *) = config->destructor;
+ config_destroy(config);
+ config_init(config);
+ config->destructor = destructor;
+
+ ctx.config = config;
+ ctx.parent = config->root;
+ ctx.setting = config->root;
+
+ libconfig_yylex_init(&scanner);
+ libconfig_yyrestart(stream, scanner);
+ r = libconfig_yyparse(scanner, &ctx);
+ libconfig_yylex_destroy(scanner);
+
+ return(r == 0 ? CONFIG_TRUE : CONFIG_FALSE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+static void __config_write_setting(const config_setting_t *setting,
+ FILE *stream, int depth)
+{
+ if(depth > 1)
+ fprintf(stream, "%*s", (depth - 1) * 2, " ");
+
+ if(setting->name)
+ {
+ fputs(setting->name, stream);
+ fprintf(stream, " %c ", (setting->type == CONFIG_TYPE_GROUP ? ':' : '='));
+ }
+
+ __config_write_value(&(setting->value), setting->type, setting->format,
+ depth, stream);
+
+ if(depth > 0)
+ {
+ fputc(';', stream);
+ fputc('\n', stream);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_write(const config_t *config, FILE *stream)
+{
+ __config_write_setting(config->root, stream, 0);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_read_file(config_t *config, const char *filename)
+{
+ int ret;
+ FILE *f = fopen(filename, "rt");
+ if(! f)
+ {
+ config->error_text = __io_error;
+ return(CONFIG_FALSE);
+ }
+
+ ret = config_read(config, f);
+ fclose(f);
+ return(ret);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_write_file(config_t *config, const char *filename)
+{
+ FILE *f = fopen(filename, "wt");
+ if(! f)
+ {
+ config->error_text = __io_error;
+ return(CONFIG_FALSE);
+ }
+
+ config_write(config, f);
+ fclose(f);
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void config_destroy(config_t *config)
+{
+ __config_setting_destroy(config->root);
+
+ 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;
+}
+
+/* ------------------------------------------------------------------------- */
+
+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);
+}
+
+/* ------------------------------------------------------------------------- */
+
+long config_setting_get_int(const config_setting_t *setting)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_INT:
+ return(setting->value.ival);
+
+ case CONFIG_TYPE_INT64:
+ if((setting->value.llval > INT32_MAX)
+ || (setting->value.llval < INT32_MIN))
+ return(0);
+ else
+ return((long)setting->value.llval);
+
+ case CONFIG_TYPE_FLOAT:
+ if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0)
+ return((long)(setting->value.fval));
+ else
+ /* fall through */;
+
+ default:
+ return(0);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+long long config_setting_get_int64(const config_setting_t *setting)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_INT64:
+ return(setting->value.llval);
+
+ case CONFIG_TYPE_INT:
+ return((long long)setting->value.ival);
+
+ case CONFIG_TYPE_FLOAT:
+ if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0)
+ return((long long)(setting->value.fval));
+ else
+ /* fall through */;
+
+ default:
+ return(0);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_set_int(config_setting_t *setting, long 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 = (long)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);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+double config_setting_get_float(const config_setting_t *setting)
+{
+ switch(setting->type)
+ {
+ case CONFIG_TYPE_FLOAT:
+ return(setting->value.fval);
+
+ case CONFIG_TYPE_INT:
+ if(config_get_auto_convert(setting->config))
+ return((double)(setting->value.ival));
+ else
+ return(0.0);
+
+ case CONFIG_TYPE_INT64:
+ if(config_get_auto_convert(setting->config))
+ return((double)(setting->value.llval));
+ else
+ return(0.0);
+
+ default:
+ return(0.0);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+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 = (long)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(config_setting_t *setting)
+{
+ return(setting->format);
+}
+
+/* ------------------------------------------------------------------------- */
+
+config_setting_t *config_lookup(const config_t *config, const char *path)
+{
+ const char *p = path;
+ config_setting_t *setting = config->root, *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);
+}
+
+/* ------------------------------------------------------------------------- */
+
+const char *config_lookup_string(const config_t *config, const char *path)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(NULL);
+
+ return(config_setting_get_string(s));
+}
+
+/* ------------------------------------------------------------------------- */
+
+long config_lookup_int(const config_t *config, const char *path)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(0);
+
+ return(config_setting_get_int(s));
+}
+
+/* ------------------------------------------------------------------------- */
+
+long long config_lookup_int64(const config_t *config, const char *path)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(INT64_CONST(0));
+
+ return(config_setting_get_int64(s));
+}
+
+/* ------------------------------------------------------------------------- */
+
+double config_lookup_float(const config_t *config, const char *path)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(0.0);
+
+ return(config_setting_get_float(s));
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_lookup_bool(const config_t *config, const char *path)
+{
+ const config_setting_t *s = config_lookup(config, path);
+ if(! s)
+ return(0);
+
+ return(config_setting_get_bool(s));
+}
+
+/* ------------------------------------------------------------------------- */
+
+long 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, 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_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;
+}
+
+/* ------------------------------------------------------------------------- */
+
+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_setting_destroy(setting);
+
+ __config_list_remove(parent->value.list, idx);
+
+ return(CONFIG_TRUE);
+}
+
+/* ------------------------------------------------------------------------- */
+
+int config_setting_remove_elem(config_setting_t *parent, unsigned int idx)
+{
+ config_list_t *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);
+
+ __config_list_remove(list, idx);
+
+ 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 < list->length; ++i, ++found)
+ {
+ if(*found == setting)
+ return(i);
+ }
+
+ return(-1);
+}
+
+/* ------------------------------------------------------------------------- */
+/* eof */
Index: /tags/2.0-rc2/external/dbus/tools/introspect.h
===================================================================
--- /tags/2.0-rc2/external/dbus/tools/introspect.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/tools/introspect.h (revision 562)
@@ -0,0 +1,44 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_TOOLS_INTROSPECT_H
+#define __DBUSXX_TOOLS_INTROSPECT_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+
+class IntrospectedObject : public DBus::IntrospectableProxy, public DBus::ObjectProxy
+{
+public:
+
+ IntrospectedObject( DBus::Connection& conn, const char* path, const char* service )
+ : DBus::ObjectProxy(conn, path, service)
+ {}
+};
+
+#endif//__DBUSXX_TOOLS_INTROSPECT_H
Index: /tags/2.0-rc2/external/dbus/tools/xml.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/tools/xml.cpp (revision 562)
+++ /tags/2.0-rc2/external/dbus/tools/xml.cpp (revision 562)
@@ -0,0 +1,315 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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 "xml.h"
+
+#include
+
+#include
+
+std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc )
+{
+ std::stringbuf xmlbuf;
+ in.get(xmlbuf, '\0');
+ doc.from_xml(xmlbuf.str());
+
+ return in;
+}
+
+std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc )
+{
+ return out << doc.to_xml();
+}
+
+using namespace DBus;
+using namespace DBus::Xml;
+
+Error::Error( const char* error, int line, int column )
+{
+ std::ostringstream estream;
+
+ estream << "line " << line << ", column " << column << ": " << error;
+
+ _error = estream.str();
+}
+
+Node::Node( const char* n, const char** a )
+: name(n)
+{
+ if(a)
+ for(int i = 0; a[i]; i += 2)
+ {
+ _attrs[a[i]] = a[i+1];
+
+ //debug_log("xml:\t%s = %s", a[i], a[i+1]);
+ }
+}
+
+Nodes Nodes::operator[]( const std::string& key )
+{
+ Nodes result;
+
+ for(iterator i = begin(); i != end(); ++i)
+ {
+ Nodes part = (**i)[key];
+
+ result.insert(result.end(), part.begin(), part.end());
+ }
+ return result;
+}
+
+Nodes Nodes::select( const std::string& attr, const std::string& value )
+{
+ Nodes result;
+
+ for(iterator i = begin(); i != end(); ++i)
+ {
+ if((*i)->get(attr) == value)
+ result.insert(result.end(), *i);
+ }
+ return result;
+}
+
+Nodes Node::operator[]( const std::string& key )
+{
+ Nodes result;
+
+ if(key.length() == 0) return result;
+
+ for(Children::iterator i = children.begin(); i != children.end(); ++i)
+ {
+ if(i->name == key)
+ result.push_back(&(*i));
+ }
+ return result;
+}
+
+std::string Node::get( const std::string& attribute )
+{
+ if(_attrs.find(attribute) != _attrs.end())
+ return _attrs[attribute];
+ else
+ return "";
+}
+
+void Node::set( const std::string& attribute, std::string value )
+{
+ if(value.length())
+ _attrs[attribute] = value;
+ else
+ _attrs.erase(value);
+}
+
+std::string Node::to_xml() const
+{
+ std::string xml;
+ int depth = 0;
+
+ _raw_xml(xml, depth);
+
+ return xml;
+}
+
+void Node::_raw_xml( std::string& xml, int& depth ) const
+{
+ xml.append(depth*2, ' ');
+ xml.append("<"+name);
+
+ for(Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i)
+ {
+ xml.append(" "+i->first+"=\""+i->second+"\"");
+ }
+
+ if(cdata.length() == 0 && children.size() == 0)
+ {
+ xml.append("/>\n");
+ }
+ else
+ {
+ xml.append(">");
+
+ if(cdata.length())
+ {
+ xml.append(cdata);
+ }
+
+ if(children.size())
+ {
+ xml.append("\n");
+ depth++;
+
+ for(Children::const_iterator i = children.begin(); i != children.end(); ++i)
+ {
+ i->_raw_xml(xml, depth);
+ }
+
+ depth--;
+ xml.append(depth*2, ' ');
+ }
+ xml.append(""+name+">\n");
+ }
+}
+
+Document::Document()
+: root(0), _depth(0)
+{
+}
+
+Document::Document( const std::string& xml )
+: root(0), _depth(0)
+{
+ from_xml(xml);
+}
+
+Document::~Document()
+{
+ delete root;
+}
+
+struct Document::Expat
+{
+ static void start_doctype_decl_handler(
+ void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset
+ );
+ static void end_doctype_decl_handler( void* data );
+ static void start_element_handler( void *data, const XML_Char *name, const XML_Char **atts );
+ static void character_data_handler( void *data, const XML_Char* chars, int len );
+ static void end_element_handler( void *data, const XML_Char *name );
+};
+
+void Document::from_xml( const std::string& xml )
+{
+ _depth = 0;
+ delete root;
+ root = 0;
+
+ XML_Parser parser = XML_ParserCreate("UTF-8");
+
+ XML_SetUserData(parser, this);
+
+ XML_SetDoctypeDeclHandler(
+ parser,
+ Document::Expat::start_doctype_decl_handler,
+ Document::Expat::end_doctype_decl_handler
+ );
+
+ XML_SetElementHandler(
+ parser,
+ Document::Expat::start_element_handler,
+ Document::Expat::end_element_handler
+ );
+
+ XML_SetCharacterDataHandler(
+ parser,
+ Document::Expat::character_data_handler
+ );
+
+ XML_Status status = XML_Parse(parser, xml.c_str(), xml.length(), true);
+
+ if(status == XML_STATUS_ERROR)
+ {
+ const char* error = XML_ErrorString(XML_GetErrorCode(parser));
+ int line = XML_GetCurrentLineNumber(parser);
+ int column = XML_GetCurrentColumnNumber(parser);
+
+ XML_ParserFree(parser);
+
+ throw Error(error, line, column);
+ }
+ else
+ {
+ XML_ParserFree(parser);
+ }
+}
+
+std::string Document::to_xml() const
+{
+ return root->to_xml();
+}
+
+void Document::Expat::start_doctype_decl_handler(
+ void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset
+)
+{
+}
+
+void Document::Expat::end_doctype_decl_handler( void* data )
+{
+}
+
+void Document::Expat::start_element_handler( void *data, const XML_Char *name, const XML_Char **atts )
+{
+ Document* doc = (Document*)data;
+
+ //debug_log("xml:%d -> %s", doc->_depth, name);
+
+ if(!doc->root)
+ {
+ doc->root = new Node(name, atts);
+ }
+ else
+ {
+ Node::Children* cld = &(doc->root->children);
+
+ for(int i = 1; i < doc->_depth; ++i)
+ {
+ cld = &(cld->back().children);
+ }
+ cld->push_back(Node(name, atts));
+
+ //std::cerr << doc->to_xml() << std::endl;
+ }
+ doc->_depth++;
+}
+
+void Document::Expat::character_data_handler( void *data, const XML_Char* chars, int len )
+{
+ Document* doc = (Document*)data;
+
+ Node* nod = doc->root;
+
+ for(int i = 1; i < doc->_depth; ++i)
+ {
+ nod = &(nod->children.back());
+ }
+ int x, y;
+
+ x = 0;
+ y = len-1;
+
+ while(isspace(chars[y]) && y > 0) --y;
+ while(isspace(chars[x]) && x < y) ++x;
+
+ nod->cdata = std::string(chars, x, y+1);
+}
+
+void Document::Expat::end_element_handler( void *data, const XML_Char *name )
+{
+ Document* doc = (Document*)data;
+
+ //debug_log("xml:%d <- %s", doc->_depth, name);
+
+ doc->_depth--;
+}
+
Index: /tags/2.0-rc2/external/dbus/tools/xml.h
===================================================================
--- /tags/2.0-rc2/external/dbus/tools/xml.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/tools/xml.h (revision 562)
@@ -0,0 +1,142 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_XML_H
+#define __DBUSXX_XML_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace DBus {
+
+namespace Xml {
+
+class Error : public std::exception
+{
+public:
+
+ Error( const char* error, int line, int column );
+
+ ~Error() throw()
+ {}
+
+ const char* what() const throw()
+ {
+ return _error.c_str();
+ }
+
+private:
+
+ std::string _error;
+};
+
+class Node;
+
+class Nodes : public std::vector
+{
+public:
+
+ Nodes operator[]( const std::string& key );
+
+ Nodes select( const std::string& attr, const std::string& value );
+};
+
+class Node
+{
+public:
+
+ typedef std::map Attributes;
+
+ typedef std::vector Children;
+
+ std::string name;
+ std::string cdata;
+ Children children;
+
+ Node( std::string& n, Attributes& a )
+ : name(n), _attrs(a)
+ {}
+
+ Node( const char* n, const char** a = NULL );
+
+ Nodes operator[]( const std::string& key );
+
+ std::string get( const std::string& attribute );
+
+ void set( const std::string& attribute, std::string value );
+
+ std::string to_xml() const;
+
+ Node& add( Node child )
+ {
+ children.push_back(child);
+ return children.back();
+ }
+
+private:
+
+ void _raw_xml( std::string& xml, int& depth ) const;
+
+ Attributes _attrs;
+};
+
+class Document
+{
+public:
+
+ struct Expat;
+
+ Node* root;
+
+ Document();
+
+ Document( const std::string& xml );
+
+ ~Document();
+
+ void from_xml( const std::string& xml );
+
+ std::string to_xml() const;
+
+private:
+
+ int _depth;
+};
+
+} /* namespace Xml */
+
+} /* namespace DBus */
+
+std::istream& operator >> ( std::istream&, DBus::Xml::Document& );
+std::ostream& operator << ( std::ostream&, DBus::Xml::Document& );
+
+#endif//__DBUSXX_XML_H
Index: /tags/2.0-rc2/external/dbus/tools/xml2cpp.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/tools/xml2cpp.cpp (revision 1235)
+++ /tags/2.0-rc2/external/dbus/tools/xml2cpp.cpp (revision 1235)
@@ -0,0 +1,975 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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 "xml2cpp.h"
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+using namespace DBus;
+
+static const char* tab = " ";
+
+static const char* header = "\n\
+/*\n\
+ * This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!\n\
+ */\n\
+\n\
+";
+
+static const char* dbus_includes = "\n\
+#include \n\
+\n\
+";
+
+typedef map TypeCache;
+
+void usage( const char* argv0 )
+{
+ cerr << endl << "Usage: " << argv0 << " [ --proxy= ] [ --adaptor= ]"
+ << endl << endl;
+ exit(-1);
+}
+
+void underscorize( string& str )
+{
+ for(unsigned int i = 0; i < str.length(); ++i)
+ {
+ if(!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_';
+ }
+}
+
+string stub_name( string name )
+{
+ underscorize(name);
+
+ return "_" + name + "_stub";
+}
+
+int char_to_atomic_type( char t )
+{
+ if(strchr("ybnqiuxtdsgavre", t))
+ return t;
+
+ return DBUS_TYPE_INVALID;
+}
+
+const char* atomic_type_to_string( char t )
+{
+ static struct { const char type; const char *name; } atos[] =
+ {
+ { 'y', "::DBus::Byte" },
+ { 'b', "::DBus::Bool" },
+ { 'n', "::DBus::Int16" },
+ { 'q', "::DBus::UInt16" },
+ { 'i', "::DBus::Int32" },
+ { 'u', "::DBus::UInt32" },
+ { 'x', "::DBus::Int64" },
+ { 't', "::DBus::UInt64" },
+ { 'd', "::DBus::Double" },
+ { 's', "::DBus::String" },
+ { 'o', "::DBus::Path" },
+ { 'g', "::DBus::Signature" },
+ { 'v', "::DBus::Variant" },
+ { '\0', "" }
+ };
+ int i;
+
+ for(i = 0; atos[i].type; ++i)
+ {
+ if(atos[i].type == t) break;
+ }
+ return atos[i].name;
+}
+
+bool is_atomic_type( const string& type )
+{
+ return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID;
+}
+
+void _parse_signature( const string& signature, string& type, unsigned int& i )
+{
+ for(; i < signature.length(); ++i)
+ {
+ switch(signature[i])
+ {
+ case 'a':
+ {
+ switch(signature[++i])
+ {
+ case '{':
+ {
+ type += "std::map< ";
+
+ const char* atom = atomic_type_to_string(signature[++i]);
+ if(!atom)
+ {
+ cerr << "invalid signature" << endl;
+ exit(-1);
+ }
+ type += atom;
+ type += ", ";
+ ++i;
+ break;
+ }
+ default:
+ {
+ type += "std::vector< ";
+ break;
+ }
+ }
+ _parse_signature(signature, type, i);
+ type += " >";
+ continue;
+ }
+ case '(':
+ {
+ type += "::DBus::Struct< ";
+ ++i;
+ _parse_signature(signature, type, i);
+ type += " >";
+ continue;
+ }
+ case ')':
+ case '}':
+ {
+ return;
+ }
+ default:
+ {
+ const char* atom = atomic_type_to_string(signature[i]);
+ if(!atom)
+ {
+ cerr << "invalid signature" << endl;
+ exit(-1);
+ }
+ type += atom;
+
+ if(signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length())
+ {
+ type += ", ";
+ }
+ break;
+ }
+ }
+ }
+}
+
+string signature_to_type( const string& signature )
+{
+ string type;
+ unsigned int i = 0;
+ _parse_signature(signature, type, i);
+ return type;
+}
+
+void generate_proxy( Xml::Document& doc, const char* filename )
+{
+ cerr << "writing " << filename << endl;
+
+ ofstream file(filename);
+ if(file.bad())
+ {
+ cerr << "unable to write file " << filename << endl;
+ exit(-1);
+ }
+
+ file << header;
+ string filestring = filename;
+ underscorize(filestring);
+
+ string cond_comp = "__dbusxx__" + filestring + "__PROXY_MARSHAL_H";
+
+ file << "#ifndef " << cond_comp << endl;
+ file << "#define " << cond_comp << endl;
+
+ file << dbus_includes;
+
+ Xml::Node& root = *(doc.root);
+ Xml::Nodes interfaces = root["interface"];
+
+ for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
+ {
+ Xml::Node& iface = **i;
+ Xml::Nodes methods = iface["method"];
+ Xml::Nodes signals = iface["signal"];
+ Xml::Nodes properties = iface["property"];
+ Xml::Nodes ms;
+ ms.insert(ms.end(), methods.begin(), methods.end());
+ ms.insert(ms.end(), signals.begin(), signals.end());
+
+ string ifacename = iface.get("name");
+ if(ifacename == "org.freedesktop.DBus.Introspectable"
+ ||ifacename == "org.freedesktop.DBus.Properties")
+ {
+ cerr << "skipping interface " << ifacename << endl;
+ continue;
+ }
+
+ istringstream ss(ifacename);
+ string nspace;
+ unsigned int nspaces = 0;
+
+ while(ss.str().find('.', ss.tellg()) != string::npos)
+ {
+ getline(ss, nspace, '.');
+
+ file << "namespace " << nspace << " {" << endl;
+
+ ++nspaces;
+ }
+ file << endl;
+
+ string ifaceclass;
+
+ getline(ss, ifaceclass);
+
+ cerr << "generating code for interface " << ifacename << "..." << endl;
+
+ file << "class " << ifaceclass << endl
+ << " : public ::DBus::InterfaceProxy" << endl
+ << "{" << endl
+ << "public:" << endl
+ << endl
+ << tab << ifaceclass << "()" << endl
+ << tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl
+ << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
+ {
+ Xml::Node& signal = **si;
+
+ string marshname = "_" + signal.get("name") + "_stub";
+
+ file << tab << tab << "connect_signal("
+ << ifaceclass << ", " << signal.get("name") << ", " << stub_name(signal.get("name"))
+ << ");" << endl;
+ }
+
+ file << tab << "}" << endl
+ << endl;
+
+ file << "public:" << endl
+ << endl
+ << tab << "/* methods exported by this interface," << endl
+ << tab << " * this functions will invoke the corresponding methods on the remote objects" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
+ {
+ Xml::Node& method = **mi;
+ Xml::Nodes args = method["arg"];
+ Xml::Nodes args_in = args.select("direction","in");
+ Xml::Nodes args_out = args.select("direction","out");
+
+ if(args_out.size() == 0 || args_out.size() > 1 )
+ {
+ file << tab << "void ";
+ }
+ else if(args_out.size() == 1)
+ {
+ file << tab << signature_to_type(args_out.front()->get("type")) << " ";
+ }
+
+ file << method.get("name") << "( ";
+
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
+ {
+ Xml::Node& arg = **ai;
+ file << "const " << signature_to_type(arg.get("type")) << "& ";
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << arg_name;
+ else
+ file << "argin" << i;
+
+ if((i+1 != args_in.size() || args_out.size() > 1))
+ file << ", ";
+ }
+
+ if(args_out.size() > 1)
+ {
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
+ {
+ Xml::Node& arg = **ao;
+ file << signature_to_type(arg.get("type")) << "&";
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << " " << arg_name;
+ else
+ file << " argout" << i;
+
+ if(i+1 != args_out.size())
+ file << ", ";
+ }
+ }
+ file << " )" << endl;
+
+ file << tab << "{" << endl
+ << tab << tab << "::DBus::CallMessage call;" << endl;
+
+ if(args_in.size() > 0)
+ {
+ file << tab << tab << "::DBus::MessageIter wi = call.writer();" << endl
+ << endl;
+ }
+
+ unsigned int j = 0;
+ for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j)
+ {
+ Xml::Node& arg = **ai;
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << tab << tab << "wi << " << arg_name << ";" << endl;
+ else
+ file << tab << tab << "wi << argin" << j << ";" << endl;
+ }
+
+ file << tab << tab << "call.member(\"" << method.get("name") << "\");" << endl
+ << tab << tab << "::DBus::Message ret = invoke_method(call);" << endl;
+
+
+ if(args_out.size() > 0)
+ {
+ file << tab << tab << "::DBus::MessageIter ri = ret.reader();" << endl
+ << endl;
+ }
+
+ if(args_out.size() == 1)
+ {
+ file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout;" << endl;
+ file << tab << tab << "ri >> argout;" << endl;
+ file << tab << tab << "return argout;" << endl;
+ }
+ else if(args_out.size() > 1)
+ {
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
+ {
+ Xml::Node& arg = **ao;
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << tab << tab << "ri >> " << arg.get("name") << ";" << endl;
+ else
+ file << tab << tab << "ri >> argout" << i << ";" << endl;
+ }
+ }
+
+ file << tab << "}" << endl
+ << endl;
+ }
+
+ file << endl
+ << "public:" << endl
+ << endl
+ << tab << "/* signal handlers for this interface" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
+ {
+ Xml::Node& signal = **si;
+ Xml::Nodes args = signal["arg"];
+
+ file << tab << "virtual void " << signal.get("name") << "( ";
+
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
+ {
+ Xml::Node& arg = **ai;
+ file << "const " << signature_to_type(arg.get("type")) << "& ";
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << arg_name;
+ else
+ file << "argin" << i;
+
+ if((ai+1 != args.end()))
+ file << ", ";
+ }
+ file << " ) = 0;" << endl;
+ }
+
+ file << endl
+ << "private:" << endl
+ << endl
+ << tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
+ {
+ Xml::Node& signal = **si;
+ Xml::Nodes args = signal["arg"];
+
+ file << tab << "void " << stub_name(signal.get("name")) << "( const ::DBus::SignalMessage& sig )" << endl
+ << tab << "{" << endl;
+
+ if(args.size() > 0)
+ {
+ file << tab << tab << "::DBus::MessageIter ri = sig.reader();" << endl
+ << endl;
+ }
+
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
+ {
+ Xml::Node& arg = **ai;
+ file << tab << tab << signature_to_type(arg.get("type")) << " " ;
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << arg_name << ";" << " ri >> " << arg_name << ";" << endl;
+ else
+ file << "arg" << i << ";" << " ri >> " << "arg" << i << ";" << endl;
+ }
+
+ file << tab << tab << signal.get("name") << "(";
+
+ unsigned int j = 0;
+ for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j)
+ {
+ Xml::Node& arg = **ai;
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << arg_name;
+ else
+ file << "arg" << j;
+
+ if(ai+1 != args.end())
+ file << ", ";
+ }
+
+ file << ");" << endl;
+
+ file << tab << "}" << endl;
+ }
+
+
+ file << "};" << endl
+ << endl;
+
+ for(unsigned int i = 0; i < nspaces; ++i)
+ {
+ file << "} ";
+ }
+ file << endl;
+ }
+
+ file << "#endif//" << cond_comp << endl;
+
+ file.close();
+}
+
+void generate_adaptor( Xml::Document& doc, const char* filename )
+{
+ cerr << "writing " << filename << endl;
+
+ ofstream file(filename);
+ if(file.bad())
+ {
+ cerr << "unable to write file " << filename << endl;
+ exit(-1);
+ }
+
+ file << header;
+ string filestring = filename;
+ underscorize(filestring);
+
+ string cond_comp = "__dbusxx__" + filestring + "__ADAPTOR_MARSHAL_H";
+
+ file << "#ifndef " << cond_comp << endl
+ << "#define " << cond_comp << endl;
+
+ file << dbus_includes;
+
+ Xml::Node& root = *(doc.root);
+ Xml::Nodes interfaces = root["interface"];
+
+ for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
+ {
+ Xml::Node& iface = **i;
+ Xml::Nodes methods = iface["method"];
+ Xml::Nodes signals = iface["signal"];
+ Xml::Nodes properties = iface["property"];
+ Xml::Nodes ms;
+ ms.insert(ms.end(), methods.begin(), methods.end());
+ ms.insert(ms.end(), signals.begin(), signals.end());
+
+ string ifacename = iface.get("name");
+ if(ifacename == "org.freedesktop.DBus.Introspectable"
+ ||ifacename == "org.freedesktop.DBus.Properties")
+ {
+ cerr << "skipping interface " << ifacename << endl;
+ continue;
+ }
+
+ istringstream ss(ifacename);
+ string nspace;
+ unsigned int nspaces = 0;
+
+ while(ss.str().find('.', ss.tellg()) != string::npos)
+ {
+ getline(ss, nspace, '.');
+
+ file << "namespace " << nspace << " {" << endl;
+
+ ++nspaces;
+ }
+ file << endl;
+
+ string ifaceclass;
+
+ getline(ss, ifaceclass);
+
+ cerr << "generating code for interface " << ifacename << "..." << endl;
+
+ file << "class " << ifaceclass << endl
+ << ": public ::DBus::InterfaceAdaptor" << endl
+ << "{" << endl
+ << "public:" << endl
+ << endl
+ << tab << ifaceclass << "()" << endl
+ << tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl
+ << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
+ {
+ Xml::Node& property = **pi;
+
+ file << tab << tab << "bind_property("
+ << property.get("name") << ", "
+ << "\"" << property.get("type") << "\", "
+ << ( property.get("access").find("read") != string::npos
+ ? "true"
+ : "false" )
+ << ", "
+ << ( property.get("access").find("write") != string::npos
+ ? "true"
+ : "false" )
+ << ");" << endl;
+ }
+
+ for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
+ {
+ Xml::Node& method = **mi;
+
+ file << tab << tab << "register_method("
+ << ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
+ << ");" << endl;
+ }
+
+ file << tab << "}" << endl
+ << endl;
+
+ file << tab << "::DBus::IntrospectedInterface* const introspect() const " << endl
+ << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
+ {
+ Xml::Node& method = **mi;
+ Xml::Nodes args = method["arg"];
+
+ file << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl
+ << tab << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai)
+ {
+ Xml::Node& arg = **ai;
+
+ file << tab << tab << tab << "{ ";
+
+ if(arg.get("name").length())
+ {
+ file << "\"" << arg.get("name") << "\", ";
+ }
+ else
+ {
+ file << "0, ";
+ }
+ file << "\"" << arg.get("type") << "\", "
+ << ( arg.get("direction") == "in" ? "true" : "false" )
+ << " }," << endl;
+ }
+ file << tab << tab << tab << "{ 0, 0, 0 }" << endl
+ << tab << tab << "};" << endl;
+ }
+
+ file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl
+ << tab << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
+ {
+ Xml::Node& method = **mi;
+
+ file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
+ }
+
+ file << tab << tab << tab << "{ 0, 0 }" << endl
+ << tab << tab << "};" << endl;
+
+ file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl
+ << tab << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
+ {
+ Xml::Node& method = **si;
+
+ file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
+ }
+
+ file << tab << tab << tab << "{ 0, 0 }" << endl
+ << tab << tab << "};" << endl;
+
+ file << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl
+ << tab << tab << "{" << endl;
+
+ for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
+ {
+ Xml::Node& property = **pi;
+
+ file << tab << tab << tab << "{ "
+ << "\"" << property.get("name") << "\", "
+ << "\"" << property.get("type") << "\", "
+ << ( property.get("access").find("read") != string::npos
+ ? "true"
+ : "false" )
+ << ", "
+ << ( property.get("access").find("write") != string::npos
+ ? "true"
+ : "false" )
+ << " }," << endl;
+ }
+
+
+ file << tab << tab << tab << "{ 0, 0, 0, 0 }" << endl
+ << tab << tab << "};" << endl;
+
+ file << tab << tab << "static ::DBus::IntrospectedInterface " << ifaceclass << "_interface = " << endl
+ << tab << tab << "{" << endl
+ << tab << tab << tab << "\"" << ifacename << "\"," << endl
+ << tab << tab << tab << ifaceclass << "_methods," << endl
+ << tab << tab << tab << ifaceclass << "_signals," << endl
+ << tab << tab << tab << ifaceclass << "_properties" << endl
+ << tab << tab << "};" << endl
+ << tab << tab << "return &" << ifaceclass << "_interface;" << endl
+ << tab << "}" << endl
+ << endl;
+
+ file << "public:" << endl
+ << endl
+ << tab << "/* properties exposed by this interface, use" << endl
+ << tab << " * property() and property(value) to get and set a particular property" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
+ {
+ Xml::Node& property = **pi;
+ string name = property.get("name");
+ string type = property.get("type");
+ string type_name = signature_to_type(type);
+
+ file << tab << "::DBus::PropertyAdaptor< " << type_name << " > " << name << ";" << endl;
+ }
+
+ file << endl;
+
+ file << "public:" << endl
+ << endl
+ << tab << "/* methods exported by this interface," << endl
+ << tab << " * you will have to implement them in your ObjectAdaptor" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
+ {
+ Xml::Node& method = **mi;
+ Xml::Nodes args = method["arg"];
+ Xml::Nodes args_in = args.select("direction","in");
+ Xml::Nodes args_out = args.select("direction","out");
+
+ file << tab << "virtual ";
+
+ if(args_out.size() == 0 || args_out.size() > 1 )
+ {
+ file << "void ";
+ }
+ else if(args_out.size() == 1)
+ {
+ file << signature_to_type(args_out.front()->get("type")) << " ";
+ }
+
+ file << method.get("name") << "( ";
+
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
+ {
+ Xml::Node& arg = **ai;
+ file << "const " << signature_to_type(arg.get("type")) << "& ";
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << arg_name;
+
+ if((i+1 != args_in.size() || args_out.size() > 1))
+ file << ", ";
+ }
+
+ if(args_out.size() > 1)
+ {
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
+ {
+ Xml::Node& arg = **ao;
+ file << signature_to_type(arg.get("type")) << "&";
+
+ string arg_name = arg.get("name");
+ if(arg_name.length())
+ file << " " << arg_name;
+
+ if(i+1 != args_out.size())
+ file << ", ";
+ }
+ }
+ file << " ) = 0;" << endl;
+ }
+
+ file << endl
+ << "public:" << endl
+ << endl
+ << tab << "/* signal emitters for this interface" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
+ {
+ Xml::Node& signal = **si;
+ Xml::Nodes args = signal["arg"];
+
+ file << tab << "void " << signal.get("name") << "( ";
+
+ unsigned int i = 0;
+ for(Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i)
+ {
+ Xml::Node& arg = **a;
+
+ file << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
+
+ if(i+1 != args.size())
+ file << ", ";
+ }
+
+ file << " )" << endl
+ << tab << "{" << endl
+ << tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;;
+
+
+ if(args.size() > 0)
+ {
+ file << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl;
+
+ for(unsigned int i = 0; i < args.size(); ++i)
+ {
+ file << tab << tab << "wi << arg" << i+1 << ";" << endl;
+ }
+ }
+
+ file << tab << tab << "emit_signal(sig);" << endl
+ << tab << "}" << endl;
+ }
+
+ file << endl
+ << "private:" << endl
+ << endl
+ << tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl
+ << tab << " */" << endl;
+
+ for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
+ {
+ Xml::Node& method = **mi;
+ Xml::Nodes args = method["arg"];
+ Xml::Nodes args_in = args.select("direction","in");
+ Xml::Nodes args_out = args.select("direction","out");
+
+ file << tab << "::DBus::Message " << stub_name(method.get("name")) << "( const ::DBus::CallMessage& call )" << endl
+ << tab << "{" << endl
+ << tab << tab << "::DBus::MessageIter ri = call.reader();" << endl
+ << endl;
+
+ unsigned int i = 1;
+ for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
+ {
+ Xml::Node& arg = **ai;
+ file << tab << tab << signature_to_type(arg.get("type")) << " argin" << i << ";"
+ << " ri >> argin" << i << ";" << endl;
+ }
+
+ if(args_out.size() == 0)
+ {
+ file << tab << tab;
+ }
+ else if(args_out.size() == 1)
+ {
+ file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout1 = ";
+ }
+ else
+ {
+ unsigned int i = 1;
+ for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
+ {
+ Xml::Node& arg = **ao;
+ file << tab << tab << signature_to_type(arg.get("type")) << " argout" << i << ";" << endl;
+ }
+ file << tab << tab;
+ }
+
+ file << method.get("name") << "(";
+
+ for(unsigned int i = 0; i < args_in.size(); ++i)
+ {
+ file << "argin" << i+1;
+
+ if((i+1 != args_in.size() || args_out.size() > 1))
+ file << ", ";
+ }
+
+ if(args_out.size() > 1)
+ for(unsigned int i = 0; i < args_out.size(); ++i)
+ {
+ file << "argout" << i+1;
+
+ if(i+1 != args_out.size())
+ file << ", ";
+ }
+
+ file << ");" << endl;
+
+ file << tab << tab << "::DBus::ReturnMessage reply(call);" << endl;
+
+ if(args_out.size() > 0)
+ {
+ file << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl;
+
+ for(unsigned int i = 0; i < args_out.size(); ++i)
+ {
+ file << tab << tab << "wi << argout" << i+1 << ";" << endl;
+ }
+ }
+
+ file << tab << tab << "return reply;" << endl;
+
+ file << tab << "}" << endl;
+ }
+
+ file << "};" << endl
+ << endl;
+
+ for(unsigned int i = 0; i < nspaces; ++i)
+ {
+ file << "} ";
+ }
+ file << endl;
+ }
+
+ file << "#endif//" << cond_comp << endl;
+
+ file.close();
+}
+
+int main( int argc, char** argv )
+{
+ if(argc < 2)
+ {
+ usage(argv[0]);
+ }
+
+ bool proxy_mode, adaptor_mode;
+ char *proxy, *adaptor;
+
+ proxy_mode = false;
+ proxy = 0;
+
+ adaptor_mode = false;
+ adaptor = 0;
+
+ for(int a = 1; a < argc; ++a)
+ {
+ if(!strncmp(argv[a], "--proxy=", 8))
+ {
+ proxy_mode = true;
+ proxy = argv[a] +8;
+ }
+ else
+ if(!strncmp(argv[a], "--adaptor=", 10))
+ {
+ adaptor_mode = true;
+ adaptor = argv[a] +10;
+ }
+ }
+
+ if(!proxy_mode && !adaptor_mode) usage(argv[0]);
+
+ ifstream xmlfile(argv[1]);
+
+ if(xmlfile.bad())
+ {
+ cerr << "unable to open file " << argv[1] << endl;
+ return -1;
+ }
+
+ Xml::Document doc;
+
+ try
+ {
+ xmlfile >> doc;
+ //cout << doc.to_xml();
+ }
+ catch(Xml::Error& e)
+ {
+ cerr << "error parsing " << argv[1] << ": " << e.what() << endl;
+ return -1;
+ }
+
+ if(!doc.root)
+ {
+ cerr << "empty document" << endl;
+ return -1;
+ }
+
+ if(proxy_mode) generate_proxy(doc, proxy);
+ if(adaptor_mode) generate_adaptor(doc, adaptor);
+
+ return 0;
+}
Index: /tags/2.0-rc2/external/dbus/tools/introspect.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/tools/introspect.cpp (revision 562)
+++ /tags/2.0-rc2/external/dbus/tools/introspect.cpp (revision 562)
@@ -0,0 +1,78 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+#include
+#include
+#include "introspect.h"
+
+DBus::BusDispatcher dispatcher;
+static bool systembus;
+static char* path;
+static char* service;
+
+void niam( int sig )
+{
+ DBus::Connection conn = systembus ? DBus::Connection::SystemBus() : DBus::Connection::SessionBus();
+
+ IntrospectedObject io(conn, path, service);
+
+ std::cout << io.Introspect();
+
+ dispatcher.leave();
+}
+
+int main( int argc, char** argv )
+{
+ signal(SIGTERM, niam);
+ signal(SIGINT, niam);
+ signal(SIGALRM, niam);
+
+ if(argc == 1)
+ {
+ std::cerr << std::endl << "Usage: " << argv[0] << " [--system] []" << std::endl << std::endl;
+ }
+ else
+ {
+ if(strcmp(argv[1], "--system"))
+ {
+ systembus = false;
+ path = argv[1];
+ service = argc > 2 ? argv[2] : 0;
+ }
+ else
+ {
+ systembus = true;
+ path = argv[2];
+ service = argc > 3 ? argv[3] : 0;
+ }
+
+ DBus::default_dispatcher = &dispatcher;
+
+ alarm(1);
+
+ dispatcher.enter();
+ }
+
+ return 0;
+}
Index: /tags/2.0-rc2/external/dbus/tools/xml2cpp.h
===================================================================
--- /tags/2.0-rc2/external/dbus/tools/xml2cpp.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/tools/xml2cpp.h (revision 562)
@@ -0,0 +1,37 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_TOOLS_XML2CPP_H
+#define __DBUSXX_TOOLS_XML2CPP_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+
+#include "xml.h"
+
+#endif//__DBUSXX_TOOLS_XML2CPP_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/error.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/error.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/error.h (revision 562)
@@ -0,0 +1,289 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_ERROR_H
+#define __DBUSXX_ERROR_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "util.h"
+
+#include
+
+namespace DBus {
+
+class Message;
+class InternalError;
+
+class DXXAPI Error : public std::exception
+{
+public:
+
+ Error();
+
+ Error( InternalError& );
+
+ Error( const char* name, const char* message );
+
+ Error( Message& );
+
+ ~Error() throw();
+
+ const char* what() const throw();
+
+ const char* name() const;
+
+ const char* message() const;
+
+ void set( const char* name, const char* message );
+ // parameters MUST be static strings
+
+ bool is_set() const;
+
+ operator bool() const
+ {
+ return is_set();
+ }
+
+private:
+
+ RefPtrI _int;
+};
+
+struct DXXAPI ErrorFailed : public Error
+{
+ ErrorFailed( const char* message )
+ : Error("org.freedesktop.DBus.Error.Failed", message)
+ {}
+};
+
+struct DXXAPI ErrorNoMemory : public Error
+{
+ ErrorNoMemory( const char* message )
+ : Error("org.freedesktop.DBus.Error.NoMemory", message)
+ {}
+};
+
+struct DXXAPI ErrorServiceUnknown : public Error
+{
+ ErrorServiceUnknown( const char* message )
+ : Error("org.freedesktop.DBus.Error.ServiceUnknown", message)
+ {}
+};
+
+struct DXXAPI ErrorNameHasNoOwner : public Error
+{
+ ErrorNameHasNoOwner( const char* message )
+ : Error("org.freedesktop.DBus.Error.NameHasNoOwner", message)
+ {}
+};
+
+struct DXXAPI ErrorNoReply : public Error
+{
+ ErrorNoReply( const char* message )
+ : Error("org.freedesktop.DBus.Error.NoReply", message)
+ {}
+};
+
+struct DXXAPI ErrorIOError : public Error
+{
+ ErrorIOError( const char* message )
+ : Error("org.freedesktop.DBus.Error.IOError", message)
+ {}
+};
+
+struct DXXAPI ErrorBadAddress : public Error
+{
+ ErrorBadAddress( const char* message )
+ : Error("org.freedesktop.DBus.Error.BadAddress", message)
+ {}
+};
+
+struct DXXAPI ErrorNotSupported : public Error
+{
+ ErrorNotSupported( const char* message )
+ : Error("org.freedesktop.DBus.Error.NotSupported", message)
+ {}
+};
+
+struct DXXAPI ErrorLimitsExceeded : public Error
+{
+ ErrorLimitsExceeded( const char* message )
+ : Error("org.freedesktop.DBus.Error.LimitsExceeded", message)
+ {}
+};
+
+struct DXXAPI ErrorAccessDenied : public Error
+{
+ ErrorAccessDenied( const char* message )
+ : Error("org.freedesktop.DBus.Error.AccessDenied", message)
+ {}
+};
+
+struct DXXAPI ErrorAuthFailed : public Error
+{
+ ErrorAuthFailed( const char* message )
+ : Error("org.freedesktop.DBus.Error.AuthFailed", message)
+ {}
+};
+
+struct DXXAPI ErrorNoServer : public Error
+{
+ ErrorNoServer( const char* message )
+ : Error("org.freedesktop.DBus.Error.NoServer", message)
+ {}
+};
+
+struct DXXAPI ErrorTimeout : public Error
+{
+ ErrorTimeout( const char* message )
+ : Error("org.freedesktop.DBus.Error.Timeout", message)
+ {}
+};
+
+struct DXXAPI ErrorNoNetwork : public Error
+{
+ ErrorNoNetwork( const char* message )
+ : Error("org.freedesktop.DBus.Error.NoNetwork", message)
+ {}
+};
+
+struct DXXAPI ErrorAddressInUse : public Error
+{
+ ErrorAddressInUse( const char* message )
+ : Error("org.freedesktop.DBus.Error.AddressInUse", message)
+ {}
+};
+
+struct DXXAPI ErrorDisconnected : public Error
+{
+ ErrorDisconnected( const char* message )
+ : Error("org.freedesktop.DBus.Error.Disconnected", message)
+ {}
+};
+
+struct DXXAPI ErrorInvalidArgs : public Error
+{
+ ErrorInvalidArgs( const char* message )
+ : Error("org.freedesktop.DBus.Error.InvalidArgs", message)
+ {}
+};
+
+struct DXXAPI ErrorFileNotFound : public Error
+{
+ ErrorFileNotFound( const char* message )
+ : Error("org.freedesktop.DBus.Error.FileNotFound", message)
+ {}
+};
+
+struct DXXAPI ErrorUnknownMethod : public Error
+{
+ ErrorUnknownMethod( const char* message )
+ : Error("org.freedesktop.DBus.Error.UnknownMethod", message)
+ {}
+};
+
+struct DXXAPI ErrorTimedOut : public Error
+{
+ ErrorTimedOut( const char* message )
+ : Error("org.freedesktop.DBus.Error.TimedOut", message)
+ {}
+};
+
+struct DXXAPI ErrorMatchRuleNotFound : public Error
+{
+ ErrorMatchRuleNotFound( const char* message )
+ : Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message)
+ {}
+};
+
+struct DXXAPI ErrorMatchRuleInvalid : public Error
+{
+ ErrorMatchRuleInvalid( const char* message )
+ : Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message)
+ {}
+};
+
+struct DXXAPI ErrorSpawnExecFailed : public Error
+{
+ ErrorSpawnExecFailed( const char* message )
+ : Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message)
+ {}
+};
+
+struct DXXAPI ErrorSpawnForkFailed : public Error
+{
+ ErrorSpawnForkFailed( const char* message )
+ : Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message)
+ {}
+};
+
+struct DXXAPI ErrorSpawnChildExited : public Error
+{
+ ErrorSpawnChildExited( const char* message )
+ : Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message)
+ {}
+};
+
+struct DXXAPI ErrorSpawnChildSignaled : public Error
+{
+ ErrorSpawnChildSignaled( const char* message )
+ : Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message)
+ {}
+};
+
+struct DXXAPI ErrorSpawnFailed : public Error
+{
+ ErrorSpawnFailed( const char* message )
+ : Error("org.freedesktop.DBus.Error.Spawn.Failed", message)
+ {}
+};
+
+struct DXXAPI ErrorInvalidSignature : public Error
+{
+ ErrorInvalidSignature( const char* message )
+ : Error("org.freedesktop.DBus.Error.InvalidSignature", message)
+ {}
+};
+
+struct DXXAPI ErrorUnixProcessIdUnknown : public Error
+{
+ ErrorUnixProcessIdUnknown( const char* message )
+ : Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message)
+ {}
+};
+
+struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error
+{
+ ErrorSELinuxSecurityContextUnknown( const char* message )
+ : Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message)
+ {}
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_ERROR_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/dbus.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/dbus.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/dbus.h (revision 562)
@@ -0,0 +1,48 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_DBUS_H
+#define __DBUSXX_DBUS_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "types.h"
+#include "interface.h"
+#include "object.h"
+#include "property.h"
+#include "connection.h"
+#include "server.h"
+#include "error.h"
+#include "message.h"
+#include "debug.h"
+#include "pendingcall.h"
+#include "server.h"
+#include "util.h"
+#include "dispatcher.h"
+#include "eventloop.h"
+#include "introspection.h"
+
+#endif//__DBUSXX_DBUS_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/glib-integration.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/glib-integration.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/glib-integration.h (revision 562)
@@ -0,0 +1,119 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_GLIB_INTEGRATION_H
+#define __DBUSXX_GLIB_INTEGRATION_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+
+#include "api.h"
+#include "eventloop.h"
+
+namespace DBus {
+
+namespace Glib {
+
+class BusDispatcher;
+
+class DXXAPI BusTimeout : public Timeout
+{
+private:
+
+ BusTimeout( Timeout::Internal*, GMainContext* );
+
+ ~BusTimeout();
+
+ void toggle();
+
+ static gboolean timeout_handler( gpointer );
+
+ void _enable();
+
+ void _disable();
+
+private:
+
+ GSource* _source;
+ GMainContext* _ctx;
+
+friend class BusDispatcher;
+};
+
+class DXXAPI BusWatch : public Watch
+{
+private:
+
+ BusWatch( Watch::Internal*, GMainContext* );
+
+ ~BusWatch();
+
+ void toggle();
+
+ static gboolean watch_handler( gpointer );
+
+ void _enable();
+
+ void _disable();
+
+private:
+
+ GSource* _source;
+ GMainContext* _ctx;
+
+friend class BusDispatcher;
+};
+
+class DXXAPI BusDispatcher : public Dispatcher
+{
+public:
+ BusDispatcher() : _ctx(NULL) {}
+
+ void attach( GMainContext* );
+
+ void enter() {}
+
+ void leave() {}
+
+ Timeout* add_timeout( Timeout::Internal* );
+
+ void rem_timeout( Timeout* );
+
+ Watch* add_watch( Watch::Internal* );
+
+ void rem_watch( Watch* );
+
+private:
+
+ GMainContext* _ctx;
+};
+
+} /* namespace Glib */
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_GLIB_INTEGRATION_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/connection.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/connection.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/connection.h (revision 562)
@@ -0,0 +1,126 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_CONNECTION_H
+#define __DBUSXX_CONNECTION_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+
+#include "api.h"
+#include "types.h"
+#include "util.h"
+#include "message.h"
+#include "pendingcall.h"
+
+namespace DBus {
+
+class Connection;
+
+typedef Slot MessageSlot;
+
+typedef std::list ConnectionList;
+
+class ObjectAdaptor;
+class Dispatcher;
+
+class DXXAPI Connection
+{
+public:
+
+ static Connection SystemBus();
+
+ static Connection SessionBus();
+
+ static Connection ActivationBus();
+
+ struct Private;
+
+ typedef std::list PrivatePList;
+
+ Connection( Private* );
+
+ Connection( const char* address, bool priv = true );
+
+ Connection( const Connection& c );
+
+ virtual ~Connection();
+
+ Dispatcher* setup( Dispatcher* );
+
+ bool operator == ( const Connection& ) const;
+
+ void add_match( const char* rule );
+
+ void remove_match( const char* rule );
+
+ bool add_filter( MessageSlot& );
+
+ void remove_filter( MessageSlot& );
+
+ bool unique_name( const char* n );
+
+ const char* unique_name() const;
+
+ bool register_bus();
+
+ bool connected() const;
+
+ void disconnect();
+
+ void exit_on_disconnect( bool exit );
+
+ void flush();
+
+ bool send( const Message&, unsigned int* serial = NULL );
+
+ Message send_blocking( Message& msg, int timeout );
+
+ PendingCall send_async( Message& msg, int timeout );
+
+ void request_name( const char* name, int flags = 0 );
+
+ bool has_name( const char* name );
+
+ bool start_service( const char* name, unsigned long flags );
+
+ const std::vector& names();
+
+private:
+
+ DXXAPILOCAL void init();
+
+private:
+
+ RefPtrI _pvt;
+
+friend class ObjectAdaptor; // needed in order to register object paths for a connection
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_CONNECTION_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/introspection.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/introspection.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/introspection.h (revision 562)
@@ -0,0 +1,90 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_INTROSPECTION_H
+#define __DBUSXX_INTROSPECTION_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "interface.h"
+
+namespace DBus {
+
+struct DXXAPI IntrospectedArgument
+{
+ const char* name;
+ const char* type;
+ const bool in;
+};
+
+struct DXXAPI IntrospectedMethod
+{
+ const char* name;
+ const IntrospectedArgument* args;
+};
+
+struct DXXAPI IntrospectedProperty
+{
+ const char* name;
+ const char* type;
+ const bool read;
+ const bool write;
+};
+
+struct DXXAPI IntrospectedInterface
+{
+ const char* name;
+ const IntrospectedMethod* methods;
+ const IntrospectedMethod* signals;
+ const IntrospectedProperty* properties;
+};
+
+class DXXAPI IntrospectableAdaptor : public InterfaceAdaptor
+{
+public:
+
+ IntrospectableAdaptor();
+
+ Message Introspect( const CallMessage& );
+
+protected:
+
+ IntrospectedInterface* const introspect() const;
+};
+
+class DXXAPI IntrospectableProxy : public InterfaceProxy
+{
+public:
+
+ IntrospectableProxy();
+
+ std::string Introspect();
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_INTROSPECTION_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/interface.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/interface.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/interface.h (revision 562)
@@ -0,0 +1,195 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_INTERFACE_H
+#define __DBUSXX_INTERFACE_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+#include "api.h"
+#include "util.h"
+#include "types.h"
+
+#include "message.h"
+
+namespace DBus {
+
+//todo: this should belong to to properties.h
+struct DXXAPI PropertyData
+{
+ bool read;
+ bool write;
+ std::string sig;
+ Variant value;
+};
+
+typedef std::map PropertyTable;
+
+class IntrospectedInterface;
+
+class ObjectAdaptor;
+class InterfaceAdaptor;
+class SignalMessage;
+
+typedef std::map InterfaceAdaptorTable;
+
+class DXXAPI AdaptorBase
+{
+public:
+
+ virtual const ObjectAdaptor* object() const = 0 ;
+
+protected:
+
+ InterfaceAdaptor* find_interface( const std::string& name );
+
+ virtual ~AdaptorBase()
+ {}
+
+ virtual void _emit_signal( SignalMessage& ) = 0;
+
+ InterfaceAdaptorTable _interfaces;
+};
+
+/*
+*/
+
+class ObjectProxy;
+class InterfaceProxy;
+class CallMessage;
+
+typedef std::map InterfaceProxyTable;
+
+class DXXAPI ProxyBase
+{
+public:
+
+ virtual const ObjectProxy* object() const = 0 ;
+
+protected:
+
+ InterfaceProxy* find_interface( const std::string& name );
+
+ virtual ~ProxyBase()
+ {}
+
+ virtual Message _invoke_method( CallMessage& ) = 0;
+
+ InterfaceProxyTable _interfaces;
+};
+
+class DXXAPI Interface
+{
+public:
+
+ Interface( const std::string& name );
+
+ virtual ~Interface();
+
+ inline const std::string& name() const;
+
+private:
+
+ std::string _name;
+};
+
+/*
+*/
+
+const std::string& Interface::name() const
+{
+ return _name;
+}
+
+/*
+*/
+
+typedef std::map< std::string, Slot > MethodTable;
+
+class DXXAPI InterfaceAdaptor : public Interface, public virtual AdaptorBase
+{
+public:
+
+ InterfaceAdaptor( const std::string& name );
+
+ Message dispatch_method( const CallMessage& );
+
+ void emit_signal( const SignalMessage& );
+
+ Variant* get_property( const std::string& name );
+
+ void set_property( const std::string& name, Variant& value );
+
+ virtual IntrospectedInterface* const introspect() const
+ {
+ return NULL;
+ }
+
+protected:
+
+ MethodTable _methods;
+ PropertyTable _properties;
+};
+
+/*
+*/
+
+typedef std::map< std::string, Slot > SignalTable;
+
+class DXXAPI InterfaceProxy : public Interface, public virtual ProxyBase
+{
+public:
+
+ InterfaceProxy( const std::string& name );
+
+ Message invoke_method( const CallMessage& );
+
+ bool dispatch_signal( const SignalMessage& );
+
+protected:
+
+ SignalTable _signals;
+};
+
+# define register_method(interface, method, callback) \
+ InterfaceAdaptor::_methods[ #method ] = \
+ new ::DBus::Callback< interface, ::DBus::Message, const ::DBus::CallMessage& >(this, & interface :: callback );
+
+# define bind_property(variable, type, can_read, can_write) \
+ InterfaceAdaptor::_properties[ #variable ].read = can_read; \
+ InterfaceAdaptor::_properties[ #variable ].write = can_write; \
+ InterfaceAdaptor::_properties[ #variable ].sig = type; \
+ variable.bind( InterfaceAdaptor::_properties[ #variable ] );
+
+# define connect_signal(interface, signal, callback) \
+ InterfaceProxy::_signals[ #signal ] = \
+ new ::DBus::Callback< interface, void, const ::DBus::SignalMessage& >(this, & interface :: callback );
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_INTERFACE_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/types.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/types.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/types.h (revision 562)
@@ -0,0 +1,514 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_TYPES_H
+#define __DBUSXX_TYPES_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+#include
+
+#include "api.h"
+#include "util.h"
+#include "message.h"
+#include "error.h"
+
+namespace DBus {
+
+typedef unsigned char Byte;
+typedef bool Bool;
+typedef signed short Int16;
+typedef unsigned short UInt16;
+typedef signed int Int32;
+typedef unsigned int UInt32;
+typedef signed long long Int64;
+typedef unsigned long long UInt64;
+typedef double Double;
+typedef std::string String;
+
+struct DXXAPI Path : public std::string
+{
+ Path() {}
+ Path( const std::string& s ) : std::string(s) {}
+ Path( const char* c ) : std::string(c) {}
+ Path& operator = ( std::string& s )
+ {
+ std::string::operator = (s);
+ return *this;
+ }
+};
+
+struct DXXAPI Signature : public std::string
+{
+ Signature() {}
+ Signature( const std::string& s ) : std::string(s) {}
+ Signature( const char* c ) : std::string(c) {}
+ Signature& operator = ( std::string& s )
+ {
+ std::string::operator = (s);
+ return *this;
+ }
+};
+
+struct DXXAPI Invalid {};
+
+class DXXAPI Variant
+{
+public:
+
+ Variant();
+
+ Variant( MessageIter& it );
+
+ Variant& operator = ( const Variant& v );
+
+ const Signature signature() const;
+
+ void clear();
+
+ MessageIter reader() const
+ {
+ return _msg.reader();
+ }
+
+ MessageIter writer()
+ {
+ return _msg.writer();
+ }
+
+ template
+ operator T() const
+ {
+ T cast;
+ MessageIter ri = _msg.reader();
+ ri >> cast;
+ return cast;
+ }
+
+private:
+
+ Message _msg;
+};
+
+template <
+ typename T1,
+ typename T2 = Invalid,
+ typename T3 = Invalid,
+ typename T4 = Invalid,
+ typename T5 = Invalid,
+ typename T6 = Invalid,
+ typename T7 = Invalid,
+ typename T8 = Invalid // who needs more than eight?
+>
+struct Struct
+{
+ T1 _1; T2 _2; T3 _3; T4 _4; T5 _5; T6 _6; T7 _7; T8 _8;
+};
+
+template
+inline bool dict_has_key( const std::map& map, const K& key )
+{
+ return map.find(key) != map.end();
+}
+
+template
+struct type
+{
+ static std::string sig()
+ {
+ throw ErrorInvalidArgs("unknown type");
+ return "";
+ }
+};
+
+template <> struct type { static std::string sig(){ return "v"; } };
+template <> struct type { static std::string sig(){ return "y"; } };
+template <> struct type { static std::string sig(){ return "b"; } };
+template <> struct type { static std::string sig(){ return "n"; } };
+template <> struct type { static std::string sig(){ return "q"; } };
+template <> struct type { static std::string sig(){ return "i"; } };
+template <> struct type { static std::string sig(){ return "u"; } };
+template <> struct type { static std::string sig(){ return "x"; } };
+template <> struct type { static std::string sig(){ return "t"; } };
+template <> struct type { static std::string sig(){ return "d"; } };
+template <> struct type { static std::string sig(){ return "s"; } };
+template <> struct type { static std::string sig(){ return "o"; } };
+template <> struct type { static std::string sig(){ return "g"; } };
+template <> struct type { static std::string sig(){ return ""; } };
+
+template
+struct type< std::vector >
+{ static std::string sig(){ return "a" + type::sig(); } };
+
+template
+struct type< std::map >
+{ static std::string sig(){ return "a{" + type::sig() + type::sig() + "}"; } };
+
+template <
+ typename T1,
+ typename T2,
+ typename T3,
+ typename T4,
+ typename T5,
+ typename T6,
+ typename T7,
+ typename T8 // who needs more than eight?
+>
+struct type< Struct >
+{
+ static std::string sig()
+ {
+ return "("
+ + type::sig()
+ + type::sig()
+ + type::sig()
+ + type::sig()
+ + type::sig()
+ + type::sig()
+ + type::sig()
+ + type::sig()
+ + ")";
+ }
+};
+
+} /* namespace DBus */
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Invalid& )
+{
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Byte& val )
+{
+ iter.append_byte(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Bool& val )
+{
+ iter.append_bool(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int16& val )
+{
+ iter.append_int16(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt16& val )
+{
+ iter.append_uint16(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int32& val )
+{
+ iter.append_int32(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt32& val )
+{
+ iter.append_uint32(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int64& val )
+{
+ iter.append_int64(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt64& val )
+{
+ iter.append_uint64(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Double& val )
+{
+ iter.append_double(val);
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::String& val )
+{
+ iter.append_string(val.c_str());
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Path& val )
+{
+ iter.append_path(val.c_str());
+ return iter;
+}
+
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Signature& val )
+{
+ iter.append_signature(val.c_str());
+ return iter;
+}
+
+template
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector& val )
+{
+ const std::string sig = DBus::type::sig();
+ DBus::MessageIter ait = iter.new_array(sig.c_str());
+
+ typename std::vector::const_iterator vit;
+ for(vit = val.begin(); vit != val.end(); ++vit)
+ {
+ ait << *vit;
+ }
+
+ iter.close_container(ait);
+ return iter;
+}
+
+template<>
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector& val )
+{
+ DBus::MessageIter ait = iter.new_array("y");
+ ait.append_array('y', &val.front(), val.size());
+ iter.close_container(ait);
+ return iter;
+}
+
+template
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::map& val )
+{
+ const std::string sig = "{" + DBus::type::sig() + DBus::type::sig() + "}";
+ DBus::MessageIter ait = iter.new_array(sig.c_str());
+
+ typename std::map::const_iterator mit;
+ for(mit = val.begin(); mit != val.end(); ++mit)
+ {
+ DBus::MessageIter eit = ait.new_dict_entry();
+
+ eit << mit->first << mit->second;
+
+ ait.close_container(eit);
+ }
+
+ iter.close_container(ait);
+ return iter;
+}
+
+template <
+ typename T1,
+ typename T2,
+ typename T3,
+ typename T4,
+ typename T5,
+ typename T6,
+ typename T7,
+ typename T8
+>
+inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Struct& val )
+{
+/* const std::string sig =
+ DBus::type::sig() + DBus::type::sig() + DBus::type::sig() + DBus::type::sig() +
+ DBus::type::sig() + DBus::type::sig() + DBus::type::sig() + DBus::type::sig();
+*/
+ DBus::MessageIter sit = iter.new_struct(/*sig.c_str()*/);
+
+ sit << val._1 << val._2 << val._3 << val._4 << val._5 << val._6 << val._7 << val._8;
+
+ iter.close_container(sit);
+
+ return iter;
+}
+
+extern DXXAPI DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Variant& val );
+
+/*
+ */
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Invalid& )
+{
+ return iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Byte& val )
+{
+ val = iter.get_byte();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Bool& val )
+{
+ val = iter.get_bool();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int16& val )
+{
+ val = iter.get_int16();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt16& val )
+{
+ val = iter.get_uint16();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int32& val )
+{
+ val = iter.get_int32();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt32& val )
+{
+ val = iter.get_uint32();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int64& val )
+{
+ val = iter.get_int64();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt64& val )
+{
+ val = iter.get_uint64();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Double& val )
+{
+ val = iter.get_double();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::String& val )
+{
+ val = iter.get_string();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Path& val )
+{
+ val = iter.get_path();
+ return ++iter;
+}
+
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Signature& val )
+{
+ val = iter.get_signature();
+ return ++iter;
+}
+
+template
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector& val )
+{
+ if(!iter.is_array())
+ throw DBus::ErrorInvalidArgs("array expected");
+
+ DBus::MessageIter ait = iter.recurse();
+
+ while(!ait.at_end())
+ {
+ E elem;
+
+ ait >> elem;
+
+ val.push_back(elem);
+ }
+ return ++iter;
+}
+
+template<>
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector& val )
+{
+ if(!iter.is_array())
+ throw DBus::ErrorInvalidArgs("array expected");
+
+ if(iter.array_type() != 'y')
+ throw DBus::ErrorInvalidArgs("byte-array expected");
+
+ DBus::MessageIter ait = iter.recurse();
+
+ DBus::Byte* array;
+ size_t length = ait.get_array(&array);
+
+ val.insert(val.end(), array, array+length);
+
+ return ++iter;
+}
+
+template
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::map& val )
+{
+ if(!iter.is_dict())
+ throw DBus::ErrorInvalidArgs("dictionary value expected");
+
+ DBus::MessageIter mit = iter.recurse();
+
+ while(!mit.at_end())
+ {
+ K key; V value;
+
+ DBus::MessageIter eit = mit.recurse();
+
+ eit >> key >> value;
+
+ val[key] = value;
+
+ ++mit;
+ }
+
+ return ++iter;
+}
+
+template <
+ typename T1,
+ typename T2,
+ typename T3,
+ typename T4,
+ typename T5,
+ typename T6,
+ typename T7,
+ typename T8
+>
+inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Struct& val)
+{
+ DBus::MessageIter sit = iter.recurse();
+
+ sit >> val._1 >> val._2 >> val._3 >> val._4 >> val._5 >> val._6 >> val._7 >> val._8;
+
+ return ++iter;
+}
+
+extern DXXAPI DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Variant& val );
+
+#endif//__DBUSXX_TYPES_H
+
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/config.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/config.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/config.h (revision 562)
@@ -0,0 +1,74 @@
+/* include/dbus-c++/config.h. Generated from config.h.in by configure. */
+/* include/dbus-c++/config.h.in. Generated from configure.ac by autoheader. */
+
+/* unstable DBus */
+/* #undef DBUS_API_SUBJECT_TO_CHANGE */
+
+/* DBus supports recursive mutexes (needs DBus >= 0.95) */
+#define DBUS_HAS_RECURSIVE_MUTEX
+
+/* dbus_threads_init_default (needs DBus >= 0.93) */
+#define DBUS_HAS_THREADS_INIT_DEFAULT
+
+/* to enable hidden symbols */
+#define GCC_HASCLASSVISIBILITY 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_EXPAT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_PTHREAD_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the header file. */
+#define HAVE_UNISTD_H 1
+
+/* Name of package */
+#define PACKAGE "libdbus-c++"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "shackan@gmail.com"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libdbus-c++"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libdbus-c++ 0.5.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libdbus-c--"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.5.0"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "0.5.0"
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/object.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/object.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/object.h (revision 562)
@@ -0,0 +1,223 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_OBJECT_H
+#define __DBUSXX_OBJECT_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+
+#include "api.h"
+#include "interface.h"
+#include "connection.h"
+#include "message.h"
+#include "types.h"
+
+namespace DBus {
+
+class DXXAPI Object
+{
+protected:
+
+ Object( Connection& conn, const Path& path, const char* service );
+
+public:
+
+ virtual ~Object();
+
+ inline const DBus::Path& path() const;
+
+ inline const std::string& service() const;
+
+ inline Connection& conn();
+
+private:
+
+ DXXAPILOCAL virtual bool handle_message( const Message& ) = 0;
+ DXXAPILOCAL virtual void register_obj() = 0;
+ DXXAPILOCAL virtual void unregister_obj() = 0;
+
+private:
+
+ Connection _conn;
+ DBus::Path _path;
+ std::string _service;
+};
+
+/*
+*/
+
+Connection& Object::conn()
+{
+ return _conn;
+}
+
+const DBus::Path& Object::path() const
+{
+ return _path;
+}
+
+const std::string& Object::service() const
+{
+ return _service;
+}
+
+/*
+*/
+
+class DXXAPI Tag
+{
+public:
+
+ virtual ~Tag()
+ {}
+};
+
+/*
+*/
+
+class ObjectAdaptor;
+
+typedef std::list ObjectAdaptorPList;
+
+class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase
+{
+public:
+
+ static ObjectAdaptor* from_path( const Path& path );
+
+ static ObjectAdaptorPList from_path_prefix( const std::string& prefix );
+
+ struct Private;
+
+ ObjectAdaptor( Connection& conn, const Path& path );
+
+ ~ObjectAdaptor();
+
+ inline const ObjectAdaptor* object() const;
+
+protected:
+
+ class DXXAPI Continuation
+ {
+ public:
+
+ inline MessageIter& writer();
+
+ inline Tag* tag();
+
+ private:
+
+ Continuation( Connection& conn, const CallMessage& call, const Tag* tag );
+
+ Connection _conn;
+ CallMessage _call;
+ MessageIter _writer;
+ ReturnMessage _return;
+ const Tag* _tag;
+
+ friend class ObjectAdaptor;
+ };
+
+ void return_later( const Tag* tag );
+
+ void return_now( Continuation* ret );
+
+ void return_error( Continuation* ret, const Error error );
+
+ Continuation* find_continuation( const Tag* tag );
+
+private:
+
+ void _emit_signal( SignalMessage& );
+
+ bool handle_message( const Message& );
+
+ void register_obj();
+ void unregister_obj();
+
+ typedef std::map ContinuationMap;
+ ContinuationMap _continuations;
+
+friend struct Private;
+};
+
+const ObjectAdaptor* ObjectAdaptor::object() const
+{
+ return this;
+}
+
+Tag* ObjectAdaptor::Continuation::tag()
+{
+ return const_cast(_tag);
+}
+
+MessageIter& ObjectAdaptor::Continuation::writer()
+{
+ return _writer;
+}
+
+/*
+*/
+
+class ObjectProxy;
+
+typedef std::list ObjectProxyPList;
+
+class DXXAPI ObjectProxy : public Object, public virtual ProxyBase
+{
+public:
+
+ ObjectProxy( Connection& conn, const Path& path, const char* service = "" );
+
+ ~ObjectProxy();
+
+ inline const ObjectProxy* object() const;
+
+private:
+
+ Message _invoke_method( CallMessage& );
+
+ bool handle_message( const Message& );
+
+ void register_obj();
+ void unregister_obj();
+
+private:
+
+ MessageSlot _filtered;
+};
+
+const ObjectProxy* ObjectProxy::object() const
+{
+ return this;
+}
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_OBJECT_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/server.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/server.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/server.h (revision 562)
@@ -0,0 +1,78 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_SERVER_H
+#define __DBUSXX_SERVER_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+
+#include "api.h"
+#include "error.h"
+#include "connection.h"
+#include "util.h"
+#include "dispatcher.h"
+
+namespace DBus {
+
+class Server;
+
+typedef std::list ServerList;
+
+class DXXAPI Server
+{
+public:
+
+ Server( const char* address );
+
+ Dispatcher* setup( Dispatcher* );
+
+ virtual ~Server();
+
+ bool listening() const;
+
+ bool operator == ( const Server& ) const;
+
+ void disconnect();
+
+ struct Private;
+
+protected:
+
+ Server( const Server& s )
+ {}
+
+ virtual void on_new_connection( Connection& c ) = 0;
+
+private:
+
+ RefPtrI _pvt;
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_SERVER_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/api.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/api.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/api.h (revision 562)
@@ -0,0 +1,42 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_API_H
+#define __DBUSXX_API_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef GCC_HASCLASSVISIBILITY
+# define DXXAPILOCAL __attribute__ ((visibility("hidden")))
+# define DXXAPIPUBLIC __attribute__ ((visibility("default")))
+#else
+# define DXXAPILOCAL
+# define DXXAPIPUBLIC
+#endif
+
+#define DXXAPI DXXAPIPUBLIC
+
+#endif//__DBUSXX_API_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/eventloop.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/eventloop.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/eventloop.h (revision 562)
@@ -0,0 +1,202 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_EVENTLOOP_H
+#define __DBUSXX_EVENTLOOP_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+
+#include "api.h"
+#include "dispatcher.h"
+#include "util.h"
+
+namespace DBus {
+
+class EepleMainLoop;
+
+class DXXAPI EepleTimeout
+{
+public:
+
+ EepleTimeout( int interval, bool repeat, EepleMainLoop* );
+
+ virtual ~EepleTimeout();
+
+ bool enabled(){ return _enabled; }
+ void enabled(bool e){ _enabled = e; }
+
+ int interval(){ return _interval; }
+ void interval(int i){ _interval = i; }
+
+ bool repeat(){ return _repeat; }
+ void repeat(bool r){ _repeat = r; }
+
+ void* data(){ return _data; }
+ void data(void* d){ _data = d; }
+
+ Slot expired;
+
+private:
+
+ bool _enabled;
+
+ int _interval;
+ bool _repeat;
+
+ double _expiration;
+
+ void* _data;
+
+ EepleMainLoop* _disp;
+
+friend class EepleMainLoop;
+};
+
+typedef std::list< EepleTimeout* > Timeouts;
+
+class DXXAPI EepleWatch
+{
+public:
+
+ EepleWatch( int fd, int flags, EepleMainLoop* );
+
+ virtual ~EepleWatch();
+
+ bool enabled(){ return _enabled; }
+ void enabled(bool e){ _enabled = e; }
+
+ int descriptor(){ return _fd; }
+
+ int flags(){ return _flags; }
+ void flags( int f ){ _flags = f; }
+
+ int state(){ return _state; }
+
+ void* data(){ return _data; }
+ void data(void* d){ _data = d; }
+
+ Slot ready;
+
+private:
+
+ bool _enabled;
+
+ int _fd;
+ int _flags;
+ int _state;
+
+ void* _data;
+
+ EepleMainLoop* _disp;
+
+friend class EepleMainLoop;
+};
+
+typedef std::list< EepleWatch* > Watches;
+
+class DXXAPI EepleMainLoop
+{
+public:
+
+ EepleMainLoop();
+
+ virtual ~EepleMainLoop();
+
+ virtual void dispatch();
+
+private:
+
+ Timeouts _timeouts;
+ Watches _watches;
+
+friend class EepleTimeout;
+friend class EepleWatch;
+};
+
+/* the classes below are those you are going to implement if you
+ * want to use another event loop (Qt, Glib, boost, whatever).
+ *
+ * Don't forget to set 'default_dispatcher' accordingly!
+ */
+
+class BusDispatcher;
+
+class DXXAPI BusTimeout : public Timeout, public EepleTimeout
+{
+ BusTimeout( Timeout::Internal*, BusDispatcher* );
+
+ void toggle();
+
+friend class BusDispatcher;
+};
+
+class DXXAPI BusWatch : public Watch, public EepleWatch
+{
+ BusWatch( Watch::Internal*, BusDispatcher* );
+
+ void toggle();
+
+friend class BusDispatcher;
+};
+
+class DXXAPI BusDispatcher : public Dispatcher, public EepleMainLoop
+{
+public:
+
+ BusDispatcher() : _running(false)
+ {}
+
+ ~BusDispatcher()
+ {}
+
+ virtual void enter();
+
+ virtual void leave();
+
+ virtual void do_iteration();
+
+ virtual Timeout* add_timeout( Timeout::Internal* );
+
+ virtual void rem_timeout( Timeout* );
+
+ virtual Watch* add_watch( Watch::Internal* );
+
+ virtual void rem_watch( Watch* );
+
+ void watch_ready( EepleWatch& );
+
+ void timeout_expired( EepleTimeout& );
+
+private:
+
+ bool _running;
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_EVENTLOOP_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/util.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/util.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/util.h (revision 562)
@@ -0,0 +1,277 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_UTIL_H
+#define __DBUSXX_UTIL_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "debug.h"
+
+namespace DBus {
+
+/*
+ * Very simple reference counting
+ */
+
+class DXXAPI RefCnt
+{
+public:
+
+ RefCnt()
+ {
+ __ref = new int;
+ (*__ref) = 1;
+ }
+
+ RefCnt( const RefCnt& rc )
+ {
+ __ref = rc.__ref;
+ ref();
+ }
+
+ virtual ~RefCnt()
+ {
+ unref();
+ }
+
+ RefCnt& operator = ( const RefCnt& ref )
+ {
+ ref.ref();
+ unref();
+ __ref = ref.__ref;
+ return *this;
+ }
+
+ bool noref() const
+ {
+ return (*__ref) == 0;
+ }
+
+ bool one() const
+ {
+ return (*__ref) == 1;
+ }
+
+private:
+
+ DXXAPILOCAL void ref() const
+ {
+ ++ (*__ref);
+ }
+ DXXAPILOCAL void unref() const
+ {
+ -- (*__ref);
+
+ if( (*__ref) < 0 )
+ {
+ debug_log("%p: refcount dropped below zero!", __ref);
+ }
+
+ if( noref() )
+ {
+ delete __ref;
+ }
+ }
+
+private:
+
+ int *__ref;
+};
+
+/*
+ * Reference counting pointers (emulate boost::shared_ptr)
+ */
+
+template
+class RefPtrI // RefPtr to incomplete type
+{
+public:
+
+ RefPtrI( T* ptr = 0 );
+
+ ~RefPtrI();
+
+ RefPtrI& operator = ( const RefPtrI& ref )
+ {
+ if( this != &ref )
+ {
+ if(__cnt.one()) delete __ptr;
+
+ __ptr = ref.__ptr;
+ __cnt = ref.__cnt;
+ }
+ return *this;
+ }
+
+ T& operator *() const
+ {
+ return *__ptr;
+ }
+
+ T* operator ->() const
+ {
+ if(__cnt.noref()) return 0;
+
+ return __ptr;
+ }
+
+ T* get() const
+ {
+ if(__cnt.noref()) return 0;
+
+ return __ptr;
+ }
+
+private:
+
+ T* __ptr;
+ RefCnt __cnt;
+};
+
+template
+class RefPtr
+{
+public:
+
+ RefPtr( T* ptr = 0)
+ : __ptr(ptr)
+ {}
+
+ ~RefPtr()
+ {
+ if(__cnt.one()) delete __ptr;
+ }
+
+ RefPtr& operator = ( const RefPtr& ref )
+ {
+ if( this != &ref )
+ {
+ if(__cnt.one()) delete __ptr;
+
+ __ptr = ref.__ptr;
+ __cnt = ref.__cnt;
+ }
+ return *this;
+ }
+
+ T& operator *() const
+ {
+ return *__ptr;
+ }
+
+ T* operator ->() const
+ {
+ if(__cnt.noref()) return 0;
+
+ return __ptr;
+ }
+
+ T* get() const
+ {
+ if(__cnt.noref()) return 0;
+
+ return __ptr;
+ }
+
+private:
+
+ T* __ptr;
+ RefCnt __cnt;
+};
+
+/*
+ * Typed callback template
+ */
+
+template
+class Callback_Base
+{
+public:
+
+ virtual R call( P param ) const = 0;
+
+ virtual ~Callback_Base()
+ {}
+};
+
+template
+class Slot
+{
+public:
+
+ Slot& operator = ( Callback_Base* s )
+ {
+ _cb = s;
+
+ return *this;
+ }
+
+ R operator()( P param ) const
+ {
+ /*if(_cb.get())*/ return _cb->call(param);
+ }
+
+ R call( P param ) const
+ {
+ /*if(_cb.get())*/ return _cb->call(param);
+ }
+
+ bool empty()
+ {
+ return _cb.get() == 0;
+ }
+
+private:
+
+ RefPtr< Callback_Base > _cb;
+};
+
+template
+class Callback : public Callback_Base
+{
+public:
+
+ typedef R (C::*M)(P);
+
+ Callback( C* c, M m )
+ : _c(c), _m(m)
+ {}
+
+ R call( P param ) const
+ {
+ /*if(_c)*/ return (_c->*_m)(param);
+ }
+
+private:
+
+ C* _c; M _m;
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_UTIL_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/pendingcall.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/pendingcall.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/pendingcall.h (revision 562)
@@ -0,0 +1,75 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_PENDING_CALL_H
+#define __DBUSXX_PENDING_CALL_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "util.h"
+
+namespace DBus {
+
+class Connection;
+
+class DXXAPI PendingCall
+{
+public:
+
+ struct Private;
+
+ PendingCall( Private* );
+
+ virtual ~PendingCall();
+
+ bool completed();
+
+ void cancel();
+
+ void block();
+
+ void data( void* );
+
+ void* data();
+
+ Slot slot;
+
+private:
+
+ DXXAPILOCAL PendingCall( const PendingCall& );
+
+private:
+
+ RefPtrI _pvt;
+
+friend struct Private;
+friend class Connection;
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_PENDING_CALL_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/refptr_impl.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/refptr_impl.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/refptr_impl.h (revision 562)
@@ -0,0 +1,50 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_REFPTR_IMPL_H
+#define __DBUSXX_REFPTR_IMPL_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "util.h"
+
+namespace DBus {
+
+template
+RefPtrI::RefPtrI( T* ptr )
+: __ptr(ptr)
+{}
+
+template
+RefPtrI::~RefPtrI()
+{
+ if(__cnt.one()) delete __ptr;
+}
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_REFPTR_IMPL_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/property.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/property.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/property.h (revision 562)
@@ -0,0 +1,106 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_PROPERTY_H
+#define __DBUSXX_PROPERTY_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "types.h"
+#include "interface.h"
+
+namespace DBus {
+
+template
+class PropertyAdaptor
+{
+public:
+
+ PropertyAdaptor() : _data(0)
+ {}
+
+ void bind( PropertyData& data )
+ {
+ _data = &data;
+ }
+
+ T operator() (void) const
+ {
+ return (T)_data->value;
+ }
+
+ PropertyAdaptor& operator = ( const T& t )
+ {
+ _data->value.clear();
+ MessageIter wi = _data->value.writer();
+ wi << t;
+ return *this;
+ }
+
+private:
+
+ PropertyData* _data;
+};
+
+struct IntrospectedInterface;
+
+class DXXAPI PropertiesAdaptor : public InterfaceAdaptor
+{
+public:
+
+ PropertiesAdaptor();
+
+ Message Get( const CallMessage& );
+
+ Message Set( const CallMessage& );
+
+protected:
+
+ virtual void on_get_property( InterfaceAdaptor& interface, const String& property, Variant& value )
+ {}
+
+ virtual void on_set_property( InterfaceAdaptor& interface, const String& property, const Variant& value )
+ {}
+
+ IntrospectedInterface* const introspect() const;
+};
+
+class DXXAPI PropertiesProxy : public InterfaceProxy
+{
+public:
+
+ PropertiesProxy();
+
+ Variant Get( const String& interface, const String& property );
+
+ void Set( const String& interface, const String& property, const Variant& value );
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_PROPERTY_H
+
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/message.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/message.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/message.h (revision 562)
@@ -0,0 +1,312 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_MESSAGE_H
+#define __DBUSXX_MESSAGE_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+
+#include "api.h"
+#include "util.h"
+
+namespace DBus {
+
+class Message;
+class ErrorMessage;
+class SignalMessage;
+class ReturnMessage;
+class Error;
+class Connection;
+
+class DXXAPI MessageIter
+{
+public:
+
+ MessageIter() {}
+
+ int type();
+
+ bool at_end();
+
+ bool has_next();
+
+ MessageIter& operator ++();
+
+ MessageIter operator ++(int);
+
+ bool append_byte( unsigned char byte );
+
+ unsigned char get_byte();
+
+ bool append_bool( bool b );
+
+ bool get_bool();
+
+ bool append_int16( signed short i );
+
+ signed short get_int16();
+
+ bool append_uint16( unsigned short u );
+
+ unsigned short get_uint16();
+
+ bool append_int32( signed int i );
+
+ signed int get_int32();
+
+ bool append_uint32( unsigned int u );
+
+ unsigned int get_uint32();
+
+ bool append_int64( signed long long i );
+
+ signed long long get_int64();
+
+ bool append_uint64( unsigned long long i );
+
+ unsigned long long get_uint64();
+
+ bool append_double( double d );
+
+ double get_double();
+
+ bool append_string( const char* chars );
+
+ const char* get_string();
+
+ bool append_path( const char* chars );
+
+ const char* get_path();
+
+ bool append_signature( const char* chars );
+
+ const char* get_signature();
+
+ char* signature() const; //returned string must be manually free()'d
+
+ MessageIter recurse();
+
+ bool append_array( char type, const void* ptr, size_t length );
+
+ int array_type();
+
+ int get_array( void* ptr );
+
+ bool is_array();
+
+ bool is_dict();
+
+ MessageIter new_array( const char* sig );
+
+ MessageIter new_variant( const char* sig );
+
+ MessageIter new_struct();
+
+ MessageIter new_dict_entry();
+
+ void close_container( MessageIter& container );
+
+ void copy_data( MessageIter& to );
+
+ Message& msg() const
+ {
+ return *_msg;
+ }
+
+private:
+
+ DXXAPILOCAL MessageIter(Message& msg) : _msg(&msg) {}
+
+ DXXAPILOCAL bool append_basic( int type_id, void* value );
+
+ DXXAPILOCAL void get_basic( int type_id, void* ptr );
+
+private:
+
+ /* I'm sorry, but don't want to include dbus.h in the public api
+ */
+ unsigned char _iter[sizeof(void*)*3+sizeof(int)*11];
+
+ Message* _msg;
+
+friend class Message;
+};
+
+class DXXAPI Message
+{
+public:
+
+ struct Private;
+
+ Message( Private*, bool incref = true );
+
+ Message( const Message& m );
+
+ ~Message();
+
+ Message& operator = ( const Message& m );
+
+ Message copy();
+
+ int type() const;
+
+ int serial() const;
+
+ int reply_serial() const;
+
+ bool reply_serial( int );
+
+ const char* sender() const;
+
+ bool sender( const char* s );
+
+ const char* destination() const;
+
+ bool destination( const char* s );
+
+ bool is_error() const;
+
+ bool is_signal( const char* interface, const char* member ) const;
+
+ MessageIter reader() const;
+
+ MessageIter writer();
+
+ bool append( int first_type, ... );
+
+ void terminate();
+
+protected:
+
+ Message();
+
+protected:
+
+ RefPtrI _pvt;
+
+/* classes who need to read `_pvt` directly
+*/
+friend class ErrorMessage;
+friend class ReturnMessage;
+friend class MessageIter;
+friend class Error;
+friend class Connection;
+};
+
+/*
+*/
+
+class DXXAPI ErrorMessage : public Message
+{
+public:
+
+ ErrorMessage();
+
+ ErrorMessage( const Message&, const char* name, const char* message );
+
+ const char* name() const;
+
+ bool name( const char* n );
+
+ bool operator == ( const ErrorMessage& ) const;
+};
+
+/*
+*/
+
+class DXXAPI SignalMessage : public Message
+{
+public:
+
+ SignalMessage( const char* name );
+
+ SignalMessage( const char* path, const char* interface, const char* name );
+
+ const char* interface() const;
+
+ bool interface( const char* i );
+
+ const char* member() const;
+
+ bool member( const char* m );
+
+ const char* path() const;
+
+ char** path_split() const;
+
+ bool path( const char* p );
+
+ bool operator == ( const SignalMessage& ) const;
+};
+
+/*
+*/
+
+class DXXAPI CallMessage : public Message
+{
+public:
+
+ CallMessage();
+
+ CallMessage( const char* dest, const char* path, const char* iface, const char* method );
+
+ const char* interface() const;
+
+ bool interface( const char* i );
+
+ const char* member() const;
+
+ bool member( const char* m );
+
+ const char* path() const;
+
+ char** path_split() const;
+
+ bool path( const char* p );
+
+ const char* signature() const;
+
+ bool operator == ( const CallMessage& ) const;
+};
+
+/*
+*/
+
+class DXXAPI ReturnMessage : public Message
+{
+public:
+
+ ReturnMessage( const CallMessage& callee );
+
+ const char* signature() const;
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_MESSAGE_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/dispatcher.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/dispatcher.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/dispatcher.h (revision 562)
@@ -0,0 +1,258 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_DISPATCHER_H
+#define __DBUSXX_DISPATCHER_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+#include "connection.h"
+
+namespace DBus {
+
+class DXXAPI Timeout
+{
+public:
+
+ class Internal;
+
+ Timeout( Internal* i );
+
+ virtual ~Timeout(){}
+
+ int interval() const;
+
+ bool enabled() const;
+
+ bool handle();
+
+ virtual void toggle() = 0;
+
+private:
+
+ DXXAPILOCAL Timeout( const Timeout& );
+
+private:
+
+ Internal* _int;
+};
+
+class DXXAPI Watch
+{
+public:
+
+ class Internal;
+
+ Watch( Internal* i );
+
+ virtual ~Watch(){}
+
+ int descriptor() const;
+
+ int flags() const;
+
+ bool enabled() const;
+
+ bool handle( int flags );
+
+ virtual void toggle() = 0;
+
+private:
+
+ DXXAPILOCAL Watch( const Watch& );
+
+private:
+
+ Internal* _int;
+};
+
+class DXXAPI Dispatcher
+{
+public:
+
+ virtual ~Dispatcher()
+ {}
+
+ void queue_connection( Connection::Private* );
+
+ void dispatch_pending();
+
+ virtual void enter() = 0;
+
+ virtual void leave() = 0;
+
+ virtual Timeout* add_timeout( Timeout::Internal* ) = 0;
+
+ virtual void rem_timeout( Timeout* ) = 0;
+
+ virtual Watch* add_watch( Watch::Internal* ) = 0;
+
+ virtual void rem_watch( Watch* ) = 0;
+
+ struct Private;
+
+private:
+
+ Connection::PrivatePList _pending_queue;
+};
+
+extern DXXAPI Dispatcher* default_dispatcher;
+
+/* classes for multithreading support
+*/
+
+class DXXAPI Mutex
+{
+public:
+
+ virtual ~Mutex() {}
+
+ virtual void lock() = 0;
+
+ virtual void unlock() = 0;
+
+ struct Internal;
+
+protected:
+
+ Internal* _int;
+};
+
+class DXXAPI CondVar
+{
+public:
+
+ virtual ~CondVar() {}
+
+ virtual void wait( Mutex* ) = 0;
+
+ virtual bool wait_timeout( Mutex*, int timeout ) = 0;
+
+ virtual void wake_one() = 0;
+
+ virtual void wake_all() = 0;
+
+ struct Internal;
+
+protected:
+
+ Internal* _int;
+};
+
+#ifndef DBUS_HAS_RECURSIVE_MUTEX
+typedef Mutex* (*MutexNewFn)();
+typedef bool (*MutexFreeFn)( Mutex* mx );
+typedef bool (*MutexLockFn)( Mutex* mx );
+typedef void (*MutexUnlockFn)( Mutex* mx );
+#else
+typedef Mutex* (*MutexNewFn)();
+typedef void (*MutexFreeFn)( Mutex* mx );
+typedef void (*MutexLockFn)( Mutex* mx );
+typedef void (*MutexUnlockFn)( Mutex* mx );
+#endif//DBUS_HAS_RECURSIVE_MUTEX
+
+typedef CondVar* (*CondVarNewFn)();
+typedef void (*CondVarFreeFn)( CondVar* cv );
+typedef void (*CondVarWaitFn)( CondVar* cv, Mutex* mx );
+typedef bool (*CondVarWaitTimeoutFn)( CondVar* cv, Mutex* mx, int timeout );
+typedef void (*CondVarWakeOneFn)( CondVar* cv );
+typedef void (*CondVarWakeAllFn)( CondVar* cv );
+
+#ifdef DBUS_HAS_THREADS_INIT_DEFAULT
+void DXXAPI _init_threading();
+#endif//DBUS_HAS_THREADS_INIT_DEFAULT
+
+void DXXAPI _init_threading(
+ MutexNewFn, MutexFreeFn, MutexLockFn, MutexUnlockFn,
+ CondVarNewFn, CondVarFreeFn, CondVarWaitFn, CondVarWaitTimeoutFn, CondVarWakeOneFn, CondVarWakeAllFn
+);
+
+template
+struct Threading
+{
+ static void init()
+ {
+ _init_threading(
+ mutex_new, mutex_free, mutex_lock, mutex_unlock,
+ condvar_new, condvar_free, condvar_wait, condvar_wait_timeout, condvar_wake_one, condvar_wake_all
+ );
+ }
+
+ static Mutex* mutex_new()
+ {
+ return new Mx;
+ }
+
+ static void mutex_free( Mutex* mx )
+ {
+ delete mx;
+ }
+
+ static void mutex_lock( Mutex* mx )
+ {
+ mx->lock();
+ }
+
+ static void mutex_unlock( Mutex* mx )
+ {
+ mx->unlock();
+ }
+
+ static CondVar* condvar_new()
+ {
+ return new Cv;
+ }
+
+ static void condvar_free( CondVar* cv )
+ {
+ delete cv;
+ }
+
+ static void condvar_wait( CondVar* cv, Mutex* mx )
+ {
+ cv->wait(mx);
+ }
+
+ static bool condvar_wait_timeout( CondVar* cv, Mutex* mx, int timeout )
+ {
+ return cv->wait_timeout(mx, timeout);
+ }
+
+ static void condvar_wake_one( CondVar* cv )
+ {
+ cv->wake_one();
+ }
+
+ static void condvar_wake_all( CondVar* cv )
+ {
+ cv->wake_all();
+ }
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_DISPATCHER_H
Index: /tags/2.0-rc2/external/dbus/include/dbus-c++/debug.h
===================================================================
--- /tags/2.0-rc2/external/dbus/include/dbus-c++/debug.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/include/dbus-c++/debug.h (revision 562)
@@ -0,0 +1,42 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_DEBUG_H
+#define __DBUSXX_DEBUG_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "api.h"
+
+namespace DBus {
+
+typedef void (*LogFunction)(const char* format, ...);
+
+extern DXXAPI LogFunction debug_log;
+
+} /* namespace DBus */
+
+#endif
Index: /tags/2.0-rc2/external/dbus/SConscript
===================================================================
--- /tags/2.0-rc2/external/dbus/SConscript (revision 1185)
+++ /tags/2.0-rc2/external/dbus/SConscript (revision 1185)
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2007 Arnold Krille
+# Copyright (C) 2007 Pieter Palmers
+#
+# This file is part of FFADO
+# FFADO = Free Firewire (pro-)audio drivers for linux
+#
+# FFADO is based upon FreeBoB.
+#
+# 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 .
+#
+
+import os
+import sys
+
+Import( 'env' )
+dbus_env = env.Clone()
+
+if dbus_env.has_key('DBUS1_FLAGS'):
+ dbus_env.MergeFlags( dbus_env['DBUS1_FLAGS'] )
+
+# add the local version of libdbus++
+dbus_env.AppendUnique( CPPPATH=["#/external/dbus/include"] )
+dbus_env.AppendUnique( LIBPATH=[dbus_env['build_base']+"external/dbus"])
+dbus_env.AppendUnique( LIBS=["dbus-c++"] )
+dbus_env.AppendUnique( CCFLAGS=["-DDBUS_API_SUBJECT_TO_CHANGE"] )
+
+sources = [
+ 'src/connection.cpp',
+ 'src/debug.cpp',
+ 'src/dispatcher.cpp',
+ 'src/error.cpp',
+ 'src/eventloop.cpp',
+ 'src/interface.cpp',
+ 'src/introspection.cpp',
+ 'src/property.cpp',
+ 'src/message.cpp',
+ 'src/object.cpp',
+ 'src/pendingcall.cpp',
+ 'src/server.cpp',
+ 'src/types.cpp'
+]
+
+if dbus_env.has_key('DEBUG') and dbus_env['DEBUG']:
+ dbus_env.AppendUnique( CCFLAGS=["-DDEBUG","-g"] )
+
+dbus_env.PrependUnique( LIBS=["expat"] )
+libdbuspp=dbus_env.StaticLibrary('dbus-c++', sources)
+
+#
+# tools
+#
+
+tools_env = dbus_env
+
+introspect_sources = [
+ 'tools/introspect.cpp',
+]
+
+xml2cpp_sources = [
+ 'tools/xml.cpp','tools/xml2cpp.cpp'
+]
+
+tools_env.AppendUnique( CCFLAGS=["-DDBUS_API_SUBJECT_TO_CHANGE"] )
+tools_env.AppendUnique( CPPPATH=["#/external/dbus/include"] )
+tools_env.PrependUnique( LIBPATH=dbus_env['build_base']+"external/dbus" )
+tools_env.PrependUnique( LIBS="dbus-c++" )
+
+dbusxx_introspect = tools_env.Program('dbusxx-introspect', introspect_sources)
+dbusxx_xml2cpp = tools_env.Program('dbusxx-xml2cpp', xml2cpp_sources)
+
Index: /tags/2.0-rc2/external/dbus/src/glib-integration.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/src/glib-integration.cpp (revision 562)
+++ /tags/2.0-rc2/external/dbus/src/glib-integration.cpp (revision 562)
@@ -0,0 +1,218 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+
+#include // for DBUS_WATCH_*
+
+using namespace DBus;
+
+Glib::BusTimeout::BusTimeout( Timeout::Internal* ti, GMainContext* ctx )
+: Timeout(ti), _ctx(ctx)
+{
+ _enable();
+}
+
+Glib::BusTimeout::~BusTimeout()
+{
+ _disable();
+}
+
+void Glib::BusTimeout::toggle()
+{
+ debug_log("glib: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
+
+ if(Timeout::enabled()) _enable();
+ else _disable();
+}
+
+gboolean Glib::BusTimeout::timeout_handler( gpointer data )
+{
+ Glib::BusTimeout* t = reinterpret_cast(data);
+
+ t->handle();
+
+ return TRUE;
+}
+
+void Glib::BusTimeout::_enable()
+{
+ _source = g_timeout_source_new(Timeout::interval());
+ g_source_set_callback(_source, timeout_handler, this, NULL);
+ g_source_attach(_source, _ctx);
+}
+
+void Glib::BusTimeout::_disable()
+{
+ g_source_destroy(_source);
+}
+
+struct BusSource
+{
+ GSource source;
+ GPollFD poll;
+};
+
+static gboolean watch_prepare( GSource *source, gint *timeout )
+{
+// debug_log("glib: watch_prepare");
+
+ *timeout = -1;
+ return FALSE;
+}
+
+static gboolean watch_check( GSource *source )
+{
+// debug_log("glib: watch_check");
+
+ BusSource* io = (BusSource*)source;
+ return io->poll.revents ? TRUE : FALSE;
+}
+
+static gboolean watch_dispatch( GSource *source, GSourceFunc callback, gpointer data )
+{
+ debug_log("glib: watch_dispatch");
+
+ gboolean cb = callback(data);
+ DBus::default_dispatcher->dispatch_pending(); //TODO: won't work in case of multiple dispatchers
+ return cb;
+}
+
+static GSourceFuncs watch_funcs = {
+ watch_prepare,
+ watch_check,
+ watch_dispatch,
+ NULL
+};
+
+Glib::BusWatch::BusWatch( Watch::Internal* wi, GMainContext* ctx )
+: Watch(wi), _ctx(ctx)
+{
+ _enable();
+}
+
+Glib::BusWatch::~BusWatch()
+{
+ _disable();
+}
+
+void Glib::BusWatch::toggle()
+{
+ debug_log("glib: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off");
+
+ if(Watch::enabled()) _enable();
+ else _disable();
+}
+
+gboolean Glib::BusWatch::watch_handler( gpointer data )
+{
+ Glib::BusWatch* w = reinterpret_cast(data);
+
+ BusSource* io = (BusSource*)(w->_source);
+
+ int flags = 0;
+ if(io->poll.revents & G_IO_IN)
+ flags |= DBUS_WATCH_READABLE;
+ if(io->poll.revents & G_IO_OUT)
+ flags |= DBUS_WATCH_WRITABLE;
+ if(io->poll.revents & G_IO_ERR)
+ flags |= DBUS_WATCH_ERROR;
+ if(io->poll.revents & G_IO_HUP)
+ flags |= DBUS_WATCH_HANGUP;
+
+ w->handle(flags);
+
+ return TRUE;
+}
+
+void Glib::BusWatch::_enable()
+{
+ _source = g_source_new(&watch_funcs, sizeof(BusSource));
+ g_source_set_callback(_source, watch_handler, this, NULL);
+
+ int flags = Watch::flags();
+ int condition = 0;
+
+ if(flags & DBUS_WATCH_READABLE)
+ condition |= G_IO_IN;
+// if(flags & DBUS_WATCH_WRITABLE)
+// condition |= G_IO_OUT;
+ if(flags & DBUS_WATCH_ERROR)
+ condition |= G_IO_ERR;
+ if(flags & DBUS_WATCH_HANGUP)
+ condition |= G_IO_HUP;
+
+ GPollFD* poll = &(((BusSource*)_source)->poll);
+ poll->fd = Watch::descriptor();
+ poll->events = condition;
+ poll->revents = 0;
+
+ g_source_add_poll(_source, poll);
+ g_source_attach(_source, _ctx);
+}
+
+void Glib::BusWatch::_disable()
+{
+ GPollFD* poll = &(((BusSource*)_source)->poll);
+ g_source_remove_poll(_source, poll);
+ g_source_destroy(_source);
+}
+
+void Glib::BusDispatcher::attach( GMainContext* ctx )
+{
+ _ctx = ctx ? ctx : g_main_context_default();
+}
+
+Timeout* Glib::BusDispatcher::add_timeout( Timeout::Internal* wi )
+{
+ Timeout* t = new Glib::BusTimeout(wi, _ctx);
+
+ debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off");
+
+ return t;
+}
+
+void Glib::BusDispatcher::rem_timeout( Timeout* t )
+{
+ debug_log("glib: removed timeout %p", t);
+
+ delete t;
+}
+
+Watch* Glib::BusDispatcher::add_watch( Watch::Internal* wi )
+{
+ Watch* w = new Glib::BusWatch(wi, _ctx);
+
+ debug_log("glib: added watch %p (%s) fd=%d flags=%d",
+ w, w->enabled() ? "on":"off", w->descriptor(), w->flags()
+ );
+ return w;
+}
+
+void Glib::BusDispatcher::rem_watch( Watch* w )
+{
+ debug_log("glib: removed watch %p", w);
+
+ delete w;
+}
Index: /tags/2.0-rc2/external/dbus/src/connection.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/src/connection.cpp (revision 562)
+++ /tags/2.0-rc2/external/dbus/src/connection.cpp (revision 562)
@@ -0,0 +1,413 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+#include
+
+#include
+#include
+
+#include "internalerror.h"
+
+#include "connection_p.h"
+#include "dispatcher_p.h"
+#include "server_p.h"
+#include "message_p.h"
+#include "pendingcall_p.h"
+
+using namespace DBus;
+
+Connection::Private::Private( DBusConnection* c, Server::Private* s )
+: conn(c) , dispatcher(0), server(s)
+{
+ init();
+}
+
+Connection::Private::Private( DBusBusType type )
+{
+ InternalError e;
+
+ conn = dbus_bus_get_private(type, e);
+
+ if(e) throw Error(e);
+
+ init();
+}
+
+Connection::Private::~Private()
+{
+ debug_log("terminating connection 0x%08x", conn);
+
+ detach_server();
+
+ if(dbus_connection_get_is_connected(conn))
+ {
+ std::vector::iterator i = names.begin();
+
+ while(i != names.end())
+ {
+ debug_log("%s: releasing bus name %s", dbus_bus_get_unique_name(conn), i->c_str());
+ dbus_bus_release_name(conn, i->c_str(), NULL);
+ ++i;
+ }
+ dbus_connection_close(conn);
+ }
+ dbus_connection_unref(conn);
+}
+
+void Connection::Private::init()
+{
+ dbus_connection_ref(conn);
+ dbus_connection_ref(conn); //todo: the library has to own another reference
+
+ disconn_filter = new Callback(
+ this, &Connection::Private::disconn_filter_function
+ );
+
+ dbus_connection_add_filter(conn, message_filter_stub, &disconn_filter, NULL);
+
+ dbus_connection_set_dispatch_status_function(conn, dispatch_status_stub, this, 0);
+ dbus_connection_set_exit_on_disconnect(conn, false); //why was this set to true??
+}
+
+void Connection::Private::detach_server()
+{
+/* Server::Private* tmp = server;
+
+ server = NULL;
+
+ if(tmp)
+ {
+ ConnectionList::iterator i;
+
+ for(i = tmp->connections.begin(); i != tmp->connections.end(); ++i)
+ {
+ if(i->_pvt.get() == this)
+ {
+ tmp->connections.erase(i);
+ break;
+ }
+ }
+ }*/
+}
+
+bool Connection::Private::do_dispatch()
+{
+ debug_log("dispatching on %p", conn);
+
+ if(!dbus_connection_get_is_connected(conn))
+ {
+ debug_log("connection terminated");
+
+ detach_server();
+
+ return true;
+ }
+
+ return dbus_connection_dispatch(conn) != DBUS_DISPATCH_DATA_REMAINS;
+}
+
+void Connection::Private::dispatch_status_stub( DBusConnection* dc, DBusDispatchStatus status, void* data )
+{
+ Private* p = static_cast(data);
+
+ switch(status)
+ {
+ case DBUS_DISPATCH_DATA_REMAINS:
+ debug_log("some dispatching to do on %p", dc);
+ p->dispatcher->queue_connection(p);
+ break;
+
+ case DBUS_DISPATCH_COMPLETE:
+ debug_log("all dispatching done on %p", dc);
+ break;
+
+ case DBUS_DISPATCH_NEED_MEMORY: //uh oh...
+ debug_log("connection %p needs memory", dc);
+ break;
+ }
+}
+
+DBusHandlerResult Connection::Private::message_filter_stub( DBusConnection* conn, DBusMessage* dmsg, void* data )
+{
+ MessageSlot* slot = static_cast(data);
+
+ Message msg = Message(new Message::Private(dmsg));
+
+ return slot && !slot->empty() && slot->call(msg)
+ ? DBUS_HANDLER_RESULT_HANDLED
+ : DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+bool Connection::Private::disconn_filter_function( const Message& msg )
+{
+ if(msg.is_signal(DBUS_INTERFACE_LOCAL,"Disconnected"))
+ {
+ debug_log("%p disconnected by local bus", conn);
+ dbus_connection_close(conn);
+
+ return true;
+ }
+ return false;
+}
+
+Connection Connection::SystemBus()
+{
+ return Connection(new Private(DBUS_BUS_SYSTEM));
+}
+
+Connection Connection::SessionBus()
+{
+ return Connection(new Private(DBUS_BUS_SESSION));
+}
+
+Connection Connection::ActivationBus()
+{
+ return Connection(new Private(DBUS_BUS_STARTER));
+}
+
+Connection::Connection( const char* address, bool priv )
+{
+ InternalError e;
+ DBusConnection* conn = priv
+ ? dbus_connection_open_private(address, e)
+ : dbus_connection_open(address, e);
+
+ if(e) throw Error(e);
+
+ _pvt = new Private(conn);
+
+ setup(default_dispatcher);
+
+ debug_log("connected to %s", address);
+}
+
+Connection::Connection( Connection::Private* p )
+: _pvt(p)
+{
+ setup(default_dispatcher);
+}
+
+Connection::Connection( const Connection& c )
+: _pvt(c._pvt)
+{
+ dbus_connection_ref(_pvt->conn);
+}
+
+Connection::~Connection()
+{
+ dbus_connection_unref(_pvt->conn);
+}
+
+Dispatcher* Connection::setup( Dispatcher* dispatcher )
+{
+ debug_log("registering stubs for connection %p", _pvt->conn);
+
+ if(!dispatcher) dispatcher = default_dispatcher;
+
+ if(!dispatcher) throw ErrorFailed("no default dispatcher set for new connection");
+
+ Dispatcher* prev = _pvt->dispatcher;
+
+ _pvt->dispatcher = dispatcher;
+
+ dispatcher->queue_connection(_pvt.get());
+
+ dbus_connection_set_watch_functions(
+ _pvt->conn,
+ Dispatcher::Private::on_add_watch,
+ Dispatcher::Private::on_rem_watch,
+ Dispatcher::Private::on_toggle_watch,
+ dispatcher,
+ 0
+ );
+
+ dbus_connection_set_timeout_functions(
+ _pvt->conn,
+ Dispatcher::Private::on_add_timeout,
+ Dispatcher::Private::on_rem_timeout,
+ Dispatcher::Private::on_toggle_timeout,
+ dispatcher,
+ 0
+ );
+
+ return prev;
+}
+
+bool Connection::operator == ( const Connection& c ) const
+{
+ return _pvt->conn == c._pvt->conn;
+}
+
+bool Connection::register_bus()
+{
+ InternalError e;
+
+ bool r = dbus_bus_register(_pvt->conn, e);
+
+ if(e) throw (e);
+
+ return r;
+}
+
+bool Connection::connected() const
+{
+ return dbus_connection_get_is_connected(_pvt->conn);
+}
+
+void Connection::disconnect()
+{
+// dbus_connection_disconnect(_pvt->conn); // disappeared in 0.9x
+ dbus_connection_close(_pvt->conn);
+}
+
+void Connection::exit_on_disconnect( bool exit )
+{
+ dbus_connection_set_exit_on_disconnect(_pvt->conn, exit);
+}
+
+bool Connection::unique_name( const char* n )
+{
+ return dbus_bus_set_unique_name(_pvt->conn, n);
+}
+
+const char* Connection::unique_name() const
+{
+ return dbus_bus_get_unique_name(_pvt->conn);
+}
+
+void Connection::flush()
+{
+ dbus_connection_flush(_pvt->conn);
+}
+
+void Connection::add_match( const char* rule )
+{
+ InternalError e;
+
+ dbus_bus_add_match(_pvt->conn, rule, e);
+
+ debug_log("%s: added match rule %s", unique_name(), rule);
+
+ if(e) throw Error(e);
+}
+
+void Connection::remove_match( const char* rule )
+{
+ InternalError e;
+
+ dbus_bus_remove_match(_pvt->conn, rule, e);
+
+ debug_log("%s: removed match rule %s", unique_name(), rule);
+
+ if(e) throw Error(e);
+}
+
+bool Connection::add_filter( MessageSlot& s )
+{
+ debug_log("%s: adding filter", unique_name());
+ return dbus_connection_add_filter(_pvt->conn, Private::message_filter_stub, &s, NULL);
+}
+
+void Connection::remove_filter( MessageSlot& s )
+{
+ debug_log("%s: removing filter", unique_name());
+ dbus_connection_remove_filter(_pvt->conn, Private::message_filter_stub, &s);
+}
+
+bool Connection::send( const Message& msg, unsigned int* serial )
+{
+ return dbus_connection_send(_pvt->conn, msg._pvt->msg, serial);
+}
+
+Message Connection::send_blocking( Message& msg, int timeout )
+{
+ DBusMessage* reply;
+ InternalError e;
+
+ reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e);
+
+ if(e) throw Error(e);
+
+ return Message(new Message::Private(reply), false);
+}
+
+PendingCall Connection::send_async( Message& msg, int timeout )
+{
+ DBusPendingCall* pending;
+
+ if(!dbus_connection_send_with_reply(_pvt->conn, msg._pvt->msg, &pending, timeout))
+ {
+ throw ErrorNoMemory("Unable to start asynchronous call");
+ }
+ return PendingCall(new PendingCall::Private(pending));
+}
+
+void Connection::request_name( const char* name, int flags )
+{
+ InternalError e;
+
+ debug_log("%s: registering bus name %s", unique_name(), name);
+
+ dbus_bus_request_name(_pvt->conn, name, flags, e); //we deliberately don't check return value
+
+ if(e) throw Error(e);
+
+// this->remove_match("destination");
+
+ if(name)
+ {
+ _pvt->names.push_back(name);
+ std::string match = "destination='" + _pvt->names.back() + "'";
+ add_match(match.c_str());
+ }
+}
+
+bool Connection::has_name( const char* name )
+{
+ InternalError e;
+
+ bool b = dbus_bus_name_has_owner(_pvt->conn, name, e);
+
+ if(e) throw Error(e);
+
+ return b;
+}
+
+const std::vector& Connection::names()
+{
+ return _pvt->names;
+}
+
+bool Connection::start_service( const char* name, unsigned long flags )
+{
+ InternalError e;
+
+ bool b = dbus_bus_start_service_by_name(_pvt->conn, name, flags, NULL, e);
+
+ if(e) throw Error(e);
+
+ return b;
+}
+
Index: /tags/2.0-rc2/external/dbus/src/introspection.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/src/introspection.cpp (revision 575)
+++ /tags/2.0-rc2/external/dbus/src/introspection.cpp (revision 575)
@@ -0,0 +1,185 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+#include
+#include
+
+#include
+
+#include
+
+using namespace DBus;
+
+static const char* introspectable_name = "org.freedesktop.DBus.Introspectable";
+
+IntrospectableAdaptor::IntrospectableAdaptor()
+: InterfaceAdaptor(introspectable_name)
+{
+ register_method(IntrospectableAdaptor, Introspect, Introspect);
+}
+
+Message IntrospectableAdaptor::Introspect( const CallMessage& call )
+{
+ debug_log("requested introspection data");
+
+ std::ostringstream xml;
+
+ xml << DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE;
+
+ const std::string path = object()->path();
+
+ xml << "";
+
+ InterfaceAdaptorTable::const_iterator iti;
+
+ for(iti = _interfaces.begin(); iti != _interfaces.end(); ++iti)
+ {
+ debug_log("introspecting interface %s", iti->first.c_str());
+
+ IntrospectedInterface* const intro = iti->second->introspect();
+ if(intro)
+ {
+ xml << "name << "\">";
+
+ for(const IntrospectedProperty* p = intro->properties; p->name; ++p)
+ {
+ std::string access;
+
+ if(p->read) access += "read";
+ if(p->write) access += "write";
+
+ xml << "name << "\""
+ << " type=\"" << p->type << "\""
+ << " access=\"" << access << "\"/>";
+ }
+
+ for(const IntrospectedMethod* m = intro->methods; m->args; ++m)
+ {
+ xml << "name << "\">";
+
+ for(const IntrospectedArgument* a = m->args; a->type; ++a)
+ {
+ xml << "in ? "in" : "out") << "\""
+ << " type=\"" << a->type << "\"";
+
+ if(a->name) xml << " name=\"" << a->name << "\"";
+
+ xml << "/>";
+ }
+
+ xml << " ";
+ }
+
+ for(const IntrospectedMethod* m = intro->signals; m->args; ++m)
+ {
+ xml << "name << "\">";
+
+ for(const IntrospectedArgument* a = m->args; a->type; ++a)
+ {
+ xml << "type << "\"";
+
+ if(a->name) xml << " name=\"" << a->name << "\"";
+
+ xml << "/>";
+ }
+ xml << " ";
+ }
+
+ xml << " ";
+ }
+ }
+ const ObjectAdaptorPList children = ObjectAdaptor::from_path_prefix(path + '/');
+
+ ObjectAdaptorPList::const_iterator oci;
+
+ debug_log("nb children: %d", children.size());
+ for(oci = children.begin(); oci != children.end(); ++oci)
+ {
+
+ std::string name = (*oci)->path().substr(path.length()+1);
+
+ std::string::size_type loc = name.find('/');
+ if( loc != std::string::npos ) {
+ name.substr(loc);
+ }
+
+ xml << " ";
+ }
+
+ xml << " ";
+
+ ReturnMessage reply(call);
+ MessageIter wi = reply.writer();
+ wi.append_string(xml.str().c_str());
+ return reply;
+}
+
+IntrospectedInterface* const IntrospectableAdaptor::introspect() const
+{
+ static IntrospectedArgument Introspect_args[] =
+ {
+ { "data", "s", false },
+ { 0, 0, 0 }
+ };
+ static IntrospectedMethod Introspectable_methods[] =
+ {
+ { "Introspect", Introspect_args },
+ { 0, 0 }
+ };
+ static IntrospectedMethod Introspectable_signals[] =
+ {
+ { 0, 0 }
+ };
+ static IntrospectedProperty Introspectable_properties[] =
+ {
+ { 0, 0, 0, 0 }
+ };
+ static IntrospectedInterface Introspectable_interface =
+ {
+ introspectable_name,
+ Introspectable_methods,
+ Introspectable_signals,
+ Introspectable_properties
+ };
+ return &Introspectable_interface;
+}
+
+IntrospectableProxy::IntrospectableProxy()
+: InterfaceProxy(introspectable_name)
+{}
+
+std::string IntrospectableProxy::Introspect()
+{
+ DBus::CallMessage call;
+
+ call.member("Introspect");
+
+ DBus::Message ret = invoke_method(call);
+
+ DBus::MessageIter ri = ret.reader();
+ const char* str = ri.get_string();
+
+ return str;
+}
Index: /tags/2.0-rc2/external/dbus/src/interface.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/src/interface.cpp (revision 562)
+++ /tags/2.0-rc2/external/dbus/src/interface.cpp (revision 562)
@@ -0,0 +1,148 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+#include
+
+#include "internalerror.h"
+
+using namespace DBus;
+
+Interface::Interface( const std::string& name )
+: _name(name)
+{}
+
+Interface::~Interface()
+{}
+
+InterfaceAdaptor* AdaptorBase::find_interface( const std::string& name )
+{
+ InterfaceAdaptorTable::const_iterator ii = _interfaces.find(name);
+
+ return ii != _interfaces.end() ? ii->second : NULL;
+}
+
+InterfaceAdaptor::InterfaceAdaptor( const std::string& name )
+: Interface(name)
+{
+ debug_log("adding interface %s", name.c_str());
+
+ _interfaces[name] = this;
+}
+
+Message InterfaceAdaptor::dispatch_method( const CallMessage& msg )
+{
+ const char* name = msg.member();
+
+ MethodTable::iterator mi = _methods.find(name);
+ if( mi != _methods.end() )
+ {
+ return mi->second.call( msg );
+ }
+ else
+ {
+ return ErrorMessage(msg, DBUS_ERROR_UNKNOWN_METHOD, name);
+ }
+}
+
+void InterfaceAdaptor::emit_signal( const SignalMessage& sig )
+{
+ SignalMessage& sig2 = const_cast(sig);
+
+ sig2.interface( name().c_str() );
+ _emit_signal(sig2);
+}
+
+Variant* InterfaceAdaptor::get_property( const std::string& name )
+{
+ PropertyTable::iterator pti = _properties.find(name);
+
+ if( pti != _properties.end() )
+ {
+ if( !pti->second.read )
+ throw ErrorAccessDenied("property is not readable");
+
+ return &(pti->second.value);
+ }
+ return NULL;
+}
+
+void InterfaceAdaptor::set_property( const std::string& name, Variant& value )
+{
+ PropertyTable::iterator pti = _properties.find(name);
+
+ if( pti != _properties.end() )
+ {
+ if( !pti->second.write )
+ throw ErrorAccessDenied("property is not writeable");
+
+ Signature sig = value.signature();
+
+ if( pti->second.sig != sig )
+ throw ErrorInvalidSignature("property expects a different type");
+
+ pti->second.value = value;
+ return;
+ }
+ throw ErrorFailed("requested property not found");
+}
+
+InterfaceProxy* ProxyBase::find_interface( const std::string& name )
+{
+ InterfaceProxyTable::const_iterator ii = _interfaces.find(name);
+
+ return ii != _interfaces.end() ? ii->second : NULL;
+}
+
+InterfaceProxy::InterfaceProxy( const std::string& name )
+: Interface(name)
+{
+ debug_log("adding interface %s", name.c_str());
+
+ _interfaces[name] = this;
+}
+
+bool InterfaceProxy::dispatch_signal( const SignalMessage& msg )
+{
+ const char* name = msg.member();
+
+ SignalTable::iterator si = _signals.find(name);
+ if( si != _signals.end() )
+ {
+ si->second.call( msg );
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+Message InterfaceProxy::invoke_method( const CallMessage& call )
+{
+ CallMessage& call2 = const_cast(call);
+
+ call2.interface( name().c_str() );
+ return _invoke_method(call2);
+}
Index: /tags/2.0-rc2/external/dbus/src/pendingcall_p.h
===================================================================
--- /tags/2.0-rc2/external/dbus/src/pendingcall_p.h (revision 562)
+++ /tags/2.0-rc2/external/dbus/src/pendingcall_p.h (revision 562)
@@ -0,0 +1,53 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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
+ *
+ */
+
+
+#ifndef __DBUSXX_PENDING_CALL_P_H
+#define __DBUSXX_PENDING_CALL_P_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include
+#include
+
+#include
+
+namespace DBus {
+
+struct DXXAPILOCAL PendingCall::Private
+{
+ DBusPendingCall* call;
+ int dataslot;
+
+ Private( DBusPendingCall* );
+
+ ~Private();
+
+ static void notify_stub( DBusPendingCall* dpc, void* data );
+};
+
+} /* namespace DBus */
+
+#endif//__DBUSXX_PENDING_CALL_P_H
Index: /tags/2.0-rc2/external/dbus/src/types.cpp
===================================================================
--- /tags/2.0-rc2/external/dbus/src/types.cpp (revision 1235)
+++ /tags/2.0-rc2/external/dbus/src/types.cpp (revision 1235)
@@ -0,0 +1,104 @@
+/*
+ *
+ * D-Bus++ - C++ bindings for D-Bus
+ *
+ * Copyright (C) 2005-2007 Paolo Durante
+ *
+ *
+ * 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