Blame


1 c23199d9 2002-02-27 alex /*
2 c23199d9 2002-02-27 alex * ngIRCd -- The Next Generation IRC Daemon
3 aa25cd7d 2005-04-27 alex * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
4 c23199d9 2002-02-27 alex *
5 490f28ff 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 490f28ff 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 490f28ff 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 490f28ff 2002-12-12 alex * (at your option) any later version.
9 490f28ff 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
10 c23199d9 2002-02-27 alex *
11 490f28ff 2002-12-12 alex * Sending IRC commands over the network
12 c23199d9 2002-02-27 alex */
13 c23199d9 2002-02-27 alex
14 c23199d9 2002-02-27 alex
15 ca33cbda 2002-03-12 alex #include "portab.h"
16 490f28ff 2002-12-12 alex
17 aa25cd7d 2005-04-27 alex static char UNUSED id[] = "$Id: irc-write.c,v 1.18 2005/04/27 07:39:18 alex Exp $";
18 c23199d9 2002-02-27 alex
19 ca33cbda 2002-03-12 alex #include "imp.h"
20 c23199d9 2002-02-27 alex #include <assert.h>
21 c1f32e82 2004-10-20 alex #ifdef PROTOTYPES
22 c1f32e82 2004-10-20 alex # include <stdarg.h>
23 c1f32e82 2004-10-20 alex #else
24 c1f32e82 2004-10-20 alex # include <varargs.h>
25 c1f32e82 2004-10-20 alex #endif
26 c23199d9 2002-02-27 alex #include <stdio.h>
27 3010f034 2002-09-03 alex #include <string.h>
28 c23199d9 2002-02-27 alex
29 aa25cd7d 2005-04-27 alex #include "defines.h"
30 b8d7dcec 2002-12-30 alex #include "conn-func.h"
31 c2f60abe 2002-05-27 alex #include "client.h"
32 c2f60abe 2002-05-27 alex #include "channel.h"
33 ca33cbda 2002-03-12 alex
34 ca33cbda 2002-03-12 alex #include "exp.h"
35 c23199d9 2002-02-27 alex #include "irc-write.h"
36 c23199d9 2002-02-27 alex
37 c23199d9 2002-02-27 alex
38 4c870f4b 2002-11-04 alex #define SEND_TO_USER 1
39 4c870f4b 2002-11-04 alex #define SEND_TO_SERVER 2
40 4c870f4b 2002-11-04 alex
41 4c870f4b 2002-11-04 alex
42 8adff592 2005-03-19 fw LOCAL char *Get_Prefix PARAMS(( CLIENT *Target, CLIENT *Client ));
43 c23199d9 2002-02-27 alex
44 c23199d9 2002-02-27 alex
45 f7327524 2002-05-30 alex #ifdef PROTOTYPES
46 8adff592 2005-03-19 fw GLOBAL bool
47 8adff592 2005-03-19 fw IRC_WriteStrClient( CLIENT *Client, char *Format, ... )
48 f7327524 2002-05-30 alex #else
49 8adff592 2005-03-19 fw GLOBAL bool
50 f7327524 2002-05-30 alex IRC_WriteStrClient( Client, Format, va_alist )
51 f7327524 2002-05-30 alex CLIENT *Client;
52 8adff592 2005-03-19 fw char *Format;
53 f7327524 2002-05-30 alex va_dcl
54 f7327524 2002-05-30 alex #endif
55 c23199d9 2002-02-27 alex {
56 8adff592 2005-03-19 fw char buffer[1000];
57 8adff592 2005-03-19 fw bool ok = CONNECTED;
58 c23199d9 2002-02-27 alex va_list ap;
59 c23199d9 2002-02-27 alex
60 c23199d9 2002-02-27 alex assert( Client != NULL );
61 c23199d9 2002-02-27 alex assert( Format != NULL );
62 c23199d9 2002-02-27 alex
63 f7327524 2002-05-30 alex #ifdef PROTOTYPES
64 c23199d9 2002-02-27 alex va_start( ap, Format );
65 f7327524 2002-05-30 alex #else
66 f7327524 2002-05-30 alex va_start( ap );
67 f7327524 2002-05-30 alex #endif
68 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
69 c23199d9 2002-02-27 alex va_end( ap );
70 c23199d9 2002-02-27 alex
71 c23199d9 2002-02-27 alex /* an den Client selber */
72 ec474a4b 2002-10-04 alex ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), "%s", buffer );
73 c23199d9 2002-02-27 alex
74 c23199d9 2002-02-27 alex return ok;
75 c23199d9 2002-02-27 alex } /* IRC_WriteStrClient */
76 c23199d9 2002-02-27 alex
77 c23199d9 2002-02-27 alex
78 f7327524 2002-05-30 alex #ifdef PROTOTYPES
79 8adff592 2005-03-19 fw GLOBAL bool
80 8adff592 2005-03-19 fw IRC_WriteStrClientPrefix( CLIENT *Client, CLIENT *Prefix, char *Format, ... )
81 f7327524 2002-05-30 alex #else
82 8adff592 2005-03-19 fw GLOBAL bool
83 f7327524 2002-05-30 alex IRC_WriteStrClientPrefix( Client, Prefix, Format, va_alist )
84 f7327524 2002-05-30 alex CLIENT *Client;
85 f7327524 2002-05-30 alex CLIENT *Prefix;
86 8adff592 2005-03-19 fw char *Format;
87 f7327524 2002-05-30 alex va_dcl
88 f7327524 2002-05-30 alex #endif
89 c23199d9 2002-02-27 alex {
90 c23199d9 2002-02-27 alex /* Text an Clients, lokal bzw. remote, senden. */
91 c23199d9 2002-02-27 alex
92 8adff592 2005-03-19 fw char buffer[1000];
93 c23199d9 2002-02-27 alex va_list ap;
94 c23199d9 2002-02-27 alex
95 c23199d9 2002-02-27 alex assert( Client != NULL );
96 c23199d9 2002-02-27 alex assert( Format != NULL );
97 c23199d9 2002-02-27 alex assert( Prefix != NULL );
98 c23199d9 2002-02-27 alex
99 f7327524 2002-05-30 alex #ifdef PROTOTYPES
100 c23199d9 2002-02-27 alex va_start( ap, Format );
101 f7327524 2002-05-30 alex #else
102 f7327524 2002-05-30 alex va_start( ap );
103 f7327524 2002-05-30 alex #endif
104 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
105 c23199d9 2002-02-27 alex va_end( ap );
106 c23199d9 2002-02-27 alex
107 c23199d9 2002-02-27 alex return Conn_WriteStr( Client_Conn( Client_NextHop( Client )), ":%s %s", Get_Prefix( Client_NextHop( Client ), Prefix ), buffer );
108 c23199d9 2002-02-27 alex } /* IRC_WriteStrClientPrefix */
109 c23199d9 2002-02-27 alex
110 c23199d9 2002-02-27 alex
111 f7327524 2002-05-30 alex #ifdef PROTOTYPES
112 8adff592 2005-03-19 fw GLOBAL bool
113 8adff592 2005-03-19 fw IRC_WriteStrChannel( CLIENT *Client, CHANNEL *Chan, bool Remote, char *Format, ... )
114 f7327524 2002-05-30 alex #else
115 8adff592 2005-03-19 fw GLOBAL bool
116 f7327524 2002-05-30 alex IRC_WriteStrChannel( Client, Chan, Remote, Format, va_alist )
117 f7327524 2002-05-30 alex CLIENT *Client;
118 f7327524 2002-05-30 alex CHANNEL *Chan;
119 8adff592 2005-03-19 fw bool Remote;
120 8adff592 2005-03-19 fw char *Format;
121 f7327524 2002-05-30 alex va_dcl
122 f7327524 2002-05-30 alex #endif
123 c23199d9 2002-02-27 alex {
124 8adff592 2005-03-19 fw char buffer[1000];
125 c23199d9 2002-02-27 alex va_list ap;
126 c23199d9 2002-02-27 alex
127 c23199d9 2002-02-27 alex assert( Client != NULL );
128 c23199d9 2002-02-27 alex assert( Format != NULL );
129 c23199d9 2002-02-27 alex
130 f7327524 2002-05-30 alex #ifdef PROTOTYPES
131 c23199d9 2002-02-27 alex va_start( ap, Format );
132 f7327524 2002-05-30 alex #else
133 f7327524 2002-05-30 alex va_start( ap );
134 f7327524 2002-05-30 alex #endif
135 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
136 c23199d9 2002-02-27 alex va_end( ap );
137 c23199d9 2002-02-27 alex
138 ec474a4b 2002-10-04 alex return IRC_WriteStrChannelPrefix( Client, Chan, Client_ThisServer( ), Remote, "%s", buffer );
139 c23199d9 2002-02-27 alex } /* IRC_WriteStrChannel */
140 c23199d9 2002-02-27 alex
141 c23199d9 2002-02-27 alex
142 f7327524 2002-05-30 alex #ifdef PROTOTYPES
143 8adff592 2005-03-19 fw GLOBAL bool
144 8adff592 2005-03-19 fw IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... )
145 f7327524 2002-05-30 alex #else
146 8adff592 2005-03-19 fw GLOBAL bool
147 f7327524 2002-05-30 alex IRC_WriteStrChannelPrefix( Client, Chan, Prefix, Remote, Format, va_alist )
148 f7327524 2002-05-30 alex CLIENT *Client;
149 f7327524 2002-05-30 alex CHANNEL *Chan;
150 f7327524 2002-05-30 alex CLIENT *Prefix;
151 8adff592 2005-03-19 fw bool Remote;
152 8adff592 2005-03-19 fw char *Format;
153 f7327524 2002-05-30 alex va_dcl
154 f7327524 2002-05-30 alex #endif
155 c23199d9 2002-02-27 alex {
156 8adff592 2005-03-19 fw bool ok = CONNECTED;
157 8adff592 2005-03-19 fw char buffer[1000];
158 c23199d9 2002-02-27 alex CL2CHAN *cl2chan;
159 601f0ede 2002-11-02 alex CONN_ID conn;
160 c23199d9 2002-02-27 alex CLIENT *c;
161 c23199d9 2002-02-27 alex va_list ap;
162 c23199d9 2002-02-27 alex
163 c23199d9 2002-02-27 alex assert( Client != NULL );
164 c23199d9 2002-02-27 alex assert( Chan != NULL );
165 c23199d9 2002-02-27 alex assert( Prefix != NULL );
166 c23199d9 2002-02-27 alex assert( Format != NULL );
167 c23199d9 2002-02-27 alex
168 f7327524 2002-05-30 alex #ifdef PROTOTYPES
169 c23199d9 2002-02-27 alex va_start( ap, Format );
170 f7327524 2002-05-30 alex #else
171 f7327524 2002-05-30 alex va_start( ap );
172 f7327524 2002-05-30 alex #endif
173 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
174 c23199d9 2002-02-27 alex va_end( ap );
175 c23199d9 2002-02-27 alex
176 601f0ede 2002-11-02 alex Conn_ClearFlags( );
177 c23199d9 2002-02-27 alex
178 c23199d9 2002-02-27 alex /* An alle Clients, die in den selben Channels sind.
179 c23199d9 2002-02-27 alex * Dabei aber nur einmal je Remote-Server */
180 c23199d9 2002-02-27 alex cl2chan = Channel_FirstMember( Chan );
181 c23199d9 2002-02-27 alex while( cl2chan )
182 c23199d9 2002-02-27 alex {
183 c23199d9 2002-02-27 alex c = Channel_GetClient( cl2chan );
184 c23199d9 2002-02-27 alex if( ! Remote )
185 c23199d9 2002-02-27 alex {
186 c23199d9 2002-02-27 alex if( Client_Conn( c ) <= NONE ) c = NULL;
187 c23199d9 2002-02-27 alex else if( Client_Type( c ) == CLIENT_SERVER ) c = NULL;
188 c23199d9 2002-02-27 alex }
189 c23199d9 2002-02-27 alex if( c ) c = Client_NextHop( c );
190 c23199d9 2002-02-27 alex
191 c23199d9 2002-02-27 alex if( c && ( c != Client ))
192 c23199d9 2002-02-27 alex {
193 c23199d9 2002-02-27 alex /* Ok, anderer Client */
194 601f0ede 2002-11-02 alex conn = Client_Conn( c );
195 4c870f4b 2002-11-04 alex if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
196 4c870f4b 2002-11-04 alex else Conn_SetFlag( conn, SEND_TO_USER );
197 c23199d9 2002-02-27 alex }
198 c23199d9 2002-02-27 alex cl2chan = Channel_NextMember( Chan, cl2chan );
199 c23199d9 2002-02-27 alex }
200 c23199d9 2002-02-27 alex
201 4c870f4b 2002-11-04 alex /* Senden: alle Verbindungen durchgehen ... */
202 601f0ede 2002-11-02 alex conn = Conn_First( );
203 601f0ede 2002-11-02 alex while( conn != NONE )
204 c23199d9 2002-02-27 alex {
205 4c870f4b 2002-11-04 alex /* muessen Daten ueber diese Verbindung verschickt werden? */
206 4c870f4b 2002-11-04 alex if( Conn_Flag( conn ) == SEND_TO_SERVER) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
207 4c870f4b 2002-11-04 alex else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
208 4c870f4b 2002-11-04 alex if( ! ok ) break;
209 4c870f4b 2002-11-04 alex
210 4c870f4b 2002-11-04 alex /* naechste Verbindung testen */
211 601f0ede 2002-11-02 alex conn = Conn_Next( conn );
212 c23199d9 2002-02-27 alex }
213 601f0ede 2002-11-02 alex
214 c23199d9 2002-02-27 alex return ok;
215 c23199d9 2002-02-27 alex } /* IRC_WriteStrChannelPrefix */
216 c23199d9 2002-02-27 alex
217 c23199d9 2002-02-27 alex
218 f7327524 2002-05-30 alex #ifdef PROTOTYPES
219 8adff592 2005-03-19 fw GLOBAL void
220 8adff592 2005-03-19 fw IRC_WriteStrServers( CLIENT *ExceptOf, char *Format, ... )
221 f7327524 2002-05-30 alex #else
222 8adff592 2005-03-19 fw GLOBAL void
223 f7327524 2002-05-30 alex IRC_WriteStrServers( ExceptOf, Format, va_alist )
224 f7327524 2002-05-30 alex CLIENT *ExceptOf;
225 8adff592 2005-03-19 fw char *Format;
226 f7327524 2002-05-30 alex va_dcl
227 f7327524 2002-05-30 alex #endif
228 c23199d9 2002-02-27 alex {
229 8adff592 2005-03-19 fw char buffer[1000];
230 c23199d9 2002-02-27 alex va_list ap;
231 c23199d9 2002-02-27 alex
232 c23199d9 2002-02-27 alex assert( Format != NULL );
233 c23199d9 2002-02-27 alex
234 f7327524 2002-05-30 alex #ifdef PROTOTYPES
235 c23199d9 2002-02-27 alex va_start( ap, Format );
236 f7327524 2002-05-30 alex #else
237 f7327524 2002-05-30 alex va_start( ap );
238 f7327524 2002-05-30 alex #endif
239 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
240 c23199d9 2002-02-27 alex va_end( ap );
241 c23199d9 2002-02-27 alex
242 c23199d9 2002-02-27 alex /* an den Client selber */
243 ec474a4b 2002-10-04 alex IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), "%s", buffer );
244 c23199d9 2002-02-27 alex } /* IRC_WriteStrServers */
245 c23199d9 2002-02-27 alex
246 c23199d9 2002-02-27 alex
247 f7327524 2002-05-30 alex #ifdef PROTOTYPES
248 8adff592 2005-03-19 fw GLOBAL void
249 8adff592 2005-03-19 fw IRC_WriteStrServersPrefix( CLIENT *ExceptOf, CLIENT *Prefix, char *Format, ... )
250 f7327524 2002-05-30 alex #else
251 8adff592 2005-03-19 fw GLOBAL void
252 f7327524 2002-05-30 alex IRC_WriteStrServersPrefix( ExceptOf, Prefix, Format, va_alist )
253 3010f034 2002-09-03 alex CLIENT *ExceptOf;
254 3010f034 2002-09-03 alex CLIENT *Prefix;
255 8adff592 2005-03-19 fw char *Format;
256 3010f034 2002-09-03 alex va_dcl
257 3010f034 2002-09-03 alex #endif
258 3010f034 2002-09-03 alex {
259 8adff592 2005-03-19 fw char buffer[1000];
260 3010f034 2002-09-03 alex va_list ap;
261 3010f034 2002-09-03 alex
262 3010f034 2002-09-03 alex assert( Format != NULL );
263 3010f034 2002-09-03 alex assert( Prefix != NULL );
264 3010f034 2002-09-03 alex
265 3010f034 2002-09-03 alex #ifdef PROTOTYPES
266 3010f034 2002-09-03 alex va_start( ap, Format );
267 3010f034 2002-09-03 alex #else
268 3010f034 2002-09-03 alex va_start( ap );
269 3010f034 2002-09-03 alex #endif
270 3010f034 2002-09-03 alex vsnprintf( buffer, 1000, Format, ap );
271 3010f034 2002-09-03 alex va_end( ap );
272 3010f034 2002-09-03 alex
273 ec474a4b 2002-10-04 alex IRC_WriteStrServersPrefixFlag( ExceptOf, Prefix, '\0', "%s", buffer );
274 3010f034 2002-09-03 alex } /* IRC_WriteStrServersPrefix */
275 3010f034 2002-09-03 alex
276 3010f034 2002-09-03 alex
277 3010f034 2002-09-03 alex #ifdef PROTOTYPES
278 8adff592 2005-03-19 fw GLOBAL void
279 8adff592 2005-03-19 fw IRC_WriteStrServersPrefixFlag( CLIENT *ExceptOf, CLIENT *Prefix, char Flag, char *Format, ... )
280 3010f034 2002-09-03 alex #else
281 8adff592 2005-03-19 fw GLOBAL void
282 3010f034 2002-09-03 alex IRC_WriteStrServersPrefixFlag( ExceptOf, Prefix, Flag, Format, va_alist )
283 f7327524 2002-05-30 alex CLIENT *ExceptOf;
284 f7327524 2002-05-30 alex CLIENT *Prefix;
285 8adff592 2005-03-19 fw char Flag;
286 8adff592 2005-03-19 fw char *Format;
287 f7327524 2002-05-30 alex va_dcl
288 f7327524 2002-05-30 alex #endif
289 c23199d9 2002-02-27 alex {
290 8adff592 2005-03-19 fw char buffer[1000];
291 c23199d9 2002-02-27 alex CLIENT *c;
292 c23199d9 2002-02-27 alex va_list ap;
293 c23199d9 2002-02-27 alex
294 c23199d9 2002-02-27 alex assert( Format != NULL );
295 c23199d9 2002-02-27 alex assert( Prefix != NULL );
296 c23199d9 2002-02-27 alex
297 f7327524 2002-05-30 alex #ifdef PROTOTYPES
298 c23199d9 2002-02-27 alex va_start( ap, Format );
299 f7327524 2002-05-30 alex #else
300 f7327524 2002-05-30 alex va_start( ap );
301 f7327524 2002-05-30 alex #endif
302 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
303 c23199d9 2002-02-27 alex va_end( ap );
304 c23199d9 2002-02-27 alex
305 c23199d9 2002-02-27 alex c = Client_First( );
306 c23199d9 2002-02-27 alex while( c )
307 c23199d9 2002-02-27 alex {
308 c23199d9 2002-02-27 alex if(( Client_Type( c ) == CLIENT_SERVER ) && ( Client_Conn( c ) > NONE ) && ( c != Client_ThisServer( )) && ( c != ExceptOf ))
309 c23199d9 2002-02-27 alex {
310 3010f034 2002-09-03 alex /* Ziel-Server gefunden. Nun noch pruefen, ob Flags stimmen */
311 ec474a4b 2002-10-04 alex if(( Flag == '\0' ) || ( strchr( Client_Flags( c ), Flag ) != NULL )) IRC_WriteStrClientPrefix( c, Prefix, "%s", buffer );
312 c23199d9 2002-02-27 alex }
313 c23199d9 2002-02-27 alex c = Client_Next( c );
314 c23199d9 2002-02-27 alex }
315 3010f034 2002-09-03 alex } /* IRC_WriteStrServersPrefixFlag */
316 c23199d9 2002-02-27 alex
317 c23199d9 2002-02-27 alex
318 f7327524 2002-05-30 alex #ifdef PROTOTYPES
319 8adff592 2005-03-19 fw GLOBAL bool
320 8adff592 2005-03-19 fw IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... )
321 f7327524 2002-05-30 alex #else
322 8adff592 2005-03-19 fw GLOBAL bool
323 f7327524 2002-05-30 alex IRC_WriteStrRelatedPrefix( Client, Prefix, Remote, Format, va_alist )
324 f7327524 2002-05-30 alex CLIENT *Client;
325 f7327524 2002-05-30 alex CLIENT *Prefix;
326 8adff592 2005-03-19 fw bool Remote;
327 8adff592 2005-03-19 fw char *Format;
328 f7327524 2002-05-30 alex va_dcl
329 f7327524 2002-05-30 alex #endif
330 c23199d9 2002-02-27 alex {
331 8adff592 2005-03-19 fw bool ok = CONNECTED;
332 c23199d9 2002-02-27 alex CL2CHAN *chan_cl2chan, *cl2chan;
333 8adff592 2005-03-19 fw char buffer[1000];
334 c23199d9 2002-02-27 alex CHANNEL *chan;
335 601f0ede 2002-11-02 alex CONN_ID conn;
336 c23199d9 2002-02-27 alex va_list ap;
337 c23199d9 2002-02-27 alex CLIENT *c;
338 c23199d9 2002-02-27 alex
339 c23199d9 2002-02-27 alex assert( Client != NULL );
340 c23199d9 2002-02-27 alex assert( Prefix != NULL );
341 c23199d9 2002-02-27 alex assert( Format != NULL );
342 c23199d9 2002-02-27 alex
343 f7327524 2002-05-30 alex #ifdef PROTOTYPES
344 c23199d9 2002-02-27 alex va_start( ap, Format );
345 f7327524 2002-05-30 alex #else
346 f7327524 2002-05-30 alex va_start( ap );
347 f7327524 2002-05-30 alex #endif
348 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
349 c23199d9 2002-02-27 alex va_end( ap );
350 c23199d9 2002-02-27 alex
351 c23199d9 2002-02-27 alex /* initialisieren */
352 601f0ede 2002-11-02 alex Conn_ClearFlags( );
353 c23199d9 2002-02-27 alex
354 c23199d9 2002-02-27 alex /* An alle Clients, die in einem Channel mit dem "Ausloeser" sind,
355 c23199d9 2002-02-27 alex * den Text schicken. An Remote-Server aber jeweils nur einmal. */
356 c23199d9 2002-02-27 alex chan_cl2chan = Channel_FirstChannelOf( Client );
357 c23199d9 2002-02-27 alex while( chan_cl2chan )
358 c23199d9 2002-02-27 alex {
359 c23199d9 2002-02-27 alex /* Channel des Users durchsuchen */
360 c23199d9 2002-02-27 alex chan = Channel_GetChannel( chan_cl2chan );
361 c23199d9 2002-02-27 alex cl2chan = Channel_FirstMember( chan );
362 c23199d9 2002-02-27 alex while( cl2chan )
363 c23199d9 2002-02-27 alex {
364 c23199d9 2002-02-27 alex c = Channel_GetClient( cl2chan );
365 c23199d9 2002-02-27 alex if( ! Remote )
366 c23199d9 2002-02-27 alex {
367 c23199d9 2002-02-27 alex if( Client_Conn( c ) <= NONE ) c = NULL;
368 c23199d9 2002-02-27 alex else if( Client_Type( c ) == CLIENT_SERVER ) c = NULL;
369 c23199d9 2002-02-27 alex }
370 c23199d9 2002-02-27 alex if( c ) c = Client_NextHop( c );
371 c23199d9 2002-02-27 alex
372 c23199d9 2002-02-27 alex if( c && ( c != Client ))
373 c23199d9 2002-02-27 alex {
374 c23199d9 2002-02-27 alex /* Ok, anderer Client */
375 601f0ede 2002-11-02 alex conn = Client_Conn( c );
376 4c870f4b 2002-11-04 alex if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
377 4c870f4b 2002-11-04 alex else Conn_SetFlag( conn, SEND_TO_USER );
378 c23199d9 2002-02-27 alex }
379 c23199d9 2002-02-27 alex cl2chan = Channel_NextMember( chan, cl2chan );
380 c23199d9 2002-02-27 alex }
381 c23199d9 2002-02-27 alex
382 c23199d9 2002-02-27 alex /* naechsten Channel */
383 c23199d9 2002-02-27 alex chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
384 c23199d9 2002-02-27 alex }
385 c23199d9 2002-02-27 alex
386 4c870f4b 2002-11-04 alex /* Senden: alle Verbindungen durchgehen ... */
387 601f0ede 2002-11-02 alex conn = Conn_First( );
388 601f0ede 2002-11-02 alex while( conn != NONE )
389 c23199d9 2002-02-27 alex {
390 4c870f4b 2002-11-04 alex /* muessen ueber diese Verbindung Daten gesendet werden? */
391 4c870f4b 2002-11-04 alex if( Conn_Flag( conn ) == SEND_TO_SERVER ) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
392 a6265aa0 2002-11-04 alex else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
393 4c870f4b 2002-11-04 alex if( ! ok ) break;
394 4c870f4b 2002-11-04 alex
395 4c870f4b 2002-11-04 alex /* naechste Verbindung testen */
396 601f0ede 2002-11-02 alex conn = Conn_Next( conn );
397 c23199d9 2002-02-27 alex }
398 c23199d9 2002-02-27 alex return ok;
399 c23199d9 2002-02-27 alex } /* IRC_WriteStrRelatedPrefix */
400 c23199d9 2002-02-27 alex
401 c23199d9 2002-02-27 alex
402 8adff592 2005-03-19 fw GLOBAL void
403 8adff592 2005-03-19 fw IRC_SetPenalty( CLIENT *Client, int Seconds )
404 7b6e2662 2003-11-05 alex {
405 7b6e2662 2003-11-05 alex CONN_ID c;
406 7b6e2662 2003-11-05 alex
407 7b6e2662 2003-11-05 alex assert( Client != NULL );
408 7b6e2662 2003-11-05 alex assert( Seconds > 0 );
409 7b6e2662 2003-11-05 alex
410 7b6e2662 2003-11-05 alex if( Client_Type( Client ) == CLIENT_SERVER ) return;
411 7b6e2662 2003-11-05 alex
412 7b6e2662 2003-11-05 alex c = Client_Conn( Client );
413 7b6e2662 2003-11-05 alex if( c > NONE ) Conn_SetPenalty( c, Seconds );
414 7b6e2662 2003-11-05 alex } /* IRC_SetPenalty */
415 7b6e2662 2003-11-05 alex
416 7b6e2662 2003-11-05 alex
417 8adff592 2005-03-19 fw LOCAL char *
418 c2f60abe 2002-05-27 alex Get_Prefix( CLIENT *Target, CLIENT *Client )
419 c23199d9 2002-02-27 alex {
420 c23199d9 2002-02-27 alex assert( Target != NULL );
421 c23199d9 2002-02-27 alex assert( Client != NULL );
422 c23199d9 2002-02-27 alex
423 c23199d9 2002-02-27 alex if( Client_Type( Target ) == CLIENT_SERVER ) return Client_ID( Client );
424 c23199d9 2002-02-27 alex else return Client_Mask( Client );
425 c23199d9 2002-02-27 alex } /* Get_Prefix */
426 c23199d9 2002-02-27 alex
427 c23199d9 2002-02-27 alex
428 c23199d9 2002-02-27 alex /* -eof- */