1 |
/* Common routines and constants for message sending. |
2 |
* |
3 |
* IRC Services is copyright (c) 1996-2009 Andrew Church. |
4 |
* E-mail: <achurch@achurch.org> |
5 |
* Parts written by Andrew Kempe and others. |
6 |
* This program is free but copyrighted software; see the file GPL.txt for |
7 |
* details. |
8 |
*/ |
9 |
|
10 |
#ifndef SEND_H |
11 |
#define SEND_H |
12 |
|
13 |
/*************************************************************************/ |
14 |
|
15 |
/* Protocol information (set by protocol module): */ |
16 |
|
17 |
extern const char *protocol_name; |
18 |
extern const char *protocol_version; |
19 |
extern uint32 protocol_features; |
20 |
extern int protocol_nickmax; |
21 |
extern const char *pseudoclient_modes; |
22 |
extern const char *enforcer_modes; |
23 |
extern int pseudoclient_oper; |
24 |
|
25 |
|
26 |
/* Constants for protocol_features: */ |
27 |
|
28 |
/* Has a "halfop" (+h) channel user mode (Unreal, etc.) */ |
29 |
#define PF_HALFOP 0x00000001 |
30 |
/* Has "protect" (+a) and "owner" (+q) channel user modes (Unreal, etc.) */ |
31 |
#define PF_CHANPROT 0x00000002 |
32 |
/* Has channel ban exceptions (+e) */ |
33 |
#define PF_BANEXCEPT 0x00000004 |
34 |
/* Has SZLINE command or equivalent (ban IP address/mask from all servers) */ |
35 |
#define PF_SZLINE 0x00000008 |
36 |
/* Suppresses QUIT messages from clients on server disconnects */ |
37 |
#define PF_NOQUIT 0x00000010 |
38 |
/* Supports some method to make a client join a channel */ |
39 |
#define PF_SVSJOIN 0x00000020 |
40 |
/* Supports some method of forcibly changing a client's nickname */ |
41 |
#define PF_CHANGENICK 0x00000040 |
42 |
/* Supports autokill exclusions */ |
43 |
#define PF_AKILL_EXCL 0x00000080 |
44 |
/* Timestamp in MODE message comes right after channel name */ |
45 |
#define PF_MODETS_FIRST 0x00000100 |
46 |
/* Has channel invite masks (+I) */ |
47 |
#define PF_INVITEMASK 0x00000200 |
48 |
|
49 |
/* Invalid flag, used to check whether protocol_features was set */ |
50 |
#define PF_UNSET 0x80000000 |
51 |
|
52 |
|
53 |
/* Routines to be implemented by protocol modules: */ |
54 |
|
55 |
E_FUNCPTR(void, send_nick, (const char *nick, const char *user, |
56 |
const char *host, const char *server, |
57 |
const char *name, const char *modes)); |
58 |
E_FUNCPTR(void, send_nickchange, (const char *nick, const char *newnick)); |
59 |
E_FUNCPTR(void, send_namechange, (const char *nick, const char *newname)); |
60 |
E_FUNCPTR(void, send_server, (void)); |
61 |
E_FUNCPTR(void, send_server_remote, (const char *server, const char *desc)); |
62 |
E_FUNCPTR(void, wallops, (const char *source, const char *fmt, ...) |
63 |
FORMAT(printf,2,3)); |
64 |
E_FUNCPTR(void, notice_all, (const char *source, const char *fmt, ...) |
65 |
FORMAT(printf,2,3)); |
66 |
E_FUNCPTR(void, send_channel_cmd, (const char *source, const char *fmt, ...) |
67 |
FORMAT(printf,2,3)); |
68 |
E_FUNCPTR(void, send_nickchange_remote, |
69 |
(const char *nick, const char *newnick)); |
70 |
|
71 |
/*************************************************************************/ |
72 |
|
73 |
/* Flags for send_pseudo_nick(): */ |
74 |
|
75 |
/* Pseudoclient requires oper privileges (note that depending on the |
76 |
* protocol, the pseudoclient may not actually get +o) */ |
77 |
#define PSEUDO_OPER 0x01 |
78 |
/* Pseudoclient should be invisible (+i) */ |
79 |
#define PSEUDO_INVIS 0x02 |
80 |
|
81 |
/*************************************************************************/ |
82 |
|
83 |
/* External declarations. */ |
84 |
|
85 |
/* Last time at which data was sent. Used to check whether a PING needs |
86 |
* to be sent. */ |
87 |
extern time_t last_send; |
88 |
|
89 |
/* Initialization/cleanup */ |
90 |
extern int send_init(int ac, char **av); |
91 |
extern void send_cleanup(void); |
92 |
|
93 |
/* Basic message-sending routine ([v]printf-like) */ |
94 |
extern void send_cmd(const char *source, const char *fmt, ...) |
95 |
FORMAT(printf,2,3); |
96 |
extern void vsend_cmd(const char *source, const char *fmt, va_list args) |
97 |
FORMAT(printf,2,0); |
98 |
|
99 |
/* Shortcuts for sending miscellaneous messages */ |
100 |
extern void send_error(const char *fmt, ...) FORMAT(printf,1,2); |
101 |
extern void send_cmode_cmd(const char *source, const char *channel, |
102 |
const char *fmt, ...); |
103 |
extern void send_pseudo_nick(const char *nick, const char *realname, |
104 |
int flags); |
105 |
|
106 |
/* Routines for PRIVMSG/NOTICE sending */ |
107 |
extern void notice(const char *source, const char *dest, const char *fmt, ...) |
108 |
FORMAT(printf,3,4); |
109 |
extern void notice_list(const char *source, const char *dest, |
110 |
const char **text); |
111 |
extern void notice_lang(const char *source, const User *dest, int message, |
112 |
...); |
113 |
extern void notice_help(const char *source, const User *dest, int message, |
114 |
...); |
115 |
extern void privmsg(const char *source, const char *dest, const char *fmt, ...) |
116 |
FORMAT(printf,3,4); |
117 |
|
118 |
/*************************************************************************/ |
119 |
|
120 |
#endif /* SEND_H */ |
121 |
|
122 |
/* |
123 |
* Local variables: |
124 |
* c-file-style: "stroustrup" |
125 |
* c-file-offsets: ((case-label . *) (statement-case-intro . *)) |
126 |
* indent-tabs-mode: nil |
127 |
* End: |
128 |
* |
129 |
* vim: expandtab shiftwidth=4: |
130 |
*/ |