2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2012 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"
49 IRC_ADMIN(CLIENT *Client, REQUEST *Req )
51 CLIENT *target, *prefix;
53 assert( Client != NULL );
54 assert( Req != NULL );
56 if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
59 if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
60 else target = Client_ThisServer( );
63 if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
65 if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
67 /* forwad message to another server? */
68 if( target != Client_ThisServer( ))
70 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
73 IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
77 /* mit Versionsinfo antworten */
78 if( ! IRC_WriteStrClient( Client, RPL_ADMINME_MSG, Client_ID( prefix ), Conf_ServerName )) return DISCONNECTED;
79 if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC1_MSG, Client_ID( prefix ), Conf_ServerAdmin1 )) return DISCONNECTED;
80 if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC2_MSG, Client_ID( prefix ), Conf_ServerAdmin2 )) return DISCONNECTED;
81 if( ! IRC_WriteStrClient( Client, RPL_ADMINEMAIL_MSG, Client_ID( prefix ), Conf_ServerAdminMail )) return DISCONNECTED;
83 IRC_SetPenalty( Client, 1 );
89 * Handler for the IRC command "INFO".
90 * See RFC 2812 section 3.4.10.
93 IRC_INFO(CLIENT * Client, REQUEST * Req)
95 CLIENT *target, *prefix;
98 assert(Client != NULL);
101 /* Wrong number of parameters? */
103 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
104 Client_ID(Client), Req->command);
106 /* Determine prefix */
107 if (Client_Type(Client) == CLIENT_SERVER)
108 prefix = Client_Search(Req->prefix);
112 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
113 Client_ID(Client), Req->prefix);
115 /* Look for a target */
117 target = Client_Search(Req->argv[0]);
119 target = Client_ThisServer();
121 /* Make sure that the target is a server */
122 if (target && Client_Type(target) != CLIENT_SERVER)
123 target = Client_Introducer(target);
126 return IRC_WriteStrClient(prefix, ERR_NOSUCHSERVER_MSG,
127 Client_ID(prefix), Req->argv[0]);
129 /* Pass on to another server? */
130 if (target != Client_ThisServer()) {
131 IRC_WriteStrClientPrefix(target, prefix, "INFO %s",
136 if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix),
140 #if defined(__DATE__) && defined(__TIME__)
141 snprintf(msg, sizeof(msg), "Birth Date: %s at %s", __DATE__, __TIME__);
142 if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
146 strlcpy(msg, "On-line since ", sizeof(msg));
147 strlcat(msg, NGIRCd_StartStr, sizeof(msg));
148 if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
151 if (!IRC_WriteStrClient(Client, RPL_ENDOFINFO_MSG, Client_ID(prefix)))
154 IRC_SetPenalty(Client, 2);
160 * Handler for the IRC "ISON" command.
162 * See RFC 2812, 4.9 "Ison message".
164 * @param Client The client from which this command has been received.
165 * @param Req Request structure with prefix and all parameters.
166 * @return CONNECTED or DISCONNECTED.
169 IRC_ISON( CLIENT *Client, REQUEST *Req )
171 char rpl[COMMAND_LEN];
176 assert(Client != NULL);
179 /* Bad number of arguments? */
181 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
182 Client_ID(Client), Req->command);
184 strlcpy(rpl, RPL_ISON_MSG, sizeof rpl);
185 for (i = 0; i < Req->argc; i++) {
186 /* "All" ircd even parse ":<x> <y> ..." arguments and split
187 * them up; so we do the same ... */
188 ptr = strtok(Req->argv[i], " ");
191 c = Client_Search(ptr);
192 if (c && Client_Type(c) == CLIENT_USER) {
193 strlcat(rpl, Client_ID(c), sizeof(rpl));
194 strlcat(rpl, " ", sizeof(rpl));
196 ptr = strtok(NULL, " ");
199 ngt_TrimLastChr(rpl, ' ');
201 return IRC_WriteStrClient(Client, rpl, Client_ID(Client));
206 * Handler for the IRC "LINKS" command.
208 * See RFC 2812, 3.4.5 "Links message".
210 * @param Client The client from which this command has been received.
211 * @param Req Request structure with prefix and all parameters.
212 * @return CONNECTED or DISCONNECTED.
215 IRC_LINKS(CLIENT *Client, REQUEST *Req)
217 CLIENT *target, *from, *c;
220 assert(Client != NULL);
223 IRC_SetPenalty(Client, 1);
226 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
227 Client_ID(Client), Req->command);
229 /* Get pointer to server mask or "*", if none given */
231 mask = Req->argv[Req->argc - 1];
235 if (Client_Type(Client) == CLIENT_SERVER)
236 from = Client_Search(Req->prefix);
240 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
241 Client_ID(Client), Req->prefix);
244 if (Req->argc == 2) {
245 target = Client_Search(Req->argv[0]);
246 if (! target || Client_Type(target) != CLIENT_SERVER)
247 return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
251 if (target != Client_ThisServer())
252 return IRC_WriteStrClientPrefix(target, from,
253 "LINKS %s %s", Req->argv[0],
259 if (Client_Type(c) == CLIENT_SERVER
260 && MatchCaseInsensitive(mask, Client_ID(c))) {
261 if (!IRC_WriteStrClient(from, RPL_LINKS_MSG,
262 Client_ID(from), Client_ID(c),
263 Client_ID(Client_TopServer(c)
264 ? Client_TopServer(c)
265 : Client_ThisServer()),
266 Client_Hops(c), Client_Info(c)))
271 return IRC_WriteStrClient(from, RPL_ENDOFLINKS_MSG,
272 Client_ID(from), mask);
277 IRC_LUSERS( CLIENT *Client, REQUEST *Req )
279 CLIENT *target, *from;
281 assert( Client != NULL );
282 assert( Req != NULL );
284 if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
286 /* Absender ermitteln */
287 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
289 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
291 /* An anderen Server forwarden? */
294 target = Client_Search( Req->argv[1] );
295 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
296 else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LUSERS %s %s", Req->argv[0], Req->argv[1] );
299 /* Wer ist der Absender? */
300 if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix );
301 else target = Client;
302 if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
304 IRC_Send_LUSERS( target );
306 IRC_SetPenalty( target, 1 );
312 * Handler for the IRC command "SERVLIST".
313 * List registered services, see RFC 2811, section 3.5.1: the syntax is
314 * "SERVLIST [<mask> [<type>]]".
317 IRC_SERVLIST(CLIENT *Client, REQUEST *Req)
321 assert(Client != NULL);
325 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
326 Client_ID(Client), Req->command);
328 if (Req->argc < 2 || strcmp(Req->argv[1], "0") == 0) {
329 for (c = Client_First(); c!= NULL; c = Client_Next(c)) {
330 if (Client_Type(c) != CLIENT_SERVICE)
332 if (Req->argc > 0 && !MatchCaseInsensitive(Req->argv[0],
335 if (!IRC_WriteStrClient(Client, RPL_SERVLIST_MSG,
336 Client_ID(Client), Client_Mask(c),
337 Client_Mask(Client_Introducer(c)), "*",
338 0, Client_Hops(c), Client_Info(c)))
343 return IRC_WriteStrClient(Client, RPL_SERVLISTEND_MSG, Client_ID(Client),
344 Req->argc > 0 ? Req->argv[0] : "*",
345 Req->argc > 1 ? Req->argv[1] : "0");
350 IRC_MOTD( CLIENT *Client, REQUEST *Req )
352 CLIENT *from, *target;
354 assert( Client != NULL );
355 assert( Req != NULL );
357 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
359 /* From aus Prefix ermitteln */
360 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
362 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
367 target = Client_Search( Req->argv[0] );
368 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
370 if( target != Client_ThisServer( ))
372 /* Ok, anderer Server ist das Ziel: forwarden */
373 return IRC_WriteStrClientPrefix( target, from, "MOTD %s", Req->argv[0] );
377 IRC_SetPenalty( from, 3 );
378 return IRC_Show_MOTD( from );
383 IRC_NAMES( CLIENT *Client, REQUEST *Req )
385 char rpl[COMMAND_LEN], *ptr;
386 CLIENT *target, *from, *c;
389 assert( Client != NULL );
390 assert( Req != NULL );
392 if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
394 /* use prefix to determine "From" */
395 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
397 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
401 /* forward to another server? */
402 target = Client_Search( Req->argv[1] );
403 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
405 if( target != Client_ThisServer( )) {
406 /* target is another server, forward */
407 return IRC_WriteStrClientPrefix( target, from, "NAMES %s :%s", Req->argv[0], Req->argv[1] );
413 /* bestimmte Channels durchgehen */
414 ptr = strtok( Req->argv[0], "," );
417 chan = Channel_Search( ptr );
421 if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
423 if( ! IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), ptr )) return DISCONNECTED;
425 /* get next channel name */
426 ptr = strtok( NULL, "," );
431 chan = Channel_First( );
434 if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
436 chan = Channel_Next( chan );
439 /* Now print all clients which are not in any channel */
441 snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
444 if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' )))
446 /* its a user, concatenate ... */
447 if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl ));
448 strlcat( rpl, Client_ID( c ), sizeof( rpl ));
450 if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
452 /* Line is gwoing too long, send now */
453 if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
454 snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
458 c = Client_Next( c );
460 if( rpl[strlen( rpl ) - 1] != ':')
462 if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
465 IRC_SetPenalty( from, 1 );
466 return IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), "*" );
471 t_diff(time_t *t, const time_t d)
479 return (unsigned int)diff;
484 uptime_days(time_t *now)
486 return t_diff(now, 60 * 60 * 24);
491 uptime_hrs(time_t *now)
493 return t_diff(now, 60 * 60);
498 uptime_mins(time_t *now)
500 return t_diff(now, 60);
505 * Handler for the IRC command "STATS".
506 * See RFC 2812 section 3.4.4.
509 IRC_STATS( CLIENT *Client, REQUEST *Req )
511 CLIENT *from, *target, *cl;
516 unsigned int days, hrs, mins;
517 struct list_head *list;
518 struct list_elem *list_item;
520 assert(Client != NULL);
524 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
525 Client_ID(Client), Req->command);
527 /* use prefix to determine "From" */
528 if (Client_Type(Client) == CLIENT_SERVER)
529 from = Client_Search(Req->prefix);
534 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
535 Client_ID(Client), Req->prefix);
537 if (Req->argc == 2) {
538 /* forward to another server? */
539 target = Client_Search(Req->argv[1]);
540 if ((!target) || (Client_Type(target) != CLIENT_SERVER))
541 return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
542 Client_ID(from), Req->argv[1]);
544 if (target != Client_ThisServer()) {
545 /* forward to another server */
546 return IRC_WriteStrClientPrefix(target, from,
547 "STATS %s %s", Req->argv[0], Req->argv[1]);
552 query = Req->argv[0][0] ? Req->argv[0][0] : '*';
557 case 'g': /* Network-wide bans ("G-Lines") */
559 case 'k': /* Server-local bans ("K-Lines") */
561 if (!Client_HasMode(from, 'o'))
562 return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
564 if (query == 'g' || query == 'G')
565 list = Class_GetList(CLASS_GLINE);
567 list = Class_GetList(CLASS_KLINE);
568 list_item = Lists_GetFirst(list);
570 if (!IRC_WriteStrClient(from, RPL_STATSXLINE_MSG,
571 Client_ID(from), query,
572 Lists_GetMask(list_item),
573 Lists_GetValidity(list_item),
574 Lists_GetReason(list_item)))
576 list_item = Lists_GetNext(list_item);
579 case 'l': /* Link status (servers and own link) */
581 time_now = time(NULL);
582 for (con = Conn_First(); con != NONE; con = Conn_Next(con)) {
583 cl = Conn_GetClient(con);
586 if ((Client_Type(cl) == CLIENT_SERVER)
588 /* Server link or our own connection */
590 if (Conn_Options(con) & CONN_ZIP) {
591 if (!IRC_WriteStrClient
592 (from, RPL_STATSLINKINFOZIP_MSG,
593 Client_ID(from), Client_Mask(cl),
594 Conn_SendQ(con), Conn_SendMsg(con),
600 (long)(time_now - Conn_StartTime(con))))
605 if (!IRC_WriteStrClient
606 (from, RPL_STATSLINKINFO_MSG,
607 Client_ID(from), Client_Mask(cl),
608 Conn_SendQ(con), Conn_SendMsg(con),
609 Conn_SendBytes(con), Conn_RecvMsg(con),
611 (long)(time_now - Conn_StartTime(con))))
616 case 'm': /* IRC command status (usage count) */
618 cmd = Parse_GetCommandStruct();
619 for (; cmd->name; cmd++) {
620 if (cmd->lcount == 0 && cmd->rcount == 0)
622 if (!IRC_WriteStrClient
623 (from, RPL_STATSCOMMANDS_MSG, Client_ID(from),
624 cmd->name, cmd->lcount, cmd->bytes, cmd->rcount))
628 case 'u': /* Server uptime */
630 time_now = time(NULL) - NGIRCd_Start;
631 days = uptime_days(&time_now);
632 hrs = uptime_hrs(&time_now);
633 mins = uptime_mins(&time_now);
634 if (!IRC_WriteStrClient(from, RPL_STATSUPTIME, Client_ID(from),
635 days, hrs, mins, (unsigned int)time_now))
640 IRC_SetPenalty(from, 2);
641 return IRC_WriteStrClient(from, RPL_ENDOFSTATS_MSG,
642 Client_ID(from), query);
647 * Handler for the IRC command "SUMMON".
648 * See RFC 2812 section 4.5. ngIRCd doesn't implement this functionality and
649 * therefore answers with ERR_SUMMONDISABLED.
652 IRC_SUMMON(CLIENT * Client, UNUSED REQUEST * Req)
654 return IRC_WriteStrClient(Client, ERR_SUMMONDISABLED_MSG,
660 IRC_TIME( CLIENT *Client, REQUEST *Req )
662 CLIENT *from, *target;
666 assert( Client != NULL );
667 assert( Req != NULL );
669 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
671 if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
673 if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
677 target = Client_Search( Req->argv[0] );
678 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
680 if( target != Client_ThisServer( ))
682 return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] );
687 (void)strftime( t_str, 60, "%A %B %d %Y -- %H:%M %Z", localtime( &t ));
688 return IRC_WriteStrClient( from, RPL_TIME_MSG, Client_ID( from ), Client_ID( Client_ThisServer( )), t_str );
693 * Handler for the IRC command "USERHOST".
694 * See RFC 2812 section 4.8.
697 IRC_USERHOST(CLIENT *Client, REQUEST *Req)
699 char rpl[COMMAND_LEN];
703 assert(Client != NULL);
707 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
708 Client_ID(Client), Req->command);
715 strlcpy(rpl, RPL_USERHOST_MSG, sizeof rpl);
716 for (i = 0; i < max; i++) {
717 c = Client_Search(Req->argv[i]);
718 if (c && (Client_Type(c) == CLIENT_USER)) {
719 /* This Nick is "online" */
720 strlcat(rpl, Client_ID(c), sizeof(rpl));
721 if (Client_HasMode(c, 'o'))
722 strlcat(rpl, "*", sizeof(rpl));
723 strlcat(rpl, "=", sizeof(rpl));
724 if (Client_HasMode(c, 'a'))
725 strlcat(rpl, "-", sizeof(rpl));
727 strlcat(rpl, "+", sizeof(rpl));
728 strlcat(rpl, Client_User(c), sizeof(rpl));
729 strlcat(rpl, "@", sizeof(rpl));
730 strlcat(rpl, Client_HostnameDisplayed(c), sizeof(rpl));
731 strlcat(rpl, " ", sizeof(rpl));
734 ngt_TrimLastChr(rpl, ' ');
736 return IRC_WriteStrClient(Client, rpl, Client_ID(Client));
741 * Handler for the IRC command "USERS".
742 * See RFC 2812 section 4.6. As suggested there the command is disabled.
745 IRC_USERS(CLIENT * Client, UNUSED REQUEST * Req)
747 return IRC_WriteStrClient(Client, ERR_USERSDISABLED_MSG,
753 IRC_VERSION( CLIENT *Client, REQUEST *Req )
755 CLIENT *target, *prefix;
757 assert( Client != NULL );
758 assert( Req != NULL );
760 if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
763 if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
764 else target = Client_ThisServer( );
766 /* Prefix ermitteln */
767 if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
768 else prefix = Client;
769 if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
771 /* An anderen Server weiterleiten? */
772 if( target != Client_ThisServer( ))
774 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
777 IRC_WriteStrClientPrefix( target, prefix, "VERSION %s", Req->argv[0] );
781 /* send version information */
782 IRC_SetPenalty(Client, 1);
783 return IRC_WriteStrClient(Client, RPL_VERSION_MSG, Client_ID(prefix),
784 PACKAGE_NAME, PACKAGE_VERSION,
785 NGIRCd_DebugLevel, Conf_ServerName,
786 NGIRCd_VersionAddition);
791 write_whoreply(CLIENT *Client, CLIENT *c, const char *channelname, const char *flags)
793 return IRC_WriteStrClient(Client, RPL_WHOREPLY_MSG, Client_ID(Client),
794 channelname, Client_User(c),
795 Client_HostnameDisplayed(c),
796 Client_ID(Client_Introducer(c)), Client_ID(c),
797 flags, Client_Hops(c), Client_Info(c));
802 who_flags_status(const char *client_modes)
804 if (strchr(client_modes, 'a'))
805 return "G"; /* away */
811 * Return channel user mode prefix(es).
813 * @param Client The client requesting the mode prefixes.
814 * @param chan_user_modes String with channel user modes.
815 * @param str String buffer to which the prefix(es) will be appended.
816 * @param len Size of "str" buffer.
817 * @return Pointer to "str".
820 who_flags_qualifier(CLIENT *Client, const char *chan_user_modes,
821 char *str, size_t len)
823 assert(Client != NULL);
825 if (Client_Cap(Client) & CLIENT_CAP_MULTI_PREFIX) {
826 if (strchr(chan_user_modes, 'q'))
827 strlcat(str, "~", len);
828 if (strchr(chan_user_modes, 'a'))
829 strlcat(str, "&", len);
830 if (strchr(chan_user_modes, 'o'))
831 strlcat(str, "@", len);
832 if (strchr(chan_user_modes, 'h'))
833 strlcat(str, "%", len);
834 if (strchr(chan_user_modes, 'v'))
835 strlcat(str, "+", len);
840 if (strchr(chan_user_modes, 'q'))
841 strlcat(str, "~", len);
842 else if (strchr(chan_user_modes, 'a'))
843 strlcat(str, "&", len);
844 else if (strchr(chan_user_modes, 'o'))
845 strlcat(str, "@", len);
846 else if (strchr(chan_user_modes, 'h'))
847 strlcat(str, "%", len);
848 else if (strchr(chan_user_modes, 'v'))
849 strlcat(str, "+", len);
856 * Send WHO reply for a "channel target" ("WHO #channel").
858 * @param Client Client requesting the information.
859 * @param Chan Channel being requested.
860 * @param OnlyOps Only display IRC operators.
861 * @return CONNECTED or DISCONNECTED.
864 IRC_WHO_Channel(CLIENT *Client, CHANNEL *Chan, bool OnlyOps)
866 bool is_visible, is_member, is_ircop;
868 const char *client_modes;
873 assert( Client != NULL );
874 assert( Chan != NULL );
876 IRC_SetPenalty(Client, 1);
878 is_member = Channel_IsMemberOf(Chan, Client);
880 /* Secret channel? */
881 if (!is_member && strchr(Channel_Modes(Chan), 's'))
882 return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG,
883 Client_ID(Client), Channel_Name(Chan));
885 cl2chan = Channel_FirstMember(Chan);
886 for (; cl2chan ; cl2chan = Channel_NextMember(Chan, cl2chan)) {
887 c = Channel_GetClient(cl2chan);
889 client_modes = Client_Modes(c);
890 is_ircop = strchr(client_modes, 'o') != NULL;
891 if (OnlyOps && !is_ircop)
894 is_visible = strchr(client_modes, 'i') == NULL;
895 if (is_member || is_visible) {
896 strlcpy(flags, who_flags_status(client_modes),
899 strlcat(flags, "*", sizeof(flags));
901 who_flags_qualifier(Client, Channel_UserModes(Chan, c),
902 flags, sizeof(flags));
904 if (!write_whoreply(Client, c, Channel_Name(Chan),
911 /* If there are a lot of clients, augment penalty a bit */
912 if (count > MAX_RPL_WHO)
913 IRC_SetPenalty(Client, 1);
915 return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client),
921 * Send WHO reply for a "mask target" ("WHO m*sk").
923 * @param Client Client requesting the information.
924 * @param Mask Mask being requested or NULL for "all" clients.
925 * @param OnlyOps Only display IRC operators.
926 * @return CONNECTED or DISCONNECTED.
929 IRC_WHO_Mask(CLIENT *Client, char *Mask, bool OnlyOps)
934 bool client_match, is_visible;
938 assert (Client != NULL);
943 IRC_SetPenalty(Client, 3);
944 for (c = Client_First(); c != NULL; c = Client_Next(c)) {
945 if (Client_Type(c) != CLIENT_USER)
948 if (OnlyOps && !Client_HasMode(c, 'o'))
952 /* Match pattern against user host/server/name/nick */
953 client_match = MatchCaseInsensitive(Mask,
956 client_match = MatchCaseInsensitive(Mask,
957 Client_ID(Client_Introducer(c)));
959 client_match = MatchCaseInsensitive(Mask,
962 client_match = MatchCaseInsensitive(Mask,
965 continue; /* no match: skip this client */
968 is_visible = !Client_HasMode(c, 'i');
970 /* Target client is invisible, but mask matches exactly? */
971 if (!is_visible && Mask && strcasecmp(Client_ID(c), Mask) == 0)
974 /* Target still invisible, but are both on the same channel? */
976 cl2chan = Channel_FirstChannelOf(Client);
977 while (cl2chan && !is_visible) {
978 chan = Channel_GetChannel(cl2chan);
979 if (Channel_IsMemberOf(chan, c))
981 cl2chan = Channel_NextChannelOf(Client, cl2chan);
985 if (!is_visible) /* target user is not visible */
988 if (IRC_CheckListTooBig(Client, count, MAX_RPL_WHO, "WHO"))
991 strlcpy(flags, who_flags_status(Client_Modes(c)), sizeof(flags));
992 if (strchr(Client_Modes(c), 'o'))
993 strlcat(flags, "*", sizeof(flags));
995 if (!write_whoreply(Client, c, "*", flags))
1000 return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client),
1006 * Handler for the IRC "WHO" command.
1008 * See RFC 2812, 3.6.1 "Who query".
1010 * @param Client The client from which this command has been received.
1011 * @param Req Request structure with prefix and all parameters.
1012 * @return CONNECTED or DISCONNECTED.
1015 IRC_WHO(CLIENT *Client, REQUEST *Req)
1020 assert (Client != NULL);
1021 assert (Req != NULL);
1024 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1025 Client_ID(Client), Req->command);
1029 if (Req->argc == 2) {
1030 if (strcmp(Req->argv[1], "o") == 0)
1034 return IRC_WriteStrClient(Client,
1035 ERR_NEEDMOREPARAMS_MSG,
1041 IRC_SetPenalty(Client, 1);
1042 if (Req->argc >= 1) {
1043 /* Channel or mask given */
1044 chan = Channel_Search(Req->argv[0]);
1046 /* Members of a channel have been requested */
1047 return IRC_WHO_Channel(Client, chan, only_ops);
1049 if (strcmp(Req->argv[0], "0") != 0) {
1050 /* A mask has been given. But please note this RFC
1051 * stupidity: "0" is same as no arguments ... */
1052 return IRC_WHO_Mask(Client, Req->argv[0], only_ops);
1056 /* No channel or (valid) mask given */
1057 IRC_SetPenalty(Client, 2);
1058 return IRC_WHO_Mask(Client, NULL, only_ops);
1063 * Generate WHOIS reply of one actual client.
1065 * @param Client The client from which this command has been received.
1066 * @param from The client requesting the information ("originator").
1067 * @param c The client of which information should be returned.
1068 * @return CONNECTED or DISCONNECTED.
1071 IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c)
1073 char str[LINE_LEN + 1];
1077 assert(Client != NULL);
1078 assert(from != NULL);
1081 /* Nick, user, hostname and client info */
1082 if (!IRC_WriteStrClient(from, RPL_WHOISUSER_MSG, Client_ID(from),
1083 Client_ID(c), Client_User(c),
1084 Client_HostnameDisplayed(c), Client_Info(c)))
1085 return DISCONNECTED;
1088 if (!IRC_WriteStrClient(from, RPL_WHOISSERVER_MSG, Client_ID(from),
1089 Client_ID(c), Client_ID(Client_Introducer(c)),
1090 Client_Info(Client_Introducer(c))))
1091 return DISCONNECTED;
1094 snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
1095 Client_ID(from), Client_ID(c));
1096 cl2chan = Channel_FirstChannelOf(c);
1098 chan = Channel_GetChannel(cl2chan);
1099 assert(chan != NULL);
1102 cl2chan = Channel_NextChannelOf(c, cl2chan);
1104 /* Secret channel? */
1105 if (strchr(Channel_Modes(chan), 's')
1106 && !Channel_IsMemberOf(chan, Client))
1109 /* Local channel and request is not from a user? */
1110 if (Client_Type(Client) == CLIENT_SERVER
1111 && Channel_IsLocal(chan))
1114 /* Concatenate channel names */
1115 if (str[strlen(str) - 1] != ':')
1116 strlcat(str, " ", sizeof(str));
1118 who_flags_qualifier(Client, Channel_UserModes(chan, c),
1120 strlcat(str, Channel_Name(chan), sizeof(str));
1122 if (strlen(str) > (LINE_LEN - CHANNEL_NAME_LEN - 4)) {
1123 /* Line becomes too long: send it! */
1124 if (!IRC_WriteStrClient(Client, "%s", str))
1125 return DISCONNECTED;
1126 snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
1127 Client_ID(from), Client_ID(c));
1130 if(str[strlen(str) - 1] != ':') {
1131 /* There is data left to send: */
1132 if (!IRC_WriteStrClient(Client, "%s", str))
1133 return DISCONNECTED;
1137 if (Client_HasMode(c, 'o') &&
1138 !IRC_WriteStrClient(from, RPL_WHOISOPERATOR_MSG,
1139 Client_ID(from), Client_ID(c)))
1140 return DISCONNECTED;
1143 if (Client_HasMode(c, 'B') &&
1144 !IRC_WriteStrClient(from, RPL_WHOISBOT_MSG,
1145 Client_ID(from), Client_ID(c)))
1146 return DISCONNECTED;
1148 /* Connected using SSL? */
1149 if (Conn_UsesSSL(Client_Conn(c)) &&
1150 !IRC_WriteStrClient(from, RPL_WHOISSSL_MSG, Client_ID(from),
1152 return DISCONNECTED;
1154 /* Registered nickname? */
1155 if (Client_HasMode(c, 'R') &&
1156 !IRC_WriteStrClient(from, RPL_WHOISREGNICK_MSG,
1157 Client_ID(from), Client_ID(c)))
1158 return DISCONNECTED;
1160 /* Local client and requester is the user itself or an IRC Op? */
1161 if (Client_Conn(c) > NONE &&
1162 (from == c || (!Conf_MorePrivacy && Client_HasMode(from, 'o')))) {
1163 /* Client hostname */
1164 if (!IRC_WriteStrClient(from, RPL_WHOISHOST_MSG,
1165 Client_ID(from), Client_ID(c), Client_Hostname(c),
1166 Conn_GetIPAInfo(Client_Conn(c))))
1167 return DISCONNECTED;
1169 if (!IRC_WriteStrClient(from, RPL_WHOISMODES_MSG,
1170 Client_ID(from), Client_ID(c), Client_Modes(c)))
1171 return DISCONNECTED;
1174 /* Idle and signon time (local clients only!) */
1175 if (!Conf_MorePrivacy && Client_Conn(c) > NONE &&
1176 !IRC_WriteStrClient(from, RPL_WHOISIDLE_MSG,
1177 Client_ID(from), Client_ID(c),
1178 (unsigned long)Conn_GetIdle(Client_Conn(c)),
1179 (unsigned long)Conn_GetSignon(Client_Conn(c))))
1180 return DISCONNECTED;
1183 if (Client_HasMode(c, 'a') &&
1184 !IRC_WriteStrClient(from, RPL_AWAY_MSG,
1185 Client_ID(from), Client_ID(c), Client_Away(c)))
1186 return DISCONNECTED;
1189 } /* IRC_WHOIS_SendReply */
1193 * Handler for the IRC "WHOIS" command.
1195 * See RFC 2812, 3.6.2 "Whois query".
1197 * @param Client The client from which this command has been received.
1198 * @param Req Request structure with prefix and all parameters.
1199 * @return CONNECTED or DISCONNECTED.
1202 IRC_WHOIS( CLIENT *Client, REQUEST *Req )
1204 CLIENT *from, *target, *c;
1205 unsigned int match_count = 0, found = 0;
1206 bool has_wildcards, is_remote;
1207 bool got_wildcard = false;
1208 char mask[COMMAND_LEN], *query;
1210 assert( Client != NULL );
1211 assert( Req != NULL );
1213 /* Bad number of parameters? */
1214 if (Req->argc < 1 || Req->argc > 2)
1215 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1216 Client_ID(Client), Req->command);
1218 /* Search sender of the WHOIS */
1219 if (Client_Type(Client) == CLIENT_SERVER) {
1220 from = Client_Search(Req->prefix);
1222 IRC_SetPenalty(Client, 1);
1226 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1227 Client_ID(Client), Req->prefix);
1229 /* Get target server for this command */
1230 if (Req->argc > 1) {
1231 /* Search the target server, which can be specified as a
1232 * nickname on that server as well: */
1233 target = Client_Search(Req->argv[0]);
1235 return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
1236 Client_ID(from), Req->argv[0]);
1238 target = Client_ThisServer();
1239 assert(target != NULL);
1241 /* Forward to other server? */
1242 if (Client_NextHop(target) != Client_ThisServer() &&
1243 Client_Type(Client_NextHop(target)) == CLIENT_SERVER)
1244 return IRC_WriteStrClientPrefix(target, from,
1246 Req->argv[0], Req->argv[1]);
1248 is_remote = Client_Conn(from) < 0;
1249 strlcpy(mask, Req->argv[Req->argc - 1], sizeof(mask));
1250 for (query = strtok(ngt_LowerStr(mask), ",");
1252 query = strtok(NULL, ","), found++)
1254 has_wildcards = query[strcspn(query, "*?")] != 0;
1256 * follows ircd 2.10 implementation:
1257 * - handle up to 3 targets
1258 * - no wildcards for remote clients
1259 * - only one wildcard target per local client
1261 * Also, at most MAX_RPL_WHOIS matches are returned.
1263 if (!has_wildcards || is_remote) {
1264 c = Client_Search(query);
1265 if (c && Client_Type(c) == CLIENT_USER) {
1266 if (!IRC_WHOIS_SendReply(Client, from, c))
1267 return DISCONNECTED;
1269 if (!IRC_WriteStrClient(Client,
1273 return DISCONNECTED;
1278 /* we already handled one wildcard query */
1279 if (!IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1280 Client_ID(Client), query))
1281 return DISCONNECTED;
1284 got_wildcard = true;
1285 IRC_SetPenalty(Client, 3);
1287 for (c = Client_First(); c; c = Client_Next(c)) {
1288 if (IRC_CheckListTooBig(Client, match_count,
1289 MAX_RPL_WHOIS, "WHOIS"))
1292 if (Client_Type(c) != CLIENT_USER)
1294 if (!MatchCaseInsensitive(query, Client_ID(c)))
1296 if (!IRC_WHOIS_SendReply(Client, from, c))
1297 return DISCONNECTED;
1302 if (match_count == 0)
1303 IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1305 Req->argv[Req->argc - 1]);
1307 return IRC_WriteStrClient(from, RPL_ENDOFWHOIS_MSG,
1308 Client_ID(from), Req->argv[Req->argc - 1]);
1313 WHOWAS_EntryWrite(CLIENT *prefix, WHOWAS *entry)
1317 (void)strftime(t_str, sizeof(t_str), "%a %b %d %H:%M:%S %Y",
1318 localtime(&entry->time));
1320 if (!IRC_WriteStrClient(prefix, RPL_WHOWASUSER_MSG, Client_ID(prefix),
1321 entry->id, entry->user, entry->host, entry->info))
1322 return DISCONNECTED;
1324 return IRC_WriteStrClient(prefix, RPL_WHOISSERVER_MSG, Client_ID(prefix),
1325 entry->id, entry->server, t_str);
1329 * IRC "WHOWAS" function.
1330 * This function implements the IRC command "WHOWHAS". It handles local
1331 * requests and request that should be forwarded to other servers.
1334 IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
1336 CLIENT *target, *prefix;
1338 char tok_buf[COMMAND_LEN];
1339 int max, last, count, i, nc;
1342 assert( Client != NULL );
1343 assert( Req != NULL );
1345 /* Do not reveal any info on disconnected users? */
1346 if (Conf_MorePrivacy)
1349 /* Wrong number of parameters? */
1351 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
1352 Client_ID(Client), Req->command);
1354 return IRC_WriteStrClient(Client, ERR_NONICKNAMEGIVEN_MSG, Client_ID(Client));
1358 target = Client_Search(Req->argv[2]);
1360 target = Client_ThisServer();
1363 if (Client_Type(Client) == CLIENT_SERVER)
1364 prefix = Client_Search(Req->prefix);
1369 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
1370 Client_ID(Client), Req->prefix);
1372 /* Forward to other server? */
1373 if (target != Client_ThisServer()) {
1374 if (!target || (Client_Type(target) != CLIENT_SERVER))
1375 return IRC_WriteStrClient(prefix, ERR_NOSUCHSERVER_MSG,
1376 Client_ID(prefix), Req->argv[2]);
1379 IRC_WriteStrClientPrefix( target, prefix, "WHOWAS %s %s %s",
1380 Req->argv[0], Req->argv[1],
1385 whowas = Client_GetWhowas( );
1386 last = Client_GetLastWhowasIndex( );
1390 max = DEF_RPL_WHOWAS;
1391 if (Req->argc > 1) {
1392 max = atoi(Req->argv[1]);
1394 max = MAX_RPL_WHOWAS;
1398 * Break up the nick argument into a list of nicks, if applicable
1399 * Can't modify Req->argv[0] because we need it for RPL_ENDOFWHOWAS_MSG.
1401 strlcpy(tok_buf, Req->argv[0], sizeof(tok_buf));
1402 nick = strtok(tok_buf, ",");
1404 for (i=last, count=0; nick != NULL ; nick = strtok(NULL, ",")) {
1408 if (whowas[i].time > 0 && strcasecmp(nick, whowas[i].id) == 0) {
1409 if (!WHOWAS_EntryWrite(prefix, &whowas[i]))
1410 return DISCONNECTED;
1414 /* previous entry */
1417 /* "underflow", wrap around */
1421 if (nc && count >= max)
1423 } while (i != last);
1425 if (nc == 0 && !IRC_WriteStrClient(prefix, ERR_WASNOSUCHNICK_MSG,
1426 Client_ID(prefix), nick))
1427 return DISCONNECTED;
1429 return IRC_WriteStrClient(prefix, RPL_ENDOFWHOWAS_MSG, Client_ID(prefix), Req->argv[0]);
1434 * Send LUSERS reply to a client.
1436 * @param Client The receipient of the information.
1437 * @return CONNECTED or DISCONNECTED.
1440 IRC_Send_LUSERS(CLIENT *Client)
1447 assert(Client != NULL);
1449 /* Users, services and serevers in the network */
1450 if (!IRC_WriteStrClient(Client, RPL_LUSERCLIENT_MSG, Client_ID(Client),
1451 Client_UserCount(), Client_ServiceCount(),
1452 Client_ServerCount()))
1453 return DISCONNECTED;
1455 /* Number of IRC operators */
1456 cnt = Client_OperCount( );
1458 if (!IRC_WriteStrClient(Client, RPL_LUSEROP_MSG,
1459 Client_ID(Client), cnt))
1460 return DISCONNECTED;
1463 /* Unknown connections */
1464 cnt = Client_UnknownCount( );
1466 if (!IRC_WriteStrClient(Client, RPL_LUSERUNKNOWN_MSG,
1467 Client_ID(Client), cnt))
1468 return DISCONNECTED;
1471 /* Number of created channels */
1472 if (!IRC_WriteStrClient(Client, RPL_LUSERCHANNELS_MSG,
1474 Channel_CountVisible(Client)))
1475 return DISCONNECTED;
1477 /* Number of local users, services and servers */
1478 if (!IRC_WriteStrClient(Client, RPL_LUSERME_MSG, Client_ID(Client),
1479 Client_MyUserCount(), Client_MyServiceCount(),
1480 Client_MyServerCount()))
1481 return DISCONNECTED;
1484 /* Maximum number of local users */
1485 cnt = Client_MyUserCount();
1486 max = Client_MyMaxUserCount();
1487 if (! IRC_WriteStrClient(Client, RPL_LOCALUSERS_MSG, Client_ID(Client),
1488 cnt, max, cnt, max))
1489 return DISCONNECTED;
1490 /* Maximum number of users in the network */
1491 cnt = Client_UserCount();
1492 max = Client_MaxUserCount();
1493 if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client),
1494 cnt, max, cnt, max))
1495 return DISCONNECTED;
1496 /* Connection counters */
1497 if (! IRC_WriteStrClient(Client, RPL_STATSCONN_MSG, Client_ID(Client),
1498 Conn_CountMax(), Conn_CountAccepted()))
1499 return DISCONNECTED;
1503 } /* IRC_Send_LUSERS */
1507 Show_MOTD_Start(CLIENT *Client)
1509 return IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG,
1510 Client_ID( Client ), Client_ID( Client_ThisServer( )));
1514 Show_MOTD_Sendline(CLIENT *Client, const char *msg)
1516 return IRC_WriteStrClient(Client, RPL_MOTD_MSG, Client_ID( Client ), msg);
1520 Show_MOTD_End(CLIENT *Client)
1522 if (!IRC_WriteStrClient(Client, RPL_ENDOFMOTD_MSG, Client_ID(Client)))
1523 return DISCONNECTED;
1525 if (*Conf_CloakHost)
1526 return IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG,
1528 Client_Hostname(Client));
1534 static bool Show_MOTD_SSLInfo(CLIENT *Client)
1537 char buf[COMMAND_LEN] = "Connected using Cipher ";
1539 if (!Conn_GetCipherInfo(Client_Conn(Client), buf + 23, sizeof buf - 23))
1542 if (!Show_MOTD_Sendline(Client, buf))
1549 Show_MOTD_SSLInfo(UNUSED CLIENT *c)
1554 IRC_Show_MOTD( CLIENT *Client )
1557 size_t len_tot, len_str;
1559 assert( Client != NULL );
1561 len_tot = array_bytes(&Conf_Motd);
1562 if (len_tot == 0 && !Conn_UsesSSL(Client_Conn(Client)))
1563 return IRC_WriteStrClient(Client, ERR_NOMOTD_MSG, Client_ID(Client));
1565 if (!Show_MOTD_Start(Client))
1566 return DISCONNECTED;
1568 line = array_start(&Conf_Motd);
1569 while (len_tot > 0) {
1570 len_str = strlen(line) + 1;
1572 assert(len_tot >= len_str);
1575 if (!Show_MOTD_Sendline(Client, line))
1576 return DISCONNECTED;
1580 if (!Show_MOTD_SSLInfo(Client))
1581 return DISCONNECTED;
1582 return Show_MOTD_End(Client);
1583 } /* IRC_Show_MOTD */
1587 * Send NAMES reply for a specific client and channel.
1589 * @param Client The client requesting the NAMES information.
1590 * @param Chan The channel
1591 * @return CONNECTED or DISCONNECTED.
1594 IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan)
1596 bool is_visible, is_member;
1597 char str[LINE_LEN + 1];
1601 assert(Client != NULL);
1602 assert(Chan != NULL);
1604 if (Channel_IsMemberOf(Chan, Client))
1609 /* Do not print info on channel memberships to anyone that is not member? */
1610 if (Conf_MorePrivacy && !is_member)
1613 /* Secret channel? */
1614 if (!is_member && strchr(Channel_Modes(Chan), 's'))
1617 snprintf(str, sizeof(str), RPL_NAMREPLY_MSG, Client_ID(Client), "=",
1618 Channel_Name(Chan));
1619 cl2chan = Channel_FirstMember(Chan);
1621 cl = Channel_GetClient(cl2chan);
1623 if (strchr(Client_Modes(cl), 'i'))
1628 if (is_member || is_visible) {
1629 if (str[strlen(str) - 1] != ':')
1630 strlcat(str, " ", sizeof(str));
1632 who_flags_qualifier(Client, Channel_UserModes(Chan, cl),
1634 strlcat(str, Client_ID(cl), sizeof(str));
1636 if (strlen(str) > (LINE_LEN - CLIENT_NICK_LEN - 4)) {
1637 if (!IRC_WriteStrClient(Client, "%s", str))
1638 return DISCONNECTED;
1639 snprintf(str, sizeof(str), RPL_NAMREPLY_MSG,
1640 Client_ID(Client), "=",
1641 Channel_Name(Chan));
1645 cl2chan = Channel_NextMember(Chan, cl2chan);
1647 if (str[strlen(str) - 1] != ':') {
1648 if (!IRC_WriteStrClient(Client, "%s", str))
1649 return DISCONNECTED;
1653 } /* IRC_Send_NAMES */
1657 * Send the ISUPPORT numeric (005).
1658 * This numeric indicates the features that are supported by this server.
1659 * See <http://www.irc.org/tech_docs/005.html> for details.
1662 IRC_Send_ISUPPORT(CLIENT * Client)
1664 if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
1666 return DISCONNECTED;
1667 return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
1668 CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
1669 COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
1670 COMMAND_LEN - 113, MAX_HNDL_MODES_ARG,
1671 MAX_HNDL_CHANNEL_LISTS);
1672 } /* IRC_Send_ISUPPORT */