15 Person person = Person_init_zero;
17 if (!
pb_decode(stream, Person_fields, &person))
22 printf(
"name: \"%s\"\n", person.name);
23 printf(
"id: %ld\n", (
long)person.id);
26 printf(
"email: \"%s\"\n", person.email);
28 for (i = 0; i < person.phone_count; i++)
30 Person_PhoneNumber *phone = &person.phone[i];
32 printf(
" number: \"%s\"\n", phone->number);
38 case Person_PhoneType_WORK:
39 printf(
" type: WORK\n");
42 case Person_PhoneType_HOME:
43 printf(
" type: HOME\n");
46 case Person_PhoneType_MOBILE:
47 printf(
" type: MOBILE\n");
61 size_t len =
fread(buf, 1, count, file);
69 stream->bytes_left = 0;
bool callback(pb_istream_t *stream, uint8_t *buf, size_t count)
bool print_person(pb_istream_t *stream)
size_t fread(void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream)
#define PB_GET_ERROR(stream)
bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct)
#define SET_BINARY_MODE(file)