X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_map.c;h=ffbcb183ab0d8ead99605c2b3985759c8daffe14;hb=refs%2Fheads%2Fupstream;hp=16b55cb54916e4b5cae7744ead2f6900e2695e27;hpb=ae91ef6320f611af74e70a0db2620c338fbaa7d5;p=ircu2.10.12-pk.git diff --git a/ircd/m_map.c b/ircd/m_map.c index 16b55cb..ffbcb18 100644 --- a/ircd/m_map.c +++ b/ircd/m_map.c @@ -79,23 +79,88 @@ * note: it is guaranteed that parv[0]..parv[parc-1] are all * non-NULL pointers. */ -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ +#include "config.h" + #include "client.h" #include "ircd.h" +#include "ircd_defs.h" +#include "ircd_features.h" +#include "ircd_log.h" #include "ircd_reply.h" +#include "ircd_snprintf.h" #include "ircd_string.h" -#include "map.h" +#include "list.h" +#include "match.h" +#include "msg.h" #include "numeric.h" +#include "s_user.h" +#include "s_serv.h" #include "send.h" +#include "querycmds.h" + +/* #include -- Now using assert in ircd_log.h */ +#include +#include + +static void dump_map(struct Client *cptr, struct Client *server, char *mask, int prompt_length) +{ + const char *chr; + static char prompt[64]; + struct DLink *lp; + char *p = prompt + prompt_length; + int cnt = 0; + + *p = '\0'; + if (prompt_length > 60) + send_reply(cptr, RPL_MAPMORE, prompt, cli_name(server)); + else + { + char lag[512]; + if (cli_serv(server)->lag>10000) + lag[0]=0; + else if (cli_serv(server)->lag<0) + strcpy(lag,"(0s)"); + else + sprintf(lag,"(%is)",cli_serv(server)->lag); + if (IsBurst(server)) + chr = "*"; + else if (IsBurstAck(server)) + chr = "!"; + else + chr = ""; + send_reply(cptr, RPL_MAP, prompt, chr, cli_name(server), + lag, (server == &me) ? UserStats.local_clients : + cli_serv(server)->clients); + } + if (prompt_length > 0) + { + p[-1] = ' '; + if (p[-2] == '`') + p[-2] = ' '; + } + if (prompt_length > 60) + return; + strcpy(p, "|-"); + for (lp = cli_serv(server)->down; lp; lp = lp->next) + if (match(mask, cli_name(lp->value.cptr))) + ClrFlag(lp->value.cptr, FLAG_MAP); + else + { + SetFlag(lp->value.cptr, FLAG_MAP); + cnt++; + } + for (lp = cli_serv(server)->down; lp; lp = lp->next) + { + if (!HasFlag(lp->value.cptr, FLAG_MAP)) + continue; + if (--cnt == 0) + *p = '`'; + dump_map(cptr, lp->value.cptr, mask, prompt_length + 2); + } + if (prompt_length > 0) + p[-1] = '-'; +} -#include /* * m_map - generic message handler @@ -106,32 +171,28 @@ */ int m_map(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { + if (feature_bool(FEAT_HIS_MAP) && !IsAnOper(sptr)) + { + sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :%s %s", sptr, + "/MAP has been disabled, from CFV-165. " + "Visit ", feature_str(FEAT_HIS_URLSERVERS)); + return 0; + } if (parc < 2) parv[1] = "*"; - dump_map(sptr, &me, parv[1], 0); - sendto_one(sptr, rpl_str(RPL_MAPEND), me.name, parv[0]); + send_reply(sptr, RPL_MAPEND); return 0; } - -#if 0 -/* - * m_map -- by Run - * - * parv[0] = sender prefix - * parv[1] = server mask - */ -int m_map(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +int mo_map(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { if (parc < 2) parv[1] = "*"; dump_map(sptr, &me, parv[1], 0); - sendto_one(sptr, rpl_str(RPL_MAPEND), me.name, parv[0]); + send_reply(sptr, RPL_MAPEND); return 0; } -#endif /* 0 */ -