Better handling of HAVE_SYSTEM, PTY, FORK, DYLINK and THREADS ##build

This commit is contained in:
pancake 2021-06-10 13:52:29 +02:00 committed by GitHub
parent f64c370585
commit b545c72017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 108 additions and 49 deletions

7
configure vendored
View File

@ -20,6 +20,7 @@ control_c() {
trap control_c 2 trap control_c 2
DEBUGGER=1 DEBUGGER=1
USE_MAGIC=0 USE_MAGIC=0
WANT_THREADS=1
LOADLIBS=1 LOADLIBS=1
WANT_DYLINK=1 WANT_DYLINK=1
HAVE_FORK=1 HAVE_FORK=1
@ -182,6 +183,7 @@ printf "
Optional Features: Optional Features:
--disable-debugger disable native debugger features --disable-debugger disable native debugger features
--with-sysmagic force to use system's magic --with-sysmagic force to use system's magic
--disable-threads disable use of thread apis
--disable-loadlibs disable loading plugins --disable-loadlibs disable loading plugins
--without-dylink disable support for dynamic loading of plugins --without-dylink disable support for dynamic loading of plugins
--without-fork disable fork --without-fork disable fork
@ -275,7 +277,7 @@ echo "LANGS: c"
echo "REQUIRED: libdl" echo "REQUIRED: libdl"
echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0" echo "OPTIONAL: libmagic libz libzip libxxhash libssl liblibuv>=1.0.0"
echo "PKG-CONFIG: capstone openssl libuv" echo "PKG-CONFIG: capstone openssl libuv"
echo "FLAGS: --disable-debugger --with-sysmagic --disable-loadlibs --without-dylink --without-fork --without-ptrace-wrap --without-gperf --with-libr --with-capstone5 --with-capstone4 --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2" echo "FLAGS: --disable-debugger --with-sysmagic --disable-threads --disable-loadlibs --without-dylink --without-fork --without-ptrace-wrap --without-gperf --with-libr --with-capstone5 --with-capstone4 --with-syscapstone --with-syszip --with-sysxxhash --without-gpl --with-openssl --without-libuv --with-rpath --with-compiler=gcc --with-ostype=auto --with-libversion=xxx --without-jemalloc --with-checks-level=2"
exit 0 exit 0
;; ;;
--cache-file) --cache-file)
@ -327,6 +329,7 @@ echo "FLAGS: --disable-debugger --with-sysmagic --disable-loadlibs --without
"--disable-debugger") DEBUGGER="0"; ;; "--disable-debugger") DEBUGGER="0"; ;;
"--with-sysmagic") USE_MAGIC="1"; ;; "--with-sysmagic") USE_MAGIC="1"; ;;
"--disable-threads") WANT_THREADS="0"; ;;
"--disable-loadlibs") LOADLIBS="0"; ;; "--disable-loadlibs") LOADLIBS="0"; ;;
"--without-dylink") WANT_DYLINK="0"; ;; "--without-dylink") WANT_DYLINK="0"; ;;
"--without-fork") HAVE_FORK="0"; ;; "--without-fork") HAVE_FORK="0"; ;;
@ -364,7 +367,7 @@ parse_options "$1"
shift shift
done done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL" ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR ETCDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION_NUMBER PKGNAME VPATH CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C DEBUGGER HAVE_LIB_DL DL_LIBS PKGCONFIG HAVE_PATCH PATCH HAVE_GIT GIT HAVE_GPERF GPERF HAVE_LIB_MAGIC USE_MAGIC USE_LIB_MAGIC LIBMAGIC WANT_THREADS LOADLIBS WANT_DYLINK HAVE_FORK WANT_PTRACE_WRAP WANT_GPERF WITH_LIBR USE_CS5 USE_CS4 WITH_CAPSTONE CAPSTONE_CFLAGS CAPSTONE_LDFLAGS HAVE_PKGCFG_CAPSTONE USE_CAPSTONE HAVE_LIB_Z HAVE_LIB_ZIP USE_ZIP USE_LIB_ZIP LIBZIP HAVE_LIB_XXHASH USE_XXHASH USE_LIB_XXHASH LIBXXHASH WITH_GPL HAVE_DECL_ADDR_NO_RANDOMIZE HAVE_DECL___GLIBC__ HAVE_ARC4RANDOM_UNIFORM HAVE_EXPLICIT_BZERO HAVE_EXPLICIT_MEMSET HAVE_CLOCK_NANOSLEEP HAVE_SIGACTION HAVE_CLOCK_GETTIME CLOCK_LDFLAGS SUPPORT_GNU99 HAVE_LIB_GMP HAVE_LIB_SSL SSL_CFLAGS SSL_LDFLAGS HAVE_PKGCFG_OPENSSL HAVE_OPENSSL WANT_OPENSSL HAVE_LIBUV_VERSION_1_0_0 LIBUV_CFLAGS LIBUV_LDFLAGS HAVE_PKGCFG_LIBUV HAVE_LIBUV WANT_LIBUV USE_RPATH USERCC USEROSTYPE LIBVERSION HAVE_JEMALLOC HAVE_PTRACE USE_PTRACE_WRAP R_CHECKS_LEVEL"
create_environ create_environ

