(RarchDB) Some build fixes for XDK 360

This commit is contained in:
twinaphex 2014-12-31 14:37:28 +01:00
parent f2e1641ace
commit 950a5489ec
4 changed files with 43 additions and 20 deletions

View File

@ -20,7 +20,7 @@ void bintree_new(struct bintree *t, bintree_cmp_func cmp, void *ctx)
static struct bintree_node *new_nil_node(struct bintree_node *parent)
{
struct bintree_node *node = calloc(1, sizeof(struct bintree_node));
struct bintree_node *node = (struct bintree_node*)calloc(1, sizeof(struct bintree_node));
if (!node)
return NULL;
node->value = NIL_NODE;

View File

@ -1,7 +1,11 @@
#include "rarchdb.h"
#include <sys/types.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
@ -265,7 +269,7 @@ int rarchdb_read_item(struct rarchdb *db, struct rmsgpack_dom_value *out)
static int node_iter(void *value, void *ctx)
{
struct node_iter_ctx *nictx = ctx;
struct node_iter_ctx *nictx = (struct node_iter_ctx*)ctx;
if (write(nictx->db->fd, value, nictx->idx->key_size + sizeof(uint64_t)) > 0)
return 0;

View File

@ -12,7 +12,11 @@
#include "rmsgpack.h"
#include <stdlib.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <errno.h>
#include <stdint.h>
#include <string.h>
@ -372,7 +376,7 @@ static int read_buff(int fd, size_t size, char** pbuff, uint64_t *len)
if(read_uint(fd, &tmp_len, size) == -1)
return -errno;
*pbuff = calloc(tmp_len + 1, sizeof(char));
*pbuff = (char*)calloc(tmp_len + 1, sizeof(char));
if (read(fd, *pbuff, tmp_len) == -1)
{
free(*pbuff);
@ -449,7 +453,7 @@ int rmsgpack_read(int fd, struct rmsgpack_read_callbacks *callbacks, void *data)
else if (type < MPF_NIL)
{
tmp_len = type - MPF_FIXSTR;
buff = calloc(tmp_len + 1, sizeof(char));
buff = (char*)calloc(tmp_len + 1, sizeof(char));
if (!buff)
return -ENOMEM;
if(read(fd, buff, tmp_len) == -1)
@ -499,7 +503,7 @@ int rmsgpack_read(int fd, struct rmsgpack_read_callbacks *callbacks, void *data)
case 0xcd:
case 0xce:
case 0xcf:
tmp_len = 1<<(type - 0xcc);
tmp_len = 1 << (type - 0xcc);
tmp_uint = 0;
if(read_uint(fd, &tmp_uint, tmp_len) == -1)
return -errno;
@ -511,7 +515,7 @@ int rmsgpack_read(int fd, struct rmsgpack_read_callbacks *callbacks, void *data)
case 0xd1:
case 0xd2:
case 0xd3:
tmp_len = 1<<(type - 0xd0);
tmp_len = 1 << (type - 0xd0);
tmp_int = 0;
if(read_int(fd, &tmp_int, tmp_len) == -1)
return -errno;

View File

@ -35,14 +35,18 @@ static int dom_reader_state_push(struct dom_reader_state *s, struct rmsgpack_dom
static int dom_read_nil(void *data)
{
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v =
(struct rmsgpack_dom_value*)dom_reader_state_pop(dom_state);
v->type = RDT_NULL;
return 0;
}
static int dom_read_bool(int value, void *data)
{
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v =
(struct rmsgpack_dom_value*)dom_reader_state_pop(dom_state);
v->type = RDT_BOOL;
v->bool_ = value;
return 0;
@ -50,7 +54,9 @@ static int dom_read_bool(int value, void *data)
static int dom_read_int(int64_t value, void *data)
{
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v =
(struct rmsgpack_dom_value*)dom_reader_state_pop(dom_state);
v->type = RDT_INT;
v->int_ = value;
return 0;
@ -58,7 +64,9 @@ static int dom_read_int(int64_t value, void *data)
static int dom_read_uint(uint64_t value, void *data)
{
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v =
(struct rmsgpack_dom_value*)dom_reader_state_pop(dom_state);
v->type = RDT_UINT;
v->uint_ = value;
return 0;
@ -66,7 +74,9 @@ static int dom_read_uint(uint64_t value, void *data)
static int dom_read_string(char* value, uint32_t len, void *data)
{
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v =
(struct rmsgpack_dom_value*)dom_reader_state_pop(dom_state);
v->type = RDT_STRING;
v->string.len = len;
v->string.buff = value;
@ -75,18 +85,22 @@ static int dom_read_string(char* value, uint32_t len, void *data)
static int dom_read_bin(void* value, uint32_t len, void *data)
{
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v =
(struct rmsgpack_dom_value*)dom_reader_state_pop(dom_state);
v->type = RDT_BINARY;
v->binary.len = len;
v->binary.buff = value;
v->binary.buff = (char*)value;
return 0;
}
static int dom_read_map_start(uint32_t len, void *data)
{
int i;
struct rmsgpack_dom_pair *items;
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
struct rmsgpack_dom_pair *items = NULL;
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v = dom_reader_state_pop(dom_state);
v->type = RDT_MAP;
v->map.len = len;
v->map.items = NULL;
@ -99,9 +113,9 @@ static int dom_read_map_start(uint32_t len, void *data)
v->map.items = items;
for (i = 0; i < len; i++)
{
if (dom_reader_state_push(data, &items[i].value) < 0)
if (dom_reader_state_push(dom_state, &items[i].value) < 0)
return -ENOMEM;
if (dom_reader_state_push(data, &items[i].key) < 0)
if (dom_reader_state_push(dom_state, &items[i].key) < 0)
return -ENOMEM;
}
return 0;
@ -110,8 +124,9 @@ static int dom_read_map_start(uint32_t len, void *data)
static int dom_read_array_start(uint32_t len, void *data)
{
int i;
struct rmsgpack_dom_value *v = dom_reader_state_pop(data);
struct rmsgpack_dom_value *items;
dom_reader_state *dom_state = (dom_reader_state*)data;
struct rmsgpack_dom_value *v = dom_reader_state_pop(dom_state);
struct rmsgpack_dom_value *items = NULL;
v->type = RDT_ARRAY;
v->array.len = len;
v->array.items = NULL;
@ -125,7 +140,7 @@ static int dom_read_array_start(uint32_t len, void *data)
for (i = 0; i < len; i++)
{
if (dom_reader_state_push(data, &items[i]) < 0)
if (dom_reader_state_push(dom_state, &items[i]) < 0)
return -ENOMEM;
}
return 0;