/[svn]/ircd-hybrid-7.2/src/s_user.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/src/s_user.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 891 - (show annotations)
Thu Nov 1 13:44:50 2007 UTC (12 years, 3 months ago) by michael
File MIME type: text/x-chdr
File size: 41469 byte(s)
- Avoid useless irc_getnameinfo calls in several places

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * s_user.c: User related functions.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "tools.h"
27 #include "s_user.h"
28 #include "s_misc.h"
29 #include "channel.h"
30 #include "channel_mode.h"
31 #include "client.h"
32 #include "common.h"
33 #include "fdlist.h"
34 #include "hash.h"
35 #include "irc_string.h"
36 #include "sprintf_irc.h"
37 #include "s_bsd.h"
38 #include "ircd.h"
39 #include "list.h"
40 #include "listener.h"
41 #include "motd.h"
42 #include "numeric.h"
43 #include "s_conf.h"
44 #include "s_log.h"
45 #include "s_serv.h"
46 #include "s_stats.h"
47 #include "send.h"
48 #include "supported.h"
49 #include "whowas.h"
50 #include "memory.h"
51 #include "packet.h"
52 #include "userhost.h"
53 #include "hook.h"
54 #include "s_misc.h"
55 #include "msg.h"
56 #include "pcre.h"
57 #include "watch.h"
58
59 int MaxClientCount = 1;
60 int MaxConnectionCount = 1;
61 struct Callback *entering_umode_cb = NULL;
62 struct Callback *umode_cb = NULL;
63 struct Callback *uid_get_cb = NULL;
64
65 static char umode_buffer[IRCD_BUFSIZE];
66
67 static void user_welcome(struct Client *);
68 static void report_and_set_user_flags(struct Client *, const struct AccessItem *);
69 static int check_xline(struct Client *);
70 static void introduce_client(struct Client *, struct Client *);
71 static void *uid_get(va_list);
72
73 /* Used for building up the isupport string,
74 * used with init_isupport, add_isupport, delete_isupport
75 */
76
77 struct Isupport
78 {
79 dlink_node node;
80 char *name;
81 char *options;
82 int number;
83 };
84
85 static dlink_list support_list = { NULL, NULL, 0 };
86 MessageFile *isupportFile;
87
88 /* memory is cheap. map 0-255 to equivalent mode */
89 unsigned int user_modes[256] =
90 {
91 /* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */
92 /* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */
93 /* 0x20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x2F */
94 /* 0x30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x3F */
95 0, /* @ */
96 0, /* A */
97 0, /* B */
98 UMODE_CCONN_FULL, /* C */
99 UMODE_DEAF, /* D */
100 0, /* E */
101 0, /* F */
102 UMODE_SOFTCALLERID, /* G */
103 0, /* H */
104 0, /* I */
105 0, /* J */
106 0, /* K */
107 0, /* L */
108 0, /* M */
109 0, /* N */
110 0, /* O */
111 0, /* P */
112 0, /* Q */
113 0, /* R */
114 0, /* S */
115 0, /* T */
116 0, /* U */
117 0, /* V */
118 0, /* W */
119 0, /* X */
120 0, /* Y */
121 0, /* Z 0x5A */
122 0, 0, 0, 0, 0, /* 0x5F */
123 0, /* 0x60 */
124 UMODE_ADMIN, /* a */
125 UMODE_BOTS, /* b */
126 UMODE_CCONN, /* c */
127 UMODE_DEBUG, /* d */
128 0, /* e */
129 UMODE_FULL, /* f */
130 UMODE_CALLERID, /* g */
131 0, /* h */
132 UMODE_INVISIBLE, /* i */
133 0, /* j */
134 UMODE_SKILL, /* k */
135 UMODE_LOCOPS, /* l */
136 0, /* m */
137 UMODE_NCHANGE, /* n */
138 UMODE_OPER, /* o */
139 0, /* p */
140 0, /* q */
141 UMODE_REJ, /* r */
142 UMODE_SERVNOTICE, /* s */
143 0, /* t */
144 UMODE_UNAUTH, /* u */
145 0, /* v */
146 UMODE_WALLOP, /* w */
147 UMODE_EXTERNAL, /* x */
148 UMODE_SPY, /* y */
149 UMODE_OPERWALL, /* z 0x7A */
150 0,0,0,0,0, /* 0x7B - 0x7F */
151
152 /* 0x80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x8F */
153 /* 0x90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x9F */
154 /* 0xA0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xAF */
155 /* 0xB0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xBF */
156 /* 0xC0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xCF */
157 /* 0xD0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xDF */
158 /* 0xE0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xEF */
159 /* 0xF0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xFF */
160 };
161
162 void
163 assemble_umode_buffer(void)
164 {
165 unsigned int idx = 0;
166 char *umode_buffer_ptr = umode_buffer;
167
168 for (; idx < (sizeof(user_modes) / sizeof(int)); ++idx)
169 if (user_modes[idx])
170 *umode_buffer_ptr++ = idx;
171
172 *umode_buffer_ptr = '\0';
173 }
174
175 /* show_lusers()
176 *
177 * inputs - pointer to client
178 * output - NONE
179 * side effects - display to client user counts etc.
180 */
181 void
182 show_lusers(struct Client *source_p)
183 {
184 const char *from, *to;
185
186 if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
187 {
188 from = me.id;
189 to = source_p->id;
190 }
191 else
192 {
193 from = me.name;
194 to = source_p->name;
195 }
196
197 if (!ConfigServerHide.hide_servers || IsOper(source_p))
198 sendto_one(source_p, form_str(RPL_LUSERCLIENT),
199 from, to, (Count.total-Count.invisi),
200 Count.invisi, dlink_list_length(&global_serv_list));
201 else
202 sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to,
203 (Count.total-Count.invisi), Count.invisi, 1);
204
205 if (Count.oper > 0)
206 sendto_one(source_p, form_str(RPL_LUSEROP),
207 from, to, Count.oper);
208
209 if (dlink_list_length(&unknown_list) > 0)
210 sendto_one(source_p, form_str(RPL_LUSERUNKNOWN),
211 from, to, dlink_list_length(&unknown_list));
212
213 if (dlink_list_length(&global_channel_list) > 0)
214 sendto_one(source_p, form_str(RPL_LUSERCHANNELS),
215 from, to, dlink_list_length(&global_channel_list));
216
217 if (!ConfigServerHide.hide_servers || IsOper(source_p))
218 {
219 sendto_one(source_p, form_str(RPL_LUSERME),
220 from, to, Count.local, Count.myserver);
221 sendto_one(source_p, form_str(RPL_LOCALUSERS),
222 from, to, Count.local, Count.max_loc,
223 Count.local, Count.max_loc);
224 }
225 else
226 {
227 sendto_one(source_p, form_str(RPL_LUSERME),
228 from, to, Count.total, 0);
229 sendto_one(source_p, form_str(RPL_LOCALUSERS),
230 from, to, Count.total, Count.max_tot,
231 Count.total, Count.max_tot);
232 }
233
234 sendto_one(source_p, form_str(RPL_GLOBALUSERS),
235 from, to, Count.total, Count.max_tot,
236 Count.total, Count.max_tot);
237
238 if (!ConfigServerHide.hide_servers || IsOper(source_p))
239 sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
240 MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
241
242 if (Count.local > MaxClientCount)
243 MaxClientCount = Count.local;
244
245 if ((Count.local + Count.myserver) > MaxConnectionCount)
246 MaxConnectionCount = Count.local + Count.myserver;
247 }
248
249 /* show_isupport()
250 *
251 * inputs - pointer to client
252 * output - NONE
253 * side effects - display to client what we support (for them)
254 */
255 void
256 show_isupport(struct Client *source_p)
257 {
258 send_message_file(source_p, isupportFile);
259 }
260
261 /*
262 ** register_local_user
263 ** This function is called when both NICK and USER messages
264 ** have been accepted for the client, in whatever order. Only
265 ** after this, is the USER message propagated.
266 **
267 ** NICK's must be propagated at once when received, although
268 ** it would be better to delay them too until full info is
269 ** available. Doing it is not so simple though, would have
270 ** to implement the following:
271 **
272 ** (actually it has been implemented already for a while) -orabidoo
273 **
274 ** 1) user telnets in and gives only "NICK foobar" and waits
275 ** 2) another user far away logs in normally with the nick
276 ** "foobar" (quite legal, as this server didn't propagate
277 ** it).
278 ** 3) now this server gets nick "foobar" from outside, but
279 ** has alread the same defined locally. Current server
280 ** would just issue "KILL foobar" to clean out dups. But,
281 ** this is not fair. It should actually request another
282 ** nick from local user or kill him/her...
283 */
284 void
285 register_local_user(struct Client *client_p, struct Client *source_p,
286 const char *nick, const char *username)
287 {
288 const struct AccessItem *aconf = NULL;
289 dlink_node *ptr = NULL;
290 dlink_node *m = NULL;
291
292 assert(source_p != NULL);
293 assert(MyConnect(source_p));
294 assert(source_p->username != username);
295 assert(!source_p->localClient->registration);
296
297 ClearCap(client_p, CAP_TS6);
298
299 if (ConfigFileEntry.ping_cookie)
300 {
301 if (!IsPingSent(source_p) &&
302 source_p->localClient->random_ping == 0)
303 {
304 source_p->localClient->random_ping = (unsigned long)rand();
305 sendto_one(source_p, "PING :%lu",
306 source_p->localClient->random_ping);
307 SetPingSent(source_p);
308 return;
309 }
310
311 if (!HasPingCookie(source_p))
312 return;
313 }
314
315 source_p->localClient->last = CurrentTime;
316 /* Straight up the maximum rate of flooding... */
317 source_p->localClient->allow_read = MAX_FLOOD_BURST;
318
319 if (!execute_callback(client_check_cb, source_p, username))
320 return;
321
322 if (valid_hostname(source_p->host) == 0)
323 {
324 sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal "
325 "character in your hostname", me.name, source_p->name);
326 strlcpy(source_p->host, source_p->sockhost,
327 sizeof(source_p->host));
328 }
329
330 ptr = source_p->localClient->confs.head;
331 aconf = map_to_conf(ptr->data);
332
333 if (!IsGotId(source_p))
334 {
335 const char *p = NULL;
336 unsigned int i = 0;
337
338 if (IsNeedIdentd(aconf))
339 {
340 ServerStats->is_ref++;
341 sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install "
342 "identd to use this server", me.name, source_p->name);
343 exit_client(source_p, &me, "Install identd");
344 return;
345 }
346
347 p = username;
348
349 if (!IsNoTilde(aconf))
350 source_p->username[i++] = '~';
351
352 while (*p && i < USERLEN)
353 {
354 if (*p != '[')
355 source_p->username[i++] = *p;
356 p++;
357 }
358
359 source_p->username[i] = '\0';
360 }
361
362 /* password check */
363 if (!EmptyString(aconf->passwd))
364 {
365 const char *pass = source_p->localClient->passwd;
366
367 if (!match_conf_password(pass, aconf))
368 {
369 ServerStats->is_ref++;
370 sendto_one(source_p, form_str(ERR_PASSWDMISMATCH),
371 me.name, source_p->name);
372 exit_client(source_p, &me, "Bad Password");
373 return;
374 }
375 }
376
377 /* don't free source_p->localClient->passwd here - it can be required
378 * by masked /stats I if there are auth{} blocks with need_password = no;
379 * --adx
380 */
381
382 /* report if user has &^>= etc. and set flags as needed in source_p */
383 report_and_set_user_flags(source_p, aconf);
384
385 /* Limit clients -
386 * We want to be able to have servers and F-line clients
387 * connect, so save room for "buffer" connections.
388 * Smaller servers may want to decrease this, and it should
389 * probably be just a percentage of the MAXCLIENTS...
390 * -Taner
391 */
392 /* Except "F:" clients */
393 if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) ||
394 (Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p)))
395 {
396 sendto_realops_flags(UMODE_FULL, L_ALL,
397 "Too many clients, rejecting %s[%s].",
398 nick, source_p->host);
399 ServerStats->is_ref++;
400 exit_client(source_p, &me, "Sorry, server is full - try later");
401 return;
402 }
403
404 /* valid user name check */
405 if (valid_username(source_p->username) == 0)
406 {
407 char tmpstr2[IRCD_BUFSIZE];
408
409 sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)",
410 nick, source_p->username, source_p->host);
411 ServerStats->is_ref++;
412 ircsprintf(tmpstr2, "Invalid username [%s]", source_p->username);
413 exit_client(source_p, &me, tmpstr2);
414 return;
415 }
416
417 assert(source_p == client_p);
418
419 if (check_xline(source_p))
420 return;
421
422 if (IsDead(client_p))
423 return;
424
425 if (me.id[0])
426 {
427 const char *id = execute_callback(uid_get_cb, source_p);
428
429 while (hash_find_id(id) != NULL)
430 id = uid_get(NULL);
431
432 strlcpy(source_p->id, id, sizeof(source_p->id));
433 hash_add_id(source_p);
434 }
435
436 sendto_realops_flags(UMODE_CCONN, L_ALL,
437 "Client connecting: %s (%s@%s) [%s] {%s} [%s]",
438 nick, source_p->username, source_p->host,
439 ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
440 "255.255.255.255" : source_p->sockhost,
441 get_client_class(source_p),
442 source_p->info);
443
444 sendto_realops_flags(UMODE_CCONN_FULL, L_ALL,
445 "CLICONN %s %s %s %s %s %s %s 0 %s",
446 nick, source_p->username, source_p->host,
447 ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
448 "255.255.255.255" : source_p->sockhost,
449 get_client_class(source_p),
450 ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
451 "<hidden>" : source_p->client_host,
452 ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ?
453 "<hidden>" : source_p->client_server,
454 source_p->info);
455
456
457 /* If they have died in send_* don't do anything. */
458 if (IsDead(source_p))
459 return;
460
461 if (ConfigFileEntry.invisible_on_connect)
462 {
463 source_p->umodes |= UMODE_INVISIBLE;
464 Count.invisi++;
465 }
466
467 if ((++Count.local) > Count.max_loc)
468 {
469 Count.max_loc = Count.local;
470
471 if (!(Count.max_loc % 10))
472 sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d",
473 Count.max_loc);
474 }
475
476 SetClient(source_p);
477
478 source_p->servptr = &me;
479 dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
480
481 /* Increment our total user count here */
482 if (++Count.total > Count.max_tot)
483 Count.max_tot = Count.total;
484 Count.totalrestartcount++;
485
486 source_p->localClient->allow_read = MAX_FLOOD_BURST;
487
488 if ((m = dlinkFindDelete(&unknown_list, source_p)) != NULL)
489 {
490 free_dlink_node(m);
491 dlinkAdd(source_p, &source_p->localClient->lclient_node, &local_client_list);
492 }
493 else assert(0);
494
495 user_welcome(source_p);
496 add_user_host(source_p->username, source_p->host, 0);
497 SetUserHost(source_p);
498
499 introduce_client(client_p, source_p);
500 }
501
502 /* register_remote_user()
503 *
504 * inputs - client_p directly connected client
505 * - source_p remote or directly connected client
506 * - username to register as
507 * - host name to register as
508 * - server name
509 * - realname (gecos)
510 * output - NONE
511 * side effects - This function is called when a remote client
512 * is introduced by a server.
513 */
514 void
515 register_remote_user(struct Client *client_p, struct Client *source_p,
516 const char *username, const char *host, const char *server,
517 const char *realname)
518 {
519 struct Client *target_p = NULL;
520
521 assert(source_p != NULL);
522 assert(source_p->username != username);
523
524 strlcpy(source_p->host, host, sizeof(source_p->host));
525 strlcpy(source_p->info, realname, sizeof(source_p->info));
526 strlcpy(source_p->username, username, sizeof(source_p->username));
527
528 /*
529 * coming from another server, take the servers word for it
530 */
531 source_p->servptr = find_server(server);
532
533 /* Super GhostDetect:
534 * If we can't find the server the user is supposed to be on,
535 * then simply blow the user away. -Taner
536 */
537 if (source_p->servptr == NULL)
538 {
539 sendto_realops_flags(UMODE_ALL, L_ALL,
540 "No server %s for user %s[%s@%s] from %s",
541 server, source_p->name, source_p->username,
542 source_p->host, source_p->from->name);
543 kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
544
545 SetKilled(source_p);
546 exit_client(source_p, &me, "Ghosted Client");
547 return;
548 }
549
550 if ((target_p = source_p->servptr) && target_p->from != source_p->from)
551 {
552 sendto_realops_flags(UMODE_DEBUG, L_ALL,
553 "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
554 client_p->name, source_p->name, source_p->username,
555 source_p->host, source_p->servptr->name,
556 target_p->name, target_p->from->name);
557 kill_client(client_p, source_p,
558 "%s (NICK from wrong direction (%s != %s))",
559 me.name, source_p->servptr->name, target_p->from->name);
560 SetKilled(source_p);
561 exit_client(source_p, &me, "USER server wrong direction");
562 return;
563 }
564
565 /* Increment our total user count here */
566 if (++Count.total > Count.max_tot)
567 Count.max_tot = Count.total;
568
569 SetClient(source_p);
570 dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->client_list);
571 add_user_host(source_p->username, source_p->host, 1);
572 SetUserHost(source_p);
573
574 introduce_client(client_p, source_p);
575 }
576
577 /* introduce_client()
578 *
579 * inputs - client_p
580 * - source_p
581 * output - NONE
582 * side effects - This common function introduces a client to the rest
583 * of the net, either from a local client connect or
584 * from a remote connect.
585 */
586 static void
587 introduce_client(struct Client *client_p, struct Client *source_p)
588 {
589 dlink_node *server_node = NULL;
590 static char ubuf[12];
591
592 if (MyClient(source_p))
593 send_umode(source_p, source_p, 0, SEND_UMODES, ubuf);
594 else
595 send_umode(NULL, source_p, 0, SEND_UMODES, ubuf);
596
597 watch_check_hash(source_p, RPL_LOGON);
598
599 if (*ubuf == '\0')
600 {
601 ubuf[0] = '+';
602 ubuf[1] = '\0';
603 }
604
605 DLINK_FOREACH(server_node, serv_list.head)
606 {
607 struct Client *server = server_node->data;
608
609 if (server == client_p)
610 continue;
611
612 if (IsCapable(server, CAP_TS6) && HasID(source_p))
613 sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s",
614 source_p->servptr->id,
615 source_p->name, source_p->hopcount+1,
616 (unsigned long)source_p->tsinfo,
617 ubuf, source_p->username, source_p->host,
618 (MyClient(source_p) && IsIPSpoof(source_p)) ?
619 "0" : source_p->sockhost, source_p->id, source_p->info);
620 else
621 sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s",
622 source_p->name, source_p->hopcount+1,
623 (unsigned long)source_p->tsinfo,
624 ubuf, source_p->username, source_p->host,
625 source_p->servptr->name, source_p->info);
626 }
627 }
628
629 /* valid_hostname()
630 *
631 * Inputs - pointer to hostname
632 * Output - 1 if valid, 0 if not
633 * Side effects - check hostname for validity
634 *
635 * NOTE: this doesn't allow a hostname to begin with a dot and
636 * will not allow more dots than chars.
637 */
638 int
639 valid_hostname(const char *hostname)
640 {
641 const char *p = hostname;
642
643 assert(p != NULL);
644
645 if ('.' == *p || ':' == *p)
646 return 0;
647
648 while (*p)
649 {
650 if (!IsHostChar(*p))
651 return 0;
652 p++;
653 }
654
655 return 1;
656 }
657
658 /* valid_username()
659 *
660 * Inputs - pointer to user
661 * Output - 1 if valid, 0 if not
662 * Side effects - check username for validity
663 *
664 * Absolutely always reject any '*' '!' '?' '@' in an user name
665 * reject any odd control characters names.
666 * Allow '.' in username to allow for "first.last"
667 * style of username
668 */
669 int
670 valid_username(const char *username)
671 {
672 int dots = 0;
673 const char *p = username;
674
675 assert(p != NULL);
676
677 if ('~' == *p)
678 ++p;
679
680 /* reject usernames that don't start with an alphanum
681 * i.e. reject jokers who have '-@somehost' or '.@somehost'
682 * or "-hi-@somehost", "h-----@somehost" would still be accepted.
683 */
684 if (!IsAlNum(*p))
685 return 0;
686
687 while (*++p)
688 {
689 if ((*p == '.') && ConfigFileEntry.dots_in_ident)
690 {
691 dots++;
692
693 if (dots > ConfigFileEntry.dots_in_ident)
694 return 0;
695 if (!IsUserChar(p[1]))
696 return 0;
697 }
698 else if (!IsUserChar(*p))
699 return 0;
700 }
701
702 return 1;
703 }
704
705 /* report_and_set_user_flags()
706 *
707 * inputs - pointer to source_p
708 * - pointer to aconf for this user
709 * output - NONE
710 * side effects - Report to user any special flags
711 * they are getting, and set them.
712 */
713 static void
714 report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf)
715 {
716 /* If this user is being spoofed, tell them so */
717 if (IsConfDoSpoofIp(aconf))
718 {
719 sendto_one(source_p,
720 ":%s NOTICE %s :*** Spoofing your IP. congrats.",
721 me.name, source_p->name);
722 }
723
724 /* If this user is in the exception class, Set it "E lined" */
725 if (IsConfExemptKline(aconf))
726 {
727 SetExemptKline(source_p);
728 sendto_one(source_p,
729 ":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.",
730 me.name, source_p->name);
731 }
732
733 /* The else here is to make sure that G line exempt users
734 * do not get noticed twice.
735 */
736 else if (IsConfExemptGline(aconf))
737 {
738 SetExemptGline(source_p);
739 sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.",
740 me.name, source_p->name);
741 }
742
743 if (IsConfExemptResv(aconf))
744 {
745 SetExemptResv(source_p);
746 sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.",
747 me.name, source_p->name);
748 }
749
750 /* If this user is exempt from user limits set it "F lined" */
751 if (IsConfExemptLimits(aconf))
752 {
753 SetExemptLimits(source_p);
754 sendto_one(source_p,
755 ":%s NOTICE %s :*** You are exempt from user limits. congrats.",
756 me.name,source_p->name);
757 }
758
759 /* If this user is exempt from idle time outs */
760 if (IsConfIdlelined(aconf))
761 {
762 SetIdlelined(source_p);
763 sendto_one(source_p,
764 ":%s NOTICE %s :*** You are exempt from idle limits. congrats.",
765 me.name, source_p->name);
766 }
767
768 if (IsConfCanFlood(aconf))
769 {
770 SetCanFlood(source_p);
771 sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood "
772 "protection, aren't you fearsome.",
773 me.name, source_p->name);
774 }
775 }
776
777 /* do_local_user()
778 *
779 * inputs -
780 * output - NONE
781 * side effects -
782 */
783 void
784 do_local_user(const char *nick, struct Client *client_p, struct Client *source_p,
785 const char *username, const char *host, const char *server,
786 const char *realname)
787 {
788 assert(source_p != NULL);
789 assert(source_p->username != username);
790
791 if (source_p == NULL)
792 return;
793
794 if (!IsUnknown(source_p))
795 {
796 sendto_one(source_p, form_str(ERR_ALREADYREGISTRED),
797 me.name, nick);
798 return;
799 }
800
801 source_p->localClient->registration &= ~REG_NEED_USER;
802
803 /*
804 * don't take the clients word for it, ever
805 */
806 source_p->servptr = &me;
807
808 strlcpy(source_p->info, realname, sizeof(source_p->info));
809
810 /* stash for later */
811 strlcpy(source_p->client_host, host, sizeof(source_p->client_host));
812 strlcpy(source_p->client_server, server, sizeof(source_p->client_server));
813
814 if (!IsGotId(source_p))
815 {
816 /* save the username in the client
817 * If you move this you'll break ping cookies..you've been warned
818 */
819 strlcpy(source_p->username, username, sizeof(source_p->username));
820 }
821
822 if (!source_p->localClient->registration)
823 /* NICK already received, now I have USER... */
824 register_local_user(client_p, source_p, source_p->name, username);
825 }
826
827 /* change_simple_umode()
828 *
829 * this callback can be hooked to allow special handling of
830 * certain usermodes
831 */
832 static void *
833 change_simple_umode(va_list args)
834 {
835 struct Client *client_p;
836 struct Client *source_p;
837 int what;
838 unsigned int flag;
839
840 client_p = va_arg(args, struct Client *);
841 source_p = va_arg(args, struct Client *);
842 what = va_arg(args, int);
843 flag = va_arg(args, unsigned int);
844
845 if (what == MODE_ADD)
846 source_p->umodes |= flag;
847 else
848 source_p->umodes &= ~flag;
849
850 return NULL;
851 }
852
853 /* set_user_mode()
854 *
855 * added 15/10/91 By Darren Reed.
856 * parv[0] - sender
857 * parv[1] - username to change mode for
858 * parv[2] - modes to change
859 */
860 void
861 set_user_mode(struct Client *client_p, struct Client *source_p,
862 int parc, char *parv[])
863 {
864 unsigned int flag, setflags;
865 char **p, *m, buf[IRCD_BUFSIZE];
866 struct Client *target_p;
867 int what = MODE_ADD, badflag = 0, i;
868
869 assert(!(parc < 2));
870
871 if ((target_p = find_person(client_p, parv[1])) == NULL)
872 {
873 if (MyConnect(source_p))
874 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
875 me.name, source_p->name, parv[1]);
876 return;
877 }
878
879 if (IsServer(source_p))
880 {
881 sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s",
882 parv[1], source_p->name);
883 return;
884 }
885
886 if (source_p != target_p || target_p->from != source_p->from)
887 {
888 sendto_one(source_p, form_str(ERR_USERSDONTMATCH),
889 me.name, source_p->name);
890 return;
891 }
892
893 if (parc < 3)
894 {
895 m = buf;
896 *m++ = '+';
897
898 for (i = 0; i < 128; i++)
899 if (source_p->umodes & user_modes[i])
900 *m++ = (char)i;
901 *m = '\0';
902
903 sendto_one(source_p, form_str(RPL_UMODEIS),
904 me.name, source_p->name, buf);
905 return;
906 }
907
908 execute_callback(entering_umode_cb, client_p, source_p);
909
910 /* find flags already set for user */
911 setflags = source_p->umodes;
912
913 /* parse mode change string(s) */
914 for (p = &parv[2]; p && *p; p++)
915 {
916 for (m = *p; *m; m++)
917 {
918 switch (*m)
919 {
920 case '+':
921 what = MODE_ADD;
922 break;
923 case '-':
924 what = MODE_DEL;
925 break;
926 case 'o':
927 if (what == MODE_ADD)
928 {
929 if (IsServer(client_p) && !IsOper(source_p))
930 {
931 ++Count.oper;
932 SetOper(source_p);
933 }
934 }
935 else
936 {
937 /* Only decrement the oper counts if an oper to begin with
938 * found by Pat Szuta, Perly , perly@xnet.com
939 */
940 if (!IsOper(source_p))
941 break;
942
943 ClearOper(source_p);
944 source_p->umodes &= ~ConfigFileEntry.oper_only_umodes;
945 Count.oper--;
946
947 if (MyConnect(source_p))
948 {
949 dlink_node *dm;
950
951 detach_conf(source_p, OPER_TYPE);
952 ClearOperFlags(source_p);
953
954 if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL)
955 free_dlink_node(dm);
956 }
957 }
958
959 break;
960
961 /* we may not get these,
962 * but they shouldnt be in default
963 */
964 case ' ' :
965 case '\n':
966 case '\r':
967 case '\t':
968 break;
969
970 default:
971 if ((flag = user_modes[(unsigned char)*m]))
972 {
973 if (MyConnect(source_p) && !IsOper(source_p) &&
974 (ConfigFileEntry.oper_only_umodes & flag))
975 {
976 badflag = 1;
977 }
978 else
979 execute_callback(umode_cb, client_p, source_p, what, flag);
980 }
981 else
982 {
983 if (MyConnect(source_p))
984 badflag = 1;
985 }
986
987 break;
988 }
989 }
990 }
991
992 if (badflag)
993 sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG),
994 me.name, source_p->name);
995
996 if ((source_p->umodes & UMODE_NCHANGE) && !IsOperN(source_p))
997 {
998 sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
999 me.name, source_p->name);
1000 source_p->umodes &= ~UMODE_NCHANGE; /* only tcm's really need this */
1001 }
1002
1003 if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) &&
1004 !IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p))
1005 {
1006 sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;",
1007 me.name, source_p->name);
1008 source_p->umodes &= ~UMODE_ADMIN;
1009 }
1010
1011 if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p))
1012 ++Count.invisi;
1013 if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p))
1014 --Count.invisi;
1015
1016 /*
1017 * compare new flags with old flags and send string which
1018 * will cause servers to update correctly.
1019 */
1020 send_umode_out(client_p, source_p, setflags);
1021 }
1022
1023 /* send_umode()
1024 * send the MODE string for user (user) to connection client_p
1025 * -avalon
1026 *
1027 * inputs - client_p
1028 * - source_p
1029 * - int old
1030 * - sendmask mask of modes to send
1031 * - suplied umode_buf
1032 * output - NONE
1033 */
1034 void
1035 send_umode(struct Client *client_p, struct Client *source_p,
1036 unsigned int old, unsigned int sendmask, char *umode_buf)
1037 {
1038 int what = 0;
1039 unsigned int i;
1040 unsigned int flag;
1041 char *m = umode_buf;
1042
1043 /*
1044 * build a string in umode_buf to represent the change in the user's
1045 * mode between the new (source_p->umodes) and 'old'.
1046 */
1047 for (i = 0; i < 128; i++)
1048 {
1049 flag = user_modes[i];
1050 if (!flag)
1051 continue;
1052
1053 if (MyClient(source_p) && !(flag & sendmask))
1054 continue;
1055
1056 if ((flag & old) && !(source_p->umodes & flag))
1057 {
1058 if (what == MODE_DEL)
1059 *m++ = (char)i;
1060 else
1061 {
1062 what = MODE_DEL;
1063 *m++ = '-';
1064 *m++ = (char)i;
1065 }
1066 }
1067 else if (!(flag & old) && (source_p->umodes & flag))
1068 {
1069 if (what == MODE_ADD)
1070 *m++ = (char)i;
1071 else
1072 {
1073 what = MODE_ADD;
1074 *m++ = '+';
1075 *m++ = (char)i;
1076 }
1077 }
1078 }
1079
1080 *m = '\0';
1081
1082 if (*umode_buf && client_p)
1083 sendto_one(client_p, ":%s!%s@%s MODE %s :%s",
1084 source_p->name, source_p->username,
1085 source_p->host, source_p->name, umode_buf);
1086 }
1087
1088 /* send_umode_out()
1089 *
1090 * inputs -
1091 * output - NONE
1092 * side effects - Only send ubuf out to servers that know about this client
1093 */
1094 void
1095 send_umode_out(struct Client *client_p, struct Client *source_p,
1096 unsigned int old)
1097 {
1098 char buf[IRCD_BUFSIZE] = { '\0' };
1099 dlink_node *ptr = NULL;
1100
1101 send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ?
1102 SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf);
1103
1104 if (buf[0])
1105 {
1106 DLINK_FOREACH(ptr, serv_list.head)
1107 {
1108 struct Client *target_p = ptr->data;
1109
1110 if ((target_p != client_p) && (target_p != source_p))
1111 sendto_one(target_p, ":%s MODE %s :%s",
1112 ID_or_name(source_p, target_p),
1113 ID_or_name(source_p, target_p), buf);
1114 }
1115 }
1116
1117 if (client_p && MyClient(client_p))
1118 send_umode(client_p, source_p, old, 0xffffffff, buf);
1119 }
1120
1121 /* user_welcome()
1122 *
1123 * inputs - client pointer to client to welcome
1124 * output - NONE
1125 * side effects -
1126 */
1127 static void
1128 user_welcome(struct Client *source_p)
1129 {
1130 #if defined(__TIME__) && defined(__DATE__)
1131 static const char built_date[] = __DATE__ " at " __TIME__;
1132 #else
1133 static const char built_date[] = "unknown";
1134 #endif
1135
1136 #ifdef HAVE_LIBCRYPTO
1137 if (source_p->localClient->fd.ssl != NULL)
1138 sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s",
1139 me.name, source_p->name,
1140 ssl_get_cipher(source_p->localClient->fd.ssl));
1141 #endif
1142
1143 sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name,
1144 ServerInfo.network_name, source_p->name);
1145 sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name,
1146 get_listener_name(source_p->localClient->listener), ircd_version);
1147 sendto_one(source_p, form_str(RPL_CREATED),
1148 me.name, source_p->name, built_date);
1149 sendto_one(source_p, form_str(RPL_MYINFO),
1150 me.name, source_p->name, me.name, ircd_version, umode_buffer);
1151 show_isupport(source_p);
1152
1153 if (source_p->id[0] != '\0')
1154 sendto_one(source_p, form_str(RPL_YOURID), me.name,
1155 source_p->name, source_p->id);
1156
1157 show_lusers(source_p);
1158
1159 if (ConfigFileEntry.short_motd)
1160 {
1161 sendto_one(source_p, "NOTICE %s :*** Notice -- motd was last changed at %s",
1162 source_p->name, ConfigFileEntry.motd.lastChangedDate);
1163 sendto_one(source_p,
1164 "NOTICE %s :*** Notice -- Please read the motd if you haven't "
1165 "read it", source_p->name);
1166 sendto_one(source_p, form_str(RPL_MOTDSTART),
1167 me.name, source_p->name, me.name);
1168 sendto_one(source_p, form_str(RPL_MOTD),
1169 me.name, source_p->name,
1170 "*** This is the short motd ***");
1171 sendto_one(source_p, form_str(RPL_ENDOFMOTD),
1172 me.name, source_p->name);
1173 }
1174 else
1175 send_message_file(source_p, &ConfigFileEntry.motd);
1176 }
1177
1178 /* check_xline()
1179 *
1180 * inputs - pointer to client to test
1181 * outupt - 1 if exiting 0 if ok
1182 * side effects -
1183 */
1184 static int
1185 check_xline(struct Client *source_p)
1186 {
1187 struct ConfItem *conf = NULL;
1188 const char *reason = NULL;
1189
1190 if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) ||
1191 (conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0)))
1192 {
1193 struct MatchItem *reg = map_to_conf(conf);
1194
1195 ++reg->count;
1196
1197 if (reg->reason != NULL)
1198 reason = reg->reason;
1199 else
1200 reason = "No Reason";
1201
1202 sendto_realops_flags(UMODE_REJ, L_ALL,
1203 "X-line Rejecting [%s] [%s], user %s [%s]",
1204 source_p->info, reason,
1205 get_client_name(source_p, HIDE_IP),
1206 source_p->sockhost);
1207
1208 ServerStats->is_ref++;
1209 if (REJECT_HOLD_TIME > 0)
1210 {
1211 sendto_one(source_p, ":%s NOTICE %s :Bad user info",
1212 me.name, source_p->name);
1213 source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME;
1214 SetCaptured(source_p);
1215 }
1216 else
1217 exit_client(source_p, &me, "Bad user info");
1218 return 1;
1219 }
1220
1221 return 0;
1222 }
1223
1224 /* oper_up()
1225 *
1226 * inputs - pointer to given client to oper
1227 * output - NONE
1228 * side effects - Blindly opers up given source_p, using aconf info
1229 * all checks on passwords have already been done.
1230 * This could also be used by rsa oper routines.
1231 */
1232 void
1233 oper_up(struct Client *source_p)
1234 {
1235 unsigned int old = source_p->umodes;
1236 const char *operprivs = "";
1237 const struct AccessItem *oconf = NULL;
1238
1239 assert(source_p->localClient->confs.head);
1240 oconf = map_to_conf((source_p->localClient->confs.head)->data);
1241
1242 ++Count.oper;
1243 SetOper(source_p);
1244
1245 if (oconf->modes)
1246 source_p->umodes |= oconf->modes;
1247 else if (ConfigFileEntry.oper_umodes)
1248 source_p->umodes |= ConfigFileEntry.oper_umodes;
1249 else
1250 source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL|
1251 UMODE_WALLOP|UMODE_LOCOPS);
1252
1253 if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p))
1254 ++Count.invisi;
1255 if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p))
1256 --Count.invisi;
1257
1258 assert(dlinkFind(&oper_list, source_p) == NULL);
1259 dlinkAdd(source_p, make_dlink_node(), &oper_list);
1260
1261 operprivs = oper_privs_as_string(oconf->port);
1262
1263 SetOFlag(source_p, oconf->port);
1264
1265 if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p))
1266 source_p->umodes |= UMODE_ADMIN;
1267 if (!IsOperN(source_p))
1268 source_p->umodes &= ~UMODE_NCHANGE;
1269
1270 sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator",
1271 source_p->name, source_p->username, source_p->host);
1272 send_umode_out(source_p, source_p, old);
1273 sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
1274 sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s",
1275 me.name, source_p->name, operprivs);
1276 send_message_file(source_p, &ConfigFileEntry.opermotd);
1277 }
1278
1279 static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */
1280
1281 int
1282 valid_sid(const char *sid)
1283 {
1284
1285 if (strlen(sid) == IRC_MAXSID)
1286 if (IsDigit(*sid))
1287 if (IsAlNum(*(sid + 1)) && IsAlNum(*(sid + 2)))
1288 return 1;
1289
1290 return 0;
1291 }
1292
1293 /*
1294 * init_uid()
1295 *
1296 * inputs - NONE
1297 * output - NONE
1298 * side effects - new_uid is filled in with server id portion (sid)
1299 * (first 3 bytes) or defaulted to 'A'.
1300 * Rest is filled in with 'A'
1301 */
1302 void
1303 init_uid(void)
1304 {
1305 int i;
1306
1307 memset(new_uid, 0, sizeof(new_uid));
1308
1309 if (ServerInfo.sid != NULL)
1310 {
1311 strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid));
1312 strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
1313
1314 hash_add_id(&me);
1315 }
1316
1317 for (i = 0; i < IRC_MAXSID; i++)
1318 if (new_uid[i] == '\0')
1319 new_uid[i] = 'A';
1320
1321 /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1322 /* Yes nenolod, I have known it was off by one ever since I wrote it
1323 * But *JUST* for you, though, it really doesn't look as *pretty*
1324 * -Dianora
1325 */
1326 memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID);
1327
1328 entering_umode_cb = register_callback("entering_umode", NULL);
1329 umode_cb = register_callback("changing_umode", change_simple_umode);
1330 uid_get_cb = register_callback("uid_get", uid_get);
1331 }
1332
1333 /*
1334 * add_one_to_uid
1335 *
1336 * inputs - index number into new_uid
1337 * output - NONE
1338 * side effects - new_uid is incremented by one
1339 * note this is a recursive function
1340 */
1341 static void
1342 add_one_to_uid(int i)
1343 {
1344 if (i != IRC_MAXSID) /* Not reached server SID portion yet? */
1345 {
1346 if (new_uid[i] == 'Z')
1347 new_uid[i] = '0';
1348 else if (new_uid[i] == '9')
1349 {
1350 new_uid[i] = 'A';
1351 add_one_to_uid(i-1);
1352 }
1353 else
1354 ++new_uid[i];
1355 }
1356 else
1357 {
1358 /* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */
1359 if (new_uid[i] == 'Z')
1360 memcpy(new_uid + IRC_MAXSID, "AAAAAA", IRC_MAXUID);
1361 else
1362 ++new_uid[i];
1363 }
1364 }
1365
1366 /*
1367 * uid_get
1368 *
1369 * inputs - struct Client *
1370 * output - new UID is returned to caller
1371 * side effects - new_uid is incremented by one.
1372 */
1373 static void *
1374 uid_get(va_list args)
1375 {
1376 add_one_to_uid(TOTALSIDUID - 1); /* index from 0 */
1377 return new_uid;
1378 }
1379
1380 /*
1381 * init_isupport()
1382 *
1383 * input - NONE
1384 * output - NONE
1385 * side effects - Must be called before isupport is enabled
1386 */
1387 void
1388 init_isupport(void)
1389 {
1390 isupportFile = init_MessageLine();
1391
1392 add_isupport("CALLERID", NULL, -1);
1393 add_isupport("CASEMAPPING", CASEMAP, -1);
1394 add_isupport("DEAF", "D", -1);
1395 add_isupport("KICKLEN", NULL, KICKLEN);
1396 add_isupport("MODES", NULL, MAXMODEPARAMS);
1397 add_isupport("NICKLEN", NULL, NICKLEN-1);
1398 #ifdef HALFOPS
1399 add_isupport("PREFIX", "(ohv)@%+", -1);
1400 add_isupport("STATUSMSG", "@%+", -1);
1401 #else
1402 add_isupport("PREFIX", "(ov)@+", -1);
1403 add_isupport("STATUSMSG", "@+", -1);
1404 #endif
1405 add_isupport("TOPICLEN", NULL, TOPICLEN);
1406 }
1407
1408 /*
1409 * add_isupport()
1410 *
1411 * input - name of supported function
1412 * - options if any
1413 * - number if any
1414 * output - NONE
1415 * side effects - Each supported item must call this when activated
1416 */
1417 void
1418 add_isupport(const char *name, const char *options, int n)
1419 {
1420 dlink_node *ptr;
1421 struct Isupport *support;
1422
1423 DLINK_FOREACH(ptr, support_list.head)
1424 {
1425 support = ptr->data;
1426 if (irccmp(support->name, name) == 0)
1427 {
1428 MyFree(support->name);
1429 MyFree(support->options);
1430 break;
1431 }
1432 }
1433
1434 if (ptr == NULL)
1435 {
1436 support = MyMalloc(sizeof(*support));
1437 dlinkAddTail(support, &support->node, &support_list);
1438 }
1439
1440 DupString(support->name, name);
1441 if (options != NULL)
1442 DupString(support->options, options);
1443 support->number = n;
1444
1445 rebuild_isupport_message_line();
1446 }
1447
1448 /*
1449 * delete_isupport()
1450 *
1451 * input - name of supported function
1452 * output - NONE
1453 * side effects - Each supported item must call this when deactivated
1454 */
1455 void
1456 delete_isupport(const char *name)
1457 {
1458 dlink_node *ptr;
1459 struct Isupport *support;
1460
1461 DLINK_FOREACH(ptr, support_list.head)
1462 {
1463 support = ptr->data;
1464 if (irccmp(support->name, name) == 0)
1465 {
1466 dlinkDelete(ptr, &support_list);
1467 MyFree(support->name);
1468 MyFree(support->options);
1469 MyFree(support);
1470 break;
1471 }
1472 }
1473
1474 rebuild_isupport_message_line();
1475 }
1476
1477 /*
1478 * rebuild_isupport_message_line
1479 *
1480 * input - NONE
1481 * output - NONE
1482 * side effects - Destroy the isupport MessageFile lines, and rebuild.
1483 */
1484 void
1485 rebuild_isupport_message_line(void)
1486 {
1487 char isupportbuffer[IRCD_BUFSIZE];
1488 char *p = isupportbuffer;
1489 dlink_node *ptr = NULL;
1490 int n = 0;
1491 int tokens = 0;
1492 size_t len = 0;
1493 size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT));
1494
1495 destroy_MessageLine(isupportFile);
1496
1497 DLINK_FOREACH(ptr, support_list.head)
1498 {
1499 struct Isupport *support = ptr->data;
1500
1501 p += (n = ircsprintf(p, "%s", support->name));
1502 len += n;
1503
1504 if (support->options != NULL)
1505 {
1506 p += (n = ircsprintf(p, "=%s", support->options));
1507 len += n;
1508 }
1509
1510 if (support->number > 0)
1511 {
1512 p += (n = ircsprintf(p, "=%d", support->number));
1513 len += n;
1514 }
1515
1516 *p++ = ' ';
1517 len++;
1518 *p = '\0';
1519
1520 if (++tokens == (MAXPARA-2) || len >= (sizeof(isupportbuffer)-reserve))
1521 { /* arbritrary for now */
1522 if (*--p == ' ')
1523 *p = '\0';
1524
1525 addto_MessageLine(isupportFile, isupportbuffer);
1526 p = isupportbuffer;
1527 len = 0;
1528 n = tokens = 0;
1529 }
1530 }
1531
1532 if (len != 0)
1533 {
1534 if (*--p == ' ')
1535 *p = '\0';
1536 addto_MessageLine(isupportFile, isupportbuffer);
1537 }
1538 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26