summaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-07-06 16:16:00 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-07-06 16:16:00 +0300
commitbb985e99274b537ee662d630b02664a3825d8829 (patch)
treea6cf90d0005d2a1f1a66977a1a4e4901c9eb24a4 /pb_decode.c
parent314460c2a518bdfc4e5dfb87992d907461a7c0e6 (diff)
Add pb_decode_delimited and pb_encode_delimited wrapper functions.
Update issue 74 Status: FixedInGit
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/pb_decode.c b/pb_decode.c
index d0e18ccb..c5336981 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -603,6 +603,19 @@ bool checkreturn pb_decode(pb_istream_t *stream, const pb_field_t fields[], void
return pb_decode_noinit(stream, fields, dest_struct);
}
+bool pb_decode_delimited(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct)
+{
+ pb_istream_t substream;
+ bool status;
+
+ if (!pb_make_string_substream(stream, &substream))
+ return false;
+
+ status = pb_decode(&substream, fields, dest_struct);
+ pb_close_string_substream(stream, &substream);
+ return status;
+}
+
/* Field decoders */
bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest)