/* ** CONFIG FILE: Simple config file parser ** Copyright (C) 2002 Michael W. Shaffer ** ** 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) 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 (see the file COPYING). If not, write to: ** ** The Free Software Foundation, Inc. ** 59 Temple Place, Suite 330, ** Boston, MA 02111-1307 USA */ #ifndef CONFIG_FILE_H #define CONFIG_FILE_H #include "hash.h" /* ** Config file format is as follows: ** ** - settings are in the form of either: ** ** key = value ** ** or: ** ** key : value ** ** - keys and values may contain only the characters: ** ** - _ . / a-z A-Z 0-9 ** ** - whitespace is optional and is discarded along with anything ** else no explicitly listed above ** - comments start with either ';' or '#' and continue ** until end of line ** - only one 'setting' per line ** ** The parsing routine basically supports either the classic ** unix style conf file with ':' as key/value separator and ** '#' as comment character as well as .ini like syntax with ** '=' as key/value separator and ';' as comment character. I ** don't think that real windows .ini files allow comments on ** the same line as settings, but this routine does. ** ** Here are some short samples of each format: ** ******************************************************************************* ** ** # ** # sample exampled.conf file ** # (classic unix syntax) ** # ** ** host: 127.0.0.1 # peer host to monitor ** interval: 20 # interval in seconds between checks ** tolerance: 3 # number of failed checks to initiate failover ** ******************************************************************************* ** ** ; ** ; sample exampled.conf file ** ; (.ini like systax) ** ; ** ** host = 127.0.0.1 ; peer host to monitor ** interval = 20 ; interval in seconds between checks ** tolerance = 3 ; number of failed checks to initiate failover ** ******************************************************************************* */ int parse_config_file (char *conf_path, struct hash_table *conf); #endif /* CONFIG_FILE_H */