#include "module.h" #define AUTHOR "SGR" #define VERSION "1.01" /* ----------------------------------------------------------- * Name: cs_listall * Author: SGR * Date: 06/12/2003 * ----------------------------------------------------------- * Functions: m_cs_do_list_all. * Limitations: None known. * Tested: Ultimate(2.8.x), Unreal(3.2), Bahamut * ----------------------------------------------------------- * This version has been tested on Ultimate2.8.6, Unreal and * Bahamut. All IRCd's should be compatible with this module. * * Any one-word pattern can be given. * * Please set the config options below. * * ChangeLog * * 1) Works * 2) Added free's for sstrdup'd data. * * -----------------------------------------------------------*/ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ int m_cs_do_list_all(User * u); void SGR_Module_Help_CHANSERV_LISTALL(User *u); int SGR_Module_Help_CHANSERV_LISTALL_FULL(User *u); int AnopeInit(int argc, char **argv) { Command *c; alog("Loading module cs_listall.so"); c = createCommand("LISTALL", m_cs_do_list_all, is_oper,-1,-1,-1,-1,-1); moduleAddCommand(CHANSERV, c, MOD_HEAD); moduleAddHelp(c,SGR_Module_Help_CHANSERV_LISTALL_FULL); moduleSetChanHelp(SGR_Module_Help_CHANSERV_LISTALL); alog("[cs_listall] Command modded: /msg %s LISTALL", s_ChanServ); alog("[cs_listall] Yayness!(tm) - MODULE LOADED AND ACTIVE"); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); return MOD_CONT; } int m_cs_do_list_all(User * u) { ChannelInfo *ci; int i; char buf[BUFSIZE]; int is_servadmin = is_services_admin(u); char *pattern = moduleGetLastBuffer(); if (!is_oper(u)) { notice_lang(s_ChanServ, u, PERMISSION_DENIED); return MOD_CONT; } if (pattern) { pattern = sstrdup(myStrGetToken(pattern,' ',0)); } else { pattern = sstrdup("*"); } notice_lang(s_ChanServ, u, CHAN_LIST_HEADER, pattern); for (i = 0; i < 256; i++) { for (ci = chanlists[i]; ci; ci = ci->next) { if (!is_servadmin && ((ci->flags & CI_PRIVATE) || (ci->flags & CI_VERBOTEN))) { continue; } if (stricmp(pattern, ci->name) == 0 || match_wild_nocase(pattern, ci->name)) { char noexpire_char = ' '; if (is_servadmin && (ci->flags & CI_NO_EXPIRE)) { noexpire_char = '!'; } if (ci->flags & CI_VERBOTEN) { snprintf(buf, sizeof(buf), "%-20s [Forbidden]", ci->name); } else if (ci->flags & CI_SUSPENDED) { snprintf(buf, sizeof(buf), "%-20s [Suspended]", ci->name); } else { snprintf(buf, sizeof(buf), "%-20s %s", ci->name, ci->desc ? ci->desc : ""); } notice_user(s_ChanServ, u, " %c%s", noexpire_char, buf); } } } notice(s_ChanServ, u->nick, "End of List"); if (pattern != NULL) { free(pattern); } return MOD_CONT; } int SGR_Module_Help_CHANSERV_LISTALL_FULL(User *u) { if (is_oper(u)) { notice(s_ChanServ, u->nick, "-----------------------------------------------------------------------"); notice(s_ChanServ, u->nick, "Syntax: LISTALL [pattern] "); notice(s_ChanServ, u->nick, " "); notice(s_ChanServ, u->nick, "The LISTALL command can be used as a substute for the LIST command"); notice(s_ChanServ, u->nick, "for listing registered channels. The LISTALL command ignores"); notice(s_ChanServ, u->nick, "any output limit and lists all channels matching any given pattern."); notice(s_ChanServ, u->nick, "-----------------------------------------------------------------------"); return MOD_CONT; } notice_lang(s_ChanServ, u, PERMISSION_DENIED); return MOD_CONT; } void SGR_Module_Help_CHANSERV_LISTALL(User *u) { if (is_oper(u)) { notice(s_ChanServ,u->nick, " LISTALL Unlimited version of LIST *."); } return; }