2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
28 #include "conn-func.h"
41 #include "irc-write.h"
42 #include "client-cap.h"
50 t_diff(time_t *t, const time_t d)
58 return (unsigned int)diff;
62 uptime_days(time_t *now)
64 return t_diff(now, 60 * 60 * 24);
68 uptime_hrs(time_t *now)
70 return t_diff(now, 60 * 60);
74 uptime_mins(time_t *now)
76 return t_diff(now, 60);
80 write_whoreply(CLIENT *Client, CLIENT *c, const char *channelname, const char *flags)
82 return IRC_WriteStrClient(Client, RPL_WHOREPLY_MSG, Client_ID(Client),
83 channelname, Client_User(c),
84 Client_HostnameDisplayed(c),
85 Client_ID(Client_Introducer(c)), Client_ID(c),
86 flags, Client_Hops(c), Client_Info(c));
90 who_flags_status(const char *client_modes)
92 if (strchr(client_modes, 'a'))
93 return "G"; /* away */
98 * Return channel user mode prefix(es).
100 * @param Client The client requesting the mode prefixes.
101 * @param chan_user_modes String with channel user modes.
102 * @param str String buffer to which the prefix(es) will be appended.
103 * @param len Size of "str" buffer.
104 * @return Pointer to "str".
107 who_flags_qualifier(CLIENT *Client, const char *chan_user_modes,
108 char *str, size_t len)
110 assert(Client != NULL);
112 if (Client_Cap(Client) & CLIENT_CAP_MULTI_PREFIX) {
113 if (strchr(chan_user_modes, 'q'))
114 strlcat(str, "~", len);
115 if (strchr(chan_user_modes, 'a'))
116 strlcat(str, "&", len);
117 if (strchr(chan_user_modes, 'o'))
118 strlcat(str, "@", len);
119 if (strchr(chan_user_modes, 'h'))
120 strlcat(str, "%", len);
121 if (strchr(chan_user_modes, 'v'))
122 strlcat(str, "+", len);
127 if (strchr(chan_user_modes, 'q'))
128 strlcat(str, "~", len);
129 else if (strchr(chan_user_modes, 'a'))
130 strlcat(str, "&", len);
131 else if (strchr(chan_user_modes, 'o'))
132 strlcat(str, "@", len);
133 else if (strchr(chan_user_modes, 'h'))
134 strlcat(str, "%", len);
135 else if (strchr(chan_user_modes, 'v'))
136 strlcat(str, "+", len);
142 * Send WHO reply for a "channel target" ("WHO #channel").
144 * @param Client Client requesting the information.
145 * @param Chan Channel being requested.
146 * @param OnlyOps Only display IRC operators.
147 * @return CONNECTED or DISCONNECTED.
150 IRC_WHO_Channel(CLIENT *Client, CHANNEL *Chan, bool OnlyOps)
152 bool is_visible, is_member, is_ircop;
154 const char *client_modes;
159 assert( Client != NULL );
160 assert( Chan != NULL );
162 IRC_SetPenalty(Client, 1);
164 is_member = Channel_IsMemberOf(Chan, Client);
166 /* Secret channel? */
167 if (!is_member && strchr(Channel_Modes(Chan), 's'))
168 return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG,
169 Client_ID(Client), Channel_Name(Chan));
171 cl2chan = Channel_FirstMember(Chan);
172 for (; cl2chan ; cl2chan = Channel_NextMember(Chan, cl2chan)) {
173 c = Channel_GetClient(cl2chan);
175 client_modes = Client_Modes(c);
176 is_ircop = strchr(client_modes, 'o') != NULL;
177 if (OnlyOps && !is_ircop)
180 is_visible = strchr(client_modes, 'i') == NULL;
181 if (is_member || is_visible) {
182 strlcpy(flags, who_flags_status(client_modes),
185 strlcat(flags, "*", sizeof(flags));
187 who_flags_qualifier(Client, Channel_UserModes(Chan, c),
188 flags, sizeof(flags));
190 if (!write_whoreply(Client, c, Channel_Name(Chan),
197 /* If there are a lot of clients, augment penalty a bit */
198 if (count > MAX_RPL_WHO)
199 IRC_SetPenalty(Client, 1);
201 return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client),
206 * Send WHO reply for a "mask target" ("WHO m*sk").
208 * @param Client Client requesting the information.
209 * @param Mask Mask being requested or NULL for "all" clients.
210 * @param OnlyOps Only display IRC operators.
211 * @return CONNECTED or DISCONNECTED.
214 IRC_WHO_Mask(CLIENT *Client, char *Mask, bool OnlyOps)
219 bool client_match, is_visible;
223 assert (Client != NULL);
228 IRC_SetPenalty(Client, 3);
229 for (c = Client_First(); c != NULL; c = Client_Next(c)) {
230 if (Client_Type(c) != CLIENT_USER)
233 if (OnlyOps && !Client_HasMode(c, 'o'))
237 /* Match pattern against user host/server/name/nick */
238 client_match = MatchCaseInsensitive(Mask,
241 client_match = MatchCaseInsensitive(Mask,
242 Client_ID(Client_Introducer(c)));
244 client_match = MatchCaseInsensitive(Mask,
247 client_match = MatchCaseInsensitive(Mask,
250 continue; /* no match: skip this client */
253 is_visible = !Client_HasMode(c, 'i');
255 /* Target client is invisible, but mask matches exactly? */
256 if (!is_visible && Mask && strcasecmp(Client_ID(c), Mask) == 0)
259 /* Target still invisible, but are both on the same channel? */
261 cl2chan = Channel_FirstChannelOf(Client);
262 while (cl2chan && !is_visible) {
263 chan = Channel_GetChannel(cl2chan);
264 if (Channel_IsMemberOf(chan, c))
266 cl2chan = Channel_NextChannelOf(Client, cl2chan);
270 if (!is_visible) /* target user is not visible */
273 if (IRC_CheckListTooBig(Client, count, MAX_RPL_WHO, "WHO"))
276 strlcpy(flags, who_flags_status(Client_Modes(c)), sizeof(flags));
277 if (strchr(Client_Modes(c), 'o'))
278 strlcat(flags, "*", sizeof(flags));
280 if (!write_whoreply(Client, c, "*", flags))
285 return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client),
290 * Generate WHOIS reply of one actual client.
292 * @param Client The client from which this command has been received.
293 * @param from The client requesting the information ("originator").
294 * @param c The client of which information should be returned.
295 * @return CONNECTED or DISCONNECTED.
298 IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c)
300 char str[LINE_LEN + 1];
304 assert(Client != NULL);
305 assert(from != NULL);
308 /* Nick, user, hostname and client info */
309 if (!IRC_WriteStrClient(from, RPL_WHOISUSER_MSG, Client_ID(from),
310 Client_ID(c), Client_User(c),
311 Client_HostnameDisplayed(c), Client_Info(c)))
315 if (!IRC_WriteStrClient(from, RPL_WHOISSERVER_MSG, Client_ID(from),
316 Client_ID(c), Client_ID(Client_Introducer(c)),
317 Client_Info(Client_Introducer(c))))
321 snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
322 Client_ID(from), Client_ID(c));
323 cl2chan = Channel_FirstChannelOf(c);
325 chan = Channel_GetChannel(cl2chan);
326 assert(chan != NULL);
329 cl2chan = Channel_NextChannelOf(c, cl2chan);
331 /* Secret channel? */
332 if (strchr(Channel_Modes(chan), 's')
333 && !Channel_IsMemberOf(chan, Client))
336 /* Local channel and request is not from a user? */
337 if (Client_Type(Client) == CLIENT_SERVER
338 && Channel_IsLocal(chan))
341 /* Concatenate channel names */
342 if (str[strlen(str) - 1] != ':')
343 strlcat(str, " ", sizeof(str));
345 who_flags_qualifier(Client, Channel_UserModes(chan, c),
347 strlcat(str, Channel_Name(chan), sizeof(str));
349 if (strlen(str) > (LINE_LEN - CHANNEL_NAME_LEN - 4)) {
350 /* Line becomes too long: send it! */
351 if (!IRC_WriteStrClient(Client, "%s", str))
353 snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
354 Client_ID(from), Client_ID(c));
357 if(str[strlen(str) - 1] != ':') {
358 /* There is data left to send: */
359 if (!IRC_WriteStrClient(Client, "%s", str))
364 if (Client_HasMode(c, 'o') &&
365 !IRC_WriteStrClient(from, RPL_WHOISOPERATOR_MSG,
366 Client_ID(from), Client_ID(c)))
370 if (Client_HasMode(c, 'B') &&
371 !IRC_WriteStrClient(from, RPL_WHOISBOT_MSG,
372 Client_ID(from), Client_ID(c)))
375 /* Connected using SSL? */
376 if (Conn_UsesSSL(Client_Conn(c)) &&
377 !IRC_WriteStrClient(from, RPL_WHOISSSL_MSG, Client_ID(from),
381 /* Registered nickname? */
382 if (Client_HasMode(c, 'R') &&
383 !IRC_WriteStrClient(from, RPL_WHOISREGNICK_MSG,
384 Client_ID(from), Client_ID(c)))
387 /* Local client and requester is the user itself or an IRC Op? */
388 if (Client_Conn(c) > NONE &&
389 (from == c || (!Conf_MorePrivacy && Client_HasMode(from, 'o')))) {
390 /* Client hostname */
391 if (!IRC_WriteStrClient(from, RPL_WHOISHOST_MSG,
392 Client_ID(from), Client_ID(c), Client_Hostname(c),
393 Conn_GetIPAInfo(Client_Conn(c))))
396 if (!IRC_WriteStrClient(from, RPL_WHOISMODES_MSG,
397 Client_ID(from), Client_ID(c), Client_Modes(c)))
401 /* Idle and signon time (local clients only!) */
402 if (!Conf_MorePrivacy && Client_Conn(c) > NONE &&
403 !IRC_WriteStrClient(from, RPL_WHOISIDLE_MSG,
404 Client_ID(from), Client_ID(c),
405 (unsigned long)Conn_GetIdle(Client_Conn(c)),
406 (unsigned long)Conn_GetSignon(Client_Conn(c))))
410 if (Client_HasMode(c, 'a') &&
411 !IRC_WriteStrClient(from, RPL_AWAY_MSG,
412 Client_ID(from), Client_ID(c), Client_Away(c)))
419 WHOWAS_EntryWrite(CLIENT *prefix, WHOWAS *entry)
423 (void)strftime(t_str, sizeof(t_str), "%a %b %d %H:%M:%S %Y",
424 localtime(&entry->time));
426 if (!IRC_WriteStrClient(prefix, RPL_WHOWASUSER_MSG, Client_ID(prefix),
427 entry->id, entry->user, entry->host, entry->info))
430 return IRC_WriteStrClient(prefix, RPL_WHOISSERVER_MSG, Client_ID(prefix),
431 entry->id, entry->server, t_str);
435 Show_MOTD_Start(CLIENT *Client)
437 return IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG,
438 Client_ID( Client ), Client_ID( Client_ThisServer( )));
442 Show_MOTD_Sendline(CLIENT *Client, const char *msg)
444 return IRC_WriteStrClient(Client, RPL_MOTD_MSG, Client_ID( Client ), msg);
448 Show_MOTD_End(CLIENT *Client)
450 if (!IRC_WriteStrClient(Client, RPL_ENDOFMOTD_MSG, Client_ID(Client)))
454 return IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG,
456 Client_Hostname(Client));
462 static bool Show_MOTD_SSLInfo(CLIENT *Client)
465 char buf[COMMAND_LEN] = "Connected using Cipher ";
467 if (!Conn_GetCipherInfo(Client_Conn(Client), buf + 23, sizeof buf - 23))
470 if (!Show_MOTD_Sendline(Client, buf))
477 Show_MOTD_SSLInfo(UNUSED CLIENT *c)
481 /* Global functions */
484 IRC_ADMIN(CLIENT *Client, REQUEST *Req )
486 CLIENT *target, *prefix;
488 assert( Client != NULL );
489 assert( Req != NULL );
491 if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
493 /* find target ... */
494 if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
495 else target = Client_ThisServer( );
498 if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
499 else prefix = Client;
500 if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
502 /* forwad message to another server? */
503 if( target != Client_ThisServer( ))
505 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
508 IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
512 /* mit Versionsinfo antworten */
513 if( ! IRC_WriteStrClient( Client, RPL_ADMINME_MSG, Client_ID( prefix ), Conf_ServerName )) return DISCONNECTED;
514 if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC1_MSG, Client_ID( prefix ), Conf_ServerAdmin1 )) return DISCONNECTED;
515 if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC2_MSG, Client_ID( prefix ), Conf_ServerAdmin2 )) return DISCONNECTED;
516 if( ! IRC_WriteStrClient( Client, RPL_ADMINEMAIL_MSG, Client_ID( prefix ), Conf_ServerAdminMail )) return DISCONNECTED;
518 IRC_SetPenalty( Client, 1 );
524 * Handler for the IRC command "INFO".
525 * See RFC 2812 section 3.4.10.
528 IRC_INFO(CLIENT * Client, REQUEST * Req)
530 CLIENT *target, *prefix;
533 assert(Client != NULL);
536 /* Wrong number of parameters? */
538 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
539 Client_ID(Client), Req->command);
541 /* Determine prefix */
542 if (Client_Type(Client) == CLIENT_SERVER)
543 prefix = Client_Search(Req->prefix);
547 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
548 Client_ID(Client), Req->prefix);
550 /* Look for a target */
552 target = Client_Search(Req->argv[0]);
554 target = Client_ThisServer();
556 /* Make sure that the target is a server */
557 if (target && Client_Type(target) != CLIENT_SERVER)
558 target = Client_Introducer(target);
561 return IRC_WriteStrClient(prefix, ERR_NOSUCHSERVER_MSG,
562 Client_ID(prefix), Req->argv[0]);
564 /* Pass on to another server? */
565 if (target != Client_ThisServer()) {
566 IRC_WriteStrClientPrefix(target, prefix, "INFO %s",
571 if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix),
575 #if defined(__DATE__) && defined(__TIME__)
576 snprintf(msg, sizeof(msg), "Birth Date: %s at %s", __DATE__, __TIME__);
577 if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
581 strlcpy(msg, "On-line since ", sizeof(msg));
582 strlcat(msg, NGIRCd_StartStr, sizeof(msg));
583 if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
586 if (!IRC_WriteStrClient(Client, RPL_ENDOFINFO_MSG, Client_ID(prefix)))
589 IRC_SetPenalty(Client, 2);
595 * Handler for the IRC "ISON" command.
597 * See RFC 2812, 4.9 "Ison message".
599 * @param Client The client from which this command has been received.
600 * @param Req Request structure with prefix and all parameters.
601 * @return CONNECTED or DISCONNECTED.
604 IRC_ISON( CLIENT *Client, REQUEST *Req )
606 char rpl[COMMAND_LEN];
611 assert(Client != NULL);
614 /* Bad number of arguments? */
616 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
617 Client_ID(Client), Req->command);
619 strlcpy(rpl, RPL_ISON_MSG, sizeof rpl);
620 for (i = 0; i < Req->argc; i++) {
621 /* "All" ircd even parse ":<x> <y> ..." arguments and split
622 * them up; so we do the same ... */
623 ptr = strtok(Req->argv[i], " ");
626 c = Client_Search(ptr);
627 if (c && Client_Type(c) == CLIENT_USER) {
628 strlcat(rpl, Client_ID(c), sizeof(rpl));
629 strlcat(rpl, " ", sizeof(rpl));
631 ptr = strtok(NULL, " ");
634 ngt_TrimLastChr(rpl, ' ');
636 return IRC_WriteStrClient(Client, rpl, Client_ID(Client));
641 * Handler for the IRC "LINKS" command.
643 * See RFC 2812, 3.4.5 "Links message".
645 * @param Client The client from which this command has been received.
646 * @param Req Request structure with prefix and all parameters.
647 * @return CONNECTED or DISCONNECTED.
650 IRC_LINKS(CLIENT *Client, REQUEST *Req)
652 CLIENT *target, *from, *c;
655 assert(Client != NULL);
658 IRC_SetPenalty(Client, 1);
661 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
662 Client_ID(Client), Req->command);
664 /* Get pointer to server mask or "*", if none given */
666 mask = Req->argv[Req->argc - 1];
670 if (Client_Type(Client) == CLIENT_SERVER)
671 from = Client_Search(Req->prefix);
675 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
676 Client_ID(Client), Req->prefix);
679 if (Req->argc == 2) {
680 target = Client_Search(Req->argv[0]);
681 if (! target || Client_Type(target) != CLIENT_SERVER)
682 return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
686 if (target != Client_ThisServer())
687 return IRC_WriteStrClientPrefix(target, from,
688 "LINKS %s %s", Req->argv[0],
694 if (Client_Type(c) == CLIENT_SERVER
695 && MatchCaseInsensitive(mask, Client_ID(c))) {
696 if (!IRC_WriteStrClient(from, RPL_LINKS_MSG,
697 Client_ID(from), Client_ID(c),
698 Client_ID(Client_TopServer(c)
699 ? Client_TopServer(c)
700 : Client_ThisServer()),
701 Client_Hops(c), Client_Info(c)))
706 return IRC_WriteStrClient(from, RPL_ENDOFLINKS_MSG,
707 Client_ID(from), mask);
712 IRC_LUSERS( CLIENT *Client, REQUEST *Req )
714 CLIENT *target, *from;
716 assert( Client != NULL );
717 assert( Req != NULL );
719 if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
721 /* Absender ermitteln */
722 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
724 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
726 /* An anderen Server forwarden? */
729 target = Client_Search( Req->argv[1] );
730 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
731 else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LUSERS %s %s", Req->argv[0], Req->argv[1] );
734 /* Wer ist der Absender? */
735 if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix );
736 else target = Client;
737 if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
739 IRC_Send_LUSERS( target );
741 IRC_SetPenalty( target, 1 );
747 * Handler for the IRC command "SERVLIST".
748 * List registered services, see RFC 2811, section 3.5.1: the syntax is
749 * "SERVLIST [<mask> [<type>]]".
752 IRC_SERVLIST(CLIENT *Client, REQUEST *Req)
756 assert(Client != NULL);
760 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
761 Client_ID(Client), Req->command);
763 if (Req->argc < 2 || strcmp(Req->argv[1], "0") == 0) {
764 for (c = Client_First(); c!= NULL; c = Client_Next(c)) {
765 if (Client_Type(c) != CLIENT_SERVICE)
767 if (Req->argc > 0 && !MatchCaseInsensitive(Req->argv[0],
770 if (!IRC_WriteStrClient(Client, RPL_SERVLIST_MSG,
771 Client_ID(Client), Client_Mask(c),
772 Client_Mask(Client_Introducer(c)), "*",
773 0, Client_Hops(c), Client_Info(c)))
778 return IRC_WriteStrClient(Client, RPL_SERVLISTEND_MSG, Client_ID(Client),
779 Req->argc > 0 ? Req->argv[0] : "*",
780 Req->argc > 1 ? Req->argv[1] : "0");
785 IRC_MOTD( CLIENT *Client, REQUEST *Req )
787 CLIENT *from, *target;
789 assert( Client != NULL );
790 assert( Req != NULL );
792 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
794 /* From aus Prefix ermitteln */
795 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
797 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
802 target = Client_Search( Req->argv[0] );
803 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
805 if( target != Client_ThisServer( ))
807 /* Ok, anderer Server ist das Ziel: forwarden */
808 return IRC_WriteStrClientPrefix( target, from, "MOTD %s", Req->argv[0] );
812 IRC_SetPenalty( from, 3 );
813 return IRC_Show_MOTD( from );
818 IRC_NAMES( CLIENT *Client, REQUEST *Req )
820 char rpl[COMMAND_LEN], *ptr;
821 CLIENT *target, *from, *c;
824 assert( Client != NULL );
825 assert( Req != NULL );
827 if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
829 /* use prefix to determine "From" */
830 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
832 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
836 /* forward to another server? */
837 target = Client_Search( Req->argv[1] );
838 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
840 if( target != Client_ThisServer( )) {
841 /* target is another server, forward */
842 return IRC_WriteStrClientPrefix( target, from, "NAMES %s :%s", Req->argv[0], Req->argv[1] );
848 /* bestimmte Channels durchgehen */
849 ptr = strtok( Req->argv[0], "," );
852 chan = Channel_Search( ptr );
856 if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
858 if( ! IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), ptr )) return DISCONNECTED;
860 /* get next channel name */
861 ptr = strtok( NULL, "," );
866 chan = Channel_First( );
869 if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
871 chan = Channel_Next( chan );
874 /* Now print all clients which are not in any channel */
876 snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
879 if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' )))
881 /* its a user, concatenate ... */
882 if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl ));
883 strlcat( rpl, Client_ID( c ), sizeof( rpl ));
885 if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
887 /* Line is gwoing too long, send now */
888 if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
889 snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
893 c = Client_Next( c );
895 if( rpl[strlen( rpl ) - 1] != ':')
897 if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
900 IRC_SetPenalty( from, 1 );
901 return IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), "*" );
906 * Handler for the IRC command "STATS".
907 * See RFC 2812 section 3.4.4.
910 IRC_STATS( CLIENT *Client, REQUEST *Req )
912 CLIENT *from, *target, *cl;
917 unsigned int days, hrs, mins;
918 struct list_head *list;
919 struct list_elem *list_item;
921 assert(Client != NULL);
925 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
926 Client_ID(Client), Req->command);
928 /* use prefix to determine "From" */
929 if (Client_Type(Client) == CLIENT_SERVER)
930 from = Client_Search(Req->prefix);
935 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
936 Client_ID(Client), Req->prefix);
938 if (Req->argc == 2) {
939 /* forward to another server? */
940 target = Client_Search(Req->argv[1]);
941 if ((!target) || (Client_Type(target) != CLIENT_SERVER))
942 return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
943 Client_ID(from), Req->argv[1]);
945 if (target != Client_ThisServer()) {
946 /* forward to another server */
947 return IRC_WriteStrClientPrefix(target, from,
948 "STATS %s %s", Req->argv[0], Req->argv[1]);
953 query = Req->argv[0][0] ? Req->argv[0][0] : '*';
958 case 'g': /* Network-wide bans ("G-Lines") */
960 case 'k': /* Server-local bans ("K-Lines") */
962 if (!Client_HasMode(from, 'o'))
963 return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
965 if (query == 'g' || query == 'G')
966 list = Class_GetList(CLASS_GLINE);
968 list = Class_GetList(CLASS_KLINE);
969 list_item = Lists_GetFirst(list);
971 if (!IRC_WriteStrClient(from, RPL_STATSXLINE_MSG,
972 Client_ID(from), query,
973 Lists_GetMask(list_item),
974 Lists_GetValidity(list_item),
975 Lists_GetReason(list_item)))
977 list_item = Lists_GetNext(list_item);
980 case 'l': /* Link status (servers and own link) */
982 time_now = time(NULL);
983 for (con = Conn_First(); con != NONE; con = Conn_Next(con)) {
984 cl = Conn_GetClient(con);
987 if ((Client_Type(cl) == CLIENT_SERVER)
989 /* Server link or our own connection */
991 if (Conn_Options(con) & CONN_ZIP) {
992 if (!IRC_WriteStrClient
993 (from, RPL_STATSLINKINFOZIP_MSG,
994 Client_ID(from), Client_Mask(cl),
995 Conn_SendQ(con), Conn_SendMsg(con),
1000 Conn_RecvBytes(con),
1001 (long)(time_now - Conn_StartTime(con))))
1002 return DISCONNECTED;
1006 if (!IRC_WriteStrClient
1007 (from, RPL_STATSLINKINFO_MSG,
1008 Client_ID(from), Client_Mask(cl),
1009 Conn_SendQ(con), Conn_SendMsg(con),
1010 Conn_SendBytes(con), Conn_RecvMsg(con),
1011 Conn_RecvBytes(con),
1012 (long)(time_now - Conn_StartTime(con))))
1013 return DISCONNECTED;
1017 case 'm': /* IRC command status (usage count) */
1019 cmd = Parse_GetCommandStruct();
1020 for (; cmd->name; cmd++) {
1021 if (cmd->lcount == 0 && cmd->rcount == 0)
1023 if (!IRC_WriteStrClient
1024 (from, RPL_STATSCOMMANDS_MSG, Client_ID(from),
1025 cmd->name, cmd->lcount, cmd->bytes, cmd->rcount))
1026 return DISCONNECTED;
1029 case 'u': /* Server uptime */
1031 time_now = time(NULL) - NGIRCd_Start;
1032 days = uptime_days(&time_now);
1033 hrs = uptime_hrs(&time_now);
1034 mins = uptime_mins(&time_now);
1035 if (!IRC_WriteStrClient(from, RPL_STATSUPTIME, Client_ID(from),
1036 days, hrs, mins, (unsigned int)time_now))
1037 return DISCONNECTED;
1041 IRC_SetPenalty(from, 2);
1042 return IRC_WriteStrClient(from, RPL_ENDOFSTATS_MSG,
1043 Client_ID(from), query);
1048 * Handler for the IRC command "SUMMON".
1049 * See RFC 2812 section 4.5. ngIRCd doesn't implement this functionality and
1050 * therefore answers with ERR_SUMMONDISABLED.
1053 IRC_SUMMON(CLIENT * Client, UNUSED REQUEST * Req)
1055 return IRC_WriteStrClient(Client, ERR_SUMMONDISABLED_MSG,
1061 IRC_TIME( CLIENT *Client, REQUEST *Req )
1063 CLIENT *from, *target;
1067 assert( Client != NULL );
1068 assert( Req != NULL );
1070 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
1072 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
1074 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
1076 if( Req->argc == 1 )
1078 target = Client_Search( Req->argv[0] );
1079 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
1081 if( target != Client_ThisServer( ))
1083 return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] );
1088 (void)strftime( t_str, 60, "%A %B %d %Y -- %H:%M %Z", localtime( &t ));
1089 return IRC_WriteStrClient( from, RPL_TIME_MSG, Client_ID( from ), Client_ID( Client_ThisServer( )), t_str );
1094 * Handler for the IRC command "USERHOST".
1095 * See RFC 2812 section 4.8.
1098 IRC_USERHOST(CLIENT *Client, REQUEST *Req)
1100 char rpl[COMMAND_LEN];
1104 assert(Client != NULL);
1105 assert(Req != NULL);
1107 if ((Req->argc < 1))
1108 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1109 Client_ID(Client), Req->command);
1116 strlcpy(rpl, RPL_USERHOST_MSG, sizeof rpl);
1117 for (i = 0; i < max; i++) {
1118 c = Client_Search(Req->argv[i]);
1119 if (c && (Client_Type(c) == CLIENT_USER)) {
1120 /* This Nick is "online" */
1121 strlcat(rpl, Client_ID(c), sizeof(rpl));
1122 if (Client_HasMode(c, 'o'))
1123 strlcat(rpl, "*", sizeof(rpl));
1124 strlcat(rpl, "=", sizeof(rpl));
1125 if (Client_HasMode(c, 'a'))
1126 strlcat(rpl, "-", sizeof(rpl));
1128 strlcat(rpl, "+", sizeof(rpl));
1129 strlcat(rpl, Client_User(c), sizeof(rpl));
1130 strlcat(rpl, "@", sizeof(rpl));
1131 strlcat(rpl, Client_HostnameDisplayed(c), sizeof(rpl));
1132 strlcat(rpl, " ", sizeof(rpl));
1135 ngt_TrimLastChr(rpl, ' ');
1137 return IRC_WriteStrClient(Client, rpl, Client_ID(Client));
1138 } /* IRC_USERHOST */
1142 * Handler for the IRC command "USERS".
1143 * See RFC 2812 section 4.6. As suggested there the command is disabled.
1146 IRC_USERS(CLIENT * Client, UNUSED REQUEST * Req)
1148 return IRC_WriteStrClient(Client, ERR_USERSDISABLED_MSG,
1154 IRC_VERSION( CLIENT *Client, REQUEST *Req )
1156 CLIENT *target, *prefix;
1158 assert( Client != NULL );
1159 assert( Req != NULL );
1161 if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
1164 if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
1165 else target = Client_ThisServer( );
1167 /* Prefix ermitteln */
1168 if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
1169 else prefix = Client;
1170 if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
1172 /* An anderen Server weiterleiten? */
1173 if( target != Client_ThisServer( ))
1175 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
1178 IRC_WriteStrClientPrefix( target, prefix, "VERSION %s", Req->argv[0] );
1182 /* send version information */
1183 IRC_SetPenalty(Client, 1);
1184 return IRC_WriteStrClient(Client, RPL_VERSION_MSG, Client_ID(prefix),
1185 PACKAGE_NAME, PACKAGE_VERSION,
1186 NGIRCd_DebugLevel, Conf_ServerName,
1187 NGIRCd_VersionAddition);
1192 * Handler for the IRC "WHO" command.
1194 * See RFC 2812, 3.6.1 "Who query".
1196 * @param Client The client from which this command has been received.
1197 * @param Req Request structure with prefix and all parameters.
1198 * @return CONNECTED or DISCONNECTED.
1201 IRC_WHO(CLIENT *Client, REQUEST *Req)
1206 assert (Client != NULL);
1207 assert (Req != NULL);
1210 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1211 Client_ID(Client), Req->command);
1215 if (Req->argc == 2) {
1216 if (strcmp(Req->argv[1], "o") == 0)
1220 return IRC_WriteStrClient(Client,
1221 ERR_NEEDMOREPARAMS_MSG,
1227 IRC_SetPenalty(Client, 1);
1228 if (Req->argc >= 1) {
1229 /* Channel or mask given */
1230 chan = Channel_Search(Req->argv[0]);
1232 /* Members of a channel have been requested */
1233 return IRC_WHO_Channel(Client, chan, only_ops);
1235 if (strcmp(Req->argv[0], "0") != 0) {
1236 /* A mask has been given. But please note this RFC
1237 * stupidity: "0" is same as no arguments ... */
1238 return IRC_WHO_Mask(Client, Req->argv[0], only_ops);
1242 /* No channel or (valid) mask given */
1243 IRC_SetPenalty(Client, 2);
1244 return IRC_WHO_Mask(Client, NULL, only_ops);
1249 * Handler for the IRC "WHOIS" command.
1251 * See RFC 2812, 3.6.2 "Whois query".
1253 * @param Client The client from which this command has been received.
1254 * @param Req Request structure with prefix and all parameters.
1255 * @return CONNECTED or DISCONNECTED.
1258 IRC_WHOIS( CLIENT *Client, REQUEST *Req )
1260 CLIENT *from, *target, *c;
1261 unsigned int match_count = 0, found = 0;
1262 bool has_wildcards, is_remote;
1263 bool got_wildcard = false;
1264 char mask[COMMAND_LEN], *query;
1266 assert( Client != NULL );
1267 assert( Req != NULL );
1269 /* Bad number of parameters? */
1270 if (Req->argc < 1 || Req->argc > 2)
1271 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1272 Client_ID(Client), Req->command);
1274 /* Search sender of the WHOIS */
1275 if (Client_Type(Client) == CLIENT_SERVER) {
1276 from = Client_Search(Req->prefix);
1278 IRC_SetPenalty(Client, 1);
1282 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1283 Client_ID(Client), Req->prefix);
1285 /* Get target server for this command */
1286 if (Req->argc > 1) {
1287 /* Search the target server, which can be specified as a
1288 * nickname on that server as well: */
1289 target = Client_Search(Req->argv[0]);
1291 return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
1292 Client_ID(from), Req->argv[0]);
1294 target = Client_ThisServer();
1295 assert(target != NULL);
1297 /* Forward to other server? */
1298 if (Client_NextHop(target) != Client_ThisServer() &&
1299 Client_Type(Client_NextHop(target)) == CLIENT_SERVER)
1300 return IRC_WriteStrClientPrefix(target, from,
1302 Req->argv[0], Req->argv[1]);
1304 is_remote = Client_Conn(from) < 0;
1305 strlcpy(mask, Req->argv[Req->argc - 1], sizeof(mask));
1306 for (query = strtok(ngt_LowerStr(mask), ",");
1308 query = strtok(NULL, ","), found++)
1310 has_wildcards = query[strcspn(query, "*?")] != 0;
1312 * follows ircd 2.10 implementation:
1313 * - handle up to 3 targets
1314 * - no wildcards for remote clients
1315 * - only one wildcard target per local client
1317 * Also, at most MAX_RPL_WHOIS matches are returned.
1319 if (!has_wildcards || is_remote) {
1320 c = Client_Search(query);
1321 if (c && Client_Type(c) == CLIENT_USER) {
1322 if (!IRC_WHOIS_SendReply(Client, from, c))
1323 return DISCONNECTED;
1325 if (!IRC_WriteStrClient(Client,
1329 return DISCONNECTED;
1334 /* we already handled one wildcard query */
1335 if (!IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1336 Client_ID(Client), query))
1337 return DISCONNECTED;
1340 got_wildcard = true;
1341 IRC_SetPenalty(Client, 3);
1343 for (c = Client_First(); c; c = Client_Next(c)) {
1344 if (IRC_CheckListTooBig(Client, match_count,
1345 MAX_RPL_WHOIS, "WHOIS"))
1348 if (Client_Type(c) != CLIENT_USER)
1350 if (!MatchCaseInsensitive(query, Client_ID(c)))
1352 if (!IRC_WHOIS_SendReply(Client, from, c))
1353 return DISCONNECTED;
1358 if (match_count == 0)
1359 IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1361 Req->argv[Req->argc - 1]);
1363 return IRC_WriteStrClient(from, RPL_ENDOFWHOIS_MSG,
1364 Client_ID(from), Req->argv[Req->argc - 1]);
1369 * IRC "WHOWAS" function.
1370 * This function implements the IRC command "WHOWHAS". It handles local
1371 * requests and request that should be forwarded to other servers.
1374 IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
1376 CLIENT *target, *prefix;
1378 char tok_buf[COMMAND_LEN];
1379 int max, last, count, i, nc;
1382 assert( Client != NULL );
1383 assert( Req != NULL );
1385 /* Do not reveal any info on disconnected users? */
1386 if (Conf_MorePrivacy)
1389 /* Wrong number of parameters? */
1391 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1392 Client_ID(Client), Req->command);
1394 return IRC_WriteStrClient(Client, ERR_NONICKNAMEGIVEN_MSG, Client_ID(Client));
1398 target = Client_Search(Req->argv[2]);
1400 target = Client_ThisServer();
1403 if (Client_Type(Client) == CLIENT_SERVER)
1404 prefix = Client_Search(Req->prefix);
1409 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1410 Client_ID(Client), Req->prefix);
1412 /* Forward to other server? */
1413 if (target != Client_ThisServer()) {
1414 if (!target || (Client_Type(target) != CLIENT_SERVER))
1415 return IRC_WriteStrClient(prefix, ERR_NOSUCHSERVER_MSG,
1416 Client_ID(prefix), Req->argv[2]);
1419 IRC_WriteStrClientPrefix( target, prefix, "WHOWAS %s %s %s",
1420 Req->argv[0], Req->argv[1],
1425 whowas = Client_GetWhowas( );
1426 last = Client_GetLastWhowasIndex( );
1430 max = DEF_RPL_WHOWAS;
1431 if (Req->argc > 1) {
1432 max = atoi(Req->argv[1]);
1434 max = MAX_RPL_WHOWAS;
1438 * Break up the nick argument into a list of nicks, if applicable
1439 * Can't modify Req->argv[0] because we need it for RPL_ENDOFWHOWAS_MSG.
1441 strlcpy(tok_buf, Req->argv[0], sizeof(tok_buf));
1442 nick = strtok(tok_buf, ",");
1444 for (i=last, count=0; nick != NULL ; nick = strtok(NULL, ",")) {
1448 if (whowas[i].time > 0 && strcasecmp(nick, whowas[i].id) == 0) {
1449 if (!WHOWAS_EntryWrite(prefix, &whowas[i]))
1450 return DISCONNECTED;
1454 /* previous entry */
1457 /* "underflow", wrap around */
1461 if (nc && count >= max)
1463 } while (i != last);
1465 if (nc == 0 && !IRC_WriteStrClient(prefix, ERR_WASNOSUCHNICK_MSG,
1466 Client_ID(prefix), nick))
1467 return DISCONNECTED;
1469 return IRC_WriteStrClient(prefix, RPL_ENDOFWHOWAS_MSG, Client_ID(prefix), Req->argv[0]);
1474 * Send LUSERS reply to a client.
1476 * @param Client The receipient of the information.
1477 * @return CONNECTED or DISCONNECTED.
1480 IRC_Send_LUSERS(CLIENT *Client)
1487 assert(Client != NULL);
1489 /* Users, services and serevers in the network */
1490 if (!IRC_WriteStrClient(Client, RPL_LUSERCLIENT_MSG, Client_ID(Client),
1491 Client_UserCount(), Client_ServiceCount(),
1492 Client_ServerCount()))
1493 return DISCONNECTED;
1495 /* Number of IRC operators */
1496 cnt = Client_OperCount( );
1498 if (!IRC_WriteStrClient(Client, RPL_LUSEROP_MSG,
1499 Client_ID(Client), cnt))
1500 return DISCONNECTED;
1503 /* Unknown connections */
1504 cnt = Client_UnknownCount( );
1506 if (!IRC_WriteStrClient(Client, RPL_LUSERUNKNOWN_MSG,
1507 Client_ID(Client), cnt))
1508 return DISCONNECTED;
1511 /* Number of created channels */
1512 if (!IRC_WriteStrClient(Client, RPL_LUSERCHANNELS_MSG,
1514 Channel_CountVisible(Client)))
1515 return DISCONNECTED;
1517 /* Number of local users, services and servers */
1518 if (!IRC_WriteStrClient(Client, RPL_LUSERME_MSG, Client_ID(Client),
1519 Client_MyUserCount(), Client_MyServiceCount(),
1520 Client_MyServerCount()))
1521 return DISCONNECTED;
1524 /* Maximum number of local users */
1525 cnt = Client_MyUserCount();
1526 max = Client_MyMaxUserCount();
1527 if (! IRC_WriteStrClient(Client, RPL_LOCALUSERS_MSG, Client_ID(Client),
1528 cnt, max, cnt, max))
1529 return DISCONNECTED;
1530 /* Maximum number of users in the network */
1531 cnt = Client_UserCount();
1532 max = Client_MaxUserCount();
1533 if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client),
1534 cnt, max, cnt, max))
1535 return DISCONNECTED;
1536 /* Connection counters */
1537 if (! IRC_WriteStrClient(Client, RPL_STATSCONN_MSG, Client_ID(Client),
1538 Conn_CountMax(), Conn_CountAccepted()))
1539 return DISCONNECTED;
1543 } /* IRC_Send_LUSERS */
1547 IRC_Show_MOTD( CLIENT *Client )
1550 size_t len_tot, len_str;
1552 assert( Client != NULL );
1554 len_tot = array_bytes(&Conf_Motd);
1555 if (len_tot == 0 && !Conn_UsesSSL(Client_Conn(Client)))
1556 return IRC_WriteStrClient(Client, ERR_NOMOTD_MSG, Client_ID(Client));
1558 if (!Show_MOTD_Start(Client))
1559 return DISCONNECTED;
1561 line = array_start(&Conf_Motd);
1562 while (len_tot > 0) {
1563 len_str = strlen(line) + 1;
1565 assert(len_tot >= len_str);
1568 if (!Show_MOTD_Sendline(Client, line))
1569 return DISCONNECTED;
1573 if (!Show_MOTD_SSLInfo(Client))
1574 return DISCONNECTED;
1575 return Show_MOTD_End(Client);
1576 } /* IRC_Show_MOTD */
1580 * Send NAMES reply for a specific client and channel.
1582 * @param Client The client requesting the NAMES information.
1583 * @param Chan The channel
1584 * @return CONNECTED or DISCONNECTED.
1587 IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan)
1589 bool is_visible, is_member;
1590 char str[LINE_LEN + 1];
1594 assert(Client != NULL);
1595 assert(Chan != NULL);
1597 if (Channel_IsMemberOf(Chan, Client))
1602 /* Do not print info on channel memberships to anyone that is not member? */
1603 if (Conf_MorePrivacy && !is_member)
1606 /* Secret channel? */
1607 if (!is_member && strchr(Channel_Modes(Chan), 's'))
1610 snprintf(str, sizeof(str), RPL_NAMREPLY_MSG, Client_ID(Client), "=",
1611 Channel_Name(Chan));
1612 cl2chan = Channel_FirstMember(Chan);
1614 cl = Channel_GetClient(cl2chan);
1616 if (strchr(Client_Modes(cl), 'i'))
1621 if (is_member || is_visible) {
1622 if (str[strlen(str) - 1] != ':')
1623 strlcat(str, " ", sizeof(str));
1625 who_flags_qualifier(Client, Channel_UserModes(Chan, cl),
1627 strlcat(str, Client_ID(cl), sizeof(str));
1629 if (strlen(str) > (LINE_LEN - CLIENT_NICK_LEN - 4)) {
1630 if (!IRC_WriteStrClient(Client, "%s", str))
1631 return DISCONNECTED;
1632 snprintf(str, sizeof(str), RPL_NAMREPLY_MSG,
1633 Client_ID(Client), "=",
1634 Channel_Name(Chan));
1638 cl2chan = Channel_NextMember(Chan, cl2chan);
1640 if (str[strlen(str) - 1] != ':') {
1641 if (!IRC_WriteStrClient(Client, "%s", str))
1642 return DISCONNECTED;
1646 } /* IRC_Send_NAMES */
1650 * Send the ISUPPORT numeric (005).
1651 * This numeric indicates the features that are supported by this server.
1652 * See <http://www.irc.org/tech_docs/005.html> for details.
1655 IRC_Send_ISUPPORT(CLIENT * Client)
1657 if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
1659 return DISCONNECTED;
1660 return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
1661 CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
1662 COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
1663 COMMAND_LEN - 113, MAX_HNDL_MODES_ARG,
1664 MAX_HNDL_CHANNEL_LISTS);
1665 } /* IRC_Send_ISUPPORT */