os_modinfo.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_modinfo.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_modinfo(User * u);
00019 void myOperServHelp(User * u);
00020 int showModuleMsgLoaded(MessageHash * msgList, char *mod_name, User * u);
00021 int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name, User * u);
00022 
00029 int AnopeInit(int argc, char **argv)
00030 {
00031     Command *c;
00032 
00033     moduleAddAuthor("Anope");
00034     moduleAddVersion("$Id: os_modinfo.c 1265 2007-08-26 15:33:06Z geniusdex $");
00035     moduleSetType(CORE);
00036     c = createCommand("MODINFO", do_modinfo, NULL, -1, -1, -1, -1,
00037                       OPER_HELP_MODINFO);
00038     moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00039 
00040     moduleSetOperHelp(myOperServHelp);
00041 
00042     return MOD_CONT;
00043 }
00044 
00048 void AnopeFini(void)
00049 {
00050 
00051 }
00052 
00053 
00058 void myOperServHelp(User * u)
00059 {
00060     notice_lang(s_OperServ, u, OPER_HELP_CMD_MODINFO);
00061 }
00062 
00068 int do_modinfo(User * u)
00069 {
00070     char *file;
00071     struct tm tm;
00072     char timebuf[64];
00073     Module *m;
00074     int idx = 0;
00075 
00076     file = strtok(NULL, "");
00077     if (!file) {
00078         syntax_error(s_OperServ, u, "MODINFO", OPER_MODULE_INFO_SYNTAX);
00079         return MOD_CONT;
00080     }
00081     m = findModule(file);
00082     if (m) {
00083         tm = *localtime(&m->time);
00084         strftime_lang(timebuf, sizeof(timebuf), u,
00085                       STRFTIME_DATE_TIME_FORMAT, &tm);
00086         notice_lang(s_OperServ, u, OPER_MODULE_INFO_LIST, m->name,
00087                     m->version ? m->version : "?",
00088                     m->author ? m->author : "?", timebuf);
00089         for (idx = 0; idx < MAX_CMD_HASH; idx++) {
00090             showModuleCmdLoaded(HOSTSERV[idx], m->name, u);
00091             showModuleCmdLoaded(OPERSERV[idx], m->name, u);
00092             showModuleCmdLoaded(NICKSERV[idx], m->name, u);
00093             showModuleCmdLoaded(CHANSERV[idx], m->name, u);
00094             showModuleCmdLoaded(BOTSERV[idx], m->name, u);
00095             showModuleCmdLoaded(MEMOSERV[idx], m->name, u);
00096             showModuleCmdLoaded(HELPSERV[idx], m->name, u);
00097             showModuleMsgLoaded(IRCD[idx], m->name, u);
00098 
00099         }
00100     } else {
00101         notice_lang(s_OperServ, u, OPER_MODULE_NO_INFO, file);
00102     }
00103     return MOD_CONT;
00104 }
00105 
00106 int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name, User * u)
00107 {
00108     Command *c;
00109     CommandHash *current;
00110     int display = 0;
00111 
00112     for (current = cmdList; current; current = current->next) {
00113         for (c = current->c; c; c = c->next) {
00114             if ((c->mod_name) && (stricmp(c->mod_name, mod_name) == 0)) {
00115                 notice_lang(s_OperServ, u, OPER_MODULE_CMD_LIST,
00116                             c->service, c->name);
00117                 display++;
00118             }
00119         }
00120     }
00121     return display;
00122 }
00123 
00124 int showModuleMsgLoaded(MessageHash * msgList, char *mod_name, User * u)
00125 {
00126     Message *msg;
00127     MessageHash *mcurrent;
00128     int display = 0;
00129     for (mcurrent = msgList; mcurrent; mcurrent = mcurrent->next) {
00130         for (msg = mcurrent->m; msg; msg = msg->next) {
00131             if ((msg->mod_name) && (stricmp(msg->mod_name, mod_name) == 0)) {
00132                 notice_lang(s_OperServ, u, OPER_MODULE_MSG_LIST,
00133                             msg->name);
00134                 display++;
00135             }
00136         }
00137     }
00138     return display;
00139 }

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