ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_userhost.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (14 years, 10 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_userhost.c
File size: 3685 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

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 /*
41 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
42 * the need for complicated requests like WHOIS. It returns user/host
43 * information only (no spurious AWAY labels or channels).
44 */
45 static void
46 m_userhost(struct Client *client_p, struct Client *source_p,
47 int parc, char *parv[])
48 {
49 struct Client *target_p;
50 char buf[IRCD_BUFSIZE];
51 char response[NICKLEN*2+USERLEN+HOSTLEN+30];
52 char *t = NULL, *p = NULL, *nick = NULL;
53 int i = 0; /* loop counter */
54 int cur_len;
55 int rl;
56
57 cur_len = ircsprintf(buf, form_str(RPL_USERHOST), me.name, source_p->name, "");
58 t = buf + cur_len;
59
60 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
61 nick = strtoken(&p, NULL, " "))
62 {
63 if ((target_p = find_person(client_p, nick)) != NULL)
64 {
65 /*
66 * Show real IP for USERHOST on yourself.
67 * This is needed for things like mIRC, which do a server-based
68 * lookup (USERHOST) to figure out what the clients' local IP
69 * is. Useful for things like NAT, and dynamic dial-up users.
70 */
71 if (MyClient(target_p) && (target_p == source_p))
72 {
73 rl = ircsprintf(response, "%s%s=%c%s@%s ",
74 target_p->name,
75 HasUMode(target_p, UMODE_OPER) ? "*" : "",
76 (target_p->away) ? '-' : '+',
77 target_p->username,
78 target_p->sockhost);
79 }
80 else
81 {
82 rl = ircsprintf(response, "%s%s=%c%s@%s ",
83 target_p->name,
84 HasUMode(target_p, UMODE_OPER) ? "*" : "",
85 (target_p->away) ? '-' : '+',
86 target_p->username,
87 target_p->host);
88 }
89
90 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
91 {
92 ircsprintf(t, "%s", response);
93 t += rl;
94 cur_len += rl;
95 }
96 else
97 break;
98 }
99 }
100
101 sendto_one(source_p, "%s", buf);
102 }
103
104 static struct Message userhost_msgtab = {
105 "USERHOST", 0, 0, 1, 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 .node = { NULL, NULL, NULL },
123 .name = NULL,
124 .version = "$Revision$",
125 .handle = NULL,
126 .modinit = module_init,
127 .modexit = module_exit,
128 .flags = 0
129 };

Properties

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