ms_cancel.c

Go to the documentation of this file.
00001 /* MemoServ 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: ms_cancel.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_cancel(User * u);
00019 void myMemoServHelp(User * u);
00020 
00027 int AnopeInit(int argc, char **argv)
00028 {
00029     Command *c;
00030 
00031     moduleAddAuthor("Anope");
00032     moduleAddVersion("$Id: ms_cancel.c 1265 2007-08-26 15:33:06Z geniusdex $");
00033     moduleSetType(CORE);
00034     c = createCommand("CANCEL", do_cancel, NULL, MEMO_HELP_CANCEL, -1, -1,
00035                       -1, -1);
00036     moduleAddCommand(MEMOSERV, c, MOD_UNIQUE);
00037     moduleSetMemoHelp(myMemoServHelp);
00038 
00039     return MOD_CONT;
00040 }
00041 
00045 void AnopeFini(void)
00046 {
00047 
00048 }
00049 
00050 
00051 
00056 void myMemoServHelp(User * u)
00057 {
00058     notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CANCEL);
00059 }
00060 
00066 int do_cancel(User * u)
00067 {
00068     int ischan;
00069     int isforbid;
00070     char *name = strtok(NULL, " ");
00071     MemoInfo *mi;
00072 
00073     if (!name) {
00074         syntax_error(s_MemoServ, u, "CANCEL", MEMO_CANCEL_SYNTAX);
00075 
00076     } else if (!nick_recognized(u)) {
00077         notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
00078 
00079     } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) {
00080         if (isforbid) {
00081             notice_lang(s_MemoServ, u,
00082                         ischan ? CHAN_X_FORBIDDEN :
00083                         NICK_X_FORBIDDEN, name);
00084         } else {
00085             notice_lang(s_MemoServ, u,
00086                         ischan ? CHAN_X_NOT_REGISTERED :
00087                         NICK_X_NOT_REGISTERED, name);
00088         }
00089     } else {
00090         int i;
00091 
00092         for (i = mi->memocount - 1; i >= 0; i--) {
00093             if ((mi->memos[i].flags & MF_UNREAD)
00094                 && !stricmp(mi->memos[i].sender, u->na->nc->display)
00095                 && (!(mi->memos[i].flags & MF_NOTIFYS))) {
00096                 delmemo(mi, mi->memos[i].number);
00097                 notice_lang(s_MemoServ, u, MEMO_CANCELLED, name);
00098                 return MOD_CONT;
00099             }
00100         }
00101 
00102         notice_lang(s_MemoServ, u, MEMO_CANCEL_NONE);
00103     }
00104     return MOD_CONT;
00105 }

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