Skip to content

Commit 9f3a5b3

Browse files
committed
Initial import
0 parents  commit 9f3a5b3

15 files changed

+4974
-0
lines changed

Diff for: .gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*~
2+
*.o
3+
*.so*
4+
*.dynlib*
5+
*.user
6+
*.cbp
7+
CMakeFiles/
8+
CMakeCache.txt
9+
cmake_install.cmake
10+
Makefile
11+
build/

Diff for: .travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: c
2+
compiler:
3+
- clang
4+
- gcc
5+
6+
script:
7+
- mkdir ./build && cd ./build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebugInfo
8+
- make
9+
- make test
10+
11+
notifications:
12+
irc: false
13+
email:
14+

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Roman Tsisyk <[email protected]> - initial author

Diff for: CMakeLists.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
project(msgpuck)
2+
cmake_minimum_required(VERSION 2.6)
3+
4+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
5+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -pg -Wall -Wextra")
6+
7+
if(NOT CMAKE_BUILD_TYPE)
8+
set(CMAKE_BUILD_TYPE RelWithDebugInfo CACHE STRING
9+
"Build type, options are: Debug Release." FORCE)
10+
endif()
11+
12+
add_subdirectory(test)
13+
add_library(${PROJECT_NAME} SHARED msgpuck.c)
14+
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 0.1 SOVERSION 0)
15+
16+
if (NOT CMAKE_INSTALL_LIBDIR)
17+
set(CMAKE_INSTALL_LIBDIR lib)
18+
endif()
19+
20+
install(FILES msgpuck.h DESTINATION include)
21+
install(TARGETS ${PROJECT_NAME}
22+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
23+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
24+
COMPONENT library)
25+
26+
add_custom_target(doc
27+
COMMAND doxygen ${PROJECT_SOURCE_DIR}/Doxyfile)

Diff for: Doxyfile

+1,792
Large diffs are not rendered by default.

Diff for: LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright (c) 2013 MsgPuck Authors
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or
5+
without modification, are permitted provided that the following
6+
conditions are met:
7+
8+
1. Redistributions of source code must retain the above
9+
copyright notice, this list of conditions and the
10+
following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above
13+
copyright notice, this list of conditions and the following
14+
disclaimer in the documentation and/or other materials
15+
provided with the distribution.
16+
17+
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21+
<COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28+
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29+
SUCH DAMAGE.

Diff for: README.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
MsgPuck
2+
=======
3+
4+
MsgPuck is a simple and efficient [MsgPack](http://msgpack.org) binary
5+
serialization library in a self-contained header file.
6+
7+
* Can be easily incorporated into your project
8+
* Is very easy to use (see examples below)
9+
* Is fully tested and documented
10+
* Has clean and readable C source code
11+
* Is published under the very liberal license (BSD-2)
12+
13+
Status
14+
------
15+
16+
MsgPuck is in beta stage.
17+
Latest MsgPack specification (2013-09) is supported.
18+
19+
The library is fully documented and covered by unit tests.
20+
21+
[![Build Status](https://travis-ci.org/rtsisyk/msgpuck.png)]
22+
(https://travis-ci.org/rtsisyk/msgpuck)
23+
24+
Examples
25+
--------
26+
27+
**Encoding:**
28+
29+
char buf[1024];
30+
31+
char *w = buf;
32+
w = mp_encode_array(w, 4)
33+
w = mp_encode_uint(w, 10);
34+
w = mp_encode_str(w, "hello world", strlen("hello world"));
35+
w = mp_encode_bool(w, true);
36+
w = mp_encode_double(w, 3.1415);
37+
38+
**Validating:**
39+
40+
const char *b = buf;
41+
bool is_valid = mp_check(&b);
42+
assert(is_valid);
43+
assert(b == w);
44+
45+
**Decoding:**
46+
47+
uint32_t size;
48+
uint64_t ival;
49+
const char *sval;
50+
uint32_t sval_len;
51+
bool bval;
52+
double dval;
53+
54+
const char *r = buf;
55+
size = mp_decode_array(&r);
56+
/* size is 4 */
57+
58+
ival = mp_decode_uint(&r);
59+
/* ival is 10; */
60+
61+
sval = mp_decode_str(&r, &sval_len);
62+
/* sval is "hello world", sval_len is strlen("hello world") */
63+
64+
bval = mp_decode_bool(&r);
65+
/* bval is true */
66+
67+
dval = mp_decode_double(&r);
68+
/* dval is 3.1415 */
69+
70+
assert(r == w);
71+
72+
Installation
73+
------------
74+
75+
You need a C99 or C++03 compatible compiler to use the header.
76+
77+
### Just use the header
78+
79+
Add this project as a git submodule or just copy `msgpuck.h` to your project.
80+
Include `msgpuck.h` as usual and define `MP_SOURCE 1` exactly in a single
81+
compilation unit (`*.c` or `*.cc` file):
82+
83+
#define MP_SOURCE 1 /* define in a single .c/.cc file */
84+
#include "msgpuck.h"
85+
86+
All non-inline versions of functions and global lookup tables will be
87+
stored in the file. `MP_SOURCE` must be defined exactly in a single compilation
88+
unit in you application, otherwise linker errors occur.
89+
90+
### Compile as a shared library
91+
92+
You can also compile and install MsgPuck as a system-wide shared library:
93+
94+
cmake .
95+
make
96+
make test
97+
make install
98+
99+
Include `msgpuck.h` and link your application with `-lmsgpuck`.
100+
101+
Documentation
102+
-------------
103+
104+
* [API Documentation](http://rtsisyk.github.io/msgpuck/)
105+
* [Specification](https://github.com/msgpack/msgpack/blob/master/spec.md)
106+
107+
API documentation can be also generated using `make doc` (Doxygen is required).
108+
109+
Contacts
110+
--------
111+
112+
MsgPuck was written to use within [Tarantool](http://tarantool.org) -
113+
the world's first full-featured MsgPack-based database.
114+
115+

Diff for: doc/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
man
2+
html

Diff for: msgpuck.c

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2013 MsgPuck Authors
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or
6+
* without modification, are permitted provided that the following
7+
* conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above
10+
* copyright notice, this list of conditions and the
11+
* following disclaimer.
12+
*
13+
* 2. Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials
16+
* provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22+
* <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26+
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29+
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30+
* SUCH DAMAGE.
31+
*/
32+
33+
#define MP_SOURCE 1
34+
#include "msgpuck.h"

0 commit comments

Comments
 (0)