Wrapper around `protoc --decode`. Adds support for length-prefixed protobuf messages.
Switch branches/tags
Nothing to show
Clone or download
erikdw add support for --decode_raw option, improve usage output to more clo…
…sely match protoc's usage, and add support for using ntohl to convert the byte-order of the length-prefix header values
Latest commit 97a8200 Feb 20, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Initial commit Feb 13, 2016
README.md initial implementation Feb 14, 2016
protoc-decode-lenprefix add support for --decode_raw option, improve usage output to more clo… Feb 21, 2016

README.md

protoc-decode-lenprefix

Wrapper around protobuf's protoc --decode utility. Adds support for length-prefixed messages.

Usage

cat PROTOBUF_MESSAGE_FILE | \
  protoc-decode-lenprefix -d mesos.internal.StatusUpdateRecord \
    -I MESOS_CODE/src -I MESOS_CODE/include \
    PROTO_FILE \

e.g., say you have a task.updates file generated by Mesos, and say you have downloaded the Mesos source code to the MESOS_CODE dir.

cat task.updates | \
  protoc-decode-lenprefix \
    --decode mesos.internal.StatusUpdateRecord \
    -I MESOS_CODE/src -I MESOS_CODE/include \
    MESOS_CODE/src/messages/messages.proto

This results in all of the StatusUpdateRecord messages in the task.updates input file being written to stdout.

Note how the parameters for protoc-decode-lenprefix are identical to those passed to protoc, assuming you don't have the length-prefix header. e.g., taking a task.info file, we use dd to strip off the 1st 4 bytes and then have protoc decode the embedded message:

dd bs=1 skip=4 if=task.info | \
  protoc \
    --decode=mesos.internal.Task \
    -I MESOS_CODE/src -I MESOS_CODE/include \
    MESOS_CODE/src/messages/messages.proto