summaryrefslogtreecommitdiff
path: root/docs/module-doc/users_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/module-doc/users_8cpp-source.html')
-rw-r--r--docs/module-doc/users_8cpp-source.html510
1 files changed, 258 insertions, 252 deletions
diff --git a/docs/module-doc/users_8cpp-source.html b/docs/module-doc/users_8cpp-source.html
index b1258eb0a..4e2e35443 100644
--- a/docs/module-doc/users_8cpp-source.html
+++ b/docs/module-doc/users_8cpp-source.html
@@ -4,7 +4,7 @@
<link href="inspircd.doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
-<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
+<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
<h1>users.cpp</h1><a href="users_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/* +------------------------------------+</span>
00002 <span class="comment"> * | Inspire Internet Relay Chat Daemon |</span>
00003 <span class="comment"> * +------------------------------------+</span>
@@ -27,259 +27,265 @@
00020 <span class="preprocessor">#include "inspircd.h"</span>
00021 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
00022 <span class="preprocessor">#include "inspstring.h"</span>
-00023
-<a name="l00024"></a><a class="code" href="users_8cpp.html#a0">00024</a> <span class="keyword">extern</span> std::stringstream <a class="code" href="channels_8cpp.html#a34">config_f</a>;
-00025
-<a name="l00026"></a><a class="code" href="users_8cpp.html#a1">00026</a> <span class="keyword">extern</span> time_t <a class="code" href="channels_8cpp.html#a37">TIME</a>;
-00027
-<a name="l00028"></a><a class="code" href="classuserrec.html#a0">00028</a> <a class="code" href="classuserrec.html#a0">userrec::userrec</a>()
-00029 {
-00030 <span class="comment">// the PROPER way to do it, AVOID bzero at *ALL* costs</span>
-00031 strcpy(<a class="code" href="classuserrec.html#o0">nick</a>,<span class="stringliteral">""</span>);
-00032 strcpy(<a class="code" href="classconnection.html#o2">ip</a>,<span class="stringliteral">"127.0.0.1"</span>);
-00033 <a class="code" href="classuserrec.html#o10">timeout</a> = 0;
-00034 strcpy(<a class="code" href="classuserrec.html#o1">ident</a>,<span class="stringliteral">""</span>);
-00035 strcpy(<a class="code" href="classconnection.html#o1">host</a>,<span class="stringliteral">""</span>);
-00036 strcpy(<a class="code" href="classuserrec.html#o2">dhost</a>,<span class="stringliteral">""</span>);
-00037 strcpy(<a class="code" href="classuserrec.html#o3">fullname</a>,<span class="stringliteral">""</span>);
-00038 strcpy(<a class="code" href="classuserrec.html#o4">modes</a>,<span class="stringliteral">""</span>);
-00039 strcpy(<a class="code" href="classuserrec.html#o6">server</a>,<span class="stringliteral">""</span>);
-00040 strcpy(<a class="code" href="classuserrec.html#o7">awaymsg</a>,<span class="stringliteral">""</span>);
-00041 strcpy(<a class="code" href="classuserrec.html#o11">oper</a>,<span class="stringliteral">""</span>);
-00042 <a class="code" href="classuserrec.html#o18">reset_due</a> = <a class="code" href="channels_8cpp.html#a37">TIME</a>;
-00043 <a class="code" href="classuserrec.html#o17">lines_in</a> = 0;
-00044 <a class="code" href="classconnection.html#o0">fd</a> = <a class="code" href="classconnection.html#o10">lastping</a> = <a class="code" href="classconnection.html#o11">signon</a> = <a class="code" href="classconnection.html#o12">idle_lastmsg</a> = <a class="code" href="classconnection.html#o13">nping</a> = <a class="code" href="classconnection.html#o9">registered</a> = 0;
-00045 <a class="code" href="classuserrec.html#o9">flood</a> = <a class="code" href="classconnection.html#o8">port</a> = <a class="code" href="classconnection.html#o3">bytes_in</a> = <a class="code" href="classconnection.html#o4">bytes_out</a> = <a class="code" href="classconnection.html#o5">cmds_in</a> = <a class="code" href="classconnection.html#o6">cmds_out</a> = 0;
-00046 <a class="code" href="classconnection.html#o7">haspassed</a> = <span class="keyword">false</span>;
-00047 <a class="code" href="classuserrec.html#o12">dns_done</a> = <span class="keyword">false</span>;
-00048 <a class="code" href="classuserrec.html#o15">recvq</a> = <span class="stringliteral">""</span>;
-00049 <a class="code" href="classuserrec.html#o16">sendq</a> = <span class="stringliteral">""</span>;
-00050 strcpy(<a class="code" href="classuserrec.html#o8">result</a>,<span class="stringliteral">""</span>);
-00051 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; MAXCHANS; i++)
-00052 {
-00053 this-&gt;<a class="code" href="classuserrec.html#o5">chans</a>[i].<a class="code" href="classucrec.html#o1">channel</a> = NULL;
-00054 this-&gt;<a class="code" href="classuserrec.html#o5">chans</a>[i].<a class="code" href="classucrec.html#o0">uc_modes</a> = 0;
-00055 }
-00056 <a class="code" href="classuserrec.html#r0">invites</a>.clear();
-00057 }
-00058
+00023 <span class="preprocessor">#include "helperfuncs.h"</span>
+00024
+<a name="l00025"></a><a class="code" href="users_8cpp.html#a0">00025</a> <span class="keyword">extern</span> std::stringstream <a class="code" href="channels_8cpp.html#a34">config_f</a>;
+00026
+<a name="l00027"></a><a class="code" href="users_8cpp.html#a1">00027</a> <span class="keyword">extern</span> time_t <a class="code" href="channels_8cpp.html#a37">TIME</a>;
+00028
+<a name="l00029"></a><a class="code" href="classuserrec.html#a0">00029</a> <a class="code" href="classuserrec.html#a0">userrec::userrec</a>()
+00030 {
+00031 <span class="comment">// the PROPER way to do it, AVOID bzero at *ALL* costs</span>
+00032 strcpy(<a class="code" href="classuserrec.html#o0">nick</a>,<span class="stringliteral">""</span>);
+00033 strcpy(<a class="code" href="classconnection.html#o2">ip</a>,<span class="stringliteral">"127.0.0.1"</span>);
+00034 <a class="code" href="classuserrec.html#o10">timeout</a> = 0;
+00035 strcpy(<a class="code" href="classuserrec.html#o1">ident</a>,<span class="stringliteral">""</span>);
+00036 strcpy(<a class="code" href="classconnection.html#o1">host</a>,<span class="stringliteral">""</span>);
+00037 strcpy(<a class="code" href="classuserrec.html#o2">dhost</a>,<span class="stringliteral">""</span>);
+00038 strcpy(<a class="code" href="classuserrec.html#o3">fullname</a>,<span class="stringliteral">""</span>);
+00039 strcpy(<a class="code" href="classuserrec.html#o4">modes</a>,<span class="stringliteral">""</span>);
+00040 strcpy(<a class="code" href="classuserrec.html#o6">server</a>,<span class="stringliteral">""</span>);
+00041 strcpy(<a class="code" href="classuserrec.html#o7">awaymsg</a>,<span class="stringliteral">""</span>);
+00042 strcpy(<a class="code" href="classuserrec.html#o11">oper</a>,<span class="stringliteral">""</span>);
+00043 <a class="code" href="classuserrec.html#o18">reset_due</a> = <a class="code" href="channels_8cpp.html#a37">TIME</a>;
+00044 <a class="code" href="classuserrec.html#o17">lines_in</a> = 0;
+00045 <a class="code" href="classconnection.html#o0">fd</a> = <a class="code" href="classconnection.html#o10">lastping</a> = <a class="code" href="classconnection.html#o11">signon</a> = <a class="code" href="classconnection.html#o12">idle_lastmsg</a> = <a class="code" href="classconnection.html#o13">nping</a> = <a class="code" href="classconnection.html#o9">registered</a> = 0;
+00046 <a class="code" href="classuserrec.html#o9">flood</a> = <a class="code" href="classconnection.html#o8">port</a> = <a class="code" href="classconnection.html#o3">bytes_in</a> = <a class="code" href="classconnection.html#o4">bytes_out</a> = <a class="code" href="classconnection.html#o5">cmds_in</a> = <a class="code" href="classconnection.html#o6">cmds_out</a> = 0;
+00047 <a class="code" href="classconnection.html#o7">haspassed</a> = <span class="keyword">false</span>;
+00048 <a class="code" href="classuserrec.html#o12">dns_done</a> = <span class="keyword">false</span>;
+00049 <a class="code" href="classuserrec.html#o15">recvq</a> = <span class="stringliteral">""</span>;
+00050 <a class="code" href="classuserrec.html#o16">sendq</a> = <span class="stringliteral">""</span>;
+00051 strcpy(<a class="code" href="classuserrec.html#o8">result</a>,<span class="stringliteral">""</span>);
+00052 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; MAXCHANS; i++)
+00053 {
+00054 this-&gt;<a class="code" href="classuserrec.html#o5">chans</a>[i].<a class="code" href="classucrec.html#o1">channel</a> = NULL;
+00055 this-&gt;<a class="code" href="classuserrec.html#o5">chans</a>[i].<a class="code" href="classucrec.html#o0">uc_modes</a> = 0;
+00056 }
+00057 <a class="code" href="classuserrec.html#r0">invites</a>.clear();
+00058 }
00059
-00060
-<a name="l00061"></a><a class="code" href="classuserrec.html#a2">00061</a> <span class="keywordtype">char</span>* <a class="code" href="classuserrec.html#a2">userrec::GetFullHost</a>()
-00062 {
-00063 snprintf(<a class="code" href="classuserrec.html#o8">result</a>,MAXBUF,<span class="stringliteral">"%s!%s@%s"</span>,<a class="code" href="classuserrec.html#o0">nick</a>,<a class="code" href="classuserrec.html#o1">ident</a>,<a class="code" href="classuserrec.html#o2">dhost</a>);
-00064 <span class="keywordflow">return</span> <a class="code" href="classuserrec.html#o8">result</a>;
-00065 }
-00066
+00060
+00061
+<a name="l00062"></a><a class="code" href="classuserrec.html#a2">00062</a> <span class="keywordtype">char</span>* <a class="code" href="classuserrec.html#a2">userrec::GetFullHost</a>()
+00063 {
+00064 snprintf(<a class="code" href="classuserrec.html#o8">result</a>,MAXBUF,<span class="stringliteral">"%s!%s@%s"</span>,<a class="code" href="classuserrec.html#o0">nick</a>,<a class="code" href="classuserrec.html#o1">ident</a>,<a class="code" href="classuserrec.html#o2">dhost</a>);
+00065 <span class="keywordflow">return</span> <a class="code" href="classuserrec.html#o8">result</a>;
+00066 }
00067
-<a name="l00068"></a><a class="code" href="classuserrec.html#a3">00068</a> <span class="keywordtype">char</span>* <a class="code" href="classuserrec.html#a3">userrec::GetFullRealHost</a>()
-00069 {
-00070 snprintf(<a class="code" href="classuserrec.html#o8">result</a>,MAXBUF,<span class="stringliteral">"%s!%s@%s"</span>,<a class="code" href="classuserrec.html#o0">nick</a>,<a class="code" href="classuserrec.html#o1">ident</a>,<a class="code" href="classconnection.html#o1">host</a>);
-00071 <span class="keywordflow">return</span> <a class="code" href="classuserrec.html#o8">result</a>;
-00072 }
-00073
-<a name="l00074"></a><a class="code" href="classuserrec.html#a4">00074</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a4">userrec::IsInvited</a>(<span class="keywordtype">char</span>* channel)
-00075 {
-00076 <span class="keywordflow">for</span> (InvitedList::iterator i = <a class="code" href="classuserrec.html#r0">invites</a>.begin(); i != <a class="code" href="classuserrec.html#r0">invites</a>.end(); i++)
-00077 {
-00078 <span class="keywordflow">if</span> (i-&gt;channel) {
-00079 <span class="keywordflow">if</span> (!strcasecmp(i-&gt;channel,channel))
-00080 {
-00081 <span class="keywordflow">return</span> <span class="keyword">true</span>;
-00082 }
-00083 }
-00084 }
-00085 <span class="keywordflow">return</span> <span class="keyword">false</span>;
-00086 }
-00087
-<a name="l00088"></a><a class="code" href="classuserrec.html#a5">00088</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a5">userrec::InviteTo</a>(<span class="keywordtype">char</span>* channel)
-00089 {
-00090 <a class="code" href="classInvited.html">Invited</a> i;
-00091 strlcpy(i.<a class="code" href="classInvited.html#o0">channel</a>,channel,CHANMAX);
-00092 <a class="code" href="classuserrec.html#r0">invites</a>.push_back(i);
-00093 }
-00094
-<a name="l00095"></a><a class="code" href="classuserrec.html#a6">00095</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a6">userrec::RemoveInvite</a>(<span class="keywordtype">char</span>* channel)
-00096 {
-00097 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Removing invites"</span>);
-00098 <span class="keywordflow">if</span> (channel)
-00099 {
-00100 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#r0">invites</a>.size())
-00101 {
-00102 <span class="keywordflow">for</span> (InvitedList::iterator i = <a class="code" href="classuserrec.html#r0">invites</a>.begin(); i != <a class="code" href="classuserrec.html#r0">invites</a>.end(); i++)
-00103 {
-00104 <span class="keywordflow">if</span> (i-&gt;channel)
-00105 {
-00106 <span class="keywordflow">if</span> (!strcasecmp(i-&gt;channel,channel))
-00107 {
-00108 <a class="code" href="classuserrec.html#r0">invites</a>.erase(i);
-00109 <span class="keywordflow">return</span>;
-00110 }
-00111 }
-00112 }
-00113 }
-00114 }
-00115 }
-00116
-<a name="l00117"></a><a class="code" href="classuserrec.html#a7">00117</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a7">userrec::HasPermission</a>(<span class="keywordtype">char</span>* command)
-00118 {
-00119 <span class="keywordtype">char</span> TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
-00120 <span class="keywordtype">char</span>* mycmd;
-00121 <span class="keywordtype">char</span>* savept;
-00122 <span class="keywordtype">char</span>* savept2;
-00123
-00124 <span class="comment">// are they even an oper at all?</span>
-00125 <span class="keywordflow">if</span> (strchr(this-&gt;modes,<span class="charliteral">'o'</span>))
-00126 {
-00127 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: %s is an oper"</span>,this-&gt;nick);
-00128 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j =0; j &lt; ConfValueEnum(<span class="stringliteral">"type"</span>,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>); j++)
-00129 {
-00130 ConfValue(<span class="stringliteral">"type"</span>,<span class="stringliteral">"name"</span>,j,TypeName,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
-00131 <span class="keywordflow">if</span> (!strcmp(TypeName,this-&gt;oper))
-00132 {
-00133 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: %s is an oper of type '%s'"</span>,this-&gt;nick,this-&gt;oper);
-00134 ConfValue(<span class="stringliteral">"type"</span>,<span class="stringliteral">"classes"</span>,j,Classes,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
-00135 <span class="keywordtype">char</span>* myclass = strtok_r(Classes,<span class="stringliteral">" "</span>,&amp;savept);
-00136 <span class="keywordflow">while</span> (myclass)
-00137 {
-00138 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: checking classtype '%s'"</span>,myclass);
-00139 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k =0; k &lt; ConfValueEnum(<span class="stringliteral">"class"</span>,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>); k++)
-00140 {
-00141 ConfValue(<span class="stringliteral">"class"</span>,<span class="stringliteral">"name"</span>,k,ClassName,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
-00142 <span class="keywordflow">if</span> (!strcmp(ClassName,myclass))
-00143 {
-00144 ConfValue(<span class="stringliteral">"class"</span>,<span class="stringliteral">"commands"</span>,k,CommandList,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
-00145 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: found class named %s with commands: '%s'"</span>,ClassName,CommandList);
-00146
-00147
-00148 mycmd = strtok_r(CommandList,<span class="stringliteral">" "</span>,&amp;savept2);
-00149 <span class="keywordflow">while</span> (mycmd)
-00150 {
-00151 <span class="keywordflow">if</span> (!strcasecmp(mycmd,command))
-00152 {
-00153 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** Command %s found, returning true"</span>,command);
-00154 <span class="keywordflow">return</span> <span class="keyword">true</span>;
-00155 }
-00156 mycmd = strtok_r(NULL,<span class="stringliteral">" "</span>,&amp;savept2);
-00157 }
-00158 }
-00159 }
-00160 myclass = strtok_r(NULL,<span class="stringliteral">" "</span>,&amp;savept);
-00161 }
-00162 }
-00163 }
-00164 }
-00165 <span class="keywordflow">return</span> <span class="keyword">false</span>;
-00166 }
-00167
-00168
-<a name="l00169"></a><a class="code" href="classuserrec.html#a8">00169</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a8">userrec::AddBuffer</a>(std::string a)
-00170 {
-00171 std::string b = <span class="stringliteral">""</span>;
-00172 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; a.length(); i++)
-00173 <span class="keywordflow">if</span> ((a[i] != <span class="charliteral">'\r'</span>) &amp;&amp; (a[i] != <span class="charliteral">'\0'</span>) &amp;&amp; (a[i] != 7))
-00174 b = b + a[i];
-00175 std::stringstream stream(<a class="code" href="classuserrec.html#o15">recvq</a>);
-00176 stream &lt;&lt; b;
-00177 <a class="code" href="classuserrec.html#o15">recvq</a> = stream.str();
-00178 <span class="keywordtype">int</span> i = 0;
-00179 <span class="comment">// count the size of the first line in the buffer.</span>
-00180 <span class="keywordflow">while</span> (i &lt; <a class="code" href="classuserrec.html#o15">recvq</a>.length())
-00181 {
-00182 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a>[i++] == <span class="charliteral">'\n'</span>)
-00183 <span class="keywordflow">break</span>;
-00184 }
-00185 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a>.length() &gt; this-&gt;<a class="code" href="classuserrec.html#o22">recvqmax</a>)
-00186 {
-00187 this-&gt;<a class="code" href="classuserrec.html#a12">SetWriteError</a>(<span class="stringliteral">"RecvQ exceeded"</span>);
-00188 WriteOpers(<span class="stringliteral">"*** User %s RecvQ of %d exceeds connect class maximum of %d"</span>,this-&gt;nick,<a class="code" href="classuserrec.html#o15">recvq</a>.length(),this-&gt;<a class="code" href="classuserrec.html#o22">recvqmax</a>);
-00189 }
-00190 <span class="comment">// return false if we've had more than 600 characters WITHOUT</span>
-00191 <span class="comment">// a carriage return (this is BAD, drop the socket)</span>
-00192 <span class="keywordflow">return</span> (i &lt; 600);
-00193 }
-00194
-<a name="l00195"></a><a class="code" href="classuserrec.html#a9">00195</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a9">userrec::BufferIsReady</a>()
-00196 {
-00197 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classuserrec.html#o15">recvq</a>.length(); i++)
-00198 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a>[i] == <span class="charliteral">'\n'</span>)
-00199 <span class="keywordflow">return</span> <span class="keyword">true</span>;
-00200 <span class="keywordflow">return</span> <span class="keyword">false</span>;
-00201 }
-00202
-<a name="l00203"></a><a class="code" href="classuserrec.html#a10">00203</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a10">userrec::ClearBuffer</a>()
-00204 {
-00205 <a class="code" href="classuserrec.html#o15">recvq</a> = <span class="stringliteral">""</span>;
-00206 }
-00207
-<a name="l00208"></a><a class="code" href="classuserrec.html#a11">00208</a> std::string <a class="code" href="classuserrec.html#a11">userrec::GetBuffer</a>()
-00209 {
-00210 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a> == <span class="stringliteral">""</span>)
-00211 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
-00212 <span class="keywordtype">char</span>* line = (<span class="keywordtype">char</span>*)<a class="code" href="classuserrec.html#o15">recvq</a>.c_str();
-00213 std::string ret = <span class="stringliteral">""</span>;
-00214 <span class="keywordflow">while</span> ((*line != <span class="charliteral">'\n'</span>) &amp;&amp; (strlen(line)))
-00215 {
-00216 ret = ret + *line;
-00217 line++;
-00218 }
-00219 <span class="keywordflow">if</span> ((*line == <span class="charliteral">'\n'</span>) || (*line == <span class="charliteral">'\r'</span>))
-00220 line++;
-00221 <a class="code" href="classuserrec.html#o15">recvq</a> = line;
-00222 <span class="keywordflow">return</span> ret;
-00223 }
-00224
-<a name="l00225"></a><a class="code" href="classuserrec.html#a14">00225</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a14">userrec::AddWriteBuf</a>(std::string data)
-00226 {
-00227 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classuserrec.html#a13">GetWriteError</a>() != <span class="stringliteral">""</span>)
-00228 <span class="keywordflow">return</span>;
-00229 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o16">sendq</a>.length() + data.length() &gt; this-&gt;<a class="code" href="classuserrec.html#o21">sendqmax</a>)
-00230 {
-00231 WriteOpers(<span class="stringliteral">"*** User %s SendQ of %d exceeds connect class maximum of %d"</span>,this-&gt;nick,<a class="code" href="classuserrec.html#o16">sendq</a>.length() + data.length(),this-&gt;<a class="code" href="classuserrec.html#o21">sendqmax</a>);
-00232 this-&gt;<a class="code" href="classuserrec.html#a12">SetWriteError</a>(<span class="stringliteral">"SendQ exceeded"</span>);
-00233 <span class="keywordflow">return</span>;
-00234 }
-00235 std::stringstream stream;
-00236 stream &lt;&lt; <a class="code" href="classuserrec.html#o16">sendq</a> &lt;&lt; data;
-00237 <a class="code" href="classuserrec.html#o16">sendq</a> = stream.str();
-00238 }
-00239
-00240 <span class="comment">// send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)</span>
-<a name="l00241"></a><a class="code" href="classuserrec.html#a15">00241</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a15">userrec::FlushWriteBuf</a>()
-00242 {
-00243 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o16">sendq</a>.length())
-00244 {
-00245 <span class="keywordtype">char</span>* tb = (<span class="keywordtype">char</span>*)this-&gt;<a class="code" href="classuserrec.html#o16">sendq</a>.c_str();
-00246 <span class="keywordtype">int</span> n_sent = write(this-&gt;fd,tb,this-&gt;sendq.length());
-00247 <span class="keywordflow">if</span> (n_sent == -1)
-00248 {
-00249 this-&gt;<a class="code" href="classuserrec.html#a12">SetWriteError</a>(strerror(errno));
-00250 }
-00251 <span class="keywordflow">else</span>
-00252 {
-00253 <span class="comment">// advance the queue</span>
-00254 tb += n_sent;
-00255 this-&gt;<a class="code" href="classuserrec.html#o16">sendq</a> = tb;
-00256 <span class="comment">// update the user's stats counters</span>
-00257 this-&gt;<a class="code" href="classconnection.html#o4">bytes_out</a> += n_sent;
-00258 this-&gt;<a class="code" href="classconnection.html#o6">cmds_out</a>++;
-00259 }
-00260 }
-00261 }
-00262
-<a name="l00263"></a><a class="code" href="classuserrec.html#a12">00263</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a12">userrec::SetWriteError</a>(std::string error)
-00264 {
-00265 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Setting error string for %s to '%s'"</span>,this-&gt;nick,error.c_str());
-00266 <span class="comment">// don't try to set the error twice, its already set take the first string.</span>
-00267 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classuserrec.html#o20">WriteError</a> == <span class="stringliteral">""</span>)
-00268 this-&gt;<a class="code" href="classuserrec.html#o20">WriteError</a> = error;
-00269 }
-00270
-<a name="l00271"></a><a class="code" href="classuserrec.html#a13">00271</a> std::string <a class="code" href="classuserrec.html#a13">userrec::GetWriteError</a>()
-00272 {
-00273 <span class="keywordflow">return</span> this-&gt;<a class="code" href="classuserrec.html#o20">WriteError</a>;
-00274 }
-</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 13 15:48:42 2005 for InspIRCd by
+00068
+<a name="l00069"></a><a class="code" href="classuserrec.html#a3">00069</a> <span class="keywordtype">char</span>* <a class="code" href="classuserrec.html#a3">userrec::GetFullRealHost</a>()
+00070 {
+00071 snprintf(<a class="code" href="classuserrec.html#o8">result</a>,MAXBUF,<span class="stringliteral">"%s!%s@%s"</span>,<a class="code" href="classuserrec.html#o0">nick</a>,<a class="code" href="classuserrec.html#o1">ident</a>,<a class="code" href="classconnection.html#o1">host</a>);
+00072 <span class="keywordflow">return</span> <a class="code" href="classuserrec.html#o8">result</a>;
+00073 }
+00074
+<a name="l00075"></a><a class="code" href="classuserrec.html#a4">00075</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a4">userrec::IsInvited</a>(<span class="keywordtype">char</span>* channel)
+00076 {
+00077 <span class="keywordflow">for</span> (InvitedList::iterator i = <a class="code" href="classuserrec.html#r0">invites</a>.begin(); i != <a class="code" href="classuserrec.html#r0">invites</a>.end(); i++)
+00078 {
+00079 <span class="keywordflow">if</span> (i-&gt;channel) {
+00080 <span class="keywordflow">if</span> (!strcasecmp(i-&gt;channel,channel))
+00081 {
+00082 <span class="keywordflow">return</span> <span class="keyword">true</span>;
+00083 }
+00084 }
+00085 }
+00086 <span class="keywordflow">return</span> <span class="keyword">false</span>;
+00087 }
+00088
+<a name="l00089"></a><a class="code" href="classuserrec.html#a16">00089</a> <a class="code" href="users_8h.html#a6">InvitedList</a>* <a class="code" href="classuserrec.html#a16">userrec::GetInviteList</a>()
+00090 {
+00091 <span class="keywordflow">return</span> &amp;<a class="code" href="classuserrec.html#r0">invites</a>;
+00092 }
+00093
+<a name="l00094"></a><a class="code" href="classuserrec.html#a5">00094</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a5">userrec::InviteTo</a>(<span class="keywordtype">char</span>* channel)
+00095 {
+00096 <a class="code" href="classInvited.html">Invited</a> i;
+00097 strlcpy(i.<a class="code" href="classInvited.html#o0">channel</a>,channel,CHANMAX);
+00098 <a class="code" href="classuserrec.html#r0">invites</a>.push_back(i);
+00099 }
+00100
+<a name="l00101"></a><a class="code" href="classuserrec.html#a6">00101</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a6">userrec::RemoveInvite</a>(<span class="keywordtype">char</span>* channel)
+00102 {
+00103 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Removing invites"</span>);
+00104 <span class="keywordflow">if</span> (channel)
+00105 {
+00106 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#r0">invites</a>.size())
+00107 {
+00108 <span class="keywordflow">for</span> (InvitedList::iterator i = <a class="code" href="classuserrec.html#r0">invites</a>.begin(); i != <a class="code" href="classuserrec.html#r0">invites</a>.end(); i++)
+00109 {
+00110 <span class="keywordflow">if</span> (i-&gt;channel)
+00111 {
+00112 <span class="keywordflow">if</span> (!strcasecmp(i-&gt;channel,channel))
+00113 {
+00114 <a class="code" href="classuserrec.html#r0">invites</a>.erase(i);
+00115 <span class="keywordflow">return</span>;
+00116 }
+00117 }
+00118 }
+00119 }
+00120 }
+00121 }
+00122
+<a name="l00123"></a><a class="code" href="classuserrec.html#a7">00123</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a7">userrec::HasPermission</a>(<span class="keywordtype">char</span>* command)
+00124 {
+00125 <span class="keywordtype">char</span> TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
+00126 <span class="keywordtype">char</span>* mycmd;
+00127 <span class="keywordtype">char</span>* savept;
+00128 <span class="keywordtype">char</span>* savept2;
+00129
+00130 <span class="comment">// are they even an oper at all?</span>
+00131 <span class="keywordflow">if</span> (strchr(this-&gt;modes,<span class="charliteral">'o'</span>))
+00132 {
+00133 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: %s is an oper"</span>,this-&gt;nick);
+00134 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j =0; j &lt; ConfValueEnum(<span class="stringliteral">"type"</span>,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>); j++)
+00135 {
+00136 ConfValue(<span class="stringliteral">"type"</span>,<span class="stringliteral">"name"</span>,j,TypeName,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
+00137 <span class="keywordflow">if</span> (!strcmp(TypeName,this-&gt;oper))
+00138 {
+00139 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: %s is an oper of type '%s'"</span>,this-&gt;nick,this-&gt;oper);
+00140 ConfValue(<span class="stringliteral">"type"</span>,<span class="stringliteral">"classes"</span>,j,Classes,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
+00141 <span class="keywordtype">char</span>* myclass = strtok_r(Classes,<span class="stringliteral">" "</span>,&amp;savept);
+00142 <span class="keywordflow">while</span> (myclass)
+00143 {
+00144 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: checking classtype '%s'"</span>,myclass);
+00145 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> k =0; k &lt; ConfValueEnum(<span class="stringliteral">"class"</span>,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>); k++)
+00146 {
+00147 ConfValue(<span class="stringliteral">"class"</span>,<span class="stringliteral">"name"</span>,k,ClassName,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
+00148 <span class="keywordflow">if</span> (!strcmp(ClassName,myclass))
+00149 {
+00150 ConfValue(<span class="stringliteral">"class"</span>,<span class="stringliteral">"commands"</span>,k,CommandList,&amp;<a class="code" href="channels_8cpp.html#a34">config_f</a>);
+00151 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: found class named %s with commands: '%s'"</span>,ClassName,CommandList);
+00152
+00153
+00154 mycmd = strtok_r(CommandList,<span class="stringliteral">" "</span>,&amp;savept2);
+00155 <span class="keywordflow">while</span> (mycmd)
+00156 {
+00157 <span class="keywordflow">if</span> (!strcasecmp(mycmd,command))
+00158 {
+00159 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** Command %s found, returning true"</span>,command);
+00160 <span class="keywordflow">return</span> <span class="keyword">true</span>;
+00161 }
+00162 mycmd = strtok_r(NULL,<span class="stringliteral">" "</span>,&amp;savept2);
+00163 }
+00164 }
+00165 }
+00166 myclass = strtok_r(NULL,<span class="stringliteral">" "</span>,&amp;savept);
+00167 }
+00168 }
+00169 }
+00170 }
+00171 <span class="keywordflow">return</span> <span class="keyword">false</span>;
+00172 }
+00173
+00174
+<a name="l00175"></a><a class="code" href="classuserrec.html#a8">00175</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a8">userrec::AddBuffer</a>(std::string a)
+00176 {
+00177 std::string b = <span class="stringliteral">""</span>;
+00178 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; a.length(); i++)
+00179 <span class="keywordflow">if</span> ((a[i] != <span class="charliteral">'\r'</span>) &amp;&amp; (a[i] != <span class="charliteral">'\0'</span>) &amp;&amp; (a[i] != 7))
+00180 b = b + a[i];
+00181 std::stringstream stream(<a class="code" href="classuserrec.html#o15">recvq</a>);
+00182 stream &lt;&lt; b;
+00183 <a class="code" href="classuserrec.html#o15">recvq</a> = stream.str();
+00184 <span class="keywordtype">int</span> i = 0;
+00185 <span class="comment">// count the size of the first line in the buffer.</span>
+00186 <span class="keywordflow">while</span> (i &lt; <a class="code" href="classuserrec.html#o15">recvq</a>.length())
+00187 {
+00188 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a>[i++] == <span class="charliteral">'\n'</span>)
+00189 <span class="keywordflow">break</span>;
+00190 }
+00191 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a>.length() &gt; this-&gt;<a class="code" href="classuserrec.html#o22">recvqmax</a>)
+00192 {
+00193 this-&gt;<a class="code" href="classuserrec.html#a12">SetWriteError</a>(<span class="stringliteral">"RecvQ exceeded"</span>);
+00194 WriteOpers(<span class="stringliteral">"*** User %s RecvQ of %d exceeds connect class maximum of %d"</span>,this-&gt;nick,<a class="code" href="classuserrec.html#o15">recvq</a>.length(),this-&gt;<a class="code" href="classuserrec.html#o22">recvqmax</a>);
+00195 }
+00196 <span class="comment">// return false if we've had more than 600 characters WITHOUT</span>
+00197 <span class="comment">// a carriage return (this is BAD, drop the socket)</span>
+00198 <span class="keywordflow">return</span> (i &lt; 600);
+00199 }
+00200
+<a name="l00201"></a><a class="code" href="classuserrec.html#a9">00201</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a9">userrec::BufferIsReady</a>()
+00202 {
+00203 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classuserrec.html#o15">recvq</a>.length(); i++)
+00204 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a>[i] == <span class="charliteral">'\n'</span>)
+00205 <span class="keywordflow">return</span> <span class="keyword">true</span>;
+00206 <span class="keywordflow">return</span> <span class="keyword">false</span>;
+00207 }
+00208
+<a name="l00209"></a><a class="code" href="classuserrec.html#a10">00209</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a10">userrec::ClearBuffer</a>()
+00210 {
+00211 <a class="code" href="classuserrec.html#o15">recvq</a> = <span class="stringliteral">""</span>;
+00212 }
+00213
+<a name="l00214"></a><a class="code" href="classuserrec.html#a11">00214</a> std::string <a class="code" href="classuserrec.html#a11">userrec::GetBuffer</a>()
+00215 {
+00216 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o15">recvq</a> == <span class="stringliteral">""</span>)
+00217 <span class="keywordflow">return</span> <span class="stringliteral">""</span>;
+00218 <span class="keywordtype">char</span>* line = (<span class="keywordtype">char</span>*)<a class="code" href="classuserrec.html#o15">recvq</a>.c_str();
+00219 std::string ret = <span class="stringliteral">""</span>;
+00220 <span class="keywordflow">while</span> ((*line != <span class="charliteral">'\n'</span>) &amp;&amp; (strlen(line)))
+00221 {
+00222 ret = ret + *line;
+00223 line++;
+00224 }
+00225 <span class="keywordflow">if</span> ((*line == <span class="charliteral">'\n'</span>) || (*line == <span class="charliteral">'\r'</span>))
+00226 line++;
+00227 <a class="code" href="classuserrec.html#o15">recvq</a> = line;
+00228 <span class="keywordflow">return</span> ret;
+00229 }
+00230
+<a name="l00231"></a><a class="code" href="classuserrec.html#a14">00231</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a14">userrec::AddWriteBuf</a>(std::string data)
+00232 {
+00233 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classuserrec.html#a13">GetWriteError</a>() != <span class="stringliteral">""</span>)
+00234 <span class="keywordflow">return</span>;
+00235 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o16">sendq</a>.length() + data.length() &gt; this-&gt;<a class="code" href="classuserrec.html#o21">sendqmax</a>)
+00236 {
+00237 WriteOpers(<span class="stringliteral">"*** User %s SendQ of %d exceeds connect class maximum of %d"</span>,this-&gt;nick,<a class="code" href="classuserrec.html#o16">sendq</a>.length() + data.length(),this-&gt;<a class="code" href="classuserrec.html#o21">sendqmax</a>);
+00238 this-&gt;<a class="code" href="classuserrec.html#a12">SetWriteError</a>(<span class="stringliteral">"SendQ exceeded"</span>);
+00239 <span class="keywordflow">return</span>;
+00240 }
+00241 std::stringstream stream;
+00242 stream &lt;&lt; <a class="code" href="classuserrec.html#o16">sendq</a> &lt;&lt; data;
+00243 <a class="code" href="classuserrec.html#o16">sendq</a> = stream.str();
+00244 }
+00245
+00246 <span class="comment">// send AS MUCH OF THE USERS SENDQ as we are able to (might not be all of it)</span>
+<a name="l00247"></a><a class="code" href="classuserrec.html#a15">00247</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a15">userrec::FlushWriteBuf</a>()
+00248 {
+00249 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#o16">sendq</a>.length())
+00250 {
+00251 <span class="keywordtype">char</span>* tb = (<span class="keywordtype">char</span>*)this-&gt;<a class="code" href="classuserrec.html#o16">sendq</a>.c_str();
+00252 <span class="keywordtype">int</span> n_sent = write(this-&gt;fd,tb,this-&gt;sendq.length());
+00253 <span class="keywordflow">if</span> (n_sent == -1)
+00254 {
+00255 this-&gt;<a class="code" href="classuserrec.html#a12">SetWriteError</a>(strerror(errno));
+00256 }
+00257 <span class="keywordflow">else</span>
+00258 {
+00259 <span class="comment">// advance the queue</span>
+00260 tb += n_sent;
+00261 this-&gt;<a class="code" href="classuserrec.html#o16">sendq</a> = tb;
+00262 <span class="comment">// update the user's stats counters</span>
+00263 this-&gt;<a class="code" href="classconnection.html#o4">bytes_out</a> += n_sent;
+00264 this-&gt;<a class="code" href="classconnection.html#o6">cmds_out</a>++;
+00265 }
+00266 }
+00267 }
+00268
+<a name="l00269"></a><a class="code" href="classuserrec.html#a12">00269</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a12">userrec::SetWriteError</a>(std::string error)
+00270 {
+00271 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Setting error string for %s to '%s'"</span>,this-&gt;nick,error.c_str());
+00272 <span class="comment">// don't try to set the error twice, its already set take the first string.</span>
+00273 <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classuserrec.html#o20">WriteError</a> == <span class="stringliteral">""</span>)
+00274 this-&gt;<a class="code" href="classuserrec.html#o20">WriteError</a> = error;
+00275 }
+00276
+<a name="l00277"></a><a class="code" href="classuserrec.html#a13">00277</a> std::string <a class="code" href="classuserrec.html#a13">userrec::GetWriteError</a>()
+00278 {
+00279 <span class="keywordflow">return</span> this-&gt;<a class="code" href="classuserrec.html#o20">WriteError</a>;
+00280 }
+</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun May 15 17:02:06 2005 for InspIRCd by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>