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">
6 <!-- Generated by Doxygen 1.3.3 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Compound List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Compound Members</a> | <a class="qindex" href="globals.html">File 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>
11 <code>#include <<a class="el" href="modules_8h-source.html">modules.h</a>></code>
13 Inherits <a class="el" href="classclassbase.html">classbase</a>.
15 <a href="classConfigReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
17 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
18 <tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a0">ConfigReader</a> ()</td></tr>
20 <tr><td class="mdescLeft"> </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> </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a1">ConfigReader</a> (std::string filename)</td></tr>
23 <tr><td class="mdescLeft"> </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> </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a2">~ConfigReader</a> ()</td></tr>
26 <tr><td class="mdescLeft"> </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 </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>
29 <tr><td class="mdescLeft"> </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 </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>
32 <tr><td class="mdescLeft"> </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 </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>
35 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a6">GetError</a> ()</td></tr>
38 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a7">Enumerate</a> (std::string tag)</td></tr>
41 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a8">Verify</a> ()</td></tr>
44 <tr><td class="mdescLeft"> </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 </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>
47 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#a10">EnumerateValues</a> (std::string tag, int index)</td></tr>
50 <tr><td class="mdescLeft"> </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 * </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p0">cache</a></td></tr>
54 <tr><td class="mdescLeft"> </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 * </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p1">errorlog</a></td></tr>
57 <tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p2">readerror</a></td></tr>
59 <tr><td class="mdescLeft"> </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 </td><td class="memItemRight" valign=bottom><a class="el" href="classConfigReader.html#p3">error</a></td></tr>
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.
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.
70 Definition at line <a class="el" href="modules_8h-source.html#l00790">790</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
71 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
72 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
75 <table cellpadding="0" cellspacing="0" border="0">
77 <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
78 <td class="md" valign="top">( </td>
79 <td class="mdname1" valign="top" nowrap> </td>
80 <td class="md" valign="top"> ) </td>
81 <td class="md" nowrap></td>
88 <table cellspacing=5 cellpadding=0 border=0>
98 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
100 Definition at line <a class="el" href="modules_8cpp-source.html#l00675">675</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
102 References <a class="el" href="modules_8h-source.html#l00798">cache</a>, <a class="el" href="modules_8h-source.html#l00782">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l00803">error</a>, <a class="el" href="modules_8h-source.html#l00799">errorlog</a>, and <a class="el" href="modules_8h-source.html#l00802">readerror</a>.
104 <div class="fragment"><pre>00676 {
105 00677 this-><a class="code" href="classConfigReader.html#p0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
106 00678 this-><a class="code" href="classConfigReader.html#p1">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
107 00679 this-><a class="code" href="classConfigReader.html#p2">readerror</a> = LoadConf(CONFIG_FILE,this->cache,this->errorlog);
108 00680 <span class="keywordflow">if</span> (!this-><a class="code" href="classConfigReader.html#p2">readerror</a>)
109 00681 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a30">CONF_FILE_NOT_FOUND</a>;
114 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
115 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
118 <table cellpadding="0" cellspacing="0" border="0">
120 <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
121 <td class="md" valign="top">( </td>
122 <td class="md" nowrap valign="top">std::string </td>
123 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
124 <td class="md" valign="top"> ) </td>
125 <td class="md" nowrap></td>
132 <table cellspacing=5 cellpadding=0 border=0>
140 Overloaded constructor.
142 This constructor initialises the ConfigReader class to read a user-specified config file
144 Definition at line <a class="el" href="modules_8cpp-source.html#l00694">694</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
146 References <a class="el" href="modules_8h-source.html#l00798">cache</a>, <a class="el" href="modules_8h-source.html#l00782">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l00803">error</a>, <a class="el" href="modules_8h-source.html#l00799">errorlog</a>, and <a class="el" href="modules_8h-source.html#l00802">readerror</a>.
148 <div class="fragment"><pre>00695 {
149 00696 this-><a class="code" href="classConfigReader.html#p0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
150 00697 this-><a class="code" href="classConfigReader.html#p1">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
151 00698 this-><a class="code" href="classConfigReader.html#p2">readerror</a> = LoadConf(filename.c_str(),this-><a class="code" href="classConfigReader.html#p0">cache</a>,this-><a class="code" href="classConfigReader.html#p1">errorlog</a>);
152 00699 <span class="keywordflow">if</span> (!this-><a class="code" href="classConfigReader.html#p2">readerror</a>)
153 00700 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a30">CONF_FILE_NOT_FOUND</a>;
158 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
159 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
162 <table cellpadding="0" cellspacing="0" border="0">
164 <td class="md" nowrap valign="top"> ConfigReader::~<a class="el" href="classConfigReader.html">ConfigReader</a> </td>
165 <td class="md" valign="top">( </td>
166 <td class="mdname1" valign="top" nowrap> </td>
167 <td class="md" valign="top"> ) </td>
168 <td class="md" nowrap></td>
175 <table cellspacing=5 cellpadding=0 border=0>
185 This method destroys the ConfigReader class.
187 Definition at line <a class="el" href="modules_8cpp-source.html#l00685">685</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
189 References <a class="el" href="modules_8h-source.html#l00798">cache</a>, and <a class="el" href="modules_8h-source.html#l00799">errorlog</a>.
191 <div class="fragment"><pre>00686 {
192 00687 <span class="keywordflow">if</span> (this-><a class="code" href="classConfigReader.html#p0">cache</a>)
193 00688 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#p0">cache</a>;
194 00689 <span class="keywordflow">if</span> (this-><a class="code" href="classConfigReader.html#p1">errorlog</a>)
195 00690 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#p1">errorlog</a>;
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">
205 <table cellpadding="0" cellspacing="0" border="0">
207 <td class="md" nowrap valign="top"> void ConfigReader::DumpErrors </td>
208 <td class="md" valign="top">( </td>
209 <td class="md" nowrap valign="top">bool </td>
210 <td class="mdname" nowrap> <em>bail</em>, </td>
215 <td class="md" nowrap><a class="el" href="classuserrec.html">userrec</a> * </td>
216 <td class="mdname" nowrap> <em>user</em></td>
220 <td class="md">) </td>
221 <td class="md" colspan="2"></td>
228 <table cellspacing=5 cellpadding=0 border=0>
236 Dumps the list of errors in a config file to an output location.
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.
240 Definition at line <a class="el" href="modules_8cpp-source.html#l00772">772</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
242 References <a class="el" href="modules_8h-source.html#l00799">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>.
244 <div class="fragment"><pre>00773 {
245 00774 <span class="keywordflow">if</span> (bail)
247 00776 printf(<span class="stringliteral">"There were errors in your configuration:\n%s"</span>,<a class="code" href="classConfigReader.html#p1">errorlog</a>->str().c_str());
250 00779 <span class="keywordflow">else</span>
252 00781 <span class="keywordtype">char</span> dataline[1024];
253 00782 <span class="keywordflow">if</span> (user)
255 00784 WriteServ(user-><a class="code" href="classconnection.html#o0">fd</a>,<span class="stringliteral">"NOTICE %s :There were errors in the configuration file:"</span>,user-><a class="code" href="classuserrec.html#o0">nick</a>);
256 00785 <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#p1">errorlog</a>->eof())
258 00787 <a class="code" href="classConfigReader.html#p1">errorlog</a>->getline(dataline,1024);
259 00788 WriteServ(user-><a class="code" href="classconnection.html#o0">fd</a>,<span class="stringliteral">"NOTICE %s :%s"</span>,user-><a class="code" href="classuserrec.html#o0">nick</a>,dataline);
262 00791 <span class="keywordflow">else</span>
264 00793 WriteOpers(<span class="stringliteral">"There were errors in the configuration file:"</span>,user-><a class="code" href="classuserrec.html#o0">nick</a>);
265 00794 <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#p1">errorlog</a>->eof())
267 00796 <a class="code" href="classConfigReader.html#p1">errorlog</a>->getline(dataline,1024);
268 00797 WriteOpers(dataline);
271 00800 <span class="keywordflow">return</span>;
277 <a name="a7" doxytag="ConfigReader::Enumerate"></a><p>
278 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
281 <table cellpadding="0" cellspacing="0" border="0">
283 <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
284 <td class="md" valign="top">( </td>
285 <td class="md" nowrap valign="top">std::string </td>
286 <td class="mdname1" valign="top" nowrap> <em>tag</em> </td>
287 <td class="md" valign="top"> ) </td>
288 <td class="md" nowrap></td>
295 <table cellspacing=5 cellpadding=0 border=0>
303 Counts the number of times a given tag appears in the config file.
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.
307 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>.
309 References <a class="el" href="modules_8h-source.html#l00798">cache</a>.
311 <div class="fragment"><pre>00806 {
312 00807 <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
317 <a name="a10" doxytag="ConfigReader::EnumerateValues"></a><p>
318 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
321 <table cellpadding="0" cellspacing="0" border="0">
323 <td class="md" nowrap valign="top"> int ConfigReader::EnumerateValues </td>
324 <td class="md" valign="top">( </td>
325 <td class="md" nowrap valign="top">std::string </td>
326 <td class="mdname" nowrap> <em>tag</em>, </td>
331 <td class="md" nowrap>int </td>
332 <td class="mdname" nowrap> <em>index</em></td>
336 <td class="md">) </td>
337 <td class="md" colspan="2"></td>
344 <table cellspacing=5 cellpadding=0 border=0>
352 Returns the number of items within a tag.
354 For example if the tag was <test tag="blah" data="foo"> then this function would return 2. Spaces and newlines both qualify as valid seperators between values.
356 Definition at line <a class="el" href="modules_8cpp-source.html#l00810">810</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
358 References <a class="el" href="modules_8h-source.html#l00798">cache</a>.
360 <div class="fragment"><pre>00811 {
361 00812 <span class="keywordflow">return</span> EnumValues(cache, tag.c_str(), index);
366 <a name="a6" doxytag="ConfigReader::GetError"></a><p>
367 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
370 <table cellpadding="0" cellspacing="0" border="0">
372 <td class="md" nowrap valign="top"> long ConfigReader::GetError </td>
373 <td class="md" valign="top">( </td>
374 <td class="mdname1" valign="top" nowrap> </td>
375 <td class="md" valign="top"> ) </td>
376 <td class="md" nowrap></td>
383 <table cellspacing=5 cellpadding=0 border=0>
391 Returns the last error to occur.
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.
395 Definition at line <a class="el" href="modules_8cpp-source.html#l00765">765</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
397 References <a class="el" href="modules_8h-source.html#l00803">error</a>.
399 <div class="fragment"><pre>00766 {
400 00767 <span class="keywordtype">long</span> olderr = this-><a class="code" href="classConfigReader.html#p3">error</a>;
401 00768 this->error = 0;
402 00769 <span class="keywordflow">return</span> olderr;
407 <a name="a4" doxytag="ConfigReader::ReadFlag"></a><p>
408 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
411 <table cellpadding="0" cellspacing="0" border="0">
413 <td class="md" nowrap valign="top"> bool ConfigReader::ReadFlag </td>
414 <td class="md" valign="top">( </td>
415 <td class="md" nowrap valign="top">std::string </td>
416 <td class="mdname" nowrap> <em>tag</em>, </td>
421 <td class="md" nowrap>std::string </td>
422 <td class="mdname" nowrap> <em>name</em>, </td>
427 <td class="md" nowrap>int </td>
428 <td class="mdname" nowrap> <em>index</em></td>
432 <td class="md">) </td>
433 <td class="md" colspan="2"></td>
440 <table cellspacing=5 cellpadding=0 border=0>
448 Retrieves a boolean value from the config file.
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.
452 Definition at line <a class="el" href="modules_8cpp-source.html#l00719">719</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
454 References <a class="el" href="modules_8h-source.html#l00798">cache</a>, <a class="el" href="modules_8h-source.html#l00781">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00803">error</a>.
456 <div class="fragment"><pre>00720 {
457 00721 <span class="keywordtype">char</span> val[MAXBUF];
458 00722 <span class="keywordtype">char</span> t[MAXBUF];
459 00723 <span class="keywordtype">char</span> n[MAXBUF];
460 00724 strlcpy(t,tag.c_str(),MAXBUF);
461 00725 strlcpy(n,name.c_str(),MAXBUF);
462 00726 <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
463 00727 <span class="keywordflow">if</span> (!res)
465 00729 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
466 00730 <span class="keywordflow">return</span> <span class="keyword">false</span>;
468 00732 std::string s = val;
469 00733 <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>));
474 <a name="a5" doxytag="ConfigReader::ReadInteger"></a><p>
475 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
478 <table cellpadding="0" cellspacing="0" border="0">
480 <td class="md" nowrap valign="top"> long ConfigReader::ReadInteger </td>
481 <td class="md" valign="top">( </td>
482 <td class="md" nowrap valign="top">std::string </td>
483 <td class="mdname" nowrap> <em>tag</em>, </td>
488 <td class="md" nowrap>std::string </td>
489 <td class="mdname" nowrap> <em>name</em>, </td>
494 <td class="md" nowrap>int </td>
495 <td class="mdname" nowrap> <em>index</em>, </td>
500 <td class="md" nowrap>bool </td>
501 <td class="mdname" nowrap> <em>needs_unsigned</em></td>
505 <td class="md">) </td>
506 <td class="md" colspan="2"></td>
513 <table cellspacing=5 cellpadding=0 border=0>
521 Retrieves an integer value from the config file.
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
525 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>.
527 References <a class="el" href="modules_8h-source.html#l00798">cache</a>, <a class="el" href="modules_8h-source.html#l00779">CONF_NOT_A_NUMBER</a>, <a class="el" href="modules_8h-source.html#l00780">CONF_NOT_UNSIGNED</a>, <a class="el" href="modules_8h-source.html#l00781">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00803">error</a>.
529 <div class="fragment"><pre>00737 {
530 00738 <span class="keywordtype">char</span> val[MAXBUF];
531 00739 <span class="keywordtype">char</span> t[MAXBUF];
532 00740 <span class="keywordtype">char</span> n[MAXBUF];
533 00741 strlcpy(t,tag.c_str(),MAXBUF);
534 00742 strlcpy(n,name.c_str(),MAXBUF);
535 00743 <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
536 00744 <span class="keywordflow">if</span> (!res)
538 00746 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
539 00747 <span class="keywordflow">return</span> 0;
541 00749 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < strlen(val); i++)
543 00751 <span class="keywordflow">if</span> (!isdigit(val[i]))
545 00753 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a27">CONF_NOT_A_NUMBER</a>;
546 00754 <span class="keywordflow">return</span> 0;
549 00757 <span class="keywordflow">if</span> ((needs_unsigned) && (atoi(val)<0))
551 00759 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a28">CONF_NOT_UNSIGNED</a>;
552 00760 <span class="keywordflow">return</span> 0;
554 00762 <span class="keywordflow">return</span> atoi(val);
559 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
560 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
563 <table cellpadding="0" cellspacing="0" border="0">
565 <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
566 <td class="md" valign="top">( </td>
567 <td class="md" nowrap valign="top">std::string </td>
568 <td class="mdname" nowrap> <em>tag</em>, </td>
573 <td class="md" nowrap>std::string </td>
574 <td class="mdname" nowrap> <em>name</em>, </td>
579 <td class="md" nowrap>int </td>
580 <td class="mdname" nowrap> <em>index</em></td>
584 <td class="md">) </td>
585 <td class="md" colspan="2"></td>
592 <table cellspacing=5 cellpadding=0 border=0>
600 Retrieves a value from the config file.
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.
604 Definition at line <a class="el" href="modules_8cpp-source.html#l00703">703</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
606 References <a class="el" href="modules_8h-source.html#l00798">cache</a>, <a class="el" href="modules_8h-source.html#l00781">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l00803">error</a>.
608 <div class="fragment"><pre>00704 {
609 00705 <span class="keywordtype">char</span> val[MAXBUF];
610 00706 <span class="keywordtype">char</span> t[MAXBUF];
611 00707 <span class="keywordtype">char</span> n[MAXBUF];
612 00708 strlcpy(t,tag.c_str(),MAXBUF);
613 00709 strlcpy(n,name.c_str(),MAXBUF);
614 00710 <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
615 00711 <span class="keywordflow">if</span> (!res)
617 00713 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
618 00714 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
620 00716 <span class="keywordflow">return</span> std::string(val);
625 <a name="a8" doxytag="ConfigReader::Verify"></a><p>
626 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
629 <table cellpadding="0" cellspacing="0" border="0">
631 <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
632 <td class="md" valign="top">( </td>
633 <td class="mdname1" valign="top" nowrap> </td>
634 <td class="md" valign="top"> ) </td>
635 <td class="md" nowrap></td>
642 <table cellspacing=5 cellpadding=0 border=0>
650 Returns true if a config file is valid.
652 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
654 Definition at line <a class="el" href="modules_8cpp-source.html#l00815">815</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
656 References <a class="el" href="modules_8h-source.html#l00802">readerror</a>.
658 <div class="fragment"><pre>00816 {
659 00817 <span class="keywordflow">return</span> this-><a class="code" href="classConfigReader.html#p2">readerror</a>;
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">
669 <table cellpadding="0" cellspacing="0" border="0">
671 <td class="md" nowrap valign="top"> std::stringstream* <a class="el" href="classConfigReader.html#p0">ConfigReader::cache</a><code> [protected]</code>
676 <table cellspacing=5 cellpadding=0 border=0>
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).
686 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
688 Definition at line <a class="el" href="modules_8h-source.html#l00798">798</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
690 Referenced by <a class="el" href="modules_8cpp-source.html#l00675">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00805">Enumerate()</a>, <a class="el" href="modules_8cpp-source.html#l00810">EnumerateValues()</a>, <a class="el" href="modules_8cpp-source.html#l00719">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00736">ReadInteger()</a>, <a class="el" href="modules_8cpp-source.html#l00703">ReadValue()</a>, and <a class="el" href="modules_8cpp-source.html#l00685">~ConfigReader()</a>. </td>
693 <a name="p3" doxytag="ConfigReader::error"></a><p>
694 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
697 <table cellpadding="0" cellspacing="0" border="0">
699 <td class="md" nowrap valign="top"> long <a class="el" href="classConfigReader.html#p3">ConfigReader::error</a><code> [protected]</code>
704 <table cellspacing=5 cellpadding=0 border=0>
714 Definition at line <a class="el" href="modules_8h-source.html#l00803">803</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
716 Referenced by <a class="el" href="modules_8cpp-source.html#l00675">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00765">GetError()</a>, <a class="el" href="modules_8cpp-source.html#l00719">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00736">ReadInteger()</a>, and <a class="el" href="modules_8cpp-source.html#l00703">ReadValue()</a>. </td>
719 <a name="p1" doxytag="ConfigReader::errorlog"></a><p>
720 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
723 <table cellpadding="0" cellspacing="0" border="0">
725 <td class="md" nowrap valign="top"> std::stringstream* <a class="el" href="classConfigReader.html#p1">ConfigReader::errorlog</a><code> [protected]</code>
730 <table cellspacing=5 cellpadding=0 border=0>
740 Definition at line <a class="el" href="modules_8h-source.html#l00799">799</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
742 Referenced by <a class="el" href="modules_8cpp-source.html#l00675">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00772">DumpErrors()</a>, and <a class="el" href="modules_8cpp-source.html#l00685">~ConfigReader()</a>. </td>
745 <a name="p2" doxytag="ConfigReader::readerror"></a><p>
746 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
749 <table cellpadding="0" cellspacing="0" border="0">
751 <td class="md" nowrap valign="top"> bool <a class="el" href="classConfigReader.html#p2">ConfigReader::readerror</a><code> [protected]</code>
756 <table cellspacing=5 cellpadding=0 border=0>
764 Used to store errors.
768 Definition at line <a class="el" href="modules_8h-source.html#l00802">802</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
770 Referenced by <a class="el" href="modules_8cpp-source.html#l00675">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00815">Verify()</a>. </td>
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 Wed Apr 13 13:07:02 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>