diff --git a/binr/blob/Makefile b/binr/blob/Makefile index dd5aa716da..a09682fa95 100644 --- a/binr/blob/Makefile +++ b/binr/blob/Makefile @@ -29,7 +29,6 @@ CFLAGS=-I../../libr/include/ ifeq ($(WITHNONPIC),1) LDFLAGS+=../../libr/io/libr_io.a LDFLAGS+=../../libr/asm/libr_asm.a -LDFLAGS+=../../libr/db/libr_db.a LDFLAGS+=../../libr/egg/libr_egg.a LDFLAGS+=../../libr/core/libr_core.a LDFLAGS+=../../libr/crypto/libr_crypto.a @@ -66,7 +65,6 @@ LDFLAGS+=-L../../libr/bin -lr_bin LDFLAGS+=-L../../libr/reg -lr_reg LDFLAGS+=-L../../libr/asm -lr_asm LDFLAGS+=-L../../libr/egg -lr_egg -LDFLAGS+=-L../../libr/db -lr_db LDFLAGS+=-L../../libr/core -lr_core LDFLAGS+=-L../../libr/anal -lr_anal LDFLAGS+=-L../../libr/crypto -lr_crypto diff --git a/binr/blob/version.c b/binr/blob/version.c index ed24ad1a6e..717bd52ee0 100644 --- a/binr/blob/version.c +++ b/binr/blob/version.c @@ -1,4 +1,5 @@ -/* copyright 2015 radare2 by pancake */ +/* copyright 2015-2016 radare2 by pancake */ + #include #ifndef R2_GITTAP @@ -18,8 +19,8 @@ static int blob_version(const char *program) { R_SYS_OS"-" R_SYS_ARCH"-%d git.%s\n", program, R2_VERSION_COMMIT, - R_SYS_BITS&8?64:32, - *R2_GITTAP? R2_GITTAP: ""); + (R_SYS_BITS & 8)? 64: 32, + *R2_GITTAP ? R2_GITTAP: ""); if (*R2_GITTIP) { printf ("commit: "R2_GITTIP" build: "R2_BIRTH"\n"); } diff --git a/binr/preload/Makefile b/binr/preload/Makefile index 44ea440d00..139f6cb7d5 100644 --- a/binr/preload/Makefile +++ b/binr/preload/Makefile @@ -2,7 +2,7 @@ BIN=libr2 ISLIB=1 BINDEPS=r_core r_parse r_search r_cons r_config BINDEPS+=r_bin r_debug r_anal r_reg r_bp r_io -BINDEPS+=r_lang r_asm r_syscall r_db r_hash r_crypto +BINDEPS+=r_lang r_asm r_syscall r_hash r_crypto BINDEPS+=r_magic r_socket r_flags r_util r_egg r_fs include ../rules.mk diff --git a/binr/rabin2/Makefile b/binr/rabin2/Makefile index bdc26ebdee..2929e92501 100644 --- a/binr/rabin2/Makefile +++ b/binr/rabin2/Makefile @@ -1,5 +1,5 @@ BIN=rabin2 -BINDEPS=r_magic r_core r_db r_bin r_egg r_cons +BINDEPS=r_magic r_core r_bin r_egg r_cons BINDEPS+=r_config r_io r_flags r_asm BINDEPS+=r_debug r_hash r_lang r_anal r_parse r_bp r_reg BINDEPS+=r_search r_syscall r_socket r_fs r_magic r_crypto r_util diff --git a/binr/radare2/Makefile b/binr/radare2/Makefile index 795fa4b9c6..8fea2208d6 100644 --- a/binr/radare2/Makefile +++ b/binr/radare2/Makefile @@ -1,7 +1,7 @@ BIN=radare2 BINDEPS=r_core r_parse r_search r_cons r_config BINDEPS+=r_bin r_debug r_anal r_reg r_bp r_io r_fs -BINDEPS+=r_lang r_asm r_syscall r_db r_hash +BINDEPS+=r_lang r_asm r_syscall r_hash BINDEPS+=r_magic r_socket r_flags r_egg r_crypto r_util # Apple Sign # diff --git a/binr/radare2/radare2.c b/binr/radare2/radare2.c index b087c8bea5..5c3e01d009 100644 --- a/binr/radare2/radare2.c +++ b/binr/radare2/radare2.c @@ -33,7 +33,6 @@ static int verify_version(int show) { { "r_flags", &r_flag_version }, // XXX inconsistency { "r_core", &r_core_version }, { "r_crypto", &r_crypto_version }, - { "r_db", &r_db_version }, { "r_bp", &r_bp_version }, { "r_debug", &r_debug_version }, { "r_hash", &r_hash_version }, diff --git a/binr/radiff2/Makefile b/binr/radiff2/Makefile index b6bb721686..7843f6533c 100644 --- a/binr/radiff2/Makefile +++ b/binr/radiff2/Makefile @@ -3,7 +3,7 @@ BIN=radiff2 BINDEPS=r_core r_config r_cons r_search r_anal BINDEPS+=r_bin r_debug r_io r_asm r_hash r_fs r_crypto BINDEPS+=r_socket r_flags r_lang r_reg r_bp r_parse -BINDEPS+=r_syscall r_db r_magic r_util r_parse r_egg +BINDEPS+=r_syscall r_magic r_util r_parse r_egg include ../rules.mk diff --git a/binr/rafind2/Makefile b/binr/rafind2/Makefile index a9c91dbbef..e607bb0e26 100644 --- a/binr/rafind2/Makefile +++ b/binr/rafind2/Makefile @@ -1,7 +1,7 @@ BIN=rafind2 BINDEPS=r_search r_io r_asm r_anal r_reg r_cons r_lang -BINDEPS+=r_socket r_db r_parse r_util r_syscall r_flags +BINDEPS+=r_socket r_parse r_util r_syscall r_flags include ../rules.mk diff --git a/binr/ragg2/Makefile b/binr/ragg2/Makefile index d08534e104..3334431fb0 100644 --- a/binr/ragg2/Makefile +++ b/binr/ragg2/Makefile @@ -1,5 +1,5 @@ BIN=ragg2 -BINDEPS=r_egg r_bin r_syscall r_asm r_db +BINDEPS=r_egg r_bin r_syscall r_asm BINDEPS+=r_io r_socket BINDEPS+=r_lang r_parse r_anal r_reg r_flags BINDEPS+=r_magic r_cons r_util diff --git a/binr/rahash2/Makefile b/binr/rahash2/Makefile index 65af800104..7be9152f04 100644 --- a/binr/rahash2/Makefile +++ b/binr/rahash2/Makefile @@ -1,7 +1,7 @@ BIN=rahash2 BINDEPS=r_io r_hash r_socket r_asm r_cons -BINDEPS+=r_anal r_syscall r_reg r_db r_parse +BINDEPS+=r_anal r_syscall r_reg r_parse BINDEPS+=r_flags r_lang r_crypto r_util include ../rules.mk diff --git a/binr/rasm2/Makefile b/binr/rasm2/Makefile index efa9cf50ed..f31a703a95 100644 --- a/binr/rasm2/Makefile +++ b/binr/rasm2/Makefile @@ -1,5 +1,5 @@ BIN=rasm2 BINDEPS=r_asm r_parse r_syscall r_anal r_reg -BINDEPS+=r_db r_flags r_cons r_util r_lang +BINDEPS+=r_flags r_cons r_util r_lang include ../rules.mk diff --git a/libr/Jamroot b/libr/Jamroot index 63553528d2..657c9e4f95 100644 --- a/libr/Jamroot +++ b/libr/Jamroot @@ -5,7 +5,6 @@ build-project hash ; build-project reg ; build-project cons ; -build-project db ; build-project magic ; build-project diff ; build-project bp ; diff --git a/libr/Makefile b/libr/Makefile index 2c4cef1fda..789cb18451 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -12,7 +12,7 @@ PREFIX?=${PWD}/../prefix PWD=$(shell pwd) LIBS0=util hash -LIBS1=socket reg cons db magic bp search config +LIBS1=socket reg cons magic bp search config LIBS2=syscall lang io crypto flags LIBS3=fs anal bin LIBS4=parse diff --git a/libr/anal/Makefile b/libr/anal/Makefile index 17c7d57262..5108f53179 100644 --- a/libr/anal/Makefile +++ b/libr/anal/Makefile @@ -4,7 +4,7 @@ EXTRA_TARGETS+=do EXTRA_CLEAN=doclean NAME=r_anal -DEPS=r_util r_db r_reg r_syscall +DEPS=r_util r_reg r_syscall CFLAGS+=-DCORELIB -Iarch -I$(TOP)/shlr LDFLAGS+=${BN_LIBS} diff --git a/libr/asm/Makefile b/libr/asm/Makefile index 0e63d5a782..6c83fa0601 100644 --- a/libr/asm/Makefile +++ b/libr/asm/Makefile @@ -1,7 +1,7 @@ include ../../global.mk NAME=r_asm -DEPS=r_db r_syscall r_lang r_util r_parse +DEPS=r_syscall r_lang r_util r_parse DEPS+=r_flags r_cons r_reg r_anal CFLAGS+=-DCORELIB -Iarch/include -Iarch -I../../shlr CURDIR=p/ diff --git a/libr/bin/Makefile b/libr/bin/Makefile index 05689a1bb0..fcab8ad305 100644 --- a/libr/bin/Makefile +++ b/libr/bin/Makefile @@ -2,7 +2,7 @@ include ../config.mk include ../../global.mk NAME=r_bin -DEPS=r_util r_db r_io r_socket r_magic +DEPS=r_util r_io r_socket r_magic .PHONY: pre diff --git a/libr/bin/p/cgc.mk b/libr/bin/p/cgc.mk index 17750a6608..d0e49819c5 100644 --- a/libr/bin/p/cgc.mk +++ b/libr/bin/p/cgc.mk @@ -2,7 +2,7 @@ OBJ_CGC=bin_cgc.o STATIC_OBJ+=${OBJ_CGC} TARGET_CGC=bin_cgc.${EXT_SO} -LINK+=-L../../db -lr_db +#LINK+=-L../../util -lr_util $(SHLR)/sdb/src/libsdb.a ifeq ($(WITHPIC),1) ALL_TARGETS+=${TARGET_CGC} diff --git a/libr/bin/p/elf.mk b/libr/bin/p/elf.mk index 380fd8378d..8f4d33215d 100644 --- a/libr/bin/p/elf.mk +++ b/libr/bin/p/elf.mk @@ -1,9 +1,9 @@ OBJ_ELF=bin_elf.o bin_dbginfo_elf.o bin_write_elf.o OBJ_ELF+=../format/elf/elf.o ../format/elf/elf_write.o +#LINK+=-L../../util -lr_util $(SHLR)/sdb/src/libsdb.a STATIC_OBJ+=${OBJ_ELF} TARGET_ELF=bin_elf.${EXT_SO} -LINK+=-L../../db -lr_db ifeq ($(WITHPIC),1) ALL_TARGETS+=${TARGET_ELF} diff --git a/libr/bin/p/mbn.mk b/libr/bin/p/mbn.mk index a770061cdf..56aa1d5dfa 100644 --- a/libr/bin/p/mbn.mk +++ b/libr/bin/p/mbn.mk @@ -2,7 +2,7 @@ OBJ_MBN=bin_mbn.o STATIC_OBJ+=${OBJ_MBN} TARGET_MBN=bin_mbn.${EXT_SO} -LINK+=-L../../db -lr_db +#LINK+=-L../../util -lr_util $(SHLR)/sdb/src/libsdb.a ifeq ($(WITHPIC),1) ALL_TARGETS+=${TARGET_MBN} diff --git a/libr/bin/p/te.mk b/libr/bin/p/te.mk index 109fba33d4..5b3d67480c 100644 --- a/libr/bin/p/te.mk +++ b/libr/bin/p/te.mk @@ -2,7 +2,7 @@ OBJ_TE=bin_te.o ../format/te/te.o STATIC_OBJ+=${OBJ_TE} TARGET_TE=bin_te.${EXT_SO} -LINK+=-L../../db -lr_db $(SHLR)/sdb/src/libsdb.a +#LINK+=-L../../util -lr_util $(SHLR)/sdb/src/libsdb.a ALL_TARGETS+=${TARGET_TE} diff --git a/libr/core/Makefile b/libr/core/Makefile index 6c4af3a092..b1d38ddfe5 100644 --- a/libr/core/Makefile +++ b/libr/core/Makefile @@ -2,7 +2,7 @@ include ../config.mk NAME=r_core -DEPS=r_config r_cons r_io r_util r_flags r_asm r_db +DEPS=r_config r_cons r_io r_util r_flags r_asm DEPS+=r_debug r_hash r_bin r_lang r_io r_anal r_parse r_bp r_egg DEPS+=r_reg r_search r_syscall r_socket r_fs r_magic r_crypto diff --git a/libr/core/cmd_search.c b/libr/core/cmd_search.c index 14aa1ea620..f89ed210b8 100644 --- a/libr/core/cmd_search.c +++ b/libr/core/cmd_search.c @@ -796,7 +796,7 @@ static RList* construct_rop_gadget(RCore *core, ut64 addr, ut8 *buf, int idx, if (regex) { // get the first regexp. if (r_list_length (rx_list) > 0) { - rx = r_list_get_n(rx_list, count++); + rx = r_list_get_n (rx_list, count++); } } } diff --git a/libr/core/p/Makefile b/libr/core/p/Makefile index e0570a9df4..1e9590d917 100644 --- a/libr/core/p/Makefile +++ b/libr/core/p/Makefile @@ -4,7 +4,8 @@ include ../../../shlr/zip/deps.mk CFLAGS+=-I../../include -Wall -shared ${PIC_CFLAGS} ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. CFLAGS+=-L../../util -lr_util -L../../reg -lr_reg -L.. -lr_core -CFLAGS+=-L../../db -lr_db -L../../cons -lr_cons -L../../bin -lr_bin +#CFLAGS+=-L../../db -lr_db +CFLAGS+=-L../../cons -lr_cons -L../../bin -lr_bin CFLAGS+=-L../../parse -lr_parse -L../../io -lr_io -L../../fs -lr_fs CFLAGS+=-L../../magic -lr_magic -L../../hash -lr_hash -L../../config -lr_config CFLAGS+=-L../../anal -lr_anal -L../../egg -lr_egg -L../../flags -lr_flags diff --git a/libr/db/Jamroot b/libr/db/Jamroot deleted file mode 100644 index 137fd93e97..0000000000 --- a/libr/db/Jamroot +++ /dev/null @@ -1,3 +0,0 @@ -OBJS = db.c table.c ; - -lib r_db : $(OBJS) : ../include ../util ../../shlr/sdb ; diff --git a/libr/db/README b/libr/db/README deleted file mode 100644 index ab6941fe38..0000000000 --- a/libr/db/README +++ /dev/null @@ -1,44 +0,0 @@ -+------+ -| r.db | Simple and performance-friendly relational database -+------+ - -The database of r.db is based on index tables of key-size depth. -The key is the index of the key-bucket array which opens the search -space to a single key. - -Items are directly sorted - - [255] key buckets - | - `-> [0..255] -----. - | \ | - | \ | - [0..255] [0..255] | - | | |-- size of key (depth) - [0..255] ... | - | | - [0..255] -----' - -OPERATIONS -========== - - ADD - - DELETE - - r_db_delete_by_key(db, K_ID, &tmp) # specify more than one key? - - ITERATE - - -+----------+ -| r.db.sql | The SQL frontend for r.db -+----------+ - - - Compiles simple SQL-like sentences into a set of r.db queries - -void **iter = r_db_sql_query("select * from flags"); -while(r_db_ptr(iter)) { - struct foo_t *foo = r_db_ptr(iter); - iter = r_db_ptr_next(iter); -} diff --git a/libr/db/TODO b/libr/db/TODO deleted file mode 100644 index 496ae95499..0000000000 --- a/libr/db/TODO +++ /dev/null @@ -1,31 +0,0 @@ -* Use r_mem_pool -* Add support for one level RDB.. to 8x speed up -* Serialize/Deserialize from disk -* Return FALSE when adding two elements with the same - attributes (get before add) if the db is unique - // not necessary, we can just do this by manually checkingc -* Benchmarking - - Compilation support for profiling memory usage - - Compare performance against sqlite -* Import/export from/to SQL -* SQL support - -CREATE TABLE flags ( - name char(25) PRIMARY KEY, - offset ut64, -); - -SELECT * FROM flags WHERE offset == 0x8048000; - -CREATE VIEW flagwindow AS SELECT * FROM flags WHERE offset>0 and offset<100 - -DROP TABLE flags -INSERT INTO flags (name, offset) VALUES ("patata", 33) - -UPDATE flags SET offset=33 WHERE offset==20 - -STORE - - ut32 - - ut64 - - Endianness matterz - - RList *get_range (0, 4096) diff --git a/libr/db/db.c b/libr/db/db.c deleted file mode 100644 index 2a23893a7b..0000000000 --- a/libr/db/db.c +++ /dev/null @@ -1,275 +0,0 @@ -/* radare - LGPL - Copyright 2009-2013 - pancake */ - -#include "r_db.h" - -R_LIB_VERSION (r_db); -#if 0 -Configurable options: - - allow dupped nodes? (two times the same pointer?) -#endif - -R_API RDatabase *r_db_new() { - RDatabase *db = R_NEW (RDatabase); - if (db) { - memset (&db->blocks, '\0', sizeof (db->blocks)); - db->id_min = -1; - db->id_max = -1; - } - return db; -} - -R_API RDatabaseBlock *r_db_block_new() { - RDatabaseBlock *ptr = R_NEW0 (RDatabaseBlock); - return ptr; -} - -R_API int r_db_add_id(struct r_db_t *db, int key, int size) { - key &= 0xff; - if (db->blocks[key]) - return false; - if (db->id_min==-1) { - db->id_min = key; - db->id_max = key; - } else if (db->id_max < key) - db->id_max = key; - if (key < db->id_min) - db->id_min = key; - db->blocks[key] = r_db_block_new (); - db->blocks_sz[key] = size; - return true; -} - -static int _r_db_add_internal(struct r_db_t *db, int key, void *b) { - int i, idx, len, size; - struct r_db_block_t *block; - if (key<0 || key>255) - return false; - size = db->blocks_sz[key]; - block = db->blocks[key]; - if (block == NULL) { - block = r_db_block_new (); - if (!block) return false; - db->blocks[key] = block; - } - for (i=0;ichilds[idx] == NULL) - block->childs[idx] = r_db_block_new(); - block = block->childs[idx]; - } - if (block) { - if (block->data == NULL) { - // TODO: use slices.. much faster alloc+free - block->data = malloc(sizeof(void *)*2); - block->data[0] = b; - block->data[1] = NULL; - } else { - for (len=0; block->data[len]; len++); - block->data = realloc (block->data, sizeof (void *)*(len+2)); - block->data[len] = b; - block->data[len+1] = NULL; - } - } - return (block != NULL); -} - -R_API int r_db_add(struct r_db_t *db, void *b) { - int i, ret = false; - for (i=db->id_min;i<=db->id_max;i++) - if (db->blocks[i]) - ret += _r_db_add_internal (db, i, b); - return ret; -} - -R_API int r_db_add_unique(struct r_db_t *db, void *b) { - int i, ret = true; - for(i=db->id_min;i<=db->id_max;i++) { - if (db->blocks[i] && r_db_get (db, i, b) != NULL) { - ret = false; - break; - } - } - if (ret) ret = r_db_add (db, b); - return ret; -} - -R_API void **r_db_get(struct r_db_t *db, int key, const ut8 *b) { - RDatabaseBlock *block; - int i, size; - if (key == -1) { - key = db->id_min; -#if 0 -UNNECESSARY LOOPZ - for (i=0;iblocks[i]) { - key = i; - break; - } - } - if (key == -1) - return NULL; -#endif - } - size = db->blocks_sz[key]; - block = db->blocks[key]; - for (i=0; block && ichilds[b[key+i]]; - if (block) - return block->data; - return NULL; -} - -/* TODO: MOVE AS DEFINE IN r_db.h */ -R_API void **r_db_get_next(void **ptr) { - return ptr+1; -} - -/* TODO: MOVE AS DEFINE IN r_db.h */ -R_API void *r_db_get_cur(void **ptr) { - return ptr[0]; -} - -static int _r_db_delete_internal(struct r_db_t *db, int key, const ut8 *b) { - RDatabaseBlock *block; - int i, j, size = db->blocks_sz[key]; - block = db->blocks[key]; - - for (i=0;block&&ichilds[b[key+i]]; - - if (block && block->data) { - for (i=0;block->data[i]; i++) { - if (block->data[i] == b) - for (j=i;block->data[j]; j++) - block->data[j] = block->data[j+1]; - } - if (block->data[0] == NULL) { - free (block->data); - block->data = NULL; - } - return true; - } - return false; -} - -R_API int r_db_delete(struct r_db_t *db, const void *ptr) { - int i; - for (i=db->id_min; i<=db->id_max; i++) - if (db->blocks[i]) - if (!_r_db_delete_internal (db, i, ptr)) - eprintf ("failed to delete internal pointer\n"); - /* TODO */ - if (db->cb_free && ptr) - return db->cb_free (db, ptr, db->cb_user); - return (ptr != NULL); -} - -static int r_db_iter_find_next(RDatabaseIter *it) { - // TODO - return false; -} - -R_API RDatabaseIter *r_db_iter_new(RDatabase *db, int key) { - RDatabaseIter *iter = R_NEW0 (RDatabaseIter); - if (!iter) return NULL; - /* TODO: detect when keys are not valid and return NULL */ - iter->db = db; - iter->key = key; - iter->size = db->blocks_sz[key]; - memset (&iter->path, 0, sizeof (iter->path)); - /* TODO: detect when no keys are found and return NULL */ - iter->ptr = 0; - iter->cur = NULL; - r_db_iter_find_next (iter); - /* TODO: first iteration must be done here */ - return iter; -} - -R_API void *r_db_iter_cur(struct r_db_iter_t *iter) { - return iter->cur; -#if 0 - void *cur = NULL; - int i, depth = 0; - struct r_db_t *db = iter->db; - struct r_db_block_t *b = db->blocks[iter->key]; - if (iter->ptr == 0) { - /* first iteration */ - } else { - for(i=0;isize;i++) { - b = &b[iter->path[i]]; - if (b == NULL) { - fprintf(stderr, "r_db: Internal data corruption\n"); - return NULL; - } - } - /* TODO: check if null to find next node */ - return b->data[iter->ptr]; - } - - for(i=0;i<255;i++) { - if (b->childs[i]) { - /* walk childs until reaching the leafs */ - b = b->childs[i]; - i=0; - depth++; - if (depth == iter->size) { - break; - } - continue; - } - } - //iter->db - return cur; -#endif -} - -// NOTE: required for vala/swig -R_API void *r_db_iterator(RDatabase *db) { - return r_db_iter_new (db, db->id_min); -} - -/* returns 1 if there is a next element */ -R_API int r_db_iter_next(RDatabaseIter *iter) { - //RDatabaseBlock *b, *block; - int i;//, j; -// TODO: must be implemented for Vala/Swig - // if (something) return 1; - // depth = iter->size - // - for (i=iter->ptr; isize; i++) { - //block = block->childs[b[key+i]]; - } - iter->ptr = i; // update pointer - iter->cur = NULL; - return 0; -} - -/* return current iter data and go to next iterable element */ -R_API void *r_db_iter_get(RDatabaseIter *iter) { - void *data = iter->cur; - -// TODO: must be implemented for Vala/Swig - return data; -} - -R_API void *r_db_iter_prev(struct r_db_iter_t *iter) { - /* TODO */ - return NULL; -} - -R_API struct r_db_iter_t *r_db_iter_free(struct r_db_iter_t *iter) { - free (iter); - return NULL; -} - -R_API int r_db_free(struct r_db_t *db) { - /* TODO : using the iterator logic */ - // TODO: use r_pool_mem here! -#if 0 - r_db_iter_t *iter = r_db_iter(db, -1); - if (db->cb_free) { - r_db_delete(db); // XXX - } -#endif - return 0; -} diff --git a/libr/db/r.mk b/libr/db/r.mk deleted file mode 100644 index 7fea93bbbe..0000000000 --- a/libr/db/r.mk +++ /dev/null @@ -1,5 +0,0 @@ -ifeq ($(WITHNONPIC),1) -LDFLAGS+=$(LIBR)/db/sdb/src/libsdb.a -else -LDFLAGS+=-L$(LIBR)/db -lr_db -endif diff --git a/libr/db/t/Makefile b/libr/db/t/Makefile deleted file mode 100644 index 594d964b5a..0000000000 --- a/libr/db/t/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -BINDEPS=r_db r_util -BIN=test -OBJ=test.o - -include ../../rules.mk -include ../r.mk diff --git a/libr/db/t/test.c b/libr/db/t/test.c deleted file mode 100644 index 9c61e12e95..0000000000 --- a/libr/db/t/test.c +++ /dev/null @@ -1,109 +0,0 @@ -/* radare - LGPL - Copyright 2009-2010 pancake */ - - -#include "r_db.h" -void test_pair (); -void test_db(); - -struct item_t { - char city[10]; - int people; - int id; -}; - -#define K_ID R_DB_INDEXOF(struct item_t, id) -#define K_CITY R_DB_INDEXOF(struct item_t, city) - -int main(int argc, char **argv) { - test_pair (); - test_db (); - return 0; -} - -void test_pair () { - char *s; - RPair *p = r_pair_new (); - r_pair_set_sync_dir (p, "sdb-db-test"); - - r_pair_set (p, "root", "clown"); - r_pair_set (p, ".branch", "clown"); - r_pair_set (p, "user.name", "pancake"); - r_pair_set (p, "user.pass", "password"); - - s = r_pair_get (p, "user.name"); - printf ("user.name=%s\n", s); - - { - RPairItem *o; - RListIter *iter; - RList *list = r_pair_list (p, "user"); - printf ("DUMP:\n"); - r_list_foreach (list, iter, o) { - printf (" %s = %s\n", o->k, o->v); - } - r_list_purge (list); - } - r_pair_sync (p); -} - -void test_db() { - RDatabase *db = r_db_new (); - void **siter; - struct item_t *it, tmp; - - r_db_add_id (db, K_CITY, 10); - r_db_add_id (db, (int)(K_ID), sizeof (int)); - - it = (struct item_t *)malloc(sizeof(struct item_t)); - strcpy(it->city, "bcn"); - it->people = 1024; - it->id = 33; - r_db_add (db, it); - r_db_add (db, it); - //printf("(ORIG) %p\n", it); - - tmp.id = 33; - siter = r_db_get (db, K_ID, (void *)&tmp); - for(; siter && *siter; siter=r_db_get_next (siter)) { - struct item_t *foo = (struct item_t *)r_db_get_cur (siter); -// printf("(GET) %p\n", foo); - printf ("city: %s, people: %d, id: %d\n", - foo->city, foo->people, foo->id); - } - - /* delete */ - r_db_delete(db, it); - printf("--> delete 1 item\n"); - - /* list */ - tmp.id = 33; - siter = r_db_get(db, K_ID, (void *)&tmp); - for(; siter && siter[0]; siter=r_db_get_next(siter)) { - struct item_t *foo = (struct item_t *)r_db_get_cur(siter); - // printf("(GET) %p\n", foo); - printf("city: %s, people: %d, id: %d\n", - foo->city, foo->people, foo->id); - } - -#if 0 - |---| key -|--.--.--.--.--| -|--.--.--.--.--| -#endif - printf("--> iterate over full list\n"); - { - struct r_db_iter_t *iter; - - iter = r_db_iter_new(db, K_ID); // iter = db.iterator(K_ID); - //while (r_db_iter_cur(iter)) { // while(iter.exists()) { - while (iter->cur) { // while(iter.exists()) { - struct item_t *foo = (struct item_t *)iter->cur; //r_db_iter_cur(siter); - printf("city: %s, people: %d, id: %d\n", - foo->city, foo->people, foo->id); - r_db_iter_next(iter); - } - } - - printf("--> free db\n"); - r_db_free(db); -} diff --git a/libr/db/table.c b/libr/db/table.c deleted file mode 100644 index a9f50df8e3..0000000000 --- a/libr/db/table.c +++ /dev/null @@ -1,70 +0,0 @@ -/* radare - LGPL - Copyright 2009-2016 - pancake */ - -#include "r_db.h" -#include "r_util.h" - -struct r_db_table_t *r_db_table_new(const char *name, const char *fmt, const char *fields) { - int i; - int offset = 0; - struct r_db_table_t *table = R_NEW0 (RDatabaseTable); - if (!table) return NULL; - table->args = strdup (fields); - if (!table->args) goto beach; - - table->nelems = r_str_word_set0 (table->args); - if (table->nelems != strlen (fmt)) { - eprintf ("r_db_table_new: Invalid arguments\n"); - goto beach; - } else { - table->fmt = strdup (fmt); - if (!table->fmt) goto beach; - table->name = strdup (name); - if (!table->name) goto beach; - table->offset = (int*)calloc (1, sizeof (int)*table->nelems); - if (!table->offset) goto beach; - for (i=0; inelems; i++) { - table->offset[i] = offset; - offset += 4; - } - } - return table; - -beach: - r_db_table_free (table); - return NULL; -} - -/* Get offset of given named field inside the table */ -int r_db_table_key(struct r_db_table_t *table, const char *name) { - const char *word; - int i; - for (i = 0; i < table->nelems; i++) { - word = r_str_word_get0 (table->args, i); - if (!strcmp (name, word)) - break; - } - return table->offset[i]; -} - -/* Get offset of the N field in the table */ -int r_db_table_key_i(struct r_db_table_t *table, int elem) { - return (elem>=0 && table->nelemsoffset[elem] - : -1; -} - -/* Get name of the N field in the table */ -const char *r_db_table_field_i(struct r_db_table_t *table, int elem) { - return (elem >= 0 && table->nelems < elem) - ? r_str_word_get0 (table->args, elem) - : NULL; -} - -void *r_db_table_free(struct r_db_table_t *table) { - free (table->name); - free (table->fmt); - free (table->args); - free (table->offset); - free (table); - return NULL; -} diff --git a/libr/debug/Makefile b/libr/debug/Makefile index d059010723..0efae0cdf2 100644 --- a/libr/debug/Makefile +++ b/libr/debug/Makefile @@ -1,7 +1,7 @@ include ../config.mk NAME=r_debug -DEPS=r_reg r_db r_anal r_bp r_io r_parse r_cons r_syscall r_hash r_flags r_util +DEPS=r_reg r_anal r_bp r_io r_parse r_cons r_syscall r_hash r_flags r_util DEPS+=r_socket CFLAGS+=-DCORELIB diff --git a/libr/debug/p/native.mk b/libr/debug/p/native.mk index 43a02218e8..10056d65b2 100644 --- a/libr/debug/p/native.mk +++ b/libr/debug/p/native.mk @@ -22,7 +22,6 @@ ${TARGET_PTRACE}: ${OBJ_PTRACE} ${LDFLAGS_LINKPATH}.. -L.. -lr_debug \ ${LDFLAGS_LINKPATH}../../io -L../../io -lr_io \ ${LDFLAGS_LINKPATH}../../bp -L../../bp -lr_bp \ - ${LDFLAGS_LINKPATH}../../db -L../../db -lr_db \ ${LDFLAGS_LINKPATH}../../anal -L../../anal -lr_anal \ ${LDFLAGS_LINKPATH}../../reg -L../../reg -lr_reg \ ${LDFLAGS_LINKPATH}../../util -L../../util -lr_util \ diff --git a/libr/egg/Makefile b/libr/egg/Makefile index 0713d867c3..32b7f0f514 100644 --- a/libr/egg/Makefile +++ b/libr/egg/Makefile @@ -1,7 +1,7 @@ include ../config.mk NAME=r_egg -DEPS=r_asm r_syscall r_db r_util r_parse r_reg r_anal +DEPS=r_asm r_syscall r_util r_parse r_reg r_anal DEPS+=r_flags r_cons LINK+=$(SHLR)/java/libr_java.a diff --git a/libr/flags/Makefile b/libr/flags/Makefile index d1781a32bf..aadf2d593f 100644 --- a/libr/flags/Makefile +++ b/libr/flags/Makefile @@ -3,6 +3,5 @@ include ../config.mk NAME=r_flags DEPS=r_util r_cons OBJS=flags.o sort.o spaces.o -#DEPS+=r_db include ../rules.mk diff --git a/libr/parse/Makefile b/libr/parse/Makefile index bdb593fb46..3474e5c597 100644 --- a/libr/parse/Makefile +++ b/libr/parse/Makefile @@ -3,7 +3,7 @@ include ../config.mk NAME=r_parse DEPS=r_flags r_util r_anal r_syscall r_reg # indirect dependencies -DEPS+=r_db r_cons +DEPS+=r_cons LINK+=$(STOP)/tcc/libr_tcc.a CFLAGS+=-I$(STOP)/tcc/ diff --git a/libr/syscall/Makefile b/libr/syscall/Makefile index 1f804bbbb3..3efc3835b0 100644 --- a/libr/syscall/Makefile +++ b/libr/syscall/Makefile @@ -1,7 +1,7 @@ include ../config.mk NAME=r_syscall -DEPS=r_util r_db +DEPS=r_util OBJS=syscall.o ioports.o CFLAGS+=-D__UNIX__ -Wall diff --git a/libr/util/Makefile b/libr/util/Makefile index 3d3b77d5a6..4e1f202ac4 100644 --- a/libr/util/Makefile +++ b/libr/util/Makefile @@ -40,7 +40,11 @@ ifneq ($(shell expr "`uname -r`" : '[0-6]\.'), 2) endif endif +pre: ${SDBLIB} + ${MAKE} all + include ../rules.mk +include sdb.mk sync-regex regex-sync: -rm -rf src/ diff --git a/libr/db/Makefile b/libr/util/sdb.mk similarity index 83% rename from libr/db/Makefile rename to libr/util/sdb.mk index 3e5861df7f..67529e8ace 100644 --- a/libr/db/Makefile +++ b/libr/util/sdb.mk @@ -1,14 +1,9 @@ -include ../config.mk - -NAME=r_db -DEPS=r_util - -OBJS=db.o table.o - SDBPATH=../../shlr/sdb/src/ SDBLIB=${SDBPATH}/libsdb.a EXTRA_TARGETS+=${SDBLIB} +${SDBLIB}: + ${MAKE} -C ${SDBPATH} SDB_OBJS= SDB_OBJS+=buffer.o SDB_OBJS+=cdb.o @@ -32,14 +27,8 @@ SDB_OBJS+=journal.o SDBOBJS=$(addprefix ${SDBPATH},${SDB_OBJS}) OBJS+=${SDBOBJS} -#LINK+=${SDBPATH}/*.o CFLAGS+=-I${SDBPATH}/src + pre: ${SDBLIB} ${MAKE} all - -include ../rules.mk - -${SDBLIB}: - ${MAKE} -C ${SDBPATH} -