summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-03-01 22:58:38 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-03-01 22:58:38 -0800
commit73ab650ad1968b13abbf1869c4739cfdf2752671 (patch)
tree63858d7e7600dac4640bdef3974bb07f3d59b2fc
parent14624e34d82468773516a4ff3eb3a4d6bc030658 (diff)
Added function for skipping data.
-rw-r--r--pbstream.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/pbstream.c b/pbstream.c
index 2362e5c..a181128 100644
--- a/pbstream.c
+++ b/pbstream.c
@@ -29,8 +29,7 @@
static pbstream_status_t get_v_uint64_t(char **buf, uint64_t *val)
{
- uint8_t* ptr = (uint8_t*)*buf;
- uint32_t b;
+ uint8_t *ptr = (uint8_t*)*buf, b;
uint32_t part0 = 0, part1 = 0, part2 = 0;
/* From the original proto2 implementation. */
@@ -52,10 +51,29 @@ done:
return PBSTREAM_STATUS_OK;
}
+static pbstream_status_t skip_v_uint64_t(char **buf)
+{
+ uint8_t *ptr = (uint8_t*)*buf, b;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ return PBSTREAM_ERROR_UNTERMINATED_VARINT;
+
+done:
+ *buf = (char*)ptr;
+ return PBSTREAM_STATUS_OK;
+}
+
static pbstream_status_t get_v_uint32_t(char **buf, uint32_t *val)
{
- uint8_t* ptr = (uint8_t*)*buf;
- uint32_t b;
+ uint8_t *ptr = (uint8_t*)*buf, b;
uint32_t result;
/* From the original proto2 implementation. */
@@ -72,6 +90,21 @@ done:
return PBSTREAM_STATUS_OK;
}
+static pbstream_status_t skip_v_uint32_t(char **buf)
+{
+ uint8_t *ptr = (uint8_t*)*buf, b;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ b = *(ptr++); if (!(b & 0x80)) goto done;
+ return PBSTREAM_ERROR_UNTERMINATED_VARINT;
+
+done:
+ *buf = (char*)ptr;
+ return PBSTREAM_STATUS_OK;
+}
+
static pbstream_status_t get_f_uint32_t(char **buf, uint32_t *val)
{
uint8_t *b = (uint8_t*)*buf;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback