From e8c426754347b9109ac910dd988d0d72542d0d28 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 21 May 2011 22:14:59 +0200 Subject: [PATCH] * Fix build --- libr/flags/sort.c | 53 ++++++++++++++++++++++++++++++++++ libr/flags/t/Makefile | 1 + r2-bindings/vapi/r_search.vapi | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 libr/flags/sort.c diff --git a/libr/flags/sort.c b/libr/flags/sort.c new file mode 100644 index 0000000000..81f49f3800 --- /dev/null +++ b/libr/flags/sort.c @@ -0,0 +1,53 @@ +/* radare - LGPL - Copyright 2007-2011 pancake */ +#include + +/* 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; +} diff --git a/libr/flags/t/Makefile b/libr/flags/t/Makefile index d139129ac8..162f72bc9b 100644 --- a/libr/flags/t/Makefile +++ b/libr/flags/t/Makefile @@ -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: diff --git a/r2-bindings/vapi/r_search.vapi b/r2-bindings/vapi/r_search.vapi index 531bfac80d..93546bfb66 100644 --- a/r2-bindings/vapi/r_search.vapi +++ b/r2-bindings/vapi/r_search.vapi @@ -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); }