aboutsummaryrefslogtreecommitdiff
path: root/elegoo/pb/pb_encode.h
diff options
context:
space:
mode:
Diffstat (limited to 'elegoo/pb/pb_encode.h')
-rw-r--r--elegoo/pb/pb_encode.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/elegoo/pb/pb_encode.h b/elegoo/pb/pb_encode.h
index d9909fb..8bf78dd 100644
--- a/elegoo/pb/pb_encode.h
+++ b/elegoo/pb/pb_encode.h
@@ -71,6 +71,12 @@ bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_
*/
bool pb_encode_delimited(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
+/* Same as pb_encode, but appends a null byte to the message for termination.
+ * NOTE: This behaviour is not supported in most other protobuf implementations, so pb_encode_delimited()
+ * is a better option for compatibility.
+ */
+bool pb_encode_nullterminated(pb_ostream_t *stream, const pb_field_t fields[], const void *src_struct);
+
/* Encode the message to get the size of the encoded data, but do not store
* the data. */
bool pb_get_encoded_size(size_t *size, const pb_field_t fields[], const void *src_struct);
@@ -123,11 +129,19 @@ bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field
/* Encode an integer in the varint format.
* This works for bool, enum, int32, int64, uint32 and uint64 field types. */
+#ifndef PB_WITHOUT_64BIT
bool pb_encode_varint(pb_ostream_t *stream, uint64_t value);
+#else
+bool pb_encode_varint(pb_ostream_t *stream, uint32_t value);
+#endif
/* Encode an integer in the zig-zagged svarint format.
* This works for sint32 and sint64. */
+#ifndef PB_WITHOUT_64BIT
bool pb_encode_svarint(pb_ostream_t *stream, int64_t value);
+#else
+bool pb_encode_svarint(pb_ostream_t *stream, int32_t value);
+#endif
/* Encode a string or bytes type field. For strings, pass strlen(s) as size. */
bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size);
@@ -136,9 +150,11 @@ bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size
* You need to pass a pointer to a 4-byte wide C variable. */
bool pb_encode_fixed32(pb_ostream_t *stream, const void *value);
+#ifndef PB_WITHOUT_64BIT
/* Encode a fixed64, sfixed64 or double value.
* You need to pass a pointer to a 8-byte wide C variable. */
bool pb_encode_fixed64(pb_ostream_t *stream, const void *value);
+#endif
/* Encode a submessage field.
* You need to pass the pb_field_t array and pointer to struct, just like