Create a message descriptor type.

This replaces the sentinel at the end of the pb_field_t
array for each message type.

git-svn-id: https://svn.kapsi.fi/jpa/nanopb-dev@1007 e3a754e5-d11d-0410-8d38-ebb782a927b9
This commit is contained in:
Michael Poole
2011-11-13 18:10:11 +00:00
committed by Petteri Aimonen
parent dcf43a6416
commit 43b8e20744
17 changed files with 127 additions and 101 deletions

View File

@@ -27,7 +27,7 @@ bool printfile_callback(pb_istream_t *stream, const pb_field_t *field, void *arg
{
FileInfo fileinfo;
if (!pb_decode(stream, FileInfo_fields, &fileinfo))
if (!pb_decode(stream, FileInfo_msg, &fileinfo))
return false;
printf("%-10lld %s\n", fileinfo.inode, fileinfo.name);
@@ -59,7 +59,7 @@ bool listdir(int fd, char *path)
strcpy(request.path, path);
}
if (!pb_encode(&output, ListFilesRequest_fields, &request))
if (!pb_encode(&output, ListFilesRequest_msg, &request))
{
fprintf(stderr, "Encoding failed.\n");
return false;
@@ -70,7 +70,7 @@ bool listdir(int fd, char *path)
response.file.funcs.decode = &printfile_callback;
if (!pb_decode(&input, ListFilesResponse_fields, &response))
if (!pb_decode(&input, ListFilesResponse_msg, &response))
{
fprintf(stderr, "Decoding failed.\n");
return false;