ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ison.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (13 years, 11 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_ison.c
File size: 3420 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_ison.c: Provides a single line answer of whether a user is online.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "handlers.h"
27     #include "client.h"
28     #include "irc_string.h"
29     #include "sprintf_irc.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "send.h"
33     #include "msg.h"
34     #include "parse.h"
35     #include "modules.h"
36     #include "s_conf.h" /* ConfigFileEntry */
37    
38    
39     static void
40 michael 885 do_ison(struct Client *client_p, struct Client *source_p,
41 adx 30 int parc, char *parv[])
42     {
43     struct Client *target_p = NULL;
44     char *nick;
45 michael 875 char *p = NULL;
46 michael 885 char *current_insert_point = NULL;
47 adx 30 char buf[IRCD_BUFSIZE];
48     int len;
49     int i;
50     int done = 0;
51    
52 michael 1230 len = ircsprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
53 adx 30 current_insert_point = buf + len;
54    
55 michael 885 /*
56     * rfc1459 is ambigious about how to handle ISON
57 adx 30 * this should handle both interpretations.
58     */
59     for (i = 1; i < parc; i++)
60     {
61     for (nick = strtoken(&p, parv[i], " "); nick;
62 michael 885 nick = strtoken(&p, NULL, " "))
63 adx 30 {
64     if ((target_p = find_person(client_p, nick)))
65     {
66     len = strlen(target_p->name);
67    
68     if ((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
69     {
70     memcpy(current_insert_point, target_p->name, len);
71     current_insert_point += len;
72     *current_insert_point++ = ' ';
73     }
74     else
75     {
76     done = 1;
77     break;
78     }
79     }
80     }
81    
82     if (done)
83     break;
84     }
85    
86 michael 885 /*
87     * current_insert_point--;
88 adx 30 * Do NOT take out the trailing space, it breaks ircII
89 michael 885 * --Rodder
90     */
91     *current_insert_point = '\0';
92 adx 30
93 michael 885 sendto_one(source_p, "%s", buf);
94 adx 30 }
95 michael 1230
96     /*
97     * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
98     * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
99     * clients. Designed to reduce number of whois requests. Can process
100     * nicknames in batches as long as the maximum buffer length.
101     *
102     * format:
103     * ISON :nicklist
104     */
105     static void
106     m_ison(struct Client *client_p, struct Client *source_p,
107     int parc, char *parv[])
108     {
109     do_ison(client_p, source_p, parc, parv);
110     }
111    
112     static struct Message ison_msgtab = {
113     "ISON", 0, 0, 1, 1, MFLG_SLOW, 0,
114     {m_unregistered, m_ison, m_ignore, m_ignore, m_ison, m_ignore}
115     };
116    
117     static void
118     module_init(void)
119     {
120     mod_add_cmd(&ison_msgtab);
121     }
122    
123     static void
124     module_exit(void)
125     {
126     mod_del_cmd(&ison_msgtab);
127     }
128    
129     struct module module_entry = {
130     .node = { NULL, NULL, NULL },
131     .name = NULL,
132     .version = "$Revision$",
133     .handle = NULL,
134     .modinit = module_init,
135     .modexit = module_exit,
136     .flags = 0
137     };

Properties

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