View File

@ -24,6 +24,7 @@ IFAND HAVE_LIB_MAGIC USE_MAGIC {
LIBMAGIC = '' ; LIBMAGIC = '' ;
} }
ARG_DISABLE WANT_THREADS threads disable use of thread apis ;
(( useful for static builds . see sys/static.sh )) (( useful for static builds . see sys/static.sh ))
ARG_DISABLE LOADLIBS loadlibs disable loading plugins ; ARG_DISABLE LOADLIBS loadlibs disable loading plugins ;

View File

@ -6,6 +6,7 @@
#endif #endif
#define R_DEBUG 0 #define R_DEBUG 0
#define R_RTDEBUG 1 #define R_RTDEBUG 1
#define WANT_THREADS 1
/* inlined APIs */ /* inlined APIs */
#define R_INLINE 0 #define R_INLINE 0

View File

@ -3015,7 +3015,9 @@ R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd) {
free (out); free (out);
ret = 0; ret = 0;
} }
#if __UNIX__ #if !HAVE_FORK
// nothing
#elif __UNIX__
r_str_trim_head (radare_cmd); r_str_trim_head (radare_cmd);
r_str_trim_head (shell_cmd); r_str_trim_head (shell_cmd);

View File

@ -4,7 +4,7 @@
#include "r_types.h" #include "r_types.h"
#include "r_list.h" #include "r_list.h"
#if __UNIX__ #if __UNIX__ && WANT_DYLINK
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif

View File

@ -6,7 +6,13 @@
#endif #endif
#define _GNU_SOURCE #define _GNU_SOURCE
#include "r_types.h" #include "r_types.h"
#include "r_userconf.h"
#ifndef WANT_THREADS
#define WANT_THREADS 1
#endif
#if WANT_THREADS
#define HAVE_PTHREAD 1 #define HAVE_PTHREAD 1
#if __WINDOWS__ #if __WINDOWS__
@ -48,9 +54,18 @@
#error Threading library only supported for pthread and w32 #error Threading library only supported for pthread and w32
#endif #endif
typedef enum { R_TH_FREED = -1, R_TH_STOP = 0, R_TH_REPEAT = 1 } RThreadFunctionRet;
#define R_TH_FUNCTION(x) RThreadFunctionRet (*x)(struct r_th_t *)
#else
#define R_TH_SEM_T int
#define R_TH_LOCK_T int
#define R_TH_COND_T int
#define R_TH_TID int
#endif
typedef enum { R_TH_FREED = -1, R_TH_STOP = 0, R_TH_REPEAT = 1 } RThreadFunctionRet;
#define R_TH_FUNCTION(x) RThreadFunctionRet (*x)(struct r_th_t *)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -90,8 +90,13 @@
#if __IPHONE_8_0 && TARGET_OS_IPHONE #if __IPHONE_8_0 && TARGET_OS_IPHONE
#define LIBC_HAVE_SYSTEM 0 #define LIBC_HAVE_SYSTEM 0
#define HAVE_SYSTEM 0
#elif __wasi__
#define LIBC_HAVE_SYSTEM 0
#define HAVE_SYSTEM 0
#else #else
#define LIBC_HAVE_SYSTEM 1 #define LIBC_HAVE_SYSTEM 1
#define HAVE_SYSTEM 1
#endif #endif
#if APPLE_SDK_IPHONEOS || APPLE_SDK_APPLETVOS || APPLE_SDK_WATCHOS || APPLE_SDK_APPLETVSIMULATOR || APPLE_SDK_WATCHSIMULATOR #if APPLE_SDK_IPHONEOS || APPLE_SDK_APPLETVOS || APPLE_SDK_WATCHOS || APPLE_SDK_APPLETVSIMULATOR || APPLE_SDK_WATCHSIMULATOR

View File

