]> jfr.im git - irc/quakenet/snircd.git/blame - include/whocmds.h
forward port of asuka-check.patch to .12
[irc/quakenet/snircd.git] / include / whocmds.h
CommitLineData
189935b1 1/** @file whocmds.h
2 * @brief Support functions for /WHO-like commands.
3 * @version $Id: whocmds.h,v 1.10 2005/09/24 02:57:20 entrope Exp $
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. */
40
41/** Default fields for /WHO */
42#define WHO_FIELD_DEF ( WHO_FIELD_NIC | WHO_FIELD_UID | WHO_FIELD_HOS | WHO_FIELD_SER )
43
44/** Is \a ac plainly visible to \a s?
45 * @param[in] s Client trying to see \a ac.
46 * @param[in] ac Client being looked at.
47 */
48#define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
49
50/** Can \a s see \a ac by using the flags in \a b?
51 * @param[in] s Client trying to see \a ac.
52 * @param[in] ac Client being looked at.
53 * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
54 */
55#define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || \
56 ((b & WHOSELECT_EXTRA) && MyConnect(ac) && \
57 (HasPriv((s), PRIV_SHOW_INVIS) || \
58 HasPriv((s), PRIV_SHOW_ALL_INVIS))))
59
60/** Can \a s see \a ac by using the flags in \a b?
61 * @param[in] s Client trying to see \a ac.
62 * @param[in] ac Client being looked at.
63 * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
64 */
65#define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || \
66 ((b & WHOSELECT_EXTRA) && \
67 HasPriv((s), PRIV_SHOW_ALL_INVIS)))
68
69/** Should we show more clients to \a sptr?
70 * @param[in] sptr Client listing other users.
71 * @param[in,out] counter Default count for clients.
72 */
73#define SHOW_MORE(sptr, counter) (HasPriv(sptr, PRIV_UNLIMIT_QUERY) || (!(counter-- < 0)) )
74
75/** Can \a s see \a chptr?
76 * @param[in] s Client trying to see \a chptr.
77 * @param[in] chptr Channel being looked at.
78 * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
79 */
80#define SEE_CHANNEL(s, chptr, b) (!SecretChannel(chptr) || ((b & WHOSELECT_EXTRA) && HasPriv((s), PRIV_SEE_CHAN)))
81
82/** Maximum number of lines to send in response to a /WHOIS. */
83#define MAX_WHOIS_LINES 50
84
85/*
86 * Prototypes
87 */
88extern void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
89 int fields, char* qrt);
90extern int count_users(char* mask);
91
92#endif /* INCLUDED_whocmds_h */