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 Inheritance diagram for ConfigReader:<p><center><img src="classConfigReader__inherit__graph.gif" border="0" usemap="#ConfigReader__inherit__map" alt="Inheritance graph"></center>
14 <map name="ConfigReader__inherit__map">
15 <area href="classclassbase.html" shape="rect" coords="20,7,100,34" alt="">
17 <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>
18 <map name="ConfigReader__coll__map">
19 <area href="classclassbase.html" shape="rect" coords="7,98,87,125" alt="">
21 <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 colspan=2><br><h2>Public Member Functions</h2></td></tr>
24 <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>
26 <tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. </em> <a href="#a0"></a><em><br><br></td></tr>
27 <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>
29 <tr><td class="mdescLeft"> </td><td class="mdescRight">Overloaded constructor. </em> <a href="#a1"></a><em><br><br></td></tr>
30 <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>
32 <tr><td class="mdescLeft"> </td><td class="mdescRight">Default destructor. </em> <a href="#a2"></a><em><br><br></td></tr>
33 <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>
35 <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>
36 <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>
38 <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>
39 <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>
41 <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>
42 <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>
44 <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the last error to occur. </em> <a href="#a6"></a><em><br><br></td></tr>
45 <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>
47 <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>
48 <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>
50 <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>
51 <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>
53 <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>
54 <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>
56 <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>
57 <tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
58 <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>
60 <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>
61 <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>
63 <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>
65 <tr><td class="mdescLeft"> </td><td class="mdescRight">Used to store errors. </em> <a href="#p2"></a><em><br><br></td></tr>
66 <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>
69 <hr><a name="_details"></a><h2>Detailed Description</h2>
70 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.
72 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.
76 Definition at line <a class="el" href="modules_8h-source.html#l01147">1147</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
77 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
78 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
81 <table cellpadding="0" cellspacing="0" border="0">
83 <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
84 <td class="md" valign="top">( </td>
85 <td class="mdname1" valign="top" nowrap> </td>
86 <td class="md" valign="top"> ) </td>
87 <td class="md" nowrap></td>
94 <table cellspacing=5 cellpadding=0 border=0>
104 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
106 Definition at line <a class="el" href="modules_8cpp-source.html#l00870">870</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
108 References <a class="el" href="modules_8h-source.html#l01155">cache</a>, <a class="el" href="modules_8h-source.html#l01138">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l01160">error</a>, <a class="el" href="modules_8h-source.html#l01156">errorlog</a>, and <a class="el" href="modules_8h-source.html#l01159">readerror</a>.
110 <div class="fragment"><pre>00871 {
111 00872 this-><a class="code" href="classConfigReader.html#p0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
112 00873 this-><a class="code" href="classConfigReader.html#p1">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
113 00874 this-><a class="code" href="classConfigReader.html#p2">readerror</a> = LoadConf(CONFIG_FILE,this->cache,this->errorlog);
114 00875 <span class="keywordflow">if</span> (!this-><a class="code" href="classConfigReader.html#p2">readerror</a>)
115 00876 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a30">CONF_FILE_NOT_FOUND</a>;
120 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
121 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
124 <table cellpadding="0" cellspacing="0" border="0">
126 <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
127 <td class="md" valign="top">( </td>
128 <td class="md" nowrap valign="top">std::string </td>
129 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
130 <td class="md" valign="top"> ) </td>
131 <td class="md" nowrap></td>
138 <table cellspacing=5 cellpadding=0 border=0>
146 Overloaded constructor.
148 This constructor initialises the ConfigReader class to read a user-specified config file
150 Definition at line <a class="el" href="modules_8cpp-source.html#l00889">889</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
152 References <a class="el" href="modules_8h-source.html#l01155">cache</a>, <a class="el" href="modules_8h-source.html#l01138">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l01160">error</a>, <a class="el" href="modules_8h-source.html#l01156">errorlog</a>, and <a class="el" href="modules_8h-source.html#l01159">readerror</a>.
154 <div class="fragment"><pre>00890 {
155 00891 this-><a class="code" href="classConfigReader.html#p0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
156 00892 this-><a class="code" href="classConfigReader.html#p1">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
157 00893 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>);
158 00894 <span class="keywordflow">if</span> (!this-><a class="code" href="classConfigReader.html#p2">readerror</a>)
159 00895 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a30">CONF_FILE_NOT_FOUND</a>;
164 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
165 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
168 <table cellpadding="0" cellspacing="0" border="0">
170 <td class="md" nowrap valign="top"> ConfigReader::~<a class="el" href="classConfigReader.html">ConfigReader</a> </td>
171 <td class="md" valign="top">( </td>
172 <td class="mdname1" valign="top" nowrap> </td>
173 <td class="md" valign="top"> ) </td>
174 <td class="md" nowrap></td>
181 <table cellspacing=5 cellpadding=0 border=0>
191 This method destroys the ConfigReader class.
193 Definition at line <a class="el" href="modules_8cpp-source.html#l00880">880</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
195 References <a class="el" href="modules_8h-source.html#l01155">cache</a>, and <a class="el" href="modules_8h-source.html#l01156">errorlog</a>.
197 <div class="fragment"><pre>00881 {
198 00882 <span class="keywordflow">if</span> (this-><a class="code" href="classConfigReader.html#p0">cache</a>)
199 00883 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#p0">cache</a>;
200 00884 <span class="keywordflow">if</span> (this-><a class="code" href="classConfigReader.html#p1">errorlog</a>)
201 00885 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#p1">errorlog</a>;
206 <hr><h2>Member Function Documentation</h2>
207 <a name="a9" doxytag="ConfigReader::DumpErrors"></a><p>
208 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
211 <table cellpadding="0" cellspacing="0" border="0">
213 <td class="md" nowrap valign="top"> void ConfigReader::DumpErrors </td>
214 <td class="md" valign="top">( </td>
215 <td class="md" nowrap valign="top">bool </td>
216 <td class="mdname" nowrap> <em>bail</em>, </td>
221 <td class="md" nowrap><a class="el" href="classuserrec.html">userrec</a> * </td>
222 <td class="mdname" nowrap> <em>user</em></td>
226 <td class="md">) </td>
227 <td class="md" colspan="2"></td>
234 <table cellspacing=5 cellpadding=0 border=0>
242 Dumps the list of errors in a config file to an output location.
244 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.
246 Definition at line <a class="el" href="modules_8cpp-source.html#l00967">967</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
248 References <a class="el" href="modules_8h-source.html#l01156">errorlog</a>, <a class="el" href="connection_8h-source.html#l00215">connection::fd</a>, and <a class="el" href="users_8h-source.html#l00121">userrec::nick</a>.
250 <div class="fragment"><pre>00968 {
251 00969 <span class="keywordflow">if</span> (bail)
253 00971 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());
256 00974 <span class="keywordflow">else</span>
258 00976 <span class="keywordtype">char</span> dataline[1024];
259 00977 <span class="keywordflow">if</span> (user)
261 00979 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>);
262 00980 <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#p1">errorlog</a>->eof())
264 00982 <a class="code" href="classConfigReader.html#p1">errorlog</a>->getline(dataline,1024);
265 00983 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);
268 00986 <span class="keywordflow">else</span>
270 00988 WriteOpers(<span class="stringliteral">"There were errors in the configuration file:"</span>,user-><a class="code" href="classuserrec.html#o0">nick</a>);
271 00989 <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#p1">errorlog</a>->eof())
273 00991 <a class="code" href="classConfigReader.html#p1">errorlog</a>->getline(dataline,1024);
274 00992 WriteOpers(dataline);
277 00995 <span class="keywordflow">return</span>;
283 <a name="a7" doxytag="ConfigReader::Enumerate"></a><p>
284 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
287 <table cellpadding="0" cellspacing="0" border="0">
289 <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
290 <td class="md" valign="top">( </td>
291 <td class="md" nowrap valign="top">std::string </td>
292 <td class="mdname1" valign="top" nowrap> <em>tag</em> </td>
293 <td class="md" valign="top"> ) </td>
294 <td class="md" nowrap></td>
301 <table cellspacing=5 cellpadding=0 border=0>
309 Counts the number of times a given tag appears in the config file.
311 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.
313 Definition at line <a class="el" href="modules_8cpp-source.html#l01000">1000</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
315 References <a class="el" href="modules_8h-source.html#l01155">cache</a>.
317 <div class="fragment"><pre>01001 {
318 01002 <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
323 <a name="a10" doxytag="ConfigReader::EnumerateValues"></a><p>
324 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
327 <table cellpadding="0" cellspacing="0" border="0">
329 <td class="md" nowrap valign="top"> int ConfigReader::EnumerateValues </td>
330 <td class="md" valign="top">( </td>
331 <td class="md" nowrap valign="top">std::string </td>
332 <td class="mdname" nowrap> <em>tag</em>, </td>
337 <td class="md" nowrap>int </td>
338 <td class="mdname" nowrap> <em>index</em></td>
342 <td class="md">) </td>
343 <td class="md" colspan="2"></td>
350 <table cellspacing=5 cellpadding=0 border=0>
358 Returns the number of items within a tag.
360 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.
362 Definition at line <a class="el" href="modules_8cpp-source.html#l01005">1005</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
364 References <a class="el" href="modules_8h-source.html#l01155">cache</a>.
366 <div class="fragment"><pre>01006 {
367 01007 <span class="keywordflow">return</span> EnumValues(cache, tag.c_str(), index);
372 <a name="a6" doxytag="ConfigReader::GetError"></a><p>
373 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
376 <table cellpadding="0" cellspacing="0" border="0">
378 <td class="md" nowrap valign="top"> long ConfigReader::GetError </td>
379 <td class="md" valign="top">( </td>
380 <td class="mdname1" valign="top" nowrap> </td>
381 <td class="md" valign="top"> ) </td>
382 <td class="md" nowrap></td>
389 <table cellspacing=5 cellpadding=0 border=0>
397 Returns the last error to occur.
399 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.
401 Definition at line <a class="el" href="modules_8cpp-source.html#l00960">960</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
403 References <a class="el" href="modules_8h-source.html#l01160">error</a>.
405 <div class="fragment"><pre>00961 {
406 00962 <span class="keywordtype">long</span> olderr = this-><a class="code" href="classConfigReader.html#p3">error</a>;
407 00963 this->error = 0;
408 00964 <span class="keywordflow">return</span> olderr;
413 <a name="a4" doxytag="ConfigReader::ReadFlag"></a><p>
414 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
417 <table cellpadding="0" cellspacing="0" border="0">
419 <td class="md" nowrap valign="top"> bool ConfigReader::ReadFlag </td>
420 <td class="md" valign="top">( </td>
421 <td class="md" nowrap valign="top">std::string </td>
422 <td class="mdname" nowrap> <em>tag</em>, </td>
427 <td class="md" nowrap>std::string </td>
428 <td class="mdname" nowrap> <em>name</em>, </td>
433 <td class="md" nowrap>int </td>
434 <td class="mdname" nowrap> <em>index</em></td>
438 <td class="md">) </td>
439 <td class="md" colspan="2"></td>
446 <table cellspacing=5 cellpadding=0 border=0>
454 Retrieves a boolean value from the config file.
456 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.
458 Definition at line <a class="el" href="modules_8cpp-source.html#l00914">914</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
460 References <a class="el" href="modules_8h-source.html#l01155">cache</a>, <a class="el" href="modules_8h-source.html#l01137">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l01160">error</a>.
462 <div class="fragment"><pre>00915 {
463 00916 <span class="keywordtype">char</span> val[MAXBUF];
464 00917 <span class="keywordtype">char</span> t[MAXBUF];
465 00918 <span class="keywordtype">char</span> n[MAXBUF];
466 00919 strlcpy(t,tag.c_str(),MAXBUF);
467 00920 strlcpy(n,name.c_str(),MAXBUF);
468 00921 <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
469 00922 <span class="keywordflow">if</span> (!res)
471 00924 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
472 00925 <span class="keywordflow">return</span> <span class="keyword">false</span>;
474 00927 std::string s = val;
475 00928 <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>));
480 <a name="a5" doxytag="ConfigReader::ReadInteger"></a><p>
481 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
484 <table cellpadding="0" cellspacing="0" border="0">
486 <td class="md" nowrap valign="top"> long ConfigReader::ReadInteger </td>
487 <td class="md" valign="top">( </td>
488 <td class="md" nowrap valign="top">std::string </td>
489 <td class="mdname" nowrap> <em>tag</em>, </td>
494 <td class="md" nowrap>std::string </td>
495 <td class="mdname" nowrap> <em>name</em>, </td>
500 <td class="md" nowrap>int </td>
501 <td class="mdname" nowrap> <em>index</em>, </td>
506 <td class="md" nowrap>bool </td>
507 <td class="mdname" nowrap> <em>needs_unsigned</em></td>
511 <td class="md">) </td>
512 <td class="md" colspan="2"></td>
519 <table cellspacing=5 cellpadding=0 border=0>
527 Retrieves an integer value from the config file.
529 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
531 Definition at line <a class="el" href="modules_8cpp-source.html#l00931">931</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
533 References <a class="el" href="modules_8h-source.html#l01155">cache</a>, <a class="el" href="modules_8h-source.html#l01135">CONF_NOT_A_NUMBER</a>, <a class="el" href="modules_8h-source.html#l01136">CONF_NOT_UNSIGNED</a>, <a class="el" href="modules_8h-source.html#l01137">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l01160">error</a>.
535 <div class="fragment"><pre>00932 {
536 00933 <span class="keywordtype">char</span> val[MAXBUF];
537 00934 <span class="keywordtype">char</span> t[MAXBUF];
538 00935 <span class="keywordtype">char</span> n[MAXBUF];
539 00936 strlcpy(t,tag.c_str(),MAXBUF);
540 00937 strlcpy(n,name.c_str(),MAXBUF);
541 00938 <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
542 00939 <span class="keywordflow">if</span> (!res)
544 00941 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
545 00942 <span class="keywordflow">return</span> 0;
547 00944 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < strlen(val); i++)
549 00946 <span class="keywordflow">if</span> (!isdigit(val[i]))
551 00948 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a27">CONF_NOT_A_NUMBER</a>;
552 00949 <span class="keywordflow">return</span> 0;
555 00952 <span class="keywordflow">if</span> ((needs_unsigned) && (atoi(val)<0))
557 00954 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a28">CONF_NOT_UNSIGNED</a>;
558 00955 <span class="keywordflow">return</span> 0;
560 00957 <span class="keywordflow">return</span> atoi(val);
565 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
566 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
569 <table cellpadding="0" cellspacing="0" border="0">
571 <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
572 <td class="md" valign="top">( </td>
573 <td class="md" nowrap valign="top">std::string </td>
574 <td class="mdname" nowrap> <em>tag</em>, </td>
579 <td class="md" nowrap>std::string </td>
580 <td class="mdname" nowrap> <em>name</em>, </td>
585 <td class="md" nowrap>int </td>
586 <td class="mdname" nowrap> <em>index</em></td>
590 <td class="md">) </td>
591 <td class="md" colspan="2"></td>
598 <table cellspacing=5 cellpadding=0 border=0>
606 Retrieves a value from the config file.
608 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.
610 Definition at line <a class="el" href="modules_8cpp-source.html#l00898">898</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
612 References <a class="el" href="modules_8h-source.html#l01155">cache</a>, <a class="el" href="modules_8h-source.html#l01137">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l01160">error</a>.
614 <div class="fragment"><pre>00899 {
615 00900 <span class="keywordtype">char</span> val[MAXBUF];
616 00901 <span class="keywordtype">char</span> t[MAXBUF];
617 00902 <span class="keywordtype">char</span> n[MAXBUF];
618 00903 strlcpy(t,tag.c_str(),MAXBUF);
619 00904 strlcpy(n,name.c_str(),MAXBUF);
620 00905 <span class="keywordtype">int</span> res = ReadConf(cache,t,n,index,val);
621 00906 <span class="keywordflow">if</span> (!res)
623 00908 this-><a class="code" href="classConfigReader.html#p3">error</a> = <a class="code" href="modules_8h.html#a29">CONF_VALUE_NOT_FOUND</a>;
624 00909 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
626 00911 <span class="keywordflow">return</span> val;
631 <a name="a8" doxytag="ConfigReader::Verify"></a><p>
632 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
635 <table cellpadding="0" cellspacing="0" border="0">
637 <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
638 <td class="md" valign="top">( </td>
639 <td class="mdname1" valign="top" nowrap> </td>
640 <td class="md" valign="top"> ) </td>
641 <td class="md" nowrap></td>
648 <table cellspacing=5 cellpadding=0 border=0>
656 Returns true if a config file is valid.
658 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
660 Definition at line <a class="el" href="modules_8cpp-source.html#l01010">1010</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
662 References <a class="el" href="modules_8h-source.html#l01159">readerror</a>.
664 <div class="fragment"><pre>01011 {
665 01012 <span class="keywordflow">return</span> this-><a class="code" href="classConfigReader.html#p2">readerror</a>;
670 <hr><h2>Member Data Documentation</h2>
671 <a name="p0" doxytag="ConfigReader::cache"></a><p>
672 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
675 <table cellpadding="0" cellspacing="0" border="0">
677 <td class="md" nowrap valign="top"> std::stringstream* <a class="el" href="classConfigReader.html#p0">ConfigReader::cache</a><code> [protected]</code>
682 <table cellspacing=5 cellpadding=0 border=0>
690 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).
692 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
694 Definition at line <a class="el" href="modules_8h-source.html#l01155">1155</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
696 Referenced by <a class="el" href="modules_8cpp-source.html#l00870">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l01000">Enumerate()</a>, <a class="el" href="modules_8cpp-source.html#l01005">EnumerateValues()</a>, <a class="el" href="modules_8cpp-source.html#l00914">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00931">ReadInteger()</a>, <a class="el" href="modules_8cpp-source.html#l00898">ReadValue()</a>, and <a class="el" href="modules_8cpp-source.html#l00880">~ConfigReader()</a>. </td>
699 <a name="p3" doxytag="ConfigReader::error"></a><p>
700 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
703 <table cellpadding="0" cellspacing="0" border="0">
705 <td class="md" nowrap valign="top"> long <a class="el" href="classConfigReader.html#p3">ConfigReader::error</a><code> [protected]</code>
710 <table cellspacing=5 cellpadding=0 border=0>
720 Definition at line <a class="el" href="modules_8h-source.html#l01160">1160</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
722 Referenced by <a class="el" href="modules_8cpp-source.html#l00870">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00960">GetError()</a>, <a class="el" href="modules_8cpp-source.html#l00914">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00931">ReadInteger()</a>, and <a class="el" href="modules_8cpp-source.html#l00898">ReadValue()</a>. </td>
725 <a name="p1" doxytag="ConfigReader::errorlog"></a><p>
726 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
729 <table cellpadding="0" cellspacing="0" border="0">
731 <td class="md" nowrap valign="top"> std::stringstream* <a class="el" href="classConfigReader.html#p1">ConfigReader::errorlog</a><code> [protected]</code>
736 <table cellspacing=5 cellpadding=0 border=0>
746 Definition at line <a class="el" href="modules_8h-source.html#l01156">1156</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
748 Referenced by <a class="el" href="modules_8cpp-source.html#l00870">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00967">DumpErrors()</a>, and <a class="el" href="modules_8cpp-source.html#l00880">~ConfigReader()</a>. </td>
751 <a name="p2" doxytag="ConfigReader::readerror"></a><p>
752 <table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
755 <table cellpadding="0" cellspacing="0" border="0">
757 <td class="md" nowrap valign="top"> bool <a class="el" href="classConfigReader.html#p2">ConfigReader::readerror</a><code> [protected]</code>
762 <table cellspacing=5 cellpadding=0 border=0>
770 Used to store errors.
774 Definition at line <a class="el" href="modules_8h-source.html#l01159">1159</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
776 Referenced by <a class="el" href="modules_8cpp-source.html#l00870">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l01010">Verify()</a>. </td>
779 <hr>The documentation for this class was generated from the following files:<ul>
780 <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>
781 <hr size="1"><address style="align: right;"><small>Generated on Fri May 13 01:59:32 2005 for InspIRCd by
782 <a href="http://www.doxygen.org/index.html">
783 <img src="doxygen.png" alt="doxygen" align="middle" border=0 >
784 </a>1.3.3 </small></address>