@ -11,6 +11,7 @@
#define HAVE_EXPLICIT_MEMSET @HAVE_EXPLICIT_MEMSET@ #define HAVE_EXPLICIT_MEMSET @HAVE_EXPLICIT_MEMSET@
#define HAVE_CLOCK_NANOSLEEP @HAVE_CLOCK_NANOSLEEP@ #define HAVE_CLOCK_NANOSLEEP @HAVE_CLOCK_NANOSLEEP@
#define HAVE_SIGACTION @HAVE_SIGACTION@ #define HAVE_SIGACTION @HAVE_SIGACTION@
#define WANT_THREADS @WANT_THREADS@
#if (HAVE_GPERF) == 1 #if (HAVE_GPERF) == 1
#define HAVE_GPERF @HAVE_GPERF@ #define HAVE_GPERF @HAVE_GPERF@

View File

@ -10,10 +10,10 @@ extern "C" {
#endif #endif
/* Returns atoi(str) if signal with `str` name not found. */ /* Returns atoi(str) if signal with `str` name not found. */
R_API int r_signal_from_string (const char *str); R_API int r_signal_from_string(const char *str);
/* Return NULL if signal with `code` not found. */ /* Return NULL if signal with `code` not found. */
R_API const char* r_signal_to_string (int code); R_API const char* r_signal_to_string(int code);
// XXX this function should be portable, not-unix specific // XXX this function should be portable, not-unix specific
#if __UNIX__ #if __UNIX__

View File

@ -1,4 +1,5 @@
/* radare - LGPLv3- Copyright 2017 - xarkes */ /* radare - LGPLv3- Copyright 2017 - xarkes */
#include <r_io.h> #include <r_io.h>
#include <r_lib.h> #include <r_lib.h>
#include <r_util.h> #include <r_util.h>

View File

@ -5,18 +5,20 @@
R_LIB_VERSION(r_lang); R_LIB_VERSION(r_lang);
#include "p/spp.c" // hardcoded
#if HAVE_SYSTEM
#include "p/pipe.c" // hardcoded #include "p/pipe.c" // hardcoded
#include "p/c.c" // hardcoded
#include "p/v.c" // hardcoded
#include "p/vala.c" // hardcoded #include "p/vala.c" // hardcoded
#include "p/rust.c" // hardcoded #include "p/rust.c" // hardcoded
#include "p/zig.c" // hardcoded #include "p/zig.c" // hardcoded
#include "p/spp.c" // hardcoded
#include "p/c.c" // hardcoded
#include "p/v.c" // hardcoded
#include "p/go.c" // hardcoded
#include "p/lib.c"
#if __UNIX__ #if __UNIX__
#include "p/cpipe.c" // hardcoded #include "p/cpipe.c" // hardcoded
#endif #endif
#endif
#include "p/go.c" // hardcoded
#include "p/lib.c"
static RLang *__lang = NULL; static RLang *__lang = NULL;
@ -45,17 +47,19 @@ R_API RLang *r_lang_new(void) {
} }
lang->defs->free = (RListFree)r_lang_def_free; lang->defs->free = (RListFree)r_lang_def_free;
lang->cb_printf = (PrintfCallback)printf; lang->cb_printf = (PrintfCallback)printf;
#if HAVE_SYSTEM
#if __UNIX__ #if __UNIX__
r_lang_add (lang, &r_lang_plugin_c); r_lang_add (lang, &r_lang_plugin_c);
r_lang_add (lang, &r_lang_plugin_cpipe); r_lang_add (lang, &r_lang_plugin_cpipe);
#endif #endif
r_lang_add (lang, &r_lang_plugin_v);
r_lang_add (lang, &r_lang_plugin_vala); r_lang_add (lang, &r_lang_plugin_vala);
r_lang_add (lang, &r_lang_plugin_rust); r_lang_add (lang, &r_lang_plugin_rust);
r_lang_add (lang, &r_lang_plugin_zig); r_lang_add (lang, &r_lang_plugin_zig);
r_lang_add (lang, &r_lang_plugin_v); r_lang_add (lang, &r_lang_plugin_pipe);
#endif
r_lang_add (lang, &r_lang_plugin_go); r_lang_add (lang, &r_lang_plugin_go);
r_lang_add (lang, &r_lang_plugin_spp); r_lang_add (lang, &r_lang_plugin_spp);
r_lang_add (lang, &r_lang_plugin_pipe);
r_lang_add (lang, &r_lang_plugin_lib); r_lang_add (lang, &r_lang_plugin_lib);
return lang; return lang;

