diff options
| author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-18 12:16:53 -0300 |
|---|---|---|
| committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-06-18 12:16:53 -0300 |
| commit | 090870ca047dee8d136f863ba742922fc265d6f4 (patch) | |
| tree | 28b5852d5c6ed9ebc415209d9c42bafa651b53b3 /src/nvim/os/msgpack_rpc.h | |
| parent | d199d18159c624844c9c8052d1a98b91084fb803 (diff) | |
| parent | a7d027c8ab289d76eda91b6afe3be63a165d4adf (diff) | |
| download | rneovim-090870ca047dee8d136f863ba742922fc265d6f4.tar.gz rneovim-090870ca047dee8d136f863ba742922fc265d6f4.tar.bz2 rneovim-090870ca047dee8d136f863ba742922fc265d6f4.zip | |
Merge PR #853
Diffstat (limited to 'src/nvim/os/msgpack_rpc.h')
| -rw-r--r-- | src/nvim/os/msgpack_rpc.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nvim/os/msgpack_rpc.h b/src/nvim/os/msgpack_rpc.h index c8f243e2cf..baabff20aa 100644 --- a/src/nvim/os/msgpack_rpc.h +++ b/src/nvim/os/msgpack_rpc.h @@ -9,6 +9,12 @@ #include "nvim/func_attr.h" #include "nvim/api/private/defs.h" +typedef enum { + kUnpackResultOk, /// Successfully parsed a document + kUnpackResultFail, /// Got unexpected input + kUnpackResultNeedMore /// Need more data +} UnpackResult; + /// Validates the basic structure of the msgpack-rpc call and fills `res` /// with the basic response structure. /// @@ -40,6 +46,19 @@ void msgpack_rpc_dispatch(uint64_t id, msgpack_packer *res) FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_NONNULL_ARG(3); +/// Try to unpack a msgpack document from the data in the unpacker buffer. This +/// function is a replacement to msgpack.h `msgpack_unpack_next` that lets +/// the called know if the unpacking failed due to bad input or due to missing +/// data. +/// +/// @param unpacker The unpacker containing the parse buffer +/// @param result The result which will contain the parsed object +/// @return kUnpackResultOk : An object was parsed +/// kUnpackResultFail : Got bad input +/// kUnpackResultNeedMore: Need more data +UnpackResult msgpack_rpc_unpack(msgpack_unpacker* unpacker, + msgpack_unpacked* result); + /// Finishes the msgpack-rpc call with an error message. /// /// @param msg The error message |
