/* Asterisk INI to Property List File Conversion Utility -- Version 1.10 * * parser.h * aini2plist * * Recursive descent parser for generic Asterisk INI configuration files * * Author: Benjamin Kowarsch * * (C) 2006 Sunrise Telephone Systems Ltd. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * In countries and territories where the above no-warranty disclaimer is * not permissible by applicable law, the following terms apply: * * NO PERMISSION TO USE THE SOFTWARE IS GRANTED AND THE SOFTWARE MUST NOT BE * USED AT ALL IN SUCH COUNTRIES AND TERRITORIES WHERE THE ABOVE NO-WARRANTY * DISCLAIMER IS NOT PERMISSIBLE AND INVALIDATED BY APPLICABLE LAW. HOWEVER, * THE COPYRIGHT HOLDERS HEREBY WAIVE THEIR RIGHT TO PURSUE OFFENDERS AS LONG * AS THEY OTHERWISE ABIDE BY THE TERMS OF THE LICENSE AS APPLICABLE FOR USE * OF THE SOFTWARE IN COUNTRIES AND TERRITORIES WHERE THE ABOVE NO-WARRANTY * DISCLAIMER IS PERMITTED BY APPLICABLE LAW. THIS WAIVER DOES NOT CONSTITUTE * A LICENSE TO USE THE SOFTWARE IN COUNTRIES AND TERRITORIES WHERE THE ABOVE * NO-WARRANTY DISCLAIMER IS NOT PERMISSIBLE AND INVALIDATED BY APPLICABLE * LAW. ANY LIABILITY OF ANY KIND IS CATEGORICALLY RULED OUT AT ALL TIMES. */ #include #import "globaldefs.h" // This module implements a single pass recursive descent parser for the // LL(1) grammar below which describes Asterisk INI configuration files: // // Production rules // // (1) config-file = // { config-unit } end-of-file-mark // // (2) config-unit = // section | comment-line | empty-line // // (3) section = // section-header section-body // // (4) section-header = // start-of-section-header identifier end-of-section-header // [ comment ] end-of-line-mark // // (5) section-body = // { key-value-assignment | comment-line | empty-line } // // (6) key-value-assignment = // identifier assign-operator value-list // [ comment ] end-of-line-mark // // (7) value-list = // value { value-separator value } // // (8) value = // composite-plain-value | composite-quoted-value // // (9) composite-plain-value = // plain-value [ argument-list ] // // (10) composite-quoted-value = // quoted-value [ bracketed-value ] // // (11) comment-line = // comment end-of-line-mark // // (12) empty-line = // end-of-line-mark // --------------------------------------------------------------------------- // Highest level of verbosity // --------------------------------------------------------------------------- #define MAX_VERBOSITY 3 // --------------------------------------------------------------------------- // Highest level of comment exclusion // --------------------------------------------------------------------------- #define MAX_COMMENT_EXCLUSION 3 // -------------------------------------------------------------------------- // function set_global_parser_defaults(verbosity, comment_exclusion) // -------------------------------------------------------------------------- // // verbosity levels: // // level 0 (default) // least verbose // // level 3 // most verbose // // comment exclusion levels: // // level 0 (default) // all comments are processed // // level 1 // comment lines inside sections are ignored // inline comments inside sections are processed // comment lines outside of sections are processed // // level 2 // comment lines inside sections are ignored // inline comments inside sections are ignored // comment lines outside of sections are processed // // level 3 // all comments are ignored void set_global_parser_defaults(CARDINAL verbosity, CARDINAL comment_exclusion); // -------------------------------------------------------------------------- // function parse_file(pathname) // -------------------------------------------------------------------------- // int parse_file(const char *infile); // --------------------------------------------------------------------------- // function: get_error_count() // --------------------------------------------------------------------------- // // Returns the error count of the pervious parser invocation. CARDINAL get_error_count(); // END OF FILE