2 * IRC - Internet Relay Chat, contrib/m_findforwards.c
3 * Copyright (C) 2002 Hybrid Development Team
4 * Copyright (C) 2004 ircd-ratbox Development Team
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)
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.
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.
20 * $Id: m_findforwards.c 986 2006-03-08 00:10:46Z jilles $
31 #include "s_newconf.h"
38 static int m_findforwards(struct Client
*client_p
, struct Client
*source_p
,
39 int parc
, const char *parv
[]);
41 struct Message findforwards_msgtab
= {
42 "FINDFORWARDS", 0, 0, 0, MFLG_SLOW
,
43 {mg_unreg
, {m_findforwards
, 2}, mg_ignore
, mg_ignore
, mg_ignore
, {m_findforwards
, 2}}
46 mapi_clist_av1 findforwards_clist
[] = { &findforwards_msgtab
, NULL
};
48 DECLARE_MODULE_AV1(findforwards
, NULL
, NULL
, findforwards_clist
, NULL
, NULL
, "$Revision: 986 $");
52 ** parv[0] = sender prefix
56 m_findforwards(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
58 static time_t last_used
= 0;
59 struct Channel
*chptr
;
60 struct membership
*msptr
;
63 char *p
= buf
, *end
= buf
+ sizeof buf
- 1;
66 /* Allow ircops to search for forwards to nonexistent channels */
69 if((chptr
= find_channel(parv
[1])) == NULL
|| (msptr
= find_channel_membership(chptr
, source_p
)) == NULL
)
71 sendto_one_numeric(source_p
, ERR_NOTONCHANNEL
,
72 form_str(ERR_NOTONCHANNEL
), parv
[1]);
78 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
79 me
.name
, source_p
->name
, parv
[1]);
83 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
85 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
86 me
.name
, source_p
->name
, "FINDFORWARDS");
90 last_used
= rb_current_time();
93 RB_DLINK_FOREACH(ptr
, global_channel_list
.head
)
96 if(chptr
->mode
.forward
&& !irccmp(chptr
->mode
.forward
, parv
[1]))
98 if(p
+ strlen(chptr
->chname
) >= end
- 13)
100 strcpy(p
, "<truncated> ");
104 strcpy(p
, chptr
->chname
);
105 p
+= strlen(chptr
->chname
);
113 sendto_one_notice(source_p
, ":Forwards for %s: %s", parv
[1], buf
);