]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/users_8cpp-source.html
Documentation update
[user/henk/code/inspircd.git] / docs / module-doc / users_8cpp-source.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>InspIRCd: users.cpp Source File</title>
4 <link href="inspircd.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3.3 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
8 <h1>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>
9 00002 <span class="comment"> *       | Inspire Internet Relay Chat Daemon |</span>
10 00003 <span class="comment"> *       +------------------------------------+</span>
11 00004 <span class="comment"> *</span>
12 00005 <span class="comment"> *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.</span>
13 00006 <span class="comment"> *                       E-mail:</span>
14 00007 <span class="comment"> *                &lt;brain@chatspike.net&gt;</span>
15 00008 <span class="comment"> *                &lt;Craig@chatspike.net&gt;</span>
16 00009 <span class="comment"> *     </span>
17 00010 <span class="comment"> * Written by Craig Edwards, Craig McLure, and others.</span>
18 00011 <span class="comment"> * This program is free but copyrighted software; see</span>
19 00012 <span class="comment"> *            the file COPYING for details.</span>
20 00013 <span class="comment"> *</span>
21 00014 <span class="comment"> * ---------------------------------------------------</span>
22 00015 <span class="comment"> */</span>
23 00016 
24 00017 <span class="preprocessor">#include "inspircd_config.h"</span> 
25 00018 <span class="preprocessor">#include "<a class="code" href="channels_8h.html">channels.h</a>"</span>
26 00019 <span class="preprocessor">#include "<a class="code" href="users_8h.html">users.h</a>"</span>
27 00020 <span class="preprocessor">#include "inspircd.h"</span>
28 00021 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
29 00022 
30 <a name="l00023"></a><a class="code" href="users_8cpp.html#a0">00023</a> <span class="keyword">extern</span> std::stringstream <a class="code" href="channels_8cpp.html#a34">config_f</a>;
31 00024 
32 <a name="l00025"></a><a class="code" href="classuserrec.html#a0">00025</a> <a class="code" href="classuserrec.html#a0">userrec::userrec</a>()
33 00026 {
34 00027         <span class="comment">// the PROPER way to do it, AVOID bzero at *ALL* costs</span>
35 00028         strcpy(<a class="code" href="classuserrec.html#o0">nick</a>,<span class="stringliteral">""</span>);
36 00029         strcpy(<a class="code" href="classconnection.html#o2">ip</a>,<span class="stringliteral">"127.0.0.1"</span>);
37 00030         <a class="code" href="classuserrec.html#o10">timeout</a> = 0;
38 00031         strcpy(<a class="code" href="classuserrec.html#o1">ident</a>,<span class="stringliteral">""</span>);
39 00032         strcpy(<a class="code" href="classconnection.html#o1">host</a>,<span class="stringliteral">""</span>);
40 00033         strcpy(<a class="code" href="classuserrec.html#o2">dhost</a>,<span class="stringliteral">""</span>);
41 00034         strcpy(<a class="code" href="classuserrec.html#o3">fullname</a>,<span class="stringliteral">""</span>);
42 00035         strcpy(<a class="code" href="classuserrec.html#o4">modes</a>,<span class="stringliteral">""</span>);
43 00036         strcpy(<a class="code" href="classconnection.html#o3">inbuf</a>,<span class="stringliteral">""</span>);
44 00037         strcpy(<a class="code" href="classuserrec.html#o6">server</a>,<span class="stringliteral">""</span>);
45 00038         strcpy(<a class="code" href="classuserrec.html#o7">awaymsg</a>,<span class="stringliteral">""</span>);
46 00039         <a class="code" href="classconnection.html#o0">fd</a> = <a class="code" href="classconnection.html#o12">lastping</a> = <a class="code" href="classconnection.html#o13">signon</a> = <a class="code" href="classconnection.html#o14">idle_lastmsg</a> = <a class="code" href="classconnection.html#o15">nping</a> = <a class="code" href="classconnection.html#o10">registered</a> = 0;
47 00040         <a class="code" href="classuserrec.html#o9">flood</a> = <a class="code" href="classconnection.html#o9">port</a> = <a class="code" href="classconnection.html#o4">bytes_in</a> = <a class="code" href="classconnection.html#o5">bytes_out</a> = <a class="code" href="classconnection.html#o6">cmds_in</a> = <a class="code" href="classconnection.html#o7">cmds_out</a> = 0;
48 00041         <a class="code" href="classconnection.html#o8">haspassed</a> = <span class="keyword">false</span>;
49 00042         strcpy(<a class="code" href="classuserrec.html#o8">result</a>,<span class="stringliteral">""</span>);
50 00043         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; MAXCHANS; i++)
51 00044         {
52 00045                 this-&gt;<a class="code" href="classuserrec.html#o5">chans</a>[i].<a class="code" href="classucrec.html#o1">channel</a> = NULL;
53 00046                 this-&gt;<a class="code" href="classuserrec.html#o5">chans</a>[i].<a class="code" href="classucrec.html#o0">uc_modes</a> = 0;
54 00047         }
55 00048         <a class="code" href="classuserrec.html#r0">invites</a>.clear();
56 00049 }
57 00050 
58 00051 
59 00052  
60 <a name="l00053"></a><a class="code" href="classuserrec.html#a2">00053</a> <span class="keywordtype">char</span>* <a class="code" href="classuserrec.html#a2">userrec::GetFullHost</a>()
61 00054 {
62 00055         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>);
63 00056         <span class="keywordflow">return</span> <a class="code" href="classuserrec.html#o8">result</a>;
64 00057 }
65 00058 
66 00059 
67 <a name="l00060"></a><a class="code" href="classuserrec.html#a3">00060</a> <span class="keywordtype">char</span>* <a class="code" href="classuserrec.html#a3">userrec::GetFullRealHost</a>()
68 00061 {
69 00062         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>);
70 00063         <span class="keywordflow">return</span> <a class="code" href="classuserrec.html#o8">result</a>;
71 00064 }
72 00065 
73 <a name="l00066"></a><a class="code" href="classuserrec.html#a4">00066</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a4">userrec::IsInvited</a>(<span class="keywordtype">char</span>* channel)
74 00067 {
75 00068         <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++)
76 00069         {
77 00070                 <span class="keywordflow">if</span> (i-&gt;channel) {
78 00071                         <span class="keywordflow">if</span> (!strcasecmp(i-&gt;channel,channel))
79 00072                         {
80 00073                                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
81 00074                         }
82 00075                 }
83 00076         }
84 00077         <span class="keywordflow">return</span> <span class="keyword">false</span>;
85 00078 }
86 00079 
87 <a name="l00080"></a><a class="code" href="classuserrec.html#a5">00080</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a5">userrec::InviteTo</a>(<span class="keywordtype">char</span>* channel)
88 00081 {
89 00082         <a class="code" href="classInvited.html">Invited</a> i;
90 00083         strlcpy(i.<a class="code" href="classInvited.html#o0">channel</a>,channel,CHANMAX);
91 00084         <a class="code" href="classuserrec.html#r0">invites</a>.push_back(i);
92 00085 }
93 00086 
94 <a name="l00087"></a><a class="code" href="classuserrec.html#a6">00087</a> <span class="keywordtype">void</span> <a class="code" href="classuserrec.html#a6">userrec::RemoveInvite</a>(<span class="keywordtype">char</span>* channel)
95 00088 {
96 00089         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"Removing invites"</span>);
97 00090         <span class="keywordflow">if</span> (channel)
98 00091         {
99 00092                 <span class="keywordflow">if</span> (<a class="code" href="classuserrec.html#r0">invites</a>.size())
100 00093                 {
101 00094                         <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++)
102 00095                         {
103 00096                                 <span class="keywordflow">if</span> (i-&gt;channel)
104 00097                                 {
105 00098                                         <span class="keywordflow">if</span> (!strcasecmp(i-&gt;channel,channel))
106 00099                                         {
107 00100                                                 <a class="code" href="classuserrec.html#r0">invites</a>.erase(i);
108 00101                                                 <span class="keywordflow">return</span>;
109 00102                                         }
110 00103                                 }
111 00104                         }
112 00105                 }
113 00106         }
114 00107 }
115 00108 
116 <a name="l00109"></a><a class="code" href="classuserrec.html#a7">00109</a> <span class="keywordtype">bool</span> <a class="code" href="classuserrec.html#a7">userrec::HasPermission</a>(<span class="keywordtype">char</span>* command)
117 00110 {
118 00111         <span class="keywordtype">char</span> TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF];
119 00112         <span class="keywordtype">char</span>* myclass;
120 00113         <span class="keywordtype">char</span>* mycmd;
121 00114         <span class="keywordtype">char</span>* savept;
122 00115         <span class="keywordtype">char</span>* savept2;
123 00116         
124 00117         <span class="comment">// are they even an oper at all?</span>
125 00118         <span class="keywordflow">if</span> (strchr(this-&gt;modes,<span class="charliteral">'o'</span>))
126 00119         {
127 00120                 log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: %s is an oper"</span>,this-&gt;nick);
128 00121                 <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++)
129 00122                 {
130 00123                         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>);
131 00124                         <span class="keywordflow">if</span> (!strcmp(TypeName,this-&gt;oper))
132 00125                         {
133 00126                                 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);
134 00127                                 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>);
135 00128                                 <span class="keywordtype">char</span>* myclass = strtok_r(Classes,<span class="stringliteral">" "</span>,&amp;savept);
136 00129                                 <span class="keywordflow">while</span> (myclass)
137 00130                                 {
138 00131                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** HasPermission: checking classtype '%s'"</span>,myclass);
139 00132                                         <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++)
140 00133                                         {
141 00134                                                 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>);
142 00135                                                 <span class="keywordflow">if</span> (!strcmp(ClassName,myclass))
143 00136                                                 {
144 00137                                                         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>);
145 00138                                                         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);
146 00139                                                         
147 00140                                                         
148 00141                                                         mycmd = strtok_r(CommandList,<span class="stringliteral">" "</span>,&amp;savept2);
149 00142                                                         <span class="keywordflow">while</span> (mycmd)
150 00143                                                         {
151 00144                                                                 <span class="keywordflow">if</span> (!strcasecmp(mycmd,command))
152 00145                                                                 {
153 00146                                                                         log(<a class="code" href="modules_8h.html#a0">DEBUG</a>,<span class="stringliteral">"*** Command %s found, returning true"</span>,command);
154 00147                                                                         <span class="keywordflow">return</span> <span class="keyword">true</span>;
155 00148                                                                 }
156 00149                                                                 mycmd = strtok_r(NULL,<span class="stringliteral">" "</span>,&amp;savept2);
157 00150                                                         }
158 00151                                                 }
159 00152                                         }
160 00153                                         myclass = strtok_r(NULL,<span class="stringliteral">" "</span>,&amp;savept);
161 00154                                 }
162 00155                         }
163 00156                 }
164 00157         }
165 00158         <span class="keywordflow">return</span> <span class="keyword">false</span>;
166 00159 }
167 00160 
168 00161 
169 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Mar 25 03:49:29 2005 for InspIRCd by
170 <a href="http://www.doxygen.org/index.html">
171 <img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
172 </a>1.3.3 </small></address>
173 </body>
174 </html>