From fba1c7d1a6418221a94965d0431bf7df0a9a74a0 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Wed, 15 May 2013 14:20:52 +0200 Subject: WIP commit moving towards working server support. --- lib/err.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lib/err.c') diff --git a/lib/err.c b/lib/err.c index 413ab3e..a0fe8a0 100644 --- a/lib/err.c +++ b/lib/err.c @@ -121,6 +121,7 @@ _ctx_err_vpush_fl (struct rs_context *ctx, int code, const char *file, return RSE_NOMEM; /* TODO: Implement a stack. */ + assert (ctx); if (ctx->err) rs_err_free (ctx->err); ctx->err = err; @@ -158,11 +159,12 @@ rs_err_ctx_push_fl (struct rs_context *ctx, int code, const char *file, int err_connbase_push_err (struct rs_conn_base *connbase, struct rs_error *err) { - + assert (connbase); if (connbase->err) rs_err_free (connbase->err); connbase->err = err; /* FIXME: use a stack */ + assert (err); return err->code; } @@ -185,6 +187,7 @@ rs_err_connbase_push (struct rs_conn_base *connbase, int code, { int r = 0; + assert (connbase); va_list args; va_start (args, fmt); r = _connbase_err_vpush_fl (connbase, code, NULL, 0, fmt, args); @@ -198,6 +201,7 @@ rs_err_conn_push (struct rs_connection *conn, int code, const char *fmt, ...) { int r = 0; + assert (conn); va_list args; va_start (args, fmt); r = _connbase_err_vpush_fl (TO_BASE_CONN (conn), code, NULL, 0, fmt, args); @@ -249,18 +253,30 @@ rs_err_ctx_pop (struct rs_context *ctx) } struct rs_error * -rs_err_conn_pop (struct rs_connection *conn) +rs_err_connbase_pop (struct rs_conn_base *connbase) { struct rs_error *err; - if (!conn) + if (!connbase) return NULL; /* FIXME: RSE_INVALID_CONN */ - err = conn->base_.err; - conn->base_.err = NULL; + err = connbase->err; + connbase->err = NULL; return err; } +struct rs_error * +rs_err_conn_pop (struct rs_connection *conn) +{ + return rs_err_connbase_pop (TO_BASE_CONN (conn)); +} + +struct rs_error * +rs_err_listener_pop (struct rs_listener *l) +{ + return rs_err_connbase_pop (TO_BASE_CONN (l)); +} + int rs_err_conn_peek_code (struct rs_connection *conn) { -- cgit v1.1