3 #include "libradsec-impl.h"
5 const char *_errtxt[] = {
6 "SUCCESS", /* 0 RSE_OK */
7 "NOMEM", /* 1 RSE_NOMEM */
8 "NYI -- not yet implemented", /* 2 RSE_NOSYS */
9 "invalid handle" /* 3 RSE_INVALID_CTX */
10 "invalid connection" /* 4 RSE_INVALID_CONN */
27 "some error" /* 21 RSE_SOME_ERROR */
30 static struct rs_error *
31 _err_new (unsigned int code, const char *msg)
35 err = malloc (sizeof (struct rs_error));
38 memset (err, 0, sizeof (struct rs_error));
40 snprintf (err->buf, sizeof (err->buf), "%s: %s",
41 code < sizeof (_errtxt) / sizeof (*_errtxt) ?
42 _errtxt[code] : "invalid error index",
49 rs_ctx_err_push (struct rs_handle *ctx, int code, const char *msg)
51 struct rs_error *err = _err_new (code, msg);
59 rs_conn_err_push (struct rs_connection *conn, int code, const char *msg)
61 struct rs_error *err = _err_new (code, msg);
69 rs_ctx_err_pop (struct rs_handle *ctx)
74 return NULL; /* FIXME: RSE_INVALID_CTX. */
81 rs_conn_err_pop (struct rs_connection *conn)
86 return NULL; /* FIXME: RSE_INVALID_CONN */
93 rs_err_free (struct rs_error *err)
102 rs_err_msg (struct rs_error *err)
109 msg = strdup (err->buf);
116 rs_err_code (struct rs_error *err)
118 int code = err->code;