Fix some compiler warnings in strict C89 mode
[apps/low-level-can-service.git] / pb_encode.h
index 95f3483..864a48b 100644 (file)
  * max_size is not checked.
  *
  * Rules for callback:
- * 1) Return false on IO errors. This will cause decoding to abort.
+ * 1) Return false on IO errors. This will cause encoding to abort.
  * 
  * 2) You can use state to store your own data (e.g. buffer pointer).
  * 
- * 3) pb_write will update bytes_written before your callback runs.
+ * 3) pb_write will update bytes_written after your callback runs.
  * 
- * 4) Your callback will be always used with the same pb_ostream_t.
- * There are no substreams when encoding.
+ * 4) Substreams will modify max_size and bytes_written. Don't use them to
+ * calculate any pointers.
  */
 struct _pb_ostream_t
 {
@@ -50,8 +50,10 @@ bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_
 
 bool pb_encode_varint(pb_ostream_t *stream, uint64_t value);
 bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, int field_number);
+/* Encode tag based on LTYPE and field number defined in the field structure. */
 bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_t *field);
-bool pb_encode_string(pb_ostream_t *stream, uint8_t *buffer, size_t size);
+/* Write length as varint and then the contents of buffer. */
+bool pb_encode_string(pb_ostream_t *stream, const uint8_t *buffer, size_t size);
 
 /* --- Field encoders ---
  * Each encoder writes the content for the field.
@@ -60,7 +62,8 @@ bool pb_encode_string(pb_ostream_t *stream, uint8_t *buffer, size_t size);
 
 bool pb_enc_varint(pb_ostream_t *stream, const pb_field_t *field, const void *src);
 bool pb_enc_svarint(pb_ostream_t *stream, const pb_field_t *field, const void *src);
-bool pb_enc_fixed(pb_ostream_t *stream, const pb_field_t *field, const void *src);
+bool pb_enc_fixed32(pb_ostream_t *stream, const pb_field_t *field, const void *src);
+bool pb_enc_fixed64(pb_ostream_t *stream, const pb_field_t *field, const void *src);
 
 bool pb_enc_bytes(pb_ostream_t *stream, const pb_field_t *field, const void *src);
 bool pb_enc_string(pb_ostream_t *stream, const pb_field_t *field, const void *src);