9 #if HAVE_HEADER_SYS_MMAN_H
64 static int cmp_ns(
const void *
a,
const void *
b) {
76 write_(fd, p, n - p); \
81 #define ESCAPE_LOOP(fd, str, escapes) \
83 const char *p = str; \
86 switch (*n) { escapes } \
91 #define ESCAPE(c, repl, replsz) \
95 write_(fd, "\\" repl, replsz + 1); \
101 const char *path_token;
140 int fd = *(
int *)user;
235 ctx->unescape =
false;
238 switch (
ctx->state) {
243 ctx->cur_db =
ctx->root_db;
245 size_t token_off = (
size_t)token_off_tmp;
246 if (!
ctx->buf[token_off]) {
251 ctx->cur_db =
ctx->root_db;
259 const char *
k =
ctx->buf +
ctx->line_begin;
260 const char *
v =
ctx->buf +
ctx->token_begin;
290 if (
c ==
'\n' ||
c ==
'\r') {
297 ctx->line_begin =
ctx->pos;
302 ctx->token_begin =
ctx->pos + 1;
312 ctx->unescape =
false;
313 }
else if (
c ==
'\\') {
316 ctx->unescape =
true;
321 ctx->token_begin =
ctx->pos + 1;
326 ctx->token_begin =
ctx->pos + 1;
329 }
else if (
ctx->shift) {
339 size_t linesz =
ctx->bufsz -
ctx->line_begin;
340 char *linebuf =
malloc(linesz + 1);
347 ctx->bufsz -=
ctx->line_begin;
349 ctx->token_begin -=
ctx->line_begin;
353 it->
data = (
void *)((
size_t)token_off_tmp -
ctx->line_begin);
374 ctx->token_begin = 0;
378 ctx->unescape =
false;
379 if (!
ctx->buf || !
ctx->path) {
395 while (
ctx.pos <
ctx.bufsz) {
412 if (
fstat(
fd, &st) || !st.st_size) {
415 #if HAVE_HEADER_SYS_MMAN_H
417 if (
x == MAP_FAILED) {
421 char *
x =
calloc(1, st.st_size);
425 if (
read(
fd,
x, st.st_size) != st.st_size) {
431 #if HAVE_HEADER_SYS_MMAN_H
static static fork const void static count static fd const char const char static newpath const char static path const char path
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 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 fstat
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, 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 char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags mmap
static const void static count static fd struct stat static buf struct pollfd unsigned static timeout void static offset munmap
RZ_API SdbList * ls_new(void)
RZ_API void ls_destroy(SdbList *list)
RZ_API void * ls_pop(SdbList *list)
RZ_API void ls_free(SdbList *list)
RZ_API SdbList * ls_clone(SdbList *list)
RZ_API bool ls_sort(SdbList *list, SdbListComparator cmp)
#define ls_foreach(list, it, pos)
RZ_API Sdb * sdb_ns(Sdb *s, const char *name, int create)
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API bool sdb_foreach(Sdb *s, SdbForeachCallback cb, void *user)
RZ_API SdbList * sdb_foreach_list(Sdb *s, bool sorted)
#define write_(fd, buf, count)
static char * sdbkv_key(const SdbKv *kv)
static char * sdbkv_value(const SdbKv *kv)
static int cmp_ns(const void *a, const void *b)
static bool load_ctx_init(LoadCtx *ctx, Sdb *s, char *buf, size_t sz)
static void write_path(int fd, SdbList *path)
static void write_key(int fd, const char *k)
RZ_API bool sdb_text_save(Sdb *s, const char *file, bool sort)
#define ESCAPE(c, repl, replsz)
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)
static void load_process_single_char(LoadCtx *ctx)
static bool text_save(Sdb *s, int fd, bool sort, SdbList *path)
static void load_ctx_fini(LoadCtx *ctx)
static bool save_kv_cb(void *user, const char *k, const char *v)
static void write_value(int fd, const char *v)
#define ESCAPE_LOOP(fd, str, escapes)
RZ_API bool sdb_text_save_fd(Sdb *s, int fd, bool sort)
static void load_process_line(LoadCtx *ctx)
static char unescape_raw_char(char c)
static bool load_process_final_line(LoadCtx *ctx)
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)