author | Tero Marttila <terom@fixme.fi> |
Sun, 15 Mar 2009 01:17:22 +0200 | |
branch | modules |
changeset 55 | 6f7f6ae729d0 |
parent 48 | 4841f4398fd2 |
child 56 | 942370000450 |
permissions | -rw-r--r-- |
3 | 1 |
#ifndef ERROR_H |
2 |
#define ERROR_H |
|
3 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
4 |
/** |
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
5 |
* @file |
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
6 |
* |
3 | 7 |
* Error-handling functions |
8 |
*/ |
|
9 |
#include <errno.h> |
|
10 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
11 |
/** |
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
12 |
* The type used for error codes is an explicitly *unsigned* int, meaning that error codes themselves are positive. |
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
13 |
* Negative error codes (as signed ints) also exist in some places, and they are just a negative err_t. |
3 | 14 |
*/ |
15 |
typedef unsigned int err_t; |
|
16 |
||
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
17 |
/** |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
18 |
* Ways to interpret error_info.extra |
7 | 19 |
*/ |
20 |
enum error_extra_types { |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
21 |
/** No extra info */ |
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
22 |
ERR_EXTRA_NONE = 0, |
7 | 23 |
|
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
24 |
/** libc errno, using strerror() */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
25 |
ERR_EXTRA_ERRNO, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
26 |
|
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
27 |
/** libc resolver, using gai_strerror() */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
28 |
ERR_EXTRA_GAI, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
29 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
30 |
/** GnuTLS, using gnutls_strerror() */ |
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
31 |
ERR_EXTRA_GNUTLS, |
7 | 32 |
}; |
33 |
||
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
34 |
/** |
3 | 35 |
* List of defined error codes, organized mostly by function name |
36 |
*/ |
|
37 |
enum error_code { |
|
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
38 |
_ERR_INVALID = 0x000000, |
3 | 39 |
|
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
40 |
/** stdlib.h functions */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
41 |
_ERR_STDLIB = 0x000100, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
42 |
ERR_CALLOC, |
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
43 |
ERR_STRDUP, |
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
44 |
|
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
45 |
/** DNS resolver */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
46 |
_ERR_RESOLVER = 0x000200, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
47 |
ERR_GETADDRINFO, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
48 |
ERR_GETADDRINFO_EMPTY, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
49 |
|
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
50 |
/** @see enum sock_error_code*/ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
51 |
_ERR_SOCK = 0x000300, |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
52 |
|
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
53 |
/** @see enum sock_gnutls_error_code */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
54 |
_ERR_GNUTLS = 0x000400, |
10
9fe218576d13
fix sock_stream read/write return value, move line buffer inside of line_proto, add some initial code for event-based non-blocking operation
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
55 |
|
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
56 |
/** Libevent errors */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
57 |
_ERR_LIBEVENT = 0x000500, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
58 |
ERR_EVENT_NEW, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
59 |
ERR_EVENT_ADD, |
17 | 60 |
|
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
61 |
/** Evsql errors */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
62 |
_ERR_EVSQL = 0x000600, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
63 |
ERR_EVSQL_NEW_PQ, |
23
542c73d07d3c
add a simple irc_log module (with evsql code) that joins a channel and log_info's PRIVMSGs
Tero Marttila <terom@fixme.fi>
parents:
17
diff
changeset
|
64 |
|
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
65 |
/** irc_proto errors */ |
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
66 |
_ERR_IRC_LINE = 0x000700, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
67 |
ERR_LINE_TOO_LONG, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
68 |
ERR_LINE_INVALID_TOKEN, |
37
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
69 |
ERR_INVALID_NM, |
4fe4a3c4496e
change irc_chan.state into bool fields, move irc_cmd implementation from irc_conn.c into irc_cmd.c, remove irc_conn arg from irc_cmd_handler, add irc_conn.nickname tracking, and handle irc_chan JOINs
Tero Marttila <terom@fixme.fi>
parents:
34
diff
changeset
|
70 |
ERR_INVALID_NICK_LENGTH, |
27
e6639132bead
add irc_conn_callbacks, and delay irc_chan_join until on_registered
Tero Marttila <terom@fixme.fi>
parents:
23
diff
changeset
|
71 |
|
e6639132bead
add irc_conn_callbacks, and delay irc_chan_join until on_registered
Tero Marttila <terom@fixme.fi>
parents:
23
diff
changeset
|
72 |
/** irc_conn errors */ |
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
73 |
_ERR_IRC_CONN = 0x000800, |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
74 |
ERR_IRC_CONN_REGISTER_STATE, |
48
4841f4398fd2
add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
75 |
ERR_IRC_CONN_QUIT_STATE, |
4841f4398fd2
add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
76 |
|
4841f4398fd2
add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
77 |
/** irc_net errors */ |
4841f4398fd2
add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
78 |
_ERR_IRC_NET = 0x000900, |
4841f4398fd2
add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
79 |
ERR_IRC_NET_QUIT_STATE, |
55
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
80 |
|
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
81 |
/** modul errors */ |
6f7f6ae729d0
'working' modules code, and convert irc_log to use said interface, but we've hit the limits on our Makefile, and the compiled module doesn't really work
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
82 |
_ERR_MODULE = 0x000a00, |
30
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
83 |
}; |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
84 |
|
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
85 |
/** |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
86 |
* Table of error descriptions |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
87 |
*/ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
88 |
struct error_desc { |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
89 |
/** The flat error code */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
90 |
err_t code; |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
91 |
|
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
92 |
/** The short name */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
93 |
const char *name; |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
94 |
|
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
95 |
/** How to interpret .extra */ |
7f8dd120933f
rework error to use a struct error_desc, and move ERR_SOCK/ERR_GNUTLS definitions to sock.h/sock_gnutls.h. error_desc definitions are still in error.c, though :(
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
96 |
enum error_extra_types extra_type; |
3 | 97 |
}; |
98 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
99 |
/** |
3 | 100 |
* An error code and associated extra infos |
101 |
*/ |
|
102 |
struct error_info { |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
103 |
/** The base error code */ |
3 | 104 |
err_t code; |
105 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
106 |
/** Additional detail info, usually some third-party error code, as defined by the code's ERR_EXTRA_* */ |
27
e6639132bead
add irc_conn_callbacks, and delay irc_chan_join until on_registered
Tero Marttila <terom@fixme.fi>
parents:
23
diff
changeset
|
107 |
int extra; |
3 | 108 |
}; |
109 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
110 |
/** |
7 | 111 |
* Translate an err_t into a function name. |
6 | 112 |
*/ |
113 |
const char *error_name (err_t code); |
|
114 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
115 |
/** |
7 | 116 |
* Maximum length of error messages returned by error_msg (including NUL byte) |
117 |
*/ |
|
118 |
#define ERROR_MSG_MAXLEN 1024 |
|
119 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
120 |
/** |
7 | 121 |
* Translate an error_info into a message. |
122 |
* |
|
123 |
* This is returned as a pointer into a statically allocated buffer. It is not re-entrant. |
|
124 |
*/ |
|
8
be88e543c8ff
split off line_proto, and make sock_stream_error return a const error_info
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
125 |
const char *error_msg (const struct error_info *err); |
7 | 126 |
|
3 | 127 |
/** No error, evaulates as logical false */ |
128 |
#define SUCCESS (0) |
|
129 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
130 |
/** Evaulates to error_info.code as lvalue */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
131 |
#define ERROR_CODE(err_info_ptr) ((err_info_ptr)->code) |
3 | 132 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
133 |
/** Evaulates to error_info.extra as lvalue */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
134 |
#define ERROR_EXTRA(err_info_ptr) ((err_info_ptr)->extra) |
3 | 135 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
136 |
/** Set error_info.code to SUCCESS, evaulates as zero */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
137 |
#define RESET_ERROR(err_info_ptr) ((err_info_ptr)->code = SUCCESS) |
3 | 138 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
139 |
/** Compare error_info.code != 0 */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
140 |
#define IS_ERROR(err_info_ptr) (!!(err_info_ptr)->code) |
3 | 141 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
142 |
/** Compare the err_code/err_extra for an err_info */ |
10
9fe218576d13
fix sock_stream read/write return value, move line buffer inside of line_proto, add some initial code for event-based non-blocking operation
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
143 |
#define MATCH_ERROR(err_info_ptr, err_code, err_extra) ((err_info_ptr)->code == (err_code) && (err_info_ptr)->extra == (err_extra)) |
9fe218576d13
fix sock_stream read/write return value, move line buffer inside of line_proto, add some initial code for event-based non-blocking operation
Tero Marttila <terom@fixme.fi>
parents:
8
diff
changeset
|
144 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
145 |
/** Set error_info.code, but leave err_extra as-is. Evaluates to err_code */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
146 |
#define SET_ERROR(err_info_ptr, err_code) ((err_info_ptr)->code = (err_code)) |
3 | 147 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
148 |
/** Set error_info.code/extra. XXX: should evaluate to err_code */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
149 |
#define _SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra) (err_info_ptr)->code = (err_code); (err_info_ptr)->extra = (err_extra) |
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
150 |
#define SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra) do { _SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra); } while (0) |
3 | 151 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
152 |
/** Set error_info.code to err_code, and .extra to errno. XXX: should evaulate to err_code */ |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
153 |
#define _SET_ERROR_ERRNO(err_info_ptr, err_code) _SET_ERROR_EXTRA(err_info_ptr, err_code, errno); |
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
154 |
#define SET_ERROR_ERRNO(err_info_ptr, err_code) SET_ERROR_EXTRA(err_info_ptr, err_code, errno); |
3 | 155 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
156 |
/** Set error_info from another error_info. Evaluates to the new error_info */ |
5 | 157 |
#define SET_ERROR_INFO(err_info_ptr, from_ptr) (*err_info_ptr = *from_ptr) |
158 |
||
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
159 |
/** Same as above, but also return err_code from func. XXX: use 'return SET_ERROR...' instead */ |
5 | 160 |
#define RETURN_SET_ERROR(err_info_ptr, err_code) do { SET_ERROR(err_info_ptr, err_code); return (err_code); } while (0) |
4
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
161 |
#define RETURN_SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra) do { _SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra); return (err_code); } while (0) |
a3ca0f97a075
change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents:
3
diff
changeset
|
162 |
#define RETURN_SET_ERROR_ERRNO(err_info_ptr, err_code) do { _SET_ERROR_ERRNO(err_info_ptr, err_code); return (err_code); } while (0) |
8
be88e543c8ff
split off line_proto, and make sock_stream_error return a const error_info
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
163 |
#define RETURN_SET_ERROR_INFO(err_info_ptr, from_ptr) do { SET_ERROR_INFO(err_info_ptr, from_ptr); return (from_ptr->code); } while (0) |
3 | 164 |
|
34
763f65f9df0c
add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents:
30
diff
changeset
|
165 |
/** Same as above, but also do a 'goto error' */ |
5 | 166 |
#define JUMP_SET_ERROR(err_info_ptr, err_code) do { SET_ERROR(err_info_ptr, err_code); goto error; } while (0) |
167 |
#define JUMP_SET_ERROR_INFO(err_info_ptr, from_ptr) do { SET_ERROR_INFO(err_info_ptr, from_ptr); goto error; } while (0) |
|
168 |
||
3 | 169 |
#endif |