Anope IRC Services  Version 1.8
hs_off.c
Go to the documentation of this file.
1 /* HostServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 /*************************************************************************/
14 
15 #include "module.h"
16 
17 static int do_off(User * u);
18 static void myHostServHelp(User * u);
19 
26 int AnopeInit(int argc, char **argv)
27 {
28  Command *c;
29 
30  moduleAddAuthor("Anope");
31  moduleAddVersion(VERSION_STRING);
33 
34  c = createCommand("OFF", do_off, NULL, HOST_HELP_OFF, -1, -1, -1, -1);
36 
38 
39  return MOD_CONT;
40 }
41 
45 void AnopeFini(void)
46 {
47 
48 }
49 
50 
51 
56 static void myHostServHelp(User * u)
57 {
58  notice_lang(s_HostServ, u, HOST_HELP_CMD_OFF);
59 }
60 
66 static int do_off(User * u)
67 {
68  NickAlias *na;
69  char *vhost;
70  char *vident = NULL;
71  if ((na = findnick(u->nick))) {
72  if (na->status & NS_IDENTIFIED) {
73  vhost = getvHost(u->nick);
74  vident = getvIdent(u->nick);
75  if (vhost == NULL && vident == NULL)
76  notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
77  else {
79  if (u->vhost)
80  free(u->vhost);
81  u->vhost = NULL;
82  }
83  } else {
84  notice_lang(s_HostServ, u, HOST_ID);
85  }
86  } else {
87  notice_lang(s_HostServ, u, HOST_NOT_REGED);
88  }
89  return MOD_CONT;
90 }
E char * getvIdent(char *nick)
Definition: hostserv.c:330
char nick[NICKMAX]
Definition: services.h:875
E NickAlias * findnick(const char *nick)
Definition: db-merger.c:1857
static int do_off(User *u)
Definition: hs_off.c:66
char * vhost
Definition: services.h:880
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
#define HOSTSERV
Definition: modules.h:56
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
static void myHostServHelp(User *u)
Definition: hs_off.c:56
uint16 status
Definition: services.h:532
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
E void anope_cmd_vhost_off(User *u)
Definition: ircd.c:151
#define MOD_CONT
Definition: modules.h:54
E char * s_HostServ
Definition: extern.h:303
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
E char * getvHost(char *nick)
Definition: hostserv.c:315
int AnopeInit(int argc, char **argv)
Definition: hs_off.c:26
#define NS_IDENTIFIED
Definition: services.h:1275
void AnopeFini(void)
Definition: hs_off.c:45
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
MDE void moduleSetHostHelp(void(*func)(User *u))
Definition: modules.c:2138
#define MOD_UNIQUE
Definition: module.h:11