Files
nanopb/tests/test_encode1.c
Petteri Aimonen 9cb63dd266 wrong file name
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@967 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-24 12:13:24 +00:00

22 lines
525 B
C

#include <stdio.h>
#include <pb_encode.h>
#include "person.pb.h"
bool streamcallback(pb_ostream_t *stream, const uint8_t *buf, size_t count)
{
FILE *file = (FILE*) stream->state;
return fwrite(buf, 1, count, file) == count;
}
int main()
{
Person person = {"Test Person 99", 99, true, "test@person.com",
1, {{"555-12345678", true, Person_PhoneType_MOBILE}}};
pb_ostream_t stream = {&streamcallback, stdout, SIZE_MAX, 0};
pb_encode(&stream, Person_fields, &person);
return 0;
}