From 33a68acb14759cb6fcf796b41ad001c93de4b8e4 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 26 Sep 2009 11:46:38 -0700 Subject: Use a status object for errors so a message can be returned. Also delay deletion of subfields until the entire message is deleted. --- src/upb.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/upb.c') diff --git a/src/upb.c b/src/upb.c index e82a8e4..e58d272 100644 --- a/src/upb.c +++ b/src/upb.c @@ -5,6 +5,7 @@ * */ +#include #include #include "upb.h" @@ -35,3 +36,14 @@ struct upb_type_info upb_type_info[] = { TYPE_INFO(BYTES, UPB_WIRE_TYPE_DELIMITED, struct upb_string*) }; +void upb_seterr(struct upb_status *status, enum upb_status_code code, + const char *msg, ...) +{ + if(upb_ok(status)) { // The first error is the most interesting. + status->code = code; + va_list args; + va_start(args, msg); + vsnprintf(status->msg, UPB_ERRORMSG_MAXLEN, msg, args); + va_end(args); + } +} -- cgit v1.2.3