Blame


1 c23199d9 2002-02-27 alex /*
2 c23199d9 2002-02-27 alex * ngIRCd -- The Next Generation IRC Daemon
3 c23199d9 2002-02-27 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 c23199d9 2002-02-27 alex *
5 c23199d9 2002-02-27 alex * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6 c23199d9 2002-02-27 alex * der GNU General Public License (GPL), wie von der Free Software Foundation
7 c23199d9 2002-02-27 alex * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8 c23199d9 2002-02-27 alex * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9 c23199d9 2002-02-27 alex * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10 c23199d9 2002-02-27 alex * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
11 c23199d9 2002-02-27 alex *
12 982a08b8 2002-09-17 alex * $Id: irc-write.c,v 1.8 2002/09/17 17:11:56 alex Exp $
13 c23199d9 2002-02-27 alex *
14 c23199d9 2002-02-27 alex * irc-write.c: IRC-Texte und Befehle ueber Netzwerk versenden
15 c23199d9 2002-02-27 alex */
16 c23199d9 2002-02-27 alex
17 c23199d9 2002-02-27 alex
18 ca33cbda 2002-03-12 alex #include "portab.h"
19 c23199d9 2002-02-27 alex
20 ca33cbda 2002-03-12 alex #include "imp.h"
21 c23199d9 2002-02-27 alex #include <assert.h>
22 c23199d9 2002-02-27 alex #include <stdarg.h>
23 c23199d9 2002-02-27 alex #include <stdio.h>
24 3010f034 2002-09-03 alex #include <string.h>
25 c23199d9 2002-02-27 alex
26 c2f60abe 2002-05-27 alex #include "conn.h"
27 c2f60abe 2002-05-27 alex #include "client.h"
28 c2f60abe 2002-05-27 alex #include "channel.h"
29 ca33cbda 2002-03-12 alex #include "defines.h"
30 ca33cbda 2002-03-12 alex
31 ca33cbda 2002-03-12 alex #include "exp.h"
32 c23199d9 2002-02-27 alex #include "irc-write.h"
33 c23199d9 2002-02-27 alex
34 c23199d9 2002-02-27 alex
35 c2f60abe 2002-05-27 alex LOCAL CHAR *Get_Prefix PARAMS(( CLIENT *Target, CLIENT *Client ));
36 c23199d9 2002-02-27 alex
37 c23199d9 2002-02-27 alex
38 f7327524 2002-05-30 alex #ifdef PROTOTYPES
39 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
40 c2f60abe 2002-05-27 alex IRC_WriteStrClient( CLIENT *Client, CHAR *Format, ... )
41 f7327524 2002-05-30 alex #else
42 f7327524 2002-05-30 alex GLOBAL BOOLEAN
43 f7327524 2002-05-30 alex IRC_WriteStrClient( Client, Format, va_alist )
44 f7327524 2002-05-30 alex CLIENT *Client;
45 f7327524 2002-05-30 alex CHAR *Format;
46 f7327524 2002-05-30 alex va_dcl
47 f7327524 2002-05-30 alex #endif
48 c23199d9 2002-02-27 alex {
49 c23199d9 2002-02-27 alex CHAR buffer[1000];
50 c23199d9 2002-02-27 alex BOOLEAN ok = CONNECTED;
51 c23199d9 2002-02-27 alex va_list ap;
52 c23199d9 2002-02-27 alex
53 c23199d9 2002-02-27 alex assert( Client != NULL );
54 c23199d9 2002-02-27 alex assert( Format != NULL );
55 c23199d9 2002-02-27 alex
56 f7327524 2002-05-30 alex #ifdef PROTOTYPES
57 c23199d9 2002-02-27 alex va_start( ap, Format );
58 f7327524 2002-05-30 alex #else
59 f7327524 2002-05-30 alex va_start( ap );
60 f7327524 2002-05-30 alex #endif
61 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
62 c23199d9 2002-02-27 alex va_end( ap );
63 c23199d9 2002-02-27 alex
64 c23199d9 2002-02-27 alex /* an den Client selber */
65 c23199d9 2002-02-27 alex ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), buffer );
66 c23199d9 2002-02-27 alex
67 c23199d9 2002-02-27 alex return ok;
68 c23199d9 2002-02-27 alex } /* IRC_WriteStrClient */
69 c23199d9 2002-02-27 alex
70 c23199d9 2002-02-27 alex
71 f7327524 2002-05-30 alex #ifdef PROTOTYPES
72 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
73 c2f60abe 2002-05-27 alex IRC_WriteStrClientPrefix( CLIENT *Client, CLIENT *Prefix, CHAR *Format, ... )
74 f7327524 2002-05-30 alex #else
75 f7327524 2002-05-30 alex GLOBAL BOOLEAN
76 f7327524 2002-05-30 alex IRC_WriteStrClientPrefix( Client, Prefix, Format, va_alist )
77 f7327524 2002-05-30 alex CLIENT *Client;
78 f7327524 2002-05-30 alex CLIENT *Prefix;
79 f7327524 2002-05-30 alex CHAR *Format;
80 f7327524 2002-05-30 alex va_dcl
81 f7327524 2002-05-30 alex #endif
82 c23199d9 2002-02-27 alex {
83 c23199d9 2002-02-27 alex /* Text an Clients, lokal bzw. remote, senden. */
84 c23199d9 2002-02-27 alex
85 c23199d9 2002-02-27 alex CHAR buffer[1000];
86 c23199d9 2002-02-27 alex va_list ap;
87 c23199d9 2002-02-27 alex
88 c23199d9 2002-02-27 alex assert( Client != NULL );
89 c23199d9 2002-02-27 alex assert( Format != NULL );
90 c23199d9 2002-02-27 alex assert( Prefix != NULL );
91 c23199d9 2002-02-27 alex
92 f7327524 2002-05-30 alex #ifdef PROTOTYPES
93 c23199d9 2002-02-27 alex va_start( ap, Format );
94 f7327524 2002-05-30 alex #else
95 f7327524 2002-05-30 alex va_start( ap );
96 f7327524 2002-05-30 alex #endif
97 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
98 c23199d9 2002-02-27 alex va_end( ap );
99 c23199d9 2002-02-27 alex
100 c23199d9 2002-02-27 alex return Conn_WriteStr( Client_Conn( Client_NextHop( Client )), ":%s %s", Get_Prefix( Client_NextHop( Client ), Prefix ), buffer );
101 c23199d9 2002-02-27 alex } /* IRC_WriteStrClientPrefix */
102 c23199d9 2002-02-27 alex
103 c23199d9 2002-02-27 alex
104 f7327524 2002-05-30 alex #ifdef PROTOTYPES
105 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
106 c2f60abe 2002-05-27 alex IRC_WriteStrChannel( CLIENT *Client, CHANNEL *Chan, BOOLEAN Remote, CHAR *Format, ... )
107 f7327524 2002-05-30 alex #else
108 f7327524 2002-05-30 alex GLOBAL BOOLEAN
109 f7327524 2002-05-30 alex IRC_WriteStrChannel( Client, Chan, Remote, Format, va_alist )
110 f7327524 2002-05-30 alex CLIENT *Client;
111 f7327524 2002-05-30 alex CHANNEL *Chan;
112 f7327524 2002-05-30 alex BOOLEAN Remote;
113 f7327524 2002-05-30 alex CHAR *Format;
114 f7327524 2002-05-30 alex va_dcl
115 f7327524 2002-05-30 alex #endif
116 c23199d9 2002-02-27 alex {
117 c23199d9 2002-02-27 alex CHAR buffer[1000];
118 c23199d9 2002-02-27 alex va_list ap;
119 c23199d9 2002-02-27 alex
120 c23199d9 2002-02-27 alex assert( Client != NULL );
121 c23199d9 2002-02-27 alex assert( Format != NULL );
122 c23199d9 2002-02-27 alex
123 f7327524 2002-05-30 alex #ifdef PROTOTYPES
124 c23199d9 2002-02-27 alex va_start( ap, Format );
125 f7327524 2002-05-30 alex #else
126 f7327524 2002-05-30 alex va_start( ap );
127 f7327524 2002-05-30 alex #endif
128 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
129 c23199d9 2002-02-27 alex va_end( ap );
130 c23199d9 2002-02-27 alex
131 c23199d9 2002-02-27 alex return IRC_WriteStrChannelPrefix( Client, Chan, Client_ThisServer( ), Remote, buffer );
132 c23199d9 2002-02-27 alex } /* IRC_WriteStrChannel */
133 c23199d9 2002-02-27 alex
134 c23199d9 2002-02-27 alex
135 f7327524 2002-05-30 alex #ifdef PROTOTYPES
136 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
137 c2f60abe 2002-05-27 alex IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, BOOLEAN Remote, CHAR *Format, ... )
138 f7327524 2002-05-30 alex #else
139 f7327524 2002-05-30 alex GLOBAL BOOLEAN
140 f7327524 2002-05-30 alex IRC_WriteStrChannelPrefix( Client, Chan, Prefix, Remote, Format, va_alist )
141 f7327524 2002-05-30 alex CLIENT *Client;
142 f7327524 2002-05-30 alex CHANNEL *Chan;
143 f7327524 2002-05-30 alex CLIENT *Prefix;
144 f7327524 2002-05-30 alex BOOLEAN Remote;
145 f7327524 2002-05-30 alex CHAR *Format;
146 f7327524 2002-05-30 alex va_dcl
147 f7327524 2002-05-30 alex #endif
148 c23199d9 2002-02-27 alex {
149 c23199d9 2002-02-27 alex BOOLEAN sock[MAX_CONNECTIONS], is_server[MAX_CONNECTIONS], ok = CONNECTED;
150 c23199d9 2002-02-27 alex CHAR buffer[1000];
151 c23199d9 2002-02-27 alex CL2CHAN *cl2chan;
152 c23199d9 2002-02-27 alex CLIENT *c;
153 c23199d9 2002-02-27 alex INT s, i;
154 c23199d9 2002-02-27 alex va_list ap;
155 c23199d9 2002-02-27 alex
156 c23199d9 2002-02-27 alex assert( Client != NULL );
157 c23199d9 2002-02-27 alex assert( Chan != NULL );
158 c23199d9 2002-02-27 alex assert( Prefix != NULL );
159 c23199d9 2002-02-27 alex assert( Format != NULL );
160 c23199d9 2002-02-27 alex
161 f7327524 2002-05-30 alex #ifdef PROTOTYPES
162 c23199d9 2002-02-27 alex va_start( ap, Format );
163 f7327524 2002-05-30 alex #else
164 f7327524 2002-05-30 alex va_start( ap );
165 f7327524 2002-05-30 alex #endif
166 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
167 c23199d9 2002-02-27 alex va_end( ap );
168 c23199d9 2002-02-27 alex
169 c23199d9 2002-02-27 alex for( i = 0; i < MAX_CONNECTIONS; i++ ) sock[i] = FALSE;
170 c23199d9 2002-02-27 alex
171 c23199d9 2002-02-27 alex /* An alle Clients, die in den selben Channels sind.
172 c23199d9 2002-02-27 alex * Dabei aber nur einmal je Remote-Server */
173 c23199d9 2002-02-27 alex cl2chan = Channel_FirstMember( Chan );
174 c23199d9 2002-02-27 alex while( cl2chan )
175 c23199d9 2002-02-27 alex {
176 c23199d9 2002-02-27 alex c = Channel_GetClient( cl2chan );
177 c23199d9 2002-02-27 alex if( ! Remote )
178 c23199d9 2002-02-27 alex {
179 c23199d9 2002-02-27 alex if( Client_Conn( c ) <= NONE ) c = NULL;
180 c23199d9 2002-02-27 alex else if( Client_Type( c ) == CLIENT_SERVER ) c = NULL;
181 c23199d9 2002-02-27 alex }
182 c23199d9 2002-02-27 alex if( c ) c = Client_NextHop( c );
183 c23199d9 2002-02-27 alex
184 c23199d9 2002-02-27 alex if( c && ( c != Client ))
185 c23199d9 2002-02-27 alex {
186 c23199d9 2002-02-27 alex /* Ok, anderer Client */
187 c23199d9 2002-02-27 alex s = Client_Conn( c );
188 c23199d9 2002-02-27 alex assert( s >= 0 );
189 c23199d9 2002-02-27 alex assert( s < MAX_CONNECTIONS );
190 c23199d9 2002-02-27 alex sock[s] = TRUE;
191 c23199d9 2002-02-27 alex if( Client_Type( c ) == CLIENT_SERVER ) is_server[s] = TRUE;
192 c23199d9 2002-02-27 alex else is_server[s] = FALSE;
193 c23199d9 2002-02-27 alex }
194 c23199d9 2002-02-27 alex cl2chan = Channel_NextMember( Chan, cl2chan );
195 c23199d9 2002-02-27 alex }
196 c23199d9 2002-02-27 alex
197 c23199d9 2002-02-27 alex /* Senden ... */
198 c23199d9 2002-02-27 alex for( i = 0; i < MAX_CONNECTIONS; i++ )
199 c23199d9 2002-02-27 alex {
200 c23199d9 2002-02-27 alex if( sock[i] )
201 c23199d9 2002-02-27 alex {
202 c23199d9 2002-02-27 alex if( is_server[i] ) ok = Conn_WriteStr( i, ":%s %s", Client_ID( Prefix ), buffer );
203 c23199d9 2002-02-27 alex else ok = Conn_WriteStr( i, ":%s %s", Client_Mask( Prefix ), buffer );
204 c23199d9 2002-02-27 alex if( ! ok ) break;
205 c23199d9 2002-02-27 alex }
206 c23199d9 2002-02-27 alex }
207 c23199d9 2002-02-27 alex return ok;
208 c23199d9 2002-02-27 alex } /* IRC_WriteStrChannelPrefix */
209 c23199d9 2002-02-27 alex
210 c23199d9 2002-02-27 alex
211 f7327524 2002-05-30 alex #ifdef PROTOTYPES
212 c2f60abe 2002-05-27 alex GLOBAL VOID
213 c2f60abe 2002-05-27 alex IRC_WriteStrServers( CLIENT *ExceptOf, CHAR *Format, ... )
214 f7327524 2002-05-30 alex #else
215 f7327524 2002-05-30 alex GLOBAL VOID
216 f7327524 2002-05-30 alex IRC_WriteStrServers( ExceptOf, Format, va_alist )
217 f7327524 2002-05-30 alex CLIENT *ExceptOf;
218 f7327524 2002-05-30 alex CHAR *Format;
219 f7327524 2002-05-30 alex va_dcl
220 f7327524 2002-05-30 alex #endif
221 c23199d9 2002-02-27 alex {
222 c23199d9 2002-02-27 alex CHAR buffer[1000];
223 c23199d9 2002-02-27 alex va_list ap;
224 c23199d9 2002-02-27 alex
225 c23199d9 2002-02-27 alex assert( Format != NULL );
226 c23199d9 2002-02-27 alex
227 f7327524 2002-05-30 alex #ifdef PROTOTYPES
228 c23199d9 2002-02-27 alex va_start( ap, Format );
229 f7327524 2002-05-30 alex #else
230 f7327524 2002-05-30 alex va_start( ap );
231 f7327524 2002-05-30 alex #endif
232 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
233 c23199d9 2002-02-27 alex va_end( ap );
234 c23199d9 2002-02-27 alex
235 c23199d9 2002-02-27 alex /* an den Client selber */
236 f7327524 2002-05-30 alex IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), buffer );
237 c23199d9 2002-02-27 alex } /* IRC_WriteStrServers */
238 c23199d9 2002-02-27 alex
239 c23199d9 2002-02-27 alex
240 f7327524 2002-05-30 alex #ifdef PROTOTYPES
241 c2f60abe 2002-05-27 alex GLOBAL VOID
242 c2f60abe 2002-05-27 alex IRC_WriteStrServersPrefix( CLIENT *ExceptOf, CLIENT *Prefix, CHAR *Format, ... )
243 f7327524 2002-05-30 alex #else
244 f7327524 2002-05-30 alex GLOBAL VOID
245 f7327524 2002-05-30 alex IRC_WriteStrServersPrefix( ExceptOf, Prefix, Format, va_alist )
246 3010f034 2002-09-03 alex CLIENT *ExceptOf;
247 3010f034 2002-09-03 alex CLIENT *Prefix;
248 3010f034 2002-09-03 alex CHAR *Format;
249 3010f034 2002-09-03 alex va_dcl
250 3010f034 2002-09-03 alex #endif
251 3010f034 2002-09-03 alex {
252 3010f034 2002-09-03 alex CHAR buffer[1000];
253 3010f034 2002-09-03 alex va_list ap;
254 3010f034 2002-09-03 alex
255 3010f034 2002-09-03 alex assert( Format != NULL );
256 3010f034 2002-09-03 alex assert( Prefix != NULL );
257 3010f034 2002-09-03 alex
258 3010f034 2002-09-03 alex #ifdef PROTOTYPES
259 3010f034 2002-09-03 alex va_start( ap, Format );
260 3010f034 2002-09-03 alex #else
261 3010f034 2002-09-03 alex va_start( ap );
262 3010f034 2002-09-03 alex #endif
263 3010f034 2002-09-03 alex vsnprintf( buffer, 1000, Format, ap );
264 3010f034 2002-09-03 alex va_end( ap );
265 3010f034 2002-09-03 alex
266 982a08b8 2002-09-17 alex IRC_WriteStrServersPrefixFlag( ExceptOf, Prefix, '\0', buffer );
267 3010f034 2002-09-03 alex } /* IRC_WriteStrServersPrefix */
268 3010f034 2002-09-03 alex
269 3010f034 2002-09-03 alex
270 3010f034 2002-09-03 alex #ifdef PROTOTYPES
271 3010f034 2002-09-03 alex GLOBAL VOID
272 3010f034 2002-09-03 alex IRC_WriteStrServersPrefixFlag( CLIENT *ExceptOf, CLIENT *Prefix, CHAR Flag, CHAR *Format, ... )
273 3010f034 2002-09-03 alex #else
274 3010f034 2002-09-03 alex GLOBAL VOID
275 3010f034 2002-09-03 alex IRC_WriteStrServersPrefixFlag( ExceptOf, Prefix, Flag, Format, va_alist )
276 f7327524 2002-05-30 alex CLIENT *ExceptOf;
277 f7327524 2002-05-30 alex CLIENT *Prefix;
278 3010f034 2002-09-03 alex CHAR Flag;
279 f7327524 2002-05-30 alex CHAR *Format;
280 f7327524 2002-05-30 alex va_dcl
281 f7327524 2002-05-30 alex #endif
282 c23199d9 2002-02-27 alex {
283 c23199d9 2002-02-27 alex CHAR buffer[1000];
284 c23199d9 2002-02-27 alex CLIENT *c;
285 c23199d9 2002-02-27 alex va_list ap;
286 c23199d9 2002-02-27 alex
287 c23199d9 2002-02-27 alex assert( Format != NULL );
288 c23199d9 2002-02-27 alex assert( Prefix != NULL );
289 c23199d9 2002-02-27 alex
290 f7327524 2002-05-30 alex #ifdef PROTOTYPES
291 c23199d9 2002-02-27 alex va_start( ap, Format );
292 f7327524 2002-05-30 alex #else
293 f7327524 2002-05-30 alex va_start( ap );
294 f7327524 2002-05-30 alex #endif
295 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
296 c23199d9 2002-02-27 alex va_end( ap );
297 c23199d9 2002-02-27 alex
298 c23199d9 2002-02-27 alex c = Client_First( );
299 c23199d9 2002-02-27 alex while( c )
300 c23199d9 2002-02-27 alex {
301 c23199d9 2002-02-27 alex if(( Client_Type( c ) == CLIENT_SERVER ) && ( Client_Conn( c ) > NONE ) && ( c != Client_ThisServer( )) && ( c != ExceptOf ))
302 c23199d9 2002-02-27 alex {
303 3010f034 2002-09-03 alex /* Ziel-Server gefunden. Nun noch pruefen, ob Flags stimmen */
304 3010f034 2002-09-03 alex if(( Flag == '\0' ) || ( strchr( Client_Flags( c ), Flag ) != NULL )) IRC_WriteStrClientPrefix( c, Prefix, buffer );
305 c23199d9 2002-02-27 alex }
306 c23199d9 2002-02-27 alex c = Client_Next( c );
307 c23199d9 2002-02-27 alex }
308 3010f034 2002-09-03 alex } /* IRC_WriteStrServersPrefixFlag */
309 c23199d9 2002-02-27 alex
310 c23199d9 2002-02-27 alex
311 f7327524 2002-05-30 alex #ifdef PROTOTYPES
312 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
313 c2f60abe 2002-05-27 alex IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, BOOLEAN Remote, CHAR *Format, ... )
314 f7327524 2002-05-30 alex #else
315 f7327524 2002-05-30 alex GLOBAL BOOLEAN
316 f7327524 2002-05-30 alex IRC_WriteStrRelatedPrefix( Client, Prefix, Remote, Format, va_alist )
317 f7327524 2002-05-30 alex CLIENT *Client;
318 f7327524 2002-05-30 alex CLIENT *Prefix;
319 f7327524 2002-05-30 alex BOOLEAN Remote;
320 f7327524 2002-05-30 alex CHAR *Format;
321 f7327524 2002-05-30 alex va_dcl
322 f7327524 2002-05-30 alex #endif
323 c23199d9 2002-02-27 alex {
324 c23199d9 2002-02-27 alex BOOLEAN sock[MAX_CONNECTIONS], is_server[MAX_CONNECTIONS], ok = CONNECTED;
325 c23199d9 2002-02-27 alex CL2CHAN *chan_cl2chan, *cl2chan;
326 c23199d9 2002-02-27 alex CHAR buffer[1000];
327 c23199d9 2002-02-27 alex CHANNEL *chan;
328 c23199d9 2002-02-27 alex va_list ap;
329 c23199d9 2002-02-27 alex CLIENT *c;
330 c23199d9 2002-02-27 alex INT i, s;
331 c23199d9 2002-02-27 alex
332 c23199d9 2002-02-27 alex assert( Client != NULL );
333 c23199d9 2002-02-27 alex assert( Prefix != NULL );
334 c23199d9 2002-02-27 alex assert( Format != NULL );
335 c23199d9 2002-02-27 alex
336 f7327524 2002-05-30 alex #ifdef PROTOTYPES
337 c23199d9 2002-02-27 alex va_start( ap, Format );
338 f7327524 2002-05-30 alex #else
339 f7327524 2002-05-30 alex va_start( ap );
340 f7327524 2002-05-30 alex #endif
341 c23199d9 2002-02-27 alex vsnprintf( buffer, 1000, Format, ap );
342 c23199d9 2002-02-27 alex va_end( ap );
343 c23199d9 2002-02-27 alex
344 c23199d9 2002-02-27 alex /* initialisieren */
345 c23199d9 2002-02-27 alex for( i = 0; i < MAX_CONNECTIONS; i++ ) sock[i] = FALSE;
346 c23199d9 2002-02-27 alex
347 c23199d9 2002-02-27 alex /* An alle Clients, die in einem Channel mit dem "Ausloeser" sind,
348 c23199d9 2002-02-27 alex * den Text schicken. An Remote-Server aber jeweils nur einmal. */
349 c23199d9 2002-02-27 alex chan_cl2chan = Channel_FirstChannelOf( Client );
350 c23199d9 2002-02-27 alex while( chan_cl2chan )
351 c23199d9 2002-02-27 alex {
352 c23199d9 2002-02-27 alex /* Channel des Users durchsuchen */
353 c23199d9 2002-02-27 alex chan = Channel_GetChannel( chan_cl2chan );
354 c23199d9 2002-02-27 alex cl2chan = Channel_FirstMember( chan );
355 c23199d9 2002-02-27 alex while( cl2chan )
356 c23199d9 2002-02-27 alex {
357 c23199d9 2002-02-27 alex c = Channel_GetClient( cl2chan );
358 c23199d9 2002-02-27 alex if( ! Remote )
359 c23199d9 2002-02-27 alex {
360 c23199d9 2002-02-27 alex if( Client_Conn( c ) <= NONE ) c = NULL;
361 c23199d9 2002-02-27 alex else if( Client_Type( c ) == CLIENT_SERVER ) c = NULL;
362 c23199d9 2002-02-27 alex }
363 c23199d9 2002-02-27 alex if( c ) c = Client_NextHop( c );
364 c23199d9 2002-02-27 alex
365 c23199d9 2002-02-27 alex if( c && ( c != Client ))
366 c23199d9 2002-02-27 alex {
367 c23199d9 2002-02-27 alex /* Ok, anderer Client */
368 c23199d9 2002-02-27 alex s = Client_Conn( c );
369 c23199d9 2002-02-27 alex assert( s >= 0 );
370 c23199d9 2002-02-27 alex assert( s < MAX_CONNECTIONS );
371 c23199d9 2002-02-27 alex sock[s] = TRUE;
372 c23199d9 2002-02-27 alex if( Client_Type( c ) == CLIENT_SERVER ) is_server[s] = TRUE;
373 c23199d9 2002-02-27 alex else is_server[s] = FALSE;
374 c23199d9 2002-02-27 alex }
375 c23199d9 2002-02-27 alex cl2chan = Channel_NextMember( chan, cl2chan );
376 c23199d9 2002-02-27 alex }
377 c23199d9 2002-02-27 alex
378 c23199d9 2002-02-27 alex /* naechsten Channel */
379 c23199d9 2002-02-27 alex chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
380 c23199d9 2002-02-27 alex }
381 c23199d9 2002-02-27 alex
382 c23199d9 2002-02-27 alex /* Senden ... */
383 c23199d9 2002-02-27 alex for( i = 0; i < MAX_CONNECTIONS; i++ )
384 c23199d9 2002-02-27 alex {
385 c23199d9 2002-02-27 alex if( sock[i] )
386 c23199d9 2002-02-27 alex {
387 c23199d9 2002-02-27 alex if( is_server[i] ) ok = Conn_WriteStr( i, ":%s %s", Client_ID( Prefix ), buffer );
388 c23199d9 2002-02-27 alex else ok = Conn_WriteStr( i, ":%s %s", Client_Mask( Prefix ), buffer );
389 c23199d9 2002-02-27 alex if( ! ok ) break;
390 c23199d9 2002-02-27 alex }
391 c23199d9 2002-02-27 alex }
392 c23199d9 2002-02-27 alex return ok;
393 c23199d9 2002-02-27 alex } /* IRC_WriteStrRelatedPrefix */
394 c23199d9 2002-02-27 alex
395 c23199d9 2002-02-27 alex
396 c2f60abe 2002-05-27 alex LOCAL CHAR *
397 c2f60abe 2002-05-27 alex Get_Prefix( CLIENT *Target, CLIENT *Client )
398 c23199d9 2002-02-27 alex {
399 c23199d9 2002-02-27 alex assert( Target != NULL );
400 c23199d9 2002-02-27 alex assert( Client != NULL );
401 c23199d9 2002-02-27 alex
402 c23199d9 2002-02-27 alex if( Client_Type( Target ) == CLIENT_SERVER ) return Client_ID( Client );
403 c23199d9 2002-02-27 alex else return Client_Mask( Client );
404 c23199d9 2002-02-27 alex } /* Get_Prefix */
405 c23199d9 2002-02-27 alex
406 c23199d9 2002-02-27 alex
407 c23199d9 2002-02-27 alex /* -eof- */