Anope IRC Services  Version 1.8
hs_conf.c
Go to the documentation of this file.
1 #include "module.h"
2 
3 #define AUTHOR "Anope"
4 #define VERSION "1"
5 
9 #define DEFAULT_SETTING "moo"
10 
11 int mShowSetting(User *u);
12 int mReadConfig(int argc, char **argv);
13 
14 char *setting;
15 
16 int AnopeInit(int argc, char **argv) {
17  Command *c;
18  EvtHook *hook;
19  int status = 0;
20 
21  setting = NULL;
22 
23  mReadConfig(0,NULL);
24 
25  c = createCommand("SHOW",mShowSetting,NULL,-1,-1,-1,-1,-1);
26  status = moduleAddCommand(HOSTSERV, c, MOD_HEAD);
27 
29  status = moduleAddEventHook(hook);
30 
31  if(status!=MOD_ERR_OK) {
32  return MOD_STOP;
33  }
34  return MOD_CONT;
35 }
36 
40 void AnopeFini(void) {
41  if(setting)
42  free(setting);
43 }
44 
48 int mShowSetting(User *u) {
49  notice(s_HostServ,u->nick,"Setting in use is [%s]",setting);
50  return MOD_CONT;
51 }
52 
57 int mReadConfig(int argc, char **argv) {
58  char *tmp=NULL;
59  Directive d[] = {{"HSConfigSetting", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}};
61 
62  if(setting) {
63  free(setting);
64  }
65  if(tmp) {
66  setting = tmp;
67  } else {
69  }
70  return MOD_CONT;
71 }
72 
73 
74 /* EOF */
int mShowSetting(User *u)
Definition: hs_conf.c:48
char nick[NICKMAX]
Definition: services.h:875
int AnopeInit(int argc, char **argv)
Definition: hs_conf.c:16
E void notice(char *source, char *dest, const char *fmt,...)
Definition: send.c:274
#define EVENT_RELOAD
Definition: events.h:40
#define PARAM_RELOAD
Definition: services.h:454
#define HOSTSERV
Definition: modules.h:56
#define DEFAULT_SETTING
Definition: hs_conf.c:9
E char * sstrdup(const char *s)
Definition: memory.c:105
#define MOD_STOP
Definition: modules.h:53
int mReadConfig(int argc, char **argv)
Definition: hs_conf.c:57
void AnopeFini(void)
Definition: hs_conf.c:40
char * setting
Definition: hs_conf.c:14
MDE EvtHook * createEventHook(char *name, int(*func)(int argc, char **argv))
Definition: events.c:305
Command * c
Definition: ns_recover.c:17
#define MOD_ERR_OK
Definition: modules.h:71
#define MOD_CONT
Definition: modules.h:54
E char * s_HostServ
Definition: extern.h:303
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
MDE int moduleGetConfigDirective(Directive *h)
Definition: modules.c:2553
#define PARAM_STRING
Definition: services.h:443
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define MOD_HEAD
Definition: module.h:12
MDE int moduleAddEventHook(EvtHook *evh)
Definition: events.c:528