ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_userhost.c
Revision: 1219
Committed: Sun Sep 18 09:02:38 2011 UTC (14 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 3561 byte(s)
Log Message:
- Start cleaning up macros in client.h. Replace several ClientHasSomeCoolFlag()
with simple HasFlag/HasUMode macros.

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 "handlers.h"
27     #include "client.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "s_serv.h"
31     #include "send.h"
32     #include "irc_string.h"
33     #include "sprintf_irc.h"
34     #include "msg.h"
35     #include "parse.h"
36     #include "modules.h"
37     #include "s_conf.h"
38    
39    
40     static void m_userhost(struct Client *, struct Client *, int, char *[]);
41    
42     struct Message userhost_msgtab = {
43 michael 1178 "USERHOST", 0, 0, 1, 1, MFLG_SLOW, 0,
44 adx 30 {m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore}
45     };
46    
47     void
48     _modinit(void)
49     {
50     mod_add_cmd(&userhost_msgtab);
51     }
52    
53     void
54     _moddeinit(void)
55     {
56     mod_del_cmd(&userhost_msgtab);
57     }
58    
59 knight 31 const char *_version = "$Revision$";
60 adx 30
61     /*
62     * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
63     * the need for complicated requests like WHOIS. It returns user/host
64     * information only (no spurious AWAY labels or channels).
65     */
66     static void
67     m_userhost(struct Client *client_p, struct Client *source_p,
68     int parc, char *parv[])
69     {
70     struct Client *target_p;
71     char buf[IRCD_BUFSIZE];
72     char response[NICKLEN*2+USERLEN+HOSTLEN+30];
73 michael 1178 char *t = NULL, *p = NULL, *nick = NULL;
74     int i = 0; /* loop counter */
75 adx 30 int cur_len;
76     int rl;
77    
78     cur_len = ircsprintf(buf,form_str(RPL_USERHOST),me.name, parv[0], "");
79     t = buf + cur_len;
80    
81 michael 1178 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
82     nick = strtoken(&p, NULL, " "))
83 adx 30 {
84 michael 1178 if ((target_p = find_person(client_p, nick)) != NULL)
85 adx 30 {
86 adx 268 /*
87 michael 885 * Show real IP for USERHOST on yourself.
88     * This is needed for things like mIRC, which do a server-based
89     * lookup (USERHOST) to figure out what the clients' local IP
90     * is. Useful for things like NAT, and dynamic dial-up users.
91 adx 268 */
92 michael 885 if (MyClient(target_p) && (target_p == source_p))
93     {
94     rl = ircsprintf(response, "%s%s=%c%s@%s ",
95     target_p->name,
96 michael 1219 HasUMode(target_p, UMODE_OPER) ? "*" : "",
97 michael 885 (target_p->away) ? '-' : '+',
98     target_p->username,
99     target_p->sockhost);
100     }
101 adx 268 else
102 michael 885 {
103     rl = ircsprintf(response, "%s%s=%c%s@%s ",
104     target_p->name,
105 michael 1219 HasUMode(target_p, UMODE_OPER) ? "*" : "",
106 michael 885 (target_p->away) ? '-' : '+',
107     target_p->username,
108     target_p->host);
109     }
110 adx 30
111 michael 885 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
112 adx 268 {
113 michael 885 ircsprintf(t, "%s", response);
114 adx 268 t += rl;
115     cur_len += rl;
116     }
117 michael 885 else
118     break;
119 adx 30 }
120 adx 268 }
121 adx 30
122     sendto_one(source_p, "%s", buf);
123     }

Properties

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