28 exit(sig < 2 ? sig : 0);
39 static int bufsize =
BS;
40 static char *next =
NULL;
41 static size_t nextlen = 0;
128 #if HAVE_HEADER_SYS_MMAN_H
129 static void synchronize(
RZ_UNUSED int sig) {
142 const char *expgrep) {
152 if (grep && !strstr(
k, expgrep) && !strstr(
v, expgrep)) {
176 static int sdb_grep(
const char *db,
int fmt,
const char *grep) {
194 if (strchr(
args[
i],
'=')) {
213 eprintf(
"Cannot create database\n");
232 eprintf(
"Failed to read text sdb from stdin\n");
241 printf(
"usage: sdb [-0cdehjJv|-D A B] [-|db] "
242 "[.file]|[-=]|==||[-+][(idx)key[=value] ..]\n");
244 printf(
" -0 terminate results with \\x00\n"
245 " -c count the number of keys database\n"
246 " -d decode base64 from stdin\n"
247 " -D diff two databases\n"
248 " -e encode stdin as base64\n"
249 " -h show this help\n"
250 " -J enable journaling\n"
251 " -v show version information\n");
287 if (
out && declen >= 0) {
305 if ((
size_t)
r >=
sizeof(sbuf)) {
315 printf(
"\x1b[%sm%s\x1b[0m\n", diff->
add ?
"32" :
"31",
buf);
344 int db0 = 1, argi = 1;
345 bool interactive =
false;
399 if (argi == 1 && !strcmp(
argv[argi],
"-")) {
402 if (argc == db0 + 1) {
411 if (argc - 1 == db0) {
417 #if HAVE_HEADER_SYS_MMAN_H
422 if (interactive || !strcmp(
argv[db0 + 1],
"-")) {
438 }
else if (!strcmp(
argv[db0 + 1],
"=")) {
440 }
else if (!strcmp(
argv[db0 + 1],
"==")) {
448 for (
i = db0 + 1;
i < argc;
i++) {
static const char * arg(RzAnalysis *a, csh *handle, cs_insn *insn, char *buf, int n)
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 * in
const lzma_allocator const uint8_t size_t uint8_t * out
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
RZ_API bool sdb_disk_insert(Sdb *s, const char *key, const char *val)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
static void dbdiff_cb(const SdbDiff *diff, void *user)
static int createdb(const char *f, const char **args, int nargs)
static int insertkeys(Sdb *s, const char **args, int nargs, int mode)
int main(int argc, const char **argv)
static int sdb_dump(const char *db, int fmt)
static bool dbdiff(const char *a, const char *b)
static void write_null(void)
static void terminate(RZ_UNUSED int sig)
static int sdb_grep(const char *db, int fmt, const char *grep)
int showcount(const char *db)
static int sdb_grep_dump(const char *dbname, int fmt, bool grep, const char *expgrep)
static char * slurp(FILE *f, size_t *sz)
static int base64encode(void)
static int base64decode(void)
static int showusage(int o)
static int showversion(void)
RZ_API int sdb_query(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)
static static fork const void static count static fd const char const char static newpath char char argv
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")
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment signal
RZ_API bool sdb_dump_dupnext(Sdb *s, char *key, char **value, int *_vlen)
RZ_API Sdb * sdb_new(const char *path, const char *name, int lock)
RZ_API bool sdb_free(Sdb *s)
RZ_API bool sdb_stats(Sdb *s, ut32 *disk, ut32 *mem)
RZ_API void sdb_dump_begin(Sdb *s)
RZ_API bool sdb_sync(Sdb *s)
RZ_API void sdb_config(Sdb *s, int options)
#define SDB_OPTION_JOURNAL
RZ_API bool sdb_text_load(Sdb *s, const char *file)
RZ_API bool sdb_text_load_buf(Sdb *s, char *buf, size_t sz)
#define SDB_OPTION_NOSTAMP
#define write_(fd, buf, count)
RZ_API bool sdb_diff(Sdb *a, Sdb *b, SdbDiffCallback cb, void *cb_user)
RZ_API int sdb_diff_format(char *str, int size, const SdbDiff *diff)