ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_testmask.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 3645 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


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 "ircd_defs.h"
40     #include "ircd.h"
41     #include "restart.h"
42     #include "s_conf.h"
43     #include "send.h"
44     #include "msg.h"
45     #include "hostmask.h"
46     #include "numeric.h"
47     #include "parse.h"
48     #include "modules.h"
49    
50     static void mo_testmask(struct Client *, struct Client *, int, char *[]);
51    
52     struct Message testmask_msgtab = {
53     "TESTMASK", 0, 0, 0, 0, MFLG_SLOW, 0,
54     {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testmask, m_ignore}
55     };
56    
57     #ifndef STATIC_MODULES
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 #endif
72    
73     /* mo_testmask()
74     *
75     * inputs - pointer to physical connection request is coming from
76     * - pointer to source connection request is coming from
77     * - parc arg count
78     * - parv actual arguments
79     * output - NONE
80     * side effects - count up clients matching mask
81     * i.e. /quote testmask user@host
82     */
83     static void
84     mo_testmask(struct Client *client_p, struct Client *source_p,
85     int parc, char *parv[])
86     {
87     char *given_host;
88     char *given_user = parv[1];
89     int local_count = 0, remote_count = 0;
90     dlink_node *ptr, *next_ptr;
91     struct Client *target_p;
92    
93     if (parc < 2 || ((given_host = strchr(given_user, '@')) == NULL))
94     {
95     sendto_one(source_p, ":%s NOTICE %s :usage: user@host",
96     me.name, source_p->name);
97     return;
98     }
99    
100     *given_host++ = '\0';
101    
102     DLINK_FOREACH_SAFE(ptr, next_ptr, global_client_list.head)
103     {
104     target_p = ptr->data;
105    
106     if (IsDead(target_p) || !IsClient(target_p))
107     continue;
108    
109     if (match(given_user, target_p->username) &&
110     match(given_host, target_p->host))
111     {
112     if (MyConnect(target_p))
113     local_count++;
114     else
115     remote_count++;
116     }
117     }
118    
119     sendto_one(source_p, form_str(RPL_TESTMASK), me.name, source_p->name,
120     given_user, given_host, local_count, remote_count);
121     }

Properties

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