#include <stdio.h>
#include <pb_decode.h>
#include "person.pb.h"
+#include "test_helpers.h"
/* This function is called once from main(), it handles
the decoding and printing. */
bool print_person(pb_istream_t *stream)
{
int i;
- Person person;
+ Person person = Person_init_zero;
if (!pb_decode(stream, Person_fields, &person))
return false;
int main()
{
+ uint8_t buffer[Person_size];
+ pb_istream_t stream;
+ size_t count;
+
/* Read the data into buffer */
- uint8_t buffer[512];
- size_t count = fread(buffer, 1, sizeof(buffer), stdin);
+ SET_BINARY_MODE(stdin);
+ count = fread(buffer, 1, sizeof(buffer), stdin);
if (!feof(stdin))
{
}
/* Construct a pb_istream_t for reading from the buffer */
- pb_istream_t stream = pb_istream_from_buffer(buffer, count);
+ stream = pb_istream_from_buffer(buffer, count);
/* Decode and print out the stuff */
if (!print_person(&stream))