Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-10-01 03:37:53 UTC
Modified files:
ChangeLog ircd/Makefile.in ircd/gline.c ircd/m_who.c
ircd/m_whois.c ircd/parse.c
Removed files:
include/whocmds.h ircd/whocmds.c
Log message:
Move whocmds.* bits into the only files that use the respective bits.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.713 ircu2.10/ChangeLog:1.714
--- ircu2.10/ChangeLog:1.713 Fri Sep 30 20:04:02 2005
+++ ircu2.10/ChangeLog Fri Sep 30 20:37:43 2005
@@ -1,5 +1,31 @@
2005-09-30 Michael Poole <[EMAIL PROTECTED]>
+ * include/whocmds.h: File becomes unused and almost empty; remove.
+
+ * ircd/whocmds.c: Likewise.
+
+ * ircd/gline.c (count_users): Move from whocmds.c and make static.
+
+ * ircd/m_who.c: Doxygenate comments about command handlers. Do
+ not #include "whocmds.h", but instead #include "ircd_snprintf.h".
+ (WHOSELECT_*): Moved from whocmds.h.
+ (WHO_FIELD_*): Likewise.
+ (IS_VISIBLE_USER): Likewise.
+ (SEE_LUSER): Likewise.
+ (SEE_USER): Likewise.
+ (SHOW_MORE): Likewise.
+ (SEE_CHANNEL): Likewise.
+ (do_who): Move from whocmds.c and make static.
+
+ * ircd/m_whois.c: Do not #include "whocmds.h".
+ (MAX_WHOIS_USERS): Moved from whocmds.h.
+
+ * ircd/parse.c: Do not #include "whocmds.h".
+
+ * ircd/Makefile.in: Remove mention of whocmds. Update depends.
+
+2005-09-30 Michael Poole <[EMAIL PROTECTED]>
+
* ircd/test/Makefile.in: Add missing path component in warning
message about Makefile.in.bak.
Index: ircu2.10/include/whocmds.h
diff -u ircu2.10/include/whocmds.h:1.10 ircu2.10/include/whocmds.h:removed
--- ircu2.10/include/whocmds.h:1.10 Fri Sep 23 19:57:20 2005
+++ ircu2.10/include/whocmds.h Fri Sep 30 20:37:53 2005
@@ -1,92 +0,0 @@
-/** @file whocmds.h
- * @brief Support functions for /WHO-like commands.
- * @version $Id: whocmds.h,v 1.10 2005/09/24 02:57:20 entrope Exp $
- */
-#ifndef INCLUDED_whocmds_h
-#define INCLUDED_whocmds_h
-
-struct Client;
-struct Channel;
-
-
-/*
- * m_who()
- * m_who with support routines rewritten by Nemesi, August 1997
- * - Alghoritm have been flattened (no more recursive)
- * - Several bug fixes
- * - Strong performance improvement
- * - Added possibility to have specific fields in the output
- * See readme.who for further details.
- */
-
-/* Macros used only in here by m_who and its support functions */
-
-#define WHOSELECT_OPER 1 /**< Flag for /WHO: Show IRC operators. */
-#define WHOSELECT_EXTRA 2 /**< Flag for /WHO: Pull rank to see users. */
-#define WHOSELECT_DELAY 4 /**< Flag for /WHO: Show join-delayed users. */
-
-#define WHO_FIELD_QTY 1 /**< Display query type. */
-#define WHO_FIELD_CHA 2 /**< Show common channel name. */
-#define WHO_FIELD_UID 4 /**< Show username. */
-#define WHO_FIELD_NIP 8 /**< Show IP address. */
-#define WHO_FIELD_HOS 16 /**< Show hostname. */
-#define WHO_FIELD_SER 32 /**< Show server. */
-#define WHO_FIELD_NIC 64 /**< Show nickname. */
-#define WHO_FIELD_FLA 128 /**< Show flags (away, oper, chanop, etc). */
-#define WHO_FIELD_DIS 256 /**< Show hop count (distance). */
-#define WHO_FIELD_REN 512 /**< Show realname (info). */
-#define WHO_FIELD_IDL 1024 /**< Show idle time. */
-#define WHO_FIELD_ACC 2048 /**< Show account name. */
-
-/** Default fields for /WHO */
-#define WHO_FIELD_DEF ( WHO_FIELD_NIC | WHO_FIELD_UID | WHO_FIELD_HOS |
WHO_FIELD_SER )
-
-/** Is \a ac plainly visible to \a s?
- * @param[in] s Client trying to see \a ac.
- * @param[in] ac Client being looked at.
- */
-#define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
-
-/** Can \a s see \a ac by using the flags in \a b?
- * @param[in] s Client trying to see \a ac.
- * @param[in] ac Client being looked at.
- * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
- */
-#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || \
- ((b & WHOSELECT_EXTRA) && MyConnect(ac) && \
- (HasPriv((s), PRIV_SHOW_INVIS) || \
- HasPriv((s), PRIV_SHOW_ALL_INVIS))))
-
-/** Can \a s see \a ac by using the flags in \a b?
- * @param[in] s Client trying to see \a ac.
- * @param[in] ac Client being looked at.
- * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
- */
-#define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || \
- ((b & WHOSELECT_EXTRA) && \
- HasPriv((s), PRIV_SHOW_ALL_INVIS)))
-
-/** Should we show more clients to \a sptr?
- * @param[in] sptr Client listing other users.
- * @param[in,out] counter Default count for clients.
- */
-#define SHOW_MORE(sptr, counter) (HasPriv(sptr, PRIV_UNLIMIT_QUERY) ||
(!(counter-- < 0)) )
-
-/** Can \a s see \a chptr?
- * @param[in] s Client trying to see \a chptr.
- * @param[in] chptr Channel being looked at.
- * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
- */
-#define SEE_CHANNEL(s, chptr, b) (!SecretChannel(chptr) || ((b &
WHOSELECT_EXTRA) && HasPriv((s), PRIV_SEE_CHAN)))
-
-/** Maximum number of lines to send in response to a /WHOIS. */
-#define MAX_WHOIS_LINES 50
-
-/*
- * Prototypes
- */
-extern void do_who(struct Client* sptr, struct Client* acptr, struct Channel*
repchan,
- int fields, char* qrt);
-extern int count_users(char* mask);
-
-#endif /* INCLUDED_whocmds_h */
Index: ircu2.10/ircd/Makefile.in
diff -u ircu2.10/ircd/Makefile.in:1.69 ircu2.10/ircd/Makefile.in:1.70
--- ircu2.10/ircd/Makefile.in:1.69 Tue Sep 20 16:17:54 2005
+++ ircu2.10/ircd/Makefile.in Fri Sep 30 20:37:43 2005
@@ -211,7 +211,6 @@
send.c \
uping.c \
userload.c \
- whocmds.c \
whowas.c \
y.tab.c
@@ -426,7 +425,7 @@
../include/ircd_chattr.h ../include/match.h ../include/numeric.h \
../include/s_bsd.h ../include/s_debug.h ../include/s_misc.h \
../include/s_stats.h ../include/send.h ../include/struct.h \
- ../include/msg.h ../include/numnicks.h ../include/whocmds.h
+ ../include/msg.h ../include/numnicks.h
hash.o: hash.c ../config.h ../include/hash.h ../include/client.h \
../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \
../include/ircd_events.h ../config.h ../include/ircd_handler.h \
@@ -1177,8 +1176,8 @@
../include/capab.h ../include/hash.h ../include/ircd.h \
../include/struct.h ../include/ircd_chattr.h ../include/ircd_features.h \
../include/ircd_log.h ../include/ircd_reply.h ../include/ircd_string.h \
- ../include/match.h ../include/numeric.h ../include/numnicks.h \
- ../include/send.h ../include/whocmds.h
+ ../include/ircd_snprintf.h ../include/match.h ../include/numeric.h \
+ ../include/numnicks.h ../include/send.h
m_whois.o: m_whois.c ../config.h ../include/channel.h \
../include/ircd_defs.h ../include/res.h ../config.h ../include/client.h \
../include/dbuf.h ../include/msgq.h ../include/ircd_events.h \
@@ -1187,7 +1186,7 @@
../include/ircd_log.h ../include/ircd_reply.h ../include/ircd_string.h \
../include/ircd_chattr.h ../include/match.h ../include/msg.h \
../include/numeric.h ../include/numnicks.h ../include/s_user.h \
- ../include/send.h ../include/whocmds.h
+ ../include/send.h
m_whowas.o: m_whowas.c ../config.h ../include/client.h \
../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \
../include/ircd_events.h ../config.h ../include/ircd_handler.h \
@@ -1262,7 +1261,7 @@
../include/s_bsd.h ../include/s_conf.h ../include/client.h \
../include/s_debug.h ../include/s_misc.h ../include/s_numeric.h \
../include/s_user.h ../include/send.h ../include/struct.h \
- ../include/sys.h ../include/whocmds.h ../include/whowas.h
+ ../include/sys.h ../include/whowas.h
querycmds.o: querycmds.c ../config.h ../include/querycmds.h \
../include/ircd_features.h
random.o: random.c ../config.h ../include/random.h ../include/client.h \
@@ -1431,20 +1430,6 @@
../include/numnicks.h ../include/querycmds.h ../include/ircd_features.h \
../include/s_misc.h ../include/s_stats.h ../include/send.h \
../include/struct.h ../include/sys.h
-whocmds.o: whocmds.c ../config.h ../include/whocmds.h \
- ../include/channel.h ../include/ircd_defs.h ../include/res.h \
- ../config.h ../include/client.h ../include/dbuf.h ../include/msgq.h \
- ../include/ircd_events.h ../include/ircd_handler.h ../include/capab.h \
- ../include/hash.h ../include/ircd.h ../include/struct.h \
- ../include/ircd_chattr.h ../include/ircd_features.h \
- ../include/ircd_reply.h ../include/ircd_snprintf.h \
- ../include/ircd_string.h ../include/list.h ../include/match.h \
- ../include/numeric.h ../include/numnicks.h ../include/querycmds.h \
- ../include/ircd_features.h ../include/random.h ../include/s_bsd.h \
- ../include/s_conf.h ../include/client.h ../include/s_misc.h \
- ../include/s_user.h ../include/send.h ../include/struct.h \
- ../include/sys.h ../include/userload.h ../include/version.h \
- ../include/whowas.h ../include/msg.h
whowas.o: whowas.c ../config.h ../include/whowas.h ../include/client.h \
../include/ircd_defs.h ../include/dbuf.h ../include/msgq.h \
../include/ircd_events.h ../config.h ../include/ircd_handler.h \
Index: ircu2.10/ircd/gline.c
diff -u ircu2.10/ircd/gline.c:1.61 ircu2.10/ircd/gline.c:1.62
--- ircu2.10/ircd/gline.c:1.61 Thu Sep 22 13:42:21 2005
+++ ircu2.10/ircd/gline.c Fri Sep 30 20:37:43 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Implementation of Gline manipulation functions.
- * @version $Id: gline.c,v 1.61 2005/09/22 20:42:21 entrope Exp $
+ * @version $Id: gline.c,v 1.62 2005/10/01 03:37:43 entrope Exp $
*/
#include "config.h"
@@ -43,7 +43,6 @@
#include "msg.h"
#include "numnicks.h"
#include "numeric.h"
-#include "whocmds.h"
/* #include <assert.h> -- Now using assert in ircd_log.h */
#include <string.h>
@@ -68,6 +67,34 @@
/** List of BadChan G-lines. */
struct Gline* BadChanGlineList = 0;
+/** Count number of users who match \a mask.
+ * @param[in] mask [EMAIL PROTECTED] or [EMAIL PROTECTED] mask to check.
+ * @return Count of matching users.
+ */
+static int
+count_users(char *mask)
+{
+ struct Client *acptr;
+ int count = 0;
+ char namebuf[USERLEN + HOSTLEN + 2];
+ char ipbuf[USERLEN + 16 + 2];
+
+ for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) {
+ if (!IsUser(acptr))
+ continue;
+
+ ircd_snprintf(0, namebuf, sizeof(namebuf), "[EMAIL PROTECTED]",
+ cli_user(acptr)->username, cli_user(acptr)->host);
+ ircd_snprintf(0, ipbuf, sizeof(ipbuf), "[EMAIL PROTECTED]",
cli_user(acptr)->username,
+ ircd_ntoa(&cli_ip(acptr)));
+
+ if (!match(mask, namebuf) || !match(mask, ipbuf))
+ count++;
+ }
+
+ return count;
+}
+
/** Find canonical user and host for a string.
* If \a userhost starts with '$', assign \a userhost to *user_p and NULL to
*host_p.
* Otherwise, if \a userhost contains '@', assign the earlier part of it to
*user_p and the rest to *host_p.
Index: ircu2.10/ircd/m_who.c
diff -u ircu2.10/ircd/m_who.c:1.22 ircu2.10/ircd/m_who.c:1.23
--- ircu2.10/ircd/m_who.c:1.22 Fri Sep 23 19:57:20 2005
+++ ircu2.10/ircd/m_who.c Fri Sep 30 20:37:43 2005
@@ -20,65 +20,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_who.c,v 1.22 2005/09/24 02:57:20 entrope Exp $
+ * $Id: m_who.c,v 1.23 2005/10/01 03:37:43 entrope Exp $
*/
-/*
- * m_functions execute protocol messages on this server:
- *
- * cptr is always NON-NULL, pointing to a *LOCAL* client
- * structure (with an open socket connected!). This
- * identifies the physical socket where the message
- * originated (or which caused the m_function to be
- * executed--some m_functions may call others...).
- *
- * sptr is the source of the message, defined by the
- * prefix part of the message if present. If not
- * or prefix not found, then sptr==cptr.
- *
- * (!IsServer(cptr)) => (cptr == sptr), because
- * prefixes are taken *only* from servers...
- *
- * (IsServer(cptr))
- * (sptr == cptr) => the message didn't
- * have the prefix.
- *
- * (sptr != cptr && IsServer(sptr) means
- * the prefix specified servername. (?)
- *
- * (sptr != cptr && !IsServer(sptr) means
- * that message originated from a remote
- * user (not local).
- *
- * combining
- *
- * (!IsServer(sptr)) means that, sptr can safely
- * taken as defining the target structure of the
- * message in this server.
- *
- * *Always* true (if 'parse' and others are working correct):
- *
- * 1) sptr->from == cptr (note: cptr->from == cptr)
- *
- * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
- * *cannot* be a local connection, unless it's
- * actually cptr!). [MyConnect(x) should probably
- * be defined as (x == x->from) --msa ]
- *
- * parc number of variable parameter strings (if zero,
- * parv is allowed to be NULL)
- *
- * parv a NULL terminated list of parameter pointers,
- *
- * parv[0], sender (prefix string), if not present
- * this points to an empty string.
- * parv[1]...parv[parc-1]
- * pointers to additional parameters
- * parv[parc] == NULL, *always*
- *
- * note: it is guaranteed that parv[0]..parv[parc-1] are all
- * non-NULL pointers.
- */
#include "config.h"
#include "channel.h"
@@ -90,21 +34,19 @@
#include "ircd_log.h"
#include "ircd_reply.h"
#include "ircd_string.h"
+#include "ircd_snprintf.h"
#include "match.h"
#include "numeric.h"
#include "numnicks.h"
#include "send.h"
-#include "whocmds.h"
/* #include <assert.h> -- Now using assert in ircd_log.h */
#include <string.h>
-/*
- * A little spin-marking utility to tell us which clients we have already
- * processed and which not
- */
+/** Variable storing current cli_marker() value to mark visited clients. */
static int who_marker = 0;
+/** Increment #who_marker, handling overflow if necessary. */
static void move_marker(void)
{
if (!++who_marker)
@@ -122,18 +64,279 @@
#define CheckMark(x, y) ((x == y) ? 0 : (x = y))
#define Process(cptr) CheckMark(cli_marker(cptr), who_marker)
-/*
- * m_who - generic message handler
+#define WHOSELECT_OPER 1 /**< Flag for /WHO: Show IRC operators. */
+#define WHOSELECT_EXTRA 2 /**< Flag for /WHO: Pull rank to see users. */
+#define WHOSELECT_DELAY 4 /**< Flag for /WHO: Show join-delayed users. */
+
+#define WHO_FIELD_QTY 1 /**< Display query type. */
+#define WHO_FIELD_CHA 2 /**< Show common channel name. */
+#define WHO_FIELD_UID 4 /**< Show username. */
+#define WHO_FIELD_NIP 8 /**< Show IP address. */
+#define WHO_FIELD_HOS 16 /**< Show hostname. */
+#define WHO_FIELD_SER 32 /**< Show server. */
+#define WHO_FIELD_NIC 64 /**< Show nickname. */
+#define WHO_FIELD_FLA 128 /**< Show flags (away, oper, chanop, etc). */
+#define WHO_FIELD_DIS 256 /**< Show hop count (distance). */
+#define WHO_FIELD_REN 512 /**< Show realname (info). */
+#define WHO_FIELD_IDL 1024 /**< Show idle time. */
+#define WHO_FIELD_ACC 2048 /**< Show account name. */
+
+/** Default fields for /WHO */
+#define WHO_FIELD_DEF ( WHO_FIELD_NIC | WHO_FIELD_UID | WHO_FIELD_HOS |
WHO_FIELD_SER )
+
+/** Is \a ac plainly visible to \a s?
+ * @param[in] s Client trying to see \a ac.
+ * @param[in] ac Client being looked at.
+ */
+#define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
+
+/** Can \a s see \a ac by using the flags in \a b?
+ * @param[in] s Client trying to see \a ac.
+ * @param[in] ac Client being looked at.
+ * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
+ */
+#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || \
+ ((b & WHOSELECT_EXTRA) && MyConnect(ac) && \
+ (HasPriv((s), PRIV_SHOW_INVIS) || \
+ HasPriv((s), PRIV_SHOW_ALL_INVIS))))
+
+/** Can \a s see \a ac by using the flags in \a b?
+ * @param[in] s Client trying to see \a ac.
+ * @param[in] ac Client being looked at.
+ * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
+ */
+#define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || \
+ ((b & WHOSELECT_EXTRA) && \
+ HasPriv((s), PRIV_SHOW_ALL_INVIS)))
+
+/** Should we show more clients to \a sptr?
+ * @param[in] sptr Client listing other users.
+ * @param[in,out] counter Default count for clients.
+ */
+#define SHOW_MORE(sptr, counter) (HasPriv(sptr, PRIV_UNLIMIT_QUERY) ||
(!(counter-- < 0)) )
+
+/** Can \a s see \a chptr?
+ * @param[in] s Client trying to see \a chptr.
+ * @param[in] chptr Channel being looked at.
+ * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
+ */
+#define SEE_CHANNEL(s, chptr, b) (!SecretChannel(chptr) || ((b &
WHOSELECT_EXTRA) && HasPriv((s), PRIV_SEE_CHAN)))
+
+/** Send a WHO reply to a client who asked.
+ * @param[in] sptr Client who is searching for other users.
+ * @param[in] acptr Client who may be shown to \a sptr.
+ * @param[in] repchan Shared channel that provides visibility.
+ * @param[in] fields Bitmask of WHO_FIELD_* values, indicating what to show.
+ * @param[in] qrt Query type string (ignored unless \a fields & WHO_FIELD_QTY).
+ */
+static void do_who(struct Client* sptr, struct Client* acptr,
+ struct Channel* repchan, int fields, char* qrt)
+{
+ char *p1;
+ struct Membership *chan = 0;
+
+ static char buf1[512];
+ /* NOTE: with current fields list and sizes this _cannot_ overrun,
+ and also the message finally sent shouldn't ever be truncated */
+
+ p1 = buf1;
+ buf1[1] = '\0';
+
+ /* If we don't have a channel and we need one... try to find it,
+ unless the listing is for a channel service, we already know
+ that there are no common channels, thus use PubChannel and not
+ SeeChannel */
+ if (repchan)
+ chan = find_channel_member(acptr, repchan);
+ else if ((!fields || (fields & (WHO_FIELD_CHA | WHO_FIELD_FLA)))
+ && !IsChannelService(acptr))
+ {
+ for (chan = cli_user(acptr)->channel; chan; chan = chan->next_channel)
+ if (PubChannel(chan->channel) &&
+ (acptr == sptr || !IsZombie(chan)))
+ break;
+ }
+
+ /* Place the fields one by one in the buffer and send it
+ note that fields == NULL means "default query" */
+
+ if (fields & WHO_FIELD_QTY) /* Query type */
+ {
+ *(p1++) = ' ';
+ if (BadPtr(qrt))
+ *(p1++) = '0';
+ else
+ while ((*qrt) && (*(p1++) = *(qrt++)));
+ }
+
+ if (!fields || (fields & WHO_FIELD_CHA))
+ {
+ char *p2;
+ *(p1++) = ' ';
+ if ((p2 = (chan ? chan->channel->chname : NULL)))
+ while ((*p2) && (*(p1++) = *(p2++)));
+ else
+ *(p1++) = '*';
+ }
+
+ if (!fields || (fields & WHO_FIELD_UID))
+ {
+ char *p2 = cli_user(acptr)->username;
+ *(p1++) = ' ';
+ while ((*p2) && (*(p1++) = *(p2++)));
+ }
+
+ if (fields & WHO_FIELD_NIP)
+ {
+ const char* p2 = HasHiddenHost(acptr) && !IsAnOper(sptr) ?
+ feature_str(FEAT_HIDDEN_IP) :
+ ircd_ntoa(&cli_ip(acptr));
+ *(p1++) = ' ';
+ while ((*p2) && (*(p1++) = *(p2++)));
+ }
+
+ if (!fields || (fields & WHO_FIELD_HOS))
+ {
+ char *p2 = cli_user(acptr)->host;
+ *(p1++) = ' ';
+ while ((*p2) && (*(p1++) = *(p2++)));
+ }
+
+ if (!fields || (fields & WHO_FIELD_SER))
+ {
+ const char *p2 = (feature_bool(FEAT_HIS_WHO_SERVERNAME) &&
!IsAnOper(sptr)) ?
+ feature_str(FEAT_HIS_SERVERNAME) :
+ cli_name(cli_user(acptr)->server);
+ *(p1++) = ' ';
+ while ((*p2) && (*(p1++) = *(p2++)));
+ }
+
+ if (!fields || (fields & WHO_FIELD_NIC))
+ {
+ char *p2 = cli_name(acptr);
+ *(p1++) = ' ';
+ while ((*p2) && (*(p1++) = *(p2++)));
+ }
+
+ if (!fields || (fields & WHO_FIELD_FLA))
+ {
+ *(p1++) = ' ';
+ if (cli_user(acptr)->away)
+ *(p1++) = 'G';
+ else
+ *(p1++) = 'H';
+ if SeeOper(sptr,acptr)
+ *(p1++) = '*';
+ if (!chan) {
+ /* No flags possible for the channel, so skip them all. */
+ }
+ else if (fields) {
+ /* If you specified flags then we assume you know how to parse
+ * multiple channel status flags, as this is currently the only
+ * way to know if someone has @'s *and* is +'d.
+ */
+ if (IsChanOp(chan))
+ *(p1++) = '@';
+ if (HasVoice(chan))
+ *(p1++) = '+';
+ if (IsZombie(chan))
+ *(p1++) = '!';
+ if (IsDelayedJoin(chan))
+ *(p1++) = '<';
+ }
+ else {
+ if (IsChanOp(chan))
+ *(p1++) = '@';
+ else if (HasVoice(chan))
+ *(p1++) = '+';
+ else if (IsZombie(chan))
+ *(p1++) = '!';
+ else if (IsDelayedJoin(chan))
+ *(p1++) = '<';
+ }
+ if (IsDeaf(acptr))
+ *(p1++) = 'd';
+ if (IsAnOper(sptr))
+ {
+ if (IsInvisible(acptr))
+ *(p1++) = 'i';
+ if (SendWallops(acptr))
+ *(p1++) = 'w';
+ if (SendDebug(acptr))
+ *(p1++) = 'g';
+ }
+ if (HasHiddenHost(acptr))
+ *(p1++) = 'x';
+ }
+
+ if (!fields || (fields & WHO_FIELD_DIS))
+ {
+ *p1++ = ' ';
+ if (!fields)
+ *p1++ = ':'; /* Place colon here for default reply */
+ if (feature_bool(FEAT_HIS_WHO_HOPCOUNT) && !IsAnOper(sptr))
+ *p1++ = (sptr == acptr) ? '0' : '3';
+ else
+ /* three digit hopcount maximum */
+ p1 += ircd_snprintf(0, p1, 3, "%d", cli_hopcount(acptr));
+ }
+
+ if (fields & WHO_FIELD_IDL)
+ {
+ *p1++ = ' ';
+ if (MyUser(acptr) &&
+ (IsAnOper(sptr) || !feature_bool(FEAT_HIS_WHO_SERVERNAME) ||
+ acptr == sptr))
+ p1 += ircd_snprintf(0, p1, 11, "%d",
+ CurrentTime - cli_user(acptr)->last);
+ else
+ *p1++ = '0';
+ }
+
+ if (fields & WHO_FIELD_ACC)
+ {
+ char *p2 = cli_user(acptr)->account;
+ *(p1++) = ' ';
+ if (*p2)
+ while ((*p2) && (*(p1++) = *(p2++)));
+ else
+ *(p1++) = '0';
+ }
+
+ if (!fields || (fields & WHO_FIELD_REN))
+ {
+ char *p2 = cli_info(acptr);
+ *p1++ = ' ';
+ if (fields)
+ *p1++ = ':'; /* Place colon here for special reply */
+ while ((*p2) && (*(p1++) = *(p2++)));
+ }
+
+ /* The first char will always be an useless blank and we
+ need to terminate buf1 */
+ *p1 = '\0';
+ p1 = buf1;
+ send_reply(sptr, fields ? RPL_WHOSPCRPL : RPL_WHOREPLY, ++p1);
+}
+
+/** Handle a WHO message.
*
- * parv[0] = sender prefix
- * parv[1] = nickname mask list
- * parv[2] = additional selection flag, only 'o' for now.
- * and %flags to specify what fields to output
- * plus a ,querytype if the t flag is specified
- * so the final thing will be like o%tnchu,777
- * parv[3] = _optional_ parameter that overrides parv[1]
- * This can be used as "/quote who foo % :The Black Hacker
- * to find me, parv[3] _can_ contain spaces !.
+ * \a parv has the following elements:
+ * \li \a parv[1] is a nickname mask list
+ * \li \a parv[2] is an additional selection flag string. 'i' selects
+ * opers, 'd' shows join-delayed users as well, 'x' shows extended
+ * information to opers with the WHOX privilege; %flags specifies
+ * what fields to output; a ,querytype if the t flag is specified
+ * so the final thing will be like o%tnchu,777.
+ * \li \a parv[3] parv[3] is an _optional_ parameter that overrides
+ * parv[1] This can be used as "/quote who foo % :The Black Hacker to
+ * find me, parv[3] _can_ contain spaces!
+ *
+ * See @ref m_functions for discussion of the arguments.
+ * @param[in] cptr Client that sent us the message.
+ * @param[in] sptr Original source of message.
+ * @param[in] parc Number of arguments.
+ * @param[in] parv Argument vector.
*/
int m_who(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
Index: ircu2.10/ircd/m_whois.c
diff -u ircu2.10/ircd/m_whois.c:1.37 ircu2.10/ircd/m_whois.c:1.38
--- ircu2.10/ircd/m_whois.c:1.37 Fri Jul 15 14:12:02 2005
+++ ircu2.10/ircd/m_whois.c Fri Sep 30 20:37:43 2005
@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: m_whois.c,v 1.37 2005/07/15 21:12:02 entrope Exp $
+ * $Id: m_whois.c,v 1.38 2005/10/01 03:37:43 entrope Exp $
*/
/*
@@ -95,11 +95,13 @@
#include "numnicks.h"
#include "s_user.h"
#include "send.h"
-#include "whocmds.h"
/* #include <assert.h> -- Now using assert in ircd_log.h */
#include <string.h>
+/** Maximum number of lines to send in response to a /WHOIS. */
+#define MAX_WHOIS_LINES 50
+
/*
* 2000-07-01: Isomer
* * Rewritten to make this understandable
Index: ircu2.10/ircd/parse.c
diff -u ircu2.10/ircd/parse.c:1.54 ircu2.10/ircd/parse.c:1.55
--- ircu2.10/ircd/parse.c:1.54 Mon Sep 26 20:54:46 2005
+++ ircu2.10/ircd/parse.c Fri Sep 30 20:37:43 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Parse input from IRC clients and other servers.
- * @version $Id: parse.c,v 1.54 2005/09/27 03:54:46 entrope Exp $
+ * @version $Id: parse.c,v 1.55 2005/10/01 03:37:43 entrope Exp $
*/
#include "config.h"
@@ -50,7 +50,6 @@
#include "send.h"
#include "struct.h"
#include "sys.h"
-#include "whocmds.h"
#include "whowas.h"
/* #include <assert.h> -- Now using assert in ircd_log.h */
Index: ircu2.10/ircd/whocmds.c
diff -u ircu2.10/ircd/whocmds.c:1.25 ircu2.10/ircd/whocmds.c:removed
--- ircu2.10/ircd/whocmds.c:1.25 Mon Sep 26 20:59:55 2005
+++ ircu2.10/ircd/whocmds.c Fri Sep 30 20:37:54 2005
@@ -1,287 +0,0 @@
-/*
- * IRC - Internet Relay Chat, ircd/s_user.c (formerly ircd/s_msg.c)
- * Copyright (C) 1990 Jarkko Oikarinen and
- * University of Oulu, Computing Center
- *
- * See file AUTHORS in IRC package for additional names of
- * the programmers.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 1, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/** @file
- * @brief Support functions for /WHO-like commands.
- * @version $Id: whocmds.c,v 1.25 2005/09/27 03:59:55 entrope Exp $
- */
-#include "config.h"
-
-#include "whocmds.h"
-#include "channel.h"
-#include "client.h"
-#include "hash.h"
-#include "ircd.h"
-#include "ircd_chattr.h"
-#include "ircd_features.h"
-#include "ircd_reply.h"
-#include "ircd_snprintf.h"
-#include "ircd_string.h"
-#include "list.h"
-#include "match.h"
-#include "numeric.h"
-#include "numnicks.h"
-#include "querycmds.h"
-#include "random.h"
-#include "s_bsd.h"
-#include "s_conf.h"
-#include "s_misc.h"
-#include "s_user.h"
-#include "send.h"
-#include "struct.h"
-#include "sys.h"
-#include "userload.h"
-#include "version.h"
-#include "whowas.h"
-#include "msg.h"
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-/** Send a WHO reply to a client who asked.
- * @param[in] sptr Client who is searching for other users.
- * @param[in] acptr Client who may be shown to \a sptr.
- * @param[in] repchan Shared channel that provides visibility.
- * @param[in] fields Bitmask of WHO_FIELD_* values, indicating what to show.
- * @param[in] qrt Query type string (ignored unless \a fields & WHO_FIELD_QTY).
- */
-void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
- int fields, char* qrt)
-{
- char *p1;
- struct Membership *chan = 0;
-
- static char buf1[512];
- /* NOTE: with current fields list and sizes this _cannot_ overrun,
- and also the message finally sent shouldn't ever be truncated */
-
- p1 = buf1;
- buf1[1] = '\0';
-
- /* If we don't have a channel and we need one... try to find it,
- unless the listing is for a channel service, we already know
- that there are no common channels, thus use PubChannel and not
- SeeChannel */
- if (repchan)
- chan = find_channel_member(acptr, repchan);
- else if ((!fields || (fields & (WHO_FIELD_CHA | WHO_FIELD_FLA)))
- && !IsChannelService(acptr))
- {
- for (chan = cli_user(acptr)->channel; chan; chan = chan->next_channel)
- if (PubChannel(chan->channel) &&
- (acptr == sptr || !IsZombie(chan)))
- break;
- }
-
- /* Place the fields one by one in the buffer and send it
- note that fields == NULL means "default query" */
-
- if (fields & WHO_FIELD_QTY) /* Query type */
- {
- *(p1++) = ' ';
- if (BadPtr(qrt))
- *(p1++) = '0';
- else
- while ((*qrt) && (*(p1++) = *(qrt++)));
- }
-
- if (!fields || (fields & WHO_FIELD_CHA))
- {
- char *p2;
- *(p1++) = ' ';
- if ((p2 = (chan ? chan->channel->chname : NULL)))
- while ((*p2) && (*(p1++) = *(p2++)));
- else
- *(p1++) = '*';
- }
-
- if (!fields || (fields & WHO_FIELD_UID))
- {
- char *p2 = cli_user(acptr)->username;
- *(p1++) = ' ';
- while ((*p2) && (*(p1++) = *(p2++)));
- }
-
- if (fields & WHO_FIELD_NIP)
- {
- const char* p2 = HasHiddenHost(acptr) && !IsAnOper(sptr) ?
- feature_str(FEAT_HIDDEN_IP) :
- ircd_ntoa(&cli_ip(acptr));
- *(p1++) = ' ';
- while ((*p2) && (*(p1++) = *(p2++)));
- }
-
- if (!fields || (fields & WHO_FIELD_HOS))
- {
- char *p2 = cli_user(acptr)->host;
- *(p1++) = ' ';
- while ((*p2) && (*(p1++) = *(p2++)));
- }
-
- if (!fields || (fields & WHO_FIELD_SER))
- {
- const char *p2 = (feature_bool(FEAT_HIS_WHO_SERVERNAME) &&
!IsAnOper(sptr)) ?
- feature_str(FEAT_HIS_SERVERNAME) :
- cli_name(cli_user(acptr)->server);
- *(p1++) = ' ';
- while ((*p2) && (*(p1++) = *(p2++)));
- }
-
- if (!fields || (fields & WHO_FIELD_NIC))
- {
- char *p2 = cli_name(acptr);
- *(p1++) = ' ';
- while ((*p2) && (*(p1++) = *(p2++)));
- }
-
- if (!fields || (fields & WHO_FIELD_FLA))
- {
- *(p1++) = ' ';
- if (cli_user(acptr)->away)
- *(p1++) = 'G';
- else
- *(p1++) = 'H';
- if SeeOper(sptr,acptr)
- *(p1++) = '*';
- if (!chan) {
- /* No flags possible for the channel, so skip them all. */
- }
- else if (fields) {
- /* If you specified flags then we assume you know how to parse
- * multiple channel status flags, as this is currently the only
- * way to know if someone has @'s *and* is +'d.
- */
- if (IsChanOp(chan))
- *(p1++) = '@';
- if (HasVoice(chan))
- *(p1++) = '+';
- if (IsZombie(chan))
- *(p1++) = '!';
- if (IsDelayedJoin(chan))
- *(p1++) = '<';
- }
- else {
- if (IsChanOp(chan))
- *(p1++) = '@';
- else if (HasVoice(chan))
- *(p1++) = '+';
- else if (IsZombie(chan))
- *(p1++) = '!';
- else if (IsDelayedJoin(chan))
- *(p1++) = '<';
- }
- if (IsDeaf(acptr))
- *(p1++) = 'd';
- if (IsAnOper(sptr))
- {
- if (IsInvisible(acptr))
- *(p1++) = 'i';
- if (SendWallops(acptr))
- *(p1++) = 'w';
- if (SendDebug(acptr))
- *(p1++) = 'g';
- }
- if (HasHiddenHost(acptr))
- *(p1++) = 'x';
- }
-
- if (!fields || (fields & WHO_FIELD_DIS))
- {
- *p1++ = ' ';
- if (!fields)
- *p1++ = ':'; /* Place colon here for default reply */
- if (feature_bool(FEAT_HIS_WHO_HOPCOUNT) && !IsAnOper(sptr))
- *p1++ = (sptr == acptr) ? '0' : '3';
- else
- /* three digit hopcount maximum */
- p1 += ircd_snprintf(0, p1, 3, "%d", cli_hopcount(acptr));
- }
-
- if (fields & WHO_FIELD_IDL)
- {
- *p1++ = ' ';
- if (MyUser(acptr) &&
- (IsAnOper(sptr) || !feature_bool(FEAT_HIS_WHO_SERVERNAME) ||
- acptr == sptr))
- p1 += ircd_snprintf(0, p1, 11, "%d",
- CurrentTime - cli_user(acptr)->last);
- else
- *p1++ = '0';
- }
-
- if (fields & WHO_FIELD_ACC)
- {
- char *p2 = cli_user(acptr)->account;
- *(p1++) = ' ';
- if (*p2)
- while ((*p2) && (*(p1++) = *(p2++)));
- else
- *(p1++) = '0';
- }
-
- if (!fields || (fields & WHO_FIELD_REN))
- {
- char *p2 = cli_info(acptr);
- *p1++ = ' ';
- if (fields)
- *p1++ = ':'; /* Place colon here for special reply */
- while ((*p2) && (*(p1++) = *(p2++)));
- }
-
- /* The first char will always be an useless blank and we
- need to terminate buf1 */
- *p1 = '\0';
- p1 = buf1;
- send_reply(sptr, fields ? RPL_WHOSPCRPL : RPL_WHOREPLY, ++p1);
-}
-
-/** Count number of users who match \a mask.
- * @param[in] mask [EMAIL PROTECTED] or [EMAIL PROTECTED] mask to check.
- * @return Count of matching users.
- */
-int
-count_users(char *mask)
-{
- struct Client *acptr;
- int count = 0;
- char namebuf[USERLEN + HOSTLEN + 2];
- char ipbuf[USERLEN + 16 + 2];
-
- for (acptr = GlobalClientList; acptr; acptr = cli_next(acptr)) {
- if (!IsUser(acptr))
- continue;
-
- ircd_snprintf(0, namebuf, sizeof(namebuf), "[EMAIL PROTECTED]",
- cli_user(acptr)->username, cli_user(acptr)->host);
- ircd_snprintf(0, ipbuf, sizeof(ipbuf), "[EMAIL PROTECTED]",
cli_user(acptr)->username,
- ircd_ntoa(&cli_ip(acptr)));
-
- if (!match(mask, namebuf) || !match(mask, ipbuf))
- count++;
- }
-
- return count;
-}
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches