Rizin
unix-like reverse engineering framework and cli tools
config.c File Reference
#include "rz_config.h"

Go to the source code of this file.

Functions

RZ_API RZ_OWN RzConfigNoderz_config_node_new (RZ_NONNULL const char *name, RZ_NONNULL const char *value)
 
RZ_API RZ_OWN RzConfigNoderz_config_node_clone (RzConfigNode *n)
 
RZ_API void rz_config_node_free (RZ_NULLABLE void *n)
 
RZ_API RZ_BORROW RzConfigNoderz_config_node_get (RzConfig *cfg, RZ_NONNULL const char *name)
 
RZ_API bool rz_config_set_getter (RzConfig *cfg, const char *key, RzConfigCallback cb)
 
RZ_API bool rz_config_set_setter (RzConfig *cfg, const char *key, RzConfigCallback cb)
 
RZ_API RZ_BORROW const char * rz_config_get (RzConfig *cfg, RZ_NONNULL const char *name)
 
RZ_API bool rz_config_toggle (RzConfig *cfg, RZ_NONNULL const char *name)
 
RZ_API ut64 rz_config_get_i (RzConfig *cfg, RZ_NONNULL const char *name)
 
RZ_API bool rz_config_get_b (RzConfig *cfg, RZ_NONNULL const char *name)
 
RZ_API const char * rz_config_node_type (RzConfigNode *node)
 
RZ_API RzConfigNoderz_config_set_cb (RzConfig *cfg, const char *name, const char *value, RzConfigCallback cb)
 
RZ_API RzConfigNoderz_config_set_i_cb (RzConfig *cfg, const char *name, int ivalue, RzConfigCallback cb)
 
static bool __is_true_or_false (const char *s)
 
RZ_API RzConfigNoderz_config_set_b (RzConfig *cfg, RZ_NONNULL const char *name, bool value)
 
