summaryrefslogtreecommitdiff
path: root/src/upb.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-09-26 11:46:38 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-09-26 11:46:38 -0700
commit33a68acb14759cb6fcf796b41ad001c93de4b8e4 (patch)
treef03543b04c0e5b7ce7f2650ff1330919d4d6e055 /src/upb.c
parent4b47002198f2c0404e16d2f02786845d6d3a0d3b (diff)
Use a status object for errors so a message can be returned.
Also delay deletion of subfields until the entire message is deleted.
Diffstat (limited to 'src/upb.c')
-rw-r--r--src/upb.c12
1 files changed, 12 insertions, 0 deletions
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 <stdarg.h>
#include <stddef.h>
#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);
+ }
+}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback