ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ison.c
Revision: 1728
Committed: Thu Jan 3 00:16:51 2013 UTC (13 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 3350 byte(s)
Log Message:
- Backported -r1723 [Fixed possible core on USERHOST/ISON/CAPAB which for some reason
  only happens with glibc with optimization enabled. Reported by Mantas]

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