1 /* Copyright (C) 2010-2017 The RetroArch team 2 * 3 * --------------------------------------------------------------------------------------- 4 * The following license statement only applies to this file (rmsgpack.h). 5 * --------------------------------------------------------------------------------------- 6 * 7 * Permission is hereby granted, free of charge, 8 * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation the rights to 10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #ifndef __LIBRETRODB_MSGPACK_H__ 24 #define __LIBRETRODB_MSGPACK_H__ 25 26 #include <stdint.h> 27 28 #include <streams/file_stream.h> 29 30 struct rmsgpack_read_callbacks 31 { 32 int (*read_nil )(void *); 33 int (*read_bool )(int, void *); 34 int (*read_int )(int64_t, void *); 35 int (*read_uint )(uint64_t, void *); 36 int (*read_string )(char *, uint32_t, void *); 37 int (*read_bin )(void *, uint32_t, void *); 38 int (*read_map_start )(uint32_t, void *); 39 int (*read_array_start)(uint32_t, void *); 40 }; 41 42 int rmsgpack_write_array_header(RFILE *fd, uint32_t size); 43 44 int rmsgpack_write_map_header(RFILE *fd, uint32_t size); 45 46 int rmsgpack_write_string(RFILE *fd, const char *s, uint32_t len); 47 48 int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len); 49 50 int rmsgpack_write_nil(RFILE *fd); 51 52 int rmsgpack_write_bool(RFILE *fd, int value); 53 54 int rmsgpack_write_int(RFILE *fd, int64_t value); 55 56 int rmsgpack_write_uint(RFILE *fd, uint64_t value ); 57 58 int rmsgpack_read(RFILE *fd, struct rmsgpack_read_callbacks *callbacks, void *data); 59 60 #endif 61