ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_testmask.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (14 years, 10 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_testmask.c
File size: 4057 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

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    
52     /* mo_testmask()
53     *
54     * inputs - pointer to physical connection request is coming from
55     * - pointer to source connection request is coming from
56     * - parc arg count
57     * - parv actual arguments
58     * output - NONE
59     * side effects - count up clients matching mask
60     * i.e. /quote testmask user@host
61     */
62     static void
63     mo_testmask(struct Client *client_p, struct Client *source_p,
64     int parc, char *parv[])
65     {
66 michael 808 struct split_nuh_item nuh;
67     char given_nick[IRCD_BUFSIZE];
68     char given_user[IRCD_BUFSIZE];
69     char given_host[IRCD_BUFSIZE];
70     unsigned int count[2] = { 0, 0 };
71     const dlink_node *ptr = NULL;
72 adx 30
73 michael 808 if (EmptyString(parv[1]))
74 adx 30 {
75 michael 808 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
76     me.name, source_p->name, "TESTMASK");
77 adx 30 return;
78     }
79    
80 michael 808 nuh.nuhmask = parv[1];
81     nuh.nickptr = given_nick;
82     nuh.userptr = given_user;
83     nuh.hostptr = given_host;
84 adx 30
85 michael 808 nuh.nicksize = sizeof(given_nick);
86     nuh.usersize = sizeof(given_user);
87     nuh.hostsize = sizeof(given_host);
88    
89     split_nuh(&nuh);
90    
91     DLINK_FOREACH(ptr, global_client_list.head)
92 adx 30 {
93 michael 808 const struct Client *target_p = ptr->data;
94 adx 30
95 michael 816 if (!IsClient(target_p) || !match(given_nick, target_p->name))
96 adx 30 continue;
97    
98 michael 808 if (match(given_user, target_p->username))
99     if (match(given_host, target_p->host) || match(given_host, target_p->sockhost))
100     ++count[!MyConnect(target_p)];
101 adx 30 }
102    
103 michael 808 sendto_one(source_p, form_str(RPL_TESTMASK), me.name,
104     source_p->name,
105     given_nick, given_user,
106     given_host, count[0], count[1]);
107 adx 30 }
108 michael 1230
109     static struct Message testmask_msgtab = {
110     "TESTMASK", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
111     {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testmask, m_ignore}
112     };
113    
114     static void
115     module_init(void)
116     {
117     mod_add_cmd(&testmask_msgtab);
118     }
119    
120     static void
121     module_exit(void)
122     {
123     mod_del_cmd(&testmask_msgtab);
124     }
125    
126     struct module module_entry = {
127     .node = { NULL, NULL, NULL },
128     .name = NULL,
129     .version = "$Revision$",
130     .handle = NULL,
131     .modinit = module_init,
132     .modexit = module_exit,
133     .flags = 0
134     };

Properties

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