1 Add welcome message functionality.
6 shows welcome messages set, same is shown on connect
9 /WELCOME [<target>] [[!]<name> :<message>]
10 to view welcome messages from a remote server
11 to set a local welcome message on this server or a remote server
12 set a global welcome message (target *)
13 the ! prefix makes the server annouce the welcome message to its clients when setting
16 :<source> WE <target> [[!]<name> <timestamp> <who> :<text>]
17 who is who set the message, the server puts in the opername when a client sets it.
18 :<name> is a number 1 to WELCOME_MAX_ENTRIES - currently set at 10 (should be more than we ever need)
19 that means there is room for 10 local and 10 global entries
21 STATS W/welcome (/STATS w/userload made case sensitive)
22 :server 230 nick W Name Target Who Timestamp :Message
23 :server 227 nick W 1 * opername 1233072583 :Latest news: testing this welcome patch :)
24 :server 227 nick W 2 * opername 1233072583 :
25 :server 227 nick W 1 servername opername 1233072590 :This is a test server, expect restarts.
26 :server 219 nick W :End of /STATS report
28 listing welcomes or on connect:
29 :server NOTICE nick :[QuakeNet] Latest news: testing this welcome patch :)
30 :server NOTICE nick :[server] This is a test server, expect restarts.
32 announcement is done by a notice by the local server to $* with the same message
33 format as for listing welcome messages.
34 :server NOTICE $* :[QuakeNet] Latest news: testing this welcome patch :)
35 :server NOTICE $* :[server] This is a test server, expect restarts.
41 add m_welcome mo_welcome ms_welcome mh_welcome functions
45 add features FEAT_WELCOME and FEAT_HIS_STATS_W
48 add MSG_WELCOME TOK_WELCOME CMD_WELCOME
51 add welcome message functions
55 add RPL_STATSWELCOME ERR_NOSUCHWELCOME
63 add welcome.c and m_welcome.c files
66 add burst welcome message
72 add showing of welcome messages on connect
78 add PRIV_LOCAL_WELCOME PRIV_WELCOME
80 diff -r b1cf15d038ee include/client.h
81 --- a/include/client.h
82 +++ b/include/client.h
84 PRIV_USER_PRIVACY, /* oper can bypass user privacy +x etc gives i.e. see real ip's */
85 PRIV_CHANNEL_PRIVACY, /* oper can bypass channel privacy i.e. can see modes on channels they are not on and channel keys */
86 PRIV_SERVERINFO, /* oper can use /get, /stats, /hash, retrieve remote information */
87 + PRIV_WELCOME, /* oper can WELCOME */
88 + PRIV_LOCAL_WELCOME, /* oper can local WELCOME */
89 PRIV_LAST_PRIV /**< number of privileges */
92 diff -r b1cf15d038ee include/handlers.h
93 --- a/include/handlers.h
94 +++ b/include/handlers.h
96 extern int m_version(struct Client*, struct Client*, int, char*[]);
97 extern int m_wallchops(struct Client*, struct Client*, int, char*[]);
98 extern int m_wallvoices(struct Client*, struct Client*, int, char*[]);
99 +extern int m_welcome(struct Client*, struct Client*, int, char*[]);
100 extern int m_who(struct Client*, struct Client*, int, char*[]);
101 extern int m_whois(struct Client*, struct Client*, int, char*[]);
102 extern int m_whowas(struct Client*, struct Client*, int, char*[]);
104 extern int mo_version(struct Client*, struct Client*, int, char*[]);
105 extern int mo_wallops(struct Client*, struct Client*, int, char*[]);
106 extern int mo_wallusers(struct Client*, struct Client*, int, char*[]);
107 +extern int mo_welcome(struct Client*, struct Client*, int, char*[]);
108 extern int mo_xquery(struct Client*, struct Client*, int, char*[]);
109 extern int mr_error(struct Client*, struct Client*, int, char*[]);
110 extern int mr_error(struct Client*, struct Client*, int, char*[]);
112 extern int ms_wallops(struct Client*, struct Client*, int, char*[]);
113 extern int ms_wallusers(struct Client*, struct Client*, int, char*[]);
114 extern int ms_wallvoices(struct Client*, struct Client*, int, char*[]);
115 +extern int ms_welcome(struct Client*, struct Client*, int, char*[]);
116 extern int ms_whois(struct Client*, struct Client*, int, char*[]);
117 extern int ms_xquery(struct Client*, struct Client*, int, char*[]);
118 extern int ms_xreply(struct Client*, struct Client*, int, char*[]);
119 diff -r b1cf15d038ee include/ircd_features.h
120 --- a/include/ircd_features.h
121 +++ b/include/ircd_features.h
123 FEAT_IRCD_RES_TIMEOUT,
125 FEAT_ANNOUNCE_INVITES,
128 /* features that affect all operators */
129 FEAT_EXTENDED_CHECKCMD,
138 diff -r b1cf15d038ee include/msg.h
142 #define TOK_NOTICE "O"
143 #define CMD_NOTICE MSG_NOTICE, TOK_NOTICE
145 +#define MSG_WELCOME "WELCOME" /* WELC */
146 +#define TOK_WELCOME "WE"
147 +#define CMD_WELCOME MSG_WELCOME, TOK_WELCOME
149 #define MSG_WALLCHOPS "WALLCHOPS" /* WC */
150 #define TOK_WALLCHOPS "WC"
151 #define CMD_WALLCHOPS MSG_WALLCHOPS, TOK_WALLCHOPS
152 diff -r b1cf15d038ee include/numeric.h
153 --- a/include/numeric.h
154 +++ b/include/numeric.h
156 RPL_STATSGLINE 227 Dalnet
157 RPL_STATSVLINE 227 unreal */
158 #define RPL_STATSALINE 226 /* Hybrid, Undernet */
159 +#define RPL_STATSWELCOME 227 /* QuakeNet extension */
160 #define RPL_STATSQLINE 228 /* Undernet extension */
162 /* RPL_SERVICEINFO 231 unused */
164 /* ERR_GHOSTEDCLIENT 503 efnet */
165 /* ERR_VWORLDWARN 503 austnet */
167 +#define ERR_NOSUCHWELCOME 509 /* QuakeNet extension */
169 #define ERR_SILELISTFULL 511 /* Undernet extension */
170 /* ERR_NOTIFYFULL 512 aircd */
171 /* ERR_TOOMANYWATCH 512 Numeric List: Dalnet */
172 diff -r b1cf15d038ee include/welcome.h
174 +++ b/include/welcome.h
176 +#ifndef INCLUDED_welcome_h
177 +#define INCLUDED_welcome_h
179 + * IRC - Internet Relay Chat, include/welcome.h
180 + * Copyright (C) 1990 Jarkko Oikarinen and
181 + * University of Oulu, Computing Center
182 + * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
184 + * This program is free software; you can redistribute it and/or modify
185 + * it under the terms of the GNU General Public License as published by
186 + * the Free Software Foundation; either version 2, or (at your option)
187 + * any later version.
189 + * This program is distributed in the hope that it will be useful,
190 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
191 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
192 + * GNU General Public License for more details.
194 + * You should have received a copy of the GNU General Public License
195 + * along with this program; if not, write to the Free Software
196 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
199 + * @brief Interface and declarations for welcome message handling.
201 +#ifndef INCLUDED_sys_types_h
202 +#include <sys/types.h>
203 +#define INCLUDED_sys_types_h
209 +/* Maximum number of welcome entries (per type; X global, X local) */
210 +#define WELCOME_MAX_ENTRIES 10
211 +/* Maximum length of a welcome message */
212 +#define WELCOMELEN TOPICLEN
215 +/* Test if a welcome entry is in a valid range */
216 +#define WelcomeIsValid(x) ((unsigned) (x) <= 2 * WELCOME_MAX_ENTRIES -1)
217 +/* Test if a welcome entry is set */
218 +#define WelcomeIsSet(x) (WelcomeArray[(x)].timestamp > 0)
219 +/* Test if a welcome entry is empty */
220 +#define WelcomeIsEmpty(x) (*WelcomeArray[(x)].text == 0)
222 +/* Get welcome timestamp */
223 +#define WelcomeTS(x) (WelcomeArray[(x)].timestamp)
224 +/* Get welcome text */
225 +#define WelcomeText(x) (WelcomeArray[(x)].text)
226 +/* Get welcome who info */
227 +#define WelcomeWho(x) (WelcomeArray[(x)].who)
230 +/* Describes a Welcome message entry. */
232 + time_t timestamp; /**< Timestamp of the welcome */
233 + char text[WELCOMELEN + 1]; /**< Message */
234 + char who[ACCOUNTLEN + 1]; /**< Who set it */
237 +/** Welcome type flags */
238 +#define WELCOME_LOCAL 0x01 /**< welcome is local */
239 +/** Welcome action flags */
240 +#define WELCOME_ANNOUNCE 0x02 /**< announce change to users */
241 +#define WELCOME_INSERT 0x04 /**< insert welcome message, move down all others one place */
243 +extern int welcome_do(struct Client *cptr, struct Client *sptr, char *name,
244 + time_t timestamp, char *who, char *text, unsigned int flags);
245 +extern void welcome_announce(int name);
246 +extern void welcome_burst(struct Client *cptr);
247 +extern int welcome_list(struct Client *sptr, int connect);
248 +extern void welcome_stats(struct Client *sptr, const struct StatDesc *sd, char *param);
249 +extern int welcome_memory_count(size_t *we_size);
251 +#endif /* INCLUDED_welcome_h */
252 diff -r b1cf15d038ee ircd/Makefile.in
253 --- a/ircd/Makefile.in
254 +++ b/ircd/Makefile.in
271 @@ -1161,6 +1163,11 @@
272 ../include/ircd_reply.h ../include/ircd_string.h \
273 ../include/ircd_chattr.h ../include/msg.h ../include/numeric.h \
274 ../include/numnicks.h ../include/s_user.h ../include/send.h
275 +m_welcome.o: m_welcome.c ../config.h ../include/channel.h \
276 + ../include/client.h ../include/hash.h ../include/ircd.h ../include/ircd_log.h \
277 + ../include/ircd_reply.h ../include/ircd_string.h ../include/msg.h \
278 + ../include/numeric.h ../include/numnicks.h ../include/s_user.h \
279 + ../include/send.h ../include/welcome.h
280 m_who.o: m_who.c ../config.h ../include/channel.h ../include/ircd_defs.h \
281 ../include/res.h ../config.h ../include/client.h ../include/dbuf.h \
282 ../include/msgq.h ../include/ircd_events.h ../include/ircd_handler.h \
283 @@ -1422,6 +1429,13 @@
284 ../include/numnicks.h ../include/querycmds.h ../include/ircd_features.h \
285 ../include/s_misc.h ../include/s_stats.h ../include/send.h \
286 ../include/struct.h ../include/sys.h
287 +welcome.o: welcome.c ../config.h ../include/client.h \
288 + ../include/hash.h ../include/ircd.h ../include/ircd_alloc.h \
289 + ../include/ircd_features.h ../include/ircd_log.h ../include/ircd_reply.h \
290 + ../include/match.h ../include/msg.h ../include/numeric.h \
291 + ../include/numnicks.h ../include/s_debug.h ../include/s_bsd.h \
292 + ../include/s_misc.h ../include/send.h ../include/struct.h \
293 + ../include/sys.h ../include/welcome.h
294 whocmds.o: whocmds.c ../config.h ../include/whocmds.h \
295 ../include/channel.h ../include/ircd_defs.h ../include/res.h \
296 ../config.h ../include/client.h ../include/dbuf.h ../include/msgq.h \
297 diff -r b1cf15d038ee ircd/client.c
301 FlagSet(&privs_local, PRIV_WHOX);
302 FlagSet(&privs_local, PRIV_DISPLAY);
303 FlagSet(&privs_local, PRIV_FORCE_LOCAL_OPMODE);
304 + FlagSet(&privs_local, PRIV_LOCAL_WELCOME);
306 privs_defaults_set = 1;
309 ClrPriv(client, PRIV_JUPE);
310 ClrPriv(client, PRIV_OPMODE);
311 ClrPriv(client, PRIV_BADCHAN);
312 + ClrPriv(client, PRIV_WELCOME);
317 P(CHANSERV), P(XTRA_OPER), P(NOIDLE), P(FREEFORM),
318 P(PARANOID), P(CHECK), P(WALL), P(CLOSE),
319 P(ROUTE), P(ROUTEINFO), P(SERVERINFO), P(CHANNEL_PRIVACY),
321 + P(USER_PRIVACY), P(WELCOME), P(LOCAL_WELCOME),
325 diff -r b1cf15d038ee ircd/ircd_features.c
326 --- a/ircd/ircd_features.c
327 +++ b/ircd/ircd_features.c
329 F_I(IRCD_RES_TIMEOUT, 0, 4, 0),
330 F_I(AUTH_TIMEOUT, 0, 9, 0),
331 F_B(ANNOUNCE_INVITES, 0, 0, 0),
332 + F_B(WELCOME, 0, 1, 0),
334 /* features that affect all operators */
335 F_B(EXTENDED_CHECKCMD, 0, 0, 0),
337 F_B(HIS_STATS_u, 0, 1, 0),
338 F_B(HIS_STATS_U, 0, 1, 0),
339 F_B(HIS_STATS_v, 0, 1, 0),
340 + F_B(HIS_STATS_W, 0, 1, 0),
341 F_B(HIS_STATS_w, 0, 1, 0),
342 F_B(HIS_STATS_x, 0, 1, 0),
343 F_B(HIS_STATS_y, 0, 1, 0),
344 diff -r b1cf15d038ee ircd/ircd_lexer.l
345 --- a/ircd/ircd_lexer.l
346 +++ b/ircd/ircd_lexer.l
348 { "serverinfo", TPRIV_SERVERINFO },
349 { "user_privacy", TPRIV_USER_PRIVACY },
350 { "channel_privacy", TPRIV_CHANNEL_PRIVACY },
351 + { "local_welcome", TPRIV_LOCAL_WELCOME },
352 + { "welcome", TPRIV_WELCOME },
356 diff -r b1cf15d038ee ircd/ircd_parser.y
357 --- a/ircd/ircd_parser.y
358 +++ b/ircd/ircd_parser.y
360 %token TPRIV_CHANSERV TPRIV_XTRA_OPER TPRIV_NOIDLE TPRIV_FREEFORM TPRIV_PARANOID
361 %token TPRIV_CHECK TPRIV_WALL TPRIV_CLOSE TPRIV_ROUTE TPRIV_ROUTEINFO TPRIV_SERVERINFO
362 %token TPRIV_CHANNEL_PRIVACY TPRIV_USER_PRIVACY TPRIV_LIST_CHAN
363 +%token TPRIV_LOCAL_WELCOME TPRIV_WELCOME
364 /* and some types... */
366 %type <num> timespec timefactor factoredtimes factoredtime
368 TPRIV_SERVERINFO { $$ = PRIV_SERVERINFO ; } |
369 TPRIV_CHANNEL_PRIVACY { $$ = PRIV_CHANNEL_PRIVACY ; } |
370 TPRIV_USER_PRIVACY { $$ = PRIV_USER_PRIVACY ; } |
371 + TPRIV_LOCAL_WELCOME { $$ = PRIV_LOCAL_WELCOME; } |
372 + TPRIV_WELCOME { $$ = PRIV_WELCOME; } |
373 TPRIV_PARANOID { $$ = PRIV_PARANOID; } ;
374 yesorno: YES { $$ = 1; } | NO { $$ = 0; };
376 diff -r b1cf15d038ee ircd/m_welcome.c
378 +++ b/ircd/m_welcome.c
381 + * IRC - Internet Relay Chat, ircd/m_welcome.c
382 + * Copyright (C) 1990 Jarkko Oikarinen and
383 + * University of Oulu, Computing Center
385 + * See file AUTHORS in IRC package for additional names of
388 + * This program is free software; you can redistribute it and/or modify
389 + * it under the terms of the GNU General Public License as published by
390 + * the Free Software Foundation; either version 1, or (at your option)
391 + * any later version.
393 + * This program is distributed in the hope that it will be useful,
394 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
395 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
396 + * GNU General Public License for more details.
398 + * You should have received a copy of the GNU General Public License
399 + * along with this program; if not, write to the Free Software
400 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
405 + * m_functions execute protocol messages on this server:
407 + * cptr is always NON-NULL, pointing to a *LOCAL* client
408 + * structure (with an open socket connected!). This
409 + * identifies the physical socket where the message
410 + * originated (or which caused the m_function to be
411 + * executed--some m_functions may call others...).
413 + * sptr is the source of the message, defined by the
414 + * prefix part of the message if present. If not
415 + * or prefix not found, then sptr==cptr.
417 + * (!IsServer(cptr)) => (cptr == sptr), because
418 + * prefixes are taken *only* from servers...
421 + * (sptr == cptr) => the message didn't
424 + * (sptr != cptr && IsServer(sptr) means
425 + * the prefix specified servername. (?)
427 + * (sptr != cptr && !IsServer(sptr) means
428 + * that message originated from a remote
429 + * user (not local).
433 + * (!IsServer(sptr)) means that, sptr can safely
434 + * taken as defining the target structure of the
435 + * message in this server.
437 + * *Always* true (if 'parse' and others are working correct):
439 + * 1) sptr->from == cptr (note: cptr->from == cptr)
441 + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
442 + * *cannot* be a local connection, unless it's
443 + * actually cptr!). [MyConnect(x) should probably
444 + * be defined as (x == x->from) --msa ]
446 + * parc number of variable parameter strings (if zero,
447 + * parv is allowed to be NULL)
449 + * parv a NULL terminated list of parameter pointers,
451 + * parv[0], sender (prefix string), if not present
452 + * this points to an empty string.
453 + * parv[1]...parv[parc-1]
454 + * pointers to additional parameters
455 + * parv[parc] == NULL, *always*
457 + * note: it is guaranteed that parv[0]..parv[parc-1] are all
458 + * non-NULL pointers.
462 +#include "channel.h"
466 +#include "ircd_features.h"
467 +#include "ircd_log.h"
468 +#include "ircd_reply.h"
469 +#include "ircd_snprintf.h"
470 +#include "ircd_string.h"
472 +#include "numeric.h"
473 +#include "numnicks.h"
476 +#include "welcome.h"
478 +/* #include <assert.h> -- Now using assert in ircd_log.h */
481 + * m_welcome - local generic message handler
483 + * parv[0] = Send prefix
484 + * parv[1] = [remote server to query]
486 +int m_welcome(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
488 + /* feature disabled */
489 + if (!feature_bool(FEAT_WELCOME))
490 + return send_reply(sptr, ERR_DISABLED, "WELCOME");
492 + /* only opers can set the welcome messages */
494 + return send_reply(sptr, ERR_NOPRIVILEGES);
496 + /* remote listing request, see if it is for me or a remote server
497 + * check FEAT_HIS_REMOTE to decide if an ordinary user can do this
499 + if ((parc > 1) && (hunt_server_cmd(sptr, CMD_WELCOME, cptr, feature_int(FEAT_HIS_REMOTE),
500 + "%C", 1, parc, parv) != HUNTED_ISME))
503 + /* local listing */
504 + return welcome_list(sptr, 0);
509 + * mo_welcome - oper message handler
512 + * parv[0] = Send prefix
515 + * parv[0] = Send prefix
518 + * set global or on remote server:
519 + * parv[0] = Send prefix
520 + * parv[1] = Target: server or * for global (or left out for this server)
524 +int mo_welcome(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
526 + char *target, *name, *who, *text, pattern[BUFSIZE];
528 + unsigned int flags = 0;
531 + /* feature disabled */
532 + if (!feature_bool(FEAT_WELCOME))
533 + return send_reply(sptr, ERR_DISABLED, "WELCOME");
535 + /* TODO: move feature check here? */
536 + /* remote listing request, see if it is for me or a remote server */
537 + if ((parc == 2) && (hunt_server_cmd(sptr, CMD_WELCOME, cptr, 0, "%C", 1, parc, parv) != HUNTED_ISME))
540 + /* local listing */
542 + return welcome_list(sptr, 0);
545 + /* local - need PRIV LOCAL_WELCOME or WELCOME */
546 + if (parc == 3 && !HasPriv(sptr,PRIV_LOCAL_WELCOME) && !HasPriv(sptr,PRIV_WELCOME))
547 + return send_reply(sptr, ERR_NOPRIVILEGES);
549 + /* global or remote - need PRIV WELCOME */
550 + if (parc >= 4 && !HasPriv(sptr,PRIV_WELCOME))
551 + return send_reply(sptr, ERR_NOPRIVILEGES);
553 + /* set the parameters */
555 + /* target not given, only name - setting local welcome */
558 + target = cli_name(&me);
560 + flags |= WELCOME_LOCAL;
562 + /* target and name given */
567 + timestamp = TStime();
568 + who = cli_user(sptr)->opername;
569 + text = parv[parc - 1];
571 + /* target is not global */
572 + if (!(target[0] == '*' && target[1] == '\0') && !local) {
574 + /* build a pattern for hunt_server_cmd since we do not have all we need in parv */
575 + ircd_snprintf(0, pattern, sizeof(pattern), "%s %s %Tu %s :%s", "%C", name, timestamp, who, text);
576 + if (hunt_server_cmd(sptr, CMD_WELCOME, cptr, 0, pattern, 1, 2, parv) != HUNTED_ISME)
579 + /* else it is a local welcome, for me */
580 + flags |= WELCOME_LOCAL;
583 + /* check for anounce prefix */
584 + if (*name == '$') {
586 + /* only allow announce by oper for local welcome */
587 + if (flags & WELCOME_LOCAL)
588 + flags |= WELCOME_ANNOUNCE;
591 + /* check for insert prefix */
592 + if (*name == '+') {
594 + flags |= WELCOME_INSERT;
598 + return welcome_do(cptr, sptr, name, timestamp, who, text, flags);
603 + * ms_welcome - server message handler
605 + * parv[0] = Send prefix
606 + * parv[1] = Target: server numeric or * for global
608 + * parv[3] = Timestamp
612 +int ms_welcome(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
614 + char *target, *name, *who, *text;
616 + unsigned int flags = 0;
618 + /* not enough - complain */
620 + protocol_violation(sptr, "Too few parameters for WELCOME (got %d - need 2)", parc);
621 + return need_more_params(sptr, "WELCOME");
624 + /* remote listing request, see if it is for me or a remote server */
626 + if (IsServer(sptr))
627 + return protocol_violation(cptr, "WELCOME listing request from server %C", sptr);
628 + if (hunt_server_cmd(sptr, CMD_WELCOME, cptr, 0, "%C", 1, parc, parv) != HUNTED_ISME)
630 + return welcome_list(sptr, 0);
633 + /* we need at least 6 parameters to continue - complain */
635 + protocol_violation(sptr, "Too few parameters for WELCOME (got %d - need 6)", parc);
636 + return need_more_params(sptr, "WELCOME");
639 + /* set the parameters */
642 + timestamp = atoi(parv[3]);
644 + text = parv[parc - 1]; /* parse reason as last parameter */
646 + /* target is not global */
647 + if (!(target[0] == '*' && target[1] == '\0')) {
649 + /* not for me, and forward it */
650 + if (hunt_server_cmd(sptr, CMD_WELCOME, cptr, 0, "%C %s %s %s :%s", 1, parc, parv) != HUNTED_ISME)
653 + /* local welcome for me */
654 + flags |= WELCOME_LOCAL;
657 + /* check for anounce prefix */
658 + if (*name == '$') {
660 + flags |= WELCOME_ANNOUNCE;
663 + /* check for insert prefix */
664 + if (*name == '+') {
666 + flags |= WELCOME_INSERT;
670 + return welcome_do(cptr, sptr, name, timestamp, who, text, flags);
672 diff -r b1cf15d038ee ircd/parse.c
676 /* UNREG, CLIENT, SERVER, OPER, SERVICE */
677 { m_unregistered, m_not_oper, ms_check, mo_check, m_ignore }
680 + /* add command for WELCOME */
684 + 0, MAXPARA, MFLG_SLOW, 0, NULL,
685 + /* UNREG, CLIENT, SERVER, OPER, SERVICE, HELP */
686 + { m_unregistered, m_welcome, ms_welcome, mo_welcome, m_ignore }
689 /* This command is an alias for QUIT during the unregistered part of
690 * of the server. This is because someone jumping via a broken web
691 diff -r b1cf15d038ee ircd/s_debug.c
698 +#include "welcome.h"
701 /* #include <assert.h> -- Now using assert in ircd_log.h */
703 aw = 0, /* aways set */
704 wwa = 0, /* whowas aways */
706 - ju = 0; /* jupes */
707 + ju = 0, /* jupes */
708 + we = 0; /* welcomes */
710 size_t chm = 0, /* memory used by channels */
711 chbm = 0, /* memory used by channel bans */
713 wwm = 0, /* whowas array memory used */
714 glm = 0, /* memory used by glines */
715 jum = 0, /* memory used by jupes */
716 + wem = 0, /* memory used by welcomes */
717 com = 0, /* memory used by conf lines */
718 dbufs_allocated = 0, /* memory used by dbufs */
719 dbufs_used = 0, /* memory used by dbufs */
721 send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
722 ":Glines %d(%zu) Jupes %d(%zu)", gl, glm, ju, jum);
724 + we = welcome_memory_count(&wem);
725 + send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
726 + ":Welcomes %d(%zu)", we, wem);
728 send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
729 ":Hash: client %d(%zu), chan is the same", HASHSIZE,
730 sizeof(void *) * HASHSIZE);
731 diff -r b1cf15d038ee ircd/s_err.c
736 { RPL_STATSALINE, "%s", "226" },
739 + { RPL_STATSWELCOME, "W %d %s %s %Tu :%s", "227" },
741 { RPL_STATSQLINE, "Q %s :%s", "228" },
743 @@ -1050,7 +1050,7 @@
748 + { ERR_NOSUCHWELCOME, "%s :No such welcome", "509" },
752 diff -r b1cf15d038ee ircd/s_serv.c
758 #include "userload.h"
759 +#include "welcome.h"
761 /* #include <assert.h> -- Now using assert in ircd_log.h */
767 + welcome_burst(cptr);
770 * Pass on my client information to the new server
771 diff -r b1cf15d038ee ircd/s_stats.c
777 #include "userload.h"
778 +#include "welcome.h"
783 { 'V', "vserversmach", (STAT_FLAG_OPERFEAT | STAT_FLAG_VARPARAM | STAT_FLAG_CASESENS), FEAT_HIS_STATS_v,
784 stats_servers_verbose, 0,
785 "Verbose server information." },
786 - { 'w', "userload", STAT_FLAG_OPERFEAT, FEAT_HIS_STATS_w,
787 + { 'w', "userload", STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS, FEAT_HIS_STATS_w,
789 "Userload statistics." },
790 + { 'W', "welcome", STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS, FEAT_HIS_STATS_W,
792 + "Welcome messages." },
793 { 'x', "memusage", STAT_FLAG_OPERFEAT, FEAT_HIS_STATS_x,
795 "List usage information." },
796 diff -r b1cf15d038ee ircd/s_user.c
800 #include "userload.h"
803 +#include "welcome.h"
805 #include "handlers.h" /* m_motd and m_lusers */
809 IPcheck_connect_succeeded(sptr);
812 + if (feature_bool(FEAT_WELCOME))
813 + welcome_list(sptr, 1);
816 /* apply auto sethost if needed */
817 apply_spoofblock(sptr);
818 diff -r b1cf15d038ee ircd/welcome.c
823 + * IRC - Internet Relay Chat, ircd/welcome.c
824 + * Copyright (C) 1990 Jarkko Oikarinen and
825 + * University of Oulu, Finland
826 + * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
828 + * This program is free software; you can redistribute it and/or modify
829 + * it under the terms of the GNU General Public License as published by
830 + * the Free Software Foundation; either version 1, or (at your option)
831 + * any later version.
833 + * This program is distributed in the hope that it will be useful,
834 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
835 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
836 + * GNU General Public License for more details.
838 + * You should have received a copy of the GNU General Public License
839 + * along with this program; if not, write to the Free Software
840 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
843 + * @brief Implementation of welcome message handling functions.
850 +#include "ircd_alloc.h"
851 +#include "ircd_features.h"
852 +#include "ircd_log.h"
853 +#include "ircd_reply.h"
854 +#include "ircd_string.h"
857 +#include "numeric.h"
858 +#include "numnicks.h"
860 +#include "s_debug.h"
864 +#include "sys.h" /* FALSE bleah */
865 +#include "welcome.h"
867 +/* #include <assert.h> -- Now using assert in ircd_log.h */
871 +/** List of welcome messages - first MAX for global, second MAX for local */
872 +static struct Welcome WelcomeArray[WELCOME_MAX_ENTRIES * 2] = { { 0 } };
875 +/** Allocate a new welcome with the given parameters.
876 + * @param[in] name Name of the welcome message.
877 + * @param[in] text The welcome message.
878 + * @param[in] who Who set it.
879 + * @param[in] timestamp When it was set.
880 + * @return name Array number of the welcome set.
883 +welcome_make(int name, char *text, char *who, time_t timestamp)
885 + assert(WelcomeIsValid(name));
886 + assert(NULL != text);
887 + assert(NULL != who);
890 + ircd_strncpy(WelcomeArray[name].text, text, WELCOMELEN);
891 + ircd_strncpy(WelcomeArray[name].who, who, ACCOUNTLEN);
892 + WelcomeArray[name].timestamp = timestamp;
898 +/** Propagate a welcome message.
899 + * @param[in] cptr Local client that sent us the welcome.
900 + * @param[in] sptr Originator of the welcome.
901 + * @param[in] nameint Name of the message.
902 + * @param[in] timestamp Timestamp of when the message was set.
903 + * @param[in] who Who set this message.
904 + * @param[in] text The welcome message.
905 + * @param[in] flags Flags to set on welcome.
909 +welcome_propagate(struct Client *cptr, struct Client *sptr, int nameint,
910 + time_t timestamp, char *who, char *text, unsigned int flags)
912 + assert(NULL != sptr);
913 + assert(NULL != cptr);
914 + assert(nameint > 0 && nameint <= WELCOME_MAX_ENTRIES);
915 + assert(!(flags & WELCOME_LOCAL));
917 + sendcmdto_serv_butone(sptr, CMD_WELCOME, cptr, "* %s%s%d %Tu %s :%s",
918 + (flags & WELCOME_ANNOUNCE) ? "$" : "", (flags & WELCOME_INSERT) ? "+" : "",
919 + nameint, timestamp, who, text);
925 +/** Resend a welcome message.
926 + * @param[in] cptr Local client that sent us the welcome.
927 + * @param[in] nameint Name of the message.
928 + * @param[in] namearray Name of the array item.
932 +welcome_resend(struct Client *cptr, int nameint, int namearray)
934 + assert(NULL != cptr);
935 + assert(IsServer(cptr));
936 + assert(nameint > 0 && nameint <= WELCOME_MAX_ENTRIES);
937 + assert(WelcomeIsValid(namearray));
939 + sendcmdto_one(&me, CMD_WELCOME, cptr, "* %d %Tu %s :%s",
940 + nameint, WelcomeTS(namearray), WelcomeWho(namearray), WelcomeText(namearray));
946 +/** Log a welcome message.
947 + * @param[in] sptr Originator of the welcome.
948 + * @param[in] msg The message to show.
949 + * @param[in] flags Flags to set on welcome.
953 +welcome_log(struct Client *sptr, char *msg, unsigned int flags)
955 + assert(NULL != sptr);
956 + assert(NULL != msg);
959 + sendto_opmask_butone(0, SNO_OLDSNO, "%s %s",
960 + (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
961 + get_client_name_and_opername(sptr) : cli_name((cli_user(sptr))->server), msg);
964 + log_write(LS_NETWORK, L_INFO, LOG_NOSNOTICE, "%s %s", get_client_name_and_opername(sptr), msg);
966 + /* welcome by remote user, inform oper of success */
967 + if ((flags & WELCOME_LOCAL) && IsUser(sptr) && !MyUser(sptr)) {
968 + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s %s",
969 + sptr, get_client_name_and_opername(sptr), msg);
971 + /* TODO: wallops all local changes, by both local and remote opers? */
972 + /* tell all opers about the local message being set remotely */
973 + sendwallto_group_butone(&me, WALL_WALLOPS, 0, "%s %s", get_client_name_and_opername(sptr), msg);
980 +/** Set a welcome message.
981 + * @param[in] cptr Local client that sent us the welcome.
982 + * @param[in] sptr Originator of the welcome.
983 + * @param[in] nameint Name of the message.
984 + * @param[in] namearray Array entry.
985 + * @param[in] timestamp Timestamp of when the message was set.
986 + * @param[in] who Who set this message.
987 + * @param[in] text The message.
988 + * @param[in] flags Flags to set on welcome.
992 +welcome_set(struct Client *cptr, struct Client *sptr, int nameint,
993 + int namearray, time_t timestamp, char *who, char *text, unsigned int flags)
995 + char msg[BUFSIZE]; /* msg for logging */
998 + assert(NULL != cptr);
999 + assert(NULL != sptr);
1000 + assert(nameint > 0 && nameint <= WELCOME_MAX_ENTRIES);
1001 + assert(WelcomeIsValid(namearray));
1004 + Debug((DEBUG_DEBUG, "welcome_set(\"%s\", \"%s\", %d, %d, %Tu, \"%s\", \"%s\", 0x%04x)",
1005 + cli_name(cptr), cli_name(sptr), nameint, namearray, timestamp, who, text, flags));
1008 + if (WelcomeIsEmpty(namearray))
1012 + welcome_make(namearray, text, who, timestamp);
1014 + /* create msg for log */
1015 + ircd_snprintf(0, msg, 0, "%s%s%s WELCOME %d \"%s\" %s [%Tu]",
1016 + new ? "setting" : "changing",
1017 + (flags & WELCOME_ANNOUNCE) ? " and announcing " : " ",
1018 + (flags & WELCOME_LOCAL) ? "local" : "global",
1019 + nameint, WelcomeText(namearray), WelcomeWho(namearray), timestamp);
1022 + welcome_log(sptr, msg, flags);
1024 + /* propagate it */
1025 + if (!(flags & WELCOME_LOCAL))
1026 + welcome_propagate(cptr, sptr, nameint, timestamp, who, text, flags);
1029 + if (flags & WELCOME_ANNOUNCE)
1030 + welcome_announce(namearray);
1036 +/** Unset a welcome message.
1037 + * @param[in] cptr Local client that sent us the welcome.
1038 + * @param[in] sptr Originator of the welcome.
1039 + * @param[in] nameint Name of the message.
1040 + * @param[in] namearray Array entry.
1041 + * @param[in] timestamp Timestamp of when the message was set.
1042 + * @param[in] who Who set this message.
1043 + * @param[in] flags Flags to set on welcome.
1047 +welcome_unset(struct Client *cptr, struct Client *sptr, int nameint,
1048 + int namearray, time_t timestamp, char *who, unsigned int flags)
1050 + char msg[BUFSIZE]; /* msg for logging */
1051 + int i; /* loop variable */
1052 + int empty = namearray; /* first empty spot in array after namearray */
1053 + int end = WELCOME_MAX_ENTRIES -1; /* last element to check in array */
1055 + assert(NULL != cptr);
1056 + assert(NULL != sptr);
1057 + assert(nameint > 0 && nameint <= WELCOME_MAX_ENTRIES);
1058 + assert(WelcomeIsValid(namearray));
1061 + Debug((DEBUG_DEBUG, "welcome_unset(\"%s\", \"%s\", %d, %d, %Tu, \"%s\", 0x%04x)",
1062 + cli_name(cptr), cli_name(sptr), nameint, namearray, timestamp, who, flags));
1064 + /* create msg for log */
1065 + ircd_snprintf(0, msg, 0, "unsetting %s WELCOME %d \"%s\" %s [%Tu]",
1066 + (flags & WELCOME_LOCAL) ? "local" : "global",
1067 + nameint, WelcomeText(namearray), WelcomeWho(namearray), timestamp);
1070 + welcome_log(sptr, msg, flags);
1073 + welcome_make(namearray, "", who, timestamp);
1075 + /* propagate it, but not when inserting */
1076 + if (!(flags & (WELCOME_LOCAL|WELCOME_INSERT)))
1077 + welcome_propagate(cptr, sptr, nameint, timestamp, who, "", flags);
1079 + /* correct end for local offset */
1080 + if (flags & WELCOME_LOCAL)
1081 + end += WELCOME_MAX_ENTRIES;
1083 + /* move entries up, update timestamp */
1084 + for (i = namearray; i < end; i++)
1085 + welcome_make(i, WelcomeText(i+1), WelcomeWho(i+1), timestamp);
1087 + /* clear last entry, update timestamp */
1088 + welcome_make(end, "", who, timestamp);
1094 +/** Insert a welcome message.
1095 + * @param[in] cptr Local client that sent us the welcome.
1096 + * @param[in] sptr Originator of the welcome.
1097 + * @param[in] nameint Name of the message.
1098 + * @param[in] namearray Array entry.
1099 + * @param[in] timestamp Timestamp of when the message was set.
1100 + * @param[in] who Who set this message.
1101 + * @param[in] text The welcome message.
1102 + * @param[in] flags Flags to set on welcome.
1106 +welcome_insert(struct Client *cptr, struct Client *sptr, int nameint,
1107 + int namearray, time_t timestamp, char *who, char *text, unsigned int flags)
1109 + char msg[BUFSIZE]; /* msg for logging */
1110 + int i; /* loop variable */
1111 + int empty = -1; /* first empty spot in array after namearray */
1112 + int end = WELCOME_MAX_ENTRIES -1; /* last element to check in array */
1113 + int last = end; /* last welcome message to feed to welcome_unset */
1115 + assert(NULL != cptr);
1116 + assert(NULL != sptr);
1117 + assert(nameint > 0 && nameint <= WELCOME_MAX_ENTRIES);
1118 + assert(WelcomeIsValid(namearray));
1121 + Debug((DEBUG_DEBUG, "welcome_insert(\"%s\", \"%s\", %d, %d, %Tu, \"%s\", \"%s\", 0x%04x)",
1122 + cli_name(cptr), cli_name(sptr), nameint, namearray, timestamp, who, text, flags));
1124 + /* correct end for local offset */
1125 + if (flags & WELCOME_LOCAL)
1126 + end += WELCOME_MAX_ENTRIES;
1128 + /* find first empty spot */
1129 + for (i = namearray; i <= end; i++) {
1130 + if (WelcomeIsEmpty(i)) {
1136 + /* no empty spot, need to unset last */
1137 + if (empty == -1) {
1138 + welcome_unset(cptr, sptr, end, namearray, timestamp, who, flags);
1142 + /* move entries down, update timestamp */
1143 + for (i = empty; i > namearray; i--)
1144 + welcome_make(i, WelcomeText(i-1), WelcomeWho(i-1), timestamp);
1146 + /* correct empty for local offset */
1147 + if (flags & WELCOME_LOCAL)
1148 + empty -= WELCOME_MAX_ENTRIES;
1150 + /* create msg for log */
1151 + if (nameint == empty)
1152 + ircd_snprintf(0, msg, 0, "moving %s WELCOME message %d one place down",
1153 + (flags & WELCOME_LOCAL) ? "local" : "global", nameint);
1155 + ircd_snprintf(0, msg, 0, "moving %s WELCOME message %d %s %d one place down",
1156 + (flags & WELCOME_LOCAL) ? "local" : "global", nameint, (empty - nameint > 1) ? "to" : "and" , empty);
1159 + welcome_log(sptr, msg, flags);
1162 + welcome_set(cptr, sptr, nameint, namearray, timestamp, who, text, flags);
1168 +/** Change a welcome message.
1169 + * @param[in] cptr Local client that sent us the welcome.
1170 + * @param[in] sptr Originator of the welcome.
1171 + * @param[in] name Name of the message.
1172 + * @param[in] timestamp Timestamp of when the message was set.
1173 + * @param[in] who Who set this message.
1174 + * @param[in] text The welcome message.
1175 + * @param[in] flags Flags to set on welcome.
1179 +welcome_do(struct Client *cptr, struct Client *sptr, char *name,
1180 + time_t timestamp, char *who, char *text, unsigned int flags)
1182 + int nameint = atoi(name); /* transform to int */
1183 + int namearray = nameint - 1; /* used to test the array element */
1185 + assert(NULL != cptr);
1186 + assert(NULL != sptr);
1187 + assert(NULL != name);
1188 + assert(NULL != text);
1189 + assert(NULL != who);
1192 + Debug((DEBUG_DEBUG, "welcome_do(\"%s\", \"%s\", \"%s\", %Tu, \"%s\", \"%s\", 0x%04x)",
1193 + cli_name(cptr), cli_name(sptr), name, timestamp, who, text, flags));
1195 + /* if for some reason timestamp is 0, increase it */
1196 + if (timestamp == 0)
1199 + /* name empty after taking off the prefixes? */
1200 + if (EmptyString(name)) {
1202 + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :WELCOME: No message number given", sptr);
1204 + protocol_violation(cptr, "WELCOME: No message number given by %C", sptr);
1209 + if (!WelcomeIsValid(namearray)) {
1211 + sendcmdto_one(&me, CMD_NOTICE, sptr,
1212 + "%C :WELCOME: Invalid message number %s - should between 1 and %d",
1213 + sptr, name, WELCOME_MAX_ENTRIES);
1215 + protocol_violation(cptr,
1216 + "WELCOME: Invalid message number %s from %C - should be between 1 and %d",
1217 + name, sptr, WELCOME_MAX_ENTRIES);
1221 + /* source is user, and is myuser or welcome is local, check length of the message */
1222 + if ((IsUser(sptr)) && ((MyUser(sptr)) || (flags & WELCOME_LOCAL)) && (strlen(text) > WELCOMELEN)) {
1223 + sendcmdto_one(&me, CMD_NOTICE, sptr,
1224 + "%C :WELCOME: The message is too long with %d chars - max is %d chars",
1225 + sptr, strlen(text), WELCOMELEN);
1226 + ircd_strncpy(text, text, WELCOMELEN);
1227 + sendcmdto_one(&me, CMD_NOTICE, sptr,
1228 + "%C :WELCOME: Change or truncate the message to: \"%s\"", sptr, text);
1232 + /* correct namearray for local offset */
1233 + if (flags & WELCOME_LOCAL)
1234 + namearray += WELCOME_MAX_ENTRIES;
1236 + /* must be true by now */
1237 + assert(WelcomeIsValid(namearray));
1238 + assert(nameint > 0 && nameint <= WELCOME_MAX_ENTRIES);
1240 + /* cannot unset welcome that is not set */
1241 + if (!WelcomeIsSet(namearray) && EmptyString(text)) {
1243 + /* from user, throw error */
1245 + return send_reply(sptr, ERR_NOSUCHWELCOME, name);
1247 + /* new local welcome from server, but empty - ignore
1248 + * we do accept a new global welcome message that is empty
1250 + if (flags & WELCOME_LOCAL)
1254 + /* check if there is something to change */
1255 + /* we got a record for it */
1256 + if (WelcomeIsSet(namearray)) {
1259 + if (!(flags & WELCOME_LOCAL)) {
1261 + /* myuser changes it,
1262 + * welcomeTS greater than or equal to timestamp, take welcomeTS+1 as timestamp
1263 + * else the change is not accepted upstream because of the older TS
1265 + if (MyUser(sptr)) {
1266 + if (WelcomeTS(namearray) >= timestamp)
1267 + timestamp = WelcomeTS(namearray) +1;
1270 + /* compare timestamps, ignore welcome when:
1271 + * we got a newer one
1272 + * or when timestamps are the same and our text is 'smaller'
1274 + else if ((timestamp < WelcomeTS(namearray)) || /* we got a newer one */
1275 + ((timestamp == WelcomeTS(namearray)) && /* same timestamp */
1276 + (strcmp(WelcomeText(namearray), text) < 0))) { /* our text is 'smaller' */
1277 + /* burst or burst ack, cptr gets our version from the burst */
1278 + if (IsBurstOrBurstAck(cptr))
1281 + return welcome_resend(cptr, nameint, namearray);
1284 + /* local welcome - we use our idea of the time */
1286 + timestamp = TStime();
1288 + /* new global welcome from my user or local welcome
1289 + * compare new message with old message
1291 + if (IsUser(sptr) && (MyUser(sptr) || (flags & WELCOME_LOCAL))) {
1292 + if (strcmp(text, WelcomeText(namearray)) == 0) { /* use strcmp because the user may wish to change case */
1293 + sendcmdto_one(&me, CMD_NOTICE, sptr,
1294 + "%C :WELCOME: Cannot change %s message for %s - nothing to change",
1295 + sptr, (flags & WELCOME_LOCAL) ? "local" : "global", name);
1301 + /* do not insert for last global/local entry and when not set yet */
1302 + if ((flags & WELCOME_INSERT) &&
1303 + ((!WelcomeIsSet(namearray)) || (nameint == WELCOME_MAX_ENTRIES)))
1304 + flags &= ~WELCOME_INSERT;
1307 + if (EmptyString(text)) {
1308 + /* clear insert flag,
1309 + * when this flag is set, welcome_unset() assumes it is being called from welcome_insert()
1310 + * and wont propagate the change
1312 + flags &= ~WELCOME_INSERT;
1313 + return welcome_unset(cptr, sptr, nameint, namearray, timestamp, who, flags);
1317 + if (flags & WELCOME_INSERT)
1318 + return welcome_insert(cptr, sptr, nameint, namearray, timestamp, who, text, flags);
1320 + /* new or change */
1321 + return welcome_set(cptr, sptr, nameint, namearray, timestamp, who, text, flags);
1325 +/** Announce a welcome message to local clients.
1326 + * @param[in] name Welcome message to announce.
1329 +welcome_announce(int name)
1331 + struct Client *acptr;
1332 + struct MsgBuf *msgbuf;
1335 + /* valid range, set and not empty */
1336 + assert(WelcomeIsValid(name));
1337 + assert(WelcomeIsSet(name));
1338 + assert(!WelcomeIsEmpty(name));
1340 + /* TODO: target is $* as if it were a global broadcast
1341 + * could make it $servername for local message announcement
1342 + * but the type is shown between [ ] already
1343 + * either [Network] or [servername] - using $* is just shorter.
1345 + /* build msgbuf */
1346 + msgbuf = msgq_make(0, ":%C %s $* :[%s] %s", &me, MSG_NOTICE,
1347 + name >= WELCOME_MAX_ENTRIES ? cli_name(&me) : feature_str(FEAT_NETWORK),
1348 + WelcomeText(name));
1350 + /* go over local clients */
1351 + for (i = HighestFd; i > 0; --i) {
1353 + /* skip unregistered clients, skip servers */
1354 + if (!(acptr = LocalClientArray[i]) || !IsRegistered(acptr) || IsServer(acptr))
1357 + /* send it away */
1358 + send_buffer(acptr, msgbuf, 0);
1363 +/** Send the full list of welcome message to \a cptr.
1364 + * @param[in] cptr Local server to send welcomes to.
1367 +welcome_burst(struct Client *cptr)
1371 + assert(NULL != cptr);
1373 + /* loop over global entries - 0 to max - 1*/
1374 + for (name = 0; name <= WELCOME_MAX_ENTRIES - 1; name++) {
1375 + if (WelcomeIsSet(name))
1376 + sendcmdto_one(&me, CMD_WELCOME, cptr, "* %d %Tu %s :%s",
1377 + name + 1, WelcomeTS(name), WelcomeWho(name), WelcomeText(name));
1382 +/** List welcome messages.
1383 + * @param[in] sptr Client requesting the listing.
1384 + * @param[in] connect When non zero do not report no welcome is set
1388 +welcome_list(struct Client *sptr, int connect)
1390 + int found = 0, local = 0, name;
1392 + assert(NULL != sptr);
1394 + /* loop over all entries - range 0 to 2 * max - 1 */
1395 + for (name = 0; name <= 2 * WELCOME_MAX_ENTRIES - 1; name++) {
1397 + /* local entries now */
1398 + if (name == WELCOME_MAX_ENTRIES)
1401 + /* not set or empty - skip */
1402 + if (!WelcomeIsSet(name) || WelcomeIsEmpty(name))
1407 + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :[%s] %s",
1408 + sptr, local ? cli_name(&me) : feature_str(FEAT_NETWORK), WelcomeText(name));
1412 + if (!found && !connect)
1413 + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :No welcome message set.", sptr);
1419 +/** Statistics callback to list Welcome messages.
1420 + * @param[in] sptr Client requesting statistics.
1421 + * @param[in] sd Stats descriptor for request (ignored).
1422 + * @param[in] param Extra parameter from user (ignored).
1425 +welcome_stats(struct Client *sptr, const struct StatDesc *sd, char *param)
1427 + int name, local = 0;
1429 + assert(NULL != sptr);
1431 + /* loop over all entries - range 0 to 2 * max - 1*/
1432 + for (name = 0; name <= 2 * WELCOME_MAX_ENTRIES - 1; name++) {
1434 + /* local entries now */
1435 + if (name == WELCOME_MAX_ENTRIES)
1439 + if (!WelcomeIsSet(name))
1443 + send_reply(sptr, RPL_STATSWELCOME,
1444 + local ? name + 1 - WELCOME_MAX_ENTRIES : name + 1,
1445 + local ? cli_name(&me) : "*",
1446 + WelcomeWho(name), WelcomeTS(name),
1447 + WelcomeIsEmpty(name) ? "<Empty>" : WelcomeText(name));
1452 +/** Count welcome messages and memory used by them.
1453 + * @param[out] we_size Receives total number of bytes allocated for welcomes.
1454 + * @return Number of welcome messages currently allocated.
1457 +welcome_memory_count(size_t *we_size)
1460 + unsigned int we = 0;
1462 + for (name = 0; name <= 2 * WELCOME_MAX_ENTRIES - 1; name++) {
1463 + if (!WelcomeIsSet(name))
1466 + *we_size += WelcomeText(name) ? (strlen(WelcomeText(name)) + 1) : 0;
1467 + *we_size += WelcomeWho(name) ? (strlen(WelcomeWho(name)) + 1) : 0;