author | Tero Marttila <terom@fixme.fi> |
Sat, 28 Feb 2009 22:47:39 +0200 | |
changeset 18 | dedf137b504f |
parent 17 | 5001564ac5fc |
child 34 | 763f65f9df0c |
permissions | -rw-r--r-- |
17 | 1 |
#ifndef IRC_LINE_H |
2 |
#define IRC_LINE_H |
|
3 |
||
4 |
#include "error.h" |
|
5 |
||
6 |
/* |
|
18
dedf137b504f
add initial irc_conn code that can register
Tero Marttila <terom@fixme.fi>
parents:
17
diff
changeset
|
7 |
* The maximum length of a line, without terminating CRLF |
17 | 8 |
*/ |
18
dedf137b504f
add initial irc_conn code that can register
Tero Marttila <terom@fixme.fi>
parents:
17
diff
changeset
|
9 |
#define IRC_LINE_MAX 510 |
17 | 10 |
|
11 |
/* |
|
12 |
* The maximum number of arguments for a single command |
|
13 |
*/ |
|
14 |
#define IRC_ARG_MAX 15 |
|
15 |
||
16 |
/* |
|
17 |
* Chars that are invalid inside of tokens |
|
18 |
*/ |
|
19 |
#define IRC_TOKEN_INVALID "\r\n\n " |
|
20 |
#define IRC_TOKEN_TRAILING_INVALID "\r\n\n" |
|
21 |
||
22 |
/* |
|
23 |
* Low-level IRC protocol unit is a line with its bits |
|
24 |
*/ |
|
25 |
struct irc_line { |
|
26 |
/* The message source, either a server name or a nickmask */ |
|
27 |
const char *prefix; |
|
28 |
||
29 |
/* The command, either a numeric or a primary command */ |
|
30 |
const char *command; |
|
31 |
||
32 |
/* The arguments, with unused ones set to NULL */ |
|
33 |
const char *args[IRC_ARG_MAX]; |
|
34 |
}; |
|
35 |
||
36 |
/* |
|
37 |
* Parse an IRC message to fill in an irc_line. This mutates the value of data (to insert NULs between tokens), and |
|
38 |
* stores pointers into this data into the irc_line. |
|
39 |
*/ |
|
40 |
err_t irc_line_parse (struct irc_line *line, char *data); |
|
41 |
||
42 |
/* |
|
43 |
* Formats an irc_line as a protocol line into the given buffer (which should hold at least IRC_LINE_MAX bytes). |
|
44 |
*/ |
|
45 |
err_t irc_line_build (const struct irc_line *line, char *buf); |
|
46 |
||
47 |
#endif /* IRC_LINE_H */ |