| 1 | <html>
|
|---|
| 2 | <head>
|
|---|
| 3 | <meta name="author" content="ndevilla@free.fr">
|
|---|
| 4 | <meta name="keywords" content="ini file, config file, parser, C library">
|
|---|
| 5 | <link href="doxygen.css" rel="stylesheet" type="text/css">
|
|---|
| 6 | <title>iniparser 2.x</title>
|
|---|
| 7 | </head>
|
|---|
| 8 |
|
|---|
| 9 | <body text="#000000" bgcolor="#ffffff">
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | <!-- Generated by Doxygen 1.5.1 -->
|
|---|
| 14 | <h1>iniparser.h File Reference</h1>Parser for ini files. <a href="#_details">More...</a>
|
|---|
| 15 | <p>
|
|---|
| 16 | <table border="0" cellpadding="0" cellspacing="0">
|
|---|
| 17 | <tr><td></td></tr>
|
|---|
| 18 | <tr><td colspan="2"><br><h2>Functions</h2></td></tr>
|
|---|
| 19 | <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#0b5d6cdc7587e2d27a30f5cdc4a91931">iniparser_getnsec</a> (dictionary *d)</td></tr>
|
|---|
| 20 |
|
|---|
| 21 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get number of sections in a dictionary. <a href="#0b5d6cdc7587e2d27a30f5cdc4a91931"></a><br></td></tr>
|
|---|
| 22 | <tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#393212be805f395bbfdeb1bafa8bb72a">iniparser_getsecname</a> (dictionary *d, int n)</td></tr>
|
|---|
| 23 |
|
|---|
| 24 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get name for section n in a dictionary. <a href="#393212be805f395bbfdeb1bafa8bb72a"></a><br></td></tr>
|
|---|
| 25 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#ece0e32de371c9e9592d8333f816dfac">iniparser_dump_ini</a> (dictionary *d, FILE *f)</td></tr>
|
|---|
| 26 |
|
|---|
| 27 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Save a dictionary to a loadable ini file. <a href="#ece0e32de371c9e9592d8333f816dfac"></a><br></td></tr>
|
|---|
| 28 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#046436b3489cd8854ba8e29109250324">iniparser_dump</a> (dictionary *d, FILE *f)</td></tr>
|
|---|
| 29 |
|
|---|
| 30 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Dump a dictionary to an opened file pointer. <a href="#046436b3489cd8854ba8e29109250324"></a><br></td></tr>
|
|---|
| 31 | <tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#587eafb48937fdee8ae414ad7a666db8">iniparser_getstr</a> (dictionary *d, const char *key)</td></tr>
|
|---|
| 32 |
|
|---|
| 33 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the string associated to a key, return NULL if not found. <a href="#587eafb48937fdee8ae414ad7a666db8"></a><br></td></tr>
|
|---|
| 34 | <tr><td class="memItemLeft" nowrap align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#7894f8480e1f254d4a1b4a31bdc51b46">iniparser_getstring</a> (dictionary *d, const char *key, char *def)</td></tr>
|
|---|
| 35 |
|
|---|
| 36 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the string associated to a key. <a href="#7894f8480e1f254d4a1b4a31bdc51b46"></a><br></td></tr>
|
|---|
| 37 | <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#694eb1110f4200db8648820a0bb405fa">iniparser_getint</a> (dictionary *d, const char *key, int notfound)</td></tr>
|
|---|
| 38 |
|
|---|
| 39 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the string associated to a key, convert to an int. <a href="#694eb1110f4200db8648820a0bb405fa"></a><br></td></tr>
|
|---|
| 40 | <tr><td class="memItemLeft" nowrap align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#480d35322f1252344cf2246ac21ee559">iniparser_getdouble</a> (dictionary *d, char *key, double notfound)</td></tr>
|
|---|
| 41 |
|
|---|
| 42 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the string associated to a key, convert to a double. <a href="#480d35322f1252344cf2246ac21ee559"></a><br></td></tr>
|
|---|
| 43 | <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#eb93c13fcbb75efaa396f53bfd73ff4d">iniparser_getboolean</a> (dictionary *d, const char *key, int notfound)</td></tr>
|
|---|
| 44 |
|
|---|
| 45 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Get the string associated to a key, convert to a boolean. <a href="#eb93c13fcbb75efaa396f53bfd73ff4d"></a><br></td></tr>
|
|---|
| 46 | <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#605a88057bac4c3249513fc588421c32">iniparser_setstr</a> (dictionary *ini, char *entry, char *val)</td></tr>
|
|---|
| 47 |
|
|---|
| 48 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Set an entry in a dictionary. <a href="#605a88057bac4c3249513fc588421c32"></a><br></td></tr>
|
|---|
| 49 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#7b1a7f2492a35043867fa801b8f21e52">iniparser_unset</a> (dictionary *ini, char *entry)</td></tr>
|
|---|
| 50 |
|
|---|
| 51 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Delete an entry in a dictionary. <a href="#7b1a7f2492a35043867fa801b8f21e52"></a><br></td></tr>
|
|---|
| 52 | <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#3d67c98bbc0cb5239f024ad54bdc63f1">iniparser_find_entry</a> (dictionary *ini, char *entry)</td></tr>
|
|---|
| 53 |
|
|---|
| 54 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Finds out if a given entry exists in a dictionary. <a href="#3d67c98bbc0cb5239f024ad54bdc63f1"></a><br></td></tr>
|
|---|
| 55 | <tr><td class="memItemLeft" nowrap align="right" valign="top">dictionary * </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#b0be559bfb769224b3f1b75e26242a67">iniparser_load</a> (const char *ininame)</td></tr>
|
|---|
| 56 |
|
|---|
| 57 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Parse an ini file and return an allocated dictionary object. <a href="#b0be559bfb769224b3f1b75e26242a67"></a><br></td></tr>
|
|---|
| 58 | <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="iniparser_8h.html#90549ee518523921886b74454ff872eb">iniparser_freedict</a> (dictionary *d)</td></tr>
|
|---|
| 59 |
|
|---|
| 60 | <tr><td class="mdescLeft"> </td><td class="mdescRight">Free all memory associated to an ini dictionary. <a href="#90549ee518523921886b74454ff872eb"></a><br></td></tr>
|
|---|
| 61 | </table>
|
|---|
| 62 | <hr><a name="_details"></a><h2>Detailed Description</h2>
|
|---|
| 63 | Parser for ini files.
|
|---|
| 64 | <p>
|
|---|
| 65 | <dl class="author" compact><dt><b>Author:</b></dt><dd>N. Devillard </dd></dl>
|
|---|
| 66 | <dl class="date" compact><dt><b>Date:</b></dt><dd>Mar 2000 </dd></dl>
|
|---|
| 67 | <dl class="version" compact><dt><b>Version:</b></dt><dd><dl class="rcs" compact><dt><b>Revision</b></dt><dd>1.23 </dd></dl>
|
|---|
| 68 | </dd></dl>
|
|---|
| 69 | <hr><h2>Function Documentation</h2>
|
|---|
| 70 | <a class="anchor" name="046436b3489cd8854ba8e29109250324"></a><!-- doxytag: member="iniparser.h::iniparser_dump" ref="046436b3489cd8854ba8e29109250324" args="(dictionary *d, FILE *f)" -->
|
|---|
| 71 | <div class="memitem">
|
|---|
| 72 | <div class="memproto">
|
|---|
| 73 | <table class="memname">
|
|---|
| 74 | <tr>
|
|---|
| 75 | <td class="memname">void iniparser_dump </td>
|
|---|
| 76 | <td>(</td>
|
|---|
| 77 | <td class="paramtype">dictionary * </td>
|
|---|
| 78 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 79 | </tr>
|
|---|
| 80 | <tr>
|
|---|
| 81 | <td class="paramkey"></td>
|
|---|
| 82 | <td></td>
|
|---|
| 83 | <td class="paramtype">FILE * </td>
|
|---|
| 84 | <td class="paramname"> <em>f</em></td><td> </td>
|
|---|
| 85 | </tr>
|
|---|
| 86 | <tr>
|
|---|
| 87 | <td></td>
|
|---|
| 88 | <td>)</td>
|
|---|
| 89 | <td></td><td></td><td width="100%"></td>
|
|---|
| 90 | </tr>
|
|---|
| 91 | </table>
|
|---|
| 92 | </div>
|
|---|
| 93 | <div class="memdoc">
|
|---|
| 94 |
|
|---|
| 95 | <p>
|
|---|
| 96 | Dump a dictionary to an opened file pointer.
|
|---|
| 97 | <p>
|
|---|
| 98 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 99 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 100 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to dump. </td></tr>
|
|---|
| 101 | <tr><td valign="top"></td><td valign="top"><em>f</em> </td><td>Opened file pointer to dump to. </td></tr>
|
|---|
| 102 | </table>
|
|---|
| 103 | </dl>
|
|---|
| 104 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>void</dd></dl>
|
|---|
| 105 | This function prints out the contents of a dictionary, one element by line, onto the provided file pointer. It is OK to specify <code>stderr</code> or <code>stdout</code> as output files. This function is meant for debugging purposes mostly.
|
|---|
| 106 | </div>
|
|---|
| 107 | </div><p>
|
|---|
| 108 | <a class="anchor" name="ece0e32de371c9e9592d8333f816dfac"></a><!-- doxytag: member="iniparser.h::iniparser_dump_ini" ref="ece0e32de371c9e9592d8333f816dfac" args="(dictionary *d, FILE *f)" -->
|
|---|
| 109 | <div class="memitem">
|
|---|
| 110 | <div class="memproto">
|
|---|
| 111 | <table class="memname">
|
|---|
| 112 | <tr>
|
|---|
| 113 | <td class="memname">void iniparser_dump_ini </td>
|
|---|
| 114 | <td>(</td>
|
|---|
| 115 | <td class="paramtype">dictionary * </td>
|
|---|
| 116 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 117 | </tr>
|
|---|
| 118 | <tr>
|
|---|
| 119 | <td class="paramkey"></td>
|
|---|
| 120 | <td></td>
|
|---|
| 121 | <td class="paramtype">FILE * </td>
|
|---|
| 122 | <td class="paramname"> <em>f</em></td><td> </td>
|
|---|
| 123 | </tr>
|
|---|
| 124 | <tr>
|
|---|
| 125 | <td></td>
|
|---|
| 126 | <td>)</td>
|
|---|
| 127 | <td></td><td></td><td width="100%"></td>
|
|---|
| 128 | </tr>
|
|---|
| 129 | </table>
|
|---|
| 130 | </div>
|
|---|
| 131 | <div class="memdoc">
|
|---|
| 132 |
|
|---|
| 133 | <p>
|
|---|
| 134 | Save a dictionary to a loadable ini file.
|
|---|
| 135 | <p>
|
|---|
| 136 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 137 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 138 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to dump </td></tr>
|
|---|
| 139 | <tr><td valign="top"></td><td valign="top"><em>f</em> </td><td>Opened file pointer to dump to </td></tr>
|
|---|
| 140 | </table>
|
|---|
| 141 | </dl>
|
|---|
| 142 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>void</dd></dl>
|
|---|
| 143 | This function dumps a given dictionary into a loadable ini file. It is Ok to specify <code>stderr</code> or <code>stdout</code> as output files.
|
|---|
| 144 | </div>
|
|---|
| 145 | </div><p>
|
|---|
| 146 | <a class="anchor" name="3d67c98bbc0cb5239f024ad54bdc63f1"></a><!-- doxytag: member="iniparser.h::iniparser_find_entry" ref="3d67c98bbc0cb5239f024ad54bdc63f1" args="(dictionary *ini, char *entry)" -->
|
|---|
| 147 | <div class="memitem">
|
|---|
| 148 | <div class="memproto">
|
|---|
| 149 | <table class="memname">
|
|---|
| 150 | <tr>
|
|---|
| 151 | <td class="memname">int iniparser_find_entry </td>
|
|---|
| 152 | <td>(</td>
|
|---|
| 153 | <td class="paramtype">dictionary * </td>
|
|---|
| 154 | <td class="paramname"> <em>ini</em>, </td>
|
|---|
| 155 | </tr>
|
|---|
| 156 | <tr>
|
|---|
| 157 | <td class="paramkey"></td>
|
|---|
| 158 | <td></td>
|
|---|
| 159 | <td class="paramtype">char * </td>
|
|---|
| 160 | <td class="paramname"> <em>entry</em></td><td> </td>
|
|---|
| 161 | </tr>
|
|---|
| 162 | <tr>
|
|---|
| 163 | <td></td>
|
|---|
| 164 | <td>)</td>
|
|---|
| 165 | <td></td><td></td><td width="100%"></td>
|
|---|
| 166 | </tr>
|
|---|
| 167 | </table>
|
|---|
| 168 | </div>
|
|---|
| 169 | <div class="memdoc">
|
|---|
| 170 |
|
|---|
| 171 | <p>
|
|---|
| 172 | Finds out if a given entry exists in a dictionary.
|
|---|
| 173 | <p>
|
|---|
| 174 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 175 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 176 | <tr><td valign="top"></td><td valign="top"><em>ini</em> </td><td>Dictionary to search </td></tr>
|
|---|
| 177 | <tr><td valign="top"></td><td valign="top"><em>entry</em> </td><td>Name of the entry to look for </td></tr>
|
|---|
| 178 | </table>
|
|---|
| 179 | </dl>
|
|---|
| 180 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>integer 1 if entry exists, 0 otherwise</dd></dl>
|
|---|
| 181 | 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.
|
|---|
| 182 | </div>
|
|---|
| 183 | </div><p>
|
|---|
| 184 | <a class="anchor" name="90549ee518523921886b74454ff872eb"></a><!-- doxytag: member="iniparser.h::iniparser_freedict" ref="90549ee518523921886b74454ff872eb" args="(dictionary *d)" -->
|
|---|
| 185 | <div class="memitem">
|
|---|
| 186 | <div class="memproto">
|
|---|
| 187 | <table class="memname">
|
|---|
| 188 | <tr>
|
|---|
| 189 | <td class="memname">void iniparser_freedict </td>
|
|---|
| 190 | <td>(</td>
|
|---|
| 191 | <td class="paramtype">dictionary * </td>
|
|---|
| 192 | <td class="paramname"> <em>d</em> </td>
|
|---|
| 193 | <td> ) </td>
|
|---|
| 194 | <td width="100%"></td>
|
|---|
| 195 | </tr>
|
|---|
| 196 | </table>
|
|---|
| 197 | </div>
|
|---|
| 198 | <div class="memdoc">
|
|---|
| 199 |
|
|---|
| 200 | <p>
|
|---|
| 201 | Free all memory associated to an ini dictionary.
|
|---|
| 202 | <p>
|
|---|
| 203 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 204 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 205 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to free </td></tr>
|
|---|
| 206 | </table>
|
|---|
| 207 | </dl>
|
|---|
| 208 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>void</dd></dl>
|
|---|
| 209 | 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.
|
|---|
| 210 | </div>
|
|---|
| 211 | </div><p>
|
|---|
| 212 | <a class="anchor" name="eb93c13fcbb75efaa396f53bfd73ff4d"></a><!-- doxytag: member="iniparser.h::iniparser_getboolean" ref="eb93c13fcbb75efaa396f53bfd73ff4d" args="(dictionary *d, const char *key, int notfound)" -->
|
|---|
| 213 | <div class="memitem">
|
|---|
| 214 | <div class="memproto">
|
|---|
| 215 | <table class="memname">
|
|---|
| 216 | <tr>
|
|---|
| 217 | <td class="memname">int iniparser_getboolean </td>
|
|---|
| 218 | <td>(</td>
|
|---|
| 219 | <td class="paramtype">dictionary * </td>
|
|---|
| 220 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 221 | </tr>
|
|---|
| 222 | <tr>
|
|---|
| 223 | <td class="paramkey"></td>
|
|---|
| 224 | <td></td>
|
|---|
| 225 | <td class="paramtype">const char * </td>
|
|---|
| 226 | <td class="paramname"> <em>key</em>, </td>
|
|---|
| 227 | </tr>
|
|---|
| 228 | <tr>
|
|---|
| 229 | <td class="paramkey"></td>
|
|---|
| 230 | <td></td>
|
|---|
| 231 | <td class="paramtype">int </td>
|
|---|
| 232 | <td class="paramname"> <em>notfound</em></td><td> </td>
|
|---|
| 233 | </tr>
|
|---|
| 234 | <tr>
|
|---|
| 235 | <td></td>
|
|---|
| 236 | <td>)</td>
|
|---|
| 237 | <td></td><td></td><td width="100%"></td>
|
|---|
| 238 | </tr>
|
|---|
| 239 | </table>
|
|---|
| 240 | </div>
|
|---|
| 241 | <div class="memdoc">
|
|---|
| 242 |
|
|---|
| 243 | <p>
|
|---|
| 244 | Get the string associated to a key, convert to a boolean.
|
|---|
| 245 | <p>
|
|---|
| 246 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 247 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 248 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to search </td></tr>
|
|---|
| 249 | <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>Key string to look for </td></tr>
|
|---|
| 250 | <tr><td valign="top"></td><td valign="top"><em>notfound</em> </td><td>Value to return in case of error </td></tr>
|
|---|
| 251 | </table>
|
|---|
| 252 | </dl>
|
|---|
| 253 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>integer</dd></dl>
|
|---|
| 254 | 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.<p>
|
|---|
| 255 | A true boolean is found if one of the following is matched:<p>
|
|---|
| 256 | <ul>
|
|---|
| 257 | <li>A string starting with 'y'</li><li>A string starting with 'Y'</li><li>A string starting with 't'</li><li>A string starting with 'T'</li><li>A string starting with '1'</li></ul>
|
|---|
| 258 | <p>
|
|---|
| 259 | A false boolean is found if one of the following is matched:<p>
|
|---|
| 260 | <ul>
|
|---|
| 261 | <li>A string starting with 'n'</li><li>A string starting with 'N'</li><li>A string starting with 'f'</li><li>A string starting with 'F'</li><li>A string starting with '0'</li></ul>
|
|---|
| 262 | <p>
|
|---|
| 263 | The notfound value returned if no boolean is identified, does not necessarily have to be 0 or 1.
|
|---|
| 264 | </div>
|
|---|
| 265 | </div><p>
|
|---|
| 266 | <a class="anchor" name="480d35322f1252344cf2246ac21ee559"></a><!-- doxytag: member="iniparser.h::iniparser_getdouble" ref="480d35322f1252344cf2246ac21ee559" args="(dictionary *d, char *key, double notfound)" -->
|
|---|
| 267 | <div class="memitem">
|
|---|
| 268 | <div class="memproto">
|
|---|
| 269 | <table class="memname">
|
|---|
| 270 | <tr>
|
|---|
| 271 | <td class="memname">double iniparser_getdouble </td>
|
|---|
| 272 | <td>(</td>
|
|---|
| 273 | <td class="paramtype">dictionary * </td>
|
|---|
| 274 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 275 | </tr>
|
|---|
| 276 | <tr>
|
|---|
| 277 | <td class="paramkey"></td>
|
|---|
| 278 | <td></td>
|
|---|
| 279 | <td class="paramtype">char * </td>
|
|---|
| 280 | <td class="paramname"> <em>key</em>, </td>
|
|---|
| 281 | </tr>
|
|---|
| 282 | <tr>
|
|---|
| 283 | <td class="paramkey"></td>
|
|---|
| 284 | <td></td>
|
|---|
| 285 | <td class="paramtype">double </td>
|
|---|
| 286 | <td class="paramname"> <em>notfound</em></td><td> </td>
|
|---|
| 287 | </tr>
|
|---|
| 288 | <tr>
|
|---|
| 289 | <td></td>
|
|---|
| 290 | <td>)</td>
|
|---|
| 291 | <td></td><td></td><td width="100%"></td>
|
|---|
| 292 | </tr>
|
|---|
| 293 | </table>
|
|---|
| 294 | </div>
|
|---|
| 295 | <div class="memdoc">
|
|---|
| 296 |
|
|---|
| 297 | <p>
|
|---|
| 298 | Get the string associated to a key, convert to a double.
|
|---|
| 299 | <p>
|
|---|
| 300 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 301 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 302 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to search </td></tr>
|
|---|
| 303 | <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>Key string to look for </td></tr>
|
|---|
| 304 | <tr><td valign="top"></td><td valign="top"><em>notfound</em> </td><td>Value to return in case of error </td></tr>
|
|---|
| 305 | </table>
|
|---|
| 306 | </dl>
|
|---|
| 307 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>double</dd></dl>
|
|---|
| 308 | 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.
|
|---|
| 309 | </div>
|
|---|
| 310 | </div><p>
|
|---|
| 311 | <a class="anchor" name="694eb1110f4200db8648820a0bb405fa"></a><!-- doxytag: member="iniparser.h::iniparser_getint" ref="694eb1110f4200db8648820a0bb405fa" args="(dictionary *d, const char *key, int notfound)" -->
|
|---|
| 312 | <div class="memitem">
|
|---|
| 313 | <div class="memproto">
|
|---|
| 314 | <table class="memname">
|
|---|
| 315 | <tr>
|
|---|
| 316 | <td class="memname">int iniparser_getint </td>
|
|---|
| 317 | <td>(</td>
|
|---|
| 318 | <td class="paramtype">dictionary * </td>
|
|---|
| 319 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 320 | </tr>
|
|---|
| 321 | <tr>
|
|---|
| 322 | <td class="paramkey"></td>
|
|---|
| 323 | <td></td>
|
|---|
| 324 | <td class="paramtype">const char * </td>
|
|---|
| 325 | <td class="paramname"> <em>key</em>, </td>
|
|---|
| 326 | </tr>
|
|---|
| 327 | <tr>
|
|---|
| 328 | <td class="paramkey"></td>
|
|---|
| 329 | <td></td>
|
|---|
| 330 | <td class="paramtype">int </td>
|
|---|
| 331 | <td class="paramname"> <em>notfound</em></td><td> </td>
|
|---|
| 332 | </tr>
|
|---|
| 333 | <tr>
|
|---|
| 334 | <td></td>
|
|---|
| 335 | <td>)</td>
|
|---|
| 336 | <td></td><td></td><td width="100%"></td>
|
|---|
| 337 | </tr>
|
|---|
| 338 | </table>
|
|---|
| 339 | </div>
|
|---|
| 340 | <div class="memdoc">
|
|---|
| 341 |
|
|---|
| 342 | <p>
|
|---|
| 343 | Get the string associated to a key, convert to an int.
|
|---|
| 344 | <p>
|
|---|
| 345 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 346 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 347 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to search </td></tr>
|
|---|
| 348 | <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>Key string to look for </td></tr>
|
|---|
| 349 | <tr><td valign="top"></td><td valign="top"><em>notfound</em> </td><td>Value to return in case of error </td></tr>
|
|---|
| 350 | </table>
|
|---|
| 351 | </dl>
|
|---|
| 352 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>integer</dd></dl>
|
|---|
| 353 | 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.<p>
|
|---|
| 354 | Supported values for integers include the usual C notation so decimal, octal (starting with 0) and hexadecimal (starting with 0x) are supported. Examples:<p>
|
|---|
| 355 | <ul>
|
|---|
| 356 | <li>"42" -> 42</li><li>"042" -> 34 (octal -> decimal)</li><li>"0x42" -> 66 (hexa -> decimal)</li></ul>
|
|---|
| 357 | <p>
|
|---|
| 358 | Warning: the conversion may overflow in various ways. Conversion is totally outsourced to strtol(), see the associated man page for overflow handling.<p>
|
|---|
| 359 | Credits: Thanks to A. Becker for suggesting strtol()
|
|---|
| 360 | </div>
|
|---|
| 361 | </div><p>
|
|---|
| 362 | <a class="anchor" name="0b5d6cdc7587e2d27a30f5cdc4a91931"></a><!-- doxytag: member="iniparser.h::iniparser_getnsec" ref="0b5d6cdc7587e2d27a30f5cdc4a91931" args="(dictionary *d)" -->
|
|---|
| 363 | <div class="memitem">
|
|---|
| 364 | <div class="memproto">
|
|---|
| 365 | <table class="memname">
|
|---|
| 366 | <tr>
|
|---|
| 367 | <td class="memname">int iniparser_getnsec </td>
|
|---|
| 368 | <td>(</td>
|
|---|
| 369 | <td class="paramtype">dictionary * </td>
|
|---|
| 370 | <td class="paramname"> <em>d</em> </td>
|
|---|
| 371 | <td> ) </td>
|
|---|
| 372 | <td width="100%"></td>
|
|---|
| 373 | </tr>
|
|---|
| 374 | </table>
|
|---|
| 375 | </div>
|
|---|
| 376 | <div class="memdoc">
|
|---|
| 377 |
|
|---|
| 378 | <p>
|
|---|
| 379 | Get number of sections in a dictionary.
|
|---|
| 380 | <p>
|
|---|
| 381 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 382 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 383 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to examine </td></tr>
|
|---|
| 384 | </table>
|
|---|
| 385 | </dl>
|
|---|
| 386 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>int Number of sections found in dictionary</dd></dl>
|
|---|
| 387 | 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.<p>
|
|---|
| 388 | This clearly fails in the case a section name contains a colon, but this should simply be avoided.<p>
|
|---|
| 389 | This function returns -1 in case of error.
|
|---|
| 390 | </div>
|
|---|
| 391 | </div><p>
|
|---|
| 392 | <a class="anchor" name="393212be805f395bbfdeb1bafa8bb72a"></a><!-- doxytag: member="iniparser.h::iniparser_getsecname" ref="393212be805f395bbfdeb1bafa8bb72a" args="(dictionary *d, int n)" -->
|
|---|
| 393 | <div class="memitem">
|
|---|
| 394 | <div class="memproto">
|
|---|
| 395 | <table class="memname">
|
|---|
| 396 | <tr>
|
|---|
| 397 | <td class="memname">char* iniparser_getsecname </td>
|
|---|
| 398 | <td>(</td>
|
|---|
| 399 | <td class="paramtype">dictionary * </td>
|
|---|
| 400 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 401 | </tr>
|
|---|
| 402 | <tr>
|
|---|
| 403 | <td class="paramkey"></td>
|
|---|
| 404 | <td></td>
|
|---|
| 405 | <td class="paramtype">int </td>
|
|---|
| 406 | <td class="paramname"> <em>n</em></td><td> </td>
|
|---|
| 407 | </tr>
|
|---|
| 408 | <tr>
|
|---|
| 409 | <td></td>
|
|---|
| 410 | <td>)</td>
|
|---|
| 411 | <td></td><td></td><td width="100%"></td>
|
|---|
| 412 | </tr>
|
|---|
| 413 | </table>
|
|---|
| 414 | </div>
|
|---|
| 415 | <div class="memdoc">
|
|---|
| 416 |
|
|---|
| 417 | <p>
|
|---|
| 418 | Get name for section n in a dictionary.
|
|---|
| 419 | <p>
|
|---|
| 420 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 421 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 422 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to examine </td></tr>
|
|---|
| 423 | <tr><td valign="top"></td><td valign="top"><em>n</em> </td><td>Section number (from 0 to nsec-1). </td></tr>
|
|---|
| 424 | </table>
|
|---|
| 425 | </dl>
|
|---|
| 426 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>Pointer to char string</dd></dl>
|
|---|
| 427 | 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!<p>
|
|---|
| 428 | This function returns NULL in case of error.
|
|---|
| 429 | </div>
|
|---|
| 430 | </div><p>
|
|---|
| 431 | <a class="anchor" name="587eafb48937fdee8ae414ad7a666db8"></a><!-- doxytag: member="iniparser.h::iniparser_getstr" ref="587eafb48937fdee8ae414ad7a666db8" args="(dictionary *d, const char *key)" -->
|
|---|
| 432 | <div class="memitem">
|
|---|
| 433 | <div class="memproto">
|
|---|
| 434 | <table class="memname">
|
|---|
| 435 | <tr>
|
|---|
| 436 | <td class="memname">char* iniparser_getstr </td>
|
|---|
| 437 | <td>(</td>
|
|---|
| 438 | <td class="paramtype">dictionary * </td>
|
|---|
| 439 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 440 | </tr>
|
|---|
| 441 | <tr>
|
|---|
| 442 | <td class="paramkey"></td>
|
|---|
| 443 | <td></td>
|
|---|
| 444 | <td class="paramtype">const char * </td>
|
|---|
| 445 | <td class="paramname"> <em>key</em></td><td> </td>
|
|---|
| 446 | </tr>
|
|---|
| 447 | <tr>
|
|---|
| 448 | <td></td>
|
|---|
| 449 | <td>)</td>
|
|---|
| 450 | <td></td><td></td><td width="100%"></td>
|
|---|
| 451 | </tr>
|
|---|
| 452 | </table>
|
|---|
| 453 | </div>
|
|---|
| 454 | <div class="memdoc">
|
|---|
| 455 |
|
|---|
| 456 | <p>
|
|---|
| 457 | Get the string associated to a key, return NULL if not found.
|
|---|
| 458 | <p>
|
|---|
| 459 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 460 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 461 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to search </td></tr>
|
|---|
| 462 | <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>Key string to look for </td></tr>
|
|---|
| 463 | </table>
|
|---|
| 464 | </dl>
|
|---|
| 465 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>pointer to statically allocated character string, or NULL.</dd></dl>
|
|---|
| 466 | 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.<p>
|
|---|
| 467 | This function is only provided for backwards compatibility with previous versions of iniparser. It is recommended to use <a class="el" href="iniparser_8h.html#7894f8480e1f254d4a1b4a31bdc51b46">iniparser_getstring()</a> instead.
|
|---|
| 468 | </div>
|
|---|
| 469 | </div><p>
|
|---|
| 470 | <a class="anchor" name="7894f8480e1f254d4a1b4a31bdc51b46"></a><!-- doxytag: member="iniparser.h::iniparser_getstring" ref="7894f8480e1f254d4a1b4a31bdc51b46" args="(dictionary *d, const char *key, char *def)" -->
|
|---|
| 471 | <div class="memitem">
|
|---|
| 472 | <div class="memproto">
|
|---|
| 473 | <table class="memname">
|
|---|
| 474 | <tr>
|
|---|
| 475 | <td class="memname">char* iniparser_getstring </td>
|
|---|
| 476 | <td>(</td>
|
|---|
| 477 | <td class="paramtype">dictionary * </td>
|
|---|
| 478 | <td class="paramname"> <em>d</em>, </td>
|
|---|
| 479 | </tr>
|
|---|
| 480 | <tr>
|
|---|
| 481 | <td class="paramkey"></td>
|
|---|
| 482 | <td></td>
|
|---|
| 483 | <td class="paramtype">const char * </td>
|
|---|
| 484 | <td class="paramname"> <em>key</em>, </td>
|
|---|
| 485 | </tr>
|
|---|
| 486 | <tr>
|
|---|
| 487 | <td class="paramkey"></td>
|
|---|
| 488 | <td></td>
|
|---|
| 489 | <td class="paramtype">char * </td>
|
|---|
| 490 | <td class="paramname"> <em>def</em></td><td> </td>
|
|---|
| 491 | </tr>
|
|---|
| 492 | <tr>
|
|---|
| 493 | <td></td>
|
|---|
| 494 | <td>)</td>
|
|---|
| 495 | <td></td><td></td><td width="100%"></td>
|
|---|
| 496 | </tr>
|
|---|
| 497 | </table>
|
|---|
| 498 | </div>
|
|---|
| 499 | <div class="memdoc">
|
|---|
| 500 |
|
|---|
| 501 | <p>
|
|---|
| 502 | Get the string associated to a key.
|
|---|
| 503 | <p>
|
|---|
| 504 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 505 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 506 | <tr><td valign="top"></td><td valign="top"><em>d</em> </td><td>Dictionary to search </td></tr>
|
|---|
| 507 | <tr><td valign="top"></td><td valign="top"><em>key</em> </td><td>Key string to look for </td></tr>
|
|---|
| 508 | <tr><td valign="top"></td><td valign="top"><em>def</em> </td><td>Default value to return if key not found. </td></tr>
|
|---|
| 509 | </table>
|
|---|
| 510 | </dl>
|
|---|
| 511 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>pointer to statically allocated character string</dd></dl>
|
|---|
| 512 | 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.
|
|---|
| 513 | </div>
|
|---|
| 514 | </div><p>
|
|---|
| 515 | <a class="anchor" name="b0be559bfb769224b3f1b75e26242a67"></a><!-- doxytag: member="iniparser.h::iniparser_load" ref="b0be559bfb769224b3f1b75e26242a67" args="(const char *ininame)" -->
|
|---|
| 516 | <div class="memitem">
|
|---|
| 517 | <div class="memproto">
|
|---|
| 518 | <table class="memname">
|
|---|
| 519 | <tr>
|
|---|
| 520 | <td class="memname">dictionary* iniparser_load </td>
|
|---|
| 521 | <td>(</td>
|
|---|
| 522 | <td class="paramtype">const char * </td>
|
|---|
| 523 | <td class="paramname"> <em>ininame</em> </td>
|
|---|
| 524 | <td> ) </td>
|
|---|
| 525 | <td width="100%"></td>
|
|---|
| 526 | </tr>
|
|---|
| 527 | </table>
|
|---|
| 528 | </div>
|
|---|
| 529 | <div class="memdoc">
|
|---|
| 530 |
|
|---|
| 531 | <p>
|
|---|
| 532 | Parse an ini file and return an allocated dictionary object.
|
|---|
| 533 | <p>
|
|---|
| 534 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 535 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 536 | <tr><td valign="top"></td><td valign="top"><em>ininame</em> </td><td>Name of the ini file to read. </td></tr>
|
|---|
| 537 | </table>
|
|---|
| 538 | </dl>
|
|---|
| 539 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>Pointer to newly allocated dictionary</dd></dl>
|
|---|
| 540 | 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.<p>
|
|---|
| 541 | The returned dictionary must be freed using <a class="el" href="iniparser_8h.html#90549ee518523921886b74454ff872eb">iniparser_freedict()</a>.
|
|---|
| 542 | </div>
|
|---|
| 543 | </div><p>
|
|---|
| 544 | <a class="anchor" name="605a88057bac4c3249513fc588421c32"></a><!-- doxytag: member="iniparser.h::iniparser_setstr" ref="605a88057bac4c3249513fc588421c32" args="(dictionary *ini, char *entry, char *val)" -->
|
|---|
| 545 | <div class="memitem">
|
|---|
| 546 | <div class="memproto">
|
|---|
| 547 | <table class="memname">
|
|---|
| 548 | <tr>
|
|---|
| 549 | <td class="memname">int iniparser_setstr </td>
|
|---|
| 550 | <td>(</td>
|
|---|
| 551 | <td class="paramtype">dictionary * </td>
|
|---|
| 552 | <td class="paramname"> <em>ini</em>, </td>
|
|---|
| 553 | </tr>
|
|---|
| 554 | <tr>
|
|---|
| 555 | <td class="paramkey"></td>
|
|---|
| 556 | <td></td>
|
|---|
| 557 | <td class="paramtype">char * </td>
|
|---|
| 558 | <td class="paramname"> <em>entry</em>, </td>
|
|---|
| 559 | </tr>
|
|---|
| 560 | <tr>
|
|---|
| 561 | <td class="paramkey"></td>
|
|---|
| 562 | <td></td>
|
|---|
| 563 | <td class="paramtype">char * </td>
|
|---|
| 564 | <td class="paramname"> <em>val</em></td><td> </td>
|
|---|
| 565 | </tr>
|
|---|
| 566 | <tr>
|
|---|
| 567 | <td></td>
|
|---|
| 568 | <td>)</td>
|
|---|
| 569 | <td></td><td></td><td width="100%"></td>
|
|---|
| 570 | </tr>
|
|---|
| 571 | </table>
|
|---|
| 572 | </div>
|
|---|
| 573 | <div class="memdoc">
|
|---|
| 574 |
|
|---|
| 575 | <p>
|
|---|
| 576 | Set an entry in a dictionary.
|
|---|
| 577 | <p>
|
|---|
| 578 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 579 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 580 | <tr><td valign="top"></td><td valign="top"><em>ini</em> </td><td>Dictionary to modify. </td></tr>
|
|---|
| 581 | <tr><td valign="top"></td><td valign="top"><em>entry</em> </td><td>Entry to modify (entry name) </td></tr>
|
|---|
| 582 | <tr><td valign="top"></td><td valign="top"><em>val</em> </td><td>New value to associate to the entry. </td></tr>
|
|---|
| 583 | </table>
|
|---|
| 584 | </dl>
|
|---|
| 585 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>int 0 if Ok, -1 otherwise.</dd></dl>
|
|---|
| 586 | 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.
|
|---|
| 587 | </div>
|
|---|
| 588 | </div><p>
|
|---|
| 589 | <a class="anchor" name="7b1a7f2492a35043867fa801b8f21e52"></a><!-- doxytag: member="iniparser.h::iniparser_unset" ref="7b1a7f2492a35043867fa801b8f21e52" args="(dictionary *ini, char *entry)" -->
|
|---|
| 590 | <div class="memitem">
|
|---|
| 591 | <div class="memproto">
|
|---|
| 592 | <table class="memname">
|
|---|
| 593 | <tr>
|
|---|
| 594 | <td class="memname">void iniparser_unset </td>
|
|---|
| 595 | <td>(</td>
|
|---|
| 596 | <td class="paramtype">dictionary * </td>
|
|---|
| 597 | <td class="paramname"> <em>ini</em>, </td>
|
|---|
| 598 | </tr>
|
|---|
| 599 | <tr>
|
|---|
| 600 | <td class="paramkey"></td>
|
|---|
| 601 | <td></td>
|
|---|
| 602 | <td class="paramtype">char * </td>
|
|---|
| 603 | <td class="paramname"> <em>entry</em></td><td> </td>
|
|---|
| 604 | </tr>
|
|---|
| 605 | <tr>
|
|---|
| 606 | <td></td>
|
|---|
| 607 | <td>)</td>
|
|---|
| 608 | <td></td><td></td><td width="100%"></td>
|
|---|
| 609 | </tr>
|
|---|
| 610 | </table>
|
|---|
| 611 | </div>
|
|---|
| 612 | <div class="memdoc">
|
|---|
| 613 |
|
|---|
| 614 | <p>
|
|---|
| 615 | Delete an entry in a dictionary.
|
|---|
| 616 | <p>
|
|---|
| 617 | <dl compact><dt><b>Parameters:</b></dt><dd>
|
|---|
| 618 | <table border="0" cellspacing="2" cellpadding="0">
|
|---|
| 619 | <tr><td valign="top"></td><td valign="top"><em>ini</em> </td><td>Dictionary to modify </td></tr>
|
|---|
| 620 | <tr><td valign="top"></td><td valign="top"><em>entry</em> </td><td>Entry to delete (entry name) </td></tr>
|
|---|
| 621 | </table>
|
|---|
| 622 | </dl>
|
|---|
| 623 | <dl class="return" compact><dt><b>Returns:</b></dt><dd>void</dd></dl>
|
|---|
| 624 | If the given entry can be found, it is deleted from the dictionary.
|
|---|
| 625 | </div>
|
|---|
| 626 | </div><p>
|
|---|
| 627 |
|
|---|
| 628 | </body>
|
|---|
| 629 | </html>
|
|---|