Anope IRC Services  Version 1.8
hs_on.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_on(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("ON", do_on, NULL, HOST_HELP_ON, -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_ON);
59 }
60 
66 static int do_on(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) {
76  notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED);
77  } else {
78  if (vIdent) {
79  notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED,
80  vIdent, vHost);
81  } else {
82  notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost);
83  }
84  anope_cmd_vhost_on(u->nick, vIdent, vHost);
85  if (ircd->vhost) {
86  if (u->vhost)
87  free(u->vhost);
88  u->vhost = sstrdup(vHost);
89  }
90  if (ircd->vident) {
91  if (vIdent) {
92  if (u->vident)
93  free(u->vident);
94  u->vident = sstrdup(vIdent);
95  }
96  }
97  set_lastmask(u);
98  }
99  } else {
100  notice_lang(s_HostServ, u, HOST_ID);
101  }
102  } else {
103  notice_lang(s_HostServ, u, HOST_NOT_REGED);
104  }
105  return MOD_CONT;
106 }
E char * getvIdent(char *nick)
Definition: hostserv.c:330
E void set_lastmask(User *u)
Definition: hostserv.c:647
char nick[NICKMAX]
Definition: services.h:875
E NickAlias * findnick(const char *nick)
Definition: db-merger.c:1857
void AnopeFini(void)
Definition: hs_on.c:45
E IRCDVar * ircd
Definition: extern.h:39
char * vhost
Definition: services.h:880
int vhost
Definition: services.h:301
E void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost)
Definition: ircd.c:549
int vident
Definition: services.h:337
static int do_on(User *u)
Definition: hs_on.c:66
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
E char * sstrdup(const char *s)
Definition: memory.c:105
uint16 status
Definition: services.h:532
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
static void myHostServHelp(User *u)
Definition: hs_on.c:56
Command * c
Definition: ns_recover.c:17
#define MOD_CONT
Definition: modules.h:54
E char * s_HostServ
Definition: extern.h:303
char * vident
Definition: services.h:882
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_on.c:26
#define NS_IDENTIFIED
Definition: services.h:1275
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