ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_userhost.c
Revision: 1156
Committed: Tue Aug 9 20:29:20 2011 UTC (14 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 3470 byte(s)
Log Message:
- create ircd-hybrid-8 "branch"

File Contents

# Content
1 /*
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 * $Id$
23 */
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 "USERHOST", 0, 0, 1, 0, MFLG_SLOW, 0,
44 {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 const char *_version = "$Revision$";
60
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 char *t;
74 int i; /* loop counter */
75 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 for (i = 0; i < 5; i++)
82 {
83 if (parv[i + 1] == NULL)
84 break;
85
86 if ((target_p = find_person(client_p, parv[i+1])) != NULL)
87 {
88 /*
89 * Show real IP for USERHOST on yourself.
90 * This is needed for things like mIRC, which do a server-based
91 * lookup (USERHOST) to figure out what the clients' local IP
92 * is. Useful for things like NAT, and dynamic dial-up users.
93 */
94 if (MyClient(target_p) && (target_p == source_p))
95 {
96 rl = ircsprintf(response, "%s%s=%c%s@%s ",
97 target_p->name,
98 IsOper(target_p) ? "*" : "",
99 (target_p->away) ? '-' : '+',
100 target_p->username,
101 target_p->sockhost);
102 }
103 else
104 {
105 rl = ircsprintf(response, "%s%s=%c%s@%s ",
106 target_p->name,
107 IsOper(target_p) ? "*" : "",
108 (target_p->away) ? '-' : '+',
109 target_p->username,
110 target_p->host);
111 }
112
113 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
114 {
115 ircsprintf(t, "%s", response);
116 t += rl;
117 cur_len += rl;
118 }
119 else
120 break;
121 }
122 }
123
124 sendto_one(source_p, "%s", buf);
125 }

Properties

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