ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_ison.c
Revision: 470
Committed: Fri Feb 17 05:07:43 2006 UTC (19 years, 6 months ago) by db
Content type: text/x-csrc
File size: 3273 byte(s)
Log Message:
- fix compile errors with moved modules.h
- fix a few missing includes, msg.h and parse.h


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

Properties

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