summaryrefslogtreecommitdiff
path: root/src/upb_parse.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/upb_parse.h')
-rw-r--r--src/upb_parse.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/upb_parse.h b/src/upb_parse.h
index e727c11..f0ec5e2 100644
--- a/src/upb_parse.h
+++ b/src/upb_parse.h
@@ -208,6 +208,38 @@ INLINE upb_status_t upb_get_f_uint64_t(uint8_t *buf, uint8_t *end,
return UPB_STATUS_OK;
}
+INLINE upb_status_t upb_skip_v_uint64_t(uint8_t *buf, uint8_t *end,
+ uint8_t **outbuf)
+{
+ uint8_t *const maxend = buf + 10;
+ uint8_t last = 0x80;
+ for(; buf < (uint8_t*)end && (last & 0x80); buf++)
+ last = *buf;
+ if(buf >= end && buf <= maxend && (last & 0x80)) return UPB_STATUS_NEED_MORE_DATA;
+ if(buf > maxend) return UPB_ERROR_UNTERMINATED_VARINT;
+ *outbuf = buf;
+ return UPB_STATUS_OK;
+}
+
+INLINE upb_status_t upb_skip_f_uint32_t(uint8_t *buf, uint8_t *end, uint8_t
+ **outbuf)
+{
+ uint8_t *uint32_end = buf + sizeof(uint32_t);
+ if(uint32_end > end) return UPB_STATUS_NEED_MORE_DATA;
+ *outbuf = uint32_end;
+ return UPB_STATUS_OK;
+}
+
+INLINE upb_status_t upb_skip_f_uint64_t(uint8_t *buf, uint8_t *end, uint8_t
+ **outbuf)
+{
+ uint8_t *uint64_end = buf + sizeof(uint64_t);
+ if(uint64_end > end) return UPB_STATUS_NEED_MORE_DATA;
+ *outbuf = uint64_end;
+ return UPB_STATUS_OK;
+}
+
+
/* Functions to read .proto values. *******************************************/
/* These functions read the appropriate wire value for a given .proto type
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback