1 /* Test decoding of extension fields. */
7 #include "alltypes.pb.h"
8 #include "extensions.pb.h"
10 int main(int argc, char **argv)
13 size_t count = fread(buffer, 1, sizeof(buffer), stdin);
14 pb_istream_t stream = pb_istream_from_buffer(buffer, count);
16 AllTypes alltypes = {};
17 int32_t extensionfield1;
18 pb_extension_t ext1 = {&AllTypes_extensionfield1, &extensionfield1, NULL};
19 alltypes.extensions = &ext1;
21 if (!pb_decode(&stream, AllTypes_fields, &alltypes))
23 printf("Parsing failed: %s\n", PB_GET_ERROR(&stream));
27 if (extensionfield1 != 12345)
29 printf("Wrong value for extension field: %d\n", extensionfield1);