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