RZ_API RzConfigNoderz_config_set (RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
 
RZ_API bool rz_config_add_node (RZ_BORROW RzConfig *cfg, RZ_OWN RzConfigNode *node)
 Appends the given node to the config cfg. More...
 
RZ_API const char * rz_config_desc (RzConfig *cfg, RZ_NONNULL const char *name, RZ_NULLABLE const char *desc)
 
RZ_API const char * rz_config_node_desc (RzConfigNode *node, RZ_NULLABLE const char *desc)
 
RZ_API bool rz_config_rm (RzConfig *cfg, RZ_NONNULL const char *name)
 
RZ_API void rz_config_node_value_format_i (char *buf, size_t buf_size, const ut64 i, RZ_NULLABLE RzConfigNode *node)
 
RZ_API RzConfigNoderz_config_set_i (RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
 
static int cmp (RzConfigNode *a, RzConfigNode *b)
 
RZ_API void rz_config_lock (RzConfig *cfg, int l)
 
RZ_API bool rz_config_readonly (RzConfig *cfg, const char *key)
 
RZ_API RzConfigrz_config_new (void *user)
 
RZ_API RzConfigrz_config_clone (RzConfig *cfg)
 
RZ_API void rz_config_free (RzConfig *cfg)
 
RZ_API void rz_config_visual_hit_i (RzConfig *cfg, const char *name, int delta)
 
RZ_API void rz_config_bump (RzConfig *cfg, const char *key)
 
RZ_API void rz_config_serialize (RZ_NONNULL RzConfig *config, RZ_NONNULL Sdb *db)
 
static bool load_config_cb (void *user, const char *k, const char *v)
 
RZ_API bool rz_config_unserialize (RZ_NONNULL RzConfig *config, RZ_NONNULL Sdb *db, RZ_NULLABLE char **err)
 
RZ_API bool rz_config_eval (RZ_NONNULL RzConfig *cfg, RZ_NONNULL const char *str)
 Sets the configuration variable and its value passed as argument. More...
 

Function Documentation

◆ __is_true_or_false()

static bool __is_true_or_false ( const char *  s)
static

Definition at line 193 of file config.c.

193  {
194  return s && (!rz_str_casecmp(s, "true") || !rz_str_casecmp(s, "false"));
195 }
static RzSocket * s
Definition: rtr.c:28
RZ_API int rz_str_casecmp(const char *dst, const char *orig)
Definition: str.c:121

References rz_str_casecmp(), and s.

Referenced by rz_config_set().

◆ cmp()

static int cmp ( RzConfigNode a,
RzConfigNode b 
)
static

Definition at line 472 of file config.c.

472  {
473  return strcmp(a->name, b->name);
474 }
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41

References a, and b.

Referenced by rz_config_lock().

◆ load_config_cb()

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

Definition at line 555 of file config.c.

555  {
556  RzConfig *config = user;
558  if (node) {
559  rz_config_set(config, k, v);
560  }
561  return true;
562 }
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
const char * k
Definition: dsignal.c:11
const char * v
Definition: dsignal.c:12

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

Referenced by rz_config_unserialize().

◆ rz_config_add_node()

RZ_API bool rz_config_add_node ( RZ_BORROW RzConfig cfg,
RZ_OWN RzConfigNode node 
)

Appends the given node to the config cfg.

Parameters
cfgThe configuration the node is appended.
nodeThe node to append.
Returns
bool True if the node was successful added. False otherwise.

Definition at line 362 of file config.c.

362  {
363  rz_return_val_if_fail(cfg && node, false);
364  if (cfg->lock) {
365  RZ_LOG_WARN("Config locked. Plugin config node not copied.\n");
366  rz_config_node_free(node);
367  return false;
368  }
369  ht_pp_insert(cfg->ht, node->name, node);
370  rz_list_append(cfg->nodes, node);
371  return true;
372 }
RZ_API void rz_config_node_free(RZ_NULLABLE void *n)
Definition: config.c:36
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56

References rz_config_node_free(), rz_list_append(), RZ_LOG_WARN, and rz_return_val_if_fail.

Referenced by set_plugin_configs().

◆ rz_config_bump()

RZ_API void rz_config_bump ( RzConfig cfg,
const char *  key 
)

Definition at line 539 of file config.c.

539  {
540  char *orig = strdup(rz_config_get(cfg, key));
541  if (orig) {
542  rz_config_set(cfg, key, orig);
543  free(orig);
544  }
545 }
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
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 static whence static length const void static len key
Definition: sflib.h:118
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
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")

References free(), key, rz_config_get(), rz_config_set(), and strdup().

◆ rz_config_clone()

RZ_API RzConfig* rz_config_clone ( RzConfig cfg)

Definition at line 507 of file config.c.

507  {
508  RzListIter *iter;
509  RzConfigNode *node;
510  RzConfig *c = rz_config_new(cfg->user);
511  if (!c) {
512  return NULL;
513  }
514  rz_list_foreach (cfg->nodes, iter, node) {
516  ht_pp_insert(c->ht, node->name, nn);
517  rz_list_append(c->nodes, nn);
518  }
519  c->lock = cfg->lock;
520  return c;
521 }
RZ_API RzConfig * rz_config_new(void *user)
Definition: config.c:490
RZ_API RZ_OWN RzConfigNode * rz_config_node_clone(RzConfigNode *n)
Definition: config.c:20
#define NULL
Definition: cris-opc.c:27
#define c(i)
Definition: sha256.c:43
RzList * nodes
Definition: rz_config.h:56
void * user
Definition: rz_config.h:54

References c, rz_config_t::lock, rz_config_node_t::name, rz_config_t::nodes, NULL, rz_config_new(), rz_config_node_clone(), rz_list_append(), and rz_config_t::user.

Referenced by rz_core_rtr_http_run().

◆ rz_config_desc()

RZ_API const char* rz_config_desc ( RzConfig cfg,
RZ_NONNULL const char *  name,
RZ_NULLABLE const char *  desc 
)

Definition at line 377 of file config.c.

377  {
379  RzConfigNode *node = rz_config_node_get(cfg, name);
380  return rz_config_node_desc(node, desc);
381 }
const char * desc
Definition: bin_vsf.c:19
RZ_API const char * rz_config_node_desc(RzConfigNode *node, RZ_NULLABLE const char *desc)
Definition: config.c:383
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68
Definition: z80asm.h:102

References desc, NULL, rz_config_node_desc(), rz_config_node_get(), rz_return_val_if_fail, and RZ_STR_ISNOTEMPTY.

Referenced by rz_core_config_init().

◆ rz_config_eval()

RZ_API bool rz_config_eval ( RZ_NONNULL RzConfig cfg,
RZ_NONNULL const char *  str 
)

Sets the configuration variable and its value passed as argument.

Parameters
cfgreference to RzConfig
strreference the configuration variable string (eg, 'asm.arch=x86')

Definition at line 575 of file config.c.

575  {
576  rz_return_val_if_fail(str, false);
577 
578  char *name = rz_str_trim_dup(str);
579  char *value = strchr(name, '=');
580  if (!value) {
581  free(name);
582  return false;
583  }
584  *value++ = 0;
585  rz_config_set(cfg, name, value);
586  free(name);
587  return true;
588 }
static int value
Definition: cmd_api.c:93
RZ_API char * rz_str_trim_dup(const char *str)
Definition: str_trim.c:78

References free(), rz_config_set(), rz_return_val_if_fail, rz_str_trim_dup(), cmd_descs_generate::str, and value.

Referenced by rz_diff_load_file_with_core(), rz_main_rizin(), and rz_main_rz_sign().

◆ rz_config_free()

RZ_API void rz_config_free ( RzConfig cfg)

Definition at line 523 of file config.c.

523  {
524  if (cfg) {
526  rz_list_free(cfg->nodes);
527  ht_pp_free(cfg->ht);
528  free(cfg);
529  }
530 }
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
HtPP * ht
Definition: rz_config.h:57
RzListFree free
Definition: rz_list.h:21

References rz_list_t::free, free(), rz_config_t::ht, rz_config_t::nodes, rz_config_node_free(), and rz_list_free().

Referenced by rz_core_fini(), and rz_core_rtr_http_run().

◆ rz_config_get()

RZ_API RZ_BORROW const char* rz_config_get ( RzConfig cfg,
RZ_NONNULL const char *  name 
)

Returns the value of the config variable of name as a string

Definition at line 75 of file config.c.

75  {
77  RzConfigNode *node = rz_config_node_get(cfg, name);
78  if (node) {
79  if (node->getter) {
80  node->getter(cfg->user, node);
81  }
82  if (rz_config_node_is_bool(node)) {
83  return rz_str_bool(rz_str_is_true(node->value));
84  }
85  return node->value;
86  } else {
87  RZ_LOG_DEBUG("rz_config_get: variable '%s' not found\n", name);
88  }
89  return NULL;
90 }
static bool rz_config_node_is_bool(RzConfigNode *node)
Definition: rz_config.h:117
#define RZ_LOG_DEBUG(fmtstr,...)
Definition: rz_log.h:49
RZ_API bool rz_str_is_true(const char *s)
Definition: str.c:3900
RZ_API const char * rz_str_bool(int b)
Definition: str.c:3896
RzConfigCallback getter
Definition: rz_config.h:44

References rz_config_node_t::getter, NULL, rz_config_node_get(), rz_config_node_is_bool(), RZ_LOG_DEBUG, rz_return_val_if_fail, rz_str_bool(), rz_str_is_true(), RZ_STR_ISNOTEMPTY, rz_config_t::user, and rz_config_node_t::value.

Referenced by __cons_cb_fkey(), __core_analysis_fcn(), __core_cmd_search_asm_infinite(), __init_menu_disasm_asm_settings_layout(), __init_menu_disasm_settings_layout(), __init_menu_screen_settings_layout(), __panels_process(), _CbInRangeSearchV(), agraph_print(), can_emulate_metadata(), cb_analysis_arch(), cb_asmarch(), cb_asmbits(), cb_asmcpu(), cb_asmos(), cb_asmplatform(), cb_cfgdebug(), cfgget(), cmd_pCd(), cmd_pCD(), cmd_print_format(), convert_dot_to_image(), core_analysis_graph_construct_nodes(), core_bin_file_print(), core_esil_init(), core_file_do_load_for_debug(), core_walk_function_blocks(), cursor_nextrow(), cursor_prevrow(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), do_asm_search(), dot_trace_traverse(), ds_init(), ds_print_data_type(), ds_print_fcn_name(), ds_print_ptr(), ds_print_relocs(), ds_print_str(), ds_show_flags(), ds_show_functions(), func_walk_blocks(), get_bits_comment(), getcommapath(), GetHeapGlobalsOffset(), graph_construct_nodes(), http_logf(), initialize_stack(), initializeEsil(), is_apple_target(), loadSystemPlugins(), mipsTweak(), myregwrite(), objc_analyze(), on_fcn_delete(), on_fcn_new(), on_fcn_rename(), parse_format(), parse_tmp_evals(), pr_bb(), print_graph_dot(), readline_callback(), reloc_set_flag(), rz_cmd_debug(), rz_cmd_info_pdb_download_handler(), rz_cmd_search(), rz_config_bump(), rz_config_hold_s(), rz_core_agraph_print_ascii(), rz_core_agraph_print_dot(), rz_core_agraph_print_interactive(), rz_core_analysis_callgraph(), rz_core_analysis_cc_init(), rz_core_analysis_esil_default(), rz_core_analysis_esil_init_mem(), rz_core_analysis_everything(), rz_core_analysis_fcn_name(), rz_core_analysis_function_until(), rz_core_analysis_graph(), rz_core_analysis_resolve_golang_strings(), rz_core_analysis_sigdb_apply(), rz_core_analysis_sigdb_list(), rz_core_analysis_type_init(), rz_core_analysis_value_pointers(), rz_core_bin_apply_symbols(), rz_core_bin_load(), rz_core_bin_pdb_get_filename(), rz_core_bin_relocs_print(), rz_core_cmd_foreach(), rz_core_cmd_subst_i(), rz_core_debug_breakpoint_hit(), rz_core_debug_syscall_hit(), rz_core_diff_show_function(), rz_core_disasm_pde(), rz_core_editor(), rz_core_egg_setup(), rz_core_file_loadlib(), rz_core_file_open(), rz_core_flirt_convert_file(), rz_core_flirt_create_file(), rz_core_fortune_get_random(), rz_core_fortune_list(), rz_core_get_boundaries_prot(), rz_core_graph_print(), rz_core_hack(), rz_core_hint_begin(), rz_core_magic_at(), rz_core_print_function_disasm_json(), rz_core_rtr_gdb_run(), rz_core_rtr_http_run(), rz_core_rtr_http_stop(), rz_core_run_script(), rz_core_search_preludes(), rz_core_search_rop(), rz_core_seek_next(), rz_core_seek_prev(), rz_core_serve(), rz_core_setup_debugger(), rz_core_sysenv_begin(), rz_core_visual(), rz_core_visual_cmd(), rz_core_visual_config_hud(), rz_core_visual_graph(), rz_core_visual_hud(), rz_core_visual_panels_root(), rz_core_visual_title(), rz_core_visual_xrefs(), rz_eval_editor_handler(), rz_eval_getset_handler(), rz_flirt_scan_handler(), rz_main_rizin(), rz_main_rz_bin(), rz_project_save_handler(), rz_seek_next_handler(), rz_seek_prev_handler(), rz_seek_search(), rz_types_open_file(), set_profile_string(), set_prompt(), set_tmp_arch(), set_tmp_bits(), step_until_inst(), symbols_print(), system_exec(), update_asmcpu_options(), visual_nkey(), and visual_refresh().

◆ rz_config_get_b()

RZ_API bool rz_config_get_b ( RzConfig cfg,
RZ_NONNULL const char *  name 
)

Reads the value of the config variable of name only and only if the variable is boolean. Returns false in case of the failure.

Definition at line 142 of file config.c.

142  {
144  RzConfigNode *node = rz_config_node_get(cfg, name);
145  if (!node) {
146  return false;
147  }
148  if (!rz_config_node_is_bool(node)) {
149  RZ_LOG_DEBUG("(error: '%s' is not a boolean variable)\n", name);
150  return false;
151  }
152  return rz_str_is_true(node->value);
153 }

References rz_config_node_get(), rz_config_node_is_bool(), RZ_LOG_DEBUG, rz_return_val_if_fail, rz_str_is_true(), RZ_STR_ISNOTEMPTY, and rz_config_node_t::value.

Referenced by __handle_print_rotate(), __init(), __init_almighty_db(), __insert_value(), __panels_process(), __panels_refresh(), __print_disassembly_cb(), __rotate_asmemu(), __set_breakpoints_on_cursor(), __watch_points_cb(), _CbInRangeAav(), analyze_function_at_flag(), basefind_create_pointer_map(), canWrite(), cb_asmarch(), cmd_print_bars(), core_analysis_graph_label(), core_file_do_load_for_debug(), debug_trace_calls(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), do_esil_search(), ds_build_op_str(), ds_init(), ds_newline(), ds_print_calls_hints(), ds_print_data_type(), ds_print_offset(), ds_print_relocs(), ds_show_flags(), ds_show_functions(), get_brks(), get_va_symbol(), hex_disasm_with_templates(), hex_set_pkt_info(), is_tcache(), meta_string_guess_add(), mipsTweak(), prompt_add_file(), prompt_add_offset(), prompt_add_section(), propagate_types_among_used_variables(), rotateAsmemu(), rz_analysis_function_add_recu_handler(), rz_analysis_function_analyze_args_handler(), rz_analyze_all_consecutive_functions_in_section_handler(), rz_analyze_all_functions_handler(), rz_analyze_symbols_entries_handler(), rz_cmd_debug_add_bp_handler(), rz_cmd_debug_add_bp_module_handler(), rz_cmd_debug_add_watchpoint_handler(), rz_cmd_disassemble_ropchain_handler(), rz_cmd_print(), rz_cmd_print_timestamp_hfs_handler(), rz_cmd_print_timestamp_ntfs_handler(), rz_cmd_print_timestamp_unix_handler(), rz_core_analysis_bytes(), rz_core_analysis_everything(), rz_core_analysis_il_step_with_events(), rz_core_analysis_refs(), rz_core_analysis_resolve_jumps(), rz_core_analysis_search_xrefs(), rz_core_analysis_sigdb_list(), rz_core_analysis_types_propagation(), rz_core_analysis_value_pointers(), rz_core_asm_bb_middle(), rz_core_bin_apply_classes(), rz_core_bin_apply_info(), rz_core_bin_apply_symbols(), rz_core_bin_basefind_print(), rz_core_bin_load(), rz_core_bin_options_init(), rz_core_debug_single_step_over(), rz_core_debug_step_over(), rz_core_debug_step_skip(), rz_core_diff_show(), rz_core_disasm_pde(), rz_core_disasm_pdi_with_buf(), rz_core_file_open(), rz_core_file_reopen(), rz_core_flirt_convert_file(), rz_core_flirt_create_file(), rz_core_get_boundaries_prot(), rz_core_io_file_open(), rz_core_notify_begin(), rz_core_notify_done(), rz_core_notify_error(), rz_core_print_disasm(), rz_core_print_scrollbar(), rz_core_print_scrollbar_bottom(), rz_core_prompt_loop(), rz_core_search_value_in_range(), rz_core_sym_name_init(), rz_core_sysenv_begin(), rz_core_visual(), rz_core_visual_bit_editor(), rz_core_visual_cmd(), rz_core_visual_disasm_down(), rz_core_visual_prompt(), rz_core_visual_prompt_input(), rz_core_visual_showcursor(), rz_core_visual_title(), rz_core_visual_toggle_hints(), rz_core_visual_xrefs(), rz_core_write_seq_at(), rz_heap_chunks_list(), rz_heap_resolve_main_arena(), rz_main_rizin(), rz_main_rz_bin(), rz_meta_string_wide16_handler(), rz_meta_string_wide32_handler(), rz_print_hexdump_hexl_common_handler(), rz_project_save_handler(), rz_write_debruijn_find_handler(), stackPrintCommand(), step_until_optype(), visual_comma(), and visual_responsive().

◆ rz_config_get_i()

RZ_API ut64 rz_config_get_i ( RzConfig cfg,
RZ_NONNULL const char *  name 
)

Reads the value of the config variable of name only and only if the variable is integer.

Definition at line 119 of file config.c.

119  {
121  RzConfigNode *node = rz_config_node_get(cfg, name);
122  if (node) {
123  if (node->getter) {
124  node->getter(cfg->user, node);
125  }
126  if (node->i_value || !strcmp(node->value, "false")) {
127  return node->i_value;
128  }
129  // TODO: Remove it once the switch to `rz_config_get_b()` is complete
130  if (!strcmp(node->value, "true")) {
131  return 1;
132  }
133  return (ut64)rz_num_math(cfg->num, node->value);
134  }
135  return (ut64)0LL;
136 }
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RzNum * num
Definition: rz_config.h:55
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References rz_config_node_t::getter, rz_config_node_t::i_value, rz_config_t::num, rz_config_node_get(), rz_num_math(), rz_return_val_if_fail, RZ_STR_ISNOTEMPTY, rz_config_t::user, ut64(), and rz_config_node_t::value.

Referenced by __call_visual_graph(), __check_if_mouse_x_on_edge(), __check_if_mouse_y_on_edge(), __core_analysis_fcn(), __core_visual_gogo(), __core_visual_print_command(), __create_new_canvas(), __direction_graph_cb(), __direction_hexdump_cb(), __direction_panels_cursor_cb(), __direction_stack_cb(), __handle_cursor_mode(), __init_panel_param(), __panels_check_stackbase(), __panels_process(), __prelude_cb_hit(), __print_stack_cb(), _analysis_calls(), _CbInRangeAav(), activateDieTime(), add_seek_history(), agraph_print(), agraph_refresh(), agraph_toggle_speed(), annotated_hexdump(), bin_dwarf(), cb_analysis_from(), cb_analysis_limits(), cb_asmos(), cfggeti(), check_changes(), check_function_modified(), cmd_aea(), cmd_analysis_esil(), cmd_analysis_graph(), cmd_analysis_trampoline(), cmd_p_minus_e(), cmd_pCd(), cmd_pCD(), cmd_pCx(), cmd_prc(), cmd_print_bars(), cmd_print_blocks(), cmd_print_pxA(), cmd_pxr(), config_visual_hit_i(), construct_rop_gadget(), core_analysis_bytes_desc(), core_analysis_bytes_esil(), core_analysis_bytes_size(), core_analysis_color_curr_node(), core_analysis_graph_construct_nodes(), core_analysis_graph_label(), core_bin_strings(), core_cmp_bits(), core_esil_init(), core_file_do_load_for_debug(), core_file_do_load_for_io_plugin(), core_perform_auto_analysis(), core_print_2bpp_tiles(), core_print_columns(), core_walk_function_blocks(), cursor_nextrow(), cursor_prevrow(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), disasm_strings(), disassemble_till_return_is_found(), do_asm_search(), do_debug_trace_calls(), do_esil_search(), do_handle_substitution_cmd(), do_syscall_search(), ds_init(), ds_print_data_type(), ds_print_esil_analysis_init(), ds_print_lines_left(), ds_print_offset(), ev_iowrite_cb(), find_autocomplete(), func_walk_blocks(), get_bbnodes(), get_bbupdate(), get_body(), get_esil_stack_name(), get_graph_string(), get_reg_color(), GetHeapGlobalsOffset(), handleMidFlags(), http_logf(), initializeEsil(), is_tcache(), mipsTweak(), mustSaveHistory(), num_callback(), objc_analyze(), open_core_file(), perform_mapped_file_yank(), pr_bb(), prevop_addr(), print_arena_stats(), print_color_node(), print_double_linked_list_bin(), print_double_linked_list_bin_graph(), print_heap_bin(), print_heap_fastbin(), print_rop(), prompt_add_offset(), readline_callback(), references_handler(), reloc_set_flag(), rizin_compare_words(), rop_classify_arithmetic(), rop_classify_arithmetic_const(), rop_classify_constant(), rop_classify_mov(), rop_classify_nops(), rotateAsmBits(), rotateAsmemu(), rotateColor(), rz_analysis_function_list_ascii_handler(), rz_analysis_functions_map_handler(), rz_cmd_debug(), rz_cmd_debug_list_maps_ascii_handler(), rz_cmd_disassemble_ropchain_handler(), rz_cmd_disassembly_all_possible_opcodes_handler(), rz_cmd_disassembly_all_possible_opcodes_treeview_handler(), rz_cmd_heap_chunks_print_handler(), rz_cmd_heap_tcache_print_handler(), rz_cmd_info_hashes_handler(), rz_cmd_info_pdb_download_handler(), rz_cmd_print(), rz_cmd_print_timestamp_hfs_handler(), rz_cmd_print_timestamp_unix_handler(), rz_cmd_search(), rz_config_hold_i(), rz_config_visual_hit_i(), rz_core_agraph_print_ascii(), rz_core_agraph_print_interactive(), rz_core_agraph_print_tiny(), rz_core_analysis_all(), rz_core_analysis_bbs_asciiart(), rz_core_analysis_bytes(), rz_core_analysis_callgraph(), rz_core_analysis_data(), rz_core_analysis_esil(), rz_core_analysis_esil_default(), rz_core_analysis_esil_emulate(), rz_core_analysis_everything(), rz_core_analysis_fcn(), rz_core_analysis_fcn_name(), rz_core_analysis_function_add(), rz_core_analysis_function_until(), rz_core_analysis_graph(), rz_core_analysis_graph_to(), rz_core_analysis_hasrefs_to_depth(), rz_core_analysis_optype_colorfor(), rz_core_analysis_paths(), rz_core_analysis_resolve_golang_strings(), rz_core_analysis_search(), rz_core_analysis_search_xrefs(), rz_core_analysis_sigdb_apply(), rz_core_analysis_value_pointers(), rz_core_bin_apply_dwarf(), rz_core_bin_basefind_print(), rz_core_bin_imports_print(), rz_core_bin_info_print(), rz_core_bin_load(), rz_core_bin_print_source_line_sample(), rz_core_bin_relocs_print(), rz_core_bin_whole_strings(), rz_core_clippy(), rz_core_cmd_pipe_old(), rz_core_cmd_subst_i(), rz_core_cmp_disasm_print(), rz_core_dbg_follow_seek_register(), rz_core_debug_bp_add_noreturn_func(), rz_core_debug_breakpoint_toggle(), rz_core_debug_esil(), rz_core_debug_step_over(), rz_core_debug_sync_bits(), rz_core_diff_show(), rz_core_disasm_instruction(), rz_core_disasm_pdi_with_buf(), rz_core_egg_setup(), rz_core_esil_step(), rz_core_extend_at(), rz_core_file_info_print(), rz_core_file_open(), rz_core_file_reopen(), rz_core_file_reopen_debug(), rz_core_file_reopen_remote_debug(), rz_core_flirt_convert_file(), rz_core_flirt_create_file(), rz_core_fortune_print_random(), rz_core_get_boundaries_prot(), rz_core_graph_print(), rz_core_help_vars_print(), rz_core_link_stroff(), rz_core_loadlibs(), rz_core_magic(), rz_core_magic_at(), rz_core_notify_begin(), rz_core_notify_done(), rz_core_notify_error(), rz_core_pdb_info_print(), rz_core_pdb_load_info(), rz_core_print_disasm_all(), rz_core_print_disasm_json(), rz_core_print_func_args(), rz_core_print_hexdump_or_hexdiff_str(), rz_core_print_scrollbar(), rz_core_rtr_add(), rz_core_rtr_cmd(), rz_core_rtr_cmds(), rz_core_rtr_gdb_cb(), rz_core_rtr_gdb_run(), rz_core_rtr_http_run(), rz_core_search_rop(), rz_core_seek_mark(), rz_core_serve(), rz_core_sysenv_begin(), rz_core_visual(), rz_core_visual_analysis(), rz_core_visual_analysis_refresh(), rz_core_visual_bit_editor(), rz_core_visual_cmd(), rz_core_visual_debugtraces(), rz_core_visual_disasm_down(), rz_core_visual_esil(), rz_core_visual_graph(), rz_core_visual_show_char(), rz_core_visual_title(), rz_core_visual_trackflags(), rz_core_write_at(), rz_core_write_value_at(), rz_core_write_value_inc_at(), rz_diff_graphs_files(), rz_flirt_scan_handler(), rz_heap_bin_content(), rz_heap_chunks_list(), rz_heap_tcache_content(), rz_heap_update_main_arena(), rz_main_rizin(), rz_main_rz_bin(), rz_open_binary_list_ascii_handler(), rz_open_maps_list_ascii_handler(), rz_print_hexdump_hexii_handler(), rz_regs_show_valgroup(), rz_seek_search(), rz_write_from_file_handler(), set_prompt(), set_tmp_bits(), show_analysis_classes(), show_class(), showcursor(), strings_print(), symbols_print(), type_match(), var_functions_show(), visual_refresh(), and visual_seek_animation().

◆ rz_config_lock()

RZ_API void rz_config_lock ( RzConfig cfg,
int  l 
)

Definition at line 476 of file config.c.

476  {
478  cfg->lock = l;
479 }
static int cmp(RzConfigNode *a, RzConfigNode *b)
Definition: config.c:472
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
Definition: list.c:743
int(* RzListComparator)(const void *value, const void *list_data)
Definition: rz_list.h:33

References cmp(), rz_config_t::lock, rz_config_t::nodes, and rz_list_sort().

Referenced by rz_asm_use(), and rz_core_config_init().

◆ rz_config_new()

RZ_API RzConfig* rz_config_new ( void *  user)

Definition at line 490 of file config.c.

490  {
491  RzConfig *cfg = RZ_NEW0(RzConfig);
492  if (!cfg) {
493  return NULL;
494  }
495  cfg->ht = ht_pp_new0();
497  if (!cfg->nodes) {
498  RZ_FREE(cfg);
499  return NULL;
500  }
501  cfg->user = user;
502  cfg->num = NULL;
503  cfg->lock = 0;
504  return cfg;
505 }
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_FREE(x)
Definition: rz_types.h:369

References rz_config_t::ht, rz_config_t::lock, rz_config_t::nodes, NULL, rz_config_t::num, rz_config_node_free(), RZ_FREE, rz_list_newf(), RZ_NEW0, and rz_config_t::user.

Referenced by rz_config_clone(), and rz_core_config_init().

◆ rz_config_node_clone()

RZ_API RZ_OWN RzConfigNode* rz_config_node_clone ( RzConfigNode n)

Definition at line 20 of file config.c.

20  {
23  if (!cn) {
24  return NULL;
25  }
26  cn->name = strdup(n->name);
27  cn->desc = n->desc ? strdup(n->desc) : NULL;
28  cn->value = strdup(n->value ? n->value : "");
29  cn->i_value = n->i_value;
30  cn->flags = n->flags;
31  cn->setter = n->setter;
32  cn->options = rz_list_clone(n->options);
33  return cn;
34 }
RZ_API RZ_OWN RzList * rz_list_clone(RZ_NONNULL const RzList *list)
Shallow copies of the list (but doesn't free its elements)
Definition: list.c:496
int n
Definition: mipsasm.c:19
RzList * options
Definition: rz_config.h:47
RzConfigCallback setter
Definition: rz_config.h:45

References rz_config_node_t::desc, rz_config_node_t::flags, rz_config_node_t::i_value, n, rz_config_node_t::name, NULL, rz_config_node_t::options, rz_list_clone(), RZ_NEW0, rz_return_val_if_fail, rz_config_node_t::setter, strdup(), and rz_config_node_t::value.

Referenced by rz_config_clone(), and set_plugin_configs().

◆ rz_config_node_desc()

RZ_API const char* rz_config_node_desc ( RzConfigNode node,
RZ_NULLABLE const char *  desc 
)

Definition at line 383 of file config.c.

383  {
385  if (desc) {
386  free(node->desc);
387  node->desc = strdup(desc);
388  }
389  return node->desc;
390 }

References desc, rz_config_node_t::desc, free(), NULL, rz_return_val_if_fail, and strdup().

Referenced by rz_config_desc().

◆ rz_config_node_free()

RZ_API void rz_config_node_free ( RZ_NULLABLE void *  n)

Definition at line 36 of file config.c.

36  {
37  RzConfigNode *node = (RzConfigNode *)n;
38  if (!node) {
39  return;
40  }
41  free(node->name);
42  free(node->desc);
43  free(node->value);
44  rz_list_free(node->options);
45  free(node);
46 }

References rz_config_node_t::desc, free(), n, rz_config_node_t::name, rz_config_node_t::options, rz_list_free(), and rz_config_node_t::value.

Referenced by rz_config_add_node(), rz_config_free(), and rz_config_new().

◆ rz_config_node_get()

◆ rz_config_node_new()

RZ_API RZ_OWN RzConfigNode* rz_config_node_new ( RZ_NONNULL const char *  name,
RZ_NONNULL const char *  value 
)

Definition at line 6 of file config.c.

6  {
9  if (!node) {
10  return NULL;
11  }
12  node->name = strdup(name);
13  node->value = strdup(value);
14  node->flags = CN_RW | CN_STR;
15  node->i_value = rz_num_get(NULL, value);
16  node->options = rz_list_new();
17  return node;
18 }
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
#define CN_STR
Definition: rz_config.h:19
#define CN_RW
Definition: rz_config.h:21
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
Definition: unum.c:172

References CN_RW, CN_STR, rz_config_node_t::flags, rz_config_node_t::i_value, rz_config_node_t::name, NULL, rz_config_node_t::options, rz_list_new(), RZ_NEW0, rz_num_get(), rz_return_val_if_fail, RZ_STR_ISNOTEMPTY, strdup(), value, and rz_config_node_t::value.

Referenced by rz_config_set(), rz_config_set_b(), and rz_config_set_i().

◆ rz_config_node_type()

RZ_API const char* rz_config_node_type ( RzConfigNode node)

Definition at line 155 of file config.c.

155  {
156  rz_return_val_if_fail(node, "");
157 
158  if (rz_config_node_is_bool(node)) {
159  return "bool";
160  }
161  if (rz_config_node_is_str(node)) {
162  return "str";
163  }
164  if (rz_config_node_is_int(node)) {
165  if (!strncmp(node->value, "0x", 2)) {
166  return "addr";
167  }
168  return "int";
169  }
170  return "";
171 }
static bool rz_config_node_is_int(RzConfigNode *node)
Definition: rz_config.h:120
static bool rz_config_node_is_str(RzConfigNode *node)
Definition: rz_config.h:126

References rz_config_node_is_bool(), rz_config_node_is_int(), rz_config_node_is_str(), rz_return_val_if_fail, and rz_config_node_t::value.

Referenced by config_print_node(), and rz_eval_type_handler().

◆ rz_config_node_value_format_i()

RZ_API void rz_config_node_value_format_i ( char *  buf,
size_t  buf_size,
const ut64  i,
RZ_NULLABLE RzConfigNode node 
)

Definition at line 403 of file config.c.

403  {
404  if (node && rz_config_node_is_bool(node)) {
406  return;
407  }
408  if (i < 1024) {
409  snprintf(buf, buf_size, "%" PFMT64d "", i);
410  } else {
411  snprintf(buf, buf_size, "0x%08" PFMT64x "", i);
412  }
413 }
lzma_index ** i
Definition: index.h:629
static int buf_size
Definition: debug_qnx.c:35
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
RZ_API size_t rz_str_ncpy(char *dst, const char *src, size_t n)
Secure string copy with null terminator.
Definition: str.c:923
#define PFMT64d
Definition: rz_types.h:394
#define PFMT64x
Definition: rz_types.h:393

References buf_size, i, PFMT64d, PFMT64x, rz_config_node_is_bool(), rz_str_bool(), rz_str_ncpy(), and snprintf.

Referenced by cb_color_getter(), and rz_config_set_i().

◆ rz_config_readonly()

RZ_API bool rz_config_readonly ( RzConfig cfg,
const char *  key 
)

Definition at line 481 of file config.c.

481  {
483  if (n) {
484  n->flags |= CN_RO;
485  return true;
486  }
487  return false;
488 }
#define CN_RO
Definition: rz_config.h:20

References CN_RO, key, n, and rz_config_node_get().

Referenced by rz_eval_readonly_handler().

◆ rz_config_rm()

RZ_API bool rz_config_rm ( RzConfig cfg,
RZ_NONNULL const char *  name 
)

Definition at line 392 of file config.c.

392  {
394  RzConfigNode *node = rz_config_node_get(cfg, name);
395  if (node) {
396  ht_pp_delete(cfg->ht, node->name);
397  rz_list_delete_data(cfg->nodes, node);
398  return true;
399  }
400  return false;
401 }
RZ_API bool rz_list_delete_data(RZ_NONNULL RzList *list, void *ptr)
Deletes an entry in the list by searching for a pointer.
Definition: list.c:148

References rz_config_t::ht, rz_config_node_t::name, rz_config_t::nodes, NULL, rz_config_node_get(), rz_list_delete_data(), rz_return_val_if_fail, and RZ_STR_ISNOTEMPTY.

Referenced by unset_plugins_config().

◆ rz_config_serialize()

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

Definition at line 547 of file config.c.

547  {
548  RzListIter *iter;
549  RzConfigNode *node;
550  rz_list_foreach (config->nodes, iter, node) {
551  sdb_set(db, node->name, node->value, 0);
552  }
553 }
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 config_path(), and rz_core_sysenv_begin().

◆ rz_config_set()

RZ_API RzConfigNode* rz_config_set ( RzConfig cfg,
RZ_NONNULL const char *  name,
const char *  value 
)

Writes the string value in the config variable of name.

Definition at line 267 of file config.c.

267  {
268  rz_return_val_if_fail(cfg && cfg->ht, NULL);
270 
271  char *ov = NULL;
272  ut64 oi;
273  RzConfigNode *node = rz_config_node_get(cfg, name);
274  if (node) {
275  if (rz_config_node_is_ro(node)) {
276  eprintf("(error: '%s' config key is read only)\n", name);
277  return node;
278  }
279  oi = node->i_value;
280  if (node->value) {
281  ov = strdup(node->value);
282  if (!ov) {
283  goto beach;
284  }
285  } else {
286  free(node->value);
287  node->value = strdup("");
288  }
289  if (rz_config_node_is_bool(node)) {
290  bool b = rz_str_is_true(value);
291  node->i_value = b ? 1 : 0;
292  char *value = strdup(rz_str_bool(b));
293  if (value) {
294  free(node->value);
295  node->value = value;
296  }
297  } else {
298  if (!value) {
299  free(node->value);
300  node->value = strdup("");
301  node->i_value = 0;
302  } else {
303  if (node->value == value) {
304  goto beach;
305  }
306  free(node->value);
307  node->value = strdup(value);
308  if (IS_DIGIT(*value) || (value[0] == '-' && IS_DIGIT(value[1]))) {
309  if (strchr(value, '/')) {
310  node->i_value = rz_num_get(cfg->num, value);
311  } else {
312  node->i_value = rz_num_math(cfg->num, value);
313  }
314  } else {
315  node->i_value = 0;
316  }
317  node->flags |= CN_INT;
318  }
319  }
320  } else { // Create a new RzConfigNode
321  oi = UT64_MAX;
322  if (!cfg->lock) {
323  node = rz_config_node_new(name, value);
324  if (node) {
325  if (__is_true_or_false(value)) {
326  node->flags |= CN_BOOL;
327  node->i_value = rz_str_is_true(value) ? 1 : 0;
328  }
329  ht_pp_insert(cfg->ht, node->name, node);
330  rz_list_append(cfg->nodes, node);
331  } else {
332  eprintf("rz_config_set: unable to create a new RzConfigNode\n");
333  }
334  } else {
335  eprintf("rz_config_set: variable '%s' not found\n", name);
336  }
337  }
338 
339  if (node && node->setter) {
340  if (!node->setter(cfg->user, node)) {
341  if (oi != UT64_MAX) {
342  node->i_value = oi;
343  }
344  free(node->value);
345  node->value = strdup(ov ? ov : "");
346  free(ov);
347  return NULL;
348  }
349  }
350 beach:
351  free(ov);
352  return node;
353 }
RZ_API RZ_OWN RzConfigNode * rz_config_node_new(RZ_NONNULL const char *name, RZ_NONNULL const char *value)
Definition: config.c:6
static bool __is_true_or_false(const char *s)
Definition: config.c:193
#define eprintf(x, y...)
Definition: rlcc.c:7
#define CN_BOOL
Definition: rz_config.h:14
static bool rz_config_node_is_ro(RzConfigNode *node)
Definition: rz_config.h:123
#define CN_INT
Definition: rz_config.h:15
#define IS_DIGIT(x)
Definition: rz_str_util.h:11
#define UT64_MAX
Definition: rz_types_base.h:86

References __is_true_or_false(), b, CN_BOOL, CN_INT, eprintf, rz_config_node_t::flags, free(), rz_config_t::ht, rz_config_node_t::i_value, IS_DIGIT, rz_config_t::lock, rz_config_node_t::name, rz_config_t::nodes, NULL, rz_config_t::num, rz_config_node_get(), rz_config_node_is_bool(), rz_config_node_is_ro(), rz_config_node_new(), rz_list_append(), rz_num_get(), rz_num_math(), rz_return_val_if_fail, rz_str_bool(), rz_str_is_true(), RZ_STR_ISNOTEMPTY, rz_config_node_t::setter, strdup(), rz_config_t::user, ut64(), UT64_MAX, value, and rz_config_node_t::value.

Referenced by __config_value_cb(), __handle_mouse_on_panel(), __rotate_asmemu(), __setsegoff(), analysis_emul_init(), applyDisMode(), cb_analysis_strings(), cb_asmarch(), cb_asmcpu(), cb_cfgdebug(), cb_dbgbackend(), cb_emustr(), cb_filepath(), cfgset(), cmd_pCd(), cmd_pCD(), cmd_Quit(), config_visual_hit(), core_analysis_graph_label(), core_esil_init(), core_walk_function_blocks(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), ds_print_esil_analysis(), func_walk_blocks(), initializeEsil(), load_config_cb(), loadGP(), parse_tmp_evals(), pr_bb(), rotateAsmemu(), rz_cmd_debug_handler_set_handler(), rz_cmd_info_purge_string_handler(), rz_cmd_panels(), rz_config_bump(), rz_config_eval(), rz_config_hold_restore(), rz_config_set_cb(), rz_core_analysis_everything(), rz_core_analysis_function_until(), rz_core_analysis_value_pointers(), rz_core_bin_apply_all_info(), rz_core_bin_apply_config(), rz_core_bin_load(), rz_core_cmd_foreach(), rz_core_cmd_subst_i(), rz_core_config_init(), rz_core_file_open(), rz_core_hint_begin(), rz_core_init(), rz_core_print_function_disasm_json(), rz_core_rtr_http_run(), rz_core_run_script(), rz_core_seek_arch_bits(), rz_core_set_asm_configs(), rz_core_setup_debugger(), rz_core_visual_applyDisMode(), rz_core_visual_applyHexMode(), rz_core_visual_cmd(), rz_core_visual_config_hud(), rz_core_visual_graph(), rz_core_visual_toggle_decompiler_disasm(), rz_core_visual_view_graph(), rz_core_visual_xrefs(), rz_diff_load_file_with_core(), rz_eval_editor_handler(), rz_eval_getset_handler(), rz_main_rizin(), rz_main_rz_bin(), rz_plugins_debug_print_handler(), rz_project_load(), rz_project_save_file(), rz_reopen_debug_rzrun_handler(), set_profile_string(), set_tmp_arch(), setab(), and setdiff().

◆ rz_config_set_b()

RZ_API RzConfigNode* rz_config_set_b ( RzConfig cfg,
RZ_NONNULL const char *  name,
bool  value 
)

Writes the boolean value in the config variable of name only and only if the variable is boolean.

Definition at line 201 of file config.c.

201  {
202  rz_return_val_if_fail(cfg && cfg->ht, NULL);
204 
205  char *ov = NULL;
206  ut64 oi = 0;
207  RzConfigNode *node = rz_config_node_get(cfg, name);
208  if (node) {
209  if (rz_config_node_is_ro(node)) {
210  RZ_LOG_DEBUG("(error: '%s' config key is read only)\n", name);
211  return node;
212  }
213 
214  oi = node->i_value;
215  if (node->value) {
216  ov = strdup(node->value);
217  }
218  if (rz_config_node_is_bool(node)) {
219  node->i_value = value ? 1 : 0;
220  char *svalue = strdup(rz_str_bool(value));
221  if (svalue) {
222  free(node->value);
223  node->value = svalue;
224  }
225  } else {
226  RZ_LOG_ERROR("(error: '%s' is not a boolean variable)\n", name);
227  free(ov);
228  return NULL;
229  }
230  } else {
231  if (!cfg->lock) {
233  if (!node) {
234  node = NULL;
235  goto beach;
236  }
237  node->flags = CN_RW | CN_BOOL;
238  node->i_value = value ? 1 : 0;
239  ht_pp_insert(cfg->ht, node->name, node);
240  if (cfg->nodes) {
241  rz_list_append(cfg->nodes, node);
242  }
243  } else {
244  RZ_LOG_ERROR("(locked: no new keys can be created (%s))\n", name);
245  }
246  }
247 
248  if (node && node->setter) {
249  if (!node->setter(cfg->user, node)) {
250  if (oi != UT64_MAX) {
251  node->i_value = oi;
252  }
253  free(node->value);
254  node->value = strdup(ov ? ov : "");
255  }
256  }
257 
258 beach:
259  free(ov);
260  return node;
261 }
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58

References CN_BOOL, CN_RW, rz_config_node_t::flags, free(), rz_config_t::ht, rz_config_node_t::i_value, rz_config_t::lock, rz_config_node_t::name, rz_config_t::nodes, NULL, rz_config_node_get(), rz_config_node_is_bool(), rz_config_node_is_ro(), rz_config_node_new(), rz_list_append(), RZ_LOG_DEBUG, RZ_LOG_ERROR, rz_return_val_if_fail, rz_str_bool(), RZ_STR_ISNOTEMPTY, rz_config_node_t::setter, strdup(), rz_config_t::user, ut64(), UT64_MAX, value, and rz_config_node_t::value.

Referenced by __insert_value(), __io_cache_off_cb(), __io_cache_on_cb(), __panels_refresh(), cb_cfgdebug(), cb_iopcache(), cb_iopcacheread(), cb_iopcachewrite(), rz_analyze_all_consecutive_functions_in_section_handler(), rz_analyze_all_functions_handler(), rz_core_analysis_esil_init_mem(), rz_core_analysis_everything(), rz_core_analysis_types_propagation(), rz_core_bin_load(), rz_core_debug_single_step_over(), rz_core_file_reopen_debug(), rz_core_file_reopen_remote_debug(), rz_core_io_file_open(), rz_core_visual_toggle_hints(), rz_core_visual_xrefs(), rz_diff_load_file_with_core(), rz_main_rz_sign(), and visual_responsive().

◆ rz_config_set_cb()

RZ_API RzConfigNode* rz_config_set_cb ( RzConfig cfg,
const char *  name,
const char *  value,
RzConfigCallback  cb 
)

Definition at line 173 of file config.c.

173  {
174  RzConfigNode *node = rz_config_set(cfg, name, value);
175  if (node && (node->setter = cb)) {
176  if (!cb(cfg->user, node)) {
177  return NULL;
178  }
179  }
180  return node;
181 }
static const char * cb[]
Definition: z80_tab.h:176

References cb, NULL, rz_config_set(), rz_config_node_t::setter, rz_config_t::user, and value.

Referenced by rz_core_config_init().

◆ rz_config_set_getter()

RZ_API bool rz_config_set_getter ( RzConfig cfg,
const char *  key,
RzConfigCallback  cb 
)

Definition at line 53 of file config.c.

53  {
54  rz_return_val_if_fail(cfg && key, false);
55  RzConfigNode *node = rz_config_node_get(cfg, key);
56  if (node) {
57  node->getter = cb;
58  return true;
59  }
60  return false;
61 }

References cb, rz_config_node_t::getter, key, rz_config_node_get(), and rz_return_val_if_fail.

Referenced by rz_core_config_init().

◆ rz_config_set_i()

RZ_API RzConfigNode* rz_config_set_i ( RzConfig cfg,
RZ_NONNULL const char *  name,
const ut64  i 
)

Writes the integer value in the config variable of name only and only if the variable is integer.

Definition at line 419 of file config.c.

419  {
420  char buf[128], *ov = NULL;
422  RzConfigNode *node = rz_config_node_get(cfg, name);
423  if (node) {
424  if (rz_config_node_is_ro(node)) {
425  node = NULL;
426  goto beach;
427  }
428  if (node->value) {
429  ov = strdup(node->value);
430  }
432  free(node->value);
433  node->value = strdup(buf);
434  if (!node->value) {
435  node = NULL;
436  goto beach;
437  }
438  node->i_value = i;
439  } else {
440  if (!cfg->lock) {
442  node = rz_config_node_new(name, buf);
443  if (!node) {
444  node = NULL;
445  goto beach;
446  }
447  node->flags = CN_RW | CN_INT;
448  node->i_value = i;
449  ht_pp_insert(cfg->ht, node->name, node);
450  if (cfg->nodes) {
451  rz_list_append(cfg->nodes, node);
452  }
453  } else {
454  RZ_LOG_ERROR("(locked: no new keys can be created (%s))\n", name);
455  }
456  }
457 
458  if (node && node->setter) {
459  ut64 oi = node->i_value;
460  int ret = node->setter(cfg->user, node);
461  if (!ret) {
462  node->i_value = oi;
463  free(node->value);
464  node->value = strdup(ov ? ov : "");
465  }
466  }
467 beach:
468  free(ov);
469  return node;
470 }
RZ_API void rz_config_node_value_format_i(char *buf, size_t buf_size, const ut64 i, RZ_NULLABLE RzConfigNode *node)
Definition: config.c:403

References CN_INT, CN_RW, rz_config_node_t::flags, free(), rz_config_t::ht, i, rz_config_node_t::i_value, rz_config_t::lock, rz_config_node_t::name, rz_config_t::nodes, NULL, rz_config_node_get(), rz_config_node_is_ro(), rz_config_node_new(), rz_config_node_value_format_i(), rz_list_append(), RZ_LOG_ERROR, rz_return_val_if_fail, rz_config_node_t::setter, strdup(), rz_config_t::user, ut64(), and rz_config_node_t::value.

Referenced by __call_visual_graph(), __direction_stack_cb(), __handle_cursor_mode(), __panels_process(), _analysis_calls(), agraph_print(), analysis_emul_init(), cb_analysis_cpu(), cb_asmarch(), cb_asmbits(), cfgseti(), cmd_analysis_graph(), cmd_pCx(), config_visual_hit(), config_visual_hit_i(), core_analysis_graph_construct_nodes(), core_analysis_graph_label(), core_file_do_load_for_debug(), core_walk_function_blocks(), cursor_nextrow(), cursor_prevrow(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), disasm_strings(), do_esil_search(), do_handle_substitution_cmd(), ds_disassemble(), func_walk_blocks(), get_body(), get_graph_string(), graph_construct_nodes(), handle_tmp_desc(), loadGP(), objc_analyze(), pr_bb(), references_handler(), rotateColor(), rz_analyze_cycles_handler(), rz_cmd_print(), rz_cmd_search(), rz_config_hold_restore(), rz_config_set_i_cb(), rz_config_toggle(), rz_config_visual_hit_i(), rz_core_agraph_print(), rz_core_agraph_print_interactive(), rz_core_agraph_print_tiny(), rz_core_analysis_esil_trace_start(), rz_core_analysis_esil_trace_stop(), rz_core_analysis_everything(), rz_core_analysis_function_until(), rz_core_analysis_graph(), rz_core_analysis_value_pointers(), rz_core_bin_apply_all_info(), rz_core_bin_apply_config(), rz_core_bin_load(), rz_core_cmd_pipe_old(), rz_core_cmd_subst_i(), rz_core_config_init(), rz_core_debug_attach(), rz_core_debug_sync_bits(), rz_core_disasm_pde(), rz_core_disasm_pdi_with_buf(), rz_core_file_open(), rz_core_file_reopen(), rz_core_file_reopen_debug(), rz_core_file_reopen_remote_debug(), rz_core_graph_print(), rz_core_init(), rz_core_link_stroff(), rz_core_print_bb_custom(), rz_core_print_function_disasm_json(), rz_core_rtr_http_run(), rz_core_seek_arch_bits(), rz_core_serve(), rz_core_set_asm_configs(), rz_core_setup_debugger(), rz_core_visual(), rz_core_visual_analysis(), rz_core_visual_cmd(), rz_core_visual_debugtraces(), rz_core_visual_graph(), rz_diff_load_file_with_core(), rz_heap_resolve_main_arena(), rz_main_rizin(), rz_main_rz_sign(), rz_seek_search(), set_color_default(), set_tmp_bits(), setab(), setprintmode(), and visual_responsive().

◆ rz_config_set_i_cb()

RZ_API RzConfigNode* rz_config_set_i_cb ( RzConfig cfg,
const char *  name,
int  ivalue,
RzConfigCallback  cb 
)

Definition at line 183 of file config.c.

183  {
184  RzConfigNode *node = rz_config_set_i(cfg, name, ivalue);
185  if (node && (node->setter = cb)) {
186  if (!node->setter(cfg->user, node)) {
187  return NULL;
188  }
189  }
190  return node;
191 }
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
Definition: config.c:419

References cb, NULL, rz_config_set_i(), rz_config_node_t::setter, and rz_config_t::user.

◆ rz_config_set_setter()

RZ_API bool rz_config_set_setter ( RzConfig cfg,
const char *  key,
RzConfigCallback  cb 
)

Definition at line 63 of file config.c.

63  {
64  RzConfigNode *node = rz_config_node_get(cfg, key);
65  if (node) {
66  node->setter = cb;
67  return true;
68  }
69  return false;
70 }

References cb, key, rz_config_node_get(), and rz_config_node_t::setter.

◆ rz_config_toggle()

RZ_API bool rz_config_toggle ( RzConfig cfg,
RZ_NONNULL const char *  name 
)

Reads the value of the config variable of name only and only if the variable is boolean, then tries to write back the inverted value. Returns true in case of success.

Definition at line 97 of file config.c.

97  {
99  RzConfigNode *node = rz_config_node_get(cfg, name);
100  if (!node) {
101  return false;
102  }
103  if (!rz_config_node_is_bool(node)) {
104  RZ_LOG_DEBUG("(error: '%s' is not a boolean variable)\n", name);
105  return false;
106  }
107  if (rz_config_node_is_ro(node)) {
108  RZ_LOG_DEBUG("(error: '%s' config key is read only)\n", name);
109  return false;
110  }
111  (void)rz_config_set_i(cfg, name, !node->i_value);
112  return true;
113 }

References rz_config_node_t::i_value, NULL, rz_config_node_get(), rz_config_node_is_bool(), rz_config_node_is_ro(), rz_config_set_i(), RZ_LOG_DEBUG, rz_return_val_if_fail, and RZ_STR_ISNOTEMPTY.

Referenced by __config_toggle_cb(), __handle_print_rotate(), rz_core_visual_analysis_classes(), rz_core_visual_classes(), rz_core_visual_cmd(), rz_core_visual_graph(), rz_core_visual_toggle_hints(), rz_core_visual_trackflags(), and rz_eval_bool_invert_handler().

◆ rz_config_unserialize()

RZ_API bool rz_config_unserialize ( RZ_NONNULL RzConfig config,
RZ_NONNULL Sdb db,
RZ_NULLABLE char **  err 
)

Definition at line 564 of file config.c.

564  {
566  return true;
567 }
static bool load_config_cb(void *user, const char *k, const char *v)
Definition: config.c:555
RZ_API bool sdb_foreach(Sdb *s, SdbForeachCallback cb, void *user)
Definition: sdb.c:758

References load_config_cb(), and sdb_foreach().

Referenced by rz_main_rz_bin().

◆ rz_config_visual_hit_i()

RZ_API void rz_config_visual_hit_i ( RzConfig cfg,
const char *  name,
int  delta 
)

Definition at line 532 of file config.c.

532  {
533  RzConfigNode *node = rz_config_node_get(cfg, name);
534  if (node && rz_config_node_is_int(node)) {
535  (void)rz_config_set_i(cfg, name, rz_config_get_i(cfg, name) + delta);
536  }
537 }
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
static st64 delta
Definition: vmenus.c:2425

References delta, rz_config_get_i(), rz_config_node_get(), rz_config_node_is_int(), and rz_config_set_i().