2 * ircd-ratbox: A slightly useful ircd.
3 * m_ison.c: Provides a single line answer of whether a user is online.
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
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.
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.
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
24 * $Id: m_ison.c 254 2005-09-21 23:35:12Z nenolod $
36 #include "s_conf.h" /* ConfigFileEntry */
37 #include "s_serv.h" /* uplink/IsCapable */
42 static int m_ison(struct Client
*, struct Client
*, int, const char **);
44 struct Message ison_msgtab
= {
45 "ISON", 0, 0, 0, MFLG_SLOW
,
46 {mg_unreg
, {m_ison
, 2}, mg_ignore
, mg_ignore
, mg_ignore
, {m_ison
, 2}}
49 mapi_clist_av1 ison_clist
[] = { &ison_msgtab
, NULL
};
50 DECLARE_MODULE_AV1(ison
, NULL
, NULL
, ison_clist
, NULL
, NULL
, "$Revision: 254 $");
52 static char buf
[BUFSIZE
];
53 static char buf2
[BUFSIZE
];
57 * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
58 * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
59 * clients. Designed to reduce number of whois requests. Can process
60 * nicknames in batches as long as the maximum buffer length.
66 m_ison(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
68 struct Client
*target_p
;
71 char *current_insert_point
, *current_insert_point2
;
76 current_insert_point2
= buf2
;
79 sprintf(buf
, form_str(RPL_ISON
), me
.name
, source_p
->name
);
81 current_insert_point
= buf
+ len
;
83 /* rfc1489 is ambigious about how to handle ISON
84 * this should handle both interpretations.
86 for (i
= 1; i
< parc
; i
++)
88 char *cs
= LOCAL_COPY(parv
[i
]);
89 for (nick
= rb_strtok_r(cs
, " ", &p
); nick
; nick
= rb_strtok_r(NULL
, " ", &p
))
91 target_p
= find_named_client(nick
);
95 len
= strlen(target_p
->name
);
96 if((current_insert_point
+ (len
+ 5)) < (buf
+ sizeof(buf
)))
98 memcpy((void *) current_insert_point
,
99 (void *) target_p
->name
, len
);
100 current_insert_point
+= len
;
101 *current_insert_point
++ = ' ';
114 /* current_insert_point--;
115 * Do NOT take out the trailing space, it breaks ircII
118 *current_insert_point
= '\0';
119 *current_insert_point2
= '\0';
121 sendto_one(source_p
, "%s", buf
);