ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_userhost.c
Revision: 4546
Committed: Fri Aug 22 08:46:38 2014 UTC (11 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 4012 byte(s)
Log Message:
- Fixed compile warnings with -Wmissing-field-initializers

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_userhost.c
23     * \brief Includes required functions for processing the USERHOST command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31     #include "send.h"
32     #include "irc_string.h"
33     #include "parse.h"
34     #include "modules.h"
35    
36    
37 michael 3299 /*! \brief USERHOST 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 up to 5 nicknames
47 adx 30 */
48 michael 2820 static int
49 michael 3156 m_userhost(struct Client *source_p, int parc, char *parv[])
50 adx 30 {
51     struct Client *target_p;
52     char buf[IRCD_BUFSIZE];
53     char response[NICKLEN*2+USERLEN+HOSTLEN+30];
54 michael 1178 char *t = NULL, *p = NULL, *nick = NULL;
55 michael 3299 int i = 0;
56 adx 30 int cur_len;
57     int rl;
58    
59 michael 3109 cur_len = snprintf(buf, sizeof(buf), numeric_form(RPL_USERHOST), me.name, source_p->name, "");
60 adx 30 t = buf + cur_len;
61    
62 michael 1178 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
63     nick = strtoken(&p, NULL, " "))
64 adx 30 {
65 michael 3246 if ((target_p = find_person(source_p, nick)))
66 adx 30 {
67 adx 268 /*
68 michael 885 * Show real IP for USERHOST on yourself.
69     * This is needed for things like mIRC, which do a server-based
70     * lookup (USERHOST) to figure out what the clients' local IP
71 michael 3299 * is. Useful for things like NAT, and dynamic dial-up users.
72 adx 268 */
73 michael 885 if (MyClient(target_p) && (target_p == source_p))
74     {
75 michael 1793 rl = sprintf(response, "%s%s=%c%s@%s ",
76     target_p->name,
77     HasUMode(target_p, UMODE_OPER) ? "*" : "",
78     (target_p->away[0]) ? '-' : '+',
79     target_p->username,
80     target_p->sockhost);
81 michael 885 }
82 adx 268 else
83 michael 885 {
84 michael 1793 rl = sprintf(response, "%s%s=%c%s@%s ",
85     target_p->name, (HasUMode(target_p, UMODE_OPER) &&
86     (!HasUMode(target_p, UMODE_HIDDEN) ||
87     HasUMode(source_p, UMODE_OPER))) ? "*" : "",
88     (target_p->away[0]) ? '-' : '+',
89     target_p->username,
90     target_p->host);
91 michael 885 }
92 adx 30
93 michael 885 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
94 adx 268 {
95 michael 1793 sprintf(t, "%s", response);
96 adx 268 t += rl;
97     cur_len += rl;
98     }
99 michael 885 else
100     break;
101 adx 30 }
102 adx 268 }
103 adx 30
104     sendto_one(source_p, "%s", buf);
105 michael 2820 return 0;
106 adx 30 }
107 michael 1230
108 michael 2820 static struct Message userhost_msgtab =
109     {
110 michael 4546 "USERHOST", NULL, 0, 0, 2, 1, MFLG_SLOW, 0,
111 michael 2820 { m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore }
112 michael 1230 };
113    
114     static void
115     module_init(void)
116     {
117     mod_add_cmd(&userhost_msgtab);
118     }
119    
120     static void
121     module_exit(void)
122     {
123     mod_del_cmd(&userhost_msgtab);
124     }
125    
126 michael 2820 struct module module_entry =
127     {
128 michael 1230 .node = { NULL, NULL, NULL },
129     .name = NULL,
130     .version = "$Revision$",
131     .handle = NULL,
132     .modinit = module_init,
133     .modexit = module_exit,
134     .flags = 0
135     };

Properties

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