ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_userhost.c
Revision: 2820
Committed: Wed Jan 15 23:10:26 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 3791 byte(s)
Log Message:
- Clean up all files in modules/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years
- Made module handlers int type for later use

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 2820 /*! \file m_userhost.c
23     * \brief Includes required functions for processing the USERHOST command.
24     * \version $Id$
25     */
26    
27 adx 30 #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 michael 2820 static int
44 adx 30 m_userhost(struct Client *client_p, struct Client *source_p,
45     int parc, char *parv[])
46     {
47     struct Client *target_p;
48     char buf[IRCD_BUFSIZE];
49     char response[NICKLEN*2+USERLEN+HOSTLEN+30];
50 michael 1178 char *t = NULL, *p = NULL, *nick = NULL;
51     int i = 0; /* loop counter */
52 adx 30 int cur_len;
53     int rl;
54    
55 michael 1834 cur_len = snprintf(buf, sizeof(buf), form_str(RPL_USERHOST), me.name, source_p->name, "");
56 adx 30 t = buf + cur_len;
57    
58 michael 1178 for (nick = strtoken(&p, parv[1], " "); nick && i++ < 5;
59     nick = strtoken(&p, NULL, " "))
60 adx 30 {
61 michael 1178 if ((target_p = find_person(client_p, nick)) != NULL)
62 adx 30 {
63 adx 268 /*
64 michael 885 * Show real IP for USERHOST on yourself.
65     * This is needed for things like mIRC, which do a server-based
66     * lookup (USERHOST) to figure out what the clients' local IP
67     * is. Useful for things like NAT, and dynamic dial-up users.
68 adx 268 */
69 michael 885 if (MyClient(target_p) && (target_p == source_p))
70     {
71 michael 1793 rl = sprintf(response, "%s%s=%c%s@%s ",
72     target_p->name,
73     HasUMode(target_p, UMODE_OPER) ? "*" : "",
74     (target_p->away[0]) ? '-' : '+',
75     target_p->username,
76     target_p->sockhost);
77 michael 885 }
78 adx 268 else
79 michael 885 {
80 michael 1793 rl = sprintf(response, "%s%s=%c%s@%s ",
81     target_p->name, (HasUMode(target_p, UMODE_OPER) &&
82     (!HasUMode(target_p, UMODE_HIDDEN) ||
83     HasUMode(source_p, UMODE_OPER))) ? "*" : "",
84     (target_p->away[0]) ? '-' : '+',
85     target_p->username,
86     target_p->host);
87 michael 885 }
88 adx 30
89 michael 885 if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
90 adx 268 {
91 michael 1793 sprintf(t, "%s", response);
92 adx 268 t += rl;
93     cur_len += rl;
94     }
95 michael 885 else
96     break;
97 adx 30 }
98 adx 268 }
99 adx 30
100     sendto_one(source_p, "%s", buf);
101 michael 2820 return 0;
102 adx 30 }
103 michael 1230
104 michael 2820 static struct Message userhost_msgtab =
105     {
106 michael 1728 "USERHOST", 0, 0, 2, 1, MFLG_SLOW, 0,
107 michael 2820 { m_unregistered, m_userhost, m_userhost, m_ignore, m_userhost, m_ignore }
108 michael 1230 };
109    
110     static void
111     module_init(void)
112     {
113     mod_add_cmd(&userhost_msgtab);
114     }
115    
116     static void
117     module_exit(void)
118     {
119     mod_del_cmd(&userhost_msgtab);
120     }
121    
122 michael 2820 struct module module_entry =
123     {
124 michael 1230 .node = { NULL, NULL, NULL },
125     .name = NULL,
126     .version = "$Revision$",
127     .handle = NULL,
128     .modinit = module_init,
129     .modexit = module_exit,
130     .flags = 0
131     };

Properties

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