Added byte stream dump.

This commit is contained in:
Takatoshi Kondo
2015-08-13 13:23:23 +09:00
parent efc27e8eb4
commit 5da1abb1ce

View File

@@ -1,6 +1,14 @@
#include <msgpack.h> #include <msgpack.h>
#include <stdio.h> #include <stdio.h>
void print(char const* buf, unsigned int len)
{
size_t i = 0;
for(; i < len ; ++i)
printf("%02x ", 0xff & buf[i]);
printf("\n");
}
int main(void) int main(void)
{ {
msgpack_sbuffer sbuf; msgpack_sbuffer sbuf;
@@ -20,6 +28,8 @@ int main(void)
msgpack_pack_str(&pk, 7); msgpack_pack_str(&pk, 7);
msgpack_pack_str_body(&pk, "example", 7); msgpack_pack_str_body(&pk, "example", 7);
print(sbuf.data, sbuf.size);
/* deserialize the buffer into msgpack_object instance. */ /* deserialize the buffer into msgpack_object instance. */
/* deserialized object is valid during the msgpack_zone instance alive. */ /* deserialized object is valid during the msgpack_zone instance alive. */
msgpack_zone_init(&mempool, 2048); msgpack_zone_init(&mempool, 2048);
@@ -35,4 +45,3 @@ int main(void)
return 0; return 0;
} }