summaryrefslogtreecommitdiff
path: root/docs/module-doc/channels_8cpp-source.html
blob: de7bf1fb6c77cda82b649837215e9f3b855545cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>channels.cpp Source File</title>
<link href="inspircd.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3-rc3 -->
<center>
<a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>channels.cpp</h1><a href="channels_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#include "inspircd_config.h"</span> 
00002 <span class="preprocessor">#include "<a class="code" href="channels_8h.html">channels.h</a>"</span>
00003 <span class="preprocessor">#include "inspircd.h"</span>
00004 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
00005 <span class="preprocessor">#include &lt;string&gt;</span>
00006 <span class="preprocessor">#include &lt;vector&gt;</span>
00007 
00008 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
00009 
<a name="l00010"></a><a class="code" href="channels_8cpp.html#a0">00010</a> std::vector&lt;ModeParameter&gt; <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>;
00011 
<a name="l00012"></a><a class="code" href="classchanrec.html#a4">00012</a> <a class="code" href="classchanrec.html#a4">chanrec::chanrec</a>()
00013 {
00014         strcpy(name,<span class="stringliteral">""</span>);
00015         strcpy(custom_modes,<span class="stringliteral">""</span>);
00016         strcpy(topic,<span class="stringliteral">""</span>);
00017         strcpy(setby,<span class="stringliteral">""</span>);
00018         strcpy(key,<span class="stringliteral">""</span>);
00019         <a class="code" href="classchanrec.html#m3">created</a> = <a class="code" href="classchanrec.html#m4">topicset</a> = <a class="code" href="classchanrec.html#m6">limit</a> = 0;
00020         <a class="code" href="classchanrec.html#m8">topiclock</a> = <a class="code" href="classchanrec.html#m9">noexternal</a> = <a class="code" href="classchanrec.html#m10">inviteonly</a> = <a class="code" href="classchanrec.html#m11">moderated</a> = <a class="code" href="classchanrec.html#m12">secret</a> = <a class="code" href="classchanrec.html#m13">c_private</a> = <span class="keyword">false</span>;
00021 }
00022 
<a name="l00023"></a><a class="code" href="classchanrec.html#a0">00023</a> <span class="keywordtype">void</span> <a class="code" href="classchanrec.html#a0">chanrec::SetCustomMode</a>(<span class="keywordtype">char</span> mode,<span class="keywordtype">bool</span> mode_on)
00024 {
00025         <span class="keywordflow">if</span> (mode_on) {
00026                 <span class="keywordtype">char</span> m[3];
00027                 m[0] = mode;
00028                 m[1] = <span class="charliteral">'\0'</span>;
00029                 <span class="keywordflow">if</span> (!strchr(this-&gt;custom_modes,mode))
00030                 {
00031                         strncat(custom_modes,m,MAXMODES);
00032                 }
00033                 log(DEBUG,<span class="stringliteral">"Custom mode %c set"</span>,mode);
00034         }
00035         <span class="keywordflow">else</span> {
00036                 <span class="keywordtype">char</span> temp[MAXBUF];
00037                 <span class="keywordtype">int</span> count = 0;
00038                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> q = 0; q &lt; strlen(custom_modes); q++) {
00039                         <span class="keywordflow">if</span> (<a class="code" href="classchanrec.html#m1">custom_modes</a>[q] != mode) {
00040                                 temp[count++] = mode;
00041                         }
00042                 }
00043                 temp[count] = <span class="charliteral">'\0'</span>;
00044                 strncpy(custom_modes,temp,MAXMODES);
00045                 log(DEBUG,<span class="stringliteral">"Custom mode %c removed"</span>,mode);
00046                 this-&gt;<a class="code" href="classchanrec.html#a1">SetCustomModeParam</a>(mode,<span class="stringliteral">""</span>,<span class="keyword">false</span>);
00047         }
00048 }
00049 
<a name="l00050"></a><a class="code" href="classchanrec.html#a1">00050</a> <span class="keywordtype">void</span> <a class="code" href="classchanrec.html#a1">chanrec::SetCustomModeParam</a>(<span class="keywordtype">char</span> mode,<span class="keywordtype">char</span>* parameter,<span class="keywordtype">bool</span> mode_on)
00051 {
00052 
00053         log(DEBUG,<span class="stringliteral">"SetCustomModeParam called"</span>);
00054         <a class="code" href="classModeParameter.html">ModeParameter</a> M;
00055         M.<a class="code" href="classModeParameter.html#m0">mode</a> = mode;
00056         strcpy(M.<a class="code" href="classModeParameter.html#m2">channel</a>,this-&gt;name);
00057         strcpy(M.<a class="code" href="classModeParameter.html#m1">parameter</a>,parameter);
00058         <span class="keywordflow">if</span> (mode_on)
00059         {
00060                 log(DEBUG,<span class="stringliteral">"Custom mode parameter %c %s added"</span>,mode,parameter);
00061                 <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.push_back(M);
00062         }
00063         <span class="keywordflow">else</span>
00064         {
00065                 <span class="keywordflow">if</span> (<a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.size())
00066                 {
00067                         <span class="keywordflow">for</span> (vector&lt;ModeParameter&gt;::iterator i = <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.begin(); i &lt; <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.end(); i++)
00068                         {
00069                                 <span class="keywordflow">if</span> ((i-&gt;mode == mode) &amp;&amp; (!strcasecmp(this-&gt;name,i-&gt;channel)))
00070                                 {
00071                                         log(DEBUG,<span class="stringliteral">"Custom mode parameter %c %s removed"</span>,mode,parameter);
00072                                         <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.erase(i);
00073                                         <span class="keywordflow">return</span>;
00074                                 }
00075                         }
00076                 }
00077                 log(DEBUG,<span class="stringliteral">"*** BUG *** Attempt to remove non-existent mode parameter!"</span>);
00078         }
00079 }
00080 
<a name="l00081"></a><a class="code" href="classchanrec.html#a2">00081</a> <span class="keywordtype">bool</span> <a class="code" href="classchanrec.html#a2">chanrec::IsCustomModeSet</a>(<span class="keywordtype">char</span> mode)
00082 {
00083         log(DEBUG,<span class="stringliteral">"Checking ISCustomModeSet: %c %s"</span>,mode,this-&gt;custom_modes);
00084         <span class="keywordflow">return</span> (strchr(this-&gt;custom_modes,mode) != 0);
00085 }
00086 
<a name="l00087"></a><a class="code" href="classchanrec.html#a3">00087</a> std::string <a class="code" href="classchanrec.html#a3">chanrec::GetModeParameter</a>(<span class="keywordtype">char</span> mode)
00088 {
00089         <span class="keywordflow">if</span> (<a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.size())
00090         {
00091                 <span class="keywordflow">for</span> (vector&lt;ModeParameter&gt;::iterator i = <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.begin(); i &lt; <a class="code" href="channels_8cpp.html#a0">custom_mode_params</a>.end(); i++)
00092                 {
00093                         <span class="keywordflow">if</span> ((i-&gt;mode == mode) &amp;&amp; (!strcasecmp(this-&gt;name,i-&gt;channel)))
00094                         {
00095                                 <span class="keywordflow">return</span> std::string(i-&gt;parameter);
00096                         }
00097                 }
00098         }
00099         <span class="keywordflow">return</span> std::string(<span class="stringliteral">""</span>);
00100 }
</pre></div><hr><address style="align: right;"><small>Generated on Wed Apr 7 19:20:14 2004 for InspIRCd by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.3-rc3 </small></address>
</body>
</html>