]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classConfigReader.html
5ad5b9aedcfbdc2ab71009ea6567c7a2fd8f7ecd
[user/henk/code/inspircd.git] / docs / module-doc / classConfigReader.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>ConfigReader class Reference</title>
4 <link href="inspircd.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3-rc3 -->
7 <center>
8 <a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
9 <hr><h1>ConfigReader Class Reference</h1>Allows reading of values from configuration files This class allows a module to read from either the main configuration file (inspircd.conf) or from a module-specified configuration file. 
10 <a href="#_details">More...</a>
11 <p>
12 <code>#include &lt;<a class="el" href="modules_8h-source.html">modules.h</a>&gt;</code>
13 <p>
14 Inheritance diagram for ConfigReader:<p><center><img src="classConfigReader__inherit__graph.gif" border="0" usemap="#ConfigReader__inherit__map" alt="Inheritance graph"></center>
15 <map name="ConfigReader__inherit__map">
16 <area href="classclassbase.html" shape="rect" coords="19,16,85,37" alt="">
17 </map>
18 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center>Collaboration diagram for ConfigReader:<p><center><img src="classConfigReader__coll__graph.gif" border="0" usemap="#ConfigReader__coll__map" alt="Collaboration graph"></center>
19 <map name="ConfigReader__coll__map">
20 <area href="classclassbase.html" shape="rect" coords="7,107,73,128" alt="">
21 </map>
22 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center><a href="classConfigReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
23 <tr><td></td></tr>
24 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
25 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a0">ConfigReader</a> ()</td></tr>
26 <tr><td>&nbsp;</td><td><font size=-1><em>Default constructor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
27 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a1">ConfigReader</a> (std::string filename)</td></tr>
28 <tr><td>&nbsp;</td><td><font size=-1><em>Overloaded constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
29 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a2">~ConfigReader</a> ()</td></tr>
30 <tr><td>&nbsp;</td><td><font size=-1><em>Default destructor.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
31 <tr><td nowrap align=right valign=top>std::string&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a3">ReadValue</a> (std::string tag, std::string name, int index)</td></tr>
32 <tr><td>&nbsp;</td><td><font size=-1><em>Retrieves a value from the config file.</em> <a href="#a3"></a><em></em></font><br><br></td></tr>
33 <tr><td nowrap align=right valign=top>bool&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a4">ReadFlag</a> (std::string tag, std::string name, int index)</td></tr>
34 <tr><td>&nbsp;</td><td><font size=-1><em>Retrieves a boolean value from the config file.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
35 <tr><td nowrap align=right valign=top>long&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a5">ReadInteger</a> (std::string tag, std::string name, int index, bool needs_unsigned)</td></tr>
36 <tr><td>&nbsp;</td><td><font size=-1><em>Retrieves an integer value from the config file.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
37 <tr><td nowrap align=right valign=top>long&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a6">GetError</a> ()</td></tr>
38 <tr><td>&nbsp;</td><td><font size=-1><em>Returns the last error to occur.</em> <a href="#a6"></a><em></em></font><br><br></td></tr>
39 <tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a7">Enumerate</a> (std::string tag)</td></tr>
40 <tr><td>&nbsp;</td><td><font size=-1><em>Counts the number of times a given tag appears in the config file.</em> <a href="#a7"></a><em></em></font><br><br></td></tr>
41 <tr><td nowrap align=right valign=top>bool&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a8">Verify</a> ()</td></tr>
42 <tr><td>&nbsp;</td><td><font size=-1><em>Returns true if a config file is valid.</em> <a href="#a8"></a><em></em></font><br><br></td></tr>
43 <tr><td nowrap align=right valign=top>int&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a9">EnumerateValues</a> (std::string tag, int index)</td></tr>
44 <tr><td>&nbsp;</td><td><font size=-1><em>Returns the number of items within a tag.</em> <a href="#a9"></a><em></em></font><br><br></td></tr>
45 <tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
46 <tr><td nowrap align=right valign=top>std::stringstream *&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#n0">cache</a></td></tr>
47 <tr><td>&nbsp;</td><td><font size=-1><em>The contents of the configuration file This protected member should never be accessed by a module (and cannot be accessed unless the core is changed).</em> <a href="#n0"></a><em></em></font><br><br></td></tr>
48 <tr><td nowrap align=right valign=top>bool&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#n1">readerror</a></td></tr>
49 <tr><td>&nbsp;</td><td><font size=-1><em>Used to store errors.</em> <a href="#n1"></a><em></em></font><br><br></td></tr>
50 <tr><td nowrap align=right valign=top>long&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#n2">error</a></td></tr>
51 </table>
52 <hr><a name="_details"></a><h2>Detailed Description</h2>
53 Allows reading of values from configuration files This class allows a module to read from either the main configuration file (inspircd.conf) or from a module-specified configuration file.
54 <p>
55 It may either be instantiated with one parameter or none. Constructing the class using one parameter allows you to specify a path to your own configuration file, otherwise, inspircd.conf is read. 
56 <p>
57
58 <p>
59 Definition at line <a class="el" href="modules_8h-source.html#l00617">617</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
60 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
61 <table width="100%" cellpadding="2" cellspacing="0" border="0">
62   <tr>
63     <td class="md">
64       <table cellpadding="0" cellspacing="0" border="0">
65         <tr>
66           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
67           <td class="md" valign="top">(&nbsp;</td>
68           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
69           <td class="md" valign="top">)&nbsp;</td>
70           <td class="md" nowrap></td>
71         </tr>
72
73       </table>
74     </td>
75   </tr>
76 </table>
77 <table cellspacing=5 cellpadding=0 border=0>
78   <tr>
79     <td>
80       &nbsp;
81     </td>
82     <td>
83
84 <p>
85 Default constructor.
86 <p>
87 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
88 <p>
89 Definition at line <a class="el" href="modules_8cpp-source.html#l00553">553</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
90 <p>
91 References <a class="el" href="modules_8h-source.html#l00625">cache</a>, <a class="el" href="modules_8h-source.html#l00609">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l00629">error</a>, and <a class="el" href="modules_8h-source.html#l00628">readerror</a>.
92 <p>
93 <div class="fragment"><pre>00554 {
94 00555         this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
95 00556         this-&gt;<a class="code" href="classConfigReader.html#n1">readerror</a> = LoadConf(CONFIG_FILE,this-&gt;cache);
96 00557         <span class="keywordflow">if</span> (!this-&gt;<a class="code" href="classConfigReader.html#n1">readerror</a>)
97 00558                 this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a25">CONF_FILE_NOT_FOUND</a>;
98 00559 }
99 </pre></div>    </td>
100   </tr>
101 </table>
102 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
103 <table width="100%" cellpadding="2" cellspacing="0" border="0">
104   <tr>
105     <td class="md">
106       <table cellpadding="0" cellspacing="0" border="0">
107         <tr>
108           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
109           <td class="md" valign="top">(&nbsp;</td>
110           <td class="md" nowrap valign="top">std::string&nbsp;</td>
111           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
112           <td class="md" valign="top">)&nbsp;</td>
113           <td class="md" nowrap></td>
114         </tr>
115
116       </table>
117     </td>
118   </tr>
119 </table>
120 <table cellspacing=5 cellpadding=0 border=0>
121   <tr>
122     <td>
123       &nbsp;
124     </td>
125     <td>
126
127 <p>
128 Overloaded constructor.
129 <p>
130 This constructor initialises the ConfigReader class to read a user-specified config file
131 <p>
132 Definition at line <a class="el" href="modules_8cpp-source.html#l00569">569</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
133 <p>
134 References <a class="el" href="modules_8h-source.html#l00625">cache</a>, <a class="el" href="modules_8h-source.html#l00609">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l00629">error</a>, and <a class="el" href="modules_8h-source.html#l00628">readerror</a>.
135 <p>
136 <div class="fragment"><pre>00570 {
137 00571         this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
138 00572         this-&gt;<a class="code" href="classConfigReader.html#n1">readerror</a> = LoadConf(filename.c_str(),this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>);
139 00573         <span class="keywordflow">if</span> (!this-&gt;<a class="code" href="classConfigReader.html#n1">readerror</a>)
140 00574                 this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a25">CONF_FILE_NOT_FOUND</a>;
141 00575 };
142 </pre></div>    </td>
143   </tr>
144 </table>
145 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
146 <table width="100%" cellpadding="2" cellspacing="0" border="0">
147   <tr>
148     <td class="md">
149       <table cellpadding="0" cellspacing="0" border="0">
150         <tr>
151           <td class="md" nowrap valign="top"> ConfigReader::~ConfigReader </td>
152           <td class="md" valign="top">(&nbsp;</td>
153           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
154           <td class="md" valign="top">)&nbsp;</td>
155           <td class="md" nowrap></td>
156         </tr>
157
158       </table>
159     </td>
160   </tr>
161 </table>
162 <table cellspacing=5 cellpadding=0 border=0>
163   <tr>
164     <td>
165       &nbsp;
166     </td>
167     <td>
168
169 <p>
170 Default destructor.
171 <p>
172 This method destroys the ConfigReader class.
173 <p>
174 Definition at line <a class="el" href="modules_8cpp-source.html#l00562">562</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
175 <p>
176 References <a class="el" href="modules_8h-source.html#l00625">cache</a>.
177 <p>
178 <div class="fragment"><pre>00563 {
179 00564         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>)
180 00565                 <span class="keyword">delete</span> this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>;
181 00566 }
182 </pre></div>    </td>
183   </tr>
184 </table>
185 <hr><h2>Member Function Documentation</h2>
186 <a name="a7" doxytag="ConfigReader::Enumerate"></a><p>
187 <table width="100%" cellpadding="2" cellspacing="0" border="0">
188   <tr>
189     <td class="md">
190       <table cellpadding="0" cellspacing="0" border="0">
191         <tr>
192           <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
193           <td class="md" valign="top">(&nbsp;</td>
194           <td class="md" nowrap valign="top">std::string&nbsp;</td>
195           <td class="mdname1" valign="top" nowrap>&nbsp; <em>tag</em>          </td>
196           <td class="md" valign="top">)&nbsp;</td>
197           <td class="md" nowrap></td>
198         </tr>
199
200       </table>
201     </td>
202   </tr>
203 </table>
204 <table cellspacing=5 cellpadding=0 border=0>
205   <tr>
206     <td>
207       &nbsp;
208     </td>
209     <td>
210
211 <p>
212 Counts the number of times a given tag appears in the config file.
213 <p>
214 This method counts the number of times a tag appears in a config file, for use where there are several tags of the same kind, e.g. with opers and connect types. It can be used with the index value of <a class="el" href="classConfigReader.html#a3">ConfigReader::ReadValue</a> to loop through all copies of a multiple instance tag.
215 <p>
216 Definition at line <a class="el" href="modules_8cpp-source.html#l00647">647</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
217 <p>
218 <div class="fragment"><pre>00648 {
219 00649         <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
220 00650 }
221 </pre></div>    </td>
222   </tr>
223 </table>
224 <a name="a9" doxytag="ConfigReader::EnumerateValues"></a><p>
225 <table width="100%" cellpadding="2" cellspacing="0" border="0">
226   <tr>
227     <td class="md">
228       <table cellpadding="0" cellspacing="0" border="0">
229         <tr>
230           <td class="md" nowrap valign="top"> int ConfigReader::EnumerateValues </td>
231           <td class="md" valign="top">(&nbsp;</td>
232           <td class="md" nowrap valign="top">std::string&nbsp;</td>
233           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
234         </tr>
235         <tr>
236           <td></td>
237           <td></td>
238           <td class="md" nowrap>int&nbsp;</td>
239           <td class="mdname" nowrap>&nbsp; <em>index</em></td>
240         </tr>
241         <tr>
242           <td></td>
243           <td class="md">)&nbsp;</td>
244           <td class="md" colspan="2"></td>
245         </tr>
246
247       </table>
248     </td>
249   </tr>
250 </table>
251 <table cellspacing=5 cellpadding=0 border=0>
252   <tr>
253     <td>
254       &nbsp;
255     </td>
256     <td>
257
258 <p>
259 Returns the number of items within a tag.
260 <p>
261 For example if the tag was &lt;test tag="blah" data="foo"&gt; then this function would return 2. Spaces and newlines both qualify as valid seperators between values.
262 <p>
263 Definition at line <a class="el" href="modules_8cpp-source.html#l00652">652</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
264 <p>
265 <div class="fragment"><pre>00653 {
266 00654         <span class="keywordflow">return</span> EnumValues(cache, tag.c_str(), index);
267 00655 }
268 </pre></div>    </td>
269   </tr>
270 </table>
271 <a name="a6" doxytag="ConfigReader::GetError"></a><p>
272 <table width="100%" cellpadding="2" cellspacing="0" border="0">
273   <tr>
274     <td class="md">
275       <table cellpadding="0" cellspacing="0" border="0">
276         <tr>
277           <td class="md" nowrap valign="top"> long ConfigReader::GetError </td>
278           <td class="md" valign="top">(&nbsp;</td>
279           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
280           <td class="md" valign="top">)&nbsp;</td>
281           <td class="md" nowrap></td>
282         </tr>
283
284       </table>
285     </td>
286   </tr>
287 </table>
288 <table cellspacing=5 cellpadding=0 border=0>
289   <tr>
290     <td>
291       &nbsp;
292     </td>
293     <td>
294
295 <p>
296 Returns the last error to occur.
297 <p>
298 Valid errors can be found by looking in <a class="el" href="modules_8h.html">modules.h</a>. Any nonzero value indicates an error condition. A call to <a class="el" href="classConfigReader.html#a6">GetError()</a> resets the error flag back to 0.
299 <p>
300 Definition at line <a class="el" href="modules_8cpp-source.html#l00639">639</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
301 <p>
302 References <a class="el" href="modules_8h-source.html#l00629">error</a>.
303 <p>
304 <div class="fragment"><pre>00640 {
305 00641         <span class="keywordtype">long</span> olderr = this-&gt;<a class="code" href="classConfigReader.html#n2">error</a>;
306 00642         this-&gt;error = 0;
307 00643         <span class="keywordflow">return</span> olderr;
308 00644 }
309 </pre></div>    </td>
310   </tr>
311 </table>
312 <a name="a4" doxytag="ConfigReader::ReadFlag"></a><p>
313 <table width="100%" cellpadding="2" cellspacing="0" border="0">
314   <tr>
315     <td class="md">
316       <table cellpadding="0" cellspacing="0" border="0">
317         <tr>
318           <td class="md" nowrap valign="top"> bool ConfigReader::ReadFlag </td>
319           <td class="md" valign="top">(&nbsp;</td>
320           <td class="md" nowrap valign="top">std::string&nbsp;</td>
321           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
322         </tr>
323         <tr>
324           <td></td>
325           <td></td>
326           <td class="md" nowrap>std::string&nbsp;</td>
327           <td class="mdname" nowrap>&nbsp; <em>name</em>, </td>
328         </tr>
329         <tr>
330           <td></td>
331           <td></td>
332           <td class="md" nowrap>int&nbsp;</td>
333           <td class="mdname" nowrap>&nbsp; <em>index</em></td>
334         </tr>
335         <tr>
336           <td></td>
337           <td class="md">)&nbsp;</td>
338           <td class="md" colspan="2"></td>
339         </tr>
340
341       </table>
342     </td>
343   </tr>
344 </table>
345 <table cellspacing=5 cellpadding=0 border=0>
346   <tr>
347     <td>
348       &nbsp;
349     </td>
350     <td>
351
352 <p>
353 Retrieves a boolean value from the config file.
354 <p>
355 This method retrieves a boolean value from the config file. Where multiple copies of the tag exist in the config file, index indicates which of the values to retrieve. The values "1", "yes" and "true" in the config file count as true to ReadFlag, and any other value counts as false.
356 <p>
357 Definition at line <a class="el" href="modules_8cpp-source.html#l00593">593</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
358 <p>
359 References <a class="el" href="modules_8h-source.html#l00608">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00629">error</a>.
360 <p>
361 <div class="fragment"><pre>00594 {
362 00595         <span class="keywordtype">char</span> val[MAXBUF];
363 00596         <span class="keywordtype">char</span> t[MAXBUF];
364 00597         <span class="keywordtype">char</span> n[MAXBUF];
365 00598         strncpy(t,tag.c_str(),MAXBUF);
366 00599         strncpy(n,name.c_str(),MAXBUF);
367 00600         <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
368 00601         <span class="keywordflow">if</span> (!res)
369 00602         {
370 00603                 this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a24">CONF_VALUE_NOT_FOUND</a>;
371 00604                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
372 00605         }
373 00606         std::string s = val;
374 00607         <span class="keywordflow">return</span> ((s == <span class="stringliteral">"yes"</span>) || (s == <span class="stringliteral">"YES"</span>) || (s == <span class="stringliteral">"true"</span>) || (s == <span class="stringliteral">"TRUE"</span>) || (s == <span class="stringliteral">"1"</span>));
375 00608 }
376 </pre></div>    </td>
377   </tr>
378 </table>
379 <a name="a5" doxytag="ConfigReader::ReadInteger"></a><p>
380 <table width="100%" cellpadding="2" cellspacing="0" border="0">
381   <tr>
382     <td class="md">
383       <table cellpadding="0" cellspacing="0" border="0">
384         <tr>
385           <td class="md" nowrap valign="top"> long ConfigReader::ReadInteger </td>
386           <td class="md" valign="top">(&nbsp;</td>
387           <td class="md" nowrap valign="top">std::string&nbsp;</td>
388           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
389         </tr>
390         <tr>
391           <td></td>
392           <td></td>
393           <td class="md" nowrap>std::string&nbsp;</td>
394           <td class="mdname" nowrap>&nbsp; <em>name</em>, </td>
395         </tr>
396         <tr>
397           <td></td>
398           <td></td>
399           <td class="md" nowrap>int&nbsp;</td>
400           <td class="mdname" nowrap>&nbsp; <em>index</em>, </td>
401         </tr>
402         <tr>
403           <td></td>
404           <td></td>
405           <td class="md" nowrap>bool&nbsp;</td>
406           <td class="mdname" nowrap>&nbsp; <em>needs_unsigned</em></td>
407         </tr>
408         <tr>
409           <td></td>
410           <td class="md">)&nbsp;</td>
411           <td class="md" colspan="2"></td>
412         </tr>
413
414       </table>
415     </td>
416   </tr>
417 </table>
418 <table cellspacing=5 cellpadding=0 border=0>
419   <tr>
420     <td>
421       &nbsp;
422     </td>
423     <td>
424
425 <p>
426 Retrieves an integer value from the config file.
427 <p>
428 This method retrieves an integer value from the config file. Where multiple copies of the tag exist in the config file, index indicates which of the values to retrieve. Any invalid integer values in the tag will cause the objects error value to be set, and any call to <a class="el" href="classConfigReader.html#a6">GetError()</a> will return CONF_INVALID_NUMBER to be returned. needs_unsigned is set if the number must be unsigned. If a signed number is placed into a tag which is specified unsigned, 0 will be returned and <a class="el" href="classConfigReader.html#a6">GetError()</a> will return CONF_NOT_UNSIGNED
429 <p>
430 Definition at line <a class="el" href="modules_8cpp-source.html#l00610">610</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
431 <p>
432 References <a class="el" href="modules_8h-source.html#l00606">CONF_NOT_A_NUMBER</a>, <a class="el" href="modules_8h-source.html#l00607">CONF_NOT_UNSIGNED</a>, <a class="el" href="modules_8h-source.html#l00608">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00629">error</a>.
433 <p>
434 <div class="fragment"><pre>00611 {
435 00612         <span class="keywordtype">char</span> val[MAXBUF];
436 00613         <span class="keywordtype">char</span> t[MAXBUF];
437 00614         <span class="keywordtype">char</span> n[MAXBUF];
438 00615         strncpy(t,tag.c_str(),MAXBUF);
439 00616         strncpy(n,name.c_str(),MAXBUF);
440 00617         <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
441 00618         <span class="keywordflow">if</span> (!res)
442 00619         {
443 00620                 this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a24">CONF_VALUE_NOT_FOUND</a>;
444 00621                 <span class="keywordflow">return</span> 0;
445 00622         }
446 00623         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; strlen(val); i++)
447 00624         {
448 00625                 <span class="keywordflow">if</span> (!isdigit(val[i]))
449 00626                 {
450 00627                         this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a22">CONF_NOT_A_NUMBER</a>;
451 00628                         <span class="keywordflow">return</span> 0;
452 00629                 }
453 00630         }
454 00631         <span class="keywordflow">if</span> ((needs_unsigned) &amp;&amp; (atoi(val)&lt;0))
455 00632         {
456 00633                 this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a23">CONF_NOT_UNSIGNED</a>;
457 00634                 <span class="keywordflow">return</span> 0;
458 00635         }
459 00636         <span class="keywordflow">return</span> atoi(val);
460 00637 }
461 </pre></div>    </td>
462   </tr>
463 </table>
464 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
465 <table width="100%" cellpadding="2" cellspacing="0" border="0">
466   <tr>
467     <td class="md">
468       <table cellpadding="0" cellspacing="0" border="0">
469         <tr>
470           <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
471           <td class="md" valign="top">(&nbsp;</td>
472           <td class="md" nowrap valign="top">std::string&nbsp;</td>
473           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
474         </tr>
475         <tr>
476           <td></td>
477           <td></td>
478           <td class="md" nowrap>std::string&nbsp;</td>
479           <td class="mdname" nowrap>&nbsp; <em>name</em>, </td>
480         </tr>
481         <tr>
482           <td></td>
483           <td></td>
484           <td class="md" nowrap>int&nbsp;</td>
485           <td class="mdname" nowrap>&nbsp; <em>index</em></td>
486         </tr>
487         <tr>
488           <td></td>
489           <td class="md">)&nbsp;</td>
490           <td class="md" colspan="2"></td>
491         </tr>
492
493       </table>
494     </td>
495   </tr>
496 </table>
497 <table cellspacing=5 cellpadding=0 border=0>
498   <tr>
499     <td>
500       &nbsp;
501     </td>
502     <td>
503
504 <p>
505 Retrieves a value from the config file.
506 <p>
507 This method retrieves a value from the config file. Where multiple copies of the tag exist in the config file, index indicates which of the values to retrieve.
508 <p>
509 Definition at line <a class="el" href="modules_8cpp-source.html#l00577">577</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
510 <p>
511 References <a class="el" href="modules_8h-source.html#l00608">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00629">error</a>.
512 <p>
513 <div class="fragment"><pre>00578 {
514 00579         <span class="keywordtype">char</span> val[MAXBUF];
515 00580         <span class="keywordtype">char</span> t[MAXBUF];
516 00581         <span class="keywordtype">char</span> n[MAXBUF];
517 00582         strncpy(t,tag.c_str(),MAXBUF);
518 00583         strncpy(n,name.c_str(),MAXBUF);
519 00584         <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
520 00585         <span class="keywordflow">if</span> (!res)
521 00586         {
522 00587                 this-&gt;<a class="code" href="classConfigReader.html#n2">error</a> = <a class="code" href="modules_8h.html#a24">CONF_VALUE_NOT_FOUND</a>;
523 00588                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
524 00589         }
525 00590         <span class="keywordflow">return</span> std::string(val);
526 00591 }
527 </pre></div>    </td>
528   </tr>
529 </table>
530 <a name="a8" doxytag="ConfigReader::Verify"></a><p>
531 <table width="100%" cellpadding="2" cellspacing="0" border="0">
532   <tr>
533     <td class="md">
534       <table cellpadding="0" cellspacing="0" border="0">
535         <tr>
536           <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
537           <td class="md" valign="top">(&nbsp;</td>
538           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
539           <td class="md" valign="top">)&nbsp;</td>
540           <td class="md" nowrap></td>
541         </tr>
542
543       </table>
544     </td>
545   </tr>
546 </table>
547 <table cellspacing=5 cellpadding=0 border=0>
548   <tr>
549     <td>
550       &nbsp;
551     </td>
552     <td>
553
554 <p>
555 Returns true if a config file is valid.
556 <p>
557 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
558 <p>
559 Definition at line <a class="el" href="modules_8cpp-source.html#l00657">657</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
560 <p>
561 References <a class="el" href="modules_8h-source.html#l00628">readerror</a>.
562 <p>
563 <div class="fragment"><pre>00658 {
564 00659         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classConfigReader.html#n1">readerror</a>;
565 00660 }
566 </pre></div>    </td>
567   </tr>
568 </table>
569 <hr><h2>Member Data Documentation</h2>
570 <a name="n0" doxytag="ConfigReader::cache"></a><p>
571 <table width="100%" cellpadding="2" cellspacing="0" border="0">
572   <tr>
573     <td class="md">
574       <table cellpadding="0" cellspacing="0" border="0">
575         <tr>
576           <td class="md" nowrap valign="top"> std::stringstream* ConfigReader::cache<code> [protected]</code>
577       </table>
578     </td>
579   </tr>
580 </table>
581 <table cellspacing=5 cellpadding=0 border=0>
582   <tr>
583     <td>
584       &nbsp;
585     </td>
586     <td>
587
588 <p>
589 The contents of the configuration file This protected member should never be accessed by a module (and cannot be accessed unless the core is changed).
590 <p>
591 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
592 <p>
593 Definition at line <a class="el" href="modules_8h-source.html#l00625">625</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
594 <p>
595 Referenced by <a class="el" href="modules_8cpp-source.html#l00553">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00562">~ConfigReader()</a>.    </td>
596   </tr>
597 </table>
598 <a name="n2" doxytag="ConfigReader::error"></a><p>
599 <table width="100%" cellpadding="2" cellspacing="0" border="0">
600   <tr>
601     <td class="md">
602       <table cellpadding="0" cellspacing="0" border="0">
603         <tr>
604           <td class="md" nowrap valign="top"> long ConfigReader::error<code> [protected]</code>
605       </table>
606     </td>
607   </tr>
608 </table>
609 <table cellspacing=5 cellpadding=0 border=0>
610   <tr>
611     <td>
612       &nbsp;
613     </td>
614     <td>
615
616 <p>
617
618 <p>
619 Definition at line <a class="el" href="modules_8h-source.html#l00629">629</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
620 <p>
621 Referenced by <a class="el" href="modules_8cpp-source.html#l00553">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00639">GetError()</a>, <a class="el" href="modules_8cpp-source.html#l00593">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00610">ReadInteger()</a>, and <a class="el" href="modules_8cpp-source.html#l00577">ReadValue()</a>.    </td>
622   </tr>
623 </table>
624 <a name="n1" doxytag="ConfigReader::readerror"></a><p>
625 <table width="100%" cellpadding="2" cellspacing="0" border="0">
626   <tr>
627     <td class="md">
628       <table cellpadding="0" cellspacing="0" border="0">
629         <tr>
630           <td class="md" nowrap valign="top"> bool ConfigReader::readerror<code> [protected]</code>
631       </table>
632     </td>
633   </tr>
634 </table>
635 <table cellspacing=5 cellpadding=0 border=0>
636   <tr>
637     <td>
638       &nbsp;
639     </td>
640     <td>
641
642 <p>
643 Used to store errors.
644 <p>
645
646 <p>
647 Definition at line <a class="el" href="modules_8h-source.html#l00628">628</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
648 <p>
649 Referenced by <a class="el" href="modules_8cpp-source.html#l00553">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00657">Verify()</a>.    </td>
650   </tr>
651 </table>
652 <hr>The documentation for this class was generated from the following files:<ul>
653 <li><a class="el" href="modules_8h-source.html">modules.h</a><li><a class="el" href="modules_8cpp-source.html">modules.cpp</a></ul>
654 <hr><address style="align: right;"><small>Generated on Sat May 1 20:58:02 2004 for InspIRCd by
655 <a href="http://www.doxygen.org/index.html">
656 <img src="doxygen.png" alt="doxygen" align="middle" border=0 
657 width=110 height=53></a>1.3-rc3 </small></address>
658 </body>
659 </html>