Please have a look at the following links:
https://groups.google.com/forum/#!topic/protobuf-c/4ZbQwqLvVdw
https://code.google.com/p/protobuf-c/wiki/libprotobuf_c (Virtual Buffers)
Basically ProtobufCBinaryData
is a structure and you can access its fileds as described in the first link. I am also showing a small example below (similar to those on the official wiki https://github.com/protobuf-c/protobuf-c/wiki/Examples).
Your proto file:
message Bmessage {
optional bytes value=1;
}
Now imagine you have recieved such message and want to extract it:
BMessage *msg;
// Read packed message from standard-input.
uint8_t buf[MAX_MSG_SIZE];
size_t msg_len = read_buffer (MAX_MSG_SIZE, buf);
// Unpack the message using protobuf-c.
msg = bmessage__unpack(NULL, msg_len, buf);
if (msg == NULL) {
fprintf(stderr, "error unpacking incoming message\n");
exit(1);
}
// Display field's size and content
if (msg->has_value) {
printf("length of value: %d\n", msg->value.len);
printf("content of value: %s\n", msg->value.data);
}
// Free the unpacked message
bmessage__free_unpacked(msg, NULL);
Hope that helps.