| 25 |
|
#include "stdinc.h" |
| 26 |
|
#include "client.h" |
| 27 |
|
#include "modules.h" |
| 28 |
– |
#include "handlers.h" |
| 28 |
|
#include "numeric.h" |
| 29 |
|
#include "send.h" |
| 30 |
< |
#include "s_conf.h" |
| 30 |
> |
#include "conf.h" |
| 31 |
|
#include "ircd.h" |
| 32 |
|
#include "irc_string.h" |
| 33 |
< |
#include "sprintf_irc.h" |
| 33 |
> |
#include "parse.h" |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
static char buf[IRCD_BUFSIZE]; |
| 38 |
– |
static void m_map(struct Client *, struct Client *, int, char *[]); |
| 39 |
– |
static void mo_map(struct Client *, struct Client *, int, char *[]); |
| 40 |
– |
static void dump_map(struct Client *, const struct Client *, int, char *); |
| 41 |
– |
|
| 42 |
– |
struct Message map_msgtab = { |
| 43 |
– |
"MAP", 0, 0, 0, 0, MFLG_SLOW, 0, |
| 44 |
– |
{ m_unregistered, m_map, m_ignore, m_ignore, mo_map, m_ignore } |
| 45 |
– |
}; |
| 46 |
– |
|
| 47 |
– |
void |
| 48 |
– |
_modinit(void) |
| 49 |
– |
{ |
| 50 |
– |
mod_add_cmd(&map_msgtab); |
| 51 |
– |
} |
| 52 |
– |
|
| 53 |
– |
void |
| 54 |
– |
_moddeinit(void) |
| 55 |
– |
{ |
| 56 |
– |
mod_del_cmd(&map_msgtab); |
| 57 |
– |
} |
| 58 |
– |
|
| 59 |
– |
const char *_version = "$Revision$"; |
| 60 |
– |
|
| 61 |
– |
|
| 62 |
– |
/* m_map() |
| 63 |
– |
* parv[0] = sender prefix |
| 64 |
– |
*/ |
| 65 |
– |
static void |
| 66 |
– |
m_map(struct Client *client_p, struct Client *source_p, |
| 67 |
– |
int parc, char *parv[]) |
| 68 |
– |
{ |
| 69 |
– |
static time_t last_used = 0; |
| 70 |
– |
|
| 71 |
– |
if (ConfigServerHide.flatten_links) |
| 72 |
– |
{ |
| 73 |
– |
m_not_oper(client_p, source_p, parc, parv); |
| 74 |
– |
return; |
| 75 |
– |
} |
| 76 |
– |
|
| 77 |
– |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 78 |
– |
{ |
| 79 |
– |
/* safe enough to give this on a local connect only */ |
| 80 |
– |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
| 81 |
– |
me.name, source_p->name); |
| 82 |
– |
return; |
| 83 |
– |
} |
| 84 |
– |
|
| 85 |
– |
last_used = CurrentTime; |
| 86 |
– |
|
| 87 |
– |
dump_map(source_p, &me, 0, buf); |
| 88 |
– |
sendto_one(source_p, form_str(RPL_MAPEND), me.name, source_p->name); |
| 89 |
– |
} |
| 90 |
– |
|
| 91 |
– |
/* mo_map() |
| 92 |
– |
* parv[0] = sender prefix |
| 93 |
– |
*/ |
| 94 |
– |
static void |
| 95 |
– |
mo_map(struct Client *client_p, struct Client *source_p, |
| 96 |
– |
int parc, char *parv[]) |
| 97 |
– |
{ |
| 98 |
– |
dump_map(source_p, &me, 0, buf); |
| 99 |
– |
sendto_one(source_p, form_str(RPL_MAPEND), me.name, source_p->name); |
| 100 |
– |
} |
| 37 |
|
|
| 38 |
|
/* dump_map() |
| 39 |
|
* dumps server map, called recursively. |
| 50 |
|
*pbuf= '\0'; |
| 51 |
|
pb = pbuf; |
| 52 |
|
|
| 53 |
< |
l = ircsprintf(pb, "%s", root_p->name); |
| 53 |
> |
l = sprintf(pb, "%s", root_p->name); |
| 54 |
|
pb += l; |
| 55 |
|
len += l; |
| 56 |
|
|
| 57 |
|
if (root_p->id[0] != '\0') |
| 58 |
|
{ |
| 59 |
< |
l = ircsprintf(pb, "[%s]", root_p->id); |
| 59 |
> |
l = sprintf(pb, "[%s]", root_p->id); |
| 60 |
|
pb += l; |
| 61 |
|
len += l; |
| 62 |
|
} |
| 76 |
|
sprintf(pb, " Users: %5d (%1.1f%%)", users, |
| 77 |
|
100 * (float)users / (float)Count.total); |
| 78 |
|
|
| 79 |
< |
sendto_one(client_p, form_str(RPL_MAP), me.name, client_p->name, buf); |
| 79 |
> |
sendto_one(client_p, RPL_MAP, me.name, client_p->name, buf); |
| 80 |
|
|
| 81 |
|
if (root_p->serv->server_list.head) |
| 82 |
|
{ |
| 114 |
|
++i; |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
+ |
|
| 118 |
+ |
/* m_map() |
| 119 |
+ |
* parv[0] = sender prefix |
| 120 |
+ |
*/ |
| 121 |
+ |
static void |
| 122 |
+ |
m_map(struct Client *client_p, struct Client *source_p, |
| 123 |
+ |
int parc, char *parv[]) |
| 124 |
+ |
{ |
| 125 |
+ |
static time_t last_used = 0; |
| 126 |
+ |
|
| 127 |
+ |
if (ConfigServerHide.flatten_links) |
| 128 |
+ |
{ |
| 129 |
+ |
m_not_oper(client_p, source_p, parc, parv); |
| 130 |
+ |
return; |
| 131 |
+ |
} |
| 132 |
+ |
|
| 133 |
+ |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
| 134 |
+ |
{ |
| 135 |
+ |
/* safe enough to give this on a local connect only */ |
| 136 |
+ |
sendto_one(source_p, RPL_LOAD2HI, |
| 137 |
+ |
me.name, source_p->name); |
| 138 |
+ |
return; |
| 139 |
+ |
} |
| 140 |
+ |
|
| 141 |
+ |
last_used = CurrentTime; |
| 142 |
+ |
|
| 143 |
+ |
dump_map(source_p, &me, 0, buf); |
| 144 |
+ |
sendto_one(source_p, RPL_MAPEND, me.name, source_p->name); |
| 145 |
+ |
} |
| 146 |
+ |
|
| 147 |
+ |
/* mo_map() |
| 148 |
+ |
* parv[0] = sender prefix |
| 149 |
+ |
*/ |
| 150 |
+ |
static void |
| 151 |
+ |
mo_map(struct Client *client_p, struct Client *source_p, |
| 152 |
+ |
int parc, char *parv[]) |
| 153 |
+ |
{ |
| 154 |
+ |
dump_map(source_p, &me, 0, buf); |
| 155 |
+ |
sendto_one(source_p, RPL_MAPEND, me.name, source_p->name); |
| 156 |
+ |
} |
| 157 |
+ |
|
| 158 |
+ |
static struct Message map_msgtab = { |
| 159 |
+ |
"MAP", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 160 |
+ |
{ m_unregistered, m_map, m_ignore, m_ignore, mo_map, m_ignore } |
| 161 |
+ |
}; |
| 162 |
+ |
|
| 163 |
+ |
static void |
| 164 |
+ |
module_init(void) |
| 165 |
+ |
{ |
| 166 |
+ |
mod_add_cmd(&map_msgtab); |
| 167 |
+ |
} |
| 168 |
+ |
|
| 169 |
+ |
static void |
| 170 |
+ |
module_exit(void) |
| 171 |
+ |
{ |
| 172 |
+ |
mod_del_cmd(&map_msgtab); |
| 173 |
+ |
} |
| 174 |
+ |
|
| 175 |
+ |
struct module module_entry = { |
| 176 |
+ |
.node = { NULL, NULL, NULL }, |
| 177 |
+ |
.name = NULL, |
| 178 |
+ |
.version = "$Revision$", |
| 179 |
+ |
.handle = NULL, |
| 180 |
+ |
.modinit = module_init, |
| 181 |
+ |
.modexit = module_exit, |
| 182 |
+ |
.flags = 0 |
| 183 |
+ |
}; |