]> jfr.im git - irc/rqf/shadowircd.git/blob - modules/m_info.c
Merge.
[irc/rqf/shadowircd.git] / modules / m_info.c
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_info.c: Sends information about the server.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
24 */
25
26 #include "stdinc.h"
27 #include "m_info.h"
28 #include "channel.h"
29 #include "client.h"
30 #include "common.h"
31 #include "match.h"
32 #include "ircd.h"
33 #include "hook.h"
34 #include "numeric.h"
35 #include "s_serv.h"
36 #include "s_user.h"
37 #include "send.h"
38 #include "s_conf.h"
39 #include "msg.h"
40 #include "parse.h"
41 #include "modules.h"
42
43 static void send_conf_options(struct Client *source_p);
44 static void send_birthdate_online_time(struct Client *source_p);
45 static void send_info_text(struct Client *source_p);
46 static void info_spy(struct Client *);
47
48 static int m_info(struct Client *, struct Client *, int, const char **);
49 static int mo_info(struct Client *, struct Client *, int, const char **);
50
51 struct Message info_msgtab = {
52 "INFO", 0, 0, 0, MFLG_SLOW,
53 {mg_unreg, {m_info, 0}, {mo_info, 0}, mg_ignore, mg_ignore, {mo_info, 0}}
54 };
55
56 int doing_info_hook;
57
58 mapi_clist_av1 info_clist[] = { &info_msgtab, NULL };
59 mapi_hlist_av1 info_hlist[] = {
60 { "doing_info", &doing_info_hook },
61 { NULL, NULL }
62 };
63
64 DECLARE_MODULE_AV1(info, NULL, NULL, info_clist, info_hlist, NULL, "$Revision: 3396 $");
65
66 /*
67 * jdc -- Structure for our configuration value table
68 */
69 struct InfoStruct
70 {
71 const char *name; /* Displayed variable name */
72 unsigned int output_type; /* See below #defines */
73 void *option; /* Pointer reference to the value */
74 const char *desc; /* ASCII description of the variable */
75 };
76 /* Types for output_type in InfoStruct */
77 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
78 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
79 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
80 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
81 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
82 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
83
84 /* *INDENT-OFF* */
85 static struct InfoStruct info_table[] = {
86 /* --[ START OF TABLE ]-------------------------------------------- */
87 {
88 "opers_see_all_users",
89 OUTPUT_BOOLEAN_YN,
90 &opers_see_all_users,
91 "Farconnect notices available or operspy accountability limited"
92 },
93 {
94 "max_connections",
95 OUTPUT_DECIMAL,
96 &maxconnections,
97 "Max number connections"
98 },
99 {
100 "anti_nick_flood",
101 OUTPUT_BOOLEAN,
102 &ConfigFileEntry.anti_nick_flood,
103 "NICK flood protection"
104 },
105 {
106 "anti_spam_exit_message_time",
107 OUTPUT_DECIMAL,
108 &ConfigFileEntry.anti_spam_exit_message_time,
109 "Duration a client must be connected for to have an exit message"
110 },
111 {
112 "use_part_messages",
113 OUTPUT_BOOLEAN_YN,
114 &ConfigFileEntry.use_part_messages,
115 "Whether or not the server should allow users to show messages on PART"
116 },
117 {
118 "caller_id_wait",
119 OUTPUT_DECIMAL,
120 &ConfigFileEntry.caller_id_wait,
121 "Minimum delay between notifying UMODE +g users of messages"
122 },
123 {
124 "client_exit",
125 OUTPUT_BOOLEAN,
126 &ConfigFileEntry.client_exit,
127 "Prepend 'Client Exit:' to user QUIT messages"
128 },
129 {
130 "client_flood",
131 OUTPUT_DECIMAL,
132 &ConfigFileEntry.client_flood,
133 "Number of lines before a client Excess Flood's",
134 },
135 {
136 "connect_timeout",
137 OUTPUT_DECIMAL,
138 &ConfigFileEntry.connect_timeout,
139 "Connect timeout for connections to servers"
140 },
141 {
142 "default_ident_timeout",
143 OUTPUT_DECIMAL,
144 &ConfigFileEntry.default_ident_timeout,
145 "Amount of time the server waits for ident responses from clients",
146 },
147 {
148 "default_floodcount",
149 OUTPUT_DECIMAL,
150 &ConfigFileEntry.default_floodcount,
151 "Startup value of FLOODCOUNT",
152 },
153 {
154 "hide_channel_below_users",
155 OUTPUT_DECIMAL,
156 &ConfigFileEntry.hide_channel_below_users,
157 "Hide channels below this many users in standard /LIST output",
158 },
159 {
160 "default_adminstring",
161 OUTPUT_STRING,
162 &ConfigFileEntry.default_adminstring,
163 "Default adminstring at startup.",
164 },
165 {
166 "default_operstring",
167 OUTPUT_STRING,
168 &ConfigFileEntry.default_operstring,
169 "Default operstring at startup.",
170 },
171 {
172 "default_operhost",
173 OUTPUT_STRING,
174 &ConfigFileEntry.default_operhost,
175 "Default vhost for operators to receive upon opering up.",
176 },
177 {
178 "static_quit",
179 OUTPUT_STRING,
180 &ConfigFileEntry.static_quit,
181 "Quit message to show for all users.",
182 },
183 {
184 "servicestring",
185 OUTPUT_STRING,
186 &ConfigFileEntry.servicestring,
187 "String shown in whois for opered services.",
188 },
189 {
190 "disable_auth",
191 OUTPUT_BOOLEAN_YN,
192 &ConfigFileEntry.disable_auth,
193 "Controls whether auth checking is disabled or not"
194 },
195 {
196 "disable_fake_channels",
197 OUTPUT_BOOLEAN_YN,
198 &ConfigFileEntry.disable_fake_channels,
199 "Controls whether bold etc are disabled for JOIN"
200 },
201 {
202 "dots_in_ident",
203 OUTPUT_DECIMAL,
204 &ConfigFileEntry.dots_in_ident,
205 "Number of permissable dots in an ident"
206 },
207 {
208 "expire_override_time",
209 OUTPUT_DECIMAL,
210 &ConfigFileEntry.expire_override_time,
211 "Period of time after which to unset user mode +p"
212 },
213 {
214 "failed_oper_notice",
215 OUTPUT_BOOLEAN,
216 &ConfigFileEntry.failed_oper_notice,
217 "Inform opers if someone /oper's with the wrong password"
218 },
219 {
220 "fname_userlog",
221 OUTPUT_STRING,
222 &ConfigFileEntry.fname_userlog,
223 "User log file"
224 },
225 {
226 "fname_fuserlog",
227 OUTPUT_STRING,
228 &ConfigFileEntry.fname_fuserlog,
229 "Failed user log file"
230 },
231
232 {
233 "fname_operlog",
234 OUTPUT_STRING,
235 &ConfigFileEntry.fname_operlog,
236 "Operator log file"
237 },
238 {
239 "fname_foperlog",
240 OUTPUT_STRING,
241 &ConfigFileEntry.fname_foperlog,
242 "Failed operator log file"
243 },
244 {
245 "fname_serverlog",
246 OUTPUT_STRING,
247 &ConfigFileEntry.fname_serverlog,
248 "Server connect/disconnect log file"
249 },
250 {
251 "fname_klinelog",
252 OUTPUT_STRING,
253 &ConfigFileEntry.fname_klinelog,
254 "KLINE etc log file"
255 },
256 {
257 "fname_operspylog",
258 OUTPUT_STRING,
259 &ConfigFileEntry.fname_operspylog,
260 "Oper spy log file"
261 },
262 {
263 "fname_ioerrorlog",
264 OUTPUT_STRING,
265 &ConfigFileEntry.fname_ioerrorlog,
266 "IO error log file"
267 },
268 {
269 "global_snotices",
270 OUTPUT_BOOLEAN_YN,
271 &ConfigFileEntry.global_snotices,
272 "Send out certain server notices globally"
273 },
274 {
275 "hide_error_messages",
276 OUTPUT_BOOLEAN2,
277 &ConfigFileEntry.hide_error_messages,
278 "Hide ERROR messages coming from servers"
279 },
280 {
281 "hide_spoof_ips",
282 OUTPUT_BOOLEAN_YN,
283 &ConfigFileEntry.hide_spoof_ips,
284 "Hide IPs of spoofed users"
285 },
286 {
287 "hub",
288 OUTPUT_BOOLEAN_YN,
289 &ServerInfo.hub,
290 "Server is a hub"
291 },
292 {
293 "kline_delay",
294 OUTPUT_DECIMAL,
295 &ConfigFileEntry.kline_delay,
296 "Duration of time to delay kline checking"
297 },
298 {
299 "kline_reason",
300 OUTPUT_STRING,
301 &ConfigFileEntry.kline_reason,
302 "K-lined clients sign off with this reason"
303 },
304 {
305 "dline_with_reason",
306 OUTPUT_BOOLEAN_YN,
307 &ConfigFileEntry.dline_with_reason,
308 "Display D-line reason to client on disconnect"
309 },
310 {
311 "kline_with_reason",
312 OUTPUT_BOOLEAN_YN,
313 &ConfigFileEntry.kline_with_reason,
314 "Display K-line reason to client on disconnect"
315 },
316 {
317 "max_accept",
318 OUTPUT_DECIMAL,
319 &ConfigFileEntry.max_accept,
320 "Maximum nicknames on accept list",
321 },
322 {
323 "max_nick_changes",
324 OUTPUT_DECIMAL,
325 &ConfigFileEntry.max_nick_changes,
326 "NICK change threshhold setting"
327 },
328 {
329 "max_nick_time",
330 OUTPUT_DECIMAL,
331 &ConfigFileEntry.max_nick_time,
332 "NICK flood protection time interval"
333 },
334 {
335 "max_targets",
336 OUTPUT_DECIMAL,
337 &ConfigFileEntry.max_targets,
338 "The maximum number of PRIVMSG/NOTICE targets"
339 },
340 {
341 "min_nonwildcard",
342 OUTPUT_DECIMAL,
343 &ConfigFileEntry.min_nonwildcard,
344 "Minimum non-wildcard chars in K lines",
345 },
346 {
347 "min_nonwildcard_simple",
348 OUTPUT_DECIMAL,
349 &ConfigFileEntry.min_nonwildcard_simple,
350 "Minimum non-wildcard chars in xlines/resvs",
351 },
352 {
353 "network_name",
354 OUTPUT_STRING,
355 &ServerInfo.network_name,
356 "Network name"
357 },
358 {
359 "network_desc",
360 OUTPUT_STRING,
361 &ServerInfo.network_desc,
362 "Network description"
363 },
364 {
365 "autochanmodes",
366 OUTPUT_STRING,
367 &ConfigChannel.autochanmodes,
368 "Channelmodes set on channel creation"
369 },
370 {
371 "exemptchanops",
372 OUTPUT_STRING,
373 &ConfigChannel.exemptchanops,
374 "Channelmodes that chanops are exempt from"
375 },
376 {
377 "nick_delay",
378 OUTPUT_DECIMAL,
379 &ConfigFileEntry.nick_delay,
380 "Delay nicks are locked for on split",
381 },
382 {
383 "no_oper_flood",
384 OUTPUT_BOOLEAN,
385 &ConfigFileEntry.no_oper_flood,
386 "Disable flood control for operators",
387 },
388 {
389 "true_no_oper_flood",
390 OUTPUT_BOOLEAN,
391 &ConfigFileEntry.true_no_oper_flood,
392 "Really disable flood control for opers, not just make it very high",
393 },
394 {
395 "non_redundant_klines",
396 OUTPUT_BOOLEAN,
397 &ConfigFileEntry.non_redundant_klines,
398 "Check for and disallow redundant K-lines"
399 },
400 {
401 "operspy_admin_only",
402 OUTPUT_BOOLEAN,
403 &ConfigFileEntry.operspy_admin_only,
404 "Send +Z operspy notices to admins only"
405 },
406 {
407 "operspy_dont_care_user_info",
408 OUTPUT_BOOLEAN,
409 &ConfigFileEntry.operspy_dont_care_user_info,
410 "Remove accountability and some '!' requirement from non-channel operspy"
411 },
412 {
413 "secret_channels_in_whois",
414 OUTPUT_BOOLEAN,
415 &ConfigFileEntry.secret_channels_in_whois,
416 "Defines whether secret channels are always shown in whois to opers with oper:spy priv."
417 },
418 {
419 "pace_wait",
420 OUTPUT_DECIMAL,
421 &ConfigFileEntry.pace_wait,
422 "Minimum delay between uses of certain commands"
423 },
424 {
425 "pace_wait_simple",
426 OUTPUT_DECIMAL,
427 &ConfigFileEntry.pace_wait_simple,
428 "Minimum delay between less intensive commands"
429 },
430 {
431 "ping_cookie",
432 OUTPUT_BOOLEAN,
433 &ConfigFileEntry.ping_cookie,
434 "Require ping cookies to connect",
435 },
436 {
437 "reject_after_count",
438 OUTPUT_DECIMAL,
439 &ConfigFileEntry.reject_after_count,
440 "Client rejection threshold setting",
441 },
442 {
443 "reject_ban_time",
444 OUTPUT_DECIMAL,
445 &ConfigFileEntry.reject_ban_time,
446 "Client rejection time interval",
447 },
448 {
449 "reject_duration",
450 OUTPUT_DECIMAL,
451 &ConfigFileEntry.reject_duration,
452 "Client rejection cache duration",
453 },
454 {
455 "short_motd",
456 OUTPUT_BOOLEAN_YN,
457 &ConfigFileEntry.short_motd,
458 "Do not show MOTD; only tell clients they should read it"
459 },
460 {
461 "stats_e_disabled",
462 OUTPUT_BOOLEAN_YN,
463 &ConfigFileEntry.stats_e_disabled,
464 "STATS e output is disabled",
465 },
466 {
467 "stats_c_oper_only",
468 OUTPUT_BOOLEAN_YN,
469 &ConfigFileEntry.stats_c_oper_only,
470 "STATS C output is only shown to operators",
471 },
472 {
473 "stats_h_oper_only",
474 OUTPUT_BOOLEAN_YN,
475 &ConfigFileEntry.stats_h_oper_only,
476 "STATS H output is only shown to operators",
477 },
478 {
479 "stats_i_oper_only",
480 OUTPUT_BOOLEAN2,
481 &ConfigFileEntry.stats_i_oper_only,
482 "STATS I output is only shown to operators",
483 },
484 {
485 "stats_k_oper_only",
486 OUTPUT_BOOLEAN2,
487 &ConfigFileEntry.stats_k_oper_only,
488 "STATS K output is only shown to operators",
489 },
490 {
491 "stats_o_oper_only",
492 OUTPUT_BOOLEAN_YN,
493 &ConfigFileEntry.stats_o_oper_only,
494 "STATS O output is only shown to operators",
495 },
496 {
497 "stats_P_oper_only",
498 OUTPUT_BOOLEAN_YN,
499 &ConfigFileEntry.stats_P_oper_only,
500 "STATS P is only shown to operators",
501 },
502 {
503 "stats_y_oper_only",
504 OUTPUT_BOOLEAN_YN,
505 &ConfigFileEntry.stats_y_oper_only,
506 "STATS Y is only shown to operators",
507 },
508 {
509 "throttle_count",
510 OUTPUT_DECIMAL,
511 &ConfigFileEntry.throttle_count,
512 "Connection throttle threshold",
513 },
514 {
515 "throttle_duration",
516 OUTPUT_DECIMAL,
517 &ConfigFileEntry.throttle_duration,
518 "Connection throttle duration",
519 },
520 {
521 "tkline_expire_notices",
522 OUTPUT_BOOLEAN,
523 &ConfigFileEntry.tkline_expire_notices,
524 "Notices given to opers when tklines expire"
525 },
526 {
527 "ts_max_delta",
528 OUTPUT_DECIMAL,
529 &ConfigFileEntry.ts_max_delta,
530 "Maximum permitted TS delta from another server"
531 },
532 {
533 "ts_warn_delta",
534 OUTPUT_DECIMAL,
535 &ConfigFileEntry.ts_warn_delta,
536 "Maximum permitted TS delta before displaying a warning"
537 },
538 {
539 "warn_no_nline",
540 OUTPUT_BOOLEAN,
541 &ConfigFileEntry.warn_no_nline,
542 "Display warning if connecting server lacks N-line"
543 },
544 {
545 "use_propagated_bans",
546 OUTPUT_BOOLEAN,
547 &ConfigFileEntry.use_propagated_bans,
548 "KLINE sets fully propagated bans"
549 },
550 {
551 "default_split_server_count",
552 OUTPUT_DECIMAL,
553 &ConfigChannel.default_split_server_count,
554 "Startup value of SPLITNUM",
555 },
556 {
557 "default_split_user_count",
558 OUTPUT_DECIMAL,
559 &ConfigChannel.default_split_user_count,
560 "Startup value of SPLITUSERS",
561 },
562 {
563 "knock_delay",
564 OUTPUT_DECIMAL,
565 &ConfigChannel.knock_delay,
566 "Delay between a users KNOCK attempts"
567 },
568 {
569 "knock_delay_channel",
570 OUTPUT_DECIMAL,
571 &ConfigChannel.knock_delay_channel,
572 "Delay between KNOCK attempts to a channel",
573 },
574 {
575 "kick_on_split_riding",
576 OUTPUT_BOOLEAN_YN,
577 &ConfigChannel.kick_on_split_riding,
578 "Kick users riding splits to join +i or +k channels"
579 },
580 {
581 "max_bans",
582 OUTPUT_DECIMAL,
583 &ConfigChannel.max_bans,
584 "Total +b/e/I/q modes allowed in a channel",
585 },
586 {
587 "max_bans_large",
588 OUTPUT_DECIMAL,
589 &ConfigChannel.max_bans_large,
590 "Total +b/e/I/q modes allowed in a +L channel",
591 },
592 {
593 "max_chans_per_user",
594 OUTPUT_DECIMAL,
595 &ConfigChannel.max_chans_per_user,
596 "Maximum number of channels a user can join",
597 },
598 {
599 "no_create_on_split",
600 OUTPUT_BOOLEAN_YN,
601 &ConfigChannel.no_create_on_split,
602 "Disallow creation of channels when split",
603 },
604 {
605 "no_join_on_split",
606 OUTPUT_BOOLEAN_YN,
607 &ConfigChannel.no_join_on_split,
608 "Disallow joining channels when split",
609 },
610 {
611 "only_ascii_channels",
612 OUTPUT_BOOLEAN_YN,
613 &ConfigChannel.only_ascii_channels,
614 "Controls whether non-ASCII is disabled for JOIN"
615 },
616 {
617 "cycle_host_change",
618 OUTPUT_BOOLEAN_YN,
619 &ConfigChannel.cycle_host_change,
620 "Controls if when a users' host changes, they cycle channels",
621 },
622 {
623 "host_in_topic",
624 OUTPUT_BOOLEAN_YN,
625 &ConfigChannel.host_in_topic,
626 "Defines whether a topicsetters host or just nick is shown on TOPIC",
627 },
628 {
629 "admin_on_channel_create",
630 OUTPUT_BOOLEAN_YN,
631 &ConfigChannel.admin_on_channel_create,
632 "Give users +ao on channel create",
633 },
634 {
635 "use_halfop",
636 OUTPUT_BOOLEAN_YN,
637 &ConfigChannel.use_halfop,
638 "Enable chanmode +h (halfop)",
639 },
640 {
641 "use_admin",
642 OUTPUT_BOOLEAN_YN,
643 &ConfigChannel.use_admin,
644 "Enable chanmode +a (admin)",
645 },
646 {
647 "use_except",
648 OUTPUT_BOOLEAN_YN,
649 &ConfigChannel.use_except,
650 "Enable chanmode +e (ban exceptions)",
651 },
652 {
653 "use_invex",
654 OUTPUT_BOOLEAN_YN,
655 &ConfigChannel.use_invex,
656 "Enable chanmode +I (invite exceptions)",
657 },
658 {
659 "use_forward",
660 OUTPUT_BOOLEAN_YN,
661 &ConfigChannel.use_forward,
662 "Enable chanmode +f (channel forwarding)",
663 },
664 {
665 "use_knock",
666 OUTPUT_BOOLEAN_YN,
667 &ConfigChannel.use_knock,
668 "Enable /KNOCK",
669 },
670 {
671 "use_local_channels",
672 OUTPUT_BOOLEAN_YN,
673 &ConfigChannel.use_local_channels,
674 "Enable local channels (&channels)"
675 },
676 {
677 "resv_forcepart",
678 OUTPUT_BOOLEAN_YN,
679 &ConfigChannel.resv_forcepart,
680 "Force-part local users on channel RESV"
681 },
682 {
683 "disable_hidden",
684 OUTPUT_BOOLEAN_YN,
685 &ConfigServerHide.disable_hidden,
686 "Prevent servers from hiding themselves from a flattened /links",
687 },
688 {
689 "flatten_links",
690 OUTPUT_BOOLEAN_YN,
691 &ConfigServerHide.flatten_links,
692 "Flatten /links list",
693 },
694 {
695 "hidden",
696 OUTPUT_BOOLEAN_YN,
697 &ConfigServerHide.hidden,
698 "Hide this server from a flattened /links on remote servers",
699 },
700 {
701 "links_delay",
702 OUTPUT_DECIMAL,
703 &ConfigServerHide.links_delay,
704 "Links rehash delay"
705 },
706 /* --[ END OF TABLE ]---------------------------------------------- */
707 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
708 };
709 /* *INDENT-ON* */
710
711 /*
712 ** m_info
713 ** parv[1] = servername
714 */
715 static int
716 m_info(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
717 {
718 static time_t last_used = 0L;
719
720 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
721 {
722 /* safe enough to give this on a local connect only */
723 sendto_one(source_p, form_str(RPL_LOAD2HI),
724 me.name, source_p->name, "INFO");
725 sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO));
726 return 0;
727 }
728 else
729 last_used = rb_current_time();
730
731 if(hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME)
732 return 0;
733
734 info_spy(source_p);
735
736 send_info_text(source_p);
737 send_birthdate_online_time(source_p);
738
739 sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO));
740 return 0;
741 }
742
743 /*
744 ** mo_info
745 ** parv[1] = servername
746 */
747 static int
748 mo_info(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
749 {
750 if(hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME)
751 {
752 info_spy(source_p);
753 send_info_text(source_p);
754
755 if(IsOper(source_p))
756 {
757 send_conf_options(source_p);
758 sendto_one_numeric(source_p, RPL_INFO, ":%s",
759 rb_lib_version());
760 }
761
762 send_birthdate_online_time(source_p);
763
764 sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO));
765 }
766
767 return 0;
768 }
769
770 /*
771 * send_info_text
772 *
773 * inputs - client pointer to send info text to
774 * output - none
775 * side effects - info text is sent to client
776 */
777 static void
778 send_info_text(struct Client *source_p)
779 {
780 const char **text = infotext;
781
782 while (*text)
783 {
784 sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), *text++);
785 }
786
787 sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), "");
788 }
789
790 /*
791 * send_birthdate_online_time
792 *
793 * inputs - client pointer to send to
794 * output - none
795 * side effects - birthdate and online time are sent
796 */
797 static void
798 send_birthdate_online_time(struct Client *source_p)
799 {
800 char tbuf[26]; /* this needs to be 26 - see ctime_r manpage */
801 sendto_one(source_p, ":%s %d %s :Birth Date: %s, compile # %s",
802 get_id(&me, source_p), RPL_INFO,
803 get_id(source_p, source_p), creation, generation);
804
805 sendto_one(source_p, ":%s %d %s :On-line since %s",
806 get_id(&me, source_p), RPL_INFO,
807 get_id(source_p, source_p), rb_ctime(startup_time, tbuf, sizeof(tbuf)));
808 }
809
810 /*
811 * send_conf_options
812 *
813 * inputs - client pointer to send to
814 * output - none
815 * side effects - send config options to client
816 */
817 static void
818 send_conf_options(struct Client *source_p)
819 {
820 Info *infoptr;
821 int i = 0;
822
823 /*
824 * Now send them a list of all our configuration options
825 * (mostly from config.h)
826 */
827 for (infoptr = MyInformation; infoptr->name; infoptr++)
828 {
829 if(infoptr->intvalue)
830 {
831 sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
832 get_id(&me, source_p), RPL_INFO,
833 get_id(source_p, source_p),
834 infoptr->name, infoptr->intvalue,
835 infoptr->desc);
836 }
837 else
838 {
839 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
840 get_id(&me, source_p), RPL_INFO,
841 get_id(source_p, source_p),
842 infoptr->name, infoptr->strvalue,
843 infoptr->desc);
844 }
845 }
846
847 /*
848 * Parse the info_table[] and do the magic.
849 */
850 for (i = 0; info_table[i].name; i++)
851 {
852 switch (info_table[i].output_type)
853 {
854 /*
855 * For "char *" references
856 */
857 case OUTPUT_STRING:
858 {
859 char *option = *((char **) info_table[i].option);
860
861 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
862 get_id(&me, source_p), RPL_INFO,
863 get_id(source_p, source_p),
864 info_table[i].name,
865 option ? option : "NONE",
866 info_table[i].desc ? info_table[i].desc : "<none>");
867
868 break;
869 }
870 /*
871 * For "char foo[]" references
872 */
873 case OUTPUT_STRING_PTR:
874 {
875 char *option = (char *) info_table[i].option;
876
877 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
878 get_id(&me, source_p), RPL_INFO,
879 get_id(source_p, source_p),
880 info_table[i].name,
881 EmptyString(option) ? "NONE" : option,
882 info_table[i].desc ? info_table[i].desc : "<none>");
883
884 break;
885 }
886 /*
887 * Output info_table[i].option as a decimal value.
888 */
889 case OUTPUT_DECIMAL:
890 {
891 int option = *((int *) info_table[i].option);
892
893 sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
894 get_id(&me, source_p), RPL_INFO,
895 get_id(source_p, source_p),
896 info_table[i].name,
897 option,
898 info_table[i].desc ? info_table[i].desc : "<none>");
899
900 break;
901 }
902
903 /*
904 * Output info_table[i].option as "ON" or "OFF"
905 */
906 case OUTPUT_BOOLEAN:
907 {
908 int option = *((int *) info_table[i].option);
909
910 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
911 get_id(&me, source_p), RPL_INFO,
912 get_id(source_p, source_p),
913 info_table[i].name,
914 option ? "ON" : "OFF",
915 info_table[i].desc ? info_table[i].desc : "<none>");
916
917 break;
918 }
919 /*
920 * Output info_table[i].option as "YES" or "NO"
921 */
922 case OUTPUT_BOOLEAN_YN:
923 {
924 int option = *((int *) info_table[i].option);
925
926 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
927 get_id(&me, source_p), RPL_INFO,
928 get_id(source_p, source_p),
929 info_table[i].name,
930 option ? "YES" : "NO",
931 info_table[i].desc ? info_table[i].desc : "<none>");
932
933 break;
934 }
935
936 case OUTPUT_BOOLEAN2:
937 {
938 int option = *((int *) info_table[i].option);
939
940 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
941 me.name, RPL_INFO, source_p->name,
942 info_table[i].name,
943 option ? ((option == 1) ? "MASK" : "YES") : "NO",
944 info_table[i].desc ? info_table[i].desc : "<none>");
945 } /* switch (info_table[i].output_type) */
946 }
947 } /* forloop */
948
949
950 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
951 ** in order for it to show up properly to opers who issue INFO
952 */
953
954 sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), "");
955 }
956
957 /* info_spy()
958 *
959 * input - pointer to client
960 * output - none
961 * side effects - hook doing_info is called
962 */
963 static void
964 info_spy(struct Client *source_p)
965 {
966 hook_data hd;
967
968 hd.client = source_p;
969 hd.arg1 = hd.arg2 = NULL;
970
971 call_hook(doing_info_hook, &hd);
972 }