ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_motd.c
Revision: 470
Committed: Fri Feb 17 05:07:43 2006 UTC (18 years, 2 months ago) by db
Content type: text/x-csrc
File size: 3707 byte(s)
Log Message:
- fix compile errors with moved modules.h
- fix a few missing includes, msg.h and parse.h


File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_motd.c: Shows the current message of the day.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "client.h"
27 #include "motd.h"
28 #include "ircd.h"
29 #include "send.h"
30 #include "numeric.h"
31 #include "handlers.h"
32 #include "msg.h"
33 #include "s_serv.h" /* hunt_server */
34 #include "parse.h"
35 #include "conf/modules.h"
36 #include "s_conf.h"
37
38 static void mr_motd(struct Client *, struct Client *, int, char **);
39 static void m_motd(struct Client*, struct Client*, int, char**);
40 static void mo_motd(struct Client*, struct Client*, int, char**);
41
42 /*
43 * note regarding mo_motd being used twice:
44 * this is not a kludge. any rate limiting, shide, or whatever
45 * other access restrictions should be done by the source's server.
46 * for security's sake, still check that the source is an oper
47 * for 'oper only' information in the mo_ function(s).
48 */
49 struct Message motd_msgtab = {
50 "MOTD", 0, 0, 0, 1, MFLG_SLOW, 0,
51 {mr_motd, m_motd, mo_motd, m_ignore, mo_motd, m_ignore}
52 };
53
54 static struct Callback *motd_cb;
55
56 static void *
57 do_motd(va_list args)
58 {
59 struct Client *source_p = va_arg(args, struct Client *);
60
61 send_message_file(source_p, &ConfigFileEntry.motd);
62 return NULL;
63 }
64
65 INIT_MODULE(m_motd, "$Revision$")
66 {
67 motd_cb = register_callback("doing_motd", do_motd);
68 mod_add_cmd(&motd_msgtab);
69 }
70
71 CLEANUP_MODULE
72 {
73 mod_del_cmd(&motd_msgtab);
74 uninstall_hook(motd_cb, do_motd);
75 }
76
77 /* mr_motd()
78 *
79 * parv[0] = sender prefix
80 */
81 static void
82 mr_motd(struct Client *client_p, struct Client *source_p,
83 int parc, char *parv[])
84 {
85 /* allow unregistered clients to see the motd, but exit them */
86 send_message_file(source_p, &ConfigFileEntry.motd);
87 exit_client(source_p, source_p, "Client Exit after MOTD");
88 }
89
90 /*
91 ** m_motd
92 ** parv[0] = sender prefix
93 ** parv[1] = servername
94 */
95 static void
96 m_motd(struct Client *client_p, struct Client *source_p,
97 int parc, char *parv[])
98 {
99 static time_t last_used = 0;
100
101 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
102 {
103 /* safe enough to give this on a local connect only */
104 sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name);
105 return;
106 }
107 else
108 last_used = CurrentTime;
109
110 /* This is safe enough to use during non hidden server mode */
111 if (!ConfigFileEntry.disable_remote && !ConfigServerHide.hide_servers)
112 {
113 if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1,parc,parv)!=HUNTED_ISME)
114 return;
115 }
116
117 execute_callback(motd_cb, source_p, parc, parv);
118 }
119
120 /*
121 ** mo_motd
122 ** parv[0] = sender prefix
123 ** parv[1] = servername
124 */
125 static void
126 mo_motd(struct Client *client_p, struct Client *source_p,
127 int parc, char *parv[])
128 {
129 if (!IsClient(source_p))
130 return;
131
132 if (hunt_server(client_p, source_p, ":%s MOTD :%s",1,parc,parv)!=HUNTED_ISME)
133 return;
134
135 execute_callback(motd_cb, source_p, parc, parv);
136 }

Properties

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