23 if (!
sb || !
str || nl < 0) {
27 if ((
sb->len +
len + 2) >=
sb->size) {
28 int newsize =
sb->size +
len + 256;
42 sb->buf[
sb->len++] =
'\n';
62 vsnprintf(
string,
sizeof(
string), fmt, ap);
73 vsnprintf(
string,
sizeof(
string), fmt, ap);
80 #define out_concat(x) \
82 strbuf_append(out, x, 1); \
104 v = (
const char *)v2;
118 line[rlen + klen + 1] =
'=';
139 char *_out, *
out =
sb->buf;
151 len = strlen(
n->name);
153 if (
len + 2 < left) {
165 int i,
d,
ok,
w, alength, bufset = 0, is_ref = 0,
encode = 0;
167 char *
eq, *next, *quot, *slash, *res,
172 if (!
s || (!_cmd && !
buf)) {
176 if ((
int)
len < 1 || !
buf) {
200 while (*
cmd && (*
cmd ==
' ' || *
cmd ==
'\t')) {
211 next = strchr(
p,
';');
220 }
else if (*
p ==
'%') {
232 next = strchr(
eq + 1,
';');
254 if (!is_ref &&
val && *
val ==
'"') {
259 quot = strchr(quot,
'"');
261 if (*(quot - 1) ==
'\\') {
262 memmove(quot - 1, quot, strlen(quot) + 1);
272 next = strchr(quot,
';');
279 slash = strchr(
cmd,
'/');
289 slash = strchr(
cmd,
'/');
295 }
else if (*
cmd ==
'*') {
296 if (!strcmp(
cmd,
"***")) {
301 int name_len = strlen(ns->
name);
302 if (name_len < (
long)
sizeof(
root)) {
305 sizeof(
root) - name_len,
308 eprintf(
"TODO: Namespace too long\n");
312 }
else if (!strcmp(
cmd,
"**")) {
319 }
else if (!strcmp(
cmd,
"*")) {
332 char *tp = strchr(
cmd,
']');
338 p = (
const char *)tp;
356 eprintf(
"sdb: filesystem access disabled in config\n");
358 }
else if (*
cmd ==
'~') {
374 }
else if (*
cmd ==
'+' || *
cmd ==
'-') {
385 const char *eb = strchr(
cmd,
']');
401 }
else if (*
cmd ==
'-') {
410 char *nstr, numstr[128];
413 }
else if (*
cmd ==
'-') {
418 nstr =
sdb_itoa(curnum, numstr, 10);
456 if (
w < 0 || (
size_t)
w >
len) {
457 if (bufset &&
len < 0xff) {
469 if (
w < 0 || (
size_t)
w >
len) {
470 if (bufset &&
len < 0xff) {
483 }
else if (*
cmd ==
'[') {
496 if (
w < 0 || (
size_t)
w >
len) {
505 }
else if (
cmd[1] ==
'!') {
513 }
else if (
cmd[1] ==
'#') {
521 }
else if (
cmd[1] ==
'+' ||
cmd[1] ==
'-') {
524 if (
cmd[1] ==
'-' &&
eq) {
526 }
else if (
cmd[1] ==
'+' && !
eq) {
542 if (!
cmd[2] ||
cmd[2] ==
']') {
601 ok =
cmd[1] ? ((
cmd[1] ==
'+') ?
sdb_array_insert(
s,
p,
i,
val, 0) :
sdb_array_set(
s,
p,
i,
val, 0)) :
sdb_array_delete(
s,
p,
i, 0);
617 eprintf(
"TODO: [b]foo -> get index of b key inside foo array\n");
641 char *sval = (
char *)
val;
696 for (
i = 0; sval[
i];
i++) {
729 int i = strlen(
cmd) - 1;
787 int must_save = ((*
cmd ==
'~') || strchr(
cmd,
'='));
RZ_API int sdb_array_length(Sdb *s, const char *key)
RZ_API char * sdb_array_get(Sdb *s, const char *key, int idx, ut32 *cas)
RZ_API int sdb_array_add_sorted_num(Sdb *s, const char *key, ut64 val, ut32 cas)
RZ_API int sdb_array_add_sorted(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API void sdb_array_sort(Sdb *s, const char *key, ut32 cas)
RZ_API int sdb_array_set(Sdb *s, const char *key, int idx, const char *val, ut32 cas)
RZ_API int sdb_array_add(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API bool sdb_array_push(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API int sdb_array_insert(Sdb *s, const char *key, int idx, const char *val, ut32 cas)
RZ_API char * sdb_array_pop(Sdb *s, const char *key, ut32 *cas)
RZ_API int sdb_array_remove(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API int sdb_array_delete(Sdb *s, const char *key, int idx, ut32 cas)
RZ_API void sdb_array_sort_num(Sdb *s, const char *key, ut32 cas)
RZ_API int sdb_array_set_num(Sdb *s, const char *key, int idx, ut64 val, ut32 cas)
RZ_API ut64 sdb_array_get_num(Sdb *s, const char *key, int idx, ut32 *cas)
RZ_API ut8 * sdb_decode(const char *in, int *len)
RZ_API char * sdb_encode(const ut8 *bin, int len)
const lzma_allocator const uint8_t size_t uint8_t * out
static static fork const void static count close
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep lseek
RZ_API char * sdb_fmt(const char *fmt,...)
static void encode(size_t size, lzma_action action)
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void list(RzEgg *egg)
static char * slurp(const char *file)
RZ_API char * sdb_querysf(Sdb *s, char *buf, size_t buflen, const char *fmt,...)
static bool foreach_list_cb(void *user, const char *k, const char *v)
RZ_API int sdb_queryf(Sdb *s, const char *fmt,...)
RZ_API int sdb_query(Sdb *s, const char *cmd)
static StrBuf * strbuf_free(StrBuf *sb)
static StrBuf * strbuf_new(void)
RZ_API char * sdb_querys(Sdb *r, char *buf, size_t len, const char *_cmd)
static StrBuf * strbuf_append(StrBuf *sb, const char *str, const int nl)
RZ_API int sdb_query_file(Sdb *s, const char *file)
static void walk_namespace(StrBuf *sb, char *root, int left, char *p, SdbNs *ns, int encode)
RZ_API int sdb_query_lines(Sdb *s, const char *cmd)
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API void ls_free(SdbList *list)
#define ls_foreach(list, it, pos)
RZ_API Sdb * sdb_ns(Sdb *s, const char *name, int create)
RZ_API ut64 sdb_num_dec(Sdb *s, const char *key, ut64 n2, ut32 cas)
RZ_API ut64 sdb_num_inc(Sdb *s, const char *key, ut64 n2, ut32 cas)
static void repeat(struct parse *, sopno, int, int)
RZ_API int sdb_set_owned(Sdb *s, const char *key, char *val, ut32 cas)
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API char * sdb_get(Sdb *s, const char *key, ut32 *cas)
RZ_API SdbList * sdb_foreach_match(Sdb *s, const char *expr, bool single)
RZ_API const char * sdb_const_get(Sdb *s, const char *key, ut32 *cas)
RZ_API bool sdb_foreach(Sdb *s, SdbForeachCallback cb, void *user)
RZ_API int sdb_uncat(Sdb *s, const char *key, const char *value, ut32 cas)
RZ_API int sdb_unset_like(Sdb *s, const char *k)
RZ_API SdbList * sdb_foreach_list(Sdb *s, bool sorted)
RZ_API int sdb_concat(Sdb *s, const char *key, const char *value, ut32 cas)
RZ_API int sdb_isnum(const char *s)
RZ_API char * sdb_itoa(ut64 n, char *s, int base)
RZ_API const char * sdb_type(const char *k)
RZ_API ut32 sdb_hash(const char *key)
RZ_API ut64 sdb_atoi(const char *s)
RZ_API int sdb_num_base(const char *s)
static char * sdbkv_key(const SdbKv *kv)
static char * sdbkv_value(const SdbKv *kv)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)