ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_userhost.c
Revision: 1178
Committed: Mon Aug 15 08:11:31 2011 UTC (14 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 3533 byte(s)
Log Message:
- Cleanup and restore older parts of the irc-command parser.
  Gives back ability to specify maximum amount of parameters
  that are processed within a command.

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, 1, 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 = NULL, *p = NULL, *nick = NULL;
74 int i = 0; /* 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 (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
82 nick = strtoken(&p, NULL, " "))
83 {
84 if ((target_p = find_person(client_p, nick)) != NULL)
85 {
86 /*
87 * 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 */
92 if (MyClient(target_p) && (target_p == source_p))
93 {
94 rl = ircsprintf(response, "%s%s=%c%s@%s ",
95 target_p->name,
96 IsOper(target_p) ? "*" : "",
97 (target_p->away) ? '-' : '+',
98 target_p->username,
99 target_p->sockhost);
100 }
101 else
102 {
103 rl = ircsprintf(response, "%s%s=%c%s@%s ",
104 target_p->name,
105 IsOper(target_p) ? "*" : "",
106 (target_p->away) ? '-' : '+',
107 target_p->username,
108 target_p->host);
109 }
110
111 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
112 {
113 ircsprintf(t, "%s", response);
114 t += rl;
115 cur_len += rl;
116 }
117 else
118 break;
119 }
120 }
121
122 sendto_one(source_p, "%s", buf);
123 }

Properties

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