#include "unrealircd.h"
-CMD_FUNC(m_whox);
-static int override_who(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]);
-
-/* Place includes here */
#define MSG_WHO "WHO"
-ModuleHeader MOD_HEADER(m_whox)
- = {
- "m_whox", /* Name of module */
- "4.0", /* Version */
- "command /who", /* Short description of module */
- "3.2-b8-1",
- NULL
- };
-
-/* This is called on module init, before Server Ready */
-MOD_INIT(m_whox)
-{
- //CommandAdd(modinfo->handle, MSG_WHO, m_whox, MAXPARA, M_USER);
- MARK_AS_OFFICIAL_MODULE(modinfo);
- IsupportAdd(NULL, "WHOX", NULL);
- return MOD_SUCCESS;
-}
-
-/* Is first run when server is 100% ready */
-MOD_LOAD(m_whox)
-{
- CmdoverrideAddEx(modinfo->handle, "WHO", 9999999, override_who);
- return MOD_SUCCESS;
-}
-
-
-/* Called when module is unloaded */
-MOD_UNLOAD(m_whox)
-{
- Isupport *hunted = IsupportFind("WHOX");
-
- if (hunted)
- IsupportDel(hunted);
-
- return MOD_SUCCESS;
-}
-
-/* Temporary glue until this module becomes the new m_who */
-static int override_who(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[])
-{
- /* We are always last (and we need to be), thanks to our cmdoverride priority */
- return m_whox(cptr, sptr, parc, parv);
-}
-
#define FLAGS_MARK 0x400000 /* marked client (was hybnotice) */
-#define SetMark(x) ((x)->flags |= FLAGS_MARK)
-#define ClearMark(x) ((x)->flags &= ~FLAGS_MARK)
-#define IsMarked(x) ((x)->flags & FLAGS_MARK)
-
-#define EmptyString(x) ((x) == NULL || *(x) == '\0')
-#define CheckEmpty(x) EmptyString(x) ? "" : x
-
-#define HasField(x, y) ((x)->fields & (y))
-#define IsMatch(x, y) ((x)->matchsel & (y))
-
-
#define FIELD_CHANNEL 0x0001
#define FIELD_HOP 0x0002
#define FIELD_FLAGS 0x0004
#define WHO_ADD 1
#define WHO_DEL 2
+#define SetMark(x) ((x)->flags |= FLAGS_MARK)
+#define ClearMark(x) ((x)->flags &= ~FLAGS_MARK)
+#define IsMarked(x) ((x)->flags & FLAGS_MARK)
+
+#define HasField(x, y) ((x)->fields & (y))
+#define IsMatch(x, y) ((x)->matchsel & (y))
+
struct who_format
{
int fields;
const char *querytype;
};
+CMD_FUNC(m_whox);
static void who_global(aClient *source_p, char *mask, int operspy, struct who_format *fmt);
static void do_who(aClient *source_p, aClient *target_p, aChannel *chptr, struct who_format *fmt);
static void do_who_on_channel(aClient *source_p, aChannel *chptr,
- int member, int operspy, struct who_format *fmt);
+ int member, int operspy, struct who_format *fmt);
+static int override_who(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]);
+
+ModuleHeader MOD_HEADER(m_whox)
+ = {
+ "m_whox",
+ "4.0",
+ "command /who",
+ "3.2-b8-1",
+ NULL
+ };
+
+MOD_INIT(m_whox)
+{
+ //CommandAdd(modinfo->handle, MSG_WHO, m_whox, MAXPARA, M_USER);
+ MARK_AS_OFFICIAL_MODULE(modinfo);
+ IsupportAdd(NULL, "WHOX", NULL);
+ return MOD_SUCCESS;
+}
+
+MOD_LOAD(m_whox)
+{
+ CmdoverrideAddEx(modinfo->handle, "WHO", 9999999, override_who);
+ return MOD_SUCCESS;
+}
+
+MOD_UNLOAD(m_whox)
+{
+ Isupport *hunted = IsupportFind("WHOX");
+
+ if (hunted)
+ IsupportDel(hunted);
+
+ return MOD_SUCCESS;
+}
+
+/* Temporary glue until this module becomes the new m_who */
+static int override_who(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[])
+{
+ /* We are always last (and we need to be), thanks to our cmdoverride priority */
+ return m_whox(cptr, sptr, parc, parv);
+}
/*
** m_whox
** parv[1] = nickname mask list
** parv[2] = additional selection flag and format options
*/
-
CMD_FUNC(m_whox)
{
static time_t last_used = 0;
{
p = parv[2];
while (((ch = *(p++))) && (ch != '%') && (ch != ','))
+ {
switch (ch)
{
case 'o': fmt.matchsel |= WMATCH_OPER; continue;
case 'a': fmt.matchsel |= WMATCH_ACCOUNT; continue;
case 'm': fmt.matchsel |= WMATCH_MODES; continue;
}
+ }
}
if ((parc > 2) && (s = strchr(parv[2], '%')) != NULL)
break;
}
}
- if (EmptyString(fmt.querytype) || (strlen(fmt.querytype) > 3))
+ if (BadPtr(fmt.querytype) || (strlen(fmt.querytype) > 3))
fmt.querytype = "0";
}
}
if ((ValidatePermissionsForPath("override:see:who:secret",sptr,NULL,NULL,NULL) ||
- ValidatePermissionsForPath("override:see:whois",sptr,NULL,NULL,NULL)) && (*mask == '!'))
+ ValidatePermissionsForPath("override:see:whois",sptr,NULL,NULL,NULL)) && (*mask == '!'))
{
mask++;
operspy = 1;
- if (EmptyString(mask))
+ if (BadPtr(mask))
{
sendto_one(sptr, getreply(RPL_ENDOFWHO), me.name, sptr->name, parv[1]);
return 0;
umodes = &fmt.noumodes;
for (i = 0; i <= Usermode_highest; i++)
+ {
if (*s == Usermode_Table[i].flag)
{
*umodes |= Usermode_Table[i].mode;
break;
}
+ }
s++;
}
if ((chptr = find_channel(parv[1] + operspy, NULL)) != NULL)
{
if (operspy)
+ {
sendto_snomask_global(SNO_EYES, "*** %s (%s@%s) did a /who on %s",
sptr->name, sptr->user->username, GetHost(sptr),
chptr->chname);
+ }
if (IsMember(sptr, chptr) || operspy)
do_who_on_channel(sptr, chptr, 1, operspy, &fmt);
if (ValidatePermissionsForPath("override:see:who:secret",sptr,NULL,NULL,NULL) ||
ValidatePermissionsForPath("override:see:whois",sptr,NULL,NULL,NULL))
+ {
operspy = 1;
+ }
/* '/who 0' for a global list. this forces clients to actually
* request a full list. I presume its because of too many typos
* output - 1 if match, 0 if no match
* side effects - NONE
*/
-static int
-do_match(aClient *source_p, aClient *target_p, char *mask, struct who_format *fmt)
+static int do_match(aClient *source_p, aClient *target_p, char *mask, struct who_format *fmt)
{
if (mask == NULL)
return 1;
(!match(mask, target_p->user->realhost) ||
(target_p->ip &&
!match(mask, target_p->ip))))))
+ {
return 1;
+ }
/* match nick */
if (IsMatch(fmt, WMATCH_NICK) && !match(mask, target_p->name))
if (IsMatch(fmt, WMATCH_HOST) && (!match(mask, GetHost(target_p)) ||
(IsOper(source_p) && (!match(mask, target_p->user->realhost) ||
(target_p->ip && !match(mask, target_p->ip))))))
+ {
return 1;
+ }
/* match realname */
if (IsMatch(fmt, WMATCH_INFO) && !match(mask, target_p->info))
return 1;
/* match ip address */
- if (IsMatch(fmt, WMATCH_IP) && IsOper(source_p) && target_p->ip &&
- !match(mask, target_p->ip))
+ if (IsMatch(fmt, WMATCH_IP) && IsOper(source_p) && target_p->ip && !match(mask, target_p->ip))
return 1;
/* match account */
- if (IsMatch(fmt, WMATCH_ACCOUNT) && !EmptyString(target_p->user->svid) &&
+ if (IsMatch(fmt, WMATCH_ACCOUNT) && !BadPtr(target_p->user->svid) &&
!isdigit(*target_p->user->svid) && !match(mask, target_p->user->svid))
+ {
return 1;
+ }
/* match usermodes */
if (IsMatch(fmt, WMATCH_MODES) &&
((target_p->umodes & fmt->umodes) &&
!(target_p->umodes & fmt->noumodes) &&
(!(target_p->umodes & UMODE_HIDEOPER) || IsOper(source_p))))
+ {
return 1;
+ }
return 0;
}
* marks matched clients.
*/
-static void
-who_common_channel(aClient *source_p, aChannel *chptr,
+static void who_common_channel(aClient *source_p, aChannel *chptr,
char *mask, int *maxmatches, struct who_format *fmt)
{
Member *cm = chptr->members;
* and will be left cleared on return
*/
-static void
-who_global(aClient *source_p, char *mask, int operspy, struct who_format *fmt)
+static void who_global(aClient *source_p, char *mask, int operspy, struct who_format *fmt)
{
aClient *target_p;
int maxmatches = WHOLIMIT ? WHOLIMIT : 100;
* side effects - do a who on given channel
*/
-static void
-do_who_on_channel(aClient *source_p, aChannel *chptr,
+static void do_who_on_channel(aClient *source_p, aChannel *chptr,
int member, int operspy, struct who_format *fmt)
{
Member *cm = chptr->members;
* this allows detecting overflow
*/
-static void
-append_format(char *buf, size_t bufsize, size_t *pos, const char *fmt, ...)
+static void append_format(char *buf, size_t bufsize, size_t *pos, const char *fmt, ...)
{
size_t max, result;
va_list ap;
* Side Effects - none
*/
-static int
-show_ip(aClient *source_p, aClient *target_p)
+static int show_ip(aClient *source_p, aClient *target_p)
{
if (IsServer(target_p))
return 0;
* side effects - do a who on given person
*/
-static void
-do_who(aClient *source_p, aClient *target_p, aChannel *chptr, struct who_format *fmt)
+static void do_who(aClient *source_p, aClient *target_p, aChannel *chptr, struct who_format *fmt)
{
char status[20];
char str[510 + 1];
status[i] = '\0';
if (fmt->fields == 0)
+ {
sendto_one(source_p, getreply(RPL_WHOREPLY), me.name,
source_p->name, chptr ? chptr->chname : "*",
target_p->user->username, GetHost(target_p),
hide ? "*" : target_p->user->server,
target_p->name, status, hide ? 0 : target_p->hopcount, target_p->info);
- else
+ } else
{
str[0] = '\0';
pos = 0;