mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-19 12:22:43 +00:00
Fix android build, update sdb code from git
This commit is contained in:
parent
be247348b5
commit
7fc1614cb5
@ -15,7 +15,6 @@ CFLAGS+=-DR2_GITTIP=\"$(GIT_TIP)\"
|
||||
ifeq ($(WITHNONPIC),1)
|
||||
LDFLAGS+=../../libr/th/libr_th.a
|
||||
LDFLAGS+=../../libr/io/libr_io.a
|
||||
LDFLAGS+=../../libr/socket/libr_socket.a
|
||||
LDFLAGS+=../../libr/asm/libr_asm.a
|
||||
LDFLAGS+=../../libr/db/libr_db.a
|
||||
LDFLAGS+=../../libr/parse/libr_parse.a
|
||||
@ -42,6 +41,7 @@ LDFLAGS+=../../libr/bp/libr_bp.a
|
||||
LDFLAGS+=../../libr/hash/libr_hash.a
|
||||
LDFLAGS+=../../libr/bin/libr_bin.a
|
||||
LDFLAGS+=../../libr/util/libr_util.a
|
||||
LDFLAGS+=../../libr/socket/libr_socket.a
|
||||
# extra libs #
|
||||
LDFLAGS+=../../libr/fs/p/grub/libgrubfs.a
|
||||
LDFLAGS+=../../libr/db/sdb/src/libsdb.a
|
||||
@ -50,6 +50,7 @@ else
|
||||
LDFLAGS+=-L../../libr/th -lr_th
|
||||
LDFLAGS+=-L../../libr/io -lr_io
|
||||
LDFLAGS+=-L../../libr/bp -lr_bp
|
||||
LDFLAGS+=-L../../libr/socket -lr_socket
|
||||
LDFLAGS+=-L../../libr/bin -lr_bin
|
||||
LDFLAGS+=-L../../libr/reg -lr_reg
|
||||
LDFLAGS+=-L../../libr/asm -lr_asm
|
||||
|
@ -21,13 +21,20 @@ EXEXT=
|
||||
|
||||
BIN=sdb${EXEXT}
|
||||
|
||||
.PHONY: all static shared clean wcl syms
|
||||
.PHONY: all static shared clean
|
||||
|
||||
all: static shared ${BIN}
|
||||
all: ${BIN}
|
||||
${MAKE} static
|
||||
${MAKE} shared
|
||||
|
||||
shared: libsdb.${SOEXT}
|
||||
sdb-version.h:
|
||||
cd .. ; ${MAKE} src/sdb-version.h
|
||||
|
||||
static: libsdb.a
|
||||
shared: sdb-version.h
|
||||
${MAKE} libsdb.${SOEXT}
|
||||
|
||||
static: sdb-version.h
|
||||
${MAKE} libsdb.a
|
||||
|
||||
libsdb.a: ${OBJ}
|
||||
@#ar qf libasb.a ${OBJ}
|
||||
@ -52,20 +59,10 @@ test:
|
||||
valgrind ./sdb foo a=3 b=4
|
||||
valgrind ./sdb foo a=9 b=2
|
||||
|
||||
syms:
|
||||
otool -Vt sdb|grep callq |awk '{print $$3}'|grep -v 0x|sort|uniq > symbols-used
|
||||
otool -Vt sdb| grep ^_ |sed -e s,:,,|sort|uniq > symbols-found
|
||||
diff -ru symbols-found symbols-used | grep ^-
|
||||
rm -f symbols-found symbols-used
|
||||
|
||||
main.c:
|
||||
|
||||
${BIN}: libsdb.a main.c
|
||||
${CC} ${CFLAGS} -o ${BIN} main.c ${OBJ}
|
||||
#libsdb.a
|
||||
|
||||
wcl:
|
||||
wc -l `echo ${OBJ}|sed -e 's,\.o,.c,g'`
|
||||
${BIN}: libsdb.a main.o
|
||||
${CC} ${CFLAGS} -o ${BIN} main.o ${OBJ}
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJ} libsdb.a a.out sdb sdb.dSYM *.sdb *.db *.${SOEXT}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* Copyleft 2012 - sdb (aka SimpleDB) - pancake<nopcode.org> */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "sdb.h"
|
||||
#include "json/json.h"
|
||||
|
||||
@ -201,3 +202,89 @@ char *sdb_json_unindent(const char *s) {
|
||||
*o = 0;
|
||||
return O;
|
||||
}
|
||||
|
||||
const char *sdb_json_format(SdbJsonString* s, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
char *arg_s, *x, tmp[128];
|
||||
float arg_f;
|
||||
unsigned long long arg_l;
|
||||
int i, arg_i;
|
||||
|
||||
#define JSONSTR_ALLOCATE(y) \
|
||||
if (s->len+y>s->blen) {\
|
||||
s->blen *= 2;\
|
||||
x = realloc (s->buf, s->blen);\
|
||||
if (!x) return NULL;\
|
||||
s->buf = x;\
|
||||
}
|
||||
if (!s->buf) {
|
||||
s->blen = 1024;
|
||||
s->buf = malloc (s->blen);
|
||||
*s->buf = 0;
|
||||
}
|
||||
if (!fmt || !*fmt) return s->buf;
|
||||
va_start (ap, fmt);
|
||||
for (; *fmt; fmt++) {
|
||||
if (*fmt == '%') {
|
||||
fmt++;
|
||||
switch (*fmt) {
|
||||
case 'b':
|
||||
JSONSTR_ALLOCATE (32);
|
||||
arg_i = va_arg (ap, int);
|
||||
arg_i = arg_i? 4: 5;
|
||||
memcpy (s->buf+s->len, arg_i==4?"true":"false", 5);
|
||||
s->len += arg_i;
|
||||
break;
|
||||
case 'f':
|
||||
JSONSTR_ALLOCATE (32);
|
||||
arg_f = va_arg (ap, int);
|
||||
snprintf (tmp, sizeof (tmp), "%f", arg_f);
|
||||
memcpy (s->buf+s->len, tmp, strlen (tmp));
|
||||
s->len += strlen (tmp);
|
||||
break;
|
||||
case 'l':
|
||||
JSONSTR_ALLOCATE (32);
|
||||
arg_l = va_arg (ap, unsigned long long);
|
||||
snprintf (tmp, sizeof (tmp), "0x%llx", arg_l);
|
||||
memcpy (s->buf+s->len, tmp, strlen (tmp));
|
||||
s->len += strlen (tmp);
|
||||
break;
|
||||
case 'd':
|
||||
case 'i':
|
||||
JSONSTR_ALLOCATE (32);
|
||||
arg_i = va_arg (ap, int);
|
||||
snprintf (tmp, sizeof (tmp), "%d", arg_i);
|
||||
memcpy (s->buf+s->len, tmp, strlen (tmp));
|
||||
s->len += strlen (tmp);
|
||||
break;
|
||||
case 's':
|
||||
arg_s = va_arg (ap, char *);
|
||||
JSONSTR_ALLOCATE (strlen (arg_s)+3);
|
||||
s->buf[s->len++] = '"';
|
||||
for (i=0; arg_s[i]; i++) {
|
||||
if (arg_s[i]=='"')
|
||||
s->buf[s->len++] = '\\';
|
||||
s->buf[s->len++] = arg_s[i];
|
||||
}
|
||||
s->buf[s->len++] = '"';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
JSONSTR_ALLOCATE (10);
|
||||
s->buf[s->len++] = *fmt;
|
||||
}
|
||||
s->buf[s->len] = 0;
|
||||
}
|
||||
va_end (ap);
|
||||
return s->buf;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int main () {
|
||||
SdbJsonString s = {0};
|
||||
sdb_json_format (&s, "[{%s:%d},%b]", "Hello \"world\"", 1024, 3);
|
||||
printf ("%s\n", sdb_json_format (&s, 0));
|
||||
sdb_json_format_free (&s);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -104,6 +104,14 @@ int sdb_json_inc(Sdb *s, const char *k, const char *p, int n, ut32 cas);
|
||||
char *sdb_json_indent(const char *s);
|
||||
char *sdb_json_unindent(const char *s);
|
||||
|
||||
typedef struct {
|
||||
char *buf;
|
||||
int blen;
|
||||
int len;
|
||||
} SdbJsonString;
|
||||
|
||||
const char *sdb_json_format(SdbJsonString* s, const char *fmt, ...);
|
||||
#define sdb_json_format_free(x) free ((x)->buf)
|
||||
|
||||
// namespace
|
||||
Sdb *sdb_ns(Sdb *s, const char *name);
|
||||
|
@ -104,6 +104,14 @@ int sdb_json_inc(Sdb *s, const char *k, const char *p, int n, ut32 cas);
|
||||
char *sdb_json_indent(const char *s);
|
||||
char *sdb_json_unindent(const char *s);
|
||||
|
||||
typedef struct {
|
||||
char *buf;
|
||||
int blen;
|
||||
int len;
|
||||
} SdbJsonString;
|
||||
|
||||
const char *sdb_json_format(SdbJsonString* s, const char *fmt, ...);
|
||||
#define sdb_json_format_free(x) free ((x)->buf)
|
||||
|
||||
// namespace
|
||||
Sdb *sdb_ns(Sdb *s, const char *name);
|
||||
|
@ -61,7 +61,7 @@ R_API void r_socket_http_response (RSocketHTTPRequest *rs, int code, const char
|
||||
if (len<1) len = strlen (out);
|
||||
r_socket_printf (rs->s, "HTTP/1.1 %d %s\n"
|
||||
"Content-Length: %d\n\n", code, strcode, len);
|
||||
r_socket_write (rs->s, out, len);
|
||||
r_socket_write (rs->s, (void*)out, len);
|
||||
}
|
||||
|
||||
/* close client socket and free struct */
|
||||
|
@ -18,7 +18,7 @@ include $(TOP)/config-user.mk
|
||||
|
||||
F_SDB=$(addsuffix .sdb,$F)
|
||||
|
||||
SDB=../../db/sdb/src/sdb
|
||||
SDB=../../db/sdb/sdb
|
||||
|
||||
all: ${SDB}
|
||||
@${MAKE} compile
|
||||
@ -37,7 +37,11 @@ clean:
|
||||
rm -f *.sdb
|
||||
|
||||
${SDB}:
|
||||
cd $(LTOP)/db/sdb/src && ${MAKE} ARCH=xxx
|
||||
cp -rf $(LTOP)/db/sdb/src $(LTOP)/db/sdb/src-native
|
||||
#cd $(LTOP)/db/sdb/src-native && ${MAKE} -j ${MAKE_JOBS} ARCH=xxx CC=gcc clean sdb
|
||||
cd $(LTOP)/db/sdb/src-native && ${MAKE} -j 1 ARCH=xxx CC=gcc clean sdb
|
||||
cp -f $(LTOP)/db/sdb/src-native/sdb $(LTOP)/db/sdb/sdb
|
||||
rm -rf $(LTOP)/db/sdb/src-native
|
||||
|
||||
.PHONY: all clean install install-symlink symstall
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user