hs_group.c

Go to the documentation of this file.
00001 /* HostServ 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: hs_group.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_group(User * u);
00019 void myHostServHelp(User * u);
00020 extern int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask,
00021                       char *creator, time_t time);
00022 
00023 
00030 int AnopeInit(int argc, char **argv)
00031 {
00032     Command *c;
00033 
00034     moduleAddAuthor("Anope");
00035     moduleAddVersion("$Id: hs_group.c 1265 2007-08-26 15:33:06Z geniusdex $");
00036     moduleSetType(CORE);
00037 
00038     c = createCommand("GROUP", do_group, NULL, HOST_HELP_GROUP, -1, -1, -1,
00039                       -1);
00040     moduleAddCommand(HOSTSERV, c, MOD_UNIQUE);
00041 
00042     moduleSetHostHelp(myHostServHelp);
00043 
00044     return MOD_CONT;
00045 }
00046 
00050 void AnopeFini(void)
00051 {
00052 
00053 }
00054 
00055 
00056 
00061 void myHostServHelp(User * u)
00062 {
00063     notice_lang(s_HostServ, u, HOST_HELP_CMD_GROUP);
00064 }
00065 
00071 int do_group(User * u)
00072 {
00073     NickAlias *na;
00074     HostCore *tmp;
00075     char *vHost = NULL;
00076     char *vIdent = NULL;
00077     char *creator = NULL;
00078     HostCore *head = NULL;
00079     time_t time;
00080     boolean found = false;
00081 
00082     head = hostCoreListHead();
00083 
00084     if ((na = findnick(u->nick))) {
00085         if (na->status & NS_IDENTIFIED) {
00086 
00087             tmp = findHostCore(head, u->nick, &found);
00088             if (found) {
00089                 if (tmp == NULL) {
00090                     tmp = head; /* incase first in list */
00091                 } else if (tmp->next) { /* we dont want the previous entry were not inserting! */
00092                     tmp = tmp->next;    /* jump to the next */
00093                 }
00094 
00095                 vHost = sstrdup(tmp->vHost);
00096                 if (tmp->vIdent)
00097                     vIdent = sstrdup(tmp->vIdent);
00098                 creator = sstrdup(tmp->creator);
00099                 time = tmp->time;
00100 
00101                 do_hs_sync(na->nc, vIdent, vHost, creator, time);
00102                 if (tmp->vIdent) {
00103                     notice_lang(s_HostServ, u, HOST_IDENT_GROUP,
00104                                 na->nc->display, vIdent, vHost);
00105                 } else {
00106                     notice_lang(s_HostServ, u, HOST_GROUP, na->nc->display,
00107                                 vHost);
00108                 }
00109                 free(vHost);
00110                 if (vIdent)
00111                     free(vIdent);
00112                 free(creator);
00113 
00114             } else {
00115                 notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
00116             }
00117         } else {
00118             notice_lang(s_HostServ, u, HOST_ID);
00119         }
00120     } else {
00121         notice_lang(s_HostServ, u, HOST_NOT_REGED);
00122     }
00123     return MOD_CONT;
00124 }

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