head 1.14; access; symbols FSL_1_7_0:1.14 CFG_0_9_11:1.14 FSL_1_6_1:1.13 CFG_0_9_10:1.13 FSL_1_6_0:1.13 FSL_1_6b2:1.13 CFG_0_9_9:1.13 FSL_1_6b1:1.13 CFG_0_9_8:1.13 CFG_0_9_7:1.12 CFG_0_9_6:1.12 CFG_0_9_5:1.12 CFG_0_9_4:1.12 FSL_1_5_0:1.11 FSL_1_5a3:1.11 CFG_0_9_3:1.11 FSL_1_5a2:1.11 FSL_1_5a1:1.11 FSL_1_4_0:1.11 FSL_1_4b1:1.11 CFG_0_9_2:1.11 CFG_0_9_1:1.11 FSL_1_4a1:1.11 FSL_1_3_0:1.11 FSL_1_3b1:1.11 FSL_1_2_1:1.11 FSL_1_2_0:1.11 FSL_1_1_0:1.11 FSL_1_1b1:1.11 FSL_1_0_8:1.11 FSL_1_0_7:1.11 FSL_1_0_6:1.8 FSL_1_0_5:1.8 FSL_1_0_4:1.8 FSL_1_0_3:1.7 FSL_1_0_2:1.7 FSL_1_0_1:1.6 FSL_1_0_0:1.6 FSL_0_9_0:1.6 CFG_0_9_0:1.6 FSL_0_1_12:1.5 FSL_0_1_11:1.5 FSL_0_1_10:1.5 FSL_0_1_9:1.4 FSL_0_1_8:1.4 FSL_0_1_7:1.4 FSL_0_1_6:1.4 FSL_0_1_5:1.4 FSL_0_1_1:1.4; locks; strict; comment @# @; 1.14 date 2006.08.10.19.35.56; author rse; state Exp; branches; next 1.13; commitid Isy241gp4yykKkIr; 1.13 date 2004.12.31.19.16.25; author rse; state Exp; branches; next 1.12; 1.12 date 2004.07.17.07.37.55; author rse; state Exp; branches; next 1.11; 1.11 date 2003.01.06.11.17.43; author rse; state Exp; branches; next 1.10; 1.10 date 2002.11.19.14.43.22; author rse; state Exp; branches; next 1.9; 1.9 date 2002.11.10.12.12.23; author rse; state Exp; branches; next 1.8; 1.8 date 2002.10.05.15.49.23; author rse; state Exp; branches; next 1.7; 1.7 date 2002.08.09.13.30.18; author rse; state Exp; branches; next 1.6; 1.6 date 2002.07.30.19.28.37; author rse; state Exp; branches; next 1.5; 1.5 date 2002.07.28.11.09.16; author rse; state Exp; branches; next 1.4; 1.4 date 2002.07.18.15.34.55; author rse; state Exp; branches; next 1.3; 1.3 date 2002.07.12.19.59.33; author rse; state Exp; branches; next 1.2; 1.2 date 2002.07.06.12.23.43; author rse; state Exp; branches; next 1.1; 1.1 date 2002.07.03.13.25.34; author rse; state Exp; branches; next ; desc @@ 1.14 log @cleanup source tree for status as of 2006 @ text @## ## OSSP cfg - Configuration Parsing ## Copyright (c) 2002-2006 Ralf S. Engelschall ## Copyright (c) 2002-2006 The OSSP Project (http://www.ossp.org/) ## ## This file is part of OSSP cfg, a configuration parsing ## library which can be found at http://www.ossp.org/pkg/lib/cfg/. ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that ## the above copyright notice and this permission notice appear in all ## copies. ## ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## ## cfg.pod: manual page ## =pod =head1 NAME B - Configuration Parsing =head1 VERSION OSSP cfg CFG_VERSION_STR =head1 SYNOPSIS =over 4 =item B cfg.h =item B cfg_t, cfg_rc_t, cfg_node_type_t, cfg_node_t, cfg_node_attr_t, cfg_fmt_t, cfg_data_t, cfg_data_ctrl_t, cfg_data_cb_t, cfg_data_attr_t =item B cfg_create, cfg_destroy, cfg_error, cfg_version, cfg_import, cfg_export, cfg_node_create, cfg_node_destroy, cfg_node_clone, cfg_node_set, cfg_node_get, cfg_node_root, cfg_node_select, cfg_node_find, cfg_node_apply, cfg_node_cmp, cfg_node_link, cfg_node_unlink, cfg_data_set, cfg_data_get, cfg_data_ctrl =back =head1 DESCRIPTION B is a ISO-C library for parsing arbitrary C/C++-style configuration files. A configuration is sequence of directives. Each directive consists of zero or more tokens. Each token can be either a string or again a complete sequence. This means the configuration syntax has a recursive structure and this way allows to create configurations with arbitrarily nested sections. Additionally the configuration syntax provides complex single/double/balanced quoting of tokens, hexadecimal/octal/decimal character encodings, character escaping, C/C++ and Shell-style comments, etc. The library API allows importing a configuration text into an Abstract Syntax Tree (AST), traversing the AST and optionally exporting the AST again as a configuration text. =head2 CONFIGURATION SYNTAX The configuration syntax is described by the following context-free (Chomsky-2) grammar: B ::= I | B | B B B B ::= B | B B B ::= B B B | B B ::= B # double quoted string | B # single quoted string | B # flexible quoted string | B # plain text string The other contained terminal symbols are defined itself by the following set of grammars production (regular sub-grammars for character sequences given as Perl-style regular expressions "/I/"): B ::= /;/ B ::= /{/ B ::= /}/ B ::= /"/ B /"/ B ::= I | B B B ::= /\\"/ # escaped quote | /\\x\{[0-9a-fA-F]+\}/ # hex-char group | /\\x[0-9a-fA-F]{2}/ # hex-char | /\\[0-7]{1,3}/ # octal character | /\\[nrtbfae]/ # special character | /\\\n[ \t]*/ # line continuation | /\\\\/ # escaped escape | /./ # any other char B ::= /'/ B /'/ B ::= I | B B B ::= /\\'/ # escaped quote | /\\\n[ \t]*/ # line contination | /\\\\/ # escaped escape | /./ # any other char B ::= /q/ B B B B ::= I | B B B ::= /\\/ B # escaped open | /\\/ B # escaped close | /\\\n[ \t]*/ # line contination | /./ # any other char B ::= /[!"#$%&'()*+,-./:;<=>?@@\[\\\]^_`{|}~]/ B ::= EE B or corresponding closing char ('}])>') if B is a char of '{[(<' EE B ::= B B B ::= I | B B B ::= /[^ \t\n;{}"']/ # none of specials Additionally, white-space B and comment B tokens are allowed at any position in the above productions of the previous grammar part. B ::= /[ \t\n]+/ B ::= B # style of C | B # style of C++ | B # style of /bin/sh B ::= /\/\*([^*]|\*(?!\/))*\*\// B ::= /\/\/[^\n]*/ B ::= /#[^\n]*/ Finally, any configuration line can have a trailing backslash character (C<\>) just before the newline character for simple line continuation. The backslash, the newline and (optionally) the leading whitespaces on the following line are silently obsorbed and as a side-effect continue the first line with the contents of the second lines. =head2 CONFIGURATION EXAMPLE A more intuitive description of the configuration syntax is perhaps given by the following example which shows all features at once: /* single word */ foo; /* multi word */ foo bar quux; /* nested structure */ foo { bar; baz } quux; /* quoted strings */ 'foo bar' "foo\x0a\t\n\ bar" =head1 APPLICATION PROGRAMMING INTERFACE (API) ... =head1 NODE SELECTION SPECIFICATION The B function takes a I string B ::= I | B B