]> jfr.im git - irc/rqf/shadowircd.git/blob - extensions/m_findforwards.c
Disallow mIRC italics in channel names when disable_fake_channels
[irc/rqf/shadowircd.git] / extensions / m_findforwards.c
1 /*
2 * IRC - Internet Relay Chat, contrib/m_findforwards.c
3 * Copyright (C) 2002 Hybrid Development Team
4 * Copyright (C) 2004 ircd-ratbox Development Team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 1, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21 #include "stdinc.h"
22 #include "channel.h"
23 #include "client.h"
24 #include "hash.h"
25 #include "match.h"
26 #include "ircd.h"
27 #include "numeric.h"
28 #include "s_user.h"
29 #include "s_conf.h"
30 #include "s_newconf.h"
31 #include "send.h"
32 #include "msg.h"
33 #include "parse.h"
34 #include "modules.h"
35 #include "packet.h"
36
37 static int m_findforwards(struct Client *client_p, struct Client *source_p,
38 int parc, const char *parv[]);
39
40 struct Message findforwards_msgtab = {
41 "FINDFORWARDS", 0, 0, 0, MFLG_SLOW,
42 {mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}}
43 };
44
45 mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL };
46
47 DECLARE_MODULE_AV1(findforwards, NULL, NULL, findforwards_clist, NULL, NULL, "$Revision: 986 $");
48
49 /*
50 ** mo_findforwards
51 ** parv[1] = channel
52 */
53 static int
54 m_findforwards(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
55 {
56 static time_t last_used = 0;
57 struct Channel *chptr;
58 struct membership *msptr;
59 rb_dlink_node *ptr;
60 char buf[414];
61 char *p = buf, *end = buf + sizeof buf - 1;
62 *p = '\0';
63
64 /* Allow ircops to search for forwards to nonexistent channels */
65 if(!IsOper(source_p))
66 {
67 if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL)
68 {
69 sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
70 form_str(ERR_NOTONCHANNEL), parv[1]);
71 return 0;
72 }
73
74 if(!is_any_op(msptr))
75 {
76 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
77 me.name, source_p->name, parv[1]);
78 return 0;
79 }
80
81 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
82 {
83 sendto_one(source_p, form_str(RPL_LOAD2HI),
84 me.name, source_p->name, "FINDFORWARDS");
85 return 0;
86 }
87 else
88 last_used = rb_current_time();
89 }
90
91 RB_DLINK_FOREACH(ptr, global_channel_list.head)
92 {
93 chptr = ptr->data;
94 if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1]))
95 {
96 if(p + strlen(chptr->chname) >= end - 13)
97 {
98 strcpy(p, "<truncated> ");
99 p += 12;
100 break;
101 }
102 strcpy(p, chptr->chname);
103 p += strlen(chptr->chname);
104 *p++ = ' ';
105 }
106 }
107
108 if(buf[0])
109 *(--p) = '\0';
110
111 sendto_one_notice(source_p, ":Forwards for %s: %s", parv[1], buf);
112
113 return 0;
114 }