Rizin
unix-like reverse engineering framework and cli tools
serialize_config.c File Reference
#include <rz_util/rz_serialize.h>
#include <rz_config.h>

Go to the source code of this file.

Classes

struct  load_config_ctx_t
 

Typedefs

typedef struct load_config_ctx_t LoadConfigCtx
 

Functions

RZ_API void rz_serialize_config_save (RZ_NONNULL Sdb *db, RZ_NONNULL RzConfig *config)
 
static bool load_config_cb (void *user, const char *k, const char *v)
 
RZ_API bool rz_serialize_config_load (RZ_NONNULL Sdb *db, RZ_NONNULL RzConfig *config, RZ_NULLABLE const char *const *exclude, RZ_NULLABLE RzSerializeResultInfo *res)
 

Typedef Documentation

◆ LoadConfigCtx

Function Documentation

◆ load_config_cb()

static bool load_config_cb ( void *  user,
const char *  k,
const char *  v 
)
static

Definition at line 32 of file serialize_config.c.

32  {
33  LoadConfigCtx *ctx = user;
34  if (ctx->exclude && ht_pp_find_kv(ctx->exclude, k, NULL)) {
35  return true;
36  }
37  RzConfigNode *node = rz_config_node_get(ctx->config, k);
38  if (!node) {
39  return 1;
40  }
41  rz_config_set(ctx->config, k, v);
42  return 1;
43 }
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
Definition: config.c:267
RZ_API RZ_BORROW RzConfigNode * rz_config_node_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:48
#define NULL
Definition: cris-opc.c:27
const char * k
Definition: dsignal.c:11
const char * v
Definition: dsignal.c:12

References k, NULL, rz_config_node_get(), rz_config_set(), and v.

Referenced by rz_serialize_config_load().

◆ rz_serialize_config_load()

RZ_API bool rz_serialize_config_load ( RZ_NONNULL Sdb db,
RZ_NONNULL RzConfig config,
RZ_NULLABLE const char *const exclude,
RZ_NULLABLE RzSerializeResultInfo res 
)
Parameters
excludeNULL-terminated array of keys to not load from the sdb.

Definition at line 48 of file serialize_config.c.

49  {
51  if (exclude) {
52  ctx.exclude = ht_pp_new(NULL, NULL, NULL);
53  if (!ctx.exclude) {
54  return false;
55  }
56  for (; *exclude; exclude++) {
57  ht_pp_insert(ctx.exclude, *exclude, NULL);
58  }
59  }
61  ht_pp_free(ctx.exclude);
62  return true;
63 }
struct config_s config
RZ_API bool sdb_foreach(Sdb *s, SdbForeachCallback cb, void *user)
Definition: sdb.c:758
static bool load_config_cb(void *user, const char *k, const char *v)

References load_config_cb(), NULL, and sdb_foreach().

Referenced by rz_serialize_core_load().

◆ rz_serialize_config_save()

RZ_API void rz_serialize_config_save ( RZ_NONNULL Sdb db,
RZ_NONNULL RzConfig config 
)

Definition at line 19 of file serialize_config.c.

19  {
21  RzConfigNode *node;
22  rz_list_foreach (config->nodes, iter, node) {
23  sdb_set(db, node->name, node->value, 0);
24  }
25 }
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
Definition: sdb.c:611

References rz_config_node_t::name, sdb_set(), and rz_config_node_t::value.

Referenced by rz_serialize_core_save().