15 const char *error_name (err_t code) |
15 const char *error_name (err_t code) |
16 { |
16 { |
17 switch (code) { |
17 switch (code) { |
18 ERROR_NAME( ERR_CALLOC, "calloc" ); |
18 ERROR_NAME( ERR_CALLOC, "calloc" ); |
19 ERROR_NAME( ERR_GETADDRINFO, "getaddrinfo" ); |
19 ERROR_NAME( ERR_GETADDRINFO, "getaddrinfo" ); |
20 ERROR_NAME( ERR_GETADDRINFO_EMPTY, "getaddrinfo" ); |
20 ERROR_NAME( ERR_GETADDRINFO_EMPTY, "getaddrinfo: no results" ); |
21 ERROR_NAME( ERR_SOCKET, "socket" ); |
21 ERROR_NAME( ERR_SOCKET, "socket" ); |
22 ERROR_NAME( ERR_CONNECT, "connect" ); |
22 ERROR_NAME( ERR_CONNECT, "connect" ); |
23 ERROR_NAME( ERR_READ, "read" ); |
23 ERROR_NAME( ERR_READ, "read" ); |
|
24 ERROR_NAME( ERR_READ_EOF, "read: EOF" ); |
24 ERROR_NAME( ERR_WRITE, "write" ); |
25 ERROR_NAME( ERR_WRITE, "write" ); |
25 ERROR_NAME( ERR_GNUTLS_CERT_ALLOC_CRED, "gnutls_certificate_allocate_credentials" ); |
26 ERROR_NAME( ERR_GNUTLS_CERT_ALLOC_CRED, "gnutls_certificate_allocate_credentials" ); |
26 ERROR_NAME( ERR_GNUTLS_GLOBAL_INIT, "gnutls_global_init" ); |
27 ERROR_NAME( ERR_GNUTLS_GLOBAL_INIT, "gnutls_global_init" ); |
27 ERROR_NAME( ERR_GNUTLS_INIT, "gnutls_init" ); |
28 ERROR_NAME( ERR_GNUTLS_INIT, "gnutls_init" ); |
28 ERROR_NAME( ERR_GNUTLS_SET_DEFAULT_PRIORITY, "gnutls_set_default_priority" ); |
29 ERROR_NAME( ERR_GNUTLS_SET_DEFAULT_PRIORITY, "gnutls_set_default_priority" ); |
30 ERROR_NAME( ERR_GNUTLS_HANDSHAKE, "gnutls_handshake" ); |
31 ERROR_NAME( ERR_GNUTLS_HANDSHAKE, "gnutls_handshake" ); |
31 default: return "[unknown]"; |
32 default: return "[unknown]"; |
32 } |
33 } |
33 } |
34 } |
34 |
35 |
35 const char *error_msg (struct error_info *err) |
36 const char *error_msg (const struct error_info *err) |
36 { |
37 { |
37 static char msg[ERROR_MSG_MAXLEN]; |
38 static char msg[ERROR_MSG_MAXLEN]; |
38 |
39 |
39 // intrepret .extra |
40 // intrepret .extra |
40 switch (err->code & _ERR_EXTRA_MASK) { |
41 switch (err->code & _ERR_EXTRA_MASK) { |