2010-01-26 13:06:41 +00:00
|
|
|
/* radare - LGPL - Copyright 2008-2010 pancake<nopcode.org> */
|
2009-02-17 09:59:26 +00:00
|
|
|
|
|
|
|
#include <r_flags.h>
|
|
|
|
|
2009-04-01 22:44:43 +00:00
|
|
|
R_API const char *r_flag_space_get(struct r_flag_t *f, int idx)
|
2009-02-17 09:59:26 +00:00
|
|
|
{
|
2009-05-28 10:57:30 +00:00
|
|
|
if (idx==-1 || idx>255 || f->space[idx]=='\0')
|
2009-02-17 09:59:26 +00:00
|
|
|
return "";
|
|
|
|
return f->space[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
void flag_space_init(struct r_flag_t *f)
|
|
|
|
{
|
|
|
|
static int init = 0;
|
|
|
|
int i;
|
|
|
|
if (init)
|
|
|
|
return;
|
|
|
|
init = 1;
|
|
|
|
for(i=0;i<R_FLAG_SPACES_MAX;i++)
|
|
|
|
f->space[i] = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-01 22:44:43 +00:00
|
|
|
R_API void r_flag_space_set(struct r_flag_t *f, const char *name)
|
2009-02-17 09:59:26 +00:00
|
|
|
{
|
|
|
|
int i;
|
2009-04-02 00:44:24 +00:00
|
|
|
if (name == NULL)
|
|
|
|
name = "noname";
|
|
|
|
|
2009-02-17 09:59:26 +00:00
|
|
|
for(i=0;i<R_FLAG_SPACES_MAX;i++) {
|
|
|
|
if (f->space[i] != NULL)
|
|
|
|
if (!strcmp(name, f->space[i])) {
|
|
|
|
f->space_idx = i; //flag_space_idx = i;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* not found */
|
|
|
|
for(i=0;i<R_FLAG_SPACES_MAX;i++) {
|
|
|
|
if (f->space[i] == NULL) {
|
|
|
|
f->space[i] = strdup(name);
|
|
|
|
f->space_idx = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-01 22:44:43 +00:00
|
|
|
R_API void r_flag_space_list(struct r_flag_t *f)
|
2009-02-17 09:59:26 +00:00
|
|
|
{
|
|
|
|
int i,j = 0;
|
|
|
|
for(i=0;i<R_FLAG_SPACES_MAX;i++) {
|
|
|
|
if (f->space[i])
|
|
|
|
printf("%02d %c %s\n", j++,
|
|
|
|
(i==f->space_idx)?'*':' ', f->space[i]);
|
|
|
|
}
|
|
|
|
}
|