1 /* A very simple encoding test case using person.proto.
2 * Just puts constant data in the fields and encodes into
3 * buffer, which is then written to stdout.
12 /* Initialize the structure with constants */
13 Person person = {"Test Person 99", 99, true, "test@person.com",
14 3, {{"555-12345678", true, Person_PhoneType_MOBILE},
15 {"99-2342", false, 0},
16 {"1234-5678", true, Person_PhoneType_WORK},
20 pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
22 /* Now encode it and check if we succeeded. */
23 if (pb_encode(&stream, Person_fields, &person))
25 fwrite(buffer, 1, stream.bytes_written, stdout);
26 return 0; /* Success */
30 return 1; /* Failure */