diff --git a/binr/binr.mk b/binr/binr.mk index 5094aabc2e..18c007eefd 100644 --- a/binr/binr.mk +++ b/binr/binr.mk @@ -5,6 +5,7 @@ include ../../libr/config.mk CFLAGS+=-I../../libr/include CFLAGS+=-DVERSION=\"${VERSION}\" CFLAGS+=-DLIBDIR=\"${PREFIX}/lib\" + LIBS=$(subst r_,-lr_,$(DEPS)) LIBS+=$(subst r_,-L../../libr/,$(DEPS)) diff --git a/doc/fortunes b/doc/fortunes index fca7efc387..12a5c7c33a 100644 --- a/doc/fortunes +++ b/doc/fortunes @@ -107,3 +107,4 @@ A C program is like a fast dance on a newly waxed dance floor by people carrying radare2 is like windows 7 but even better Enlarge your radare2 Excellent; we can attack in any direction! +Better than an eel in the ass diff --git a/libr/lib/Makefile b/libr/lib/Makefile index 1fc061b322..405a1ce1ac 100644 --- a/libr/lib/Makefile +++ b/libr/lib/Makefile @@ -1,4 +1,5 @@ NAME=r_lib +DEPS=r_util OBJ=lib.o include ../config.mk diff --git a/libr/lib/lib.c b/libr/lib/lib.c index f0093deb57..bea109b07d 100644 --- a/libr/lib/lib.c +++ b/libr/lib/lib.c @@ -1,6 +1,7 @@ /* radare - LGPL - Copyright 2008-2010 pancake */ #include "r_types.h" +#include "r_util.h" #include "r_lib.h" #include #include @@ -30,6 +31,8 @@ static const char *r_lib_types[] = { "bp", "syscall", "fastcall", "crypto", "cmd", NULL }; +static int r_lib_debug_enabled = 0; + /* XXX: Rename this helper function */ R_API const char *r_lib_types_get(int idx) { if (idx<0||idx>R_LIB_TYPE_LAST) @@ -40,9 +43,9 @@ R_API const char *r_lib_types_get(int idx) { R_API void *r_lib_dl_open(const char *libname) { void *ret; ret = DLOPEN (libname); - if (ret == NULL) + if (r_lib_debug_enabled && ret == NULL) #if __UNIX__ - eprintf ("dlerror(%s): %s\n", libname, dlerror()); + eprintf ("dlerror(%s): %s\n", libname, dlerror ()); #else eprintf ("r_lib_dl_open: Cannot open '%s'\n", libname); #endif @@ -64,6 +67,7 @@ R_API RLib *r_lib_new(const char *symname) { lib = R_NEW (RLib); if (lib) { + r_lib_debug_enabled = r_sys_getenv ("R_DEBUG")?R_TRUE:R_FALSE; INIT_LIST_HEAD (&lib->handlers); INIT_LIST_HEAD (&lib->plugins); strncpy (lib->symname, symname, sizeof (lib->symname)-1); @@ -132,7 +136,6 @@ static int samefile(const char *a, const char *b) { ptr = strstr(sa, "//"); if (ptr) strcpy(ptr, ptr+1); } while(ptr); - do { ptr = strstr(sb, "//"); if (ptr) strcpy(ptr, ptr+1); @@ -187,11 +190,11 @@ R_API int r_lib_open(RLib *lib, const char *file) { ret = r_lib_run_handler(lib, p, stru); if (ret == R_FAIL) { - IFDBG fprintf(stderr, "Library handler has failed for '%s'\n", file); - free(p->file); - free(p); - r_lib_dl_close(handler); - } else list_add(&p->list, &lib->plugins); + IFDBG eprintf ("Library handler has failed for '%s'\n", file); + free (p->file); + free (p); + r_lib_dl_close (handler); + } else list_add (&p->list, &lib->plugins); return ret; } @@ -213,7 +216,7 @@ R_API int r_lib_opendir(RLib *lib, const char *path) { IFDBG eprintf ("Cannot open directory '%s'\n", path); return R_FALSE; } - while ((de = (struct dirent *)readdir(dh))) { + while ((de = (struct dirent *)readdir (dh))) { snprintf (file, sizeof (file), "%s/%s", path, de->d_name); if (r_lib_dl_check_filename (file)) r_lib_open (lib, file); @@ -234,7 +237,7 @@ R_API int r_lib_add_handler(RLib *lib, list_for_each_prev(pos, &lib->handlers) { RLibHandler *h = list_entry(pos, RLibHandler, list); if (type == h->type) { - IFDBG fprintf(stderr, "Redefining library handler constructor for %d\n", type); + IFDBG eprintf ("Redefining library handler constructor for %d\n", type); handler = h; break; } diff --git a/libr/lib/t/Makefile b/libr/lib/t/Makefile index 0d06fb9f47..f9b72ab408 100644 --- a/libr/lib/t/Makefile +++ b/libr/lib/t/Makefile @@ -7,7 +7,7 @@ plugin.${EXT_SO}: ${CC} -shared -Wall -o plugin.${EXT_SO} ${LDFLAGS_LIB} plugin.c -I../../include test-plugin${EXT_EXE}: - ${CC} -Wall -o test-plugin${EXT_EXE} test-plugin.c -I ../../include ../*.o ${DL_LIBS} + ${CC} -Wall -o test-plugin${EXT_EXE} test-plugin.c -lr_util -I../../include ../*.o ${DL_LIBS} clean: -rm -f plugin.${EXT_SO} test-plugin${EXT_EXE}