author | Tero Marttila <terom@fixme.fi> |
Thu, 12 Mar 2009 18:48:42 +0200 | |
changeset 39 | a4891d71aca9 |
child 45 | 71e65564afd2 |
permissions | -rw-r--r-- |
39
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef IRC_PROTO_H |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define IRC_PROTO_H |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
* @file |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
* |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
* General IRC protocol things, such as prefix/nickmask/nickname parsing |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
#include "error.h" |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
#include <stddef.h> |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
* Maximum length of an IRC nickname including terminating NUL |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
#define IRC_NICK_MAX 31 |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
* Parsed nickmask |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
struct irc_nm { |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
/** Nickname, not normalized */ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
const char *nickname; |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
/** Username, including any ident-related prefix from the network */ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
const char *username; |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
/** Hostname, either reverse DNS hostname, literal IPv4 or literal IPv6 */ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
const char *hostname; |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
}; |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
* Parse a full nickmask from a prefix. This fails if the prefix is a server name. |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
* |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
* XXX: not implemented, and memory-management issues |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
err_t irc_nm_parse (struct irc_nm *nm, char *prefix); |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
* Compare two nicknames for equality, with standard strcmp() semantics. |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
int irc_cmp_nick (const char *nick1, const char *nick2); |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
* Compare up to the first n chars of the two nickname strings for equality, with standard strcmp() semantics. |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
46 |
int irc_ncmp_nick (const char *nick1, const char *nick2, size_t n); |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
* Parse the nickname portion of a prefix, storing it in the given buffer of IRC_NICK_MAX bytes. |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
51 |
err_t irc_prefix_parse_nick (const char *prefix, char nick[IRC_NICK_MAX]); |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
53 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
54 |
* Compare the nickname in the given prefix and with the given nickname for equality. |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
* |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
56 |
* @return -err for invalid prefix, 0 for match, >0 for non-match. |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
57 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
58 |
int irc_prefix_cmp_nick (const char *prefix, const char *nick); |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
59 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
60 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
* @group IRC command numerics |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
62 |
* @{ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
63 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
64 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
65 |
/** |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
66 |
* 001 <nick> :Welcome to the Internet Relay Network <nick>!<user>@<host> |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
67 |
*/ |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
68 |
#define IRC_RPL_WELCOME "001" |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
69 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
// @} |
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
|
a4891d71aca9
rename irc_nm to irc_proto, and move numerics from irc_cmd.h
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
72 |
#endif |