/[svn]/ircd-hybrid/branches/8.1.x/modules/m_ison.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.1.x/modules/m_ison.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2100 - (show annotations)
Sun May 19 11:00:50 2013 UTC (7 years, 2 months ago) by michael
File MIME type: text/x-chdr
File size: 3175 byte(s)
- m_ison.c: merge do_ison() into m_ison()

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

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28