/[svn]/ircd-hybrid/trunk/modules/m_ison.c
ViewVC logotype

Annotation of /ircd-hybrid/trunk/modules/m_ison.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2099 - (hide annotations)
Sun May 19 11:00:34 2013 UTC (7 years, 5 months ago) by michael
File MIME type: text/x-chdr
File size: 3175 byte(s)
- m_ison.c: merge do_ison() into m_ison()

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 "client.h"
27     #include "irc_string.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "send.h"
31     #include "parse.h"
32     #include "modules.h"
33    
34    
35 michael 2099 /*
36     * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
37     * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
38     * clients. Designed to reduce number of whois requests. Can process
39     * nicknames in batches as long as the maximum buffer length.
40     *
41     * format:
42     * ISON :nicklist
43     */
44 adx 30 static void
45 michael 2099 m_ison(struct Client *client_p, struct Client *source_p,
46     int parc, char *parv[])
47 adx 30 {
48     struct Client *target_p = NULL;
49     char *nick;
50 michael 875 char *p = NULL;
51 michael 885 char *current_insert_point = NULL;
52 adx 30 char buf[IRCD_BUFSIZE];
53     int len;
54     int i;
55     int done = 0;
56    
57 michael 1834 len = snprintf(buf, sizeof(buf), form_str(RPL_ISON), me.name, source_p->name);
58 adx 30 current_insert_point = buf + len;
59    
60 michael 885 /*
61     * rfc1459 is ambigious about how to handle ISON
62 adx 30 * this should handle both interpretations.
63     */
64     for (i = 1; i < parc; i++)
65     {
66     for (nick = strtoken(&p, parv[i], " "); nick;
67 michael 885 nick = strtoken(&p, NULL, " "))
68 adx 30 {
69     if ((target_p = find_person(client_p, nick)))
70     {
71     len = strlen(target_p->name);
72    
73     if ((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
74     {
75     memcpy(current_insert_point, target_p->name, len);
76     current_insert_point += len;
77     *current_insert_point++ = ' ';
78     }
79     else
80     {
81     done = 1;
82     break;
83     }
84     }
85     }
86    
87     if (done)
88     break;
89     }
90    
91 michael 885 /*
92     * current_insert_point--;
93 adx 30 * Do NOT take out the trailing space, it breaks ircII
94 michael 885 * --Rodder
95     */
96     *current_insert_point = '\0';
97 adx 30
98 michael 885 sendto_one(source_p, "%s", buf);
99 adx 30 }
100 michael 1230
101     static struct Message ison_msgtab = {
102 michael 1728 "ISON", 0, 0, 2, 1, MFLG_SLOW, 0,
103 michael 1230 {m_unregistered, m_ison, m_ignore, m_ignore, m_ison, m_ignore}
104     };
105    
106     static void
107     module_init(void)
108     {
109     mod_add_cmd(&ison_msgtab);
110     }
111    
112     static void
113     module_exit(void)
114     {
115     mod_del_cmd(&ison_msgtab);
116     }
117    
118     struct module module_entry = {
119     .node = { NULL, NULL, NULL },
120     .name = NULL,
121     .version = "$Revision$",
122     .handle = NULL,
123     .modinit = module_init,
124     .modexit = module_exit,
125     .flags = 0
126     };

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28