diff options
| author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
|---|---|---|
| committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
| commit | 6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 (patch) | |
| tree | 91b0841faf23087ebe0c74dd4269d181a383f1e7 /src/memoserv.c | |
| parent | 069409cd99cf78ab8bf87a1fe69a833576414fd3 (diff) | |
Insane commit of doom: s/ \t/g
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1681 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/memoserv.c')
| -rw-r--r-- | src/memoserv.c | 638 |
1 files changed, 319 insertions, 319 deletions
diff --git a/src/memoserv.c b/src/memoserv.c index 716bd41e0..0054f3f9c 100644 --- a/src/memoserv.c +++ b/src/memoserv.c @@ -38,94 +38,94 @@ void moduleAddMemoServCmds(void) { */ void ms_init(void) { - moduleAddMemoServCmds(); + moduleAddMemoServCmds(); } /*************************************************************************/ /** * memoserv: Main MemoServ routine. - * Note that the User structure passed to the do_* routines will - * always be valid (non-NULL) and will always have a valid - * NickInfo pointer in the `ni' field. + * Note that the User structure passed to the do_* routines will + * always be valid (non-NULL) and will always have a valid + * NickInfo pointer in the `ni' field. * @param u User Struct * @param buf Buffer containing the privmsg * @return void */ void memoserv(User * u, char *buf) { - const char *cmd, *s; - - cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - s = ""; - } - ircdproto->SendCTCP(findbot(s_MemoServ), u->nick, "PING %s", s); - } else { - if (!u->na && stricmp(cmd, "HELP") != 0) - notice_lang(s_MemoServ, u, NICK_NOT_REGISTERED_HELP, - s_NickServ); - else - mod_run_cmd(s_MemoServ, u, MEMOSERV, cmd); - } + const char *cmd, *s; + + cmd = strtok(buf, " "); + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + s = ""; + } + ircdproto->SendCTCP(findbot(s_MemoServ), u->nick, "PING %s", s); + } else { + if (!u->na && stricmp(cmd, "HELP") != 0) + notice_lang(s_MemoServ, u, NICK_NOT_REGISTERED_HELP, + s_NickServ); + else + mod_run_cmd(s_MemoServ, u, MEMOSERV, cmd); + } } /*************************************************************************/ /** * check_memos: See if the given user has any unread memos, and send a - * NOTICE to that user if so (and if the appropriate flag is - * set). + * NOTICE to that user if so (and if the appropriate flag is + * set). * @param u User Struct * @return void */ void check_memos(User * u) { - NickCore *nc; - int i, newcnt = 0; - - if (!u) { - if (debug) { - alog("debug: check_memos called with NULL values"); - } - return; - } - - if (!(nc = (u->na ? u->na->nc : NULL)) || !nick_recognized(u) || - !(nc->flags & NI_MEMO_SIGNON)) { - return; - } - - for (i = 0; i < nc->memos.memocount; i++) { - if (nc->memos.memos[i].flags & MF_UNREAD) - newcnt++; - } - if (newcnt > 0) { - notice_lang(s_MemoServ, u, - newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS, - newcnt); - if (newcnt == 1 && (nc->memos.memos[i - 1].flags & MF_UNREAD)) { - notice_lang(s_MemoServ, u, MEMO_TYPE_READ_LAST, s_MemoServ); - } else if (newcnt == 1) { - for (i = 0; i < nc->memos.memocount; i++) { - if (nc->memos.memos[i].flags & MF_UNREAD) - break; - } - notice_lang(s_MemoServ, u, MEMO_TYPE_READ_NUM, s_MemoServ, - nc->memos.memos[i].number); - } else { - notice_lang(s_MemoServ, u, MEMO_TYPE_LIST_NEW, s_MemoServ); - } - } - if (nc->memos.memomax > 0 && nc->memos.memocount >= nc->memos.memomax) { - if (nc->memos.memocount > nc->memos.memomax) - notice_lang(s_MemoServ, u, MEMO_OVER_LIMIT, nc->memos.memomax); - else - notice_lang(s_MemoServ, u, MEMO_AT_LIMIT, nc->memos.memomax); - } + NickCore *nc; + int i, newcnt = 0; + + if (!u) { + if (debug) { + alog("debug: check_memos called with NULL values"); + } + return; + } + + if (!(nc = (u->na ? u->na->nc : NULL)) || !nick_recognized(u) || + !(nc->flags & NI_MEMO_SIGNON)) { + return; + } + + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].flags & MF_UNREAD) + newcnt++; + } + if (newcnt > 0) { + notice_lang(s_MemoServ, u, + newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS, + newcnt); + if (newcnt == 1 && (nc->memos.memos[i - 1].flags & MF_UNREAD)) { + notice_lang(s_MemoServ, u, MEMO_TYPE_READ_LAST, s_MemoServ); + } else if (newcnt == 1) { + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].flags & MF_UNREAD) + break; + } + notice_lang(s_MemoServ, u, MEMO_TYPE_READ_NUM, s_MemoServ, + nc->memos.memos[i].number); + } else { + notice_lang(s_MemoServ, u, MEMO_TYPE_LIST_NEW, s_MemoServ); + } + } + if (nc->memos.memomax > 0 && nc->memos.memocount >= nc->memos.memomax) { + if (nc->memos.memocount > nc->memos.memomax) + notice_lang(s_MemoServ, u, MEMO_OVER_LIMIT, nc->memos.memomax); + else + notice_lang(s_MemoServ, u, MEMO_AT_LIMIT, nc->memos.memomax); + } } /*************************************************************************/ @@ -142,41 +142,41 @@ void check_memos(User * u) */ MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid) { - if (*name == '#') { - ChannelInfo *ci; - if (ischan) - *ischan = 1; - ci = cs_findchan(name); - if (ci) { - if (!(ci->flags & CI_VERBOTEN)) { - *isforbid = 0; - return &ci->memos; - } else { - *isforbid = 1; - return NULL; - } - } else { - *isforbid = 0; - return NULL; - } - } else { - NickAlias *na; - if (ischan) - *ischan = 0; - na = findnick(name); - if (na) { - if (!(na->status & NS_VERBOTEN)) { - *isforbid = 0; - return &na->nc->memos; - } else { - *isforbid = 1; - return NULL; - } - } else { - *isforbid = 0; - return NULL; - } - } + if (*name == '#') { + ChannelInfo *ci; + if (ischan) + *ischan = 1; + ci = cs_findchan(name); + if (ci) { + if (!(ci->flags & CI_VERBOTEN)) { + *isforbid = 0; + return &ci->memos; + } else { + *isforbid = 1; + return NULL; + } + } else { + *isforbid = 0; + return NULL; + } + } else { + NickAlias *na; + if (ischan) + *ischan = 0; + na = findnick(name); + if (na) { + if (!(na->status & NS_VERBOTEN)) { + *isforbid = 0; + return &na->nc->memos; + } else { + *isforbid = 1; + return NULL; + } + } else { + *isforbid = 0; + return NULL; + } + } } /*************************************************************************/ @@ -195,139 +195,139 @@ MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid) */ void memo_send(User * u, char *name, char *text, int z) { - int ischan; - int isforbid; - Memo *m; - MemoInfo *mi; - time_t now = time(NULL); - char *source = u->na->nc->display; - int is_servoper = is_services_oper(u); - - if (readonly) { - notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); - } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { - notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); - return; - } else if (!text) { - if (z == 0) - syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); - - if (z == 3) - syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); - - } else if (!nick_recognized(u)) { - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - - } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { - if (z == 0 || z == 3) { - if (isforbid) { - notice_lang(s_MemoServ, u, - ischan ? CHAN_X_FORBIDDEN : - NICK_X_FORBIDDEN, name); - } else { - notice_lang(s_MemoServ, u, - ischan ? CHAN_X_NOT_REGISTERED : - NICK_X_NOT_REGISTERED, name); - } - } - } else if (z != 2 && MSSendDelay > 0 && - u && u->lastmemosend + MSSendDelay > now && !is_servoper) { - u->lastmemosend = now; - if (z == 0) - notice_lang(s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, MSSendDelay); - - if (z == 3) - notice_lang(s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, - MSSendDelay); - - } else if (mi->memomax == 0 && !is_servoper) { - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name); - - } else if (mi->memomax > 0 && mi->memocount >= mi->memomax - && !is_servoper) { - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name); - - } else { - u->lastmemosend = now; - mi->memocount++; - mi->memos = (Memo *)srealloc(mi->memos, sizeof(Memo) * mi->memocount); - m = &mi->memos[mi->memocount - 1]; - strscpy(m->sender, source, NICKMAX); - m->moduleData = NULL; - if (mi->memocount > 1) { - m->number = m[-1].number + 1; - if (m->number < 1) { - int i; - for (i = 0; i < mi->memocount; i++) { - mi->memos[i].number = i + 1; - } - } - } else { - m->number = 1; - } - m->time = time(NULL); - m->text = sstrdup(text); - m->flags = MF_UNREAD; - /* Set notify sent flag - DrStein */ - if (z == 2) { - m->flags |= MF_NOTIFYS; - } - /* Set receipt request flag */ - if (z == 3) - m->flags |= MF_RECEIPT; - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, MEMO_SENT, name); - if (!ischan) { - NickAlias *na; - NickCore *nc = (findnick(name))->nc; - - if (MSNotifyAll) { - if ((nc->flags & NI_MEMO_RECEIVE) - && get_ignore(name) == NULL) { - int i; - - for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; - if (na->u && nick_identified(na->u)) - notice_lang(s_MemoServ, na->u, - MEMO_NEW_MEMO_ARRIVED, source, - s_MemoServ, m->number); - } - } else { - if ((u = finduser(name)) && nick_identified(u) - && (nc->flags & NI_MEMO_RECEIVE)) - notice_lang(s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED, - source, s_MemoServ, m->number); - } /* if (flags & MEMO_RECEIVE) */ - } - /* if (MSNotifyAll) */ - /* let's get out the mail if set in the nickcore - certus */ - if (nc->flags & NI_MEMO_MAIL) - new_memo_mail(nc, m); - } else { - struct c_userlist *cu, *next; - Channel *c; - - if (MSNotifyAll && (c = findchan(name))) { - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (check_access(cu->user, c->ci, CA_MEMO)) { - if (cu->user->na - && (cu->user->na->nc->flags & NI_MEMO_RECEIVE) - && get_ignore(cu->user->nick) == NULL) { - notice_lang(s_MemoServ, cu->user, - MEMO_NEW_X_MEMO_ARRIVED, - c->ci->name, s_MemoServ, - c->ci->name, m->number); - } - } - } - } /* MSNotifyAll */ - } /* if (!ischan) */ - } /* if command is valid */ + int ischan; + int isforbid; + Memo *m; + MemoInfo *mi; + time_t now = time(NULL); + char *source = u->na->nc->display; + int is_servoper = is_services_oper(u); + + if (readonly) { + notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); + } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { + notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); + return; + } else if (!text) { + if (z == 0) + syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); + + if (z == 3) + syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); + + } else if (!nick_recognized(u)) { + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + + } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { + if (z == 0 || z == 3) { + if (isforbid) { + notice_lang(s_MemoServ, u, + ischan ? CHAN_X_FORBIDDEN : + NICK_X_FORBIDDEN, name); + } else { + notice_lang(s_MemoServ, u, + ischan ? CHAN_X_NOT_REGISTERED : + NICK_X_NOT_REGISTERED, name); + } + } + } else if (z != 2 && MSSendDelay > 0 && + u && u->lastmemosend + MSSendDelay > now && !is_servoper) { + u->lastmemosend = now; + if (z == 0) + notice_lang(s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, MSSendDelay); + + if (z == 3) + notice_lang(s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, + MSSendDelay); + + } else if (mi->memomax == 0 && !is_servoper) { + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name); + + } else if (mi->memomax > 0 && mi->memocount >= mi->memomax + && !is_servoper) { + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name); + + } else { + u->lastmemosend = now; + mi->memocount++; + mi->memos = (Memo *)srealloc(mi->memos, sizeof(Memo) * mi->memocount); + m = &mi->memos[mi->memocount - 1]; + strscpy(m->sender, source, NICKMAX); + m->moduleData = NULL; + if (mi->memocount > 1) { + m->number = m[-1].number + 1; + if (m->number < 1) { + int i; + for (i = 0; i < mi->memocount; i++) { + mi->memos[i].number = i + 1; + } + } + } else { + m->number = 1; + } + m->time = time(NULL); + m->text = sstrdup(text); + m->flags = MF_UNREAD; + /* Set notify sent flag - DrStein */ + if (z == 2) { + m->flags |= MF_NOTIFYS; + } + /* Set receipt request flag */ + if (z == 3) + m->flags |= MF_RECEIPT; + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, MEMO_SENT, name); + if (!ischan) { + NickAlias *na; + NickCore *nc = (findnick(name))->nc; + + if (MSNotifyAll) { + if ((nc->flags & NI_MEMO_RECEIVE) + && get_ignore(name) == NULL) { + int i; + + for (i = 0; i < nc->aliases.count; i++) { + na = (NickAlias *)nc->aliases.list[i]; + if (na->u && nick_identified(na->u)) + notice_lang(s_MemoServ, na->u, + MEMO_NEW_MEMO_ARRIVED, source, + s_MemoServ, m->number); + } + } else { + if ((u = finduser(name)) && nick_identified(u) + && (nc->flags & NI_MEMO_RECEIVE)) + notice_lang(s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED, + source, s_MemoServ, m->number); + } /* if (flags & MEMO_RECEIVE) */ + } + /* if (MSNotifyAll) */ + /* let's get out the mail if set in the nickcore - certus */ + if (nc->flags & NI_MEMO_MAIL) + new_memo_mail(nc, m); + } else { + struct c_userlist *cu, *next; + Channel *c; + + if (MSNotifyAll && (c = findchan(name))) { + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (check_access(cu->user, c->ci, CA_MEMO)) { + if (cu->user->na + && (cu->user->na->nc->flags & NI_MEMO_RECEIVE) + && get_ignore(cu->user->nick) == NULL) { + notice_lang(s_MemoServ, cu->user, + MEMO_NEW_X_MEMO_ARRIVED, + c->ci->name, s_MemoServ, + c->ci->name, m->number); + } + } + } + } /* MSNotifyAll */ + } /* if (!ischan) */ + } /* if command is valid */ } /*************************************************************************/ @@ -339,53 +339,53 @@ void memo_send(User * u, char *name, char *text, int z) */ int delmemo(MemoInfo * mi, int num) { - int i; - - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].number == num) - break; - } - if (i < mi->memocount) { - moduleCleanStruct(&mi->memos[i].moduleData); - free(mi->memos[i].text); /* Deallocate memo text memory */ - mi->memocount--; /* One less memo now */ - if (i < mi->memocount) /* Move remaining memos down a slot */ - memmove(mi->memos + i, mi->memos + i + 1, - sizeof(Memo) * (mi->memocount - i)); - if (mi->memocount == 0) { /* If no more memos, free array */ - free(mi->memos); - mi->memos = NULL; - } - return 1; - } else { - return 0; - } + int i; + + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].number == num) + break; + } + if (i < mi->memocount) { + moduleCleanStruct(&mi->memos[i].moduleData); + free(mi->memos[i].text); /* Deallocate memo text memory */ + mi->memocount--; /* One less memo now */ + if (i < mi->memocount) /* Move remaining memos down a slot */ + memmove(mi->memos + i, mi->memos + i + 1, + sizeof(Memo) * (mi->memocount - i)); + if (mi->memocount == 0) { /* If no more memos, free array */ + free(mi->memos); + mi->memos = NULL; + } + return 1; + } else { + return 0; + } } /*************************************************************************/ static void new_memo_mail(NickCore * nc, Memo * m) { - MailInfo *mail = NULL; - - if (!nc || !m) - return; - - mail = MailMemoBegin(nc); - if (!mail) { - return; - } - fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT1), nc->display); - fprintf(mail->pipe, "\n"); - fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT2), m->sender, - m->number); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring2(NULL, MEMO_MAIL_TEXT3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", m->text); - fprintf(mail->pipe, "\n"); - MailEnd(mail); - return; + MailInfo *mail = NULL; + + if (!nc || !m) + return; + + mail = MailMemoBegin(nc); + if (!mail) { + return; + } + fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT1), nc->display); + fprintf(mail->pipe, "\n"); + fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT2), m->sender, + m->number); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, "%s", getstring2(NULL, MEMO_MAIL_TEXT3)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, "%s", m->text); + fprintf(mail->pipe, "\n"); + MailEnd(mail); + return; } @@ -394,49 +394,49 @@ static void new_memo_mail(NickCore * nc, Memo * m) void rsend_notify(User * u, Memo * m, const char *chan) { - NickAlias *na; - NickCore *nc; - char text[256]; - const char *fmt; - - /* Only send receipt if memos are allowed */ - if ((!readonly) && (!checkDefCon(DEFCON_NO_NEW_MEMOS))) { - - /* Get nick alias for sender */ - na = findnick(m->sender); - - if (!na) { - return; - } - - /* Get nick core for sender */ - nc = na->nc; - - if (!nc) { - return; - } - - /* Text of the memo varies if the recepient was a - nick or channel */ - if (chan) { - fmt = getstring(na, MEMO_RSEND_CHAN_MEMO_TEXT); - sprintf(text, fmt, chan); - } else { - fmt = getstring(na, MEMO_RSEND_NICK_MEMO_TEXT); - sprintf(text, "%s", fmt); - } - - /* Send notification */ - memo_send(u, m->sender, text, 2); - - /* Notify recepient of the memo that a notification has - been sent to the sender */ - notice_lang(s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, - nc->display); - } - - /* Remove receipt flag from the original memo */ - m->flags &= ~MF_RECEIPT; - - return; + NickAlias *na; + NickCore *nc; + char text[256]; + const char *fmt; + + /* Only send receipt if memos are allowed */ + if ((!readonly) && (!checkDefCon(DEFCON_NO_NEW_MEMOS))) { + + /* Get nick alias for sender */ + na = findnick(m->sender); + + if (!na) { + return; + } + + /* Get nick core for sender */ + nc = na->nc; + + if (!nc) { + return; + } + + /* Text of the memo varies if the recepient was a + nick or channel */ + if (chan) { + fmt = getstring(na, MEMO_RSEND_CHAN_MEMO_TEXT); + sprintf(text, fmt, chan); + } else { + fmt = getstring(na, MEMO_RSEND_NICK_MEMO_TEXT); + sprintf(text, "%s", fmt); + } + + /* Send notification */ + memo_send(u, m->sender, text, 2); + + /* Notify recepient of the memo that a notification has + been sent to the sender */ + notice_lang(s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, + nc->display); + } + + /* Remove receipt flag from the original memo */ + m->flags &= ~MF_RECEIPT; + + return; } |
