Anope IRC Services  Version 1.8
os_staff.c
Go to the documentation of this file.
1 /* OperServ 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_staff(User * u);
18 static void myOperServHelp(User * u);
19 static int opers_list_callback(SList * slist, int number, void *item,
20  va_list args);
21 static int opers_list(int number, NickCore * nc, User * u, char *level);
22 
29 int AnopeInit(int argc, char **argv)
30 {
31  Command *c;
32 
33  moduleAddAuthor("Anope");
34  moduleAddVersion(VERSION_STRING);
36 
37  c = createCommand("STAFF", do_staff, NULL, OPER_HELP_STAFF, -1, -1,
38  -1, -1);
40 
42 
43  return MOD_CONT;
44 }
45 
49 void AnopeFini(void)
50 {
51 
52 }
53 
54 
59 static void myOperServHelp(User * u)
60 {
61  notice_lang(s_OperServ, u, OPER_HELP_CMD_STAFF);
62 }
63 
69 static int do_staff(User * u)
70 {
71  int idx = 0;
72  User *au = NULL;
73  NickCore *nc;
74  NickAlias *na;
75  int found;
76  int i;
77 
78  notice_lang(s_OperServ, u, OPER_STAFF_LIST_HEADER);
79  slist_enum(&servopers, NULL, &opers_list_callback, u, "OPER");
80  slist_enum(&servadmins, NULL, &opers_list_callback, u, "ADMN");
81 
82  for (idx = 0; idx < RootNumber; idx++) {
83  found = 0;
84  if ((au = finduser(ServicesRoots[idx]))) { /* see if user is online */
85  found = 1;
86  notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', "ROOT",
87  ServicesRoots[idx]);
88  } else if ((nc = findcore(ServicesRoots[idx]))) {
89  for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */
90  na = nc->aliases.list[i];
91  if ((au = finduser(na->nick))) { /* see if user is online */
92  found = 1;
93  notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT,
94  '*', "ROOT", ServicesRoots[idx], na->nick);
95  }
96  }
97  }
98 
99  if (!found)
100  notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', "ROOT",
101  ServicesRoots[idx]);
102 
103  }
104  notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Staff");
105  return MOD_CONT;
106 }
107 
111 static int opers_list_callback(SList * slist, int number, void *item,
112  va_list args)
113 {
114  User *u = va_arg(args, User *);
115  char *level = va_arg(args, char *);
116 
117  return opers_list(number, item, u, level);
118 }
119 
120 
124 static int opers_list(int number, NickCore * nc, User * u, char *level)
125 {
126  User *au = NULL;
127  NickAlias *na;
128  int found;
129  int i;
130 
131  if (!nc)
132  return 0;
133 
134  found = 0;
135  if ((au = finduser(nc->display))) { /* see if user is online */
136  found = 1;
137  notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', level,
138  nc->display);
139  } else {
140  for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */
141  na = nc->aliases.list[i];
142  if ((au = finduser(na->nick))) { /* see if user is online */
143  found = 1;
144  notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, '*', level,
145  nc->display, na->nick);
146  }
147  }
148  }
149 
150  if (!found)
151  notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', level,
152  nc->display);
153 
154  return 1;
155 }
E SList servadmins
Definition: extern.h:971
E int slist_enum(SList *slist, char *range, slist_enumcb_t cb,...)
Definition: slist.c:203
static void myOperServHelp(User *u)
Definition: os_staff.c:59
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
E NickCore * findcore(const char *nick)
Definition: nickserv.c:1263
char * display
Definition: services.h:542
#define OPERSERV
Definition: modules.h:62
void ** list
Definition: slist.h:21
E char * s_OperServ
Definition: extern.h:289
int16 count
Definition: slist.h:23
E User * finduser(const char *nick)
Definition: users.c:323
int AnopeInit(int argc, char **argv)
Definition: os_staff.c:29
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
static int opers_list_callback(SList *slist, int number, void *item, va_list args)
Definition: os_staff.c:111
MDE void moduleSetOperHelp(void(*func)(User *u))
Definition: modules.c:2126
#define MOD_CONT
Definition: modules.h:54
static int opers_list(int number, NickCore *nc, User *u, char *level)
Definition: os_staff.c:124
static int do_staff(User *u)
Definition: os_staff.c:69
char * nick
Definition: services.h:526
void AnopeFini(void)
Definition: os_staff.c:49
Definition: modules.h:99
Definition: slist.h:20
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 ** ServicesRoots
Definition: extern.h:434
SList aliases
Definition: services.h:559
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
E SList servopers
Definition: extern.h:972
E int RootNumber
Definition: extern.h:435
#define MOD_UNIQUE
Definition: module.h:11