]> jfr.im git - irc/quakenet/snircd.git/blame - doc/api/send.txt
sync undernet upstream ircu changes.
[irc/quakenet/snircd.git] / doc / api / send.txt
CommitLineData
189935b1 1The send functions are perhaps the most important API in all of ircd;
2without them, communications would not be possible. Most of these
3functions are pretty much stand-alone, although one or two are
4intended for use in conjunction with the MsgQ interface. The send
5functions use the MsgQ interface internally, but for the most part,
6this fact is hidden from the caller.
7
8Command tokenization provides the greatest complication. The
9functions do use ircd_snprintf() internally, so the use of numerics
10doesn't increase that complication. The tokenization issue is dealt
11with by making each function accept two char* pointers, _cmd_ and
12_tok_, in that order, and then defining a CMD_* macro in msg.h that
13contains the message string and the token string in that order. When
14one of these functions is called, it determines whether the
15destination will be a server or a user, then selects the correct one,
16either _cmd_ or _tok_, for that message.
17
18The MsgQ interface provides the concept of a priority queue; messages
19which must be sent as soon as possible, regardless of what other
20messages may already be in the queue. The sendcmdto_prio_one() and
21sendcmdto_flag_butone() functions make use of this priority queue.
22The function send_buffer() also takes a _prio_ argument that should be
23non-zero if the message passed to it should be placed in the priority
24queue.
25
26<macro>
27#define SKIP_DEAF 0x01 /* skip users that are +d */
28
29This flag may be passed to sendcmdto_channel_butone() to cause a
30message passed by that function to skip users that are +d. See the
31documentation for sendcmdto_channel_butone() for more information.
32</macro>
33
34<macro>
35#define SKIP_BURST 0x02 /* skip users that are bursting */
36
37This is another flag that may be passed to
38sendcmdto_channel_butone(). Its purpose is to cause the server to not
39send the message across a link that is still in the "burst" stage of
40network junction. See the documentation for
41sendcmdto_channel_butone() for more information.
42</macro>
43
44<macro>
45#define SKIP_NONOPS 0x04 /* skip users that aren't chanops */
46
47Some messages may need to be passed only to channel operators. This
48flag is passed to sendcmdto_channel_butone() when that is the case.
49See the documentation for sendcmdto_channel_butone() for more
50information.
51</macro>
52
53<function>
54void send_buffer(struct Client* to, struct MsgBuf* buf, int prio);
55
56Some applications may need to build a message piece by piece, directly
57utilizing the MsgQ interface. The function send_buffer() is used when
58that message has been completed to place the message on a client's
59queue. See the documentation for the MsgQ interface for more
60information about struct MsgBuf and the _buf_ parameter.
61</function>
62
63<function>
64void flush_connections(struct Client* cptr);
65
66This function attempts to send all queued data to a client specified
67by _cptr_. If _cptr_ is 0, all clients with non-empty send queues
68will have their queues flushed.
69</function>
70
71<function>
72void send_queued(struct Client *to);
73
74This function attempts to send all queued data to a client specified
75by _to_. The _to_ parameter is not permitted to be 0. This is the
76function called by flush_connections().
77</function>
78
79<function>
80void sendrawto_one(struct Client *to, const char *pattern, ...);
81
82Most of the actual send functions in this API send their data with a
83prefix--the numeric of the origin. This function is used when a
84message should be sent _without_ that prefix. The caller must specify
85the complete message, including the exact command, with the _pattern_
86argument and the variable argument list following it.
87</function>
88
89<function>
90void sendcmdto_one(struct Client *from, const char *cmd, const char *tok,
91 struct Client *to, const char *pattern, ...);
92
93This function is used for sending messages to specific clients. The
94origin of the message is specified using the _from_ parameter; this
95will be used to formulate the origin. As mentioned above, _cmd_ and
96_tok_ are used to determine the command and token to be used. The
97_to_ parameter specifies which client the message should be sent to.
98The origin and command will be formatted and followed by a space; the
99given _pattern_ and the following arguments are passed to
100ircd_snprintf() for formatting.
101</function>
102
103<function>
104void sendcmdto_prio_one(struct Client *from, const char *cmd, const char *tok,
105 struct Client *to, const char *pattern, ...);
106
107This function is identical to sendcmdto_one() except that messages
108formatted using it will be placed onto the priority queue.
109</function>
110
111<function>
112void sendcmdto_serv_butone(struct Client *from, const char *cmd,
113 const char *tok, struct Client *one,
114 const char *pattern, ...);
115
116This function treats its arguments similar to sendcmdto_one() does.
117Messages passed created with this function are sent to all directly
118linked servers except for the _one_ passed. If _one_ is 0, the
119message is sent to all linked servers.
120</function>
121
122<function>
123void sendcmdto_common_channels(struct Client *from, const char *cmd,
124 const char *tok, const char *pattern, ...);
125
126When a user quits IRC, all of the other users on the channels that the
127user is on must receive a single QUIT message. This function formats
128the message, under control of _from_ (for the origin prefix), _cmd_
129and _tok_, and _pattern_ and the variable argument list, and sends
130that message to all local users on the same channels as the user
131specified by _from_. This function does not send any messages across
132server<->server links.
133</function>
134
135<function>
136void sendcmdto_channel_butserv(struct Client *from, const char *cmd,
137 const char *tok, struct Channel *to,
138 const char *pattern, ...);
139
140This function is used to send a command to every local user on a
141particular channel, specified by _to_. No messages are sent across
142the server<->server links.
143</function>
144
145<function>
146void sendcmdto_channel_butone(struct Client *from, const char *cmd,
147 const char *tok, struct Channel *to,
148 struct Client *one, unsigned int skip,
149 const char *pattern, ...);
150
151This function is used mostly for sending PRIVMSG commands to
152particular channels. The users that receive the message are under the
153control of the _skip_ parameter, which is a binary OR of the
154SKIP_DEAF, SKIP_BURST, and SKIP_NONOPS flags, depending on what
155channel users should see the message. This function sends messages
156across both client<->server and server<->server links, as needed. The
157client specified by _one_ will not receive a copy of the message.
158</function>
159
160<function>
161void sendcmdto_flag_butone(struct Client *from, const char *cmd,
162 const char *tok, struct Client *one,
163 unsigned int flag, const char *pattern, ...);
164
165This function is used for sending messages to clients with specific
166user modes set (specified by the _flag_ parameter). Three flags make
167sense for this function: FLAGS_WALLOP (user mode +w), FLAGS_DEBUG
168(user mode +g), and FLAGS_OPER. FLAGS_OPER has a special meaning that
169further restricts distribution of the message only to IRC operators.
170For the purposes of this function, no distinction is made between
171global operators and local operators.
172</function>
173
174<function>
175void sendcmdto_match_butone(struct Client *from, const char *cmd,
176 const char *tok, const char *to,
177 struct Client *one, unsigned int who,
178 const char *pattern, ...);
179
180Certain kinds of global messages may be sent by IRC operators. This
181function implements those global messages. The _to_ parameter is used
182to specify a pattern by which to filter users, while _who_ specifies
183whether that pattern is to be applied to the user's server name or to
184the user's host name. The _who_ parameter may be one of MATCH_SERVER
185or MATCH_HOST; these two macros are defined in s_user.h. The _one_
186parameter will not receive a copy of the message.
187</function>
188
189<function>
190void sendto_opmask_butone(struct Client *one, unsigned int mask,
191 const char *pattern, ...);
192
193The sendto_opmask_butone() function sends a server notice to all
194subscribing users except for _one_. The _mask_ parameter is one of
195the SNO_* values defined in client.h and is used for selection of
196subscribing users.
197</function>
198
199<function>
200void vsendto_opmask_butone(struct Client *one, unsigned int mask,
201 const char *pattern, va_list vl);
202
203The vsendto_opmask_butone() function is identical to the
204sendto_opmask_butone() function except that instead of a variable
205argument list, it takes a va_list, specified by _vl_.
206</function>
207
208<macro>
209#define SND_EXPLICIT 0x40000000 /* first arg is a pattern to use */
210
211When this flag, defined in ircd_reply.h, is combined with the _reply_
212argument to the send_reply() function, the format string send_reply()
213uses is obtained from the first argument in the variable argument list
214passed to that function, rather than from the table of replies.
215</macro>
216
217<function>
218int send_reply(struct Client* to, int reply, ...);
219
220The send_reply() function, declared in ircd_reply.h, is used to send
221clients numeric replies. Unless SND_EXPLICIT is used, the pattern
222will be extracted from a table of replies.
223</function>
224
225<authors>
226Kev <klmitch@mit.edu>
227</authors>
228
229<changelog>
230[2001-6-15 Kev] Initial documentation for the send functions.
231</changelog>