1 /* 2 * Copyright (c) 2005, Stefan Walter 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * * Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the 11 * following disclaimer. 12 * * Redistributions in binary form must reproduce the 13 * above copyright notice, this list of conditions and 14 * the following disclaimer in the documentation and/or 15 * other materials provided with the distribution. 16 * * The names of contributors to this software may not be 17 * used to endorse or promote products derived from this 18 * software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 31 * DAMAGE. 32 * 33 * 34 * CONTRIBUTORS 35 * Stefan Walter <stef@memberwebs.com> 36 */ 37 38 #ifndef __CONFIG_PARSER_H__ 39 #define __CONFIG_PARSER_H__ 40 41 #include <bsnmp/asn1.h> 42 #include <bsnmp/snmp.h> 43 44 /* Callbacks must be defined by the caller */ 45 extern int cfg_value(const char* filename, const char* header, const char* name, 46 char* value, void* data); 47 extern int cfg_error(const char* filename, const char* errmsg, void* data); 48 49 /* Calling these will call the callbacks above */ 50 int cfg_parse_dir(const char* dirname, void* data); 51 int cfg_parse_file(const char* filename, void* data, char** memory); 52 53 /* A helper for parsing URIs */ 54 const char* cfg_parse_uri (char *uri, char** scheme, char** host, char **port, char** user, char** path, char** query); 55 56 /* Parsing snmp, snmp2 snmp2c etc... */ 57 const char* cfg_parse_scheme (const char *input, enum snmp_version *scheme); 58 59 /* Parse query=xxxx arguments */ 60 const char* cfg_parse_query (char *query, char **name, char **value, char **remainder); 61 62 /* A helper for URL decoding URI values */ 63 const char* cfg_parse_url_decode (char *value); 64 65 #endif /* __CONFIG_PARSER_H__ */ 66