mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 22:00:18 +00:00
* Fix build
This commit is contained in:
parent
6099a388f6
commit
e8c4267543
53
libr/flags/sort.c
Normal file
53
libr/flags/sort.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* radare - LGPL - Copyright 2007-2011 pancake<nopcode.org> */
|
||||
#include <r_flags.h>
|
||||
|
||||
/* compare names */
|
||||
static int ncmp(const void *a, const void *b) {
|
||||
RFlagItem *fa = (RFlagItem *)a;
|
||||
RFlagItem *fb = (RFlagItem *)b;
|
||||
return strcmp (fa->name, fb->name);
|
||||
}
|
||||
|
||||
/* compare offsets */
|
||||
static int cmp(const void *a, const void *b) {
|
||||
RFlagItem *fa = (RFlagItem *)a;
|
||||
RFlagItem *fb = (RFlagItem *)b;
|
||||
if (fa->offset > fb->offset) return 1;
|
||||
else if (fa->offset < fb->offset) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_flag_sort(RFlag *f, int namesort) {
|
||||
int ret = R_FALSE;
|
||||
int changes;
|
||||
RFlagItem *flag, *fi = NULL;
|
||||
RListIter *iter, *it_elem;
|
||||
RList *tmp = r_list_new ();
|
||||
// find bigger ones after this
|
||||
do {
|
||||
changes = 0;
|
||||
fi = NULL;
|
||||
r_list_foreach (f->flags, iter, flag) {
|
||||
if (fi == NULL) {
|
||||
fi = flag;
|
||||
it_elem = iter;
|
||||
changes = 1;
|
||||
} else if (((namesort)? ncmp (fi, flag): cmp (fi, flag)) <= 0) {
|
||||
fi = flag;
|
||||
it_elem = iter;
|
||||
changes = 1;
|
||||
}
|
||||
}
|
||||
if (fi && changes) {
|
||||
ret = R_TRUE;
|
||||
r_list_split_iter (f->flags, it_elem);
|
||||
free (it_elem);
|
||||
r_list_append (tmp, fi);
|
||||
}
|
||||
} while (changes);
|
||||
|
||||
free (f->flags);
|
||||
f->flags = tmp;
|
||||
f->flags->free = free;
|
||||
return ret;
|
||||
}
|
@ -3,6 +3,7 @@ include ../../config.mk
|
||||
all: test${EXT_EXE}
|
||||
|
||||
test${EXT_EXE}:
|
||||
rm -f ../flags.o
|
||||
${CC} ${CFLAGS} -g -I ../../include test.c ../*.o -lr_util -L../../util -L../../cons -lr_cons -o test${EXT_EXE}
|
||||
|
||||
clean:
|
||||
|
@ -46,7 +46,7 @@ public class Radare.RSearch {
|
||||
//public int idx;
|
||||
public int count;
|
||||
|
||||
public Keyword.str (string str, string bmask, string data);
|
||||
public Keyword.str (string str, string bmask, string data, bool icase);
|
||||
//public Keyword.hex (string str, string bmask, string data);
|
||||
public Keyword (uint8 *s, int sl, uint8 *b, int bl, string data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user