ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_ison.c
Revision: 3738
Committed: Sun Jun 1 16:18:16 2014 UTC (11 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 3363 byte(s)
Log Message:
- m_ison.c:m_ison(): style corrections

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 2820 /*! \file m_ison.c
23     * \brief Includes required functions for processing the ISON command.
24     * \version $Id$
25     */
26    
27 adx 30 #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 michael 3344 /*! \brief ISON command handler
38 michael 2099 *
39 michael 3344 * \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 michael 2099 */
48 michael 2820 static int
49 michael 3156 m_ison(struct Client *source_p, int parc, char *parv[])
50 adx 30 {
51     struct Client *target_p = NULL;
52     char *nick;
53 michael 875 char *p = NULL;
54 michael 885 char *current_insert_point = NULL;
55 adx 30 char buf[IRCD_BUFSIZE];
56     int len;
57     int done = 0;
58    
59 michael 3109 len = snprintf(buf, sizeof(buf), numeric_form(RPL_ISON), me.name, source_p->name);
60 adx 30 current_insert_point = buf + len;
61    
62 michael 885 /*
63     * rfc1459 is ambigious about how to handle ISON
64 adx 30 * this should handle both interpretations.
65     */
66 michael 3738 for (int i = 1; i < parc; ++i)
67 adx 30 {
68     for (nick = strtoken(&p, parv[i], " "); nick;
69 michael 885 nick = strtoken(&p, NULL, " "))
70 adx 30 {
71 michael 3156 if ((target_p = find_person(source_p, nick)))
72 adx 30 {
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 michael 885 /*
94     * current_insert_point--;
95 adx 30 * Do NOT take out the trailing space, it breaks ircII
96 michael 885 * --Rodder
97     */
98     *current_insert_point = '\0';
99 adx 30
100 michael 885 sendto_one(source_p, "%s", buf);
101 michael 2820 return 0;
102 adx 30 }
103 michael 1230
104 michael 2820 static struct Message ison_msgtab =
105     {
106 michael 1728 "ISON", 0, 0, 2, 1, MFLG_SLOW, 0,
107 michael 2820 { m_unregistered, m_ison, m_ignore, m_ignore, m_ison, m_ignore }
108 michael 1230 };
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 michael 2820 struct module module_entry =
123     {
124 michael 1230 .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