]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_ison.c
Removal of ancient SVN ID's part one
[irc/rqf/shadowircd.git] / modules / m_ison.c
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_ison.c: Provides a single line answer of whether a user is online.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
212380e3 24 */
25
26#include "stdinc.h"
27#include "client.h"
13ae2f4b 28#include "match.h"
212380e3 29#include "ircd.h"
30#include "numeric.h"
31#include "send.h"
32#include "msg.h"
33#include "parse.h"
34#include "modules.h"
35#include "s_conf.h" /* ConfigFileEntry */
36#include "s_serv.h" /* uplink/IsCapable */
37#include "hash.h"
38
39#include <string.h>
40
41static int m_ison(struct Client *, struct Client *, int, const char **);
42
43struct Message ison_msgtab = {
44 "ISON", 0, 0, 0, MFLG_SLOW,
45 {mg_unreg, {m_ison, 2}, mg_ignore, mg_ignore, mg_ignore, {m_ison, 2}}
46};
47
48mapi_clist_av1 ison_clist[] = { &ison_msgtab, NULL };
49DECLARE_MODULE_AV1(ison, NULL, NULL, ison_clist, NULL, NULL, "$Revision: 254 $");
50
51static char buf[BUFSIZE];
52static char buf2[BUFSIZE];
53
54
55/*
56 * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
57 * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
58 * clients. Designed to reduce number of whois requests. Can process
59 * nicknames in batches as long as the maximum buffer length.
60 *
61 * format:
62 * ISON :nicklist
63 */
64static int
65m_ison(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
66{
67 struct Client *target_p;
68 char *nick;
69 char *p;
70 char *current_insert_point, *current_insert_point2;
71 int len;
72 int i;
73 int done = 0;
74
75 current_insert_point2 = buf2;
76 *buf2 = '\0';
77
581fa5c4 78 rb_sprintf(buf, form_str(RPL_ISON), me.name, source_p->name);
212380e3 79 len = strlen(buf);
80 current_insert_point = buf + len;
81
82 /* rfc1489 is ambigious about how to handle ISON
83 * this should handle both interpretations.
84 */
85 for (i = 1; i < parc; i++)
86 {
87 char *cs = LOCAL_COPY(parv[i]);
dcbd1d07 88 for (nick = rb_strtok_r(cs, " ", &p); nick; nick = rb_strtok_r(NULL, " ", &p))
212380e3 89 {
90 target_p = find_named_client(nick);
91
92 if(target_p != NULL)
93 {
94 len = strlen(target_p->name);
95 if((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
96 {
97 memcpy((void *) current_insert_point,
98 (void *) target_p->name, len);
99 current_insert_point += len;
100 *current_insert_point++ = ' ';
101 }
102 else
103 {
104 done = 1;
105 break;
106 }
107 }
108 }
109 if(done)
110 break;
111 }
112
113 /* current_insert_point--;
114 * Do NOT take out the trailing space, it breaks ircII
115 * --Rodder */
116
117 *current_insert_point = '\0';
118 *current_insert_point2 = '\0';
119
120 sendto_one(source_p, "%s", buf);
121
122 return 0;
123}