ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.1.x/modules/m_map.c
Revision: 2821
Committed: Wed Jan 15 23:12:35 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4346 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

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2001-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_map.c
23 * \brief Includes required functions for processing the MAP command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "modules.h"
30 #include "numeric.h"
31 #include "send.h"
32 #include "conf.h"
33 #include "ircd.h"
34 #include "irc_string.h"
35 #include "parse.h"
36 #include "s_user.h"
37
38
39
40 static void dump_map(struct Client *client,
41 struct Client *server,
42 unsigned int prompt_length)
43 {
44 dlink_node *ptr = NULL;
45 struct Client *target_p = NULL;
46 static char prompt[64];
47 char *p = prompt + prompt_length;
48 int cnt = 0;
49
50 *p = '\0';
51
52 if (prompt_length > 60)
53 sendto_one(client, form_str(RPL_MAPMORE), me.name,
54 client->name, prompt, server->name);
55 else
56 {
57 char buf[IRC_MAXSID + 3] = ""; /* +3 for [, ], \0 */
58
59 if (HasUMode(client, UMODE_OPER) && server->id[0])
60 snprintf(buf, sizeof(buf), "[%s]", server->id);
61
62 sendto_one(client, form_str(RPL_MAP), me.name, client->name,
63 prompt, server->name, buf,
64 dlink_list_length(&server->serv->client_list),
65 dlink_list_length(&server->serv->client_list) * 100 / Count.total);
66 }
67
68 if (prompt_length > 0)
69 {
70 *(p - 1) = ' ';
71
72 if (*(p - 2) == '`')
73 *(p - 2) = ' ';
74 }
75
76 if (prompt_length > 60)
77 return;
78 strcpy(p, "|-");
79
80 DLINK_FOREACH(ptr, server->serv->server_list.head)
81 {
82 target_p = ptr->data;
83
84 if (IsHidden(target_p) && !HasUMode(client, UMODE_OPER))
85 continue;
86
87 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
88 if (!HasUMode(client, UMODE_OPER))
89 continue;
90
91 ++cnt;
92 }
93
94 DLINK_FOREACH(ptr, server->serv->server_list.head)
95 {
96 target_p = ptr->data;
97
98 if (IsHidden(target_p) && !HasUMode(client, UMODE_OPER))
99 continue;
100
101 if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services)
102 if (!HasUMode(client, UMODE_OPER))
103 continue;
104
105 if (--cnt == 0)
106 *p = '`';
107 dump_map(client, target_p, prompt_length + 2);
108 }
109
110 if (prompt_length > 0)
111 *(p - 1) = '-';
112 }
113
114 /* m_map()
115 * parv[0] = sender prefix
116 */
117 static int
118 m_map(struct Client *client_p, struct Client *source_p,
119 int parc, char *parv[])
120 {
121 static time_t last_used = 0;
122
123 if (ConfigServerHide.flatten_links)
124 return m_not_oper(client_p, source_p, parc, parv);
125
126 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
127 {
128 /* safe enough to give this on a local connect only */
129 sendto_one(source_p, form_str(RPL_LOAD2HI),
130 me.name, source_p->name);
131 return 0;
132 }
133
134 last_used = CurrentTime;
135
136 dump_map(source_p, &me, 0);
137 sendto_one(source_p, form_str(RPL_MAPEND), me.name, source_p->name);
138 return 0;
139 }
140
141 /* mo_map()
142 * parv[0] = sender prefix
143 */
144 static int
145 mo_map(struct Client *client_p, struct Client *source_p,
146 int parc, char *parv[])
147 {
148 dump_map(source_p, &me, 0);
149 sendto_one(source_p, form_str(RPL_MAPEND), me.name, source_p->name);
150 return 0;
151 }
152
153 static struct Message map_msgtab =
154 {
155 "MAP", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
156 { m_unregistered, m_map, m_ignore, m_ignore, mo_map, m_ignore }
157 };
158
159 static void
160 module_init(void)
161 {
162 mod_add_cmd(&map_msgtab);
163 }
164
165 static void
166 module_exit(void)
167 {
168 mod_del_cmd(&map_msgtab);
169 }
170
171 struct module module_entry =
172 {
173 .node = { NULL, NULL, NULL },
174 .name = NULL,
175 .version = "$Revision$",
176 .handle = NULL,
177 .modinit = module_init,
178 .modexit = module_exit,
179 .flags = 0
180 };

Properties

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