]> jfr.im git - irc/quakenet/snircd.git/blame - include/whocmds.h
Update my e-mail address.
[irc/quakenet/snircd.git] / include / whocmds.h
CommitLineData
189935b1 1/** @file whocmds.h
2 * @brief Support functions for /WHO-like commands.
dd9731c9 3 * @version $Id: whocmds.h,v 1.10.2.1 2006/11/04 21:35:28 entrope Exp $
189935b1 4 */
5#ifndef INCLUDED_whocmds_h
6#define INCLUDED_whocmds_h
7
8struct Client;
9struct Channel;
10
11
12/*
13 * m_who()
14 * m_who with support routines rewritten by Nemesi, August 1997
15 * - Alghoritm have been flattened (no more recursive)
16 * - Several bug fixes
17 * - Strong performance improvement
18 * - Added possibility to have specific fields in the output
19 * See readme.who for further details.
20 */
21
22/* Macros used only in here by m_who and its support functions */
23
24#define WHOSELECT_OPER 1 /**< Flag for /WHO: Show IRC operators. */
25#define WHOSELECT_EXTRA 2 /**< Flag for /WHO: Pull rank to see users. */
26#define WHOSELECT_DELAY 4 /**< Flag for /WHO: Show join-delayed users. */
27
28#define WHO_FIELD_QTY 1 /**< Display query type. */
29#define WHO_FIELD_CHA 2 /**< Show common channel name. */
30#define WHO_FIELD_UID 4 /**< Show username. */
31#define WHO_FIELD_NIP 8 /**< Show IP address. */
32#define WHO_FIELD_HOS 16 /**< Show hostname. */
33#define WHO_FIELD_SER 32 /**< Show server. */
34#define WHO_FIELD_NIC 64 /**< Show nickname. */
35#define WHO_FIELD_FLA 128 /**< Show flags (away, oper, chanop, etc). */
36#define WHO_FIELD_DIS 256 /**< Show hop count (distance). */
37#define WHO_FIELD_REN 512 /**< Show realname (info). */
38#define WHO_FIELD_IDL 1024 /**< Show idle time. */
39#define WHO_FIELD_ACC 2048 /**< Show account name. */
dd9731c9 40#define WHO_FIELD_OPL 4096 /**< Show oplevel. */
189935b1 41
42/** Default fields for /WHO */
43#define WHO_FIELD_DEF ( WHO_FIELD_NIC | WHO_FIELD_UID | WHO_FIELD_HOS | WHO_FIELD_SER )
44
45/** Is \a ac plainly visible to \a s?
46 * @param[in] s Client trying to see \a ac.
47 * @param[in] ac Client being looked at.
48 */
49#define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
50
51/** Can \a s see \a ac by using the flags in \a b?
52 * @param[in] s Client trying to see \a ac.
53 * @param[in] ac Client being looked at.
54 * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
55 */
56#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || \
57 ((b & WHOSELECT_EXTRA) && MyConnect(ac) && \
58 (HasPriv((s), PRIV_SHOW_INVIS) || \
59 HasPriv((s), PRIV_SHOW_ALL_INVIS))))
60
61/** Can \a s see \a ac by using the flags in \a b?
62 * @param[in] s Client trying to see \a ac.
63 * @param[in] ac Client being looked at.
64 * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
65 */
66#define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || \
67 ((b & WHOSELECT_EXTRA) && \
68 HasPriv((s), PRIV_SHOW_ALL_INVIS)))
69
70/** Should we show more clients to \a sptr?
71 * @param[in] sptr Client listing other users.
72 * @param[in,out] counter Default count for clients.
73 */
74#define SHOW_MORE(sptr, counter) (HasPriv(sptr, PRIV_UNLIMIT_QUERY) || (!(counter-- < 0)) )
75
76/** Can \a s see \a chptr?
77 * @param[in] s Client trying to see \a chptr.
78 * @param[in] chptr Channel being looked at.
79 * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
80 */
81#define SEE_CHANNEL(s, chptr, b) (!SecretChannel(chptr) || ((b & WHOSELECT_EXTRA) && HasPriv((s), PRIV_SEE_CHAN)))
82
83/** Maximum number of lines to send in response to a /WHOIS. */
84#define MAX_WHOIS_LINES 50
85
86/*
87 * Prototypes
88 */
89extern void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
90 int fields, char* qrt);
91extern int count_users(char* mask);
92
93#endif /* INCLUDED_whocmds_h */