View File

@ -994,7 +994,7 @@ R_API int r_main_rabin2(int argc, const char **argv) {
} }
if (file && *file && action & R_BIN_REQ_DLOPEN) { if (file && *file && action & R_BIN_REQ_DLOPEN) {
#if __UNIX__ #if __UNIX__ && HAVE_FORK
int child = r_sys_fork (); int child = r_sys_fork ();
if (child == -1) { if (child == -1) {
r_core_fini (&core); r_core_fini (&core);

View File

@ -1,10 +1,10 @@
/* radare2 - Copyleft 2011-2020 - pancake */ /* radare2 - Copyleft 2011-2021 - pancake */
#include <r_util.h> #include <r_util.h>
#include <r_main.h> #include <r_main.h>
#include <r_socket.h> #include <r_socket.h>
#if __UNIX__ #if __UNIX__ && HAVE_PTY
static void fwd(int sig) { static void fwd(int sig) {
/* do nothing? send kill signal to remote process */ /* do nothing? send kill signal to remote process */
} }
@ -34,7 +34,7 @@ R_API int r_main_rarun2(int argc, const char **argv) {
} }
const char *file = argv[1]; const char *file = argv[1];
if (!strcmp (file, "-t")) { if (!strcmp (file, "-t")) {
#if __UNIX__ #if __UNIX__ && HAVE_PTY
rarun2_tty (); rarun2_tty ();
return 0; return 0;
#else #else

View File

@ -83,7 +83,7 @@ R_API void *r_lib_dl_sym(void *handler, const char *name) {
} }
R_API int r_lib_dl_close(void *handler) { R_API int r_lib_dl_close(void *handler) {
#if __UNIX__ #if __UNIX__ && WANT_DYLINK
return dlclose (handler); return dlclose (handler);
#else #else
return handler? 0: -1; return handler? 0: -1;

View File

@ -481,7 +481,7 @@ R_API int r_sandbox_kill(int pid, int sig) {
if (enabled) { if (enabled) {
return -1; return -1;
} }
#if __UNIX__ #if HAVE_SYSTEM && __UNIX__
return kill (pid, sig); return kill (pid, sig);
#endif #endif
return -1; return -1;

View File

@ -69,8 +69,10 @@ R_API const char* r_signal_to_string (int code) {
return NULL; return NULL;
} }
#if HAVE_PTHREAD #if __UNIX__
R_API void r_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask) { R_API void r_signal_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask) {
#if HAVE_PTHREAD
pthread_sigmask (how, newmask, oldmask); pthread_sigmask (how, newmask, oldmask);
#endif
} }
#endif #endif

View File

@ -614,7 +614,7 @@ R_API int r_sys_thp_mode(void) {
#endif #endif
} }
#if __UNIX__ #if __UNIX__ && HAVE_SYSTEM
R_API int r_sys_cmd_str_full(const char *cmd, const char *input, int ilen, char **output, int *len, char **sterr) { R_API int r_sys_cmd_str_full(const char *cmd, const char *input, int ilen, char **output, int *len, char **sterr) {
char *mysterr = NULL; char *mysterr = NULL;
if (!sterr) { if (!sterr) {

View File

@ -40,6 +40,8 @@ R_API int r_th_lock_enter(RThreadLock *thl) {
#elif __WINDOWS__ #elif __WINDOWS__
EnterCriticalSection (&thl->lock); EnterCriticalSection (&thl->lock);
return 0; return 0;
#else
return 0;
#endif #endif
} }
@ -48,6 +50,8 @@ R_API int r_th_lock_tryenter(RThreadLock *thl) {
return !pthread_mutex_trylock (&thl->lock); return !pthread_mutex_trylock (&thl->lock);
#elif __WINDOWS__ #elif __WINDOWS__
return TryEnterCriticalSection (&thl->lock); return TryEnterCriticalSection (&thl->lock);
#else
return 0;
#endif #endif
} }
@ -57,6 +61,8 @@ R_API int r_th_lock_leave(RThreadLock *thl) {
#elif __WINDOWS__ #elif __WINDOWS__
LeaveCriticalSection (&thl->lock); LeaveCriticalSection (&thl->lock);
return 0; return 0;
#else
return 0;
#endif #endif
} }

View File

@ -349,6 +349,8 @@ userconf.set10('HAVE_OPENSSL', use_sys_openssl)
userconf.set10('HAVE_LIBUV', use_libuv) userconf.set10('HAVE_LIBUV', use_libuv)
userconf.set10('HAVE_FORK', use_fork) userconf.set10('HAVE_FORK', use_fork)
userconf.set10('WANT_DYLINK', use_dylink) userconf.set10('WANT_DYLINK', use_dylink)
userconf.set10('WANT_THREADS', get_option('want_threads'))
userconf.set10('HAVE_GPERF', get_option('sdb_cgen'))
userconf.set10('HAVE_PTRACE', have_ptrace) userconf.set10('HAVE_PTRACE', have_ptrace)
userconf.set10('USE_PTRACE_WRAP', use_ptrace_wrap) userconf.set10('USE_PTRACE_WRAP', use_ptrace_wrap)
userconf.set10('WITH_GPL', not get_option('nogpl')) userconf.set10('WITH_GPL', not get_option('nogpl'))

View File

@ -23,6 +23,7 @@ option('r2_gittap', type: 'string', value: '')
option('r2_gittip', type: 'string', value: '') option('r2_gittip', type: 'string', value: '')
option('checks_level', type: 'integer', value: 9999, description: 'Value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL). By default its value depends on buildtype (2 on debug, 1 on release).') option('checks_level', type: 'integer', value: 9999, description: 'Value between 0 and 3 to enable different level of assert (see R_CHECKS_LEVEL). By default its value depends on buildtype (2 on debug, 1 on release).')
option('capstone_in_builddir', type: 'boolean', value: false, description: 'When true, capstone is downloaded in the build directory and not in the source one') option('capstone_in_builddir', type: 'boolean', value: false, description: 'When true, capstone is downloaded in the build directory and not in the source one')
option('want_threads', type: 'boolean', value: true)
option('use_sys_capstone', type: 'boolean', value: false) option('use_sys_capstone', type: 'boolean', value: false)
option('use_capstone_version', type: 'combo', choices: ['v3', 'v4', 'v5'], value: 'v5') option('use_capstone_version', type: 'combo', choices: ['v3', 'v4', 'v5'], value: 'v5')
option('use_sys_magic', type: 'boolean', value: false) option('use_sys_magic', type: 'boolean', value: false)

View File

@ -70,42 +70,52 @@ Usage example
------------- -------------
Let's create a database! Let's create a database!
$ sdb d hello=world ```
$ sdb d hello $ sdb d hello=world
world $ sdb d hello
world
```
Using arrays (>=0.6): Using arrays (>=0.6):
$ sdb - '[]list=1,2' '[0]list' '[0]list=foo' '[]list' '[+1]list=bar' ```
1 $ sdb - '[]list=1,2' '[0]list' '[0]list=foo' '[]list' '[+1]list=bar'
foo 1
2 foo
2
```
Let's play with json: Let's play with json:
$ sdb d g='{"foo":1,"bar":{"cow":3}}' ```
$ sdb d g:bar.cow $ sdb d g='{"foo":1,"bar":{"cow":3}}'
3 $ sdb d g:bar.cow
$ sdb - user='{"id":123}' user:id=99 user:id 3
99 $ sdb - user='{"id":123}' user:id=99 user:id
99
```
Using the command-line without any disk database: Using the command-line without any disk database:
$ sdb - foo=bar foo a=3 +a -a ```
bar $ sdb - foo=bar foo a=3 +a -a
4 bar
3 4
3
$ sdb - $ sdb -
foo=bar foo=bar
foo foo
bar bar
a=3 a=3
+a +a
4 4
-a -a
3 3
```
Remove the database Remove the database
$ rm -f d ```
$ rm -f d
```

View File

@ -4,6 +4,9 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <fcntl.h> #include <fcntl.h>
#ifndef HAVE_SYSTEM
#define HAVE_SYSTEM 1
#endif
#if USE_DLSYSTEM #if USE_DLSYSTEM
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@ -718,6 +721,7 @@ static int showcount(const char *db) {
static int sdb_system(const char *cmd) { static int sdb_system(const char *cmd) {
static int (*sys)(const char *cmd) = NULL; static int (*sys)(const char *cmd) = NULL;
if (!sys) { if (!sys) {
#if HAVE_SYSTEM
#if USE_DLSYSTEM #if USE_DLSYSTEM
sys = dlsym (NULL, "system"); sys = dlsym (NULL, "system");
if (!sys) { if (!sys) {
@ -726,6 +730,7 @@ static int sdb_system(const char *cmd) {
} }
#else #else
sys = system; sys = system;
#endif
#endif #endif
} }
return sys (cmd); return sys (cmd);