| 33 |
|
#include "irc_string.h" |
| 34 |
|
#include "sprintf_irc.h" |
| 35 |
|
|
| 36 |
+ |
|
| 37 |
+ |
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 *, 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} |
| 44 |
> |
{ m_unregistered, m_map, m_ignore, m_ignore, mo_map, m_ignore } |
| 45 |
|
}; |
| 46 |
|
|
| 47 |
|
#ifndef STATIC_MODULES |
| 48 |
< |
void _modinit(void) |
| 48 |
> |
void |
| 49 |
> |
_modinit(void) |
| 50 |
|
{ |
| 51 |
|
mod_add_cmd(&map_msgtab); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
< |
void _moddeinit(void) |
| 54 |
> |
void |
| 55 |
> |
_moddeinit(void) |
| 56 |
|
{ |
| 57 |
|
mod_del_cmd(&map_msgtab); |
| 58 |
|
} |
| 60 |
|
const char *_version = "$Revision$"; |
| 61 |
|
#endif |
| 62 |
|
|
| 59 |
– |
static char buf[IRCD_BUFSIZE]; |
| 63 |
|
|
| 64 |
|
/* m_map() |
| 65 |
|
* parv[0] = sender prefix |
| 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); |
| 81 |
> |
me.name, source_p->name); |
| 82 |
|
return; |
| 83 |
|
} |
| 84 |
< |
else |
| 85 |
< |
last_used = CurrentTime; |
| 84 |
> |
|
| 85 |
> |
last_used = CurrentTime; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
dump_map(client_p, &me, 0, buf); |
| 109 |
|
*/ |
| 110 |
|
static void |
| 111 |
|
dump_map(struct Client *client_p, struct Client *root_p, int start_len, |
| 112 |
< |
char *pbuf) |
| 112 |
> |
char *pbuf) |
| 113 |
|
{ |
| 114 |
|
int cnt = 0, i = 0, l = 0, len = start_len; |
| 115 |
|
int users, dashes; |
| 116 |
|
dlink_node *ptr; |
| 114 |
– |
struct Client *server_p; |
| 117 |
|
char *pb; |
| 118 |
|
|
| 119 |
|
*pbuf= '\0'; |
| 123 |
|
pb += l; |
| 124 |
|
len += l; |
| 125 |
|
|
| 126 |
< |
/* IsOper isn't called *that* often. */ |
| 125 |
< |
if (IsOper(client_p)) |
| 126 |
> |
if (root_p->id[0] != '\0') |
| 127 |
|
{ |
| 128 |
< |
if (root_p->id[0] != '\0') |
| 129 |
< |
{ |
| 130 |
< |
l = ircsprintf(pb, "[%s]", root_p->id); |
| 130 |
< |
pb += l; |
| 131 |
< |
len += l; |
| 132 |
< |
} |
| 128 |
> |
l = ircsprintf(pb, "[%s]", root_p->id); |
| 129 |
> |
pb += l; |
| 130 |
> |
len += l; |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
*pb++ = ' '; |
| 134 |
|
len++; |
| 135 |
|
dashes = 50 - len; |
| 136 |
< |
for(i = 0; i < dashes; i++) |
| 137 |
< |
{ |
| 136 |
> |
|
| 137 |
> |
for (i = 0; i < dashes; i++) |
| 138 |
|
*pb++ = '-'; |
| 139 |
< |
} |
| 139 |
> |
|
| 140 |
|
*pb++ = ' '; |
| 141 |
|
*pb++ = '|'; |
| 142 |
|
|
| 143 |
< |
users = dlink_list_length(&root_p->serv->users); |
| 143 |
> |
users = dlink_list_length(&root_p->serv->client_list); |
| 144 |
|
|
| 145 |
|
sprintf(pb, " Users: %5d (%1.1f%%)", users, |
| 146 |
< |
100 * (float)users / (float)Count.total); |
| 146 |
> |
100 * (float)users / (float)Count.total); |
| 147 |
|
|
| 148 |
|
sendto_one(client_p, form_str(RPL_MAP), me.name, client_p->name, buf); |
| 149 |
< |
|
| 150 |
< |
if (root_p->serv->servers.head) |
| 149 |
> |
|
| 150 |
> |
if (root_p->serv->server_list.head) |
| 151 |
|
{ |
| 152 |
< |
cnt += dlink_list_length(&root_p->serv->servers); |
| 152 |
> |
cnt += dlink_list_length(&root_p->serv->server_list); |
| 153 |
|
|
| 154 |
|
if (cnt) |
| 155 |
|
{ |
| 165 |
|
|
| 166 |
|
i = 1; |
| 167 |
|
|
| 168 |
< |
DLINK_FOREACH(ptr, root_p->serv->servers.head) |
| 168 |
> |
DLINK_FOREACH(ptr, root_p->serv->server_list.head) |
| 169 |
|
{ |
| 170 |
< |
server_p = ptr->data; |
| 170 |
> |
struct Client *server_p = ptr->data; |
| 171 |
|
|
| 172 |
|
*pbuf = ' '; |
| 173 |
+ |
|
| 174 |
|
if (i < cnt) |
| 175 |
|
*(pbuf + 1) = '|'; |
| 176 |
|
else |
| 177 |
|
*(pbuf + 1) = '`'; |
| 178 |
< |
|
| 178 |
> |
|
| 179 |
|
*(pbuf + 2) = '-'; |
| 180 |
|
*(pbuf + 3) = ' '; |
| 181 |
< |
dump_map(client_p, server_p, start_len+4, pbuf+4); |
| 181 |
> |
dump_map(client_p, server_p, start_len + 4, pbuf + 4); |
| 182 |
|
|
| 183 |
|
++i; |
| 184 |
|
} |