]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classConfigReader.html
New documentation on today's new methods etc
[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>InspIRCd: ConfigReader class Reference</title>
4 <link href="inspircd.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3.3 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
8 <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.  
9 <a href="#_details">More...</a>
10 <p>
11 <code>#include &lt;<a class="el" href="modules_8h-source.html">modules.h</a>&gt;</code>
12 <p>
13 Inherits <a class="el" href="classclassbase.html">classbase</a>.
14 <p>
15 <a href="classConfigReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
16 <tr><td></td></tr>
17 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
18 <tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a0">ConfigReader</a> ()</td></tr>
19
20 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor. </em> <a href="#a0"></a><em><br><br></td></tr>
21 <tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a1">ConfigReader</a> (std::string filename)</td></tr>
22
23 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Overloaded constructor. </em> <a href="#a1"></a><em><br><br></td></tr>
24 <tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a2">~ConfigReader</a> ()</td></tr>
25
26 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default destructor. </em> <a href="#a2"></a><em><br><br></td></tr>
27 <tr><td class="memItemLeft" nowrap align=right valign=top>std::string&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a3">ReadValue</a> (std::string tag, std::string name, int index)</td></tr>
28
29 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retrieves a value from the config file. </em> <a href="#a3"></a><em><br><br></td></tr>
30 <tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a4">ReadFlag</a> (std::string tag, std::string name, int index)</td></tr>
31
32 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retrieves a boolean value from the config file. </em> <a href="#a4"></a><em><br><br></td></tr>
33 <tr><td class="memItemLeft" nowrap align=right valign=top>long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a5">ReadInteger</a> (std::string tag, std::string name, int index, bool needs_unsigned)</td></tr>
34
35 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retrieves an integer value from the config file. </em> <a href="#a5"></a><em><br><br></td></tr>
36 <tr><td class="memItemLeft" nowrap align=right valign=top>long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a6">GetError</a> ()</td></tr>
37
38 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the last error to occur. </em> <a href="#a6"></a><em><br><br></td></tr>
39 <tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a7">Enumerate</a> (std::string tag)</td></tr>
40
41 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Counts the number of times a given tag appears in the config file. </em> <a href="#a7"></a><em><br><br></td></tr>
42 <tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a8">Verify</a> ()</td></tr>
43
44 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns true if a config file is valid. </em> <a href="#a8"></a><em><br><br></td></tr>
45 <tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a9">DumpErrors</a> (bool bail, <a class="el" href="classuserrec.html">userrec</a> *user)</td></tr>
46
47 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Dumps the list of errors in a config file to an output location. </em> <a href="#a9"></a><em><br><br></td></tr>
48 <tr><td class="memItemLeft" nowrap align=right valign=top>int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a10">EnumerateValues</a> (std::string tag, int index)</td></tr>
49
50 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns the number of items within a tag. </em> <a href="#a10"></a><em><br><br></td></tr>
51 <tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
52 <tr><td class="memItemLeft" nowrap align=right valign=top>std::stringstream *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p0">cache</a></td></tr>
53
54 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">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="#p0"></a><em><br><br></td></tr>
55 <tr><td class="memItemLeft" nowrap align=right valign=top>std::stringstream *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p1">errorlog</a></td></tr>
56
57 <tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p2">readerror</a></td></tr>
58
59 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Used to store errors. </em> <a href="#p2"></a><em><br><br></td></tr>
60 <tr><td class="memItemLeft" nowrap align=right valign=top>long&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p3">error</a></td></tr>
61
62 </table>
63 <hr><a name="_details"></a><h2>Detailed Description</h2>
64 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. 
65 <p>
66 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. 
67 <p>
68
69 <p>
70 Definition at line <a class="el" href="modules_8h-source.html#l00835">835</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
71 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
72 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
73   <tr>
74     <td class="mdRow">
75       <table cellpadding="0" cellspacing="0" border="0">
76         <tr>
77           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
78           <td class="md" valign="top">(&nbsp;</td>
79           <td class="mdname1" valign="top" nowrap>          </td>
80           <td class="md" valign="top">&nbsp;)&nbsp;</td>
81           <td class="md" nowrap></td>
82         </tr>
83
84       </table>
85     </td>
86   </tr>
87 </table>
88 <table cellspacing=5 cellpadding=0 border=0>
89   <tr>
90     <td>
91       &nbsp;
92     </td>
93     <td>
94
95 <p>
96 Default constructor. 
97 <p>
98 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
99 <p>
100 Definition at line <a class="el" href="modules_8cpp-source.html#l00708">708</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
101 <p>
102 References <a class="el" href="modules_8h-source.html#l00843">cache</a>, <a class="el" href="modules_8h-source.html#l00827">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l00848">error</a>, <a class="el" href="modules_8h-source.html#l00844">errorlog</a>, and <a class="el" href="modules_8h-source.html#l00847">readerror</a>.
103 <p>
104 <div class="fragment"><pre>00709 {
105 00710         this-&gt;<a class="code" href="classConfigReader.html#p0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
106 00711         this-&gt;<a class="code" href="classConfigReader.html#p1">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
107 00712         this-&gt;<a class="code" href="classConfigReader.html#p2">readerror</a> = LoadConf(CONFIG_FILE,this-&gt;cache,this-&gt;errorlog);
108 00713         <span class="keywordflow">if</span> (!this-&gt;<a class="code" href="classConfigReader.html#p2">readerror</a>)
109 00714                 this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a30">CONF_FILE_NOT_FOUND</a>;
110 00715 }
111 </pre></div>    </td>
112   </tr>
113 </table>
114 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
115 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
116   <tr>
117     <td class="mdRow">
118       <table cellpadding="0" cellspacing="0" border="0">
119         <tr>
120           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
121           <td class="md" valign="top">(&nbsp;</td>
122           <td class="md" nowrap valign="top">std::string&nbsp;</td>
123           <td class="mdname1" valign="top" nowrap> <em>filename</em>          </td>
124           <td class="md" valign="top">&nbsp;)&nbsp;</td>
125           <td class="md" nowrap></td>
126         </tr>
127
128       </table>
129     </td>
130   </tr>
131 </table>
132 <table cellspacing=5 cellpadding=0 border=0>
133   <tr>
134     <td>
135       &nbsp;
136     </td>
137     <td>
138
139 <p>
140 Overloaded constructor. 
141 <p>
142 This constructor initialises the ConfigReader class to read a user-specified config file
143 <p>
144 Definition at line <a class="el" href="modules_8cpp-source.html#l00727">727</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
145 <p>
146 References <a class="el" href="modules_8h-source.html#l00843">cache</a>, <a class="el" href="modules_8h-source.html#l00827">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l00848">error</a>, <a class="el" href="modules_8h-source.html#l00844">errorlog</a>, and <a class="el" href="modules_8h-source.html#l00847">readerror</a>.
147 <p>
148 <div class="fragment"><pre>00728 {
149 00729         this-&gt;<a class="code" href="classConfigReader.html#p0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
150 00730         this-&gt;<a class="code" href="classConfigReader.html#p1">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
151 00731         this-&gt;<a class="code" href="classConfigReader.html#p2">readerror</a> = LoadConf(filename.c_str(),this-&gt;<a class="code" href="classConfigReader.html#p0">cache</a>,this-&gt;<a class="code" href="classConfigReader.html#p1">errorlog</a>);
152 00732         <span class="keywordflow">if</span> (!this-&gt;<a class="code" href="classConfigReader.html#p2">readerror</a>)
153 00733                 this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a30">CONF_FILE_NOT_FOUND</a>;
154 00734 };
155 </pre></div>    </td>
156   </tr>
157 </table>
158 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
159 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
160   <tr>
161     <td class="mdRow">
162       <table cellpadding="0" cellspacing="0" border="0">
163         <tr>
164           <td class="md" nowrap valign="top"> ConfigReader::~<a class="el" href="classConfigReader.html">ConfigReader</a> </td>
165           <td class="md" valign="top">(&nbsp;</td>
166           <td class="mdname1" valign="top" nowrap>          </td>
167           <td class="md" valign="top">&nbsp;)&nbsp;</td>
168           <td class="md" nowrap></td>
169         </tr>
170
171       </table>
172     </td>
173   </tr>
174 </table>
175 <table cellspacing=5 cellpadding=0 border=0>
176   <tr>
177     <td>
178       &nbsp;
179     </td>
180     <td>
181
182 <p>
183 Default destructor. 
184 <p>
185 This method destroys the ConfigReader class.
186 <p>
187 Definition at line <a class="el" href="modules_8cpp-source.html#l00718">718</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
188 <p>
189 References <a class="el" href="modules_8h-source.html#l00843">cache</a>, and <a class="el" href="modules_8h-source.html#l00844">errorlog</a>.
190 <p>
191 <div class="fragment"><pre>00719 {
192 00720         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classConfigReader.html#p0">cache</a>)
193 00721                 <span class="keyword">delete</span> this-&gt;<a class="code" href="classConfigReader.html#p0">cache</a>;
194 00722         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classConfigReader.html#p1">errorlog</a>)
195 00723                 <span class="keyword">delete</span> this-&gt;<a class="code" href="classConfigReader.html#p1">errorlog</a>;
196 00724 }
197 </pre></div>    </td>
198   </tr>
199 </table>
200 <hr><h2>Member Function Documentation</h2>
201 <a name="a9" doxytag="ConfigReader::DumpErrors"></a><p>
202 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
203   <tr>
204     <td class="mdRow">
205       <table cellpadding="0" cellspacing="0" border="0">
206         <tr>
207           <td class="md" nowrap valign="top"> void ConfigReader::DumpErrors </td>
208           <td class="md" valign="top">(&nbsp;</td>
209           <td class="md" nowrap valign="top">bool&nbsp;</td>
210           <td class="mdname" nowrap> <em>bail</em>, </td>
211         </tr>
212         <tr>
213           <td></td>
214           <td></td>
215           <td class="md" nowrap><a class="el" href="classuserrec.html">userrec</a> *&nbsp;</td>
216           <td class="mdname" nowrap> <em>user</em></td>
217         </tr>
218         <tr>
219           <td></td>
220           <td class="md">)&nbsp;</td>
221           <td class="md" colspan="2"></td>
222         </tr>
223
224       </table>
225     </td>
226   </tr>
227 </table>
228 <table cellspacing=5 cellpadding=0 border=0>
229   <tr>
230     <td>
231       &nbsp;
232     </td>
233     <td>
234
235 <p>
236 Dumps the list of errors in a config file to an output location. 
237 <p>
238 If bail is true, then the program will abort. If bail is false and user points to a valid user record, the error report will be spooled to the given user by means of NOTICE. if bool is false AND user is false, the error report will be spooled to all opers by means of a NOTICE to all opers.
239 <p>
240 Definition at line <a class="el" href="modules_8cpp-source.html#l00805">805</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
241 <p>
242 References <a class="el" href="modules_8h-source.html#l00844">errorlog</a>, <a class="el" href="connection_8h-source.html#l00178">connection::fd</a>, and <a class="el" href="users_8h-source.html#l00106">userrec::nick</a>.
243 <p>
244 <div class="fragment"><pre>00806 {
245 00807         <span class="keywordflow">if</span> (bail)
246 00808         {
247 00809                 printf(<span class="stringliteral">"There were errors in your configuration:\n%s"</span>,<a class="code" href="classConfigReader.html#p1">errorlog</a>-&gt;str().c_str());
248 00810                 exit(0);
249 00811         }
250 00812         <span class="keywordflow">else</span>
251 00813         {
252 00814                 <span class="keywordtype">char</span> dataline[1024];
253 00815                 <span class="keywordflow">if</span> (user)
254 00816                 {
255 00817                         WriteServ(user-&gt;<a class="code" href="classconnection.html#o0">fd</a>,<span class="stringliteral">"NOTICE %s :There were errors in the configuration file:"</span>,user-&gt;<a class="code" href="classuserrec.html#o0">nick</a>);
256 00818                         <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#p1">errorlog</a>-&gt;eof())
257 00819                         {
258 00820                                 <a class="code" href="classConfigReader.html#p1">errorlog</a>-&gt;getline(dataline,1024);
259 00821                                 WriteServ(user-&gt;<a class="code" href="classconnection.html#o0">fd</a>,<span class="stringliteral">"NOTICE %s :%s"</span>,user-&gt;<a class="code" href="classuserrec.html#o0">nick</a>,dataline);
260 00822                         }
261 00823                 }
262 00824                 <span class="keywordflow">else</span>
263 00825                 {
264 00826                         WriteOpers(<span class="stringliteral">"There were errors in the configuration file:"</span>,user-&gt;<a class="code" href="classuserrec.html#o0">nick</a>);
265 00827                         <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#p1">errorlog</a>-&gt;eof())
266 00828                         {
267 00829                                 <a class="code" href="classConfigReader.html#p1">errorlog</a>-&gt;getline(dataline,1024);
268 00830                                 WriteOpers(dataline);
269 00831                         }
270 00832                 }
271 00833                 <span class="keywordflow">return</span>;
272 00834         }
273 00835 }
274 </pre></div>    </td>
275   </tr>
276 </table>
277 <a name="a7" doxytag="ConfigReader::Enumerate"></a><p>
278 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
279   <tr>
280     <td class="mdRow">
281       <table cellpadding="0" cellspacing="0" border="0">
282         <tr>
283           <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
284           <td class="md" valign="top">(&nbsp;</td>
285           <td class="md" nowrap valign="top">std::string&nbsp;</td>
286           <td class="mdname1" valign="top" nowrap> <em>tag</em>          </td>
287           <td class="md" valign="top">&nbsp;)&nbsp;</td>
288           <td class="md" nowrap></td>
289         </tr>
290
291       </table>
292     </td>
293   </tr>
294 </table>
295 <table cellspacing=5 cellpadding=0 border=0>
296   <tr>
297     <td>
298       &nbsp;
299     </td>
300     <td>
301
302 <p>
303 Counts the number of times a given tag appears in the config file. 
304 <p>
305 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.
306 <p>
307 Definition at line <a class="el" href="modules_8cpp-source.html#l00838">838</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
308 <p>
309 References <a class="el" href="modules_8h-source.html#l00843">cache</a>.
310 <p>
311 <div class="fragment"><pre>00839 {
312 00840         <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
313 00841 }
314 </pre></div>    </td>
315   </tr>
316 </table>
317 <a name="a10" doxytag="ConfigReader::EnumerateValues"></a><p>
318 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
319   <tr>
320     <td class="mdRow">
321       <table cellpadding="0" cellspacing="0" border="0">
322         <tr>
323           <td class="md" nowrap valign="top"> int ConfigReader::EnumerateValues </td>
324           <td class="md" valign="top">(&nbsp;</td>
325           <td class="md" nowrap valign="top">std::string&nbsp;</td>
326           <td class="mdname" nowrap> <em>tag</em>, </td>
327         </tr>
328         <tr>
329           <td></td>
330           <td></td>
331           <td class="md" nowrap>int&nbsp;</td>
332           <td class="mdname" nowrap> <em>index</em></td>
333         </tr>
334         <tr>
335           <td></td>
336           <td class="md">)&nbsp;</td>
337           <td class="md" colspan="2"></td>
338         </tr>
339
340       </table>
341     </td>
342   </tr>
343 </table>
344 <table cellspacing=5 cellpadding=0 border=0>
345   <tr>
346     <td>
347       &nbsp;
348     </td>
349     <td>
350
351 <p>
352 Returns the number of items within a tag. 
353 <p>
354 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.
355 <p>
356 Definition at line <a class="el" href="modules_8cpp-source.html#l00843">843</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
357 <p>
358 References <a class="el" href="modules_8h-source.html#l00843">cache</a>.
359 <p>
360 <div class="fragment"><pre>00844 {
361 00845         <span class="keywordflow">return</span> EnumValues(cache, tag.c_str(), index);
362 00846 }
363 </pre></div>    </td>
364   </tr>
365 </table>
366 <a name="a6" doxytag="ConfigReader::GetError"></a><p>
367 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
368   <tr>
369     <td class="mdRow">
370       <table cellpadding="0" cellspacing="0" border="0">
371         <tr>
372           <td class="md" nowrap valign="top"> long ConfigReader::GetError </td>
373           <td class="md" valign="top">(&nbsp;</td>
374           <td class="mdname1" valign="top" nowrap>          </td>
375           <td class="md" valign="top">&nbsp;)&nbsp;</td>
376           <td class="md" nowrap></td>
377         </tr>
378
379       </table>
380     </td>
381   </tr>
382 </table>
383 <table cellspacing=5 cellpadding=0 border=0>
384   <tr>
385     <td>
386       &nbsp;
387     </td>
388     <td>
389
390 <p>
391 Returns the last error to occur. 
392 <p>
393 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.
394 <p>
395 Definition at line <a class="el" href="modules_8cpp-source.html#l00798">798</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
396 <p>
397 References <a class="el" href="modules_8h-source.html#l00848">error</a>.
398 <p>
399 <div class="fragment"><pre>00799 {
400 00800         <span class="keywordtype">long</span> olderr = this-&gt;<a class="code" href="classConfigReader.html#p3">error</a>;
401 00801         this-&gt;error = 0;
402 00802         <span class="keywordflow">return</span> olderr;
403 00803 }
404 </pre></div>    </td>
405   </tr>
406 </table>
407 <a name="a4" doxytag="ConfigReader::ReadFlag"></a><p>
408 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
409   <tr>
410     <td class="mdRow">
411       <table cellpadding="0" cellspacing="0" border="0">
412         <tr>
413           <td class="md" nowrap valign="top"> bool ConfigReader::ReadFlag </td>
414           <td class="md" valign="top">(&nbsp;</td>
415           <td class="md" nowrap valign="top">std::string&nbsp;</td>
416           <td class="mdname" nowrap> <em>tag</em>, </td>
417         </tr>
418         <tr>
419           <td></td>
420           <td></td>
421           <td class="md" nowrap>std::string&nbsp;</td>
422           <td class="mdname" nowrap> <em>name</em>, </td>
423         </tr>
424         <tr>
425           <td></td>
426           <td></td>
427           <td class="md" nowrap>int&nbsp;</td>
428           <td class="mdname" nowrap> <em>index</em></td>
429         </tr>
430         <tr>
431           <td></td>
432           <td class="md">)&nbsp;</td>
433           <td class="md" colspan="2"></td>
434         </tr>
435
436       </table>
437     </td>
438   </tr>
439 </table>
440 <table cellspacing=5 cellpadding=0 border=0>
441   <tr>
442     <td>
443       &nbsp;
444     </td>
445     <td>
446
447 <p>
448 Retrieves a boolean value from the config file. 
449 <p>
450 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.
451 <p>
452 Definition at line <a class="el" href="modules_8cpp-source.html#l00752">752</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
453 <p>
454 References <a class="el" href="modules_8h-source.html#l00843">cache</a>, <a class="el" href="modules_8h-source.html#l00826">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00848">error</a>.
455 <p>
456 <div class="fragment"><pre>00753 {
457 00754         <span class="keywordtype">char</span> val[MAXBUF];
458 00755         <span class="keywordtype">char</span> t[MAXBUF];
459 00756         <span class="keywordtype">char</span> n[MAXBUF];
460 00757         strlcpy(t,tag.c_str(),MAXBUF);
461 00758         strlcpy(n,name.c_str(),MAXBUF);
462 00759         <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
463 00760         <span class="keywordflow">if</span> (!res)
464 00761         {
465 00762                 this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
466 00763                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
467 00764         }
468 00765         std::string s = val;
469 00766         <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>));
470 00767 }
471 </pre></div>    </td>
472   </tr>
473 </table>
474 <a name="a5" doxytag="ConfigReader::ReadInteger"></a><p>
475 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
476   <tr>
477     <td class="mdRow">
478       <table cellpadding="0" cellspacing="0" border="0">
479         <tr>
480           <td class="md" nowrap valign="top"> long ConfigReader::ReadInteger </td>
481           <td class="md" valign="top">(&nbsp;</td>
482           <td class="md" nowrap valign="top">std::string&nbsp;</td>
483           <td class="mdname" nowrap> <em>tag</em>, </td>
484         </tr>
485         <tr>
486           <td></td>
487           <td></td>
488           <td class="md" nowrap>std::string&nbsp;</td>
489           <td class="mdname" nowrap> <em>name</em>, </td>
490         </tr>
491         <tr>
492           <td></td>
493           <td></td>
494           <td class="md" nowrap>int&nbsp;</td>
495           <td class="mdname" nowrap> <em>index</em>, </td>
496         </tr>
497         <tr>
498           <td></td>
499           <td></td>
500           <td class="md" nowrap>bool&nbsp;</td>
501           <td class="mdname" nowrap> <em>needs_unsigned</em></td>
502         </tr>
503         <tr>
504           <td></td>
505           <td class="md">)&nbsp;</td>
506           <td class="md" colspan="2"></td>
507         </tr>
508
509       </table>
510     </td>
511   </tr>
512 </table>
513 <table cellspacing=5 cellpadding=0 border=0>
514   <tr>
515     <td>
516       &nbsp;
517     </td>
518     <td>
519
520 <p>
521 Retrieves an integer value from the config file. 
522 <p>
523 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
524 <p>
525 Definition at line <a class="el" href="modules_8cpp-source.html#l00769">769</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
526 <p>
527 References <a class="el" href="modules_8h-source.html#l00843">cache</a>, <a class="el" href="modules_8h-source.html#l00824">CONF_NOT_A_NUMBER</a>, <a class="el" href="modules_8h-source.html#l00825">CONF_NOT_UNSIGNED</a>, <a class="el" href="modules_8h-source.html#l00826">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00848">error</a>.
528 <p>
529 <div class="fragment"><pre>00770 {
530 00771         <span class="keywordtype">char</span> val[MAXBUF];
531 00772         <span class="keywordtype">char</span> t[MAXBUF];
532 00773         <span class="keywordtype">char</span> n[MAXBUF];
533 00774         strlcpy(t,tag.c_str(),MAXBUF);
534 00775         strlcpy(n,name.c_str(),MAXBUF);
535 00776         <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
536 00777         <span class="keywordflow">if</span> (!res)
537 00778         {
538 00779                 this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
539 00780                 <span class="keywordflow">return</span> 0;
540 00781         }
541 00782         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; strlen(val); i++)
542 00783         {
543 00784                 <span class="keywordflow">if</span> (!isdigit(val[i]))
544 00785                 {
545 00786                         this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a27">CONF_NOT_A_NUMBER</a>;
546 00787                         <span class="keywordflow">return</span> 0;
547 00788                 }
548 00789         }
549 00790         <span class="keywordflow">if</span> ((needs_unsigned) &amp;&amp; (atoi(val)&lt;0))
550 00791         {
551 00792                 this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a28">CONF_NOT_UNSIGNED</a>;
552 00793                 <span class="keywordflow">return</span> 0;
553 00794         }
554 00795         <span class="keywordflow">return</span> atoi(val);
555 00796 }
556 </pre></div>    </td>
557   </tr>
558 </table>
559 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
560 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
561   <tr>
562     <td class="mdRow">
563       <table cellpadding="0" cellspacing="0" border="0">
564         <tr>
565           <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
566           <td class="md" valign="top">(&nbsp;</td>
567           <td class="md" nowrap valign="top">std::string&nbsp;</td>
568           <td class="mdname" nowrap> <em>tag</em>, </td>
569         </tr>
570         <tr>
571           <td></td>
572           <td></td>
573           <td class="md" nowrap>std::string&nbsp;</td>
574           <td class="mdname" nowrap> <em>name</em>, </td>
575         </tr>
576         <tr>
577           <td></td>
578           <td></td>
579           <td class="md" nowrap>int&nbsp;</td>
580           <td class="mdname" nowrap> <em>index</em></td>
581         </tr>
582         <tr>
583           <td></td>
584           <td class="md">)&nbsp;</td>
585           <td class="md" colspan="2"></td>
586         </tr>
587
588       </table>
589     </td>
590   </tr>
591 </table>
592 <table cellspacing=5 cellpadding=0 border=0>
593   <tr>
594     <td>
595       &nbsp;
596     </td>
597     <td>
598
599 <p>
600 Retrieves a value from the config file. 
601 <p>
602 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.
603 <p>
604 Definition at line <a class="el" href="modules_8cpp-source.html#l00736">736</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
605 <p>
606 References <a class="el" href="modules_8h-source.html#l00843">cache</a>, <a class="el" href="modules_8h-source.html#l00826">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00848">error</a>.
607 <p>
608 <div class="fragment"><pre>00737 {
609 00738         <span class="keywordtype">char</span> val[MAXBUF];
610 00739         <span class="keywordtype">char</span> t[MAXBUF];
611 00740         <span class="keywordtype">char</span> n[MAXBUF];
612 00741         strlcpy(t,tag.c_str(),MAXBUF);
613 00742         strlcpy(n,name.c_str(),MAXBUF);
614 00743         <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
615 00744         <span class="keywordflow">if</span> (!res)
616 00745         {
617 00746                 this-&gt;<a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
618 00747                 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
619 00748         }
620 00749         <span class="keywordflow">return</span> std::string(val);
621 00750 }
622 </pre></div>    </td>
623   </tr>
624 </table>
625 <a name="a8" doxytag="ConfigReader::Verify"></a><p>
626 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
627   <tr>
628     <td class="mdRow">
629       <table cellpadding="0" cellspacing="0" border="0">
630         <tr>
631           <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
632           <td class="md" valign="top">(&nbsp;</td>
633           <td class="mdname1" valign="top" nowrap>          </td>
634           <td class="md" valign="top">&nbsp;)&nbsp;</td>
635           <td class="md" nowrap></td>
636         </tr>
637
638       </table>
639     </td>
640   </tr>
641 </table>
642 <table cellspacing=5 cellpadding=0 border=0>
643   <tr>
644     <td>
645       &nbsp;
646     </td>
647     <td>
648
649 <p>
650 Returns true if a config file is valid. 
651 <p>
652 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
653 <p>
654 Definition at line <a class="el" href="modules_8cpp-source.html#l00848">848</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
655 <p>
656 References <a class="el" href="modules_8h-source.html#l00847">readerror</a>.
657 <p>
658 <div class="fragment"><pre>00849 {
659 00850         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classConfigReader.html#p2">readerror</a>;
660 00851 }
661 </pre></div>    </td>
662   </tr>
663 </table>
664 <hr><h2>Member Data Documentation</h2>
665 <a name="p0" doxytag="ConfigReader::cache"></a><p>
666 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
667   <tr>
668     <td class="mdRow">
669       <table cellpadding="0" cellspacing="0" border="0">
670         <tr>
671           <td class="md" nowrap valign="top"> std::stringstream* <a class="el" href="classConfigReader.html#p0">ConfigReader::cache</a><code> [protected]</code>
672       </table>
673     </td>
674   </tr>
675 </table>
676 <table cellspacing=5 cellpadding=0 border=0>
677   <tr>
678     <td>
679       &nbsp;
680     </td>
681     <td>
682
683 <p>
684 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). 
685 <p>
686 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
687 <p>
688 Definition at line <a class="el" href="modules_8h-source.html#l00843">843</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
689 <p>
690 Referenced by <a class="el" href="modules_8cpp-source.html#l00708">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00838">Enumerate()</a>, <a class="el" href="modules_8cpp-source.html#l00843">EnumerateValues()</a>, <a class="el" href="modules_8cpp-source.html#l00752">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00769">ReadInteger()</a>, <a class="el" href="modules_8cpp-source.html#l00736">ReadValue()</a>, and <a class="el" href="modules_8cpp-source.html#l00718">~ConfigReader()</a>.    </td>
691   </tr>
692 </table>
693 <a name="p3" doxytag="ConfigReader::error"></a><p>
694 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
695   <tr>
696     <td class="mdRow">
697       <table cellpadding="0" cellspacing="0" border="0">
698         <tr>
699           <td class="md" nowrap valign="top"> long <a class="el" href="classConfigReader.html#p3">ConfigReader::error</a><code> [protected]</code>
700       </table>
701     </td>
702   </tr>
703 </table>
704 <table cellspacing=5 cellpadding=0 border=0>
705   <tr>
706     <td>
707       &nbsp;
708     </td>
709     <td>
710
711 <p>
712
713 <p>
714 Definition at line <a class="el" href="modules_8h-source.html#l00848">848</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
715 <p>
716 Referenced by <a class="el" href="modules_8cpp-source.html#l00708">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00798">GetError()</a>, <a class="el" href="modules_8cpp-source.html#l00752">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00769">ReadInteger()</a>, and <a class="el" href="modules_8cpp-source.html#l00736">ReadValue()</a>.    </td>
717   </tr>
718 </table>
719 <a name="p1" doxytag="ConfigReader::errorlog"></a><p>
720 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
721   <tr>
722     <td class="mdRow">
723       <table cellpadding="0" cellspacing="0" border="0">
724         <tr>
725           <td class="md" nowrap valign="top"> std::stringstream* <a class="el" href="classConfigReader.html#p1">ConfigReader::errorlog</a><code> [protected]</code>
726       </table>
727     </td>
728   </tr>
729 </table>
730 <table cellspacing=5 cellpadding=0 border=0>
731   <tr>
732     <td>
733       &nbsp;
734     </td>
735     <td>
736
737 <p>
738
739 <p>
740 Definition at line <a class="el" href="modules_8h-source.html#l00844">844</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
741 <p>
742 Referenced by <a class="el" href="modules_8cpp-source.html#l00708">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00805">DumpErrors()</a>, and <a class="el" href="modules_8cpp-source.html#l00718">~ConfigReader()</a>.    </td>
743   </tr>
744 </table>
745 <a name="p2" doxytag="ConfigReader::readerror"></a><p>
746 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
747   <tr>
748     <td class="mdRow">
749       <table cellpadding="0" cellspacing="0" border="0">
750         <tr>
751           <td class="md" nowrap valign="top"> bool <a class="el" href="classConfigReader.html#p2">ConfigReader::readerror</a><code> [protected]</code>
752       </table>
753     </td>
754   </tr>
755 </table>
756 <table cellspacing=5 cellpadding=0 border=0>
757   <tr>
758     <td>
759       &nbsp;
760     </td>
761     <td>
762
763 <p>
764 Used to store errors. 
765 <p>
766
767 <p>
768 Definition at line <a class="el" href="modules_8h-source.html#l00847">847</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
769 <p>
770 Referenced by <a class="el" href="modules_8cpp-source.html#l00708">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00848">Verify()</a>.    </td>
771   </tr>
772 </table>
773 <hr>The documentation for this class was generated from the following files:<ul>
774 <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>
775 <hr size="1"><address style="align: right;"><small>Generated on Thu Apr 14 21:12:08 2005 for InspIRCd by
776 <a href="http://www.doxygen.org/index.html">
777 <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
778 </a>1.3.3 </small></address>
779 </body>
780 </html>