ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_testmask.c
Revision: 1121
Committed: Sun Jan 9 11:03:03 2011 UTC (14 years, 7 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.3/modules/m_testmask.c
File size: 3937 byte(s)
Log Message:
- removed all instances of STATIC_MODULES since we don't have
  static modules anymore
- removed m_mkpasswd module from contrib

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 "handlers.h"
37     #include "client.h"
38     #include "common.h"
39     #include "irc_string.h"
40     #include "ircd_defs.h"
41     #include "ircd.h"
42     #include "restart.h"
43     #include "s_conf.h"
44     #include "send.h"
45     #include "msg.h"
46     #include "hostmask.h"
47     #include "numeric.h"
48     #include "parse.h"
49     #include "modules.h"
50    
51     static void mo_testmask(struct Client *, struct Client *, int, char *[]);
52    
53     struct Message testmask_msgtab = {
54     "TESTMASK", 0, 0, 0, 0, MFLG_SLOW, 0,
55     {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testmask, m_ignore}
56     };
57    
58     void
59     _modinit(void)
60     {
61     mod_add_cmd(&testmask_msgtab);
62     }
63    
64     void
65     _moddeinit(void)
66     {
67     mod_del_cmd(&testmask_msgtab);
68     }
69    
70 knight 31 const char *_version = "$Revision$";
71 adx 30
72     /* mo_testmask()
73     *
74     * inputs - pointer to physical connection request is coming from
75     * - pointer to source connection request is coming from
76     * - parc arg count
77     * - parv actual arguments
78     * output - NONE
79     * side effects - count up clients matching mask
80     * i.e. /quote testmask user@host
81     */
82     static void
83     mo_testmask(struct Client *client_p, struct Client *source_p,
84     int parc, char *parv[])
85     {
86 michael 808 struct split_nuh_item nuh;
87     char given_nick[IRCD_BUFSIZE];
88     char given_user[IRCD_BUFSIZE];
89     char given_host[IRCD_BUFSIZE];
90     unsigned int count[2] = { 0, 0 };
91     const dlink_node *ptr = NULL;
92 adx 30
93 michael 808 if (EmptyString(parv[1]))
94 adx 30 {
95 michael 808 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
96     me.name, source_p->name, "TESTMASK");
97 adx 30 return;
98     }
99    
100 michael 808 nuh.nuhmask = parv[1];
101     nuh.nickptr = given_nick;
102     nuh.userptr = given_user;
103     nuh.hostptr = given_host;
104 adx 30
105 michael 808 nuh.nicksize = sizeof(given_nick);
106     nuh.usersize = sizeof(given_user);
107     nuh.hostsize = sizeof(given_host);
108    
109     split_nuh(&nuh);
110    
111     DLINK_FOREACH(ptr, global_client_list.head)
112 adx 30 {
113 michael 808 const struct Client *target_p = ptr->data;
114 adx 30
115 michael 816 if (!IsClient(target_p) || !match(given_nick, target_p->name))
116 adx 30 continue;
117    
118 michael 808 if (match(given_user, target_p->username))
119     if (match(given_host, target_p->host) || match(given_host, target_p->sockhost))
120     ++count[!MyConnect(target_p)];
121 adx 30 }
122    
123 michael 808 sendto_one(source_p, form_str(RPL_TESTMASK), me.name,
124     source_p->name,
125     given_nick, given_user,
126     given_host, count[0], count[1]);
127 adx 30 }

Properties

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