Update for sdb-1.6.0 (#18114)

This commit is contained in:
pancake 2020-12-27 12:09:20 +01:00 committed by GitHub
parent fd2dfd63d7
commit 46a658c9f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 77 additions and 18 deletions

View File

@ -43,6 +43,18 @@ To compile with Emscripten for Javascript:
make CC=emcc EXT_EXE=.js
To crosscompile with meson:
```
$ cat > cross-file.txt <<EOF
[properties]
exe_wrapper = 'wine'
and then run meson build --cross-file cross-file.txt ; ninja -C build. It should work and it should create another binary called sdb_native.
EOF
$ meson build --cross-file cross-file.txt
$ ninja -C build
```
Changes
-------
I have modified cdb code a little to create smaller databases and

View File

@ -6,7 +6,7 @@ INCDIR=${PREFIX}/include
VAPIDIR=${DATADIR}/vala/vapi/
MANDIR=${DATADIR}/man/man1
SDBVER=1.5.1-git
SDBVER=1.6.0
BUILD_MEMCACHE=0

View File

@ -118,6 +118,17 @@ sdb_exe = executable('sdb', 'src/main.c',
implicit_include_directories: false
)
if meson.is_cross_build()
sdb_native_exe = executable('sdb_native', 'src/main.c',
include_directories: sdb_inc,
link_with: [link_with],
install: false,
implicit_include_directories: false
)
else
sdb_native_exe = sdb_exe
endif
if not meson.is_subproject()
install_man(['src/sdb.1'])
endif

View File

@ -144,7 +144,7 @@ SDB_API bool sdb_ns_unset (Sdb *s, const char *name, Sdb *r) {
return false;
}
SDB_API int sdb_ns_set (Sdb *s, const char *name, Sdb *r) {
SDB_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r) {
SdbNs *ns;
SdbListIter *it;
ut32 hash = sdb_hash (name);

View File

@ -68,7 +68,7 @@ SDB_API int sdb_queryf (Sdb *s, const char *fmt, ...) {
return ret;
}
SDB_API char *sdb_querysf (Sdb *s, char *buf, size_t buflen, const char *fmt, ...) {
SDB_API char *sdb_querysf(Sdb *s, char *buf, size_t buflen, const char *fmt, ...) {
char string[4096];
char *ret;
va_list ap;

View File

@ -1,8 +1,35 @@
/* sdb - MIT - Copyright 2019 - pancake */
/* sdb - MIT - Copyright 2019-2020 - pancake */
#include "set.h"
// p
//// set foreach spaguetti
typedef struct {
void *cbptr;
void *userdata;
} SetData;
static bool u_foreach_cb(void *user, const ut64 k, const void *nada) {
SetData *sd = (SetData*)user;
set_u_foreach_cb cb = (set_u_foreach_cb)sd->cbptr;
return cb (sd->userdata, k);
}
SDB_API void set_u_foreach(SetU *s, set_u_foreach_cb cb, void *userdata) {
SetData sd = {cb, userdata};
ht_up_foreach (s, u_foreach_cb, &sd);
}
static bool p_foreach_cb(void *user, const void *k, const void *nada) {
SetData *sd = (SetData*)user;
set_p_foreach_cb cb = (set_p_foreach_cb)sd->cbptr;
return cb (sd->userdata, k);
}
SDB_API void set_p_foreach(SetP *s, set_p_foreach_cb cb, void *userdata) {
SetData sd = {cb, userdata};
ht_pp_foreach (s, p_foreach_cb, &sd);
}
////
SDB_API SetP *set_p_new(void) {
return ht_pp_new0 ();

View File

@ -5,12 +5,15 @@
#include "ht_up.h"
typedef HtPP SetP;
typedef bool (*set_p_foreach_cb)(void *userdata, const void *p);
typedef bool (*set_u_foreach_cb)(void *userdata, const ut64 u);
SDB_API SetP *set_p_new(void);
SDB_API void set_p_add(SetP *p, void *u);
SDB_API bool set_p_contains(SetP *s, void *u);
SDB_API void set_p_delete(SetP *s, void *u);
SDB_API void set_p_free(SetP *p);
SDB_API void set_p_foreach(SetP *p, set_p_foreach_cb cb, void *u);
typedef HtUP SetU;
@ -20,4 +23,6 @@ SDB_API bool set_u_contains(SetU *s, ut64 u);
SDB_API void set_u_delete(SetU *s, ut64 u);
SDB_API void set_u_free(SetU *p);
SDB_API void set_u_foreach(SetU *s, set_u_foreach_cb cb, void *u);
#endif

View File

@ -11,21 +11,25 @@
#undef eprintf
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
// Copied from https://gcc.gnu.org/wiki/Visibility
#ifndef SDB_API
#if defined(__GNUC__) && __GNUC__ >= 4
#define SDB_API __attribute__((visibility("default")))
#else
#define SDB_API
#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define SDB_API __attribute__ ((dllexport))
#else
#define SDB_API __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
#endif
#define SDB_IPI
#else
#if __GNUC__ >= 4
#define SDB_API __attribute__ ((visibility ("default")))
#define SDB_IPI __attribute__ ((visibility ("hidden")))
#else
#define SDB_API
#define SDB_IPI
#endif
#endif
#endif
#endif
#ifndef SDB_IPI
#if defined(__GNUC__) && __GNUC__ >= 4
// __attribute__((visibility("hidden")))
#endif
#define SDB_IPI static
#endif
#if MINGW || __MINGW32__ || __MINGW64__
#define __MINGW__ 1