ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ison.c
Revision: 1857
Committed: Wed Apr 24 20:47:21 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 3331 byte(s)
Log Message:
- Constification

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

Properties

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