1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 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.doxygen.css" rel="stylesheet" type="text/css">
6 <!-- Generated by Doxygen 1.4.4-20050815 -->
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">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div>
8 <h1>ConfigReader Class Reference</h1><!-- doxytag: class="ConfigReader" --><!-- doxytag: inherits="classbase" -->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="19,7,99,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,97,87,124" 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#ConfigReader_28_29">ConfigReader</a> ()</td></tr>
26 <tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#ConfigReader_28_29"></a><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#ConfigReader_28std_3A_3Astring_20filename_29">ConfigReader</a> (<a class="el" href="namespaceirc.html#string">std::string</a> filename)</td></tr>
29 <tr><td class="mdescLeft"> </td><td class="mdescRight">Overloaded constructor. <a href="#ConfigReader_28std_3A_3Astring_20filename_29"></a><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#_7EConfigReader_28_29">~ConfigReader</a> ()</td></tr>
32 <tr><td class="mdescLeft"> </td><td class="mdescRight">Default destructor. <a href="#_7EConfigReader_28_29"></a><br></td></tr>
33 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classConfigReader.html#ReadValue_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29">ReadValue</a> (<a class="el" href="namespaceirc.html#string">std::string</a> tag, <a class="el" href="namespaceirc.html#string">std::string</a> name, int index)</td></tr>
35 <tr><td class="mdescLeft"> </td><td class="mdescRight">Retrieves a value from the config file. <a href="#ReadValue_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29"></a><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#ReadFlag_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29">ReadFlag</a> (<a class="el" href="namespaceirc.html#string">std::string</a> tag, <a class="el" href="namespaceirc.html#string">std::string</a> name, int index)</td></tr>
38 <tr><td class="mdescLeft"> </td><td class="mdescRight">Retrieves a boolean value from the config file. <a href="#ReadFlag_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29"></a><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#ReadInteger_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_2C_20bool_20needs_5Funsigned_29">ReadInteger</a> (<a class="el" href="namespaceirc.html#string">std::string</a> tag, <a class="el" href="namespaceirc.html#string">std::string</a> 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. <a href="#ReadInteger_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_2C_20bool_20needs_5Funsigned_29"></a><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#GetError_28_29">GetError</a> ()</td></tr>
44 <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the last error to occur. <a href="#GetError_28_29"></a><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#Enumerate_28std_3A_3Astring_20tag_29">Enumerate</a> (<a class="el" href="namespaceirc.html#string">std::string</a> 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. <a href="#Enumerate_28std_3A_3Astring_20tag_29"></a><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#Verify_28_29">Verify</a> ()</td></tr>
50 <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns true if a config file is valid. <a href="#Verify_28_29"></a><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#DumpErrors_28bool_20bail_2C_20userrec_20_2Auser_29">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. <a href="#DumpErrors_28bool_20bail_2C_20userrec_20_2Auser_29"></a><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#EnumerateValues_28std_3A_3Astring_20tag_2C_20int_20index_29">EnumerateValues</a> (<a class="el" href="namespaceirc.html#string">std::string</a> tag, int index)</td></tr>
56 <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the number of items within a tag. <a href="#EnumerateValues_28std_3A_3Astring_20tag_2C_20int_20index_29"></a><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#cache">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). <a href="#cache"></a><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#errorlog">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#readerror">readerror</a></td></tr>
65 <tr><td class="mdescLeft"> </td><td class="mdescRight">Used to store errors. <a href="#readerror"></a><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#error">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#l01121">1121</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
77 <a class="anchor" name="ConfigReader_28_29"></a><!-- doxytag: member="ConfigReader::ConfigReader" ref="ConfigReader_28_29" args="()" --><p>
78 <table class="mdTable" 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>
93 <table cellspacing="5" cellpadding="0" border="0">
103 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
105 Definition at line <a class="el" href="modules_8cpp-source.html#l00796">796</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
107 References <a class="el" href="modules_8h-source.html#l01129">cache</a>, <a class="el" href="modules_8h-source.html#l01112">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l01134">error</a>, <a class="el" href="modules_8h-source.html#l01130">errorlog</a>, <a class="el" href="modules_8cpp.html#include_5Fstack">include_stack</a>, and <a class="el" href="modules_8h-source.html#l01133">readerror</a>.<div class="fragment"><pre class="fragment"><a name="l00797"></a>00797 {
108 <a name="l00798"></a>00798 <a class="code" href="modules_8cpp.html#include_5Fstack">include_stack</a>.clear();
109 <a name="l00799"></a>00799 this-><a class="code" href="classConfigReader.html#cache">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
110 <a name="l00800"></a>00800 this-><a class="code" href="classConfigReader.html#errorlog">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
111 <a name="l00801"></a>00801 this-><a class="code" href="classConfigReader.html#readerror">readerror</a> = LoadConf(CONFIG_FILE,this->cache,this->errorlog);
112 <a name="l00802"></a>00802 <span class="keywordflow">if</span> (!this->readerror)
113 <a name="l00803"></a>00803 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FFILE_5FNOT_5FFOUND">CONF_FILE_NOT_FOUND</a>;
114 <a name="l00804"></a>00804 }
120 <a class="anchor" name="ConfigReader_28std_3A_3Astring_20filename_29"></a><!-- doxytag: member="ConfigReader::ConfigReader" ref="ConfigReader_28std_3A_3Astring_20filename_29" args="(std::string filename)" --><p>
121 <table class="mdTable" 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"><a class="el" href="namespaceirc.html#string">std::string</a> </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>
137 <table cellspacing="5" cellpadding="0" border="0">
145 Overloaded constructor.
147 This constructor initialises the ConfigReader class to read a user-specified config file
149 Definition at line <a class="el" href="modules_8cpp-source.html#l00816">816</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
151 References <a class="el" href="modules_8h-source.html#l01129">cache</a>, <a class="el" href="modules_8h-source.html#l01112">CONF_FILE_NOT_FOUND</a>, <a class="el" href="modules_8h-source.html#l01134">error</a>, <a class="el" href="modules_8h-source.html#l01130">errorlog</a>, and <a class="el" href="modules_8h-source.html#l01133">readerror</a>.<div class="fragment"><pre class="fragment"><a name="l00817"></a>00817 {
152 <a name="l00818"></a>00818 this-><a class="code" href="classConfigReader.html#cache">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
153 <a name="l00819"></a>00819 this-><a class="code" href="classConfigReader.html#errorlog">errorlog</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
154 <a name="l00820"></a>00820 this-><a class="code" href="classConfigReader.html#readerror">readerror</a> = LoadConf(filename.c_str(),this-><a class="code" href="classConfigReader.html#cache">cache</a>,this-><a class="code" href="classConfigReader.html#errorlog">errorlog</a>);
155 <a name="l00821"></a>00821 <span class="keywordflow">if</span> (!this->readerror)
156 <a name="l00822"></a>00822 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FFILE_5FNOT_5FFOUND">CONF_FILE_NOT_FOUND</a>;
157 <a name="l00823"></a>00823 };
163 <a class="anchor" name="_7EConfigReader_28_29"></a><!-- doxytag: member="ConfigReader::~ConfigReader" ref="_7EConfigReader_28_29" args="()" --><p>
164 <table class="mdTable" cellpadding="2" cellspacing="0">
167 <table cellpadding="0" cellspacing="0" border="0">
169 <td class="md" nowrap valign="top">ConfigReader::~ConfigReader </td>
170 <td class="md" valign="top">( </td>
171 <td class="mdname1" valign="top" nowrap> </td>
172 <td class="md" valign="top"> ) </td>
173 <td class="md" nowrap></td>
179 <table cellspacing="5" cellpadding="0" border="0">
189 This method destroys the ConfigReader class.
191 Definition at line <a class="el" href="modules_8cpp-source.html#l00807">807</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
193 References <a class="el" href="modules_8h-source.html#l01129">cache</a>, and <a class="el" href="modules_8h-source.html#l01130">errorlog</a>.<div class="fragment"><pre class="fragment"><a name="l00808"></a>00808 {
194 <a name="l00809"></a>00809 <span class="keywordflow">if</span> (this->cache)
195 <a name="l00810"></a>00810 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#cache">cache</a>;
196 <a name="l00811"></a>00811 <span class="keywordflow">if</span> (this->errorlog)
197 <a name="l00812"></a>00812 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#errorlog">errorlog</a>;
198 <a name="l00813"></a>00813 }
204 <hr><h2>Member Function Documentation</h2>
205 <a class="anchor" name="DumpErrors_28bool_20bail_2C_20userrec_20_2Auser_29"></a><!-- doxytag: member="ConfigReader::DumpErrors" ref="DumpErrors_28bool_20bail_2C_20userrec_20_2Auser_29" args="(bool bail, userrec *user)" --><p>
206 <table class="mdTable" cellpadding="2" cellspacing="0">
209 <table cellpadding="0" cellspacing="0" border="0">
211 <td class="md" nowrap valign="top">void ConfigReader::DumpErrors </td>
212 <td class="md" valign="top">( </td>
213 <td class="md" nowrap valign="top">bool </td>
214 <td class="mdname" nowrap> <em>bail</em>, </td>
217 <td class="md" nowrap align="right"></td>
219 <td class="md" nowrap><a class="el" href="classuserrec.html">userrec</a> * </td>
220 <td class="mdname" nowrap> <em>user</em></td>
224 <td class="md">) </td>
225 <td class="md" colspan="2"></td>
231 <table cellspacing="5" cellpadding="0" border="0">
239 Dumps the list of errors in a config file to an output location.
241 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.
243 Definition at line <a class="el" href="modules_8cpp-source.html#l00894">894</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
245 References <a class="el" href="modules_8h-source.html#l01130">errorlog</a>, <a class="el" href="connection_8h-source.html#l00042">connection::fd</a>, and <a class="el" href="users_8h-source.html#l00121">userrec::nick</a>.<div class="fragment"><pre class="fragment"><a name="l00895"></a>00895 {
246 <a name="l00896"></a>00896 <span class="keywordflow">if</span> (bail)
247 <a name="l00897"></a>00897 {
248 <a name="l00898"></a>00898 printf(<span class="stringliteral">"There were errors in your configuration:\n%s"</span>,<a class="code" href="classConfigReader.html#errorlog">errorlog</a>->str().c_str());
249 <a name="l00899"></a>00899 exit(0);
250 <a name="l00900"></a>00900 }
251 <a name="l00901"></a>00901 <span class="keywordflow">else</span>
252 <a name="l00902"></a>00902 {
253 <a name="l00903"></a>00903 <span class="keywordtype">char</span> dataline[1024];
254 <a name="l00904"></a>00904 <span class="keywordflow">if</span> (user)
255 <a name="l00905"></a>00905 {
256 <a name="l00906"></a>00906 WriteServ(user-><a class="code" href="classconnection.html#fd">fd</a>,<span class="stringliteral">"NOTICE %s :There were errors in the configuration file:"</span>,user-><a class="code" href="classuserrec.html#nick_5BNICKMAX_5D">nick</a>);
257 <a name="l00907"></a>00907 <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#errorlog">errorlog</a>->eof())
258 <a name="l00908"></a>00908 {
259 <a name="l00909"></a>00909 <a class="code" href="classConfigReader.html#errorlog">errorlog</a>->getline(dataline,1024);
260 <a name="l00910"></a>00910 WriteServ(user-><a class="code" href="classconnection.html#fd">fd</a>,<span class="stringliteral">"NOTICE %s :%s"</span>,user-><a class="code" href="classuserrec.html#nick_5BNICKMAX_5D">nick</a>,dataline);
261 <a name="l00911"></a>00911 }
262 <a name="l00912"></a>00912 }
263 <a name="l00913"></a>00913 <span class="keywordflow">else</span>
264 <a name="l00914"></a>00914 {
265 <a name="l00915"></a>00915 WriteOpers(<span class="stringliteral">"There were errors in the configuration file:"</span>,user-><a class="code" href="classuserrec.html#nick_5BNICKMAX_5D">nick</a>);
266 <a name="l00916"></a>00916 <span class="keywordflow">while</span> (!<a class="code" href="classConfigReader.html#errorlog">errorlog</a>->eof())
267 <a name="l00917"></a>00917 {
268 <a name="l00918"></a>00918 <a class="code" href="classConfigReader.html#errorlog">errorlog</a>->getline(dataline,1024);
269 <a name="l00919"></a>00919 WriteOpers(dataline);
270 <a name="l00920"></a>00920 }
271 <a name="l00921"></a>00921 }
272 <a name="l00922"></a>00922 <span class="keywordflow">return</span>;
273 <a name="l00923"></a>00923 }
274 <a name="l00924"></a>00924 }
280 <a class="anchor" name="Enumerate_28std_3A_3Astring_20tag_29"></a><!-- doxytag: member="ConfigReader::Enumerate" ref="Enumerate_28std_3A_3Astring_20tag_29" args="(std::string tag)" --><p>
281 <table class="mdTable" cellpadding="2" cellspacing="0">
284 <table cellpadding="0" cellspacing="0" border="0">
286 <td class="md" nowrap valign="top">int ConfigReader::Enumerate </td>
287 <td class="md" valign="top">( </td>
288 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
289 <td class="mdname1" valign="top" nowrap> <em>tag</em> </td>
290 <td class="md" valign="top"> ) </td>
291 <td class="md" nowrap></td>
297 <table cellspacing="5" cellpadding="0" border="0">
305 Counts the number of times a given tag appears in the config file.
307 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#ReadValue_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29">ConfigReader::ReadValue</a> to loop through all copies of a multiple instance tag.
309 Definition at line <a class="el" href="modules_8cpp-source.html#l00927">927</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
311 References <a class="el" href="modules_8h-source.html#l01129">cache</a>.<div class="fragment"><pre class="fragment"><a name="l00928"></a>00928 {
312 <a name="l00929"></a>00929 <span class="keywordflow">return</span> EnumConf(<a class="code" href="classConfigReader.html#cache">cache</a>,tag.c_str());
313 <a name="l00930"></a>00930 }
319 <a class="anchor" name="EnumerateValues_28std_3A_3Astring_20tag_2C_20int_20index_29"></a><!-- doxytag: member="ConfigReader::EnumerateValues" ref="EnumerateValues_28std_3A_3Astring_20tag_2C_20int_20index_29" args="(std::string tag, int index)" --><p>
320 <table class="mdTable" cellpadding="2" cellspacing="0">
323 <table cellpadding="0" cellspacing="0" border="0">
325 <td class="md" nowrap valign="top">int ConfigReader::EnumerateValues </td>
326 <td class="md" valign="top">( </td>
327 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
328 <td class="mdname" nowrap> <em>tag</em>, </td>
331 <td class="md" nowrap align="right"></td>
333 <td class="md" nowrap>int </td>
334 <td class="mdname" nowrap> <em>index</em></td>
338 <td class="md">) </td>
339 <td class="md" colspan="2"></td>
345 <table cellspacing="5" cellpadding="0" border="0">
353 Returns the number of items within a tag.
355 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.
357 Definition at line <a class="el" href="modules_8cpp-source.html#l00932">932</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
359 References <a class="el" href="modules_8h-source.html#l01129">cache</a>.<div class="fragment"><pre class="fragment"><a name="l00933"></a>00933 {
360 <a name="l00934"></a>00934 <span class="keywordflow">return</span> EnumValues(<a class="code" href="classConfigReader.html#cache">cache</a>, tag.c_str(), index);
361 <a name="l00935"></a>00935 }
367 <a class="anchor" name="GetError_28_29"></a><!-- doxytag: member="ConfigReader::GetError" ref="GetError_28_29" args="()" --><p>
368 <table class="mdTable" cellpadding="2" cellspacing="0">
371 <table cellpadding="0" cellspacing="0" border="0">
373 <td class="md" nowrap valign="top">long ConfigReader::GetError </td>
374 <td class="md" valign="top">( </td>
375 <td class="mdname1" valign="top" nowrap> </td>
376 <td class="md" valign="top"> ) </td>
377 <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#GetError_28_29">GetError()</a> resets the error flag back to 0.
395 Definition at line <a class="el" href="modules_8cpp-source.html#l00887">887</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
397 References <a class="el" href="modules_8h-source.html#l01134">error</a>.<div class="fragment"><pre class="fragment"><a name="l00888"></a>00888 {
398 <a name="l00889"></a>00889 <span class="keywordtype">long</span> olderr = this-><a class="code" href="classConfigReader.html#error">error</a>;
399 <a name="l00890"></a>00890 this-><a class="code" href="classConfigReader.html#error">error</a> = 0;
400 <a name="l00891"></a>00891 <span class="keywordflow">return</span> olderr;
401 <a name="l00892"></a>00892 }
407 <a class="anchor" name="ReadFlag_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29"></a><!-- doxytag: member="ConfigReader::ReadFlag" ref="ReadFlag_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29" args="(std::string tag, std::string name, int index)" --><p>
408 <table class="mdTable" 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"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
416 <td class="mdname" nowrap> <em>tag</em>, </td>
419 <td class="md" nowrap align="right"></td>
421 <td class="md" nowrap><a class="el" href="namespaceirc.html#string">std::string</a> </td>
422 <td class="mdname" nowrap> <em>name</em>, </td>
425 <td class="md" nowrap align="right"></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>
439 <table cellspacing="5" cellpadding="0" border="0">
447 Retrieves a boolean value from the config file.
449 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 Definition at line <a class="el" href="modules_8cpp-source.html#l00841">841</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
453 References <a class="el" href="modules_8h-source.html#l01129">cache</a>, <a class="el" href="modules_8h-source.html#l01111">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l01134">error</a>.<div class="fragment"><pre class="fragment"><a name="l00842"></a>00842 {
454 <a name="l00843"></a>00843 <span class="keywordtype">char</span> val[MAXBUF];
455 <a name="l00844"></a>00844 <span class="keywordtype">char</span> t[MAXBUF];
456 <a name="l00845"></a>00845 <span class="keywordtype">char</span> n[MAXBUF];
457 <a name="l00846"></a>00846 strlcpy(t,tag.c_str(),MAXBUF);
458 <a name="l00847"></a>00847 strlcpy(n,name.c_str(),MAXBUF);
459 <a name="l00848"></a>00848 <span class="keywordtype">int</span> res = ReadConf(<a class="code" href="classConfigReader.html#cache">cache</a>,t,n,index,val);
460 <a name="l00849"></a>00849 <span class="keywordflow">if</span> (!res)
461 <a name="l00850"></a>00850 {
462 <a name="l00851"></a>00851 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FVALUE_5FNOT_5FFOUND">CONF_VALUE_NOT_FOUND</a>;
463 <a name="l00852"></a>00852 <span class="keywordflow">return</span> <span class="keyword">false</span>;
464 <a name="l00853"></a>00853 }
465 <a name="l00854"></a>00854 <a class="code" href="namespaceirc.html#string">std::string</a> s = val;
466 <a name="l00855"></a>00855 <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>));
467 <a name="l00856"></a>00856 }
473 <a class="anchor" name="ReadInteger_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_2C_20bool_20needs_5Funsigned_29"></a><!-- doxytag: member="ConfigReader::ReadInteger" ref="ReadInteger_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_2C_20bool_20needs_5Funsigned_29" args="(std::string tag, std::string name, int index, bool needs_unsigned)" --><p>
474 <table class="mdTable" cellpadding="2" cellspacing="0">
477 <table cellpadding="0" cellspacing="0" border="0">
479 <td class="md" nowrap valign="top">long ConfigReader::ReadInteger </td>
480 <td class="md" valign="top">( </td>
481 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
482 <td class="mdname" nowrap> <em>tag</em>, </td>
485 <td class="md" nowrap align="right"></td>
487 <td class="md" nowrap><a class="el" href="namespaceirc.html#string">std::string</a> </td>
488 <td class="mdname" nowrap> <em>name</em>, </td>
491 <td class="md" nowrap align="right"></td>
493 <td class="md" nowrap>int </td>
494 <td class="mdname" nowrap> <em>index</em>, </td>
497 <td class="md" nowrap align="right"></td>
499 <td class="md" nowrap>bool </td>
500 <td class="mdname" nowrap> <em>needs_unsigned</em></td>
504 <td class="md">) </td>
505 <td class="md" colspan="2"></td>
511 <table cellspacing="5" cellpadding="0" border="0">
519 Retrieves an integer value from the config file.
521 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#GetError_28_29">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#GetError_28_29">GetError()</a> will return CONF_NOT_UNSIGNED
523 Definition at line <a class="el" href="modules_8cpp-source.html#l00858">858</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
525 References <a class="el" href="modules_8h-source.html#l01129">cache</a>, <a class="el" href="modules_8h-source.html#l01109">CONF_NOT_A_NUMBER</a>, <a class="el" href="modules_8h-source.html#l01110">CONF_NOT_UNSIGNED</a>, <a class="el" href="modules_8h-source.html#l01111">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l01134">error</a>.<div class="fragment"><pre class="fragment"><a name="l00859"></a>00859 {
526 <a name="l00860"></a>00860 <span class="keywordtype">char</span> val[MAXBUF];
527 <a name="l00861"></a>00861 <span class="keywordtype">char</span> t[MAXBUF];
528 <a name="l00862"></a>00862 <span class="keywordtype">char</span> n[MAXBUF];
529 <a name="l00863"></a>00863 strlcpy(t,tag.c_str(),MAXBUF);
530 <a name="l00864"></a>00864 strlcpy(n,name.c_str(),MAXBUF);
531 <a name="l00865"></a>00865 <span class="keywordtype">int</span> res = ReadConf(<a class="code" href="classConfigReader.html#cache">cache</a>,t,n,index,val);
532 <a name="l00866"></a>00866 <span class="keywordflow">if</span> (!res)
533 <a name="l00867"></a>00867 {
534 <a name="l00868"></a>00868 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FVALUE_5FNOT_5FFOUND">CONF_VALUE_NOT_FOUND</a>;
535 <a name="l00869"></a>00869 <span class="keywordflow">return</span> 0;
536 <a name="l00870"></a>00870 }
537 <a name="l00871"></a>00871 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < strlen(val); i++)
538 <a name="l00872"></a>00872 {
539 <a name="l00873"></a>00873 <span class="keywordflow">if</span> (!isdigit(val[i]))
540 <a name="l00874"></a>00874 {
541 <a name="l00875"></a>00875 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FNOT_5FA_5FNUMBER">CONF_NOT_A_NUMBER</a>;
542 <a name="l00876"></a>00876 <span class="keywordflow">return</span> 0;
543 <a name="l00877"></a>00877 }
544 <a name="l00878"></a>00878 }
545 <a name="l00879"></a>00879 <span class="keywordflow">if</span> ((needs_unsigned) && (atoi(val)<0))
546 <a name="l00880"></a>00880 {
547 <a name="l00881"></a>00881 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FNOT_5FUNSIGNED">CONF_NOT_UNSIGNED</a>;
548 <a name="l00882"></a>00882 <span class="keywordflow">return</span> 0;
549 <a name="l00883"></a>00883 }
550 <a name="l00884"></a>00884 <span class="keywordflow">return</span> atoi(val);
551 <a name="l00885"></a>00885 }
557 <a class="anchor" name="ReadValue_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29"></a><!-- doxytag: member="ConfigReader::ReadValue" ref="ReadValue_28std_3A_3Astring_20tag_2C_20std_3A_3Astring_20name_2C_20int_20index_29" args="(std::string tag, std::string name, int index)" --><p>
558 <table class="mdTable" cellpadding="2" cellspacing="0">
561 <table cellpadding="0" cellspacing="0" border="0">
563 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> ConfigReader::ReadValue </td>
564 <td class="md" valign="top">( </td>
565 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
566 <td class="mdname" nowrap> <em>tag</em>, </td>
569 <td class="md" nowrap align="right"></td>
571 <td class="md" nowrap><a class="el" href="namespaceirc.html#string">std::string</a> </td>
572 <td class="mdname" nowrap> <em>name</em>, </td>
575 <td class="md" nowrap align="right"></td>
577 <td class="md" nowrap>int </td>
578 <td class="mdname" nowrap> <em>index</em></td>
582 <td class="md">) </td>
583 <td class="md" colspan="2"></td>
589 <table cellspacing="5" cellpadding="0" border="0">
597 Retrieves a value from the config file.
599 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.
601 Definition at line <a class="el" href="modules_8cpp-source.html#l00825">825</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
603 References <a class="el" href="modules_8h-source.html#l01129">cache</a>, <a class="el" href="modules_8h-source.html#l01111">CONF_VALUE_NOT_FOUND</a>, and <a class="el" href="modules_8h-source.html#l01134">error</a>.<div class="fragment"><pre class="fragment"><a name="l00826"></a>00826 {
604 <a name="l00827"></a>00827 <span class="keywordtype">char</span> val[MAXBUF];
605 <a name="l00828"></a>00828 <span class="keywordtype">char</span> t[MAXBUF];
606 <a name="l00829"></a>00829 <span class="keywordtype">char</span> n[MAXBUF];
607 <a name="l00830"></a>00830 strlcpy(t,tag.c_str(),MAXBUF);
608 <a name="l00831"></a>00831 strlcpy(n,name.c_str(),MAXBUF);
609 <a name="l00832"></a>00832 <span class="keywordtype">int</span> res = ReadConf(<a class="code" href="classConfigReader.html#cache">cache</a>,t,n,index,val);
610 <a name="l00833"></a>00833 <span class="keywordflow">if</span> (!res)
611 <a name="l00834"></a>00834 {
612 <a name="l00835"></a>00835 this-><a class="code" href="classConfigReader.html#error">error</a> = <a class="code" href="modules_8h.html#CONF_5FVALUE_5FNOT_5FFOUND">CONF_VALUE_NOT_FOUND</a>;
613 <a name="l00836"></a>00836 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
614 <a name="l00837"></a>00837 }
615 <a name="l00838"></a>00838 <span class="keywordflow">return</span> val;
616 <a name="l00839"></a>00839 }
622 <a class="anchor" name="Verify_28_29"></a><!-- doxytag: member="ConfigReader::Verify" ref="Verify_28_29" args="()" --><p>
623 <table class="mdTable" cellpadding="2" cellspacing="0">
626 <table cellpadding="0" cellspacing="0" border="0">
628 <td class="md" nowrap valign="top">bool ConfigReader::Verify </td>
629 <td class="md" valign="top">( </td>
630 <td class="mdname1" valign="top" nowrap> </td>
631 <td class="md" valign="top"> ) </td>
632 <td class="md" nowrap></td>
638 <table cellspacing="5" cellpadding="0" border="0">
646 Returns true if a config file is valid.
648 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
650 Definition at line <a class="el" href="modules_8cpp-source.html#l00937">937</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
652 References <a class="el" href="modules_8h-source.html#l01133">readerror</a>.<div class="fragment"><pre class="fragment"><a name="l00938"></a>00938 {
653 <a name="l00939"></a>00939 <span class="keywordflow">return</span> this-><a class="code" href="classConfigReader.html#readerror">readerror</a>;
654 <a name="l00940"></a>00940 }
660 <hr><h2>Member Data Documentation</h2>
661 <a class="anchor" name="cache"></a><!-- doxytag: member="ConfigReader::cache" ref="cache" args="" --><p>
662 <table class="mdTable" cellpadding="2" cellspacing="0">
665 <table cellpadding="0" cellspacing="0" border="0">
667 <td class="md" nowrap valign="top">std::stringstream* <a class="el" href="classConfigReader.html#cache">ConfigReader::cache</a><code> [protected]</code> </td>
673 <table cellspacing="5" cellpadding="0" border="0">
681 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).
683 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
685 Definition at line <a class="el" href="modules_8h-source.html#l01129">1129</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
687 Referenced by <a class="el" href="modules_8cpp-source.html#l00796">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00927">Enumerate()</a>, <a class="el" href="modules_8cpp-source.html#l00932">EnumerateValues()</a>, <a class="el" href="modules_8cpp-source.html#l00841">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00858">ReadInteger()</a>, <a class="el" href="modules_8cpp-source.html#l00825">ReadValue()</a>, and <a class="el" href="modules_8cpp-source.html#l00807">~ConfigReader()</a>. </td>
690 <a class="anchor" name="error"></a><!-- doxytag: member="ConfigReader::error" ref="error" args="" --><p>
691 <table class="mdTable" cellpadding="2" cellspacing="0">
694 <table cellpadding="0" cellspacing="0" border="0">
696 <td class="md" nowrap valign="top">long <a class="el" href="classConfigReader.html#error">ConfigReader::error</a><code> [protected]</code> </td>
702 <table cellspacing="5" cellpadding="0" border="0">
712 Definition at line <a class="el" href="modules_8h-source.html#l01134">1134</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
714 Referenced by <a class="el" href="modules_8cpp-source.html#l00796">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00887">GetError()</a>, <a class="el" href="modules_8cpp-source.html#l00841">ReadFlag()</a>, <a class="el" href="modules_8cpp-source.html#l00858">ReadInteger()</a>, and <a class="el" href="modules_8cpp-source.html#l00825">ReadValue()</a>. </td>
717 <a class="anchor" name="errorlog"></a><!-- doxytag: member="ConfigReader::errorlog" ref="errorlog" args="" --><p>
718 <table class="mdTable" cellpadding="2" cellspacing="0">
721 <table cellpadding="0" cellspacing="0" border="0">
723 <td class="md" nowrap valign="top">std::stringstream* <a class="el" href="classConfigReader.html#errorlog">ConfigReader::errorlog</a><code> [protected]</code> </td>
729 <table cellspacing="5" cellpadding="0" border="0">
739 Definition at line <a class="el" href="modules_8h-source.html#l01130">1130</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
741 Referenced by <a class="el" href="modules_8cpp-source.html#l00796">ConfigReader()</a>, <a class="el" href="modules_8cpp-source.html#l00894">DumpErrors()</a>, and <a class="el" href="modules_8cpp-source.html#l00807">~ConfigReader()</a>. </td>
744 <a class="anchor" name="readerror"></a><!-- doxytag: member="ConfigReader::readerror" ref="readerror" args="" --><p>
745 <table class="mdTable" cellpadding="2" cellspacing="0">
748 <table cellpadding="0" cellspacing="0" border="0">
750 <td class="md" nowrap valign="top">bool <a class="el" href="classConfigReader.html#readerror">ConfigReader::readerror</a><code> [protected]</code> </td>
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#l01133">1133</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#l00796">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00937">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 Sun Nov 27 01:43:25 2005 for InspIRCd by
776 <a href="http://www.doxygen.org/index.html">
777 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4-20050815 </small></address>