- /* Read the data into buffer */
- SET_BINARY_MODE(stdin);
- count = fread(buffer, 1, sizeof(buffer), stdin);
+#ifdef HAVE_MALLINFO
+ /* Dynamic library loader etc. may have some malloc()ed memory also. */
+ {
+ struct mallinfo m = mallinfo();
+ orig_allocations = m.uordblks;
+ }
+#endif
+
+ {
+ uint8_t buffer[1024];
+ size_t count;
+ pb_istream_t stream;
+
+ /* Whether to expect the optional values or the default values. */
+ int mode = (argc > 1) ? atoi(argv[1]) : 0;
+
+ /* Read the data into buffer */
+ SET_BINARY_MODE(stdin);
+ count = fread(buffer, 1, sizeof(buffer), stdin);
+
+ /* Construct a pb_istream_t for reading from the buffer */
+ stream = pb_istream_from_buffer(buffer, count);
+
+ /* Decode and verify the message */
+ status = check_alltypes(&stream, mode);
+
+ if (!status)
+ fprintf(stderr, "Parsing failed: %s\n", PB_GET_ERROR(&stream));
+ }