ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_userhost.c
Revision: 3246
Committed: Sun Mar 30 17:37:13 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 3751 byte(s)
Log Message:
- Fixed inconsistent style in several places

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2014 ircd-hybrid development team
5 *
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 /*! \file m_userhost.c
23 * \brief Includes required functions for processing the USERHOST command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "s_serv.h"
32 #include "send.h"
33 #include "irc_string.h"
34 #include "parse.h"
35 #include "modules.h"
36
37
38 /*
39 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
40 * the need for complicated requests like WHOIS. It returns user/host
41 * information only (no spurious AWAY labels or channels).
42 */
43 static int
44 m_userhost(struct Client *source_p, int parc, char *parv[])
45 {
46 struct Client *target_p;
47 char buf[IRCD_BUFSIZE];
48 char response[NICKLEN*2+USERLEN+HOSTLEN+30];
49 char *t = NULL, *p = NULL, *nick = NULL;
50 int i = 0; /* loop counter */
51 int cur_len;
52 int rl;
53
54 cur_len = snprintf(buf, sizeof(buf), numeric_form(RPL_USERHOST), me.name, source_p->name, "");
55 t = buf + cur_len;
56
57 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
58 nick = strtoken(&p, NULL, " "))
59 {
60 if ((target_p = find_person(source_p, nick)))
61 {
62 /*
63 * Show real IP for USERHOST on yourself.
64 * This is needed for things like mIRC, which do a server-based
65 * lookup (USERHOST) to figure out what the clients' local IP
66 * is. Useful for things like NAT, and dynamic dial-up users.
67 */
68 if (MyClient(target_p) && (target_p == source_p))
69 {
70 rl = sprintf(response, "%s%s=%c%s@%s ",
71 target_p->name,
72 HasUMode(target_p, UMODE_OPER) ? "*" : "",
73 (target_p->away[0]) ? '-' : '+',
74 target_p->username,
75 target_p->sockhost);
76 }
77 else
78 {
79 rl = sprintf(response, "%s%s=%c%s@%s ",
80 target_p->name, (HasUMode(target_p, UMODE_OPER) &&
81 (!HasUMode(target_p, UMODE_HIDDEN) ||
82 HasUMode(source_p, UMODE_OPER))) ? "*" : "",
83 (target_p->away[0]) ? '-' : '+',
84 target_p->username,
85 target_p->host);
86 }
87
88 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
89 {
90 sprintf(t, "%s", response);
91 t += rl;
92 cur_len += rl;
93 }
94 else
95 break;
96 }
97 }
98
99 sendto_one(source_p, "%s", buf);
100 return 0;
101 }
102
103 static struct Message userhost_msgtab =
104 {
105 "USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0,
106 { m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore }
107 };
108
109 static void
110 module_init(void)
111 {
112 mod_add_cmd(&userhost_msgtab);
113 }
114
115 static void
116 module_exit(void)
117 {
118 mod_del_cmd(&userhost_msgtab);
119 }
120
121 struct module module_entry =
122 {
123 .node = { NULL, NULL, NULL },
124 .name = NULL,
125 .version = "$Revision$",
126 .handle = NULL,
127 .modinit = module_init,
128 .modexit = module_exit,
129 .flags = 0
130 };

Properties

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