2009-02-05 22:08:46 +01:00
|
|
|
#ifndef _INCLUDE_R_CONFIG_H_
|
|
|
|
#define _INCLUDE_R_CONFIG_H_
|
|
|
|
|
|
|
|
#include "r_types.h"
|
|
|
|
#include "r_util.h"
|
2010-06-30 02:30:07 +02:00
|
|
|
#include "list.h" // TODO: port to r_list
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2013-06-18 12:09:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-06-14 02:51:33 +02:00
|
|
|
R_LIB_VERSION_HEADER(r_config);
|
|
|
|
|
2009-02-05 22:08:46 +01:00
|
|
|
#define CN_BOOL 0x000001
|
|
|
|
#define CN_INT 0x000002
|
|
|
|
#define CN_OFFT 0x000004
|
|
|
|
#define CN_STR 0x000008
|
|
|
|
#define CN_RO 0x000010
|
|
|
|
#define CN_RW 0x000020
|
|
|
|
|
2010-06-30 02:30:07 +02:00
|
|
|
typedef int (*RConfigCallback)(void *user, void *data);
|
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
typedef struct r_config_node_t {
|
2009-02-05 22:08:46 +01:00
|
|
|
char *name;
|
2011-03-17 19:05:39 +01:00
|
|
|
ut32 hash;
|
2009-02-05 22:08:46 +01:00
|
|
|
int flags;
|
|
|
|
char *value;
|
2009-07-08 13:49:55 +02:00
|
|
|
ut64 i_value;
|
|
|
|
ut64 *cb_ptr_q;
|
2009-02-05 22:08:46 +01:00
|
|
|
int *cb_ptr_i;
|
|
|
|
char **cb_ptr_s;
|
2010-06-30 02:30:07 +02:00
|
|
|
RConfigCallback callback;
|
2011-08-27 04:32:27 +02:00
|
|
|
char *desc;
|
2010-01-26 01:28:33 +01:00
|
|
|
} RConfigNode;
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
typedef struct r_config_t {
|
2009-02-05 22:08:46 +01:00
|
|
|
int lock;
|
|
|
|
int last_notfound;
|
|
|
|
int n_nodes;
|
2009-03-12 01:42:35 +00:00
|
|
|
void *user;
|
2012-08-13 04:33:01 +02:00
|
|
|
RNum *num;
|
2011-03-17 19:05:39 +01:00
|
|
|
PrintfCallback printf;
|
|
|
|
RList *nodes;
|
|
|
|
RHashTable *ht;
|
2010-01-26 01:28:33 +01:00
|
|
|
} RConfig;
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
#ifdef R_API
|
2010-02-12 00:43:11 +01:00
|
|
|
R_API RConfig *r_config_new(void *user);
|
|
|
|
R_API int r_config_free(RConfig *cfg);
|
2010-01-26 01:28:33 +01:00
|
|
|
R_API void r_config_lock(RConfig *cfg, int l);
|
|
|
|
R_API int r_config_eval(RConfig *cfg, const char *str);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API RConfigNode *r_config_set_i(RConfig *cfg, const char *name, const ut64 i);
|
|
|
|
R_API RConfigNode *r_config_set_cb(RConfig *cfg, const char *name, const char *value, int (*callback)(void *user, void *data));
|
|
|
|
R_API RConfigNode *r_config_set_i_cb(RConfig *cfg, const char *name, int ivalue, int (*callback)(void *user, void *data));
|
|
|
|
R_API RConfigNode *r_config_set(RConfig *cfg, const char *name, const char *value);
|
2011-08-27 04:32:27 +02:00
|
|
|
R_API int r_config_rm(RConfig *cfg, const char *name);
|
2010-01-26 01:28:33 +01:00
|
|
|
R_API ut64 r_config_get_i(RConfig *cfg, const char *name);
|
2010-04-06 14:23:12 +02:00
|
|
|
R_API const char *r_config_get(RConfig *cfg, const char *name);
|
2011-08-27 04:32:27 +02:00
|
|
|
R_API const char *r_config_desc(RConfig *cfg, const char *name, const char *desc);
|
2010-01-26 01:28:33 +01:00
|
|
|
R_API void r_config_list(RConfig *cfg, const char *str, int rad);
|
2010-02-12 00:43:11 +01:00
|
|
|
R_API RConfigNode *r_config_node_get(RConfig *cfg, const char *name);
|
|
|
|
R_API RConfigNode *r_config_node_new(const char *name, const char *value);
|
2010-01-26 01:28:33 +01:00
|
|
|
R_API int r_config_swap(RConfig *cfg, const char *name);
|
2012-09-07 10:07:41 +02:00
|
|
|
R_API int r_config_readonly (RConfig *cfg, const char *key);
|
2009-12-24 03:17:53 +01:00
|
|
|
#endif
|
2009-02-05 22:08:46 +01:00
|
|
|
|
2013-06-18 12:09:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-05 22:08:46 +01:00
|
|
|
#endif
|