ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_userhost.c
Revision: 1832
Committed: Fri Apr 19 19:16:09 2013 UTC (13 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 3701 byte(s)
Log Message:
- Made all numeric defines use the actual string instead of the numeric value
  which allows to use gcc's printf format attribute
- Remove current message locale implementation

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_userhost.c: Shows a user's host.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "client.h"
27     #include "ircd.h"
28     #include "numeric.h"
29     #include "s_serv.h"
30     #include "send.h"
31     #include "irc_string.h"
32     #include "parse.h"
33     #include "modules.h"
34    
35    
36     /*
37     * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
38     * the need for complicated requests like WHOIS. It returns user/host
39     * information only (no spurious AWAY labels or channels).
40     */
41     static void
42     m_userhost(struct Client *client_p, struct Client *source_p,
43     int parc, char *parv[])
44     {
45     struct Client *target_p;
46     char buf[IRCD_BUFSIZE];
47     char response[NICKLEN*2+USERLEN+HOSTLEN+30];
48 michael 1178 char *t = NULL, *p = NULL, *nick = NULL;
49     int i = 0; /* loop counter */
50 adx 30 int cur_len;
51     int rl;
52    
53 michael 1832 cur_len = snprintf(buf, sizeof(buf), RPL_USERHOST, me.name, source_p->name, "");
54 adx 30 t = buf + cur_len;
55    
56 michael 1178 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
57     nick = strtoken(&p, NULL, " "))
58 adx 30 {
59 michael 1178 if ((target_p = find_person(client_p, nick)) != NULL)
60 adx 30 {
61 adx 268 /*
62 michael 885 * Show real IP for USERHOST on yourself.
63     * This is needed for things like mIRC, which do a server-based
64     * lookup (USERHOST) to figure out what the clients' local IP
65     * is. Useful for things like NAT, and dynamic dial-up users.
66 adx 268 */
67 michael 885 if (MyClient(target_p) && (target_p == source_p))
68     {
69 michael 1793 rl = sprintf(response, "%s%s=%c%s@%s ",
70     target_p->name,
71     HasUMode(target_p, UMODE_OPER) ? "*" : "",
72     (target_p->away[0]) ? '-' : '+',
73     target_p->username,
74     target_p->sockhost);
75 michael 885 }
76 adx 268 else
77 michael 885 {
78 michael 1793 rl = sprintf(response, "%s%s=%c%s@%s ",
79     target_p->name, (HasUMode(target_p, UMODE_OPER) &&
80     (!HasUMode(target_p, UMODE_HIDDEN) ||
81     HasUMode(source_p, UMODE_OPER))) ? "*" : "",
82     (target_p->away[0]) ? '-' : '+',
83     target_p->username,
84     target_p->host);
85 michael 885 }
86 adx 30
87 michael 885 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
88 adx 268 {
89 michael 1793 sprintf(t, "%s", response);
90 adx 268 t += rl;
91     cur_len += rl;
92     }
93 michael 885 else
94     break;
95 adx 30 }
96 adx 268 }
97 adx 30
98     sendto_one(source_p, "%s", buf);
99     }
100 michael 1230
101     static struct Message userhost_msgtab = {
102 michael 1728 "USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0,
103 michael 1230 {m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore}
104     };
105    
106     static void
107     module_init(void)
108     {
109     mod_add_cmd(&userhost_msgtab);
110     }
111    
112     static void
113     module_exit(void)
114     {
115     mod_del_cmd(&userhost_msgtab);
116     }
117    
118     struct module module_entry = {
119     .node = { NULL, NULL, NULL },
120     .name = NULL,
121     .version = "$Revision$",
122     .handle = NULL,
123     .modinit = module_init,
124     .modexit = module_exit,
125     .flags = 0
126     };

Properties

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