ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_testmask.c
Revision: 1652
Committed: Tue Nov 13 20:28:53 2012 UTC (13 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 3998 byte(s)
Log Message:
- changed match() polarity. match() now returns 0 on match and 1 on non-match
  This cleans up several places where function pointers of different matching
  functions like irccmp/strcmp/match are passed to other functions.
- added improved collapse() to match.c

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_testmask.c: Counts the birdies err local and remote clients.
4     *
5     * Copyright (C) 2005 by Diane Bruce
6     * Coypright (C) 2005 ircd-hybrid team
7     *
8     * Redistribution and use in source and binary forms, with or without
9     * modification, are permitted provided that the following conditions are
10     * met:
11     *
12     * 1.Redistributions of source code must retain the above copyright notice,
13     * this list of conditions and the following disclaimer.
14     * 2.Redistributions in binary form must reproduce the above copyright
15     * notice, this list of conditions and the following disclaimer in the
16     * documentation and/or other materials provided with the distribution.
17     * 3.The name of the author may not be used to endorse or promote products
18     * derived from this software without specific prior written permission.
19     *
20     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23     * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24     * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26     * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28     * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29     * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30     * POSSIBILITY OF SUCH DAMAGE.
31     *
32 knight 31 * $Id$
33 adx 30 */
34    
35     #include "stdinc.h"
36     #include "client.h"
37     #include "irc_string.h"
38     #include "ircd_defs.h"
39     #include "ircd.h"
40     #include "restart.h"
41 michael 1309 #include "conf.h"
42 adx 30 #include "send.h"
43     #include "hostmask.h"
44     #include "numeric.h"
45     #include "parse.h"
46     #include "modules.h"
47    
48    
49     /* mo_testmask()
50     *
51     * inputs - pointer to physical connection request is coming from
52     * - pointer to source connection request is coming from
53     * - parc arg count
54     * - parv actual arguments
55     * output - NONE
56     * side effects - count up clients matching mask
57     * i.e. /quote testmask user@host
58     */
59     static void
60     mo_testmask(struct Client *client_p, struct Client *source_p,
61     int parc, char *parv[])
62     {
63 michael 808 struct split_nuh_item nuh;
64     char given_nick[IRCD_BUFSIZE];
65     char given_user[IRCD_BUFSIZE];
66     char given_host[IRCD_BUFSIZE];
67     unsigned int count[2] = { 0, 0 };
68     const dlink_node *ptr = NULL;
69 adx 30
70 michael 808 if (EmptyString(parv[1]))
71 adx 30 {
72 michael 808 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
73     me.name, source_p->name, "TESTMASK");
74 adx 30 return;
75     }
76    
77 michael 808 nuh.nuhmask = parv[1];
78     nuh.nickptr = given_nick;
79     nuh.userptr = given_user;
80     nuh.hostptr = given_host;
81 adx 30
82 michael 808 nuh.nicksize = sizeof(given_nick);
83     nuh.usersize = sizeof(given_user);
84     nuh.hostsize = sizeof(given_host);
85    
86     split_nuh(&nuh);
87    
88     DLINK_FOREACH(ptr, global_client_list.head)
89 adx 30 {
90 michael 808 const struct Client *target_p = ptr->data;
91 adx 30
92 michael 1652 if (!IsClient(target_p) || match(given_nick, target_p->name))
93 adx 30 continue;
94    
95 michael 1652 if (!match(given_user, target_p->username))
96     if (!match(given_host, target_p->host) || !match(given_host, target_p->sockhost))
97 michael 808 ++count[!MyConnect(target_p)];
98 adx 30 }
99    
100 michael 808 sendto_one(source_p, form_str(RPL_TESTMASK), me.name,
101     source_p->name,
102     given_nick, given_user,
103     given_host, count[0], count[1]);
104 adx 30 }
105 michael 1230
106     static struct Message testmask_msgtab = {
107     "TESTMASK", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
108     {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testmask, m_ignore}
109     };
110    
111     static void
112     module_init(void)
113     {
114     mod_add_cmd(&testmask_msgtab);
115     }
116    
117     static void
118     module_exit(void)
119     {
120     mod_del_cmd(&testmask_msgtab);
121     }
122    
123     struct module module_entry = {
124     .node = { NULL, NULL, NULL },
125     .name = NULL,
126     .version = "$Revision$",
127     .handle = NULL,
128     .modinit = module_init,
129     .modexit = module_exit,
130     .flags = 0
131     };

Properties

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