This commit is contained in:
pancake 2014-05-12 10:44:19 +02:00
parent 4be8df4ac7
commit e9f820d17f
5 changed files with 19 additions and 11 deletions

View File

@ -107,7 +107,7 @@ int sdb_foreach (Sdb* s, SdbForeachCallback cb, void *user);
int sdb_disk_create (Sdb* s);
int sdb_disk_insert (Sdb* s, const char *key, const char *val);
int sdb_disk_finish (Sdb* s);
void sdb_disk_unlink (Sdb* s);
int sdb_disk_unlink (Sdb* s);
/* iterate */
void sdb_dump_begin (Sdb* s);
@ -127,7 +127,7 @@ ut64 sdb_num_dec (Sdb* s, const char *key, ut64 n, ut32 cas);
int sdb_lock(const char *s);
const char *sdb_lockfile(const char *f);
void sdb_unlock(const char *s);
SDB_API void sdb_unlink (Sdb* s);
SDB_API int sdb_unlink (Sdb* s);
SDB_API int sdb_lock_wait(const char *s UNUSED);
/* expiration */

View File

@ -81,7 +81,9 @@ SDB_API int sdb_disk_finish (Sdb* s) {
return ret;
}
SDB_API void sdb_disk_unlink (Sdb *s) {
SDB_API int sdb_disk_unlink (Sdb *s) {
if (s->dir && *(s->dir))
unlink (s->dir);
if (unlink (s->dir) != -1)
return 1;
return 0;
}

View File

@ -121,6 +121,7 @@ repeat:
}
eq = strchr (p, '=');
if (eq) {
d = 1;
*eq++ = 0;
if (*eq=='$') {
next = strchr (eq+1, ';');
@ -129,7 +130,10 @@ repeat:
if (next) *next = ';';
is_ref = 1; // protect readonly buffer from being processed
} else val = eq;
} else val = NULL;
} else {
val = NULL;
d = 0;
}
if (!is_ref) {
next = strchr (val?val:cmd, ';'); //val?val:cmd, ';');
}
@ -545,13 +549,15 @@ fail:
}
SDB_API int sdb_query (Sdb *s, const char *cmd) {
char buf[1024], *out = sdb_querys (s, buf, sizeof (buf), cmd);
char buf[1024], *out;
int must_save = ((*cmd=='~') || strchr (cmd, '='));
out = sdb_querys (s, buf, sizeof (buf), cmd);
if (out) {
if (*out) puts (out);
if (out != buf)
free (out);
}
return ((*cmd=='~')||strchr (cmd, '='))? 1: 0;
return must_save;
}
SDB_API int sdb_query_lines (Sdb *s, const char *cmd) {

View File

@ -629,11 +629,11 @@ SDB_API void sdb_config(Sdb *s, int options) {
}
}
SDB_API void sdb_unlink (Sdb* s) {
SDB_API int sdb_unlink (Sdb* s) {
// nullify Sdb
sdb_fini (s, 1);
// remove from disk
sdb_disk_unlink (s);
return sdb_disk_unlink (s);
}
SDB_API void sdb_drain(Sdb *s, Sdb *f) {

View File

@ -107,7 +107,7 @@ int sdb_foreach (Sdb* s, SdbForeachCallback cb, void *user);
int sdb_disk_create (Sdb* s);
int sdb_disk_insert (Sdb* s, const char *key, const char *val);
int sdb_disk_finish (Sdb* s);
void sdb_disk_unlink (Sdb* s);
int sdb_disk_unlink (Sdb* s);
/* iterate */
void sdb_dump_begin (Sdb* s);
@ -127,7 +127,7 @@ ut64 sdb_num_dec (Sdb* s, const char *key, ut64 n, ut32 cas);
int sdb_lock(const char *s);
const char *sdb_lockfile(const char *f);
void sdb_unlock(const char *s);
SDB_API void sdb_unlink (Sdb* s);
SDB_API int sdb_unlink (Sdb* s);
SDB_API int sdb_lock_wait(const char *s UNUSED);
/* expiration */