mirror of
https://github.com/ivabus/pantry
synced 2024-11-10 02:25:18 +03:00
msgpack.org (#2333)
This commit is contained in:
parent
ddb00b3d20
commit
79bb350d63
39
projects/msgpack.org/package.yml
Normal file
39
projects/msgpack.org/package.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
distributable:
|
||||
url: https://github.com/msgpack/msgpack-c/releases/download/c-{{version}}/msgpack-c-{{version}}.tar.gz
|
||||
strip-components: 1
|
||||
|
||||
versions:
|
||||
github: msgpack/msgpack-c
|
||||
strip: /^cpp-/
|
||||
|
||||
build:
|
||||
dependencies:
|
||||
tea.xyz/gx/cc: c99
|
||||
tea.xyz/gx/make: '*'
|
||||
cmake.org: '*'
|
||||
google.com/googletest: '*'
|
||||
|
||||
script:
|
||||
- cmake -S . -B build $ARGS
|
||||
- cmake --build build
|
||||
- cmake --install build
|
||||
env:
|
||||
ARGS:
|
||||
- -DMSGPACK_BUILD_TESTS=OFF
|
||||
- -DCMAKE_INSTALL_PREFIX={{prefix}}
|
||||
- -DCMAKE_INSTALL_LIBDIR=lib
|
||||
- -DCMAKE_BUILD_TYPE=Release
|
||||
- -DCMAKE_FIND_FRAMEWORK=LAST
|
||||
- -DCMAKE_VERBOSE_MAKEFILE=ON
|
||||
- -Wno-dev
|
||||
- -DBUILD_TESTING=OFF
|
||||
|
||||
test:
|
||||
dependencies:
|
||||
tea.xyz/gx/cc: c99
|
||||
freedesktop.org/pkg-config: '*'
|
||||
script:
|
||||
- cc test.c -lmsgpack-c -o test
|
||||
- ./test
|
||||
- pkg-config --modversion msgpack-c | grep {{version}}
|
||||
|
29
projects/msgpack.org/test.c
Normal file
29
projects/msgpack.org/test.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <msgpack.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
msgpack_sbuffer* buffer = msgpack_sbuffer_new();
|
||||
msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write);
|
||||
msgpack_pack_int(pk, 1);
|
||||
msgpack_pack_int(pk, 2);
|
||||
msgpack_pack_int(pk, 3);
|
||||
|
||||
/* deserializes these objects using msgpack_unpacker. */
|
||||
msgpack_unpacker pac;
|
||||
msgpack_unpacker_init(&pac, MSGPACK_UNPACKER_INIT_BUFFER_SIZE);
|
||||
|
||||
/* feeds the buffer. */
|
||||
msgpack_unpacker_reserve_buffer(&pac, buffer->size);
|
||||
memcpy(msgpack_unpacker_buffer(&pac), buffer->data, buffer->size);
|
||||
msgpack_unpacker_buffer_consumed(&pac, buffer->size);
|
||||
|
||||
/* now starts streaming deserialization. */
|
||||
msgpack_unpacked result;
|
||||
msgpack_unpacked_init(&result);
|
||||
|
||||
while(msgpack_unpacker_next(&pac, &result)) {
|
||||
msgpack_object_print(stdout, result.data);
|
||||
puts("");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue