2014-03-27 15:34:17 +00:00
|
|
|
#ifndef R2_FLAGS_H
|
|
|
|
#define R2_FLAGS_H
|
2009-02-05 21:08:46 +00:00
|
|
|
|
|
|
|
#include <r_types.h>
|
2011-05-21 19:05:21 +00:00
|
|
|
#include <r_util.h>
|
2010-12-23 23:51:01 +00:00
|
|
|
#include <r_list.h>
|
2015-05-28 22:51:57 +00:00
|
|
|
#include <r_db.h>
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2013-06-18 10:09:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-06-14 00:51:33 +00:00
|
|
|
// TODO: rename to r_flags_XXX api
|
|
|
|
R_LIB_VERSION_HEADER(r_flag);
|
|
|
|
|
2015-04-11 02:33:37 +00:00
|
|
|
#define R_FLAG_NAME_SIZE 512
|
2015-11-08 22:38:42 +00:00
|
|
|
#define R_FLAG_SPACES_MAX 128
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_flag_item_t {
|
2016-02-22 09:18:08 +00:00
|
|
|
char *name; /* unique name, escaped to avoid issues with r2 shell */
|
|
|
|
char *realname; /* real name, without any escaping */
|
|
|
|
ut64 namehash; /* hash of the name, to be used as the key of the hashtable */
|
|
|
|
ut64 offset; /* offset flagged by this item */
|
|
|
|
ut64 size; /* size of the flag item */
|
|
|
|
int space; /* flag space this item belongs to */
|
|
|
|
char *color; /* item color */
|
|
|
|
char *comment; /* item comment */
|
|
|
|
char *alias; /* used to define a flag based on a math expression (e.g. foo + 3) */
|
2010-01-26 00:28:33 +00:00
|
|
|
} RFlagItem;
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_flag_t {
|
2016-02-22 09:18:08 +00:00
|
|
|
st64 base; /* base address for all flag items */
|
|
|
|
int space_idx; /* index of the selected space in spaces array */
|
|
|
|
bool space_strict; /* when true returned flag items must belong to the selected space */
|
|
|
|
char *spaces[R_FLAG_SPACES_MAX]; /* array of flag spaces */
|
2014-09-01 00:24:38 +00:00
|
|
|
RNum *num;
|
2016-02-22 09:18:08 +00:00
|
|
|
RHashTable64 *ht_off; /* hashmap key=item name, value=RList of items */
|
|
|
|
RHashTable64 *ht_name; /* hashmap key=item name, value=RList of items */
|
|
|
|
RList *flags; /* list of RFlagItem contained in the flag */
|
2015-04-03 18:38:34 +00:00
|
|
|
RList *spacestack;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RFlag;
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2014-09-26 12:24:33 +00:00
|
|
|
/* compile time dependency */
|
|
|
|
|
|
|
|
typedef RFlagItem* (*RFlagGet)(RFlag *f, const char *name);
|
2015-11-12 12:47:44 +00:00
|
|
|
typedef RFlagItem* (*RFlagGetAt)(RFlag *f, ut64 addr);
|
2014-09-26 12:24:33 +00:00
|
|
|
typedef RFlagItem* (*RFlagSet)(RFlag *f, const char *name, ut64 addr, ut32 size, int dup);
|
|
|
|
typedef int (*RFlagSetSpace)(RFlag *f, const char *name);
|
|
|
|
|
|
|
|
typedef struct r_flag_bind_t {
|
|
|
|
int init;
|
|
|
|
RFlag *f;
|
|
|
|
RFlagGet get;
|
2015-11-12 12:47:44 +00:00
|
|
|
RFlagGetAt get_at;
|
2014-09-26 12:24:33 +00:00
|
|
|
RFlagSet set;
|
|
|
|
RFlagSetSpace set_fs;
|
|
|
|
} RFlagBind;
|
|
|
|
|
|
|
|
#define r_flag_bind_init(x) memset(&x,0,sizeof(x))
|
|
|
|
R_API int r_flag_bind(RFlag *io, RFlagBind *bnd);
|
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
#ifdef R_API
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API RFlag * r_flag_new(void);
|
2010-04-09 15:13:35 +00:00
|
|
|
R_API RFlag * r_flag_free(RFlag *f);
|
2015-05-07 10:12:55 +00:00
|
|
|
R_API void r_flag_list(RFlag *f, int rad, const char *pfx);
|
2010-04-09 15:13:35 +00:00
|
|
|
R_API RFlagItem *r_flag_get(RFlag *f, const char *name);
|
|
|
|
R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off);
|
2013-09-03 20:45:43 +00:00
|
|
|
R_API RFlagItem *r_flag_get_i2(RFlag *f, ut64 off);
|
2016-02-22 09:18:08 +00:00
|
|
|
R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off);
|
2014-11-20 00:14:47 +00:00
|
|
|
R_API const RList* /*<RFlagItem*>*/ r_flag_get_list(RFlag *f, ut64 off);
|
2015-01-17 00:56:20 +00:00
|
|
|
R_API char *r_flag_get_liststr(RFlag *f, ut64 off);
|
2012-07-21 10:11:21 +00:00
|
|
|
R_API int r_flag_unset(RFlag *f, const char *name, RFlagItem *p);
|
|
|
|
R_API int r_flag_unset_i(RFlag *f, ut64 addr, RFlagItem *p);
|
2015-01-22 01:22:29 +00:00
|
|
|
R_API void r_flag_unset_all (RFlag *f);
|
2014-09-01 00:24:38 +00:00
|
|
|
R_API RFlagItem *r_flag_set(RFlag *fo, const char *name, ut64 addr, ut32 size, int dup);
|
2010-04-09 09:32:17 +00:00
|
|
|
R_API int r_flag_sort(RFlag *f, int namesort);
|
2014-09-24 09:37:59 +00:00
|
|
|
R_API int r_flag_item_set_name(RFlagItem *item, const char *name, const char *realname);
|
2014-09-01 00:24:38 +00:00
|
|
|
R_API void r_flag_item_set_alias(RFlagItem *item, const char *alias);
|
2012-10-26 08:00:22 +00:00
|
|
|
R_API void r_flag_item_free (RFlagItem *item);
|
|
|
|
R_API void r_flag_item_set_comment(RFlagItem *item, const char *comment);
|
2011-05-21 19:05:21 +00:00
|
|
|
R_API int r_flag_unset_glob(RFlag *f, const char *name);
|
|
|
|
R_API int r_flag_rename(RFlag *f, RFlagItem *item, const char *name);
|
2013-08-29 01:19:16 +00:00
|
|
|
R_API int r_flag_relocate (RFlag *f, ut64 off, ut64 off_mask, ut64 to);
|
2014-03-02 04:41:45 +00:00
|
|
|
R_API int r_flag_move (RFlag *f, ut64 at, ut64 to);
|
2014-08-18 23:47:02 +00:00
|
|
|
R_API const char *r_flag_color(RFlag *f, RFlagItem *it, const char *color);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-02-17 09:59:26 +00:00
|
|
|
/* spaces */
|
2011-02-17 00:34:29 +00:00
|
|
|
R_API int r_flag_space_get(RFlag *f, const char *name);
|
2011-02-16 23:58:54 +00:00
|
|
|
R_API const char *r_flag_space_get_i(RFlag *f, int idx);
|
2015-07-17 09:10:28 +00:00
|
|
|
R_API const char *r_flag_space_cur(RFlag *f);
|
2014-09-26 12:24:33 +00:00
|
|
|
R_API int r_flag_space_set(RFlag *f, const char *name);
|
2015-01-22 01:22:29 +00:00
|
|
|
R_API int r_flag_space_unset (RFlag *f, const char *fs);
|
2013-01-17 02:29:46 +00:00
|
|
|
R_API int r_flag_space_list(RFlag *f, int mode);
|
2013-03-07 22:47:41 +00:00
|
|
|
R_API int r_flag_space_rename (RFlag *f, const char *oname, const char *nname);
|
2015-04-03 18:38:34 +00:00
|
|
|
R_API int r_flag_space_pop(RFlag *f);
|
|
|
|
R_API int r_flag_space_push(RFlag *f, const char *name);
|
2009-12-24 02:17:53 +00:00
|
|
|
#endif
|
2009-02-17 09:59:26 +00:00
|
|
|
|
2013-06-18 10:09:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#endif
|