ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_ison.c
Revision: 4564
Committed: Sun Aug 24 10:24:47 2014 UTC (9 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3374 byte(s)
Log Message:
- Update GPL 2 license headers

File Contents

# Content
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
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 /*! \brief ISON command handler
38 *
39 * \param source_p Pointer to allocated Client struct from which the message
40 * originally comes from. This can be a local or remote client.
41 * \param parc Integer holding the number of supplied arguments.
42 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
43 * pointers.
44 * \note Valid arguments for this command are:
45 * - parv[0] = command
46 * - parv[1] = space-separated list of nicknames
47 */
48 static int
49 m_ison(struct Client *source_p, int parc, char *parv[])
50 {
51 struct Client *target_p = NULL;
52 char *nick;
53 char *p = NULL;
54 char *current_insert_point = NULL;
55 char buf[IRCD_BUFSIZE];
56 int len;
57 int done = 0;
58
59 len = snprintf(buf, sizeof(buf), numeric_form(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 (int 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(source_p, nick)))
72 {
73 len = strlen(target_p->name);
74
75 if ((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
76 {
77 strlcpy(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", NULL, 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 };

Properties

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