ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ison.c
Revision: 1793
Committed: Sun Mar 31 14:06:08 2013 UTC (13 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 3325 byte(s)
Log Message:
- Replaced all occurrences of ircsprintf with sprintf/snprintf
  and killed sprintf_irc.(c|h)

File Contents

# Content
1 /*
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 * $Id$
23 */
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 do_ison(struct Client *client_p, struct Client *source_p,
37 int parc, char *parv[])
38 {
39 struct Client *target_p = NULL;
40 char *nick;
41 char *p = NULL;
42 char *current_insert_point = NULL;
43 char buf[IRCD_BUFSIZE];
44 int len;
45 int i;
46 int done = 0;
47
48 len = snprintf(buf, sizeof(buf), form_str(RPL_ISON), me.name, source_p->name);
49 current_insert_point = buf + len;
50
51 /*
52 * rfc1459 is ambigious about how to handle ISON
53 * this should handle both interpretations.
54 */
55 for (i = 1; i < parc; i++)
56 {
57 for (nick = strtoken(&p, parv[i], " "); nick;
58 nick = strtoken(&p, NULL, " "))
59 {
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 /*
83 * current_insert_point--;
84 * Do NOT take out the trailing space, it breaks ircII
85 * --Rodder
86 */
87 *current_insert_point = '\0';
88
89 sendto_one(source_p, "%s", buf);
90 }
91
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 "ISON", 0, 0, 2, 1, MFLG_SLOW, 0,
110 {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