ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_ison.c
Revision: 885
Committed: Wed Oct 31 18:09:24 2007 UTC (18 years, 8 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-7.2/modules/m_ison.c
File size: 3394 byte(s)
Log Message:
- Removed LazyLinks in 7.2 to stop people from asking why we keep
  broken code for half a decade. LL will be implemented in a smarter
  fashion in due time

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

Properties

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