Make references to channel password lengths consistent.
[ircu2.10.12-pk.git] / include / whocmds.h
1 /** @file whocmds.h
2  * @brief Support functions for /WHO-like commands.
3  * @version $Id$
4  */
5 #ifndef INCLUDED_whocmds_h
6 #define INCLUDED_whocmds_h
7
8 struct Client;
9 struct 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
27 #define WHO_FIELD_QTY 1    /**< Display query type. */
28 #define WHO_FIELD_CHA 2    /**< Show common channel name. */
29 #define WHO_FIELD_UID 4    /**< Show username. */
30 #define WHO_FIELD_NIP 8    /**< Show IP address. */
31 #define WHO_FIELD_HOS 16   /**< Show hostname. */
32 #define WHO_FIELD_SER 32   /**< Show server. */
33 #define WHO_FIELD_NIC 64   /**< Show nickname. */
34 #define WHO_FIELD_FLA 128  /**< Show flags (away, oper, chanop, etc). */
35 #define WHO_FIELD_DIS 256  /**< Show hop count (distance). */
36 #define WHO_FIELD_REN 512  /**< Show realname (info). */
37 #define WHO_FIELD_IDL 1024 /**< Show idle time. */
38 #define WHO_FIELD_ACC 2048 /**< Show account name. */
39
40 /** Default fields for /WHO */
41 #define WHO_FIELD_DEF ( WHO_FIELD_NIC | WHO_FIELD_UID | WHO_FIELD_HOS | WHO_FIELD_SER )
42
43 /** Is \a ac plainly visible to \a s?
44  * @param[in] s Client trying to see \a ac.
45  * @param[in] ac Client being looked at.
46  */
47 #define IS_VISIBLE_USER(s,ac) ((s==ac) || (!IsInvisible(ac)))
48
49 /** Can \a s see \a ac by using the flags in \a b?
50  * @param[in] s Client trying to see \a ac.
51  * @param[in] ac Client being looked at.
52  * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
53  */
54 #define SEE_LUSER(s, ac, b) (IS_VISIBLE_USER(s, ac) || \
55                              ((b & WHOSELECT_EXTRA) && MyConnect(ac) && \
56                              (HasPriv((s), PRIV_SHOW_INVIS) || \
57                               HasPriv((s), PRIV_SHOW_ALL_INVIS))))
58
59 /** Can \a s see \a ac by using the flags in \a b?
60  * @param[in] s Client trying to see \a ac.
61  * @param[in] ac Client being looked at.
62  * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
63  */
64 #define SEE_USER(s, ac, b) (SEE_LUSER(s, ac, b) || \
65                             ((b & WHOSELECT_EXTRA) && \
66                               HasPriv((s), PRIV_SHOW_ALL_INVIS)))
67
68 /** Should we show more clients to \a sptr?
69  * @param[in] sptr Client listing other users.
70  * @param[in,out] counter Default count for clients.
71  */
72 #define SHOW_MORE(sptr, counter) (HasPriv(sptr, PRIV_UNLIMIT_QUERY) || (!(counter-- < 0)) )
73
74 /** Can \a s see \a chptr?
75  * @param[in] s Client trying to see \a chptr.
76  * @param[in] chptr Channel being looked at.
77  * @param[in] b Bitset of extra flags (options: WHOSELECT_EXTRA).
78  */
79 #define SEE_CHANNEL(s, chptr, b) (!SecretChannel(chptr) || ((b & WHOSELECT_EXTRA) && HasPriv((s), PRIV_SEE_CHAN)))
80
81 /** Maximum number of lines to send in response to a /WHOIS. */
82 #define MAX_WHOIS_LINES 50
83
84 /*
85  * Prototypes
86  */
87 extern void do_who(struct Client* sptr, struct Client* acptr, struct Channel* repchan,
88                    int fields, char* qrt);
89 extern int count_users(char* mask);
90
91 #endif /* INCLUDED_whocmds_h */