src/error.h
author Tero Marttila <terom@fixme.fi>
Sun, 03 May 2009 17:16:30 +0300
branchnew-transport
changeset 164 7847a7c3b678
parent 156 6534a4ac957b
child 178 3d357d055d67
permissions -rw-r--r--
remove ERR_READ_EOF, add more general errors, add missing _general_error_desc, and have error_name return for SUCCESS
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
#ifndef ERROR_H
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
#define ERROR_H
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     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
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
 * Error-handling functions
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
 */
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
#include <errno.h>
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    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
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
 */
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
typedef unsigned int err_t;
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    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
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
    19
 */
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
    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
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
    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,
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    32
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    33
    /** Static error message string */
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    34
    ERR_EXTRA_STR,
7
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
    35
};
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
    36
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
    37
/**
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
 * List of defined error codes, organized mostly by function name
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
 */
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
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
    41
    _ERR_INVALID    = 0x000000,
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
    
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
    43
    /** 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
    44
    _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
    45
    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
    46
    ERR_STRDUP,
71
0a13030f795d implement signal_ignore using sigaction directly, without any libevent in between
Tero Marttila <terom@fixme.fi>
parents: 68
diff changeset
    47
    ERR_SIGACTION,
108
50ff7ac8a725 implement modules_path + module_load with NULL path
Tero Marttila <terom@fixme.fi>
parents: 106
diff changeset
    48
    ERR_ACCESS_READ,
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
    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
    /** 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
    51
    _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
    52
    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
    53
    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
    54
    
155
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    55
    /** socket/IO 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
    56
    _ERR_SOCK       = 0x000300,
155
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    57
    ERR_SOCKET,         ///< socket(2) failed
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    58
    ERR_CONNECT,        ///< connect(2) error - either direct or async
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    59
    ERR_READ,           ///< read(2) error - will probably show up as an ERR_WRITE as well
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    60
    ERR_WRITE,          ///< write(2) error - data was unsent, will probably show up as an ERR_READ as well
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    61
    ERR_WRITE_EOF,      ///< write(2) gave EOF - zero bytes written
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    62
    ERR_FCNTL,          ///< fcntl(2) failed
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    63
    ERR_CLOSE,          ///< close(2) failed, some written data was probably not sent
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    64
    ERR_GETSOCKOPT,     ///< getsockopt(2) failed
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
    65
    ERR_OPEN,           ///< open(2) failed
4
a3ca0f97a075 change ERROR_* to use pointers again, and implement error_info for sock_init
Tero Marttila <terom@fixme.fi>
parents: 3
diff changeset
    66
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    67
    /** @see sock_gnutls_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
    68
    _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
    69
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
    70
    /** 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
    71
    _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
    72
    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
    73
    ERR_EVENT_ADD,
156
6534a4ac957b add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents: 155
diff changeset
    74
    ERR_EVENT_DEL,
17
5001564ac5fc irc_line implementation
Tero Marttila <terom@fixme.fi>
parents: 12
diff changeset
    75
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
    76
    /** 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
    77
    _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
    78
    ERR_EVSQL_NEW_PQ,
68
591a574f390e add FindEvsql/FindLibPQ cmake modules and irc_log.sql definition, and implement logging of JOIN, PART, MODE, TOPIC, KICK, PRIVMSG, NOTICE and OPEN messages
Tero Marttila <terom@fixme.fi>
parents: 63
diff changeset
    79
    ERR_EVSQL_QUERY_EXEC,
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
    80
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
    81
    /** 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
    82
    _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
    83
    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
    84
    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
    85
    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
    86
    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
    87
e6639132bead add irc_conn_callbacks, and delay irc_chan_join until on_registered
Tero Marttila <terom@fixme.fi>
parents: 23
diff changeset
    88
    /** 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
    89
    _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
    90
    ERR_IRC_CONN_REGISTER_STATE,
48
4841f4398fd2 add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    91
    ERR_IRC_CONN_QUIT_STATE,
4841f4398fd2 add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    92
4841f4398fd2 add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    93
    /** irc_net errors */
4841f4398fd2 add irc_net_quit and signal handling
Tero Marttila <terom@fixme.fi>
parents: 37
diff changeset
    94
    _ERR_IRC_NET    = 0x000900,
98
f357f835f0d5 add irc_client_defaults to apply default values for irc_client_add_net irc_net_info, implement --defaults cmd opt and lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
    95
    ERR_IRC_NET_INFO,
97
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
    96
    ERR_IRC_NET_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
    97
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    98
    /** @see module_error_code */
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
    99
    _ERR_MODULE     = 0x000a00,
63
d399a1d915a3 start reworking option-parsing, but --module/--config is still unimplemented
Tero Marttila <terom@fixme.fi>
parents: 57
diff changeset
   100
83
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents: 71
diff changeset
   101
    /** config errors */
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents: 71
diff changeset
   102
    _ERR_CONFIG     = 0x000b00,
120
576bab0a1c5a modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents: 108
diff changeset
   103
    ERR_CONFIG_NAME,        ///< unknown option name
576bab0a1c5a modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents: 108
diff changeset
   104
    ERR_CONFIG_TYPE,        ///< invalid value type for parameter
576bab0a1c5a modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents: 108
diff changeset
   105
    ERR_CONFIG_REQUIRED,    ///< missing value for required parameter
576bab0a1c5a modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents: 108
diff changeset
   106
    ERR_CONFIG_VALUE,       ///< invalid value
576bab0a1c5a modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents: 108
diff changeset
   107
    ERR_CONFIG_PARAMS,      ///< invalid number of parameters
93
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   108
    
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   109
    /** lua errors */
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   110
    _ERR_LUA        = 0x000c00,
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   111
    ERR_LUA_MEM,
42ade8285570 add some rudimentary lua support, by having a simple interactive console, and providing access to irc_client_quit
Tero Marttila <terom@fixme.fi>
parents: 87
diff changeset
   112
    ERR_LUA_SYNTAX,
98
f357f835f0d5 add irc_client_defaults to apply default values for irc_client_add_net irc_net_info, implement --defaults cmd opt and lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   113
    ERR_LUA_RUN,
f357f835f0d5 add irc_client_defaults to apply default values for irc_client_add_net irc_net_info, implement --defaults cmd opt and lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   114
    ERR_LUA_ERR,
106
f00661136ac2 add nexus_lua_error for unified LUA_ERR* -> ERR_LUA_* mapping, and lua configuration support
Tero Marttila <terom@fixme.fi>
parents: 100
diff changeset
   115
    ERR_LUA_FILE,
83
c8e2dac08207 add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents: 71
diff changeset
   116
97
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
   117
    /** irc_chan errors */
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
   118
    _ERR_IRC_CHAN   = 0x000d00,
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
   119
    ERR_IRC_CHAN_STATE,
d3bc82ee76cb add irc_conn_PRIVMSG/irc_chan_PRIVMSG and lua bindings
Tero Marttila <terom@fixme.fi>
parents: 93
diff changeset
   120
121
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 120
diff changeset
   121
    /** pcre errors */
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 120
diff changeset
   122
    _ERR_PCRE       = 0x000e00,
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 120
diff changeset
   123
    ERR_PCRE_COMPILE,       ///< pcre_compile: <error_msg>
127
94e6c3b4230f implement logwatch_on_line/logwatch_filter_apply, along with irc_*_NOTICE
Tero Marttila <terom@fixme.fi>
parents: 121
diff changeset
   124
    ERR_PCRE_EXEC,          ///< pcre_exec: <error code>
121
4682ebbc5644 implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents: 120
diff changeset
   125
129
361740b82fe5 implement str_format with tests
Tero Marttila <terom@fixme.fi>
parents: 127
diff changeset
   126
    /** str errors */
361740b82fe5 implement str_format with tests
Tero Marttila <terom@fixme.fi>
parents: 127
diff changeset
   127
    _ERR_STR        = 0x000f00,
361740b82fe5 implement str_format with tests
Tero Marttila <terom@fixme.fi>
parents: 127
diff changeset
   128
155
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
   129
    /** Transport errors */
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
   130
    _ERR_TRANSPORT  = 0x001000,
c59d3eaff0fb most of the new transport/sock code compiles, but things are still missing
Tero Marttila <terom@fixme.fi>
parents: 154
diff changeset
   131
63
d399a1d915a3 start reworking option-parsing, but --module/--config is still unimplemented
Tero Marttila <terom@fixme.fi>
parents: 57
diff changeset
   132
    /** General errors */
d399a1d915a3 start reworking option-parsing, but --module/--config is still unimplemented
Tero Marttila <terom@fixme.fi>
parents: 57
diff changeset
   133
    _ERR_GENERAL    = 0xffff00,
156
6534a4ac957b add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents: 155
diff changeset
   134
    ERR_MISC,               ///< general error
6534a4ac957b add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents: 155
diff changeset
   135
    ERR_CMD_OPT,            ///< invalid commandline option
98
f357f835f0d5 add irc_client_defaults to apply default values for irc_client_add_net irc_net_info, implement --defaults cmd opt and lua_client_connect
Tero Marttila <terom@fixme.fi>
parents: 97
diff changeset
   136
    ERR_UNKNOWN,
156
6534a4ac957b add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents: 155
diff changeset
   137
    ERR_DUP_NAME,           ///< duplicate name
6534a4ac957b add transport/sock/line_proto/etc code compiles
Tero Marttila <terom@fixme.fi>
parents: 155
diff changeset
   138
    ERR_EOF,                ///< end of file
164
7847a7c3b678 remove ERR_READ_EOF, add more general errors, add missing _general_error_desc, and have error_name return for SUCCESS
Tero Marttila <terom@fixme.fi>
parents: 156
diff changeset
   139
    ERR_MEM,                ///< memory allocation error
7847a7c3b678 remove ERR_READ_EOF, add more general errors, add missing _general_error_desc, and have error_name return for SUCCESS
Tero Marttila <terom@fixme.fi>
parents: 156
diff changeset
   140
    ERR_NOT_IMPLEMENTED,    ///< function not implemented
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
   141
};
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
   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: 29
diff changeset
   143
/**
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
   144
 * 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
   145
 */
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
   146
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
   147
    /** 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
   148
    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
   149
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
   150
    /** 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
   151
    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
   152
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
   153
    /** 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
   154
    enum error_extra_types extra_type;
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
};
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   157
/**
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   158
 * An error code and associated extra infos
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   159
 */
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
struct error_info {
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   161
    /** The base error code */
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   162
    err_t code;
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   163
    
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   164
    union {
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   165
        /** Additional detail info, usually some third-party error code, as defined by the code's ERR_EXTRA_* */
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   166
        int extra;
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   167
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   168
        /** Additional info, stored as a pointer to a static string (note how dangerous this is) */
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   169
        const char *extra_str;
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   170
    };
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   171
};
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   172
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   173
/**
154
f4472119de3b initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents: 143
diff changeset
   174
 * The public names
f4472119de3b initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents: 143
diff changeset
   175
 */
f4472119de3b initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents: 143
diff changeset
   176
typedef struct error_info error_t;
f4472119de3b initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents: 143
diff changeset
   177
f4472119de3b initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents: 143
diff changeset
   178
/**
7
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   179
 * Translate an err_t into a function name.
6
240ae8482d64 add error_name function
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
   180
 */
240ae8482d64 add error_name function
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
   181
const char *error_name (err_t code);
240ae8482d64 add error_name function
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
   182
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   183
/**
7
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   184
 * Maximum length of error messages returned by error_msg (including NUL byte)
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   185
 */
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   186
#define ERROR_MSG_MAXLEN 1024
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   187
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   188
/**
7
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   189
 * Translate an error_info into a message.
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   190
 *
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   191
 * This is returned as a pointer into a statically allocated buffer. It is not re-entrant.
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   192
 */
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
   193
const char *error_msg (const struct error_info *err);
7
844f014409ff and then error_msg
Tero Marttila <terom@fixme.fi>
parents: 6
diff changeset
   194
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   195
/** No error, evaulates as logical false */
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   196
#define SUCCESS (0)
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   197
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   198
/** 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
   199
#define ERROR_CODE(err_info_ptr) ((err_info_ptr)->code)
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   200
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   201
/** 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
   202
#define ERROR_EXTRA(err_info_ptr) ((err_info_ptr)->extra)
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   203
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   204
/** 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
   205
#define RESET_ERROR(err_info_ptr) ((err_info_ptr)->code = SUCCESS)
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   206
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   207
/** 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
   208
#define IS_ERROR(err_info_ptr) (!!(err_info_ptr)->code)
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   209
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   210
/** 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
   211
#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
   212
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   213
/** 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
   214
#define SET_ERROR(err_info_ptr, err_code) ((err_info_ptr)->code = (err_code))
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   215
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   216
/** 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
   217
#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
   218
#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
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   219
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   220
/** 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
   221
#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
   222
#define SET_ERROR_ERRNO(err_info_ptr, err_code) SET_ERROR_EXTRA(err_info_ptr, err_code, errno);
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   223
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   224
/** 
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   225
 * Set error_info.code to err_code, and .extra_str to str. The given string pointer should remain valid while the error
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   226
 * is being handled down-stack.
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   227
 */
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   228
#define _SET_ERROR_STR(err_info_ptr, err_code, err_str) (err_info_ptr)->code = (err_code); (err_info_ptr)->extra_str = (err_str)
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   229
#define SET_ERROR_STR(err_info_ptr, err_code, err_str) do { _SET_ERROR_STR(err_info_ptr, err_code, err_str); } while(0)
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   230
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   231
/** Set error_info from another error_info. Evaluates to the new error_info */
5
a09a0797f6f0 ERROR-ify sock_gnutls
Tero Marttila <terom@fixme.fi>
parents: 4
diff changeset
   232
#define SET_ERROR_INFO(err_info_ptr, from_ptr) (*err_info_ptr = *from_ptr)
a09a0797f6f0 ERROR-ify sock_gnutls
Tero Marttila <terom@fixme.fi>
parents: 4
diff changeset
   233
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   234
/** Same as above, but also return err_code from func. XXX: use 'return SET_ERROR...' instead */
5
a09a0797f6f0 ERROR-ify sock_gnutls
Tero Marttila <terom@fixme.fi>
parents: 4
diff changeset
   235
#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
   236
#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
   237
#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
   238
#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)
56
942370000450 compiling, working, but still ugly module code
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
   239
#define RETURN_SET_ERROR_STR(err_info_ptr, err_code, err_str) do { _SET_ERROR_STR(err_info_ptr, err_code, err_str); return (err_code); } while (0)
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   240
34
763f65f9df0c add doxygen.conf, and tweak comments
Tero Marttila <terom@fixme.fi>
parents: 30
diff changeset
   241
/** Same as above, but also do a 'goto error' */
5
a09a0797f6f0 ERROR-ify sock_gnutls
Tero Marttila <terom@fixme.fi>
parents: 4
diff changeset
   242
#define JUMP_SET_ERROR(err_info_ptr, err_code) do { SET_ERROR(err_info_ptr, err_code); goto error; } while (0)
87
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 83
diff changeset
   243
#define JUMP_SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra) do { _SET_ERROR_EXTRA(err_info_ptr, err_code, err_extra); goto error; } while (0)
f0db6ebf18b9 documentation tweaks
Tero Marttila <terom@fixme.fi>
parents: 83
diff changeset
   244
#define JUMP_SET_ERROR_ERRNO(err_info_ptr, err_code) do { _SET_ERROR_ERRNO(err_info_ptr, err_code); goto error; } while (0)
5
a09a0797f6f0 ERROR-ify sock_gnutls
Tero Marttila <terom@fixme.fi>
parents: 4
diff changeset
   245
#define JUMP_SET_ERROR_INFO(err_info_ptr, from_ptr) do { SET_ERROR_INFO(err_info_ptr, from_ptr); goto error; } while (0)
57
ce1accba5fc7 slight cleanup to move module funcs to a 'struct module_funcs'
Tero Marttila <terom@fixme.fi>
parents: 56
diff changeset
   246
#define JUMP_SET_ERROR_STR(err_info_ptr, err_code, err_str) do { _SET_ERROR_STR(err_info_ptr, err_code, err_str); goto error; } while (0)
5
a09a0797f6f0 ERROR-ify sock_gnutls
Tero Marttila <terom@fixme.fi>
parents: 4
diff changeset
   247
100
cfb7776bd6f0 improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents: 98
diff changeset
   248
/**
cfb7776bd6f0 improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents: 98
diff changeset
   249
 * Macro used to mark code segments that should never be executed (e.g. switch-default), kind of like assert
cfb7776bd6f0 improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents: 98
diff changeset
   250
 */
143
1edab39c88a8 implement lua_args_parse
Tero Marttila <terom@fixme.fi>
parents: 132
diff changeset
   251
#include <stdlib.h>
1edab39c88a8 implement lua_args_parse
Tero Marttila <terom@fixme.fi>
parents: 132
diff changeset
   252
#define NOT_REACHED() abort()
100
cfb7776bd6f0 improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents: 98
diff changeset
   253
3
cc94ae754e2a error handling magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   254
#endif