Last active
December 29, 2015 23:39
-
-
Save choplin/7744006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msgpack.h> | |
int main() | |
{ | |
msgpack_sbuffer sbuf; | |
msgpack_sbuffer_init(&sbuf); | |
msgpack_packer pk; | |
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write); | |
msgpack_pack_array(&pk, 3); | |
msgpack_pack_int(&pk, 1); | |
msgpack_pack_true(&pk); | |
msgpack_pack_raw(&pk, 7); | |
msgpack_pack_raw_body(&pk, "example", 7); | |
size_t size = sbuf.size; | |
char *msg = msgpack_sbuffer_release(&sbuf); | |
msgpack_pack_array(&pk, 3); | |
msgpack_pack_int(&pk, 1); | |
/* put binary into buffer directly */ | |
msgpack_sbuffer_write(&sbuf, msg, size); | |
msgpack_pack_true(&pk); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment