os_userlist.c

Go to the documentation of this file.
00001 /* OperServ core functions
00002  *
00003  * (C) 2003-2007 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  * $Id: os_userlist.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 #ifdef _WIN32
00019 extern MDE int anope_get_invite_mode();
00020 extern MDE int anope_get_invis_mode();
00021 #endif
00022 
00023 int do_userlist(User * u);
00024 void myOperServHelp(User * u);
00025 
00032 int AnopeInit(int argc, char **argv)
00033 {
00034     Command *c;
00035 
00036     moduleAddAuthor("Anope");
00037     moduleAddVersion("$Id: os_userlist.c 1265 2007-08-26 15:33:06Z geniusdex $");
00038     moduleSetType(CORE);
00039 
00040     c = createCommand("USERLIST", do_userlist, NULL,
00041                       OPER_HELP_USERLIST, -1, -1, -1, -1);
00042     moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00043 
00044     moduleSetOperHelp(myOperServHelp);
00045 
00046     return MOD_CONT;
00047 }
00048 
00052 void AnopeFini(void)
00053 {
00054 
00055 }
00056 
00057 
00062 void myOperServHelp(User * u)
00063 {
00064     notice_lang(s_OperServ, u, OPER_HELP_CMD_USERLIST);
00065 }
00066 
00073 int do_userlist(User * u)
00074 {
00075     char *pattern = strtok(NULL, " ");
00076     char *opt = strtok(NULL, " ");
00077 
00078     Channel *c;
00079     int modes = 0;
00080 
00081     if (opt && !stricmp(opt, "INVISIBLE"))
00082         modes |= anope_get_invis_mode();
00083 
00084     if (pattern && (c = findchan(pattern))) {
00085         struct c_userlist *cu;
00086 
00087         notice_lang(s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern);
00088 
00089         for (cu = c->users; cu; cu = cu->next) {
00090             if (modes && !(cu->user->mode & modes))
00091                 continue;
00092             notice_lang(s_OperServ, u, OPER_USERLIST_RECORD,
00093                         cu->user->nick, common_get_vident(cu->user),
00094                         common_get_vhost(cu->user));
00095         }
00096     } else {
00097         char mask[BUFSIZE];
00098         int i;
00099         User *u2;
00100 
00101         notice_lang(s_OperServ, u, OPER_USERLIST_HEADER);
00102 
00103         for (i = 0; i < 1024; i++) {
00104             for (u2 = userlist[i]; u2; u2 = u2->next) {
00105                 if (pattern) {
00106                     snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick,
00107                              common_get_vident(u2), common_get_vhost(u2));
00108                     if (!match_wild_nocase(pattern, mask))
00109                         continue;
00110                     if (modes && !(u2->mode & modes))
00111                         continue;
00112                 }
00113                 notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick,
00114                             common_get_vident(u2), common_get_vhost(u2));
00115             }
00116         }
00117     }
00118 
00119     notice_lang(s_OperServ, u, OPER_USERLIST_END);
00120     return MOD_CONT;
00121 }

Generated on Sun Dec 30 09:26:48 2007 for Anope by  doxygen 1.5.1-20070107