ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/src/s_user.c
Revision: 980
Committed: Sun Aug 9 12:51:45 2009 UTC (14 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 41351 byte(s)
Log Message:
- remove useless MyConnect tests in m_time() and m_lusers()
- remove useless TS6 handling in m_who() since this is sent to local
  clients only

File Contents

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

Properties

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