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