author | Tero Marttila <terom@fixme.fi> |
Sun, 15 Mar 2009 23:22:57 +0200 | |
branch | modules |
changeset 57 | ce1accba5fc7 |
parent 56 | 942370000450 |
child 63 | d399a1d915a3 |
permissions | -rw-r--r-- |
6 | 1 |
|
2 |
#include "error.h" |
|
3 |
||
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:
10
diff
changeset
|
4 |
// for the error_desc tables |
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:
10
diff
changeset
|
5 |
#include "sock.h" |
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:
10
diff
changeset
|
6 |
#include "sock_gnutls.h" |
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:
41
diff
changeset
|
7 |
#include "module.h" |
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:
10
diff
changeset
|
8 |
|
7 | 9 |
#include <string.h> |
10 |
#include <stdio.h> |
|
11 |
||
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:
10
diff
changeset
|
12 |
struct error_desc _core_error_desc[] = { |
31 | 13 |
{ ERR_CALLOC, "calloc", ERR_EXTRA_NONE }, |
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:
31
diff
changeset
|
14 |
{ ERR_STRDUP, "strdup", ERR_EXTRA_NONE }, |
31 | 15 |
{ ERR_GETADDRINFO, "getaddrinfo", ERR_EXTRA_GAI }, |
16 |
{ ERR_GETADDRINFO_EMPTY, "getaddrinfo: no results", ERR_EXTRA_NONE }, |
|
17 |
{ ERR_EVENT_NEW, "event_new", ERR_EXTRA_NONE }, |
|
18 |
{ ERR_EVENT_ADD, "event_add", ERR_EXTRA_NONE }, |
|
19 |
{ ERR_EVSQL_NEW_PQ, "evsql_new_pq", ERR_EXTRA_NONE }, |
|
20 |
{ _ERR_INVALID, NULL, 0 } |
|
7 | 21 |
|
31 | 22 |
}, _sock_error_desc[] = { |
23 |
{ ERR_SOCKET, "socket", ERR_EXTRA_ERRNO }, |
|
24 |
{ ERR_CONNECT, "connect", ERR_EXTRA_ERRNO }, |
|
25 |
{ ERR_READ, "read", ERR_EXTRA_ERRNO }, |
|
26 |
{ ERR_READ_EOF, "read: EOF", ERR_EXTRA_NONE }, |
|
27 |
{ ERR_WRITE, "write", ERR_EXTRA_ERRNO }, |
|
28 |
{ ERR_WRITE_EOF, "write: EOF", ERR_EXTRA_NONE }, |
|
29 |
{ ERR_FCNTL, "fcntl", ERR_EXTRA_ERRNO }, |
|
30 |
{ ERR_CLOSE, "close", ERR_EXTRA_ERRNO }, |
|
31 |
{ _ERR_INVALID, NULL, 0 } |
|
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:
10
diff
changeset
|
32 |
|
31 | 33 |
}, _sock_gnutls_error_desc[] = { |
34 |
{ ERR_GNUTLS_CERT_ALLOC_CRED, "gnutls_certificate_allocate_credentials", ERR_EXTRA_GNUTLS }, |
|
35 |
{ ERR_GNUTLS_GLOBAL_INIT, "gnutls_global_init", ERR_EXTRA_GNUTLS }, |
|
36 |
{ ERR_GNUTLS_SET_DEFAULT_PRIORITY, "gnutls_set_default_priority", ERR_EXTRA_GNUTLS }, |
|
37 |
{ ERR_GNUTLS_CRED_SET, "gnutls_credentials_set", ERR_EXTRA_GNUTLS }, |
|
38 |
{ ERR_GNUTLS_HANDSHAKE, "gnutls_handshake", ERR_EXTRA_GNUTLS }, |
|
39 |
{ ERR_GNUTLS_RECORD_SEND, "gnutls_record_send", ERR_EXTRA_GNUTLS }, |
|
40 |
{ ERR_GNUTLS_RECORD_RECV, "gnutls_record_recv", ERR_EXTRA_GNUTLS }, |
|
41 |
{ ERR_GNUTLS_RECORD_GET_DIRECTION, "gnutls_record_get_direction", ERR_EXTRA_GNUTLS }, |
|
42 |
{ _ERR_INVALID, NULL, 0 } |
|
43 |
||
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:
31
diff
changeset
|
44 |
}, _irc_proto_error_desc[] = { |
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:
31
diff
changeset
|
45 |
{ ERR_LINE_TOO_LONG, "IRC line is too long", ERR_EXTRA_NONE }, |
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:
31
diff
changeset
|
46 |
{ ERR_LINE_INVALID_TOKEN, "Illegal token value for IRC line", ERR_EXTRA_NONE }, |
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:
31
diff
changeset
|
47 |
{ ERR_INVALID_NM, "Invalid nickmask", ERR_EXTRA_NONE }, |
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:
31
diff
changeset
|
48 |
{ ERR_INVALID_NICK_LENGTH, "Nickname is too long", ERR_EXTRA_NONE }, |
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:
31
diff
changeset
|
49 |
{ _ERR_INVALID, NULL, 0 } |
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:
41
diff
changeset
|
50 |
}, _module_error_desc[] = { |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
51 |
{ ERR_MODULE_OPEN, "module dlopen() failed", ERR_EXTRA_STR }, |
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:
41
diff
changeset
|
52 |
{ ERR_MODULE_NAME, "invalid module name", ERR_EXTRA_NONE }, |
57
ce1accba5fc7
slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
53 |
{ ERR_MODULE_INIT_FUNC, "invalid module init func", ERR_EXTRA_STR }, |
56
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
54 |
{ ERR_MODULE_CONF, "module_conf", ERR_EXTRA_STR }, |
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:
41
diff
changeset
|
55 |
{ _ERR_INVALID, NULL, 0 } |
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:
10
diff
changeset
|
56 |
}; |
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:
10
diff
changeset
|
57 |
|
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:
10
diff
changeset
|
58 |
/** |
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:
10
diff
changeset
|
59 |
* Array of error_desc tables |
6 | 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:
10
diff
changeset
|
61 |
static struct error_desc* _desc_tables[] = { |
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:
10
diff
changeset
|
62 |
_core_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:
10
diff
changeset
|
63 |
_sock_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:
10
diff
changeset
|
64 |
_sock_gnutls_error_desc, |
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:
31
diff
changeset
|
65 |
_irc_proto_error_desc, |
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:
41
diff
changeset
|
66 |
_module_error_desc, |
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:
10
diff
changeset
|
67 |
NULL |
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:
10
diff
changeset
|
68 |
}; |
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:
10
diff
changeset
|
69 |
|
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:
10
diff
changeset
|
70 |
/** |
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:
10
diff
changeset
|
71 |
* Look up the error_desc for the given 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:
10
diff
changeset
|
72 |
*/ |
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:
10
diff
changeset
|
73 |
static const struct error_desc* error_lookup_desc (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:
10
diff
changeset
|
74 |
{ |
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:
10
diff
changeset
|
75 |
struct error_desc **desc_table, *desc = NULL; |
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:
10
diff
changeset
|
76 |
|
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:
10
diff
changeset
|
77 |
// iterate over each defined error_desc array |
41
40f7aa051acb
add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents:
37
diff
changeset
|
78 |
for (desc_table = _desc_tables; *desc_table; desc_table++) { |
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:
10
diff
changeset
|
79 |
for (desc = *desc_table; desc->code && desc->name; 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:
10
diff
changeset
|
80 |
// compare 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:
10
diff
changeset
|
81 |
if (desc->code == 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:
10
diff
changeset
|
82 |
// found |
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:
10
diff
changeset
|
83 |
return 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:
10
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:
10
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:
10
diff
changeset
|
86 |
|
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:
10
diff
changeset
|
87 |
// not found |
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:
10
diff
changeset
|
88 |
return NULL; |
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:
10
diff
changeset
|
89 |
} |
6 | 90 |
|
91 |
const char *error_name (err_t code) |
|
92 |
{ |
|
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:
10
diff
changeset
|
93 |
const struct error_desc *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:
10
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:
10
diff
changeset
|
95 |
// do we have an error_desc for it? |
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:
10
diff
changeset
|
96 |
if ((desc = error_lookup_desc(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:
10
diff
changeset
|
97 |
return desc->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:
10
diff
changeset
|
98 |
else |
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:
10
diff
changeset
|
99 |
// unknown |
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:
10
diff
changeset
|
100 |
return "[unknown]"; |
6 | 101 |
} |
102 |
||
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
|
103 |
const char *error_msg (const struct error_info *err) |
7 | 104 |
{ |
105 |
static char msg[ERROR_MSG_MAXLEN]; |
|
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:
10
diff
changeset
|
106 |
const struct error_desc *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:
10
diff
changeset
|
107 |
|
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:
10
diff
changeset
|
108 |
// do we have an error_desc for it? |
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:
10
diff
changeset
|
109 |
if ((desc = error_lookup_desc(err->code)) == NULL) |
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:
10
diff
changeset
|
110 |
// ??? |
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:
10
diff
changeset
|
111 |
snprintf(msg, ERROR_MSG_MAXLEN, "[%#.8x]: %#.8x", err->code, err->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:
10
diff
changeset
|
112 |
|
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:
10
diff
changeset
|
113 |
else |
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:
10
diff
changeset
|
114 |
// intrepret .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:
10
diff
changeset
|
115 |
switch (desc->extra_type) { |
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:
10
diff
changeset
|
116 |
case ERR_EXTRA_NONE: |
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:
10
diff
changeset
|
117 |
// no additional info |
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:
10
diff
changeset
|
118 |
snprintf(msg, ERROR_MSG_MAXLEN, "%s", desc->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:
10
diff
changeset
|
119 |
break; |
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:
10
diff
changeset
|
120 |
|
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:
10
diff
changeset
|
121 |
case 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:
10
diff
changeset
|
122 |
// 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:
10
diff
changeset
|
123 |
snprintf(msg, ERROR_MSG_MAXLEN, "%s: %s", desc->name, strerror(err->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:
10
diff
changeset
|
124 |
break; |
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:
10
diff
changeset
|
125 |
|
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:
10
diff
changeset
|
126 |
case 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:
10
diff
changeset
|
127 |
// 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:
10
diff
changeset
|
128 |
snprintf(msg, ERROR_MSG_MAXLEN, "%s: %s", desc->name, gai_strerror(err->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:
10
diff
changeset
|
129 |
break; |
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:
10
diff
changeset
|
130 |
|
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:
10
diff
changeset
|
131 |
case ERR_EXTRA_GNUTLS: |
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:
10
diff
changeset
|
132 |
// gnutls_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:
10
diff
changeset
|
133 |
snprintf(msg, ERROR_MSG_MAXLEN, "%s: %s", desc->name, gnutls_strerror(err->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:
10
diff
changeset
|
134 |
break; |
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:
10
diff
changeset
|
135 |
|
56
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
136 |
case ERR_EXTRA_STR: |
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
137 |
// static error message string |
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
138 |
snprintf(msg, ERROR_MSG_MAXLEN, "%s: %s", desc->name, err->extra_str); |
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
139 |
break; |
942370000450
compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents:
55
diff
changeset
|
140 |
|
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:
10
diff
changeset
|
141 |
default: |
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:
10
diff
changeset
|
142 |
// ??? |
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:
10
diff
changeset
|
143 |
snprintf(msg, ERROR_MSG_MAXLEN, "%s: %#.8x", desc->name, err->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:
10
diff
changeset
|
144 |
break; |
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:
10
diff
changeset
|
145 |
} |
7 | 146 |
|
147 |
// return static pointer |
|
148 |
return msg; |
|
149 |
} |
|
150 |