1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_ison.c |
23 |
* \brief Includes required functions for processing the ISON command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "irc_string.h" |
30 |
#include "ircd.h" |
31 |
#include "numeric.h" |
32 |
#include "send.h" |
33 |
#include "parse.h" |
34 |
#include "modules.h" |
35 |
|
36 |
|
37 |
/* |
38 |
* m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator |
39 |
* with respect to cpu/bandwidth used. Implemented for NOTIFY feature in |
40 |
* clients. Designed to reduce number of whois requests. Can process |
41 |
* nicknames in batches as long as the maximum buffer length. |
42 |
* |
43 |
* format: |
44 |
* ISON :nicklist |
45 |
*/ |
46 |
static int |
47 |
m_ison(struct Client *client_p, struct Client *source_p, |
48 |
int parc, char *parv[]) |
49 |
{ |
50 |
struct Client *target_p = NULL; |
51 |
char *nick; |
52 |
char *p = NULL; |
53 |
char *current_insert_point = NULL; |
54 |
char buf[IRCD_BUFSIZE]; |
55 |
int len; |
56 |
int i; |
57 |
int done = 0; |
58 |
|
59 |
len = snprintf(buf, sizeof(buf), form_str(RPL_ISON), me.name, source_p->name); |
60 |
current_insert_point = buf + len; |
61 |
|
62 |
/* |
63 |
* rfc1459 is ambigious about how to handle ISON |
64 |
* this should handle both interpretations. |
65 |
*/ |
66 |
for (i = 1; i < parc; i++) |
67 |
{ |
68 |
for (nick = strtoken(&p, parv[i], " "); nick; |
69 |
nick = strtoken(&p, NULL, " ")) |
70 |
{ |
71 |
if ((target_p = find_person(client_p, nick))) |
72 |
{ |
73 |
len = strlen(target_p->name); |
74 |
|
75 |
if ((current_insert_point + (len + 5)) < (buf + sizeof(buf))) |
76 |
{ |
77 |
memcpy(current_insert_point, target_p->name, len); |
78 |
current_insert_point += len; |
79 |
*current_insert_point++ = ' '; |
80 |
} |
81 |
else |
82 |
{ |
83 |
done = 1; |
84 |
break; |
85 |
} |
86 |
} |
87 |
} |
88 |
|
89 |
if (done) |
90 |
break; |
91 |
} |
92 |
|
93 |
/* |
94 |
* current_insert_point--; |
95 |
* Do NOT take out the trailing space, it breaks ircII |
96 |
* --Rodder |
97 |
*/ |
98 |
*current_insert_point = '\0'; |
99 |
|
100 |
sendto_one(source_p, "%s", buf); |
101 |
return 0; |
102 |
} |
103 |
|
104 |
static struct Message ison_msgtab = |
105 |
{ |
106 |
"ISON", 0, 0, 2, 1, MFLG_SLOW, 0, |
107 |
{ m_unregistered, m_ison, m_ignore, m_ignore, m_ison, m_ignore } |
108 |
}; |
109 |
|
110 |
static void |
111 |
module_init(void) |
112 |
{ |
113 |
mod_add_cmd(&ison_msgtab); |
114 |
} |
115 |
|
116 |
static void |
117 |
module_exit(void) |
118 |
{ |
119 |
mod_del_cmd(&ison_msgtab); |
120 |
} |
121 |
|
122 |
struct module module_entry = |
123 |
{ |
124 |
.node = { NULL, NULL, NULL }, |
125 |
.name = NULL, |
126 |
.version = "$Revision$", |
127 |
.handle = NULL, |
128 |
.modinit = module_init, |
129 |
.modexit = module_exit, |
130 |
.flags = 0 |
131 |
}; |