ircu2.10.12 pk910 fork
[ircu2.10.12-pk.git] / include / s_user.h
1 /** @file s_user.h
2  * @brief Miscellaneous user-related helper functions.
3  * @version $Id: s_user.h 1818 2007-07-14 02:40:01Z isomer $
4  */
5 #ifndef INCLUDED_s_user_h
6 #define INCLUDED_s_user_h
7 #ifndef INCLUDED_sys_types_h
8 #include <sys/types.h>
9 #define INCLUDED_sys_types_h
10 #endif
11
12 struct Client;
13 struct User;
14 struct Channel;
15 struct MsgBuf;
16 struct Flags;
17
18 /*
19  * Macros
20  */
21
22 /**
23  * Nick flood limit.
24  * Minimum time between nick changes.
25  * (The first two changes are allowed quickly after another however).
26  */
27 #define NICK_DELAY 30
28
29 /**
30  * Target flood time.
31  * Minimum time between target changes.
32  * (MAXTARGETS are allowed simultaneously however).
33  * Its set to a power of 2 because we devide through it quite a lot.
34  */
35 #define TARGET_DELAY 128
36
37 /* return values for hunt_server() */
38
39 #define HUNTED_NOSUCH   (-1)    /**< if the hunted server is not found */
40 #define HUNTED_ISME     0       /**< if this server should execute the command */
41 #define HUNTED_PASS     1       /**< if message passed onwards successfully */
42
43 /* send sets for send_umode() */
44 #define ALL_UMODES 0  /**< both local and global user modes */
45 #define SEND_UMODES 1  /**< global user modes only */
46 #define SEND_UMODES_BUT_OPER 2  /**< global user modes except for FLAG_OPER */
47
48 /* used when sending to #mask or $mask */
49
50 #define MATCH_SERVER  1 /**< flag for relay_masked_message (etc) to indicate the mask matches a server name */
51 #define MATCH_HOST    2 /**< flag for relay_masked_message (etc) to indicate the mask matches host name */
52
53 /* used for parsing user modes */
54 #define ALLOWMODES_ANY  0 /**< Allow any user mode */
55 #define ALLOWMODES_DEFAULT  1 /**< Only allow the subset of modes that are legit defaults */
56 #define ALLOWMODES_WITHSECSERV  2
57
58 /** Formatter function for send_user_info().
59  * @param who Client being displayed.
60  * @param sptr Client requesting information.
61  * @param buf Message buffer that should receive the response text.
62  */
63 typedef void (*InfoFormatter)(struct Client* who, struct Client *sptr, struct MsgBuf* buf);
64
65 /*
66  * Prototypes
67  */
68 extern struct User* make_user(struct Client *cptr);
69 extern void         free_user(struct User *user);
70 extern int          register_user(struct Client* cptr, struct Client *sptr);
71
72 extern void         user_count_memory(size_t* count_out, size_t* bytes_out);
73
74 extern int set_nick_name(struct Client* cptr, struct Client* sptr,
75                          const char* nick, int parc, char* parv[], unsigned int force);
76 extern void send_umode_out(struct Client* cptr, struct Client* sptr,
77                           struct Flags* old, int prop);
78 extern int whisper(struct Client* source, const char* nick,
79                    const char* channel, const char* text, int is_notice);
80 extern void send_user_info(struct Client* to, char* names, int rpl,
81                            InfoFormatter fmt);
82
83 extern int hide_hostmask(struct Client *cptr, unsigned int flags);
84 extern int apply_fakehost(struct Client *cptr);
85 extern int set_user_mode(struct Client *cptr, struct Client *sptr,
86                          int parc, char *parv[], int allow_modes);
87 extern int is_silenced(struct Client *sptr, struct Client *acptr);
88 extern int hunt_server_cmd(struct Client *from, const char *cmd,
89                            const char *tok, struct Client *one,
90                            int MustBeOper, const char *pattern, int server,
91                            int parc, char *parv[]);
92 extern int hunt_server_prio_cmd(struct Client *from, const char *cmd,
93                                 const char *tok, struct Client *one,
94                                 int MustBeOper, const char *pattern,
95                                 int server, int parc, char *parv[]);
96 extern struct Client* next_client(struct Client* next, const char* ch);
97 extern char *umode_str(struct Client *cptr);
98 extern int send_umode(struct Client *cptr, struct Client *sptr,
99                       struct Flags *old, int sendset, int fakehost);
100 extern void set_snomask(struct Client *, unsigned int, int);
101 extern int is_snomask(char *);
102 extern int check_target_limit(struct Client *sptr, void *target, const char *name,
103     int created);
104 extern void add_target(struct Client *sptr, void *target);
105 extern unsigned int umode_make_snomask(unsigned int oldmask, char *arg,
106                                        int what);
107 extern int send_supported(struct Client *cptr);
108
109 #define NAMES_ALL 1 /**< List all users in channel */
110 #define NAMES_VIS 2 /**< List only visible users in non-secret channels */
111 #define NAMES_EON 4 /**< Add an 'End Of Names' reply to the end */
112 #define NAMES_DEL 8 /**< Show delayed joined users only */
113
114 void do_names(struct Client* sptr, struct Channel* chptr, int filter);
115
116 #endif /* INCLUDED_s_user_h */