[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
-#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
+baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
[update]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
-#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
+baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=1
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
-#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
+baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=0
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
-#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
+baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
protect=0
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
-#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
+baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
-#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
+baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#include <boost/test/parameterized_test.hpp>
#include <boost/test/unit_test_log.hpp>
-#include "zypp/parser/inifile/ini_file.hpp"
+#include "zypp/base/Logger.h"
+#include "zypp/parser/inifile/iniparser.h"
#include "zypp/Url.h"
#include "zypp/PathInfo.h"
void ini_read_test(const string &dir)
{
+ dictionary *d = iniparser_new((Pathname(dir)+"/1.ini").c_str());
+ if ( d == NULL )
+ ZYPP_THROW(Exception("Failed creating dictionary"));
+
+ int n = iniparser_getnsec(d);
+ BOOST_CHECK_EQUAL( n, 6 );
+ MIL << n << endl;
+
+ for ( int i = 0; i < n; i++ )
+ {
+ MIL << iniparser_getsecname(d, i) << endl;
+ }
}
test_suite*
cout << "inifile_test:"
" path to directory with test data required as parameter. Using " << datadir << endl;
//return (test_suite *)0;
-
}
else
{
)
SET( zypp_parser_inifile_SRCS
- parser/inifile/ini_file.cpp
+ parser/inifile/iniparser.c
)
SET( zypp_parser_inifile_HEADERS
- parser/inifile/ini_file.hpp
+ parser/inifile/iniparser.h
)
INSTALL( FILES
+++ /dev/null
-# Configuration file (really a shell script!)
-name=ini_file
-version=1.0
+++ /dev/null
-//
-// Copyright (c) 2006 Alexis Wilke
-//
-// Boost Software License - Version 1.0 - August 17th, 2003
-//
-// Permission is hereby granted, free of charge, to any person or organization
-// obtaining a copy of the software and accompanying documentation covered by
-// this license (the "Software") to use, reproduce, display, distribute,
-// execute, and transmit the Software, and to prepare derivative works of the
-// Software, and to permit third-parties to whom the Software is furnished to
-// do so, all subject to the following:
-//
-// The copyright notices in the Software and this entire statement, including
-// the above license grant, this restriction and the following disclaimer,
-// must be included in all copies of the Software, in whole or in part, and
-// all derivative works of the Software, unless such copies or derivative
-// works are solely in the form of machine-executable object code generated by
-// a source language processor.
-//
-// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-// Find documentation on the home website:
-//
-// http://boost-extras.sourceforge.net/
-// http://boost-extras.sourceforge.net/ini_file/ini_file.html
-//
-#include "ini_file.hpp"
-#include <iostream>
-
-namespace ini_file
-{
-const param param_map::m_empty("");
-const section section_map::m_empty("");
-
-std::istream& operator >> (std::istream& in, section_map& _section_map)
-{
- boost::shared_ptr<section> sec;
- boost::shared_ptr<param> par;
- std::string result, comment, name;
- char c, quote;
- const char *s, *e;
- int line, i;
-
- line = 0;
- while(!in.eof() && !!in) {
- ++line;
- getline(in, result);
-//std::cout << "Line = <<" << result << ">>" << std::endl;
- if(result.size() == 0) continue;
- switch(c = result[0]) {
- case ';':
- // comment
- if(comment.size() > 0) {
- comment += "\n";
- }
- s = result.c_str() + 1;
- while(isspace(*s)) {
- ++s;
- }
- comment += s;
- break;
-
- case '[':
- // section
- s = result.c_str() + 1;
- e = result.c_str() + result.size();
- while(s < e && isspace(s[0])) {
- ++s;
- }
- while(e > s && isspace(e[-1])) {
- --e;
- }
- if(e[-1] != ']') {
- // name must end with ']' + optional spaces
- throw ini_exceptions::invalid_section_name();
- }
- --e;
- while(e > s && isspace(e[-1])) {
- --e;
- }
- if(e == s) {
- // name mustn't be empty
- throw ini_exceptions::invalid_section_name();
- }
- // valid section name, create section
- sec.reset(new section(result.substr(s - result.c_str(), e - s)));
- sec->set_comment(comment);
- comment.clear();
- _section_map.insert(sec);
- break;
-
- default:
- // make sure the variable starts with a letter or _
- // (there is no spec. for that, but it feels sensical;
- // should that apply to section names?)
- if((c >= 'a' || c <= 'z')
- && (c >= 'A' || c <= 'Z')
- && c == '_') {
- if(isspace(c)) {
- // note the loop does not test 'result[0]'
- // since we just checked it (it's in 'c')
- i = result.size() - 1;
- while(i > 0 && isspace(result[i])) {
- --i;
- }
- if(i == 0) {
- // empty line with just spaces
- continue;
- }
- }
- // unsure what this is
- throw ini_exceptions::invalid_param_name();
- }
- if(!sec) {
- // variables before a section is not valid
- throw ini_exceptions::param_without_section();
- }
- s = result.c_str();
- e = s + 1;
- while(!isspace(*e) && *e != '=') {
- ++e;
- }
- // This case cannot happen since we start with e = s + 1.
- //if(e == s) {
- // // empty variable names are not acceptable
- // throw ini_exceptions::invalid_param_name();
- //}
- par.reset(new param(result.substr(0, e - s)));
- while(isspace(*e)) {
- ++e;
- }
- if(*e != '=') {
- // variable names must be followed by '='
- throw ini_exceptions::invalid_parameter();
- }
- ++e;
- while(isspace(*e)) {
- ++e;
- }
- quote = *e;
- if(quote == '"' || quote == '\'') {
- // quoted value
- ++e;
- s = e;
- while(*e != quote && *e != '\0') {
- // allow escaping, but keep the backslashes
- // TODO: which is wrong!
- if(*e == '\\' && e[1] == quote) {
- ++e;
- }
- ++e;
- }
- if(*e != quote) {
- throw ini_exceptions::invalid_quotation();
- }
- // warning: we ignore what follows
- }
- else {
- s = e;
- e = result.c_str() + result.size();
- while(e > s && isspace(e[-1])) {
- --e;
- }
- }
- par->set_value(result.substr(s - result.c_str(), e - s));
- par->set_comment(comment);
- comment.clear();
- sec->insert(par);
- break;
-
- }
- }
- return in;
-}
-
-namespace details
-{
-std::ostream& operator << (std::ostream& out, const name& _name)
-{
- return out << _name.get_name();
-}
-std::ostream& operator << (std::ostream& out, const comment& _comment)
-{
- // TODO:
- // we would need a filter for comments, but I'm not too sure we can
- // do that (i.e. add a filter, write the comment, remove the filter)
- bool new_line = true;
- std::string::const_iterator i;
- std::string::const_iterator end = _comment.get_comment().end();
- for(i = _comment.get_comment().begin(); i != end; ++i) {
- if(*i == '\r' || *i == '\n') {
- out << *i;
- new_line = true;
- }
- else {
- if(new_line) {
- out << "; ";
- }
- new_line = false;
- out << *i;
- }
- }
- if(!new_line) {
- out << std::endl;
- }
- return out;
-}
-}
-
-std::ostream& operator << (std::ostream& out, const param& _param)
-{
- if(_param.get_name().size() == 0) {
- if(_param.get_value().size() == 0) {
- return out;
- }
- throw ini_exceptions::param_name_missing();
- }
-
- // output <comment> and then '<name>='
- out << static_cast<const details::comment&>(_param)
- << static_cast<const details::name&>(_param)
- << '=';
-
- // output <value>, check whether we need quotation
- const std::string& value = _param.get_value();
- const char *s = value.c_str();
- const char *e = s + value.size();
- if(*s == '"' || *s == '\'' || isspace(*s) || (e > s && isspace(e[-1]))) {
- // need quotation to not lose any data
- char quote = '\0';
- while(*s != '\0') {
- if(*s == '\'') {
- quote = '"';
- break;
- }
- if(*s == '"') {
- quote = '\'';
- break;
- }
- ++s;
- }
- s = value.c_str();
- out << quote;
- while(*s != '\0') {
- if(*s == quote) {
- out << "\\";
- }
- out << *s;
- ++s;
- }
- out << quote;
- }
- else {
- // no quotation necessary
- out << value;
- }
-
- out << std::endl;
-}
-
-
-std::ostream& operator << (std::ostream& out, const param_map& _param_map)
-{
- param_map::const_iterator i = _param_map.begin();
- param_map::const_iterator end = _param_map.end();
- while(i != end) {
- out << *(*i).second;
- ++i;
- }
- return out;
-}
-
-std::ostream& operator << (std::ostream& out, const section& _section)
-{
- if(_section.get_name().size() == 0) {
- if(_section.size() == 0) {
- return out;
- }
- throw ini_exceptions::section_name_missing();
- }
-
- return out
- << static_cast<const details::comment&>(_section)
- << '[' << static_cast<const details::name&>(_section) << ']' << std::endl
- << static_cast<const param_map&>(_section);
-}
-std::ostream& operator << (std::ostream& out, const section_map& _section_map)
-{
- section_map::const_iterator i = _section_map.begin();
- section_map::const_iterator end = _section_map.end();
- while(i != end) {
- out << *(*i).second;
- out << std::endl;
- ++i;
- }
- return out;
-}
-
-
-
-
-} // namespace ini_file
-// vim: ts=4
+++ /dev/null
-//
-// Copyright (c) 2006 Alexis Wilke
-//
-// Boost Software License - Version 1.0 - August 17th, 2003
-//
-// Permission is hereby granted, free of charge, to any person or organization
-// obtaining a copy of the software and accompanying documentation covered by
-// this license (the "Software") to use, reproduce, display, distribute,
-// execute, and transmit the Software, and to prepare derivative works of the
-// Software, and to permit third-parties to whom the Software is furnished to
-// do so, all subject to the following:
-//
-// The copyright notices in the Software and this entire statement, including
-// the above license grant, this restriction and the following disclaimer,
-// must be included in all copies of the Software, in whole or in part, and
-// all derivative works of the Software, unless such copies or derivative
-// works are solely in the form of machine-executable object code generated by
-// a source language processor.
-//
-// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-// Find documentation on the home website:
-//
-// http://boost-extras.sourceforge.net/
-// http://boost-extras.sourceforge.net/ini_file/ini_file.html
-//
-#ifndef BOOST_EXTRAS_INI_FILE
-#define BOOST_EXTRAS_INI_FILE 1
-
-#include <boost/shared_ptr.hpp>
-#include <exception>
-#include <string>
-#include <map>
-#include <iostream>
-
-namespace ini_file
-{
-
-
-namespace ini_exceptions
-{
- class ini_file_exception : std::exception {};
- class section_name_missing : ini_file_exception {};
- class invalid_section_name : ini_file_exception {};
- class param_name_missing : ini_file_exception {};
- class invalid_param_name : ini_file_exception {};
- class invalid_parameter : ini_file_exception {};
- class param_without_section : ini_file_exception {};
- class invalid_quotation : ini_file_exception {};
-} // namespace ini_exceptions
-
-
-namespace details
-{
-struct name
-{
- name(const std::string& _name) : m_name(_name) {}
- virtual ~name() {}
- //void set_name(const std::string& _name) { m_name = _name; }
- const std::string& get_name() const { return m_name; }
-
-private:
- const std::string m_name;
-};
-extern std::ostream& operator << (std::ostream& out, const name& _name);
-struct comment
-{
- virtual ~comment() {}
- void set_comment(const std::string& _comment) { m_comment = _comment; }
- const std::string& get_comment() const { return m_comment; }
-
-private:
- std::string m_comment;
-};
-extern std::ostream& operator << (std::ostream& out, const comment& _comment);
-} // namespace details
-
-
-struct param : details::name, details::comment
-{
- param(const std::string& _name) : details::name(_name) {}
- void set_value(const std::string& _value) { m_value = _value; }
- const std::string& get_value() const { return m_value; }
-
- param& operator = (const std::string& _value) { set_value(_value); return *this; }
- operator const std::string& () const { return m_value; }
-private:
- std::string m_value;
-};
-namespace details
-{
-typedef std::map<std::string, boost::shared_ptr<param> > param_map_t;
-}
-struct param_map : details::param_map_t
-{
- void insert(boost::shared_ptr<param> _p)
- {
- if(_p) {
- details::param_map_t::insert(details::param_map_t::value_type(_p->get_name(), _p));
- }
- }
- param& operator [] (const std::string& _name)
- {
- details::param_map_t::iterator i = details::param_map_t::find(_name);
- if(i == end()) {
- boost::shared_ptr<param> p(new param(_name));
- insert(p);
- return *p;
- }
- return *i->second;
- }
- const param& operator [] (const std::string& _name) const
- {
- details::param_map_t::const_iterator i = details::param_map_t::find(_name);
- if(i == end()) return m_empty;
- return *i->second;
- }
-
-private:
- static const param m_empty;
-};
-
-
-
-struct section : details::name, details::comment, param_map
-{
- section(const std::string& _name) : details::name(_name) {}
-};
-namespace details
-{
-typedef std::map<std::string, boost::shared_ptr<section> > section_map_t;
-}
-struct section_map : details::section_map_t
-{
- void insert(boost::shared_ptr<section> _s)
- {
- if(_s) {
- details::section_map_t::insert(details::section_map_t::value_type(_s->get_name(), _s));
- }
- }
- const section& operator [] (const std::string& _name) const
- {
- details::section_map_t::const_iterator i = details::section_map_t::find(_name);
- if(i == end()) return m_empty;
- return *i->second;
- }
- section& operator [] (const std::string& _name)
- {
- details::section_map_t::iterator i = details::section_map_t::find(_name);
- if(i == end()) {
- boost::shared_ptr<section> s(new section(_name));
- insert(s);
- return *s;
- }
- return *i->second;
- }
-private:
- static const section m_empty;
-};
-
-
-
-
-
-extern std::istream& operator >> (std::istream& in, section_map& _section_map);
-
-extern std::ostream& operator << (std::ostream& out, const param& _param);
-extern std::ostream& operator << (std::ostream& out, const section& _section);
-
-extern std::ostream& operator << (std::ostream& out, const param_map& _param_map);
-extern std::ostream& operator << (std::ostream& out, const section_map& _section_map);
-
-
-
-} // namespace ini_file
-
-
-#endif // #ifdef BOOST_EXTRAS_INI_FILE
-// vim: ts=4
+++ /dev/null
-<html>
-<head>
- <title>ini_file</title>
- <style>
- body {
- margin: 0px;
- }
- .code {
- font-family: monospace;
- background-color: #f8f8f8;
- border: 1px solid #c0c0c0;
- margin: 5px;
- }
- .fig {
- color: grey;
- font-style: italic;
- font-size: 80%;
- }
- </style>
-</head>
-<body>
- <div style="margin: 15px;">
- <h1>ini_file helpers</h1>
-
- <p>
- Go to the <a href="http://boost-extras.sourceforge.net/documentation.html">Boost-Extra Home Page</a>.
- </p>
-
- <h2>Summary</h2>
-
- <blockquote>
- <ul>
- <li><a href="#introduction">Introduction</a></li>
- <li><a href="#usage">Usage</a></li>
- <li><a href="#thread">Thread Consideration</a></li>
- <li><a href="#advantages">Advantages of these Classes</a></li>
- <li><a href="#synopsis">Synopsis</a></li>
- <li><a href="#members">Members</a></li>
- <ul>
- <li><a href="#ini_exceptions">ini_exceptions</a></li>
- <li><a href="#param">param</a></li>
- <li><a href="#param_map">param_map</a></li>
- <li><a href="#section">section</a></li>
- <li><a href="#section_map">section_map</a></li>
- <li><a href="#helpers">Helper Functions</a></li>
- </ul>
- <li><a href="ini_file_header.html">ini_file.hpp</a></li>
- </ul>
- </blockquote>
-
-
- <h2><a name="introduction">Introduction</a></h2>
- <p>
- The <b>ini_file</b> classes are used to read and write INI files.
- The format of an INI file is defined as follow:
- </p>
- <ul>
- <li>Files are composed of comments, sections and parameters</li>
- <li>Comments start with a semi-colon (;) at the very beginning
- of a line</li>
- <li>Sections names are defined between square brackets ([ and ]) and
- start at the very beginning of a line</li>
- <li>Parameters are defined as a name, followed by an equal sign
- followed by a value. There can be spaces before and after the
- equal sign. Spaces at the end of a value are also trimmed.</li>
- <li>Empty lines are legal and skipped silently.</li>
- </ul>
- <p>
- There is an example:
- </p>
-<pre class="code">
-
- <font color="blue">; INI file sample</font>
- <font color="purple">[section1]</font>
- <font color="green">var1=value1</font>
- <font color="green">var2 = value2</font>
-
- <font color="purple">[section2]</font>
- <font color="green">var3= value3</font>
- <font color="green">var4 =value4</font>
-
-</pre>
-<center><span class="fig">Example 1. file format definition</span></center>
-
-
- <h2><a name="usage">Usage</a></h2>
- <p>
- An INI file is represented by a set of sections and one set of
- parameters per section. Sets are defined as maps. Sections and
- parameters have a name, a comment and parameters also have a
- value. All of these objects are represented below:
- </p>
- <p>
- <table align="center"><tbody><tr><td align="center">
- <div style="border: 1px black solid; padding: 10px; text-align: center;">
- <img src="ini_file.png" width="509" height="265"/>
- </div>
- <span class="fig">Fig 1. Representation of the ini_file classes.</span>
- </td></tr></tbody></table>
- </p>
-
- <p>
- So creating and saving an INI file comes down to:
- </p>
-
- <ul>
- <li>instantiating a <b>section_map</b> object;</li>
- <li>adding parameters in sections;</li>
- <li>saving the INI file with the << operator.</li>
- </ul>
-
-<pre class="code">
-
- <font color="blue">// create an ini file and save it to std::cout</font>
- int main(int argc, char *argv[])
- {
- ini_file::section_map ini;
-
- ini["section1"]["var1"] = "value of var1";
- ini["section1"]["var2"] = "value of var2";
- ini["section2"]["var3"] = "value of var3";
- ini["section2"]["var4"] = "value of var4";
-
- std::cout << ini;
- };
-
-</pre>
-<center><span class="fig">Example 2. create an INI file</span></center>
-
- <p>
- In a similar fashion, it is possible to read and use an INI file by:
- </p>
-
- <ul>
- <li>instantiating a <b>section_map</b> object;</li>
- <li>reading an INI file with the >> operator;</li>
- <li>getting the parameters value.</li>
- </ul>
-
-<pre class="code">
-
- <font color="blue">// read an ini file from a stream and print out the content</font>
- int main(int argc, char *argv[])
- {
- ini_file::section_map ini;
-
- {
- // first we create a file that we can then read
- std::fstream output;
- output.open("test_file.ini", std::fstream::out);
- output << "; This is an auto-generated test file." << std::endl;
- output << "[section1]" << std::endl;
- output << "var1=This is variable ONE" << std::endl;
- output << "var2=This is variable TWO" << std::endl;
- output << "[section2]" << std::endl;
- output << "var3 = \" This is \\\"variable\\\" THREE \" " << std::endl;
- output << "; Comment on variable 4" << std::endl;
- output << "var4=This is variable FOUR" << std::endl;
- } // file closes
-
- // now try to read it and print out the content
- std::fstream input;
- input.open("test_file.ini", std::fstream::in);
-
- input >> ini;
-
- std::cout << "section1 -> " << ini["section1"];
- std::cout << "section1.var1 -> " << ini["section1"]["var1"];
- std::cout << "section1.var2 -> " << ini["section1"]["var2"];
- std::cout << "section2 -> " << ini["section2"];
- std::cout << "section2.var3 -> " << ini["section2"]["var3"];
- std::cout << "section2.var4 -> " << ini["section2"]["var4"];
- };
-
-</pre>
-<center><span class="fig">Example 3. reading an INI file and print the data</span></center>
-
-
-
-
- <h2><a name="thread">Thread</a></h2>
- <p>
- These classes are not thread safe. However, if read once from disk and
- then used only as constant objects, it will work even if accessed between
- multiple threads (assuming that the boost::shared_ptr<> is thread
- safe.)
- </p>
-
-
-
- <h2><a name="advantages">Advantages of these Classes</a></h2>
-
- <p>
- Ease of use to read and write INI files including comments
- (comments aren't getting lost.)
- </p>
-
-
-
-
- <h2><a name="synopsis">Synopsis</a></h2>
-
-<blockquote>
-<pre class="code">
-
- namespace ini_file
- {
- namespace ini_exceptions
- {
- class ini_file_exception : std::exception {};
- class section_name_missing : ini_file_exception {};
- class invalid_section_name : ini_file_exception {};
- class param_name_missing : ini_file_exception {};
- class invalid_param_name : ini_file_exception {};
- class invalid_parameter : ini_file_exception {};
- class param_without_section : ini_file_exception {};
- class invalid_quotation : ini_file_exception {};
- } // namespace ini_exceptions
-
- struct param : ...
- {
- param(const std::string& _name);
- const std::string& get_name() const;
- void set_comment(const std::string& _comment);
- const std::string& get_comment() const;
- void set_value(const std::string& _value);
- const std::string& get_value() const;
- param& operator = (const std::string& _value);
- operator const std::string& () const;
- };
-
- struct param_map : ...
- {
- void insert(boost::shared_ptr<param> _p);
- param& operator [] (const std::string& _name);
- const param& operator [] (const std::string& _name) const;
- };
-
- struct section : ...
- {
- section(const std::string& _name);
- const std::string& get_name() const;
- void set_comment(const std::string& _comment);
- const std::string& get_comment() const;
- void insert(boost::shared_ptr<param> _p);
- param& operator [] (const std::string& _name);
- const param& operator [] (const std::string& _name) const;
- };
-
- struct section_map : ...
- {
- void insert(boost::shared_ptr<section> _p);
- section& operator [] (const std::string& _name);
- const section& operator [] (const std::string& _name) const;
- };
-
- extern std::istream& operator >> (std::istream& in, section_map& _section_map);
-
- extern std::ostream& operator << (std::ostream& out, const param& _param);
- extern std::ostream& operator << (std::ostream& out, const section& _section);
-
- extern std::ostream& operator << (std::ostream& out, const param_map& _param_map);
- extern std::ostream& operator << (std::ostream& out, const section_map& _section_map);
- }
-
-</pre>
-</blockquote>
-
-
-
- <h2><a name="members">Members</a></h2>
-
- <h3> <a name="ini_exceptions">ini_exceptions</a></h3>
-
- <ul>
- <li><b>ini_file_exception</b></li>
- <p>
- All the ini_file exceptions derive from <b>ini_file_exception</b>.
- In order to catch all the exceptions at once, catch this exception.
- </p>
- <li><b>section_name_missing</b></li>
- <p>
- This exception is thrown when a section with no name is being saved.
- </p>
- <li><b>invalid_section_name</b></li>
- <p>
- This exception is thrown when the parser reading a file finds a line
- which starts with '[' and either does not finish with ']' or defines
- an empty name (only spaces or just '[]').
- </p>
- <li><b>param_name_missing</b></li>
- <p>
- This exception is thrown when a parameter with no name is being saved.
- </p>
- <li><b>invalid_param_name</b></li>
- <p>
- This exception is thrown when the parser finds a parameter name which
- does not start with one of these characters: [a-zA-Z_].
- </p>
- <li><b>invalid_parameter</b></li>
- <p>
- This exception is thrown when parsing a file and the variable name is
- not followed by an equal sign and a value.
- </p>
- <li><b>param_without_section</b></li>
- <p>
- This exception is thrown when parsing a file and a variable is found
- before a section.
- </p>
- <li><b>invalid_quotation</b></li>
- <p>
- This exception is thrown when parsing a quoted parameter which has no
- closing quotation.
- </p>
- </ul>
-
-
-
-
-
-
- <h3> <a name="param">param</a></h3>
-
- <blockquote>
- <pre>param(const std::string& _name);</pre>
- <blockquote>
- <p>
- <b>Preconditions:</b> the parameter name is not empty; though this is
- currently not enforced since we need a default parameter with an empty
- name (see the [] operators.)
- </p>
- <p>
- <b>Effects:</b> create a parameter named <code>_name</code>.
- </p>
- <p>
- <b>Postconditions:</b> the parameter name cannot be changed.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>const std::string& get_name() const;</pre>
- <blockquote>
- <p>
- <b>Postconditions:</b> the returned string cannot be modified.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>void set_comment(const std::string& comment);</pre>
- <blockquote>
- <p>
- <b>Effects:</b> assigns a comment to that object. Comments
- are written right before parameters. Comments read right
- before a paramater are assigned to that parameter.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>const std::string& get_comment() const;</pre>
- <blockquote>
- <p>
- <b>Postconditions:</b> the returned string cannot be modified; use
- <b>set_comment()</b> to modify a comment.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>void set_value(const std::string& _value);
-param& operator = (const std::string& _value)</pre>
- <blockquote>
- <p>
- <b>Effects:</b> assigns a new value to the parameter. Anything is
- valid except a new line character and a null character. If the
- parameter value starts or ends with spaces or quotes, the value
- will be saved quoted.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>const std::string& get_value() const;
-operator const std::string& () const;</pre>
- <blockquote>
- <p>
- <b>Effects:</b> retrieve the current value of the parameter.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
-
-
-
- <h3> <a name="param_map">param_map</a></h3>
-
- <blockquote>
- <pre>void insert(boost::shared_ptr<param> _p);</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> if the pointer is null, nothing happens and the
- function returns right away.
- </p>
- <p>
- <b>Effects:</b> add the specified parameter in the map of parameters.
- The use of a map makes it faster to retrieve parameters. However, this
- means you lose the possible ordering from input files.
- </p>
- <p>
- <b>Throws:</b> memory allocation exceptions
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>param& operator [] (const std::string& _name);
-const param& operator [] (const std::string& _name) const;</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> if a parameter with the specified <code>_name</code>
- does not exist:
- <ul>
- <li><i>Non-constant parameter map</i></li>
- <p>
- When the non-constant operator is used, a new parameter
- is created if none already exist with that <code>_name</code>.
- </p>
- <p>
- <li><i>Constant parameter map</i></li>
- <p>
- When the constant operator is used, it returns an empty
- parameter which must not be modified.
- That empty parameter is not part of the map.
- </p>
- </ul>
- </p>
- <p>
- <b>Effects:</b> return the empty parameter, an existing parameter or
- a new parameter with the specified <code>_name</code>.
- </p>
- <p>
- <b>Throws:</b> memory allocation exceptions
- </p>
- </blockquote>
- </blockquote>
-
-
-
-
-
-
- <h3> <a name="section">section</a></h3>
-
- <blockquote>
- <pre>section(const std::string& _name);</pre>
- <blockquote>
- <p>
- <b>Preconditions:</b> the parameter name is not empty; though this is
- currently not enforced since we need a default parameter with an empty
- name (see the [] operators.)
- </p>
- <p>
- <b>Effects:</b> create a section named <code>_name</code>.
- </p>
- <p>
- <b>Postconditions:</b> the section name cannot be changed.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>const std::string& get_name() const;</pre>
- <blockquote>
- <p>
- <b>Postconditions:</b> the returned string cannot be modified.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>void set_comment(const std::string& comment);</pre>
- <blockquote>
- <p>
- <b>Effects:</b> assigns a comment to that object. Comments
- are written right before sections. Comments read right
- before a section are assigned to that section. Comments
- read right after a section are assigned the the first
- parameter. If there is no parameter, it is assigned to
- the next section. If there is no other section or parameter,
- it is lost.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>const std::string& get_comment() const;</pre>
- <blockquote>
- <p>
- <b>Postconditions:</b> the returned string cannot be modified; use
- <b>set_comment()</b> to modify a comment.
- </p>
- <p>
- <b>Throws:</b> nothing
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>void insert(boost::shared_ptr<param> _p);</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> if the pointer is null, nothing happens and the
- function returns right away.
- </p>
- <p>
- <b>Effects:</b> add the specified parameter in the map of parameters.
- The use of a map makes it faster to retrieve parameters. However, this
- means you lose the possible ordering from input files.
- </p>
- <p>
- <b>Throws:</b> memory allocation exceptions
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>param& operator [] (const std::string& _name);
-const param& operator [] (const std::string& _name) const;</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> if a parameter with the specified <code>_name</code>
- does not exist:
- <ul>
- <li><i>Non-constant parameter map</i></li>
- <p>
- When the non-constant operator is used, a new parameter
- is created if none already exist with that <code>_name</code>.
- </p>
- <p>
- <li><i>Constant parameter map</i></li>
- <p>
- When the constant operator is used, it returns an empty
- parameter which must not be modified.
- That empty parameter is not part of the map.
- </p>
- </ul>
- </p>
- <p>
- <b>Effects:</b> return the empty parameter, an existing parameter or
- a new parameter with the specified <code>_name</code>.
- </p>
- <p>
- <b>Throws:</b> memory allocation exceptions
- </p>
- </blockquote>
- </blockquote>
-
-
-
-
-
- <h3> <a name="section_map">section_map</a></h3>
-
- <blockquote>
- <pre>void insert(boost::shared_ptr<section> _s);</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> if the pointer is null, nothing happens and the
- function returns right away.
- </p>
- <p>
- <b>Effects:</b> add the specified section in the map of sections.
- The use of a map makes it faster to retrieve sections. However, this
- means you lose the possible ordering from input files.
- </p>
- <p>
- <b>Throws:</b> memory allocation exceptions
- </p>
- </blockquote>
- </blockquote>
-
- <blockquote>
- <pre>section& operator [] (const std::string& _name);
-const section& operator [] (const std::string& _name) const;</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> if a section with the specified <code>_name</code>
- does not exist:
- <ul>
- <li><i>Non-constant section map</i></li>
- <p>
- When the non-constant operator is used, a new section
- is created if none already exist with that <code>_name</code>.
- </p>
- <p>
- <li><i>Constant section map</i></li>
- <p>
- When the constant operator is used, it returns an empty
- section which must not be modified.
- That empty section is not part of the map.
- </p>
- </ul>
- </p>
- <p>
- <b>Effects:</b> return the empty section, an existing section or
- a new section with the specified <code>_name</code>.
- </p>
- <p>
- <b>Throws:</b> memory allocation exceptions
- </p>
- </blockquote>
- </blockquote>
-
-
-
- <h3> <a name="helpers">Helper functions</a></h3>
-
- <blockquote>
- <pre>extern std::istream& operator >> (std::istream& in, section_map& _section_map);
-
-extern std::ostream& operator << (std::ostream& out, const param& _param);
-extern std::ostream& operator << (std::ostream& out, const section& _section);
-
-extern std::ostream& operator << (std::ostream& out, const param_map& _param_map);
-extern std::ostream& operator << (std::ostream& out, const section_map& _section_map);
-</pre>
- <blockquote>
- <p>
- <b>Precondition:</b> to write a parameter, section or a map thereof, all the
- parameters and sections must have a valid name (i.e. not empty.) A section
- can be empty (have no parameters.)
- </p>
- <p>
- <b>Effects:</b> the >> oparator appends the content of the input stream
- to the specified <code>_section_map</code>. If the input includes sections
- and parameters which already exist in the <code>_section_map</code>, they
- will be overwritten (i.e. thus you can define defaults before to use the
- >> operator.) The << operators print out the specified parameter. In
- all cases, the output ends with a newline. A section ends with an empty
- line. To save a section map to an init file, use the << operator
- accepting a <code>_section_map</code> reference.
- </p>
- <p>
- <b>Throws:</b> the output operators (<<) can throw the
- <b>ini_exceptions::param_name_missing</b> or
- <b>ini_exceptions::section_name_missing</b> exceptions.
- The input operator (>>) can throw many different exceptions
- when the input file is invalid:
- <ul>
- <li><b>ini_exceptions::invalid_section_name</b></li>
- <li><b>ini_exceptions::invalid_param_name</b></li>
- <li><b>ini_exceptions::param_without_section</b></li>
- <li><b>ini_exceptions::invalid_parameter</b></li>
- <li><b>ini_exceptions::invalid_quotation</b></li>
- </ul>
- </p>
- </blockquote>
- </blockquote>
-
-
- </div>
-
- <hr/>
-
- <p style="font-size: 75%; text-align: center;">
- <u>Copyright (c) 2006 Alexis Wilke</u><br/>
- <br/>
- <i>Permission to copy, use, modify, sell and distribute this document is granted provided<br/>
- this copyright notice appears in all copies. This document is provided "as is" without<br/>
- express or implied warranty, and with no claim as to its suitability for any purpose.</i>
- </p>
-</body>
-<!--
- vim: ts=2
--->
-</html>
+++ /dev/null
-//
-// Copyright (c) 2006 Alexis Wilke
-//
-// Boost Software License - Version 1.0 - August 17th, 2003
-//
-// Permission is hereby granted, free of charge, to any person or organization
-// obtaining a copy of the software and accompanying documentation covered by
-// this license (the "Software") to use, reproduce, display, distribute,
-// execute, and transmit the Software, and to prepare derivative works of the
-// Software, and to permit third-parties to whom the Software is furnished to
-// do so, all subject to the following:
-//
-// The copyright notices in the Software and this entire statement, including
-// the above license grant, this restriction and the following disclaimer,
-// must be included in all copies of the Software, in whole or in part, and
-// all derivative works of the Software, unless such copies or derivative
-// works are solely in the form of machine-executable object code generated by
-// a source language processor.
-//
-// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-// DEALINGS IN THE SOFTWARE.
-//
-// Find documentation on the home website:
-//
-// http://boost-extras.sourceforge.net/
-// http://boost-extras.sourceforge.net/ini_file/ini_file.html
-//
-#include <ini_file.hpp>
-#include <iostream>
-#include <fstream>
-
-// select sample with -DSAMPLE=<1, 2 or 3> on the command line
-
-
-int main(int argc, char *argv[])
-{
-#if SAMPLE == 1
- ini_file::section_map ini;
-
- ini["section1"]["var1"] = "value of var1";
- ini["section1"]["var2"] = "value of var2";
- ini["section2"]["var3"] = "value of var3";
- ini["section2"]["var4"] = "value of var4";
-
- ini["section1"].set_comment("This is section1 comment");
- ini["section2"].set_comment("This is section2 comment");
- ini["section2"]["var4"].set_comment("This is var4 comment");
-
- std::cout << ini;
-#elif SAMPLE == 2
- ini_file::section_map ini;
-
- {
- // first we create a file that we can then read
- std::fstream output;
- output.open("test_file.ini", std::fstream::out);
- output << "; This is an auto-generated test file." << std::endl;
- output << "[section1]" << std::endl;
- output << "var1=This is variable ONE" << std::endl;
- output << "var2=This is variable TWO" << std::endl;
- output << "[section2]" << std::endl;
- output << "var3 = \" This is \\\"variable\\\" THREE \" " << std::endl;
- output << "; Comment on variable 4" << std::endl;
- output << "var4=This is variable FOUR" << std::endl;
- } // file closes
-
- // now try to read it and print out the content
- std::fstream input;
- input.open("test_file.ini", std::fstream::in);
-
- input >> ini;
-
- std::cout << "section1 -> " << ini["section1"];
- std::cout << "section1.var1 -> " << ini["section1"]["var1"];
- std::cout << "section1.var2 -> " << ini["section1"]["var2"];
- std::cout << "section2 -> " << ini["section2"];
- std::cout << "section2.var3 -> " << ini["section2"]["var3"];
- std::cout << "section2.var4 -> " << ini["section2"]["var4"];
-#elif SAMPLE == 3
- {
- ini_file::section_map s;
-
- boost::shared_ptr<ini_file::section> sec(new ini_file::section("section1"));
- sec->set_comment("this is a long comment\nwith a new-line");
-
- boost::shared_ptr<ini_file::param> p(new ini_file::param("var1"));
- p->set_value("this is the value of var1");
- sec->insert(p);
-
- s.insert(sec);
-
- sec.reset(new ini_file::section("section2"));
- sec->set_comment("this is yet another long comment\nwith a new-line!!!");
-
- p.reset(new ini_file::param("var2"));
- p->set_value("this is the value of var2");
- p->set_comment("and v2 has a comment too!\n");
- sec->insert(p);
-
- s.insert(sec);
-
- s["section3"]["var3"].set_value("this is variable number three");
- s["section3"]["var4"] = "another variable in section3";
-
-
- // test reading parameters values
- std::cout << "section1 -> " << s["section1"];
- std::cout << "section1.var1 -> " << s["section1"]["var1"];
- std::cout << "section2.var2 -> " << s["section2"]["var2"];
- std::cout << "unknown_section = " << const_cast<const ini_file::section_map&>(s)["unknown_section"] << std::endl;
-
- std::string what = s["section3"]["var4"];
- std::cout << "extracted content of section3.var4 -> " << what << std::endl;
-
- std::cout << "*********** Output ini file (std::cout << /ini_file::section_map/) ******" << std::endl;
- std::cout << s;
- std::cout << "*****************" << std::endl;
- }
-#else
- std::cerr << "error: no -DSAMPLE=<1,2 or 3> was specified when compiling" << std::endl;
-#endif
-
- return 0;
-}
-
-
-// vim: ts=4
--- /dev/null
+/*
+ Based upon libiniparser, by Nicolas Devillard
+ Hacked into 1 file (m-iniparser) by Freek/2005
+ Original terms following:
+
+ -- -
+
+ Copyright (c) 2000 by Nicolas Devillard (ndevilla AT free DOT fr).
+
+ Written by Nicolas Devillard. Not derived from licensed software.
+
+ Permission is granted to anyone to use this software for any
+ purpose on any computer system, and to redistribute it freely,
+ subject to the following restrictions:
+
+ 1. The author is not responsible for the consequences of use of
+ this software, no matter how awful, even if they arise
+ from defects in it.
+
+ 2. The origin of this software must not be misrepresented, either
+ by explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+
+ 4. This notice may not be removed or altered.
+
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "iniparser.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* strlib.c following */
+
+#define ASCIILINESZ 1024
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Convert a string to lowercase.
+ @param s String to convert.
+ @return ptr to statically allocated string.
+
+ This function returns a pointer to a statically allocated string
+ containing a lowercased version of the input string. Do not free
+ or modify the returned string! Since the returned string is statically
+ allocated, it will be modified at each function call (not re-entrant).
+ */
+/*--------------------------------------------------------------------------*/
+
+static char * strlwc(char * s)
+{
+ static char l[ASCIILINESZ+1];
+ int i ;
+
+ if (s==NULL) return NULL ;
+ memset(l, 0, ASCIILINESZ+1);
+ i=0 ;
+ while (s[i] && i<ASCIILINESZ) {
+ l[i] = (char)tolower((int)s[i]);
+ i++ ;
+ }
+ l[ASCIILINESZ]=(char)0;
+ return l ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Convert a string to uppercase.
+ @param s String to convert.
+ @return ptr to statically allocated string.
+
+ This function returns a pointer to a statically allocated string
+ containing an uppercased version of the input string. Do not free
+ or modify the returned string! Since the returned string is statically
+ allocated, it will be modified at each function call (not re-entrant).
+ */
+/*--------------------------------------------------------------------------*/
+
+static char * strupc(char * s)
+{
+ static char l[ASCIILINESZ+1];
+ int i ;
+
+ if (s==NULL) return NULL ;
+ memset(l, 0, ASCIILINESZ+1);
+ i=0 ;
+ while (s[i] && i<ASCIILINESZ) {
+ l[i] = (char)toupper((int)s[i]);
+ i++ ;
+ }
+ l[ASCIILINESZ]=(char)0;
+ return l ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Skip blanks until the first non-blank character.
+ @param s String to parse.
+ @return Pointer to char inside given string.
+
+ This function returns a pointer to the first non-blank character in the
+ given string.
+ */
+/*--------------------------------------------------------------------------*/
+
+static char * strskp(char * s)
+{
+ char * skip = s;
+ if (s==NULL) return NULL ;
+ while (isspace((int)*skip) && *skip) skip++;
+ return skip ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Remove blanks at the end of a string.
+ @param s String to parse.
+ @return ptr to statically allocated string.
+
+ This function returns a pointer to a statically allocated string,
+ which is identical to the input string, except that all blank
+ characters at the end of the string have been removed.
+ Do not free or modify the returned string! Since the returned string
+ is statically allocated, it will be modified at each function call
+ (not re-entrant).
+ */
+/*--------------------------------------------------------------------------*/
+
+static char * strcrop(char * s)
+{
+ static char l[ASCIILINESZ+1];
+ char * last ;
+
+ if (s==NULL) return NULL ;
+ memset(l, 0, ASCIILINESZ+1);
+ strcpy(l, s);
+ last = l + strlen(l);
+ while (last > l) {
+ if (!isspace((int)*(last-1)))
+ break ;
+ last -- ;
+ }
+ *last = (char)0;
+ return l ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Remove blanks at the beginning and the end of a string.
+ @param s String to parse.
+ @return ptr to statically allocated string.
+
+ This function returns a pointer to a statically allocated string,
+ which is identical to the input string, except that all blank
+ characters at the end and the beg. of the string have been removed.
+ Do not free or modify the returned string! Since the returned string
+ is statically allocated, it will be modified at each function call
+ (not re-entrant).
+ */
+/*--------------------------------------------------------------------------*/
+static char * strstrip(char * s)
+{
+ static char l[ASCIILINESZ+1];
+ char * last ;
+
+ if (s==NULL) return NULL ;
+
+ while (isspace((int)*s) && *s) s++;
+
+ memset(l, 0, ASCIILINESZ+1);
+ strcpy(l, s);
+ last = l + strlen(l);
+ while (last > l) {
+ if (!isspace((int)*(last-1)))
+ break ;
+ last -- ;
+ }
+ *last = (char)0;
+
+ return (char*)l ;
+}
+
+
+/* dictionary.c.c following */
+/** Maximum value size for integers and doubles. */
+#define MAXVALSZ 1024
+
+/** Minimal allocated number of entries in a dictionary */
+#define DICTMINSZ 128
+
+/** Invalid key token */
+#define DICT_INVALID_KEY ((char*)-1)
+
+/*
+ Doubles the allocated size associated to a pointer
+ 'size' is the current allocated size.
+ */
+static void * mem_double(void * ptr, int size)
+{
+ void *newptr;
+
+ newptr = calloc(2*size, 1);
+ memcpy(newptr, ptr, size);
+ free(ptr);
+ return newptr ;
+}
+
+
+/*---------------------------------------------------------------------------
+ Function codes
+ ---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Compute the hash key for a string.
+ @param key Character string to use for key.
+ @return 1 unsigned int on at least 32 bits.
+
+ This hash function has been taken from an Article in Dr Dobbs Journal.
+ This is normally a collision-free function, distributing keys evenly.
+ The key is stored anyway in the struct so that collision can be avoided
+ by comparing the key itself in last resort.
+ */
+/*--------------------------------------------------------------------------*/
+
+static unsigned dictionary_hash(char * key)
+{
+ int len ;
+ unsigned hash ;
+ int i ;
+
+ len = strlen(key);
+ for (hash=0, i=0 ; i<len ; i++) {
+ hash += (unsigned)key[i] ;
+ hash += (hash<<10);
+ hash ^= (hash>>6) ;
+ }
+ hash += (hash <<3);
+ hash ^= (hash >>11);
+ hash += (hash <<15);
+ return hash ;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Create a new dictionary object.
+ @param size Optional initial size of the dictionary.
+ @return 1 newly allocated dictionary objet.
+
+ This function allocates a new dictionary object of given size and returns
+ it. If you do not know in advance (roughly) the number of entries in the
+ dictionary, give size=0.
+ */
+/*--------------------------------------------------------------------------*/
+
+static dictionary * dictionary_new(int size)
+{
+ dictionary *d ;
+
+ /* If no size was specified, allocate space for DICTMINSZ */
+ if (size<DICTMINSZ) size=DICTMINSZ ;
+
+ d = (dictionary *)calloc(1, sizeof(dictionary));
+ d->size = size ;
+ d->val = (char **)calloc(size, sizeof(char*));
+ d->key = (char **)calloc(size, sizeof(char*));
+ d->hash = (unsigned int *)calloc(size, sizeof(unsigned));
+
+ return d;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete a dictionary object
+ @param d dictionary object to deallocate.
+ @return void
+
+ Deallocate a dictionary object and all memory associated to it.
+ */
+/*--------------------------------------------------------------------------*/
+
+static void dictionary_del(dictionary * d)
+{
+ int i ;
+
+ if (d==NULL) return ;
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]!=NULL)
+ free(d->key[i]);
+ if (d->val[i]!=NULL)
+ free(d->val[i]);
+ }
+ free(d->val);
+ free(d->key);
+ free(d->hash);
+ free(d);
+
+ return;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get a value from a dictionary.
+ @param d dictionary object to search.
+ @param key Key to look for in the dictionary.
+ @param def Default value to return if key not found.
+ @return 1 pointer to internally allocated character string.
+
+ This function locates a key in a dictionary and returns a pointer to its
+ value, or the passed 'def' pointer if no such key can be found in
+ dictionary. The returned character pointer points to data internal to the
+ dictionary object, you should not try to free it or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+static char * dictionary_get(dictionary * d, char * key, char * def)
+{
+ unsigned hash ;
+ int i ;
+
+ hash = dictionary_hash(key);
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key==NULL)
+ continue ;
+ /* Compare hash */
+ if (hash==d->hash[i]) {
+ /* Compare string, to avoid hash collisions */
+ if (!strcmp(key, d->key[i])) {
+ return d->val[i] ;
+ }
+ }
+ }
+ return def ;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Set a value in a dictionary.
+ @param d dictionary object to modify.
+ @param key Key to modify or add.
+ @param val Value to add.
+ @return void
+
+ If the given key is found in the dictionary, the associated value is
+ replaced by the provided one. If the key cannot be found in the
+ dictionary, it is added to it.
+
+ It is Ok to provide a NULL value for val, but NULL values for the dictionary
+ or the key are considered as errors: the function will return immediately
+ in such a case.
+
+ Notice that if you dictionary_set a variable to NULL, a call to
+ dictionary_get will return a NULL value: the variable will be found, and
+ its value (NULL) is returned. In other words, setting the variable
+ content to NULL is equivalent to deleting the variable from the
+ dictionary. It is not possible (in this implementation) to have a key in
+ the dictionary without value.
+ */
+/*--------------------------------------------------------------------------*/
+
+static void dictionary_set(dictionary * d, char * key, char * val)
+{
+ int i ;
+ unsigned hash ;
+
+ if (d==NULL || key==NULL) return ;
+
+ /* Compute hash for this key */
+ hash = dictionary_hash(key) ;
+ /* Find if value is already in blackboard */
+ if (d->n>0) {
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (hash==d->hash[i]) { /* Same hash value */
+ if (!strcmp(key, d->key[i])) { /* Same key */
+ /* Found a value: modify and return */
+ if (d->val[i]!=NULL)
+ free(d->val[i]);
+ d->val[i] = val ? strdup(val) : NULL ;
+ /* Value has been modified: return */
+ return ;
+ }
+ }
+ }
+ }
+ /* Add a new value */
+ /* See if dictionary needs to grow */
+ if (d->n==d->size) {
+
+ /* Reached maximum size: reallocate blackboard */
+ d->val = (char **)mem_double(d->val, d->size * sizeof(char*)) ;
+ d->key = (char **)mem_double(d->key, d->size * sizeof(char*)) ;
+ d->hash = (unsigned int *)mem_double(d->hash, d->size * sizeof(unsigned)) ;
+
+ /* Double size */
+ d->size *= 2 ;
+ }
+
+ /* Insert key in the first empty slot */
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]==NULL) {
+ /* Add key here */
+ break ;
+ }
+ }
+ /* Copy key */
+ d->key[i] = strdup(key);
+ d->val[i] = val ? strdup(val) : NULL ;
+ d->hash[i] = hash;
+ d->n ++ ;
+ return ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete a key in a dictionary
+ @param d dictionary object to modify.
+ @param key Key to remove.
+ @return void
+
+ This function deletes a key in a dictionary. Nothing is done if the
+ key cannot be found.
+ */
+/*--------------------------------------------------------------------------*/
+static void dictionary_unset(dictionary * d, char * key)
+{
+ unsigned hash ;
+ int i ;
+
+ hash = dictionary_hash(key);
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ /* Compare hash */
+ if (hash==d->hash[i]) {
+ /* Compare string, to avoid hash collisions */
+ if (!strcmp(key, d->key[i])) {
+ /* Found key */
+ break ;
+ }
+ }
+ }
+ if (i>=d->size)
+ /* Key not found */
+ return ;
+
+ free(d->key[i]);
+ d->key[i] = NULL ;
+ if (d->val[i]!=NULL) {
+ free(d->val[i]);
+ d->val[i] = NULL ;
+ }
+ d->hash[i] = 0 ;
+ d->n -- ;
+ return ;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dump a dictionary to an opened file pointer.
+ @param d Dictionary to dump
+ @param f Opened file pointer.
+ @return void
+
+ Dumps a dictionary onto an opened file pointer. Key pairs are printed out
+ as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
+ output file pointers.
+ */
+/*--------------------------------------------------------------------------*/
+
+static void dictionary_dump(dictionary *d, FILE *f)
+{
+ int i;
+
+ if (d==NULL || f==NULL) return;
+
+ for (i=0; i<d->size; i++) {
+ if (d->key[i] == NULL)
+ continue ;
+ if (d->val[i] != NULL) {
+ fprintf(f, "[%s]=[%s]\n", d->key[i], d->val[i]);
+ } else {
+ fprintf(f, "[%s]=UNDEF\n", d->key[i]);
+ }
+ }
+
+ return;
+}
+
+
+/* iniparser.c.c following */
+#define ASCIILINESZ 1024
+#define INI_INVALID_KEY ((char*)-1)
+
+/* Private: add an entry to the dictionary */
+static void iniparser_add_entry(
+ dictionary * d,
+ char * sec,
+ char * key,
+ char * val)
+{
+ char longkey[2*ASCIILINESZ+1];
+
+ /* Make a key as section:keyword */
+ if (key!=NULL) {
+ sprintf(longkey, "%s:%s", sec, key);
+ } else {
+ strcpy(longkey, sec);
+ }
+
+ /* Add (key,val) to dictionary */
+ dictionary_set(d, longkey, val);
+ return ;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get number of sections in a dictionary
+ @param d Dictionary to examine
+ @return int Number of sections found in dictionary
+
+ This function returns the number of sections found in a dictionary.
+ The test to recognize sections is done on the string stored in the
+ dictionary: a section name is given as "section" whereas a key is
+ stored as "section:key", thus the test looks for entries that do not
+ contain a colon.
+
+ This clearly fails in the case a section name contains a colon, but
+ this should simply be avoided.
+
+ This function returns -1 in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+
+int iniparser_getnsec(dictionary * d)
+{
+ int i ;
+ int nsec ;
+
+ if (d==NULL) return -1 ;
+ nsec=0 ;
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (strchr(d->key[i], ':')==NULL) {
+ nsec ++ ;
+ }
+ }
+ return nsec ;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get name for section n in a dictionary.
+ @param d Dictionary to examine
+ @param n Section number (from 0 to nsec-1).
+ @return Pointer to char string
+
+ This function locates the n-th section in a dictionary and returns
+ its name as a pointer to a string statically allocated inside the
+ dictionary. Do not free or modify the returned string!
+
+ This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+
+char * iniparser_getsecname(dictionary * d, int n)
+{
+ int i ;
+ int foundsec ;
+
+ if (d==NULL || n<0) return NULL ;
+ foundsec=0 ;
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (strchr(d->key[i], ':')==NULL) {
+ foundsec++ ;
+ if (foundsec>n)
+ break ;
+ }
+ }
+ if (foundsec<=n) {
+ return NULL ;
+ }
+ return d->key[i] ;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dump a dictionary to an opened file pointer.
+ @param d Dictionary to dump.
+ @param f Opened file pointer to dump to.
+ @return void
+
+ This function prints out the contents of a dictionary, one element by
+ line, onto the provided file pointer. It is OK to specify @c stderr
+ or @c stdout as output files. This function is meant for debugging
+ purposes mostly.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_dump(dictionary * d, FILE * f)
+{
+ dictionary_dump(d,f);
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Save a dictionary to a loadable ini file
+ @param d Dictionary to dump
+ @param f Opened file pointer to dump to
+ @return void
+
+ This function dumps a given dictionary into a loadable ini file.
+ It is Ok to specify @c stderr or @c stdout as output files.
+ */
+/*--------------------------------------------------------------------------*/
+
+void iniparser_dump_ini(dictionary * d, FILE * f)
+{
+ int i, j ;
+ char keym[ASCIILINESZ+1];
+ int nsec ;
+ char * secname ;
+ int seclen ;
+
+ if (d==NULL || f==NULL) return ;
+
+ nsec = iniparser_getnsec(d);
+ if (nsec<1) {
+ /* No section in file: dump all keys as they are */
+ for (i=0 ; i<d->size ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ fprintf(f, "%s = %s\n", d->key[i], d->val[i]);
+ }
+ return ;
+ }
+ for (i=0 ; i<nsec ; i++) {
+ secname = iniparser_getsecname(d, i) ;
+ seclen = (int)strlen(secname);
+ fprintf(f, "\n[%s]\n", secname);
+ sprintf(keym, "%s:", secname);
+ for (j=0 ; j<d->size ; j++) {
+ if (d->key[j]==NULL)
+ continue ;
+ if (!strncmp(d->key[j], keym, seclen+1)) {
+ fprintf(f,
+ "%-30s = %s\n",
+ d->key[j]+seclen+1,
+ d->val[j] ? d->val[j] : "");
+ }
+ }
+ }
+ fprintf(f, "\n");
+ return ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, return NULL if not found
+ @param d Dictionary to search
+ @param key Key string to look for
+ @return pointer to statically allocated character string, or NULL.
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ NULL is returned.
+ The returned char pointer is pointing to a string allocated in
+ the dictionary, do not free or modify it.
+
+ This function is only provided for backwards compatibility with
+ previous versions of iniparser. It is recommended to use
+ iniparser_getstring() instead.
+ */
+/*--------------------------------------------------------------------------*/
+char * iniparser_getstr(dictionary * d, char * key)
+{
+ return iniparser_getstring(d, key, NULL);
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param def Default value to return if key not found.
+ @return pointer to statically allocated character string
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the pointer passed as 'def' is returned.
+ The returned char pointer is pointing to a string allocated in
+ the dictionary, do not free or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * iniparser_getstring(dictionary * d, char * key, char * def)
+{
+ char * lc_key ;
+ char * sval ;
+
+ if (d==NULL || key==NULL)
+ return def ;
+
+ lc_key = strdup(strlwc(key));
+ sval = dictionary_get(d, lc_key, def);
+ free(lc_key);
+ return sval ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to an int
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return integer
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getint(dictionary * d, char * key, int notfound)
+{
+ char * str ;
+
+ str = iniparser_getstring(d, key, INI_INVALID_KEY);
+ if (str==INI_INVALID_KEY) return notfound ;
+ return atoi(str);
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to a double
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return double
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+ */
+/*--------------------------------------------------------------------------*/
+double iniparser_getdouble(dictionary * d, char * key, double notfound)
+{
+ char * str ;
+
+ str = iniparser_getstring(d, key, INI_INVALID_KEY);
+ if (str==INI_INVALID_KEY) return notfound ;
+ return atof(str);
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to a boolean
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return integer
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+
+ A true boolean is found if one of the following is matched:
+
+ - A string starting with 'y'
+ - A string starting with 'Y'
+ - A string starting with 't'
+ - A string starting with 'T'
+ - A string starting with '1'
+
+ A false boolean is found if one of the following is matched:
+
+ - A string starting with 'n'
+ - A string starting with 'N'
+ - A string starting with 'f'
+ - A string starting with 'F'
+ - A string starting with '0'
+
+ The notfound value returned if no boolean is identified, does not
+ necessarily have to be 0 or 1.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getboolean(dictionary * d, char * key, int notfound)
+{
+ char * c ;
+ int ret ;
+
+ c = iniparser_getstring(d, key, INI_INVALID_KEY);
+ if (c==INI_INVALID_KEY) return notfound ;
+ if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') {
+ ret = 1 ;
+ } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') {
+ ret = 0 ;
+ } else {
+ ret = notfound ;
+ }
+ return ret;
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Finds out if a given entry exists in a dictionary
+ @param ini Dictionary to search
+ @param entry Name of the entry to look for
+ @return integer 1 if entry exists, 0 otherwise
+
+ Finds out if a given entry exists in the dictionary. Since sections
+ are stored as keys with NULL associated values, this is the only way
+ of querying for the presence of sections in a dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+
+int iniparser_find_entry(
+ dictionary * ini,
+ char * entry
+)
+{
+ int found=0 ;
+ if (iniparser_getstring(ini, entry, INI_INVALID_KEY)!=INI_INVALID_KEY) {
+ found = 1 ;
+ }
+ return found ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Set an entry in a dictionary.
+ @param ini Dictionary to modify.
+ @param entry Entry to modify (entry name)
+ @param val New value to associate to the entry.
+ @return int 0 if Ok, -1 otherwise.
+
+ If the given entry can be found in the dictionary, it is modified to
+ contain the provided value. If it cannot be found, -1 is returned.
+ It is Ok to set val to NULL.
+ */
+/*--------------------------------------------------------------------------*/
+
+int iniparser_setstr(dictionary * ini, char * entry, char * val)
+{
+ dictionary_set(ini, strlwc(entry), val);
+ return 0 ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete an entry in a dictionary
+ @param ini Dictionary to modify
+ @param entry Entry to delete (entry name)
+ @return void
+
+ If the given entry can be found, it is deleted from the dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_unset(dictionary * ini, char * entry)
+{
+ dictionary_unset(ini, strlwc(entry));
+}
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Parse an ini file and return an allocated dictionary object
+ @param ininame Name of the ini file to read.
+ @return Pointer to newly allocated dictionary
+
+ This is the parser for ini files. This function is called, providing
+ the name of the file to be read. It returns a dictionary object that
+ should not be accessed directly, but through accessor functions
+ instead.
+
+ The returned dictionary must be freed using iniparser_free().
+ */
+/*--------------------------------------------------------------------------*/
+
+dictionary * iniparser_new(const char *ininame)
+{
+ dictionary * d ;
+ char lin[ASCIILINESZ+1];
+ char sec[ASCIILINESZ+1];
+ char key[ASCIILINESZ+1];
+ char val[ASCIILINESZ+1];
+ char * where ;
+ FILE * ini ;
+ int lineno ;
+
+ if ((ini=fopen(ininame, "r"))==NULL) {
+ return NULL ;
+ }
+
+ sec[0]=0;
+
+ /*
+ * Initialize a new dictionary entry
+ */
+ d = dictionary_new(0);
+ lineno = 0 ;
+ while (fgets(lin, ASCIILINESZ, ini)!=NULL) {
+ lineno++ ;
+ where = strskp(lin); /* Skip leading spaces */
+ if (*where==';' || *where=='#' || *where==0)
+ continue ; /* Comment lines */
+ else {
+ if (sscanf(where, "[%[^]]", sec)==1) {
+ /* Valid section name */
+ strcpy(sec, strlwc(sec));
+ iniparser_add_entry(d, sec, NULL, NULL);
+ } else if (sscanf (where, "%[^=] = \"%[^\"]\"", key, val) == 2
+ || sscanf (where, "%[^=] = '%[^\']'", key, val) == 2
+ || sscanf (where, "%[^=] = %[^;#]", key, val) == 2) {
+ strcpy(key, strlwc(strcrop(key)));
+ /*
+ * sscanf cannot handle "" or '' as empty value,
+ * this is done here
+ */
+ if (!strcmp(val, "\"\"") || !strcmp(val, "''")) {
+ val[0] = (char)0;
+ } else {
+ strcpy(val, strcrop(val));
+ }
+ iniparser_add_entry(d, sec, key, val);
+ }
+ }
+ }
+ fclose(ini);
+ return d ;
+}
+
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Free all memory associated to an ini dictionary
+ @param d Dictionary to free
+ @return void
+
+ Free all memory associated to an ini dictionary.
+ It is mandatory to call this function before the dictionary object
+ gets out of the current context.
+ */
+/*--------------------------------------------------------------------------*/
+
+void iniparser_free(dictionary * d)
+{
+ dictionary_del(d);
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ Based upon libiniparser, by Nicolas Devillard
+ Hacked into 1 file (m-iniparser) by Freek/2005
+ Original terms following:
+
+ -- -
+
+ Copyright (c) 2000 by Nicolas Devillard (ndevilla AT free DOT fr).
+
+ Written by Nicolas Devillard. Not derived from licensed software.
+
+ Permission is granted to anyone to use this software for any
+ purpose on any computer system, and to redistribute it freely,
+ subject to the following restrictions:
+
+ 1. The author is not responsible for the consequences of use of
+ this software, no matter how awful, even if they arise
+ from defects in it.
+
+ 2. The origin of this software must not be misrepresented, either
+ by explicit claim or by omission.
+
+ 3. Altered versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+
+ 4. This notice may not be removed or altered.
+
+ */
+
+
+#ifndef _INIPARSER_H_
+#define _INIPARSER_H_
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct _dictionary_ {
+ /** Number of entries in dictionary */
+ int n;
+ /** Storage size */
+ int size;
+ /** List of string values */
+ char **val;
+ /** List of string keys */
+ char **key ;
+ /** List of hash values for keys */
+ unsigned *hash;
+} dictionary ;
+
+
+/* generated by genproto */
+
+dictionary * iniparser_new(const char *ininame);
+void iniparser_free(dictionary * d);
+
+int iniparser_getnsec(dictionary * d);
+char * iniparser_getsecname(dictionary * d, int n);
+void iniparser_dump(dictionary * d, FILE * f);
+void iniparser_dump_ini(dictionary * d, FILE * f);
+char * iniparser_getkey(dictionary *d, char *section, char *key);
+char * iniparser_getstr(dictionary * d, char * key);
+char * iniparser_getstring(dictionary * d, char * key, char * def);
+int iniparser_getint(dictionary * d, char * key, int notfound);
+double iniparser_getdouble(dictionary * d, char * key, double notfound);
+int iniparser_getboolean(dictionary * d, char * key, int notfound);
+int iniparser_find_entry(dictionary * ini, char * entry);
+int iniparser_setstr(dictionary * ini, char * entry, char * val);
+void iniparser_unset(dictionary * ini, char * entry);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+