diff --git a/configure b/configure index 2baed385e8..8aa4221ef2 100755 --- a/configure +++ b/configure @@ -436,7 +436,7 @@ for A in ${ENVWORDS} ; do SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;" done SEDFLAGS="${SEDFLAGS}'" -for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_io.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_bininfo.pc pkgcfg/r_anal.pc pkgcfg/r_hash.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc pkgcfg/r_meta.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_macro.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc pkgcfg/r_trace.pc pkgcfg/r_search.pc pkgcfg/r_vm.pc pkgcfg/r_var.pc pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc ; do # SUBDIRS +for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/libr.pc pkgcfg/r_io.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_bininfo.pc pkgcfg/r_anal.pc pkgcfg/r_hash.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc pkgcfg/r_meta.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_macro.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc pkgcfg/r_trace.pc pkgcfg/r_search.pc pkgcfg/r_vm.pc pkgcfg/r_var.pc pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc pkgcfg/r_lib.pc ; do # SUBDIRS if [ -f "${VPATH}/${A}.acr" ]; then SD_TARGET=${A} else diff --git a/configure.acr b/configure.acr index 3bb552c9c9..84791da291 100644 --- a/configure.acr +++ b/configure.acr @@ -83,4 +83,5 @@ SUBDIRS ./config-user.mk libr/include/r_userconf.h pkgcfg/r_th.pc pkgcfg/r_bp.pc pkgcfg/r_db.pc + pkgcfg/r_lib.pc ; diff --git a/libr/Makefile b/libr/Makefile index 43229aa89d..7d534931f8 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -25,15 +25,18 @@ libs: libr: .objs libr2.${EXT_SO} libr2.${EXT_AR} -# libr.a is not generated by default -libr2.${EXT_AR}: - ar -r libr2.${EXT_AR} .objs/*.o - ifeq ($(WITHPIC),1) libr2.${EXT_SO}: ${CC} -shared ${PIC_CFLAGS} .objs/*.o -o libr2.${EXT_SO} + +libr2.${EXT_AR}: + @echo No archive libr.a. Try --without-pic in configure + else libr2.${EXT_SO}: + +libr2.${EXT_AR}: + ar -r libr2.${EXT_AR} .objs/*.o endif # XXX needs autodetection of deps to remake and so.. diff --git a/libr/bp/bp.c b/libr/bp/bp.c index a4dcaaee7e..757376aa88 100644 --- a/libr/bp/bp.c +++ b/libr/bp/bp.c @@ -55,10 +55,10 @@ R_API int r_bp_get_bytes(struct r_bp_t *bp, ut8 *buf, int len, int endian, int i return 0; } -R_API rBreakpointItem *r_bp_at_addr(rBreakpoint *bp, ut64 addr, int rwx) +R_API RBreakpointItem *r_bp_at_addr(RBreakpoint *bp, ut64 addr, int rwx) { struct list_head *pos; - rBreakpointItem *b; + RBreakpointItem *b; eprintf ("===ataddr=== 0x%08llx\n", addr); list_for_each(pos, &bp->bps) { diff --git a/libr/bp/io.c b/libr/bp/io.c index e214d51b84..910df4937d 100644 --- a/libr/bp/io.c +++ b/libr/bp/io.c @@ -1,4 +1,7 @@ +/* radare - LGPL - Copyright 2009-2010 pancake */ + #include +#include "../config.h" // TODO: rename from r_debug_ ... #if 0 @@ -78,14 +81,14 @@ R_API int r_bp_restore(struct r_bp_t *bp, int set) return R_TRUE; } -R_API int r_bp_recoil(rBreakpoint *bp, ut64 addr) +R_API int r_bp_recoil(RBreakpoint *bp, ut64 addr) { - rBreakpointItem *b = r_bp_at_addr (bp, addr, 0xFFFFFF); -if (b) { - eprintf("HIT AT ADDR 0x%llx\n", addr); - eprintf(" recoil = %d\n", b->recoil); - eprintf(" size = %d\n", b->size); -} + RBreakpointItem *b = r_bp_at_addr (bp, addr, 0xFFFFFF); + if (b) { + eprintf("HIT AT ADDR 0x%llx\n", addr); + eprintf(" recoil = %d\n", b->recoil); + eprintf(" size = %d\n", b->size); + } if (b) if (!b->hw && ((b->addr + b->size) == addr)) return b->recoil; return 0; diff --git a/libr/cons/cons.c b/libr/cons/cons.c index 40417a1868..971ad093ed 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -36,8 +36,10 @@ static char *r_cons_buffer = NULL; static char *r_cons_lastline = NULL; char *r_cons_filterline = NULL; char *r_cons_teefile = NULL; -int r_cons_is_html = 0; -int r_cons_interactive = 1; +int r_cons_is_interactive = R_TRUE; +int r_cons_is_html = R_FALSE; +int r_cons_rows = 0; +int r_cons_columns = 0; int r_cons_lines = 0; int r_cons_noflush = 0; @@ -79,8 +81,13 @@ R_API void r_cons_break_end() R_API int r_cons_init() { r_cons_stdin_fd = stdin; + r_cons_breaked = R_FALSE; + r_cons_is_interactive = R_TRUE; + r_cons_is_html = R_FALSE; + r_cons_noflush = R_FALSE; + r_cons_get_size (NULL); #if HAVE_DIETLINE - r_line_init(); + r_line_init (); #endif //r_cons_palette_init(NULL); return 0; @@ -101,36 +108,19 @@ static void palloc(int moar) R_API int r_cons_eof() { - return feof(r_cons_stdin_fd); + return feof (r_cons_stdin_fd); } -/* XXX unused ? */ -#if 0 -static void r_cons_print_real(const char *buf) -{ -#if __WINDOWS__ - if (r_cons_stdout_fd == 1) - r_cons_w32_print(buf); - else -#endif - if (r_cons_is_html) - r_cons_html_print(buf); - else write(r_cons_stdout_fd, buf, r_cons_buffer_len); -} -#endif - R_API void r_cons_gotoxy(int x, int y) { #if __WINDOWS__ static HANDLE hStdout = NULL; COORD coord; - coord.X = x; coord.Y = y; if(!hStdout) hStdout = GetStdHandle(STD_OUTPUT_HANDLE); - SetConsoleCursorPosition(hStdout,coord); #else r_cons_strcat("\x1b[0;0H"); @@ -219,7 +209,7 @@ R_API void r_cons_grep(const char *str) if (*ptr) { free(grepstr); grepstr = (char *)strdup(ptr); - /* set the rest of words to grep */ + /* set the rest of words to grep */ grepstrings_n = 0; // TODO: refactor this ugly loop optr = grepstr; @@ -251,9 +241,10 @@ R_API void r_cons_flush() if (r_cons_noflush) return; - if (r_cons_interactive) { + if (r_cons_is_interactive) { if (r_cons_buffer_len > CONS_MAX_USER) { - if (r_cons_yesno('n', "Do you want to print %d bytes? (y/N)", r_cons_buffer_len)== 0) { + if (r_cons_yesno('n', "Do you want to print %d bytes? (y/N)", + r_cons_buffer_len)== 0) { r_cons_reset(); return; } @@ -263,11 +254,18 @@ R_API void r_cons_flush() if (tee&&tee[0]) { FILE *d = fopen(tee, "a+"); if (d != NULL) { - fwrite(r_cons_buffer, strlen(r_cons_buffer), 1, d); + fwrite (r_cons_buffer, strlen(r_cons_buffer), 1, d); fclose(d); } - // TODO: make this 'write' portable - } else write(1, r_cons_buffer, r_cons_buffer_len); + } else { + // is_html must be a filter, not a write endpoint + if (r_cons_is_html) r_cons_html_print (r_cons_buffer); else +#if __WINDOWS__ + r_cons_w32_print (r_cons_buffer); +#else + write (1, r_cons_buffer, r_cons_buffer_len); +#endif + } r_cons_reset(); } @@ -277,18 +275,13 @@ R_API void r_cons_printf(const char *format, ...) char buf[CONS_BUFSZ]; va_list ap; - if (strchr(format,'%')==NULL) { - r_cons_strcat(format); - return; - } - - va_start(ap, format); - - len = vsnprintf(buf, CONS_BUFSZ-1, format, ap); - if (len>0) - r_cons_memcat(buf, len); - - va_end(ap); + if (strchr (format, '%')) { + va_start (ap, format); + len = vsnprintf (buf, CONS_BUFSZ-1, format, ap); + if (len>0) + r_cons_memcat (buf, len); + va_end (ap); + } else r_cons_strcat (format); } /* TODO: use const char * instead ..strdup at the beggining? */ @@ -386,6 +379,8 @@ R_API void r_cons_newline() else r_cons_strcat("\n"); } +#if 0 +/* TODO: deprecated */ R_API int r_cons_get_columns() { int columns_i = r_cons_get_real_columns(); @@ -399,29 +394,28 @@ R_API int r_cons_get_columns() return columns_i; } +#endif -R_API int r_cons_get_real_columns() -{ +R_API int r_cons_get_size (int *rows) { + r_cons_columns = 80; + r_cons_rows = 23; #if __UNIX__ struct winsize win; - - if (ioctl(1, TIOCGWINSZ, &win)) { - /* default values */ - win.ws_col = 80; - win.ws_row = 23; + if (ioctl (1, TIOCGWINSZ, &win) == 0) { + r_cons_columns = win.ws_col; + r_cons_rows = win.ws_row; } -#ifdef RADARE_CORE - config.width = win.ws_col; - config.height = win.ws_row; -#endif - return win.ws_col; #else - return 80; + const char *str = r_sys_getenv ("COLUMNS"); + if (str != NULL) + r_cons_columns = atoi (str); #endif + if (rows) + *rows = r_cons_rows; + return r_cons_columns; } -R_API int r_cons_yesno(int def, const char *fmt, ...) -{ +R_API int r_cons_yesno(int def, const char *fmt, ...) { va_list ap; int key = def; va_start(ap, fmt); @@ -439,7 +433,6 @@ R_API int r_cons_yesno(int def, const char *fmt, ...) } /** - * * void r_cons_set_raw( [0,1] ) * * Change canonicality of the terminal @@ -471,8 +464,7 @@ R_API void r_cons_set_raw(int b) termios_init = 1; } tcsetattr(0, TCSANOW, &tio_new); - } else - tcsetattr(0, TCSANOW, &tio_old); + } else tcsetattr(0, TCSANOW, &tio_old); #else /* TODO : W32 */ #endif @@ -485,9 +477,9 @@ R_API void r_cons_set_raw(int b) R_API int r_cons_get_arrow(int ch) { #if 0 -printf("ARROW(0x%x)\n", ch); -fflush(stdout); -r_sys_sleep(3); + printf("ARROW(0x%x)\n", ch); + fflush(stdout); + r_sys_sleep(3); #endif if (ch==0x1b) { ch = r_cons_readchar(); @@ -501,10 +493,8 @@ r_sys_sleep(3); case 0x42: ch='j'; break; // down case 0x43: ch='l'; break; // right case 0x44: ch='h'; break; // left - case 0x3b: - break; - default: - ch = 0; + case 0x3b: break; + default: ch = 0; } } } diff --git a/libr/cons/print.c b/libr/cons/print.c index 40c03e859e..e2367a48d2 100644 --- a/libr/cons/print.c +++ b/libr/cons/print.c @@ -1,14 +1,15 @@ -/* radare - LGPL - Copyright 2009 pancake */ +/* radare - LGPL - Copyright 2009-2010 pancake */ #include -int r_cons_html_print(const char *ptr) +// XXX: rename char *r_cons_filter_html(const char *ptr) +R_API int r_cons_html_print(const char *ptr) { + const char *str = ptr; + int color = 0; int esc = 0; - const char *str = (char *)ptr; int len = 0; int inv = 0; - int color = 0; for (;ptr[0]; ptr = ptr + 1) { if (ptr[0] == '\n') { @@ -143,7 +144,7 @@ int r_cons_html_print(const char *ptr) } #if __WINDOWS__ -int r_cons_w32_print(unsigned char *ptr) +int r_cons_w32_print(ut8 *ptr) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); int esc = 0; @@ -278,8 +279,7 @@ int r_cons_w32_print(unsigned char *ptr) } len++; } - write(1, str, ptr-str); + write (1, str, ptr-str); return len; } #endif - diff --git a/libr/core/core.c b/libr/core/core.c index 3c80813985..b60ef4f7f1 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009 pancake */ +/* radare - LGPL - Copyright 2009-2010 pancake */ #include #include "../config.h" @@ -161,8 +161,9 @@ R_API int r_core_init(struct r_core_t *core) // XXX fix path here /* load plugins */ - r_core_loadlibs(core); - /* UH? */ + r_core_loadlibs (core); + + // TODO: get arch from r_bin or from native arch r_asm_use(&core->assembler, DEFAULT_ARCH); r_anal_use(&core->anal, DEFAULT_ARCH); r_bp_use(core->dbg.bp, DEFAULT_ARCH); @@ -174,6 +175,7 @@ R_API int r_core_init(struct r_core_t *core) R_API struct r_core_t *r_core_free(struct r_core_t *c) { + /* TODO: it leaks as shit */ free(c); return NULL; } diff --git a/libr/debug/debug.c b/libr/debug/debug.c index da257e71f0..b9f10e7a04 100644 --- a/libr/debug/debug.c +++ b/libr/debug/debug.c @@ -128,7 +128,7 @@ R_API int r_debug_step_over(struct r_debug_t *dbg, int steps) /* restore program counter after breakpoint hit */ static int r_debug_recoil(struct r_debug_t *dbg) { int recoil, ret = R_FALSE; - rRegisterItem *ri; + RRegisterItem *ri; r_debug_reg_sync (dbg, R_REG_TYPE_GPR, R_FALSE); ri = r_reg_get (dbg->reg, "eip", -1); if (ri) { diff --git a/libr/include/r_anal.h b/libr/include/r_anal.h index 358c9dd486..788a983607 100644 --- a/libr/include/r_anal.h +++ b/libr/include/r_anal.h @@ -9,7 +9,6 @@ #include "list.h" #define R_ANAL_NAME(x) "anal" R_LIB_SEPARATOR x - #define R_ANAL_MAXREG 16 enum { @@ -103,9 +102,9 @@ struct r_anal_refline_t { ut64 to; int index; struct list_head list; -}; +} RAnalysisRefline; -struct r_anal_aop_t { +typedef struct r_anal_aop_t { int type; /* type of opcode */ int stackop; /* operation on stack? */ int cond; /* condition type */ @@ -118,14 +117,14 @@ struct r_anal_aop_t { ut64 value; /* reference to value */ int r_dst[R_ANAL_MAXREG]; /* register arguments */ ut64 i_dst[R_ANAL_MAXREG]; /* inmediate arguments */ -}; +} RAnalysisAop; -struct r_anal_fcn_t { +typedef struct r_anal_function_t { ut64 from; ut64 to; -}; +} RAnalysisFunction; -struct r_anal_t { +typedef struct r_anal_t { int bits; int big_endian; ut64 pc; @@ -133,25 +132,25 @@ struct r_anal_t { struct r_anal_ctx_t *ctx; struct r_anal_handle_t *cur; struct list_head anals; -}; +} RAnalysis; -struct r_anal_ctx_t { +typedef struct r_anal_ctx_t { /* TODO: add more info here */ /* per opcode deep level */ /* per opcode stack size */ /* basic blocks */ int stacksize; struct r_anal_t *anal; -}; +} RAnalysisContext; -struct r_anal_handle_t { +typedef struct r_anal_handle_t { char *name; char *desc; int (*init)(void *user); int (*fini)(void *user); int (*aop)(struct r_anal_t *a, struct r_anal_aop_t *aop, void *data); struct list_head list; -}; +} RAnalysisHandle; /* anal.c */ #ifdef R_API diff --git a/libr/include/r_asm.h b/libr/include/r_asm.h index f3756b6cdb..bf7dcdc561 100644 --- a/libr/include/r_asm.h +++ b/libr/include/r_asm.h @@ -32,7 +32,7 @@ enum { typedef struct r_asm_fastcall_t { const char *arg[16]; -} rAsmFastcall; +} RAsmFastcall; typedef struct r_asm_aop_t { int inst_len; @@ -40,14 +40,14 @@ typedef struct r_asm_aop_t { char buf_asm[R_ASM_BUFSIZE]; char buf_hex[R_ASM_BUFSIZE]; char buf_err[R_ASM_BUFSIZE]; -} rAsmAop; +} RAsmAop; typedef struct r_asm_code_t { int len; ut8 *buf; char *buf_hex; char *buf_asm; -} rAsmCode; +} RAsmCode; typedef struct r_asm_t { int bits; @@ -58,7 +58,7 @@ typedef struct r_asm_t { struct r_asm_handle_t *cur; struct r_asm_fastcall_t *fastcall; struct list_head asms; -} rAsm; +} RAsm; // TODO: rename to handler? typedef struct r_asm_handle_t { @@ -75,7 +75,7 @@ typedef struct r_asm_handle_t { int (*set_subarch)(struct r_asm_t *a, const char *buf); struct r_asm_fastcall_t *fastcall[R_ASM_FASTCALL_ARGS]; struct list_head list; -} rAsmHandle; +} RAsmHandle; #ifdef R_API /* asm.c */ diff --git a/libr/include/r_bin.h b/libr/include/r_bin.h index f121a69b95..4d85757cc6 100644 --- a/libr/include/r_bin.h +++ b/libr/include/r_bin.h @@ -30,7 +30,7 @@ typedef struct r_bin_t { struct r_buf_t *buf; struct r_bin_handle_t *cur; struct list_head bins; -} rBin; +} RBin; typedef struct r_bin_handle_t { char *name; @@ -49,12 +49,12 @@ typedef struct r_bin_handle_t { struct r_bin_info_t* (*info)(struct r_bin_t *bin); struct r_bin_field_t* (*fields)(struct r_bin_t *bin); struct list_head list; -} rBinHandle; +} RBinHandle; typedef struct r_bin_entry_t { ut64 rva; ut64 offset; -} rBinEntry; +} RBinEntry; typedef struct r_bin_section_t { char name[R_BIN_SIZEOF_STRINGS]; @@ -64,7 +64,7 @@ typedef struct r_bin_section_t { ut64 offset; ut64 characteristics; int last; -} rBinSection; +} RBinSection; #define r_bin_Rarray struct r_bin_symbol_t typedef struct r_bin_symbol_t { @@ -77,7 +77,7 @@ typedef struct r_bin_symbol_t { ut64 size; ut64 ordinal; int last; -} rBinSymbol; +} RBinSymbol; typedef struct r_bin_import_t { char name[R_BIN_SIZEOF_STRINGS]; @@ -88,7 +88,7 @@ typedef struct r_bin_import_t { ut64 ordinal; ut64 hint; int last; -} rBinImport; +} RBinImport; typedef struct r_bin_string_t { char string[R_BIN_SIZEOF_STRINGS]; @@ -97,7 +97,7 @@ typedef struct r_bin_string_t { ut64 ordinal; ut64 size; int last; -} rBinString; +} RBinString; typedef struct r_bin_info_t { char type[R_BIN_SIZEOF_STRINGS]; @@ -109,14 +109,14 @@ typedef struct r_bin_info_t { char subsystem[R_BIN_SIZEOF_STRINGS]; int big_endian; ut64 dbg_info; -} rBinInfo; +} RBinInfo; typedef struct r_bin_field_t { char name[R_BIN_SIZEOF_STRINGS]; ut64 rva; ut64 offset; int last; -} rBinField; +} RBinField; typedef struct r_bin_obj_t { rArray entrys; @@ -125,8 +125,8 @@ typedef struct r_bin_obj_t { rArray imports; rArray strings; rArray fields; - rBinInfo info; -} rBinObject; + RBinInfo info; +} RBinObject; #ifdef R_API R_API int r_bin_add(struct r_bin_t *bin, struct r_bin_handle_t *foo); diff --git a/libr/include/r_bininfo.h b/libr/include/r_bininfo.h index 609217aa80..12a57e9908 100644 --- a/libr/include/r_bininfo.h +++ b/libr/include/r_bininfo.h @@ -15,7 +15,7 @@ #define R_BININFO_SIZEOF_NAMES 256 -// XXX: rename to rBinMeta...rBinDwarf..rBinFoo ??? rBininfo can be confusing with rBinInfo +// XXX: rename to rBinMeta...rBinDwarf..rBinFoo ??? RBininfo can be confusing with rBinInfo /* types */ typedef struct r_bininfo_t { const char *file; @@ -26,7 +26,7 @@ typedef struct r_bininfo_t { void *user; struct r_bininfo_handle_t *cur; struct list_head bins; -} rBininfo; +} RBininfo; typedef struct r_bininfo_handle_t { char *name; @@ -40,7 +40,7 @@ typedef struct r_bininfo_handle_t { int (*close)(struct r_bininfo_t *bin); int (*check)(struct r_bininfo_t *bin); struct list_head list; -} rBininfoHandle; +} RBininfoHandle; #ifdef R_API /* bininfo.c */ diff --git a/libr/include/r_bp.h b/libr/include/r_bp.h index f65945168f..d8ccb19a4b 100644 --- a/libr/include/r_bp.h +++ b/libr/include/r_bp.h @@ -13,7 +13,7 @@ typedef struct r_bp_arch_t { int length; int endian; const ut8 *bytes; -} rBreakpointArch; +} RBreakpointArch; enum { R_BP_TYPE_SW, @@ -30,7 +30,7 @@ typedef struct r_bp_handle_t { int nbps; struct r_bp_arch_t *bps; struct list_head list; -} rBreakpointHandler; +} RBreakpointHandler; typedef struct r_bp_item_t { ut64 addr; @@ -45,21 +45,21 @@ typedef struct r_bp_item_t { ut8 *bbytes; /* breakpoint bytes */ int pids[R_BP_MAXPIDS]; struct list_head list; -} rBreakpointItem; +} RBreakpointItem; -typedef int (*rBreakpointCallback)(void *user, int type, ut64 addr, int hw, int rwx); +typedef int (*RBreakpointCallback)(void *user, int type, ut64 addr, int hw, int rwx); typedef struct r_bp_t { int trace_all; ut64 trace_bp; int nbps; int stepcont; - rBreakpointCallback breakpoint; + RBreakpointCallback breakpoint; struct r_io_bind_t iob; // compile time dependency struct r_bp_handle_t *cur; struct list_head plugins; struct list_head bps; -} rBreakpoint; +} RBreakpoint; enum { R_BP_PROT_READ = 1, @@ -92,7 +92,7 @@ R_API int r_bp_add_fault(struct r_bp_t *bp, ut64 addr, int size, int rwx); R_API struct r_bp_item_t *r_bp_add_sw(struct r_bp_t *bp, ut64 addr, int size, int rwx); R_API struct r_bp_item_t *r_bp_add_hw(struct r_bp_t *bp, ut64 addr, int size, int rwx); -R_API rBreakpointItem *r_bp_at_addr(rBreakpoint *bp, ut64 addr, int rwx); +R_API RBreakpointItem *r_bp_at_addr(RBreakpoint *bp, ut64 addr, int rwx); R_API int r_bp_restore(struct r_bp_t *bp, int set); R_API int r_bp_recoil(struct r_bp_t *bp, ut64 addr); #endif diff --git a/libr/include/r_cmd.h b/libr/include/r_cmd.h index fd116245ae..714ff5729d 100644 --- a/libr/include/r_cmd.h +++ b/libr/include/r_cmd.h @@ -11,7 +11,7 @@ typedef struct r_cmd_item_t { char cmd[64]; char desc[128]; r_cmd_callback(callback); -} CmdItem; +} RCommandItem; typedef struct r_cmd_long_item_t { char cmd[64]; /* long command */ @@ -19,14 +19,14 @@ typedef struct r_cmd_long_item_t { char cmd_short[32]; /* short command */ char desc[128]; struct list_head list; -} CmdLongItem; +} RCommandLongItem; typedef struct r_cmd_t { void *data; r_cmd_nullcallback(nullcallback); struct list_head lcmds; struct r_cmd_item_t *cmds[255]; -} Cmd; +} RCommand; #ifdef R_API R_API int r_cmd_init(struct r_cmd_t *cmd); @@ -38,5 +38,4 @@ R_API int r_cmd_call(struct r_cmd_t *cmd, const char *command); R_API int r_cmd_call_long(struct r_cmd_t *cmd, const char *input); R_API char **r_cmd_args(struct r_cmd_t *cmd, int *argc); #endif - #endif diff --git a/libr/include/r_config.h b/libr/include/r_config.h index 780a6bf53b..aace5abcf6 100644 --- a/libr/include/r_config.h +++ b/libr/include/r_config.h @@ -23,7 +23,7 @@ typedef struct r_config_node_t { char **cb_ptr_s; int (*callback)(void *user, void *data); struct list_head list; -} rConfigNode; +} RConfigNode; typedef struct r_config_t { int lock; @@ -32,25 +32,25 @@ typedef struct r_config_t { void *user; void (*printf)(const char *str, ...); struct list_head nodes; -} rConfig; +} RConfig; #ifdef R_API R_API struct r_config_t *r_config_new(void *user); R_API int r_config_free(struct r_config_t *cfg); R_API int r_config_init(struct r_config_t *core, void *user); -R_API void r_config_lock(rConfig *cfg, int l); -R_API int r_config_eval(rConfig *cfg, const char *str); -R_API struct r_config_node_t *r_config_set_i(rConfig *cfg, const char *name, const ut64 i); -R_API struct r_config_node_t *r_config_set_cb(rConfig *cfg, const char *name, const char *value, int (*callback)(void *user, void *data)); -R_API struct r_config_node_t *r_config_set_i_cb(rConfig *cfg, const char *name, int ivalue, int (*callback)(void *user, void *data)); -R_API int r_config_rm(rConfig *cfg, const char *name); -R_API struct r_config_node_t *r_config_set(rConfig *cfg, const char *name, const char *value); -R_API ut64 r_config_get_i(rConfig *cfg, const char *name); -R_API const char *r_config_get(rConfig *cfg, const char *name); -R_API void r_config_list(rConfig *cfg, const char *str, int rad); -R_API struct r_config_node_t *r_config_node_get(rConfig *cfg, const char *name); +R_API void r_config_lock(RConfig *cfg, int l); +R_API int r_config_eval(RConfig *cfg, const char *str); +R_API struct r_config_node_t *r_config_set_i(RConfig *cfg, const char *name, const ut64 i); +R_API struct r_config_node_t *r_config_set_cb(RConfig *cfg, const char *name, const char *value, int (*callback)(void *user, void *data)); +R_API struct r_config_node_t *r_config_set_i_cb(RConfig *cfg, const char *name, int ivalue, int (*callback)(void *user, void *data)); +R_API int r_config_rm(RConfig *cfg, const char *name); +R_API struct r_config_node_t *r_config_set(RConfig *cfg, const char *name, const char *value); +R_API ut64 r_config_get_i(RConfig *cfg, const char *name); +R_API const char *r_config_get(RConfig *cfg, const char *name); +R_API void r_config_list(RConfig *cfg, const char *str, int rad); +R_API struct r_config_node_t *r_config_node_get(RConfig *cfg, const char *name); R_API struct r_config_node_t *r_config_node_new(const char *name, const char *value); -R_API int r_config_swap(rConfig *cfg, const char *name); +R_API int r_config_swap(RConfig *cfg, const char *name); #endif #endif diff --git a/libr/include/r_cons.h b/libr/include/r_cons.h index b6418c86a9..82fe784864 100644 --- a/libr/include/r_cons.h +++ b/libr/include/r_cons.h @@ -40,7 +40,6 @@ #define C_BGRAY "\x1b[1;38m" /* palette */ - #define CONS_PALETTE_SIZE 22 #define CONS_COLORS_SIZE 21 enum { @@ -77,7 +76,7 @@ enum { #define COLOR_AD C_GREEN #endif -/* XXX */ +/* XXX : global variables? or a struct with a singleton? */ extern FILE *stdin_fd; extern FILE *r_cons_stdin_fd; extern int r_cons_stdout_fd; @@ -87,7 +86,9 @@ extern const char *r_cons_palette_default; const char *r_cons_colors[CONS_COLORS_SIZE+1]; extern char r_cons_palette[CONS_PALETTE_SIZE][8]; extern const char *dl_prompt; -extern int r_cons_lines; +extern int r_cons_columns; +extern int r_cons_rows; +extern int r_cons_lines; // private or public? extern int r_cons_is_html; extern int r_cons_noflush; extern char *r_cons_filterline; @@ -128,11 +129,8 @@ R_API int r_cons_readchar(); R_API void r_cons_any_key(); R_API int r_cons_eof(); -/* colors */ R_API int r_cons_palette_init(const unsigned char *pal); - -R_API int r_cons_get_real_columns(); -R_API int r_cons_get_columns(); +R_API int r_cons_get_size(int *rows); R_API int r_cons_get_arrow(int ch); R_API int r_cons_html_print(const char *ptr); diff --git a/libr/include/r_core.h b/libr/include/r_core.h index 519e537837..8ab3178879 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -33,7 +33,7 @@ typedef struct r_core_file_t { int fd; int dbg; struct list_head list; -} rCoreFile; +} RCoreFile; typedef struct r_core_t { ut64 offset; @@ -65,7 +65,7 @@ typedef struct r_core_t { struct r_macro_t macro; struct r_config_t config; struct r_search_t *search; -} rCore; +} RCore; #ifdef R_API R_API int r_core_init(struct r_core_t *core); diff --git a/libr/include/r_crypto.h b/libr/include/r_crypto.h index cf21d3c179..99c99c3d31 100644 --- a/libr/include/r_crypto.h +++ b/libr/include/r_crypto.h @@ -26,7 +26,7 @@ typedef struct r_crypto_t { int output_size; void *user; struct list_head handlers; -} rCrypto; +} RCrypto; typedef struct r_crypto_handle_t { const char *name; @@ -38,7 +38,7 @@ typedef struct r_crypto_handle_t { int (*use)(const char *algo); int (*fini)(struct r_crypto_t *cry); struct list_head list; -} rCryptoHandle; +} RCryptoHandle; #ifdef R_API R_API struct r_crypto_t *r_crypto_init(struct r_crypto_t *cry, int hard); diff --git a/libr/include/r_db.h b/libr/include/r_db.h index b7466adfdd..200f7678c8 100644 --- a/libr/include/r_db.h +++ b/libr/include/r_db.h @@ -16,7 +16,7 @@ typedef struct r_db_t { int blocks_sz[R_DB_KEYS]; void *cb_user; int (*cb_free)(void *db, const void *item, void *user); -} rDatabase; +} RDatabase; typedef struct r_db_iter_t { struct r_db_t *db; @@ -25,7 +25,7 @@ typedef struct r_db_iter_t { int path[256]; /* for each depth level */ int ptr; /* pointer in block nodes (repeated childs) */ void *cur; -} rDatabaseIter; +} RDatabaseIter; /* table */ typedef struct r_db_table_t { @@ -34,7 +34,7 @@ typedef struct r_db_table_t { char *fmt; char *args; int *offset; -} rDatabaseTable; +} RDatabaseTable; #ifdef R_API R_API void r_db_init(struct r_db_t *db); diff --git a/libr/include/r_debug.h b/libr/include/r_debug.h index f98b96368d..dea20381ed 100644 --- a/libr/include/r_debug.h +++ b/libr/include/r_debug.h @@ -37,7 +37,7 @@ typedef struct r_debug_t { - list of mapped memory (from /proc/XX/maps) - list of managed memory (allocated in child...) */ -} rDebug; +} RDebug; /* TODO: pass dbg and user data pointer everywhere */ typedef struct r_debug_handle_t { @@ -54,7 +54,7 @@ typedef struct r_debug_handle_t { int (*wait)(int pid); int (*contsc)(int pid, int sc); /* registers */ - rBreakpointCallback breakpoint; + RBreakpointCallback breakpoint; int (*reg_read)(struct r_debug_t *dbg, int type, ut8 *buf, int size); char* (*reg_profile)(); int (*reg_write)(int pid, int type, const ut8 *buf, int size); //XXX struct r_regset_t regs); @@ -63,7 +63,7 @@ typedef struct r_debug_handle_t { int (*mem_free)(void *user, ut64 addr); struct list_head list; -} rDebugHandle; +} RDebugHandle; // TODO: rename to r_debug_process_t ? maybe a thread too ? typedef struct r_debug_pid_t { @@ -74,7 +74,7 @@ typedef struct r_debug_pid_t { struct list_head childs; struct r_debug_pid_t *parent; struct list_head list; -} rDebugPid; +} RDebugPid; #ifdef R_API R_API int r_debug_use(struct r_debug_t *dbg, const char *str); diff --git a/libr/include/r_diff.h b/libr/include/r_diff.h index b3298c4de4..617e3fe78a 100644 --- a/libr/include/r_diff.h +++ b/libr/include/r_diff.h @@ -14,7 +14,7 @@ typedef struct r_diff_op_t { ut64 b_off; const ut8 *b_buf; int b_len; -} rDiffOp; +} RDiffOp; typedef struct r_diff_t { ut64 off_a; @@ -23,7 +23,7 @@ typedef struct r_diff_t { void *user; int (*callback)(struct r_diff_t *d, void *user, struct r_diff_op_t *op); -} rDiff; +} RDiff; /* XXX: this api needs to be reviewed , constructor with offa+offb?? */ #ifdef R_API diff --git a/libr/include/r_flags.h b/libr/include/r_flags.h index c693f9cb78..cd687b8e8e 100644 --- a/libr/include/r_flags.h +++ b/libr/include/r_flags.h @@ -24,7 +24,7 @@ typedef struct r_flag_item_t { const char *cmd; unsigned char data[R_FLAG_BUF_SIZE]; // only take a minor part of the data struct list_head list; -} rFlagItem; +} RFlagItem; typedef struct r_flag_t { int space_idx; @@ -36,7 +36,7 @@ typedef struct r_flag_t { struct btree_node *ntree; /* index by name */ #endif struct list_head flags; -} rFlag; +} RFlag; #ifdef R_API R_API struct r_flag_t * r_flag_new(); diff --git a/libr/include/r_hash.h b/libr/include/r_hash.h index fa8b544c19..165d5439ef 100644 --- a/libr/include/r_hash.h +++ b/libr/include/r_hash.h @@ -41,7 +41,7 @@ typedef struct r_hash_t { SHA512_CTX sha512; int rst; ut8 digest[128]; -} rHash; +} RHash; #define R_HASH_SIZE_MD4 16 #define R_HASH_SIZE_MD5 16 diff --git a/libr/include/r_io.h b/libr/include/r_io.h index 18262f2196..edb3595114 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -1,8 +1,9 @@ #ifndef _LIB_R_IO_H_ #define _LIB_R_IO_H_ -#include "r_types.h" -#include "list.h" +#include +#include +#include #define R_IO_READ 4 #define R_IO_WRITE 2 @@ -22,7 +23,7 @@ typedef struct r_io_map_t { ut64 from; ut64 to; struct list_head list; -} rIoMap; +} RIoMap; /* stores write and seek changes */ #define R_IO_UNDOS 64 @@ -37,7 +38,7 @@ typedef struct r_io_undo_t { int fd[R_IO_UNDOS]; int idx; int limit; -} rIoUndo; +} RIoUndo; typedef struct r_io_undo_w_t { int set; @@ -46,7 +47,7 @@ typedef struct r_io_undo_w_t { ut8 *n; /* new data */ int len; /* length */ struct list_head list; -} rIoUndoWrite; +} RIoUndoWrite; typedef struct r_io_t { int fd; @@ -70,7 +71,7 @@ typedef struct r_io_t { struct list_head maps; struct list_head desc; struct list_head cache; -} rIo; +} RIo; //struct r_io_handle_fd_t { // ... store io changes here @@ -94,27 +95,27 @@ typedef struct r_io_handle_t { int (*handle_open)(struct r_io_t *io, const char *); //int (*handle_fd)(struct r_io_t *, int); int fds[R_IO_NFDS]; -} rIoHandle; +} RIoHandle; typedef struct r_io_list_t { struct r_io_handle_t *plugin; struct list_head list; -} rIoList; +} RIoList; -/* TODO: find better name... rIoSetFd_Callback? ..Func? .. too camels here */ -typedef int (*rIoSetFd)(rIo *io, int fd); -typedef int (*rIoReadAt)(rIo *io, ut64 addr, ut8 *buf, int size); -typedef int (*rIoWriteAt)(rIo *io, ut64 addr, const ut8 *buf, int size); +/* TODO: find better name... RIoSetFd_Callback? ..Func? .. too camels here */ +typedef int (*RIoSetFd)(RIo *io, int fd); +typedef int (*RIoReadAt)(RIo *io, ut64 addr, ut8 *buf, int size); +typedef int (*RIoWriteAt)(RIo *io, ut64 addr, const ut8 *buf, int size); /* compile time dependency */ typedef struct r_io_bind_t { int init; struct r_io_t *io; - rIoSetFd set_fd; - rIoReadAt read_at; - rIoWriteAt write_at; -} rIoBind; + RIoSetFd set_fd; + RIoReadAt read_at; + RIoWriteAt write_at; +} RIoBind; /* sections */ typedef struct r_io_section_t { @@ -125,7 +126,7 @@ typedef struct r_io_section_t { ut64 paddr; // offset on disk int rwx; struct list_head list; -} rIoSection; +} RIoSection; typedef struct r_io_cache_t { ut64 from; @@ -133,7 +134,7 @@ typedef struct r_io_cache_t { int size; ut8 *data; struct list_head list; -} rIoCache; +} RIoCache; typedef struct r_io_desc_t { int fd; @@ -141,7 +142,7 @@ typedef struct r_io_desc_t { char name[4096]; struct r_io_handle_t *handle; struct list_head list; -} rIoDesc; +} RIoDesc; #ifdef R_API #define r_io_bind_init(x) memset(&x,0,sizeof(x)) @@ -165,7 +166,7 @@ R_API int r_io_open(struct r_io_t *io, const char *file, int flags, int mode); R_API int r_io_open_as(struct r_io_t *io, const char *urihandler, const char *file, int flags, int mode); R_API int r_io_redirect(struct r_io_t *io, const char *file); R_API int r_io_set_fd(struct r_io_t *io, int fd); -R_API struct r_buf_t *r_io_read_buf(struct r_io_t *io, ut64 addr, int len); +R_API RBuffer *r_io_read_buf(struct r_io_t *io, ut64 addr, int len); R_API int r_io_read(struct r_io_t *io, ut8 *buf, int len); R_API int r_io_read_at(struct r_io_t *io, ut64 addr, ut8 *buf, int len); R_API ut64 r_io_read_i(struct r_io_t *io, ut64 addr, int sz, int endian); diff --git a/libr/include/r_lang.h b/libr/include/r_lang.h index 99cd2f9287..8e3edd9e89 100644 --- a/libr/include/r_lang.h +++ b/libr/include/r_lang.h @@ -9,7 +9,7 @@ typedef struct r_lang_t { void *user; struct list_head defs; struct list_head langs; -} rLang; +} RLang; typedef struct r_lang_handle_t { const char *name; @@ -22,14 +22,14 @@ typedef struct r_lang_handle_t { int (*run_file)(struct r_lang_t *user, const char *file); int (*set_argv)(struct r_lang_t *user, int argc, char **argv); struct list_head list; -} rLangHandle; +} RLangHandle; typedef struct r_lang_def_t { char *name; char *type; void *value; struct list_head list; -} rLangDef; +} RLangDef; #ifdef R_API R_API struct r_lang_t *r_lang_new(); @@ -49,5 +49,4 @@ R_API int r_lang_prompt(struct r_lang_t *lang); R_API int r_lang_define(struct r_lang_t *lang, const char *type, const char *name, void *value); R_API void r_lang_undef(struct r_lang_t *lang); #endif - #endif diff --git a/libr/include/r_lib.h b/libr/include/r_lib.h index 4923e6e54b..50caab15ca 100644 --- a/libr/include/r_lib.h +++ b/libr/include/r_lib.h @@ -29,7 +29,7 @@ typedef struct r_lib_plugin_t { struct r_lib_handler_t *handler; void *dl_handler; // DL HANDLER struct list_head list; -} rLibraryPlugin; +} RLibraryPlugin; /* store list of initialized plugin handlers */ typedef struct r_lib_handler_t { @@ -39,14 +39,14 @@ typedef struct r_lib_handler_t { int (*constructor)(struct r_lib_plugin_t *, void *user, void *data); int (*destructor)(struct r_lib_plugin_t *, void *user, void *data); struct list_head list; -} rLibraryHandler; +} RLibraryHandler; /* this structure should be pointed by the 'radare_plugin' symbol found in the loaded .so */ typedef struct r_lib_struct_t { int type; void *data; /* pointer to data handled by plugin handler */ -} rLibraryStruct; +} RLibraryStruct; //extern const char *r_lib_types[]; @@ -73,7 +73,7 @@ typedef struct r_lib_t { char symname[32]; struct list_head plugins; struct list_head handlers; -} rLibrary; +} RLibrary; #ifdef R_API R_API struct r_lib_t *r_lib_init(struct r_lib_t *lib, const char *symname); diff --git a/libr/include/r_macro.h b/libr/include/r_macro.h index 7934a3899b..feb1f90e84 100644 --- a/libr/include/r_macro.h +++ b/libr/include/r_macro.h @@ -11,7 +11,7 @@ typedef struct r_macro_label_t { char name[80]; char *ptr; -} rMacrolabel; +} RMacrolabel; typedef struct r_macro_item_t { char *name; @@ -19,7 +19,7 @@ typedef struct r_macro_item_t { char *code; int nargs; struct list_head list; -} rMacroItem; +} RMacroItem; typedef struct r_macro_t { int counter; @@ -33,7 +33,7 @@ typedef struct r_macro_t { int labels_n; struct r_macro_label_t labels[MACRO_LABELS]; struct list_head macros; -} rMacro; +} RMacro; #ifdef R_API R_API void r_macro_init(struct r_macro_t *mac); diff --git a/libr/include/r_meta.h b/libr/include/r_meta.h index 8423b86f2b..d49160a7b8 100644 --- a/libr/include/r_meta.h +++ b/libr/include/r_meta.h @@ -10,7 +10,7 @@ typedef struct r_meta_count_t { int xref_code; int xref_data; /* TODO: ... */ -} rMetaCount; +} RMetaCount; #if 0 TODO: @@ -30,14 +30,14 @@ typedef struct r_meta_item_t { // int times; char *str; struct list_head list; -} rMetaItem; +} RMetaItem; typedef struct r_meta_t { struct list_head data; // struct reflines_t *reflines = NULL; // struct list_head comments; // struct list_head xrefs; -} rMeta; +} RMeta; enum { R_META_WHERE_PREV = -1, diff --git a/libr/include/r_parse.h b/libr/include/r_parse.h index 1466deecb8..7cd8f78868 100644 --- a/libr/include/r_parse.h +++ b/libr/include/r_parse.h @@ -9,13 +9,13 @@ // XXX : remove this define??? #define R_PARSE_STRLEN 256 -struct r_parse_t { +typedef struct r_parse_t { void *user; struct r_parse_handle_t *cur; struct list_head parsers; -}; +} RParse; -struct r_parse_handle_t { +typedef struct r_parse_handle_t { char *name; char *desc; int (*init)(void *user); @@ -23,7 +23,7 @@ struct r_parse_handle_t { int (*parse)(struct r_parse_t *p, void *data, char *str); int (*assemble)(struct r_parse_t *p, char *data, char *str); struct list_head list; -}; +} RParseHandle; /* parse.c */ R_API struct r_parse_t *r_parse_new(); diff --git a/libr/include/r_print.h b/libr/include/r_print.h index 5239522d91..82b9012353 100644 --- a/libr/include/r_print.h +++ b/libr/include/r_print.h @@ -24,7 +24,7 @@ typedef struct r_print_t { int ocur; int flags; int addrmod; -} rPrint; +} RPrint; #ifdef R_API R_API struct r_print_t *r_print_new(); diff --git a/libr/include/r_range.h b/libr/include/r_range.h index b44744f408..ba948d35d9 100644 --- a/libr/include/r_range.h +++ b/libr/include/r_range.h @@ -5,20 +5,21 @@ #include "r_util.h" #include "list.h" -struct r_range_item_t { +typedef struct r_range_item_t { ut64 fr; ut64 to; ut8 *data; int datalen; struct list_head list; -}; +} RRangeItem; -struct r_range_t { +typedef struct r_range_t { int count; int changed; struct list_head ranges; -}; +} RRange; +#ifdef R_API int r_range_init(struct r_range_t *r); struct r_range_t *r_range_new(); struct r_range_t *r_range_new_from_string(const char *string); @@ -36,5 +37,5 @@ int r_range_percent(struct r_range_t *rgs); int r_range_list(struct r_range_t *rgs, int rad); int r_range_get_n(struct r_range_t *rgs, int n, ut64 *from, ut64 *to); struct r_range_t *r_range_inverse(struct r_range_t *rgs, ut64 from, ut64 to, int flags); - +#endif #endif diff --git a/libr/include/r_reg.h b/libr/include/r_reg.h index fd2988c967..299da99556 100644 --- a/libr/include/r_reg.h +++ b/libr/include/r_reg.h @@ -24,26 +24,26 @@ typedef struct r_reg_item_t { int offset; // offset in data structure int packed_size; /* 0 means no packed register, 1byte pack, 2b pack... */ struct list_head list; -} rRegisterItem; +} RRegisterItem; typedef struct r_reg_arena_t { ut8 *bytes; int size; struct list_head list; -} rRegisterArena; +} RRegisterArena; typedef struct r_reg_set_t { struct r_reg_arena_t *arena; struct list_head arenas; /* r_reg_arena_t */ struct list_head regs; /* r_reg_item_t */ -} rRegisterSet; +} RRegisterSet; typedef struct r_reg_t { char *profile; struct r_reg_set_t regset[R_REG_TYPE_LAST]; -} rRegister; +} RRegister; -#define r_reg_new() r_reg_init (MALLOC_STRUCT (rRegister)) +#define r_reg_new() r_reg_init (MALLOC_STRUCT (RRegister)) #ifdef R_API extern const char *r_reg_types[R_REG_TYPE_LAST+1]; diff --git a/libr/include/r_search.h b/libr/include/r_search.h index 16faae94a2..dafab9e6f7 100644 --- a/libr/include/r_search.h +++ b/libr/include/r_search.h @@ -29,16 +29,16 @@ typedef struct r_search_kw_t { int count; int kwidx; struct list_head list; -} rSearchKeyword; +} RSearchKeyword; typedef struct r_search_hit_t { ut64 addr; struct r_search_kw_t *kw; int len; struct list_head list; -} rSearchHit; +} RSearchHit; -typedef int (*rSearchCallback)(struct r_search_kw_t *kw, void *user, ut64 where); +typedef int (*RSearchCallback)(struct r_search_kw_t *kw, void *user, ut64 where); typedef struct r_search_t { int n_kws; @@ -48,11 +48,11 @@ typedef struct r_search_t { ut32 string_max; /* max number of matches */ void *user; /* user data */ //int (*callback)(struct r_search_kw_t *kw, void *user, ut64 where); - rSearchCallback callback; + RSearchCallback callback; //struct r_search_binparse_t *bp; struct list_head kws; //r_search_hw_t kws; struct list_head hits; //r_search_hit_t hits; -} rSearch; +} RSearch; #ifdef R_API R_API struct r_search_t *r_search_new(int mode); @@ -88,8 +88,7 @@ R_API int r_search_xrefs_update(struct r_search_t *s, ut64 from, const ut8 *buf, R_API int r_search_pattern(struct r_search_t *s, ut32 size); R_API int r_search_strings(struct r_search_t *s, ut32 min, ut32 max); //R_API int r_search_set_callback(struct r_search_t *s, int (*callback)(struct r_search_kw_t *, void *, ut64), void *user); -R_API int r_search_set_callback(struct r_search_t *s, rSearchCallback(callback), void *user); +R_API int r_search_set_callback(struct r_search_t *s, RSearchCallback(callback), void *user); R_API int r_search_begin(struct r_search_t *s); #endif - #endif diff --git a/libr/include/r_sign.h b/libr/include/r_sign.h index dba9c4528b..21bdaaee14 100644 --- a/libr/include/r_sign.h +++ b/libr/include/r_sign.h @@ -11,12 +11,12 @@ typedef struct r_sign_item_t { ut8 *bytes; ut32 csum; struct list_head list; -} rSignItem; +} RSignItem; typedef struct r_sign_t { int count; struct list_head items; -} rSign; +} RSign; #ifdef R_API R_API int r_sign_generate(struct r_sign_t *sig, const char *file, FILE *fd); diff --git a/libr/include/r_socket.h b/libr/include/r_socket.h index 3f58eea29e..f64da62484 100644 --- a/libr/include/r_socket.h +++ b/libr/include/r_socket.h @@ -8,8 +8,25 @@ /* struct r_socket_t *sock = r_socket_new(R_SOCKET_TCP, "gogle.com", 80); */ /* struct r_socket_t *sock = r_socket_proc_new(R_SOCKET_PROCESS, "/bin/ls", 80); */ -/* process */ +#ifdef R_API +#if __UNIX__ +R_API int r_socket_unix_connect(const char *file); +R_API int r_socket_unix_listen(const char *file); +#endif +R_API int r_socket_flush(int fd); +R_API void r_socket_block(int fd, int block); +R_API int r_socket_ready(int fd, int secs, int usecs); +R_API int r_socket_read(int fd, unsigned char *read, int len); +R_API int r_socket_puts(int fd, char *buf); +R_API int r_socket_write(int fd, void *buf, int len); +R_API int r_socket_connect(char *host, int port); +R_API int r_socket_listen(int port); +R_API int r_socket_accept(int fd); +R_API int r_socket_gets(int fd, char *buf, int size); +R_API void r_socket_printf(int fd, const char *fmt, ...); +R_API char *r_socket_to_string(int fd); +/* process */ struct r_socket_proc_t { int fd0[2]; int fd1[2]; @@ -24,28 +41,5 @@ R_API int r_socket_proc_close(struct r_socket_proc_t *sp); #define r_socket_proc_printf(x,y) r_socket_printf(x->fd0[1],y) #define r_socket_proc_ready(x,y,z) r_socket_ready(x->fd1[0],y,z) -// read from stdout of process is fd1[0] -// write to stdin of process is fd0[1] - - -/* socket */ - -#if __UNIX__ -R_API int r_socket_unix_connect(const char *file); -R_API int r_socket_unix_listen(const char *file); #endif - -R_API int r_socket_flush(int fd); -R_API void r_socket_block(int fd, int block); -R_API int r_socket_ready(int fd, int secs, int usecs); -R_API int r_socket_read(int fd, unsigned char *read, int len); -R_API int r_socket_puts(int fd, char *buf); -R_API int r_socket_write(int fd, void *buf, int len); -R_API int r_socket_connect(char *host, int port); -R_API int r_socket_listen(int port); -R_API int r_socket_accept(int fd); -R_API int r_socket_gets(int fd, char *buf, int size); -R_API void r_socket_printf(int fd, const char *fmt, ...); -R_API char *r_socket_to_string(int fd); - #endif diff --git a/libr/include/r_syscall.h b/libr/include/r_syscall.h index 1e579669e9..305fdf7a0c 100644 --- a/libr/include/r_syscall.h +++ b/libr/include/r_syscall.h @@ -4,25 +4,6 @@ #include "r_types.h" #include "list.h" -typedef struct r_syscall_list_t { - const char *name; - int swi; - int num; - int args; - char *sargs; -} rSyscallList; - - -// TODO: use this as arg to store state :) -typedef struct r_syscall_t { -#if 0 - int arch; // XXX char *?? - int os; -#endif - FILE *fd; - struct r_syscall_list_t *sysptr; -} rSyscall; - enum { R_SYSCALL_OS_LINUX = 0, R_SYSCALL_OS_NETBSD, @@ -39,7 +20,48 @@ enum { R_SYSCALL_ARCH_SPARC }; +typedef struct r_syscall_list_t { + const char *name; + int swi; + int num; + int args; + char *sargs; +} RSyscallList; + +// TODO: use this as arg to store state :) +typedef struct r_syscall_t { +#if 0 + int arch; // XXX char *?? + int os; +#endif + FILE *fd; + struct r_syscall_list_t *sysptr; +} RSyscall; + //#define R_SYSCALL_CTX struct r_syscall_t +/* plugin struct */ +typedef struct r_syscall_handle_t { + char *name; + char *arch; + char *os; + char *desc; + int bits; + int nargs; + struct r_syscall_args_t *args; + struct list_head list; +} RSyscallHandle; + +typedef struct r_syscall_arch_handle_t { + char *name; + char *arch; + char *desc; + int *bits; + int nargs; + struct r_syscall_args_t **args; + struct list_head list; +} RSyscallArchHandle; + +#ifdef R_API struct r_syscall_t *r_syscall_new(); void r_syscall_free(struct r_syscall_t *ctx); void r_syscall_init(struct r_syscall_t *ctx); @@ -50,27 +72,6 @@ int r_syscall_get(struct r_syscall_t *ctx, const char *str); struct r_syscall_list_t *r_syscall_get_n(struct r_syscall_t *ctx, int n); const char *r_syscall_get_i(struct r_syscall_t *ctx, int num, int swi); void r_syscall_list(struct r_syscall_t *ctx); - -/* plugin struct */ -struct r_syscall_handle_t { - char *name; - char *arch; - char *os; - char *desc; - int bits; - int nargs; - struct r_syscall_args_t *args; - struct list_head list; -}; - -struct r_syscall_arch_handle_t { - char *name; - char *arch; - char *desc; - int *bits; - int nargs; - struct r_syscall_args_t **args; - struct list_head list; -}; +#endif #endif diff --git a/libr/include/r_th.h b/libr/include/r_th.h index eab9e85f0a..cfb54d4bad 100644 --- a/libr/include/r_th.h +++ b/libr/include/r_th.h @@ -27,7 +27,7 @@ typedef struct r_th_lock_t { int refs; R_TH_LOCK_T lock; -} rThreadLock; +} RThreadLock; typedef struct r_th_t { R_TH_TID tid; @@ -38,12 +38,12 @@ typedef struct r_th_t { int breaked; // thread aims to be interruped int delay; // delay the startup of the thread N seconds int ready; // thread is properly setup -} rThread; +} RThread; typedef struct r_th_pool_t { int size; struct r_th_t **threads; -} rThreadPool; +} RThreadPool; #ifdef R_API R_API struct r_th_t *r_th_new(R_TH_FUNCTION(fun), void *user, int delay); diff --git a/libr/include/r_trace.h b/libr/include/r_trace.h index 288187b792..4c6269a4a3 100644 --- a/libr/include/r_trace.h +++ b/libr/include/r_trace.h @@ -1,7 +1,7 @@ /* radare - LGPL - Copyright 2009 pancake<@nopcode.org> */ -#ifndef _INCLUDE_R_ASM_H_ -#define _INCLUDE_R_ASM_H_ +#ifndef _INCLUDE_R_TRACE_H_ +#define _INCLUDE_R_TRACE_H_ #include #include @@ -13,7 +13,7 @@ typedef struct r_trace_t { int tag; int dup; int (*printf)(const char *str,...); -} rTrace; +} RTrace; typedef struct r_trace_item_t { ut64 addr; @@ -23,7 +23,7 @@ typedef struct r_trace_item_t { int count; struct timeval tm; struct list_head list; -} rTraceItem; +} RTraceItem; #ifdef R_API R_API int r_trace_init(struct r_trace_t *t); diff --git a/libr/include/r_types.h b/libr/include/r_types.h index a28637c0b1..41ac27ca17 100644 --- a/libr/include/r_types.h +++ b/libr/include/r_types.h @@ -52,7 +52,6 @@ #define R_FALSE 0 /* types */ - #undef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 #undef _GNU_SOURCE diff --git a/libr/include/r_util.h b/libr/include/r_util.h index aec89bb3f8..f144021074 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -18,7 +18,7 @@ typedef struct r_mem_pool_t { int nodesize; int poolsize; int poolcount; -} rMemPool; +} RMemoryPool; /* buf */ typedef struct r_buf_t { @@ -26,7 +26,7 @@ typedef struct r_buf_t { int length; int cur; ut64 base; -} rBuffer; +} RBuffer; /* r_cache */ // TOTHINK: move into a separated library? @@ -34,29 +34,29 @@ typedef struct r_cache_item_t { ut64 addr; char *str; struct list_head list; -} rCacheItem; +} RCacheItem; typedef struct r_cache_t { ut64 start; ut64 end; struct list_head items; -} rCache; +} RCache; typedef struct r_prof_t { struct timeval begin; double result; -} rProf; +} RProfile; /* numbers */ typedef struct r_num_t { ut64 (*callback)(void *userptr, const char *str, int *ok); ut64 value; void *userptr; -} rNum; -typedef ut64 (*rNumCallback)(rNum *self, const char *str, int *ok); +} RNum; +typedef ut64 (*RNumCallback)(RNum *self, const char *str, int *ok); #ifdef R_API -R_API struct r_num_t *r_num_new(rNumCallback *cb, void *ptr); +R_API struct r_num_t *r_num_new(RNumCallback *cb, void *ptr); #define R_BUF_CUR -1 R_API struct r_buf_t *r_buf_init(struct r_buf_t *b); @@ -75,7 +75,7 @@ R_API struct r_mem_pool_t *r_mem_pool_free(struct r_mem_pool_t *pool); R_API void* r_mem_pool_alloc(struct r_mem_pool_t *pool); R_API int r_mem_count(ut8 **addr); R_API void r_cache_init(struct r_cache_t *lang); -R_API rCache* r_cache_new(); +R_API RCache* r_cache_new(); R_API void r_cache_free(struct r_cache_t *c); R_API char *r_cache_get(struct r_cache_t *c, ut64 addr); R_API int r_cache_set(struct r_cache_t *c, ut64 addr, char *str); @@ -107,7 +107,7 @@ R_API void r_num_init(struct r_num_t *num); #define iswhitechar(x) (x==' '||x=='\t'||x=='\n'||x=='\r') #define iswhitespace(x) (x==' '||x=='\t') #define isseparator(x) (x==' '||x=='\t'||x=='\n'||x=='\r'||x==' '|| \ - x==','||x==';'||x==':'||x=='['||x==']'||x=='('||x==')'||x=='{'||x=='}') + x==','||x==';'||x==':'||x=='['||x==']'||x=='('||x==')'||x=='{'||x=='}') #define ishexchar(x) ((x>='0'&&x<='9') || (x>='a'&&x<='f') || (x>='A'&&x<='F')) { /* stabilized */ diff --git a/libr/include/r_var.h b/libr/include/r_var.h index 8abc38d14b..243ca69e4b 100644 --- a/libr/include/r_var.h +++ b/libr/include/r_var.h @@ -14,33 +14,33 @@ enum { R_VAR_TYPE_ARGREG }; -struct r_var_anal_t { +typedef struct r_var_anal_t { int type; int delta; int count; -}; +} RVariableAnalysis; -struct r_var_type_t { +typedef struct r_var_type_t { char name[128]; char fmt[128]; unsigned int size; struct list_head list; -}; +} RVariableType; -struct r_var_t { +typedef struct r_var_t { int anal_size; struct r_var_anal_t anal[R_VAR_ANAL_MAX]; struct list_head vartypes; struct list_head vars; -}; +} RVariable; -struct r_var_access_t { +typedef struct r_var_access_t { ut64 addr; int set; struct list_head list; -}; +} RVariableAccess; -struct r_var_item_t { +typedef struct r_var_item_t { int type; /* global, local... */ ut64 addr; /* address where it is used */ ut64 eaddr; /* address where it is used */ @@ -50,8 +50,9 @@ struct r_var_item_t { char vartype[128]; struct list_head access; /* list of accesses for this var */ struct list_head list; -}; +} RVariableItem; +#ifdef R_API /* api */ R_API struct r_var_t *r_var_new(); R_API void r_var_free(struct r_var_t *var); @@ -71,5 +72,6 @@ R_API int r_var_list(struct r_var_t *var, ut64 addr, int delta); R_API int r_var_anal_get(struct r_var_t *var, int type); R_API void r_var_anal_reset(struct r_var_t *var); R_API int r_var_anal_add(struct r_var_t *var, int type, int delta); +#endif #endif diff --git a/libr/include/r_vm.h b/libr/include/r_vm.h index 59e48a7b62..e604a99050 100644 --- a/libr/include/r_vm.h +++ b/libr/include/r_vm.h @@ -27,18 +27,18 @@ typedef struct r_vm_reg_t { char *get; char *set; struct list_head list; -} rVmReg; +} RVmReg; typedef struct r_vm_op_t { char opcode[32]; char code[1024]; struct list_head list; -} rVmOp; +} RVmOp; typedef struct r_vm_reg_type { int type; char *str; -} rVmRegType; +} RVmRegType; typedef struct r_vm_cpu_t { const char *pc; @@ -51,14 +51,14 @@ typedef struct r_vm_cpu_t { const char *a3; const char *ret; const char *zf; -} rVmCpu; +} RVmCpu; typedef struct r_vm_change_t { ut64 from; ut64 to; ut8 *data; struct list_head list; -} rVmChange; +} RVmChange; typedef struct r_vm_t { struct r_vm_reg_t *rec; @@ -73,12 +73,11 @@ typedef struct r_vm_t { int (*read)(void *user, ut64 addr, ut8 *buf, int len); int (*write)(void *user, ut64 addr, ut8 *buf, int len); void *user; -} rVm; +} RVm; #ifdef R_API R_API ut64 vm_reg_get(const char *name); R_API void vm_stack_push(ut64 _val); - #if 0 static ut64 r_vm_get_value(struct r_vm_t *vm, const char *str); static ut64 r_vm_get_math(struct r_vm_t *vm, const char *str); diff --git a/libr/io/io.c b/libr/io/io.c index 2103dfc6d7..453ccdcc24 100644 --- a/libr/io/io.c +++ b/libr/io/io.c @@ -26,10 +26,9 @@ R_API struct r_io_t *r_io_new() { return r_io_init (MALLOC_STRUCT (struct r_io_t)); } -R_API struct r_buf_t *r_io_read_buf(struct r_io_t *io, ut64 addr, int len) +R_API RBuffer *r_io_read_buf(struct r_io_t *io, ut64 addr, int len) { - struct r_buf_t *b; - b = MALLOC_STRUCT(struct r_buf_t); + RBuffer *b = MALLOC_STRUCT(RBuffer); b->buf = malloc(len); len = r_io_read_at(io, addr, b->buf, len); if (len<0) len = 0; diff --git a/libr/line/dietline.c b/libr/line/dietline.c index 834c668ed6..8f7859f07e 100644 --- a/libr/line/dietline.c +++ b/libr/line/dietline.c @@ -375,7 +375,7 @@ R_API char *r_line_readline(int argc, const char **argv) int ch, i, len = 0; int opt = 0; int gcomp = 0; /* grep completion */ - int columns = r_cons_get_real_columns()-2; + int columns = r_cons_get_size (NULL)-2; r_line_buffer_idx = r_line_buffer_len = 0; r_line_buffer[0]='\0'; @@ -424,7 +424,7 @@ R_API char *r_line_readline(int argc, const char **argv) buf[0] = ch; // printf("\x1b[K\r"); - columns = r_cons_get_real_columns ()-2; + columns = r_cons_get_size (NULL)-2; if (columns <1) columns = 40; if (r_line_echo) diff --git a/libr/reg/reg.c b/libr/reg/reg.c index 0b02194dc7..041ba373ef 100644 --- a/libr/reg/reg.c +++ b/libr/reg/reg.c @@ -104,7 +104,7 @@ static int r_reg_set_word(struct r_reg_item_t *item, int idx, char *word) { /* TODO: make this parser better and cleaner */ R_API int r_reg_set_profile_string(struct r_reg_t *reg, const char *str) { - rRegisterItem *item; + RRegisterItem *item; int ret = R_FALSE; int lastchar = 0; int chidx = 0; diff --git a/libr/util/num.c b/libr/util/num.c index de21ed7b93..b921b2f501 100644 --- a/libr/util/num.c +++ b/libr/util/num.c @@ -51,7 +51,7 @@ R_API void r_num_init(struct r_num_t *num) num->value = 0LL; } -R_API struct r_num_t *r_num_new(rNumCallback *cb, void *ptr) +R_API struct r_num_t *r_num_new(RNumCallback *cb, void *ptr) { struct r_num_t *num; num = (struct r_num_t*) malloc(sizeof(struct r_num_t)); diff --git a/libr/vapi/r_asm.vapi b/libr/vapi/r_asm.vapi index 4b93abaf29..d0e1ae86d6 100644 --- a/libr/vapi/r_asm.vapi +++ b/libr/vapi/r_asm.vapi @@ -1,82 +1,80 @@ /* radare - LGPL - Copyright 2009, 2010 nibble<.ds@gmail.com> */ -namespace Radare { +[Compact] +[CCode (cheader_filename="r_asm.h", cname="struct r_asm_t", free_function="r_asm_free", cprefix="r_asm_")] +public class Radare.RAsm { + [CCode (cprefix="R_ASM_ARCH_", cname="int")] + public enum Arch { + NONE, + X86, + ARM, + PPC, + M68K, + JAVA, + MIPS, + SPARC, + CSR, + MSIL, + OBJD, + BF + } + + [CCode (cprefix="R_ASM_SYNTAX_", cname="int")] + public enum Syntax { + NONE, + INTEL, + ATT + } + [Compact] - [CCode (cheader_filename="r_asm.h", cname="struct r_asm_t", free_function="r_asm_free", cprefix="r_asm_")] - public class rAsm { - [CCode (cprefix="R_ASM_ARCH_", cname="int")] - public enum Arch { - NONE, - X86, - ARM, - PPC, - M68K, - JAVA, - MIPS, - SPARC, - CSR, - MSIL, - OBJD, - BF - } - - [CCode (cprefix="R_ASM_SYNTAX_", cname="int")] - public enum Syntax { - NONE, - INTEL, - ATT - } - - [Compact] - [CCode (cname="struct r_asm_aop_t", destroy_function="" )] - public struct Aop { - public int inst_len; - public uint8 *buf; - public string buf_asm; - public string buf_hex; - public string buf_err; - //pointer - } - - [CCode (cname="struct r_asm_code_t", destroy_function="" )] - public struct Code { - public int len; - public uint8* buf; - public string buf_hex; - public string buf_asm; - } - - public int arch; - public int bits; - public bool big_endian; - public int syntax; - public int parser; - public uint64 pc; + [CCode (cname="struct r_asm_aop_t", destroy_function="" )] + public struct Aop { + public int inst_len; + public uint8 *buf; public string buf_asm; public string buf_hex; public string buf_err; - public void *aux; - - public rAsm(); - - public weak rAsm init(); - public int list(); - public bool use(string name); -// public bool set_arch(Asm.Arch arch); - public bool set_bits(int bits); - public bool set_syntax(Syntax syntax); - public bool set_pc(uint64 addr); - public bool set_big_endian(bool big); - //public bool set_parser(rAsm.Parser parser, parse_cb cb, void *aux); - public int disassemble(out Aop aop, uint8 *buf, uint64 length); - public int assemble(out Aop aop, string buf); - public Code? mdisassemble(uint8 *buf, uint64 length); - public Code? massemble(string buf); - public weak string fastcall(int idx, int num); - //public int parse(); - // This is the destructor - public void free(); + //pointer } - public static delegate int parse_cb(rAsm a); + [CCode (cname="struct r_asm_code_t", destroy_function="" )] + public struct Code { + public int len; + public uint8* buf; + public string buf_hex; + public string buf_asm; + } + + public int arch; + public int bits; + public bool big_endian; + public int syntax; + public int parser; + public uint64 pc; + public string buf_asm; + public string buf_hex; + public string buf_err; + public void *aux; + + public RAsm(); + + public weak RAsm init(); + public int list(); + public bool use(string name); +// public bool set_arch(Asm.Arch arch); + public bool set_bits(int bits); + public bool set_syntax(Syntax syntax); + public bool set_pc(uint64 addr); + public bool set_big_endian(bool big); + //public bool set_parser(RAsm.Parser parser, parse_cb cb, void *aux); + public int disassemble(out Aop aop, uint8 *buf, uint64 length); + public int assemble(out Aop aop, string buf); + public Code? mdisassemble(uint8 *buf, uint64 length); + public Code? massemble(string buf); +// public weak string fastcall(int idx, int num); + //public int parse(); + // This is the destructor + public void free(); + + public static delegate int parse_cb(RAsm a); } diff --git a/libr/vapi/r_bin.vapi b/libr/vapi/r_bin.vapi index 0a7a143f3b..df813b922e 100644 --- a/libr/vapi/r_bin.vapi +++ b/libr/vapi/r_bin.vapi @@ -4,11 +4,11 @@ namespace Radare { [Compact] [CCode (cname="struct r_bin_t", free_function="r_bin_free", cprefix="r_bin_")] - public class rBin { + public class RBin { public const string file; public int fd; - public rBin(); + public RBin(); //public int open(string file, bool rw, string? plugin_name = null); public int init(string file, int rw); @@ -17,11 +17,11 @@ namespace Radare { public Entrypoint get_entry(); // TODO: deprecate - public rList symbols; + public rList symbols; - //public rArray get_sections(); - //public rArray get_symbols(); - //public rArray get_imports(); + //public rArray get_sections(); + //public rArray get_symbols(); + //public rArray get_imports(); public Info* get_info(); public uint64 get_section_offset(string name); diff --git a/libr/vapi/r_bininfo.vapi b/libr/vapi/r_bininfo.vapi index 4ac5b5e438..eca37dc6a8 100644 --- a/libr/vapi/r_bininfo.vapi +++ b/libr/vapi/r_bininfo.vapi @@ -4,8 +4,8 @@ namespace Radare { [Compact] [CCode (cname="struct r_bininfo_t", free_function="r_bininfo_free", cprefix="r_bininfo_")] - public class rBininfo { - public rBininfo (); + public class RBininfo { + public RBininfo (); // XXX bad signature? public int get_line (uint64 addr, out string file, int len, int *line); public bool set_source_path (string path); diff --git a/libr/vapi/r_bp.vapi b/libr/vapi/r_bp.vapi index 3e3854759c..f90a60cba0 100644 --- a/libr/vapi/r_bp.vapi +++ b/libr/vapi/r_bp.vapi @@ -1,50 +1,47 @@ -/* radare - LGPL - Copyright 2009 pancake */ +/* radare - LGPL - Copyright 2009-2010 pancake */ + +[Compact] +[CCode (cheader_filename="r_bp.h", cname="struct r_bp_t", free_function="r_bp_free", cprefix="r_bp_")] +public class Radare.RBreakpoint { + public RBreakpoint (); + public bool use (string arch); + public void enable (uint64 addr, bool enabled); + public bool at_addr (uint64 addr, int rwx); + public Item add_sw (uint64 addr, int len, int rwx); + public Item add_hw (uint64 addr, int len, int rwx); + public bool add_fault (uint64 addr, int len, int rwx); + public int add_cond (string cond); + public bool del (uint64 addr); + public bool del_cond (int idx); + + /* TODO: deprecate the list() method.. language iterators should be enought */ + public int list (bool rad); + + [CCode (cprefix="R_BP_PROT_")] + public enum Protection { + READ, + WRITE, + EXEC + } + + [CCode (cprefix="R_BP_TYPE_")] + public enum Type { + SW, + HW, + COND + } -[CCode (cheader_filename="r_bp.h", cprefix="r_bp", lower_case_cprefix="r_bp_")] -namespace Radare { [Compact] - [CCode (cname="struct r_bp_t", free_function="r_bp_free", cprefix="r_bp_")] - public class rBreakpoint { - public rBreakpoint (); - public bool use (string arch); - public void enable (uint64 addr, bool enabled); - public bool at_addr (uint64 addr, int rwx); - public Item add_sw (uint64 addr, int len, int rwx); - public Item add_hw (uint64 addr, int len, int rwx); - public bool add_fault (uint64 addr, int len, int rwx); - public int add_cond (string cond); - public bool del (uint64 addr); - public bool del_cond (int idx); - - /* TODO: deprecate the list() method.. language iterators should be enought */ - public int list (bool rad); - - [CCode (cprefix="R_BP_PROT_")] - public enum Protection { - READ, - WRITE, - EXEC - } - - [CCode (cprefix="R_BP_TYPE_")] - public enum Type { - SW, - HW, - COND - } - - [Compact] - [CCode (cname="struct r_bp_item_t", cprefix="r_bp_item")] - public struct Item { - uint64 addr; - int size; - int rwx; - int hw; - int trace; - int enabled; - uint8* obytes; - uint8* bbytes; - int[] pids; - } + [CCode (cname="RBreakpointItem")] + public struct Item { + uint64 addr; + int size; + int rwx; + int hw; + int trace; + int enabled; + uint8* obytes; + uint8* bbytes; + int[] pids; } } diff --git a/libr/vapi/r_config.vapi b/libr/vapi/r_config.vapi index 3e096707b3..eddbd8c643 100644 --- a/libr/vapi/r_config.vapi +++ b/libr/vapi/r_config.vapi @@ -2,7 +2,7 @@ namespace Radare { [Compact] [CCode (cprefix="r_config_", cname="struct r_config_t", free_function="r_config_free")] - public class rConfig { + public class RConfig { public void init (void *user); //TODO: public void setup_file(string file); diff --git a/libr/vapi/r_cons.vapi b/libr/vapi/r_cons.vapi index 97832fbf7f..18e6fc8614 100644 --- a/libr/vapi/r_cons.vapi +++ b/libr/vapi/r_cons.vapi @@ -4,7 +4,17 @@ namespace Radare { [Compact] [CCode (cname="struct r_cons_t", free_function="r_cons_free", cprefix="r_cons_")] - public class rCons { + public class RCons { + public static bool init (); /* you have to call this before using it */ + + public static bool is_interactive; + public static bool is_html; + public static bool eof(); + + /* size of terminal */ + public static int rows; + public static int columns; + public static void printf(string fmt, ...); public static void strcat(string str); public static void memcat(string str, int len); @@ -13,7 +23,6 @@ namespace Radare { //public static int fgets(out string buf, int len, int argc, string argv[]); public static int readchar(); public static void any_key(); - public static int eof(); public static int get_columns(); public static int get_real_columns(); } diff --git a/libr/vapi/r_core.vapi b/libr/vapi/r_core.vapi index 1aed0f2921..6527f761a9 100644 --- a/libr/vapi/r_core.vapi +++ b/libr/vapi/r_core.vapi @@ -3,9 +3,9 @@ namespace Radare { [Compact] [CCode (cheader_filename="r_core.h", cname="struct r_core_t", free_function="r_core_free", cprefix="r_core_")] - public class rCore { + public class RCore { /* lifecycle */ - public rCore(); + public RCore(); /* commands */ public int prompt(); @@ -21,7 +21,7 @@ namespace Radare { public int seek(uint64 addr, bool rb); /* files */ - public rCore.File file_open(string file, int mode); + public RCore.File file_open(string file, int mode); // XXX mode = Radare.Io.Mode [Compact] diff --git a/libr/vapi/r_crypto.vapi b/libr/vapi/r_crypto.vapi index 006ff42346..aed892e1b0 100644 --- a/libr/vapi/r_crypto.vapi +++ b/libr/vapi/r_crypto.vapi @@ -4,7 +4,7 @@ namespace Radare { [Compact] [CCode (cname="struct r_crypto_t", free_function="r_crypto_free", cprefix="r_crypto_")] - public class rCrypto { + public class RCrypto { [CCode (cprefix="R_CRYPTO_DIR")] public enum Direction { @@ -20,7 +20,7 @@ namespace Radare { CFB } - public rCrypto(); + public RCrypto(); public bool use(string algorithm); // public bool set_key(uint8 *key, Crypto.Mode mode, Crypto.Direction direction); public bool set_iv(uint8 *iv); diff --git a/libr/vapi/r_db.vapi b/libr/vapi/r_db.vapi index 372dc94457..2c9872a4fc 100644 --- a/libr/vapi/r_db.vapi +++ b/libr/vapi/r_db.vapi @@ -1,27 +1,24 @@ -/* radare - LGPL - Copyright 2009 pancake<@nopcode.org> */ +/* radare - LGPL - Copyright 2009-2010 pancake<@nopcode.org> */ -[CCode (cheader_filename="r_db.h", cprefix="r_db_", lower_case_cprefix="r_db_")] -namespace Radare { - [Compact] - [CCode (cname="struct r_db_t", free_function="r_db_free", cprefix="r_db_")] - public class rDatabase { - /* lifecycle */ - public rDatabase(); - /** - * Initializes a database object - */ - public void init(); - public void free(); +[Compact] +[CCode (cheader_filename="r_db.h", cname="struct r_db_t", free_function="r_db_free", cprefix="r_db_")] +public class Radare.RDatabase { + /* lifecycle */ + public RDatabase(); + /** + * Initializes a database object + */ + public void init(); + public void free(); - /* storage */ - public int add_id(int off, int size); - public bool @add(void *b); - public bool add_unique(void *b); - public bool delete(void *b); - public void* get(int key, uint8* buf); + /* storage */ + public int add_id(int off, int size); + public bool @add(void *b); + public bool add_unique(void *b); + public bool delete(void *b); + public void* get(int key, uint8* buf); - /* stacky! */ - public int push(ref uint8* buf); - public uint8 *pop(); - } + /* stacky! */ + public int push(ref uint8* buf); + public uint8 *pop(); } diff --git a/libr/vapi/r_debug.vapi b/libr/vapi/r_debug.vapi index d14e41e838..81927e5c73 100644 --- a/libr/vapi/r_debug.vapi +++ b/libr/vapi/r_debug.vapi @@ -1,66 +1,64 @@ /* radare - LGPL - Copyright 2009-2010 pancake */ -namespace Radare { +[Compact] +[CCode (cheader_filename="r_debug.h", cname="struct r_debug_t", free_function="r_debug_free", cprefix="r_debug_")] +public class Radare.RDebug { + public RBreakpoint bp; + public RDebug(); + + public bool use(string plugin); + + /* life cycle */ + public bool attach(int pid); + public bool detach(int pid); + // TODO: add attribute to invert arraylen + public bool startv(string[] argv); // XXX + public bool start(string cmd); + public int stop_reason(); + + /* control flow */ + public bool wait(); + public bool step(int count); + //public bool kill(int pid, int sig); + public bool step_over(int count); + public bool @continue(); + public bool continue_until(uint64 addr); + public bool continue_syscall(int syscall); + + //public bool mmu_alloc(uint64 size, out uint64 size); + //public bool mmu_free(uint64 addr); + + /* registers */ [Compact] - [CCode (cheader_filename="r_debug.h", cname="struct r_debug_t", free_function="r_debug_free", cprefix="r_debug_")] - public class rDebug { - public rBreakpoint bp; - public rDebug(); - - public bool use(string plugin); - - /* life cycle */ - public bool attach(int pid); - public bool detach(int pid); - // TODO: add attribute to invert arraylen - public bool startv(string[] argv); // XXX - public bool start(string cmd); - public int stop_reason(); - - /* control flow */ - public bool wait(); - public bool step(int count); - //public bool kill(int pid, int sig); - public bool step_over(int count); - public bool @continue(); - public bool continue_until(uint64 addr); - public bool continue_syscall(int syscall); - - //public bool mmu_alloc(uint64 size, out uint64 size); - //public bool mmu_free(uint64 addr); - - /* registers */ - [Compact] - [CCode (cname="struct r_debug_t", free_function="r_debug_free", cprefix="r_debug_")] - public struct Register { - - } - bool reg_sync(bool set); - bool reg_list(int type, int size, bool rad); // TODO must be depreacted + [CCode (cname="struct r_debug_t", free_function="r_debug_free", cprefix="r_debug_")] + public struct Register { - /* processes */ - public struct Process { - public int pid; - public int status; - public int runnable; - // list for childs - // list for threads - //public struct Process *parent; - } + } + bool reg_sync(bool set); + bool reg_list(int type, int size, bool rad); // TODO must be depreacted + + /* processes */ + public struct Process { + public int pid; + public int status; + public int runnable; + // list for childs + // list for threads + //public struct Process *parent; + } // XXX cname=int must be deprecated by valaswig - [CCode (cprefix="R_DBG_PROC_", cname="int")] - public enum ProcessStatus { - STOP, - RUN, - SLEEP, - ZOMBIE, - } - public int pid_add(); - public int pid_del(); - public int pid_add_thread(); - public int pid_del_thread(); - //public Process pid_get(int pid); // XXX wrong api syntax 'get' is keyword - //public bool pid_set_status(ProcessStatus status); + [CCode (cprefix="R_DBG_PROC_", cname="int")] + public enum ProcessStatus { + STOP, + RUN, + SLEEP, + ZOMBIE, } + public int pid_add(); + public int pid_del(); + public int pid_add_thread(); + public int pid_del_thread(); + //public Process pid_get(int pid); // XXX wrong api syntax 'get' is keyword + //public bool pid_set_status(ProcessStatus status); } diff --git a/libr/vapi/r_diff.vapi b/libr/vapi/r_diff.vapi index f912e8295d..960c76268e 100644 --- a/libr/vapi/r_diff.vapi +++ b/libr/vapi/r_diff.vapi @@ -3,8 +3,8 @@ namespace Radare { [Compact] [CCode (cheader_filename="r_diff.h", cname="struct r_diff_t", free_function="r_diff_free", cprefix="r_diff_")] - public class rDiff { - public rDiff (uint64 off_a = 0LL, uint64 off_b = 0LL); + public class RDiff { + public RDiff (uint64 off_a = 0LL, uint64 off_b = 0LL); public int buffers (uint8* a, int la, uint8* b, int lb); //public int set_callback(...); public int buffers_distance (uint8 *a, int la, uint8 *b, int lb, out int distance, out double similarity); diff --git a/libr/vapi/r_hash.vapi b/libr/vapi/r_hash.vapi index a3bf67218a..08b4997518 100644 --- a/libr/vapi/r_hash.vapi +++ b/libr/vapi/r_hash.vapi @@ -3,7 +3,7 @@ /* This vapi has been manually generated by me */ [Compact] [CCode (cheader_filename="r_hash.h", cprefix="r_hash_", cname="struct r_hash_t", free_function="r_hash_free")] -public class Radare.rHash { +public class Radare.RHash { [CCode (cprefix="R_HASH_")] [Flags] public enum Algorithm { @@ -39,7 +39,7 @@ public class Radare.rHash { public static int pcprint(uint8 *buf, uint64 len); /* methods */ - public rHash(bool rst); + public RHash(bool rst); // public void init(int rst, Algorithm bits); public void init(bool rst, int bits); public uint8 *do_md4(uint8 *input, uint32 len); diff --git a/libr/vapi/r_io.vapi b/libr/vapi/r_io.vapi index 61a581040c..e02d351de4 100644 --- a/libr/vapi/r_io.vapi +++ b/libr/vapi/r_io.vapi @@ -2,8 +2,8 @@ namespace Radare { [Compact] - [CCode (cheader_filename="r_io.h", cname="rIo", free_function="r_io_free", cprefix="r_io_")] - public class rIo { + [CCode (cheader_filename="r_io.h,r_util.h", cname="RIo", free_function="r_io_free", cprefix="r_io_")] + public class RIo { [CCode (cprefix="R_IO_")] public enum Perm { READ = 0, @@ -18,9 +18,9 @@ namespace Radare { END = 2, } - public rIo(); - public rIo free(); - public unowned rIo init(); + public RIo(); + public RIo free(); + public unowned RIo init(); public bool set_write_mask(uint8 *buf, int len); /** @@ -34,7 +34,7 @@ namespace Radare { public int open_as(string urihandler, string path, int flags, int mode); public int read(out uint8 *buf, int len); public int read_at(uint64 addr, uint8 *buf, int len); - public rBuffer read_buf(uint64 addr, int len); + public RBuffer *read_buf(uint64 addr, int len); public int write(uint8 *buf, int len); public uint64 seek(int fd, uint64 addr, int whence); public int system(string cmd); @@ -49,7 +49,7 @@ namespace Radare { /* handle */ [Compact] - [CCode (cname="rIoHandle", cprefix="r_io_handle_")] + [CCode (cname="RIoHandle", cprefix="r_io_handle_")] public class Handle { string name; string desc; @@ -63,7 +63,7 @@ namespace Radare { public void handle_list(); /* maps */ - [CCode (cname="rIoMap", cprefix="r_io_map_")] + [CCode (cname="RIoMap", cprefix="r_io_map_")] public struct Map { int fd; uint64 from; @@ -77,7 +77,7 @@ namespace Radare { public int map_write_at(uint64 addr, uint8 *buf, uint64 len); /* sections */ - [CCode (cname="rIoSection")] + [CCode (cname="RIoSection")] public struct Section { string comment; uint64 from; @@ -88,7 +88,7 @@ namespace Radare { } /* desc */ - [CCode (cname="rIoDesc")] + [CCode (cname="RIoDesc")] public struct Desc { int fd; int flags; diff --git a/libr/vapi/r_lang.vapi b/libr/vapi/r_lang.vapi index 6287dbef5b..2c57b0e0f2 100644 --- a/libr/vapi/r_lang.vapi +++ b/libr/vapi/r_lang.vapi @@ -4,8 +4,8 @@ namespace Radare { [Compact] [CCode (cname="struct r_lang_t", free_function="r_lang_free", cprefix="r_lang_")] - public class Language { - public Language(); + public class RLanguage { + public RLanguage(); public bool define(string type, string name, void* ptr); public bool @add(Language.Handler handler); public bool use(string name); @@ -24,7 +24,7 @@ namespace Radare { public string help; } - public Language.Handler cur; + public Handler cur; } } diff --git a/libr/vapi/r_lib.vapi b/libr/vapi/r_lib.vapi index 4ce7abd9ed..82a1a18ba3 100644 --- a/libr/vapi/r_lib.vapi +++ b/libr/vapi/r_lib.vapi @@ -3,9 +3,9 @@ namespace Radare { [Compact] [CCode (cheader_filename="r_lib.h", cprefix="r_lib_", cname="struct r_lib_t", free_function="r_lib_free")] - public class rLibrary { - public rLibrary(string symname); - public rLibrary init(string symname); + public class RLibrary { + public RLibrary(string symname); + public RLibrary init(string symname); public bool close(void *ptr); public void* opendir(string path); public string types_get(int idx); diff --git a/libr/vapi/r_parse.vapi b/libr/vapi/r_parse.vapi index e4d49d3a42..8413b9ef7f 100644 --- a/libr/vapi/r_parse.vapi +++ b/libr/vapi/r_parse.vapi @@ -4,8 +4,8 @@ namespace Radare { [Compact] [CCode (cname="struct r_parse_t", free_function="r_parse_free", cprefix="r_parse_")] - public class Parse { - public Parse(); + public class RParse { + public RParse(); public int init(); public int list(); diff --git a/libr/vapi/r_range.vapi b/libr/vapi/r_range.vapi index 034fdb45cf..3eb6a58f0f 100644 --- a/libr/vapi/r_range.vapi +++ b/libr/vapi/r_range.vapi @@ -1,35 +1,32 @@ -/* radare - LGPL - Copyright 2009 pancake */ +/* radare - LGPL - Copyright 2009-2010 pancake */ -[CCode (cheader_filename="r_range.h", cprefix="r_range", lower_case_cprefix="r_range_")] -namespace Radare { - [Compact] - [CCode (cname="struct r_range_t", free_function="r_range_free", cprefix="r_range_")] - public class rRange { - /* lifecycle */ - public Range(); - public Range.from_string(string str); +[Compact] +[CCode (cheader_filename="r_range.h", cname="struct r_range_t", free_function="r_range_free", cprefix="r_range_")] +public class Radare.RRange { + /* lifecycle */ + public RRange(); + public RRange.from_string(string str); - public Range.Item *item_get(uint64 addr); - public uint64 size(); - public uint64 add_from_string(string str); - public uint64 add_string(string str); - //public uint64 add(uint64 fr, uint64 to, int rw); + public Item *item_get(uint64 addr); + public uint64 size(); + public uint64 add_from_string(string str); + public uint64 add_string(string str); + //public uint64 add(uint64 fr, uint64 to, int rw); // public bool sub(uint64 fr, uint64 to); - //public bool merge(Range r); - public bool contains(uint64 addr); - public bool sort(); - //public bool percent(); // XXX - public bool list(bool rad); // XXX - public bool get_n(int n, out uint64 fr, out uint64 to); - public Range *inverse(uint64 fr, uint64 to, int flags); + //public bool merge(Range r); + public bool contains(uint64 addr); + public bool sort(); + //public bool percent(); // XXX + public bool list(bool rad); // XXX + public bool get_n(int n, out uint64 fr, out uint64 to); + public Range *inverse(uint64 fr, uint64 to, int flags); - [Compact] - [CCode (cname="struct r_core_file_t", cprefix="r_core_")] - public static struct Item { - public uint64 fr; - public uint64 to; - public uint8 *data; - public int datalen; - } + [Compact] + [CCode (cname="struct r_range_item_t", cprefix="r_range_item_")] + public static struct Item { + public uint64 fr; + public uint64 to; + public uint8 *data; + public int datalen; } } diff --git a/libr/vapi/r_reg.vapi b/libr/vapi/r_reg.vapi index f591bb9634..9a6da850cd 100644 --- a/libr/vapi/r_reg.vapi +++ b/libr/vapi/r_reg.vapi @@ -1,10 +1,9 @@ /* radare - LGPL - Copyright 2009-2010 pancake<@nopcode.org> */ -[CCode (cheader_filename="r_reg.h", cprefix="r_reg_", lower_case_cprefix="r_reg_")] [Compact] -[CCode (cname="struct r_reg_t", free_function="r_reg_free", cprefix="r_reg_")] -public class Radare.rRegister { - [CCode (cprefix="R_REG_TYPE_")] +[CCode (cheader_filename="r_reg.h", cname="struct r_reg_t", free_function="r_reg_free", cprefix="r_reg_")] +public class Radare.RRegister { + [CCode (cprefix="R_REG_TYPE_", cname="int")] public enum Type { GPR, DRX, @@ -37,24 +36,24 @@ public class Radare.rRegister { [Compact] [CCode (cname="struct r_reg_set_t", destroy_function="", free_function="" )] public class Set { - public rRegister.Arena arena; - public rList arenas; - public rList regs; + public RRegister.Arena arena; + public RList arenas; + public RList regs; } [NoArrayLength] [CCode (cname="r_reg_types")] public static weak string types[]; //Type.LAST]; - public rRegister(); + public RRegister(); public bool set_profile(string file); public bool set_profile_string(string profile); - public rRegister.Item get(string name, int type = -1); + public Item get(string name, int type = -1); /* TODO: use r_array or r_list here */ - //public KernelList get_list(rRegister.Type type); + //public KernelList get_list(RRegister.Type type); - public uint64 get_value(rRegister.Item item); - public bool set_value(rRegister.Item item, uint64 val); + public uint64 get_value(Item item); + public bool set_value(Item item, uint64 val); public float get_fvalue(Item item); public bool set_fvalue(Item item, float val); diff --git a/libr/vapi/r_search.vapi b/libr/vapi/r_search.vapi index f7ab782e6f..f459a98fcf 100644 --- a/libr/vapi/r_search.vapi +++ b/libr/vapi/r_search.vapi @@ -1,52 +1,48 @@ -/* radare - LGPL - Copyright 2009 pancake */ +/* radare - LGPL - Copyright 2009-2010 pancake */ -[CCode (cheader_filename="r_search.h")] -namespace Radare { +[Compact] +[CCode (cheader_filename="r_search.h", cname="struct r_search_t", free_function="r_search_free", cprefix="r_search_")] +public class Radare.RSearch { + public RSearch (Mode mode); + public bool set_mode (Mode mode); + public bool set_string_limits (uint32 min, uint32 max); + public bool begin(); + public void kw_reset(); + public void reset(); + public bool update(out uint64 from, uint8 *buf, long len); + public bool update_i(uint64 from, uint8 *buf, long len); + public bool kw_add(string kw, string binmask); + public bool kw_add_hex(string kw, string binmask); + public bool kw_add_bin(string kw, uint32 kw_len, string binmask, long bm_len); + public Keyword kw_list(); + public int set_callback(Callback cb, void *user); + public int pattern_update(int size); // this is uint? long? + public int set_pattern_size(int size); // this is uint? long? + public int strings_update(uint64 addr, char *buf, int len, int enc); - [Compact] - [CCode (cname="struct r_search_t", free_function="r_search_free", cprefix="r_search_")] - public class rSearch { - public rSearch (Mode mode); - public bool set_mode (Mode mode); - public bool set_string_limits (uint32 min, uint32 max); - public bool begin(); - public void kw_reset(); - public void reset(); - public bool update(out uint64 from, uint8 *buf, long len); - public bool update_i(uint64 from, uint8 *buf, long len); - public bool kw_add(string kw, string binmask); - public bool kw_add_hex(string kw, string binmask); - public bool kw_add_bin(string kw, uint32 kw_len, string binmask, long bm_len); - public Keyword kw_list(); - public int set_callback(Callback cb, void *user); - public int pattern_update(int size); // this is uint? long? - public int set_pattern_size(int size); // this is uint? long? - public int strings_update(uint64 addr, char *buf, int len, int enc); - - [CCode (cprefix="R_SEARCH_", cname="int")] - public enum Mode { - KEYWORD, - REGEXP, - PATTERN, - STRING, - XREFS, - AES - } - - [Compact] - [CCode (cname="struct r_search_kw_t")] - public struct Keyword { - public unowned string keyword; - public unowned string binmask; - public uint8 *bin_keyword; - public uint8 *bin_binmask; - public int keyword_length; - public int binmask_length; - public int idx; - public int count; - } + [CCode (cprefix="R_SEARCH_", cname="int")] + public enum Mode { + KEYWORD, + REGEXP, + PATTERN, + STRING, + XREFS, + AES } - [CCode (cname="rSearchCallback")] - public static delegate int Callback(rSearch.Keyword s, void *user, uint64 addr); + [Compact] + [CCode (cname="struct r_search_kw_t")] + public struct Keyword { + public unowned string keyword; + public unowned string binmask; + public uint8 *bin_keyword; + public uint8 *bin_binmask; + public int keyword_length; + public int binmask_length; + public int idx; + public int count; + } + + [CCode (cname="RSearchCallback")] + public static delegate int Callback(Keyword s, void *user, uint64 addr); } diff --git a/libr/vapi/r_socket.vapi b/libr/vapi/r_socket.vapi index d4093ad68d..4ef77821ff 100644 --- a/libr/vapi/r_socket.vapi +++ b/libr/vapi/r_socket.vapi @@ -2,21 +2,20 @@ /* TODO: Add simpletype instead of int so, we can use it as an object */ +[SimpleType] [CCode (cname="int", cheader_filename="r_socket.h", cprefix="r_socket_")] -public struct Radare.rSocket : int +public struct Radare.RSocket : int { - public bool ready(int secs, int usecs); - [NoArrayLength] - public int read(string *buf, int len); - [NoArrayLength] - public int write(int fd, void *buf, int len); [CCode (cname="r_socket_connect")] - public rSocket.connect(string host, int port); + public RSocket.connect(string host, int port); [CCode (cname="r_socket_listen")] - public rSocket.listen(int port); + public RSocket.listen(int port); + + public bool ready(int secs, int usecs); + public int read(ref string buf, int len); + public int write(int fd, void *buf, int len); public int close(); - [NoArrayLength] - public int gets(string buf, int len); + public int gets(ref string buf, int len); public int printf(string str, ...); public int accept(); public void block(bool blocking); diff --git a/libr/vapi/r_syscall.vapi b/libr/vapi/r_syscall.vapi index 55f2cc47ba..86549e1cb0 100644 --- a/libr/vapi/r_syscall.vapi +++ b/libr/vapi/r_syscall.vapi @@ -1,29 +1,26 @@ /* radare - LGPL - Copyright 2009 pancake */ -[CCode (cheader_filename="r_syscall.h", cprefix="r_", lower_case_cprefix="r_")] -namespace Radare { - [Compact] - [CCode (cname="struct r_syscall_t", free_function="r_syscall_free", cprefix="r_syscall_")] - public class rSyscall { +[Compact] +[CCode (cheader_filename="r_syscall.h", cname="struct r_syscall_t", free_function="r_syscall_free", cprefix="r_syscall_")] +public class Radare.RSyscall { - [CCode (cprefix="R_SYSCALL_OS_")] - public enum OS { - LINUX = 0, - NETBSD, OPENBSD, FREEBSD, - DARWIN - } - - [CCode (cprefix="R_SYSCALL_ARCH_")] - public enum ARCH { - X86 = 0, PPC, ARM, MIPS, SPARC - } - - public rSyscall(); - public void setup(int os, int arch); - public void setup_file(string file); - public int get(string syscall); - public string get_i(int num, int swi); - public string get_n(int num); - public void list(); + [CCode (cprefix="R_SYSCALL_OS_")] + public enum OS { + LINUX = 0, + NETBSD, OPENBSD, FREEBSD, + DARWIN } + + [CCode (cprefix="R_SYSCALL_ARCH_")] + public enum ARCH { + X86 = 0, PPC, ARM, MIPS, SPARC + } + + public RSyscall(); + public void setup(int os, int arch); + public void setup_file(string file); + public int get(string syscall); + public string get_i(int num, int swi); + public string get_n(int num); + public void list(); } diff --git a/libr/vapi/r_util.vapi b/libr/vapi/r_util.vapi index 4c179e2d2e..a77a9dbedd 100644 --- a/libr/vapi/r_util.vapi +++ b/libr/vapi/r_util.vapi @@ -1,133 +1,132 @@ /* radare - LGPL - Copyright 2009 pancake<@nopcode.org> */ -namespace Radare { - [Compact] - [CCode (cheader_filename="r_util.h", cprefix="r_util_")] - public static class rUtil { - //public static int hex_str2bin (string input, uint8 *buf); - //public static int hex_bin2str (uint8 *buf, int len, out string str); - //public static string hex_bin2strdup (uint8 *buf, int len); - /* mem */ - //public static uint8 *mem_mem (uint8 *a, int al, uint8 *b, int bl); - //public static void mem_copyendian (uint8 *dest, uint8 *orig, int size, int endian); - //public static void mem_copyloop (uint8 *dest, uint8 *orig, int dsize, int osize); - //public static void mem_cmp_mask (uint8 *dest, uint8 *orig, uint8 *mask, int len); - /* num */ - //public static uint64 num_get(void *num, string str); // XXX void * - //public static int offsetof(void *type, void *member); - } +//[Compact] +//[CCode (cheader_filename="r_util.h", cprefix="r_util_")] +//public static class Radare.RUtil { + //public static int hex_str2bin (string input, uint8 *buf); + //public static int hex_bin2str (uint8 *buf, int len, out string str); + //public static string hex_bin2strdup (uint8 *buf, int len); + /* mem */ + //public static uint8 *mem_mem (uint8 *a, int al, uint8 *b, int bl); + //public static void mem_copyendian (uint8 *dest, uint8 *orig, int size, int endian); + //public static void mem_copyloop (uint8 *dest, uint8 *orig, int dsize, int osize); + //public static void mem_cmp_mask (uint8 *dest, uint8 *orig, uint8 *mask, int len); + /* num */ + //public static uint64 num_get(void *num, string str); // XXX void * + //public static int offsetof(void *type, void *member); +//} - // ??? - [CCode (cheader_filename="r_util.h", cprefix="r_str_")] - public static class rStr { - public rStr(); - public int hash(string str); - } +// ??? wtf +[CCode (cheader_filename="r_util.h", cprefix="r_str_")] +public static class RString { + public RString(); + public int hash(string str); +} - [CCode (cheader_filename="r_util.h", cprefix="r_num_")] - public static class rNum { - public rNum(rNumCallback cb, void *user); - public uint64 get(string str); - public uint64 math(string str); - } - public delegate uint64 rNumCallback (rNum num, string str, int *ok); +[CCode (cheader_filename="r_util.h", cprefix="r_num_")] +public static class RNum { + public RNum(RNumCallback cb, void *user); + public uint64 get(string str); + public uint64 math(string str); +} +public delegate uint64 RNumCallback (RNum num, string str, int *ok); - [CCode (cheader_filename="r_util.h", cprefix="r_log_")] - public static class rLog { - public bool msg(string str); - public bool err(string str); - } +[CCode (cheader_filename="r_util.h", cprefix="r_log_")] +public static class RLog { + public bool msg(string str); + public bool err(string str); +} - [CCode (cheader_filename="r_util.h", cprefix="r_buf_")] - public class rBuffer { - public rBuffer(); - public int read_at(uint64 addr, uint8 *buf, int len); - public int write_at(uint64 addr, uint8 *buf, int len); - public bool set_bytes(uint8 *buf, int len); - //public bool memcpy(uint64 addr, uint8 *dst, uint8 *src, int len); - /* ... */ - } +[Compact] +[CCode (cname="RBuffer", cheader_filename="r_util.h", cprefix="r_buf_")] +public class RBuffer { + public RBuffer(); + public int read_at(uint64 addr, uint8 *buf, int len); + public int write_at(uint64 addr, uint8 *buf, int len); + public bool set_bytes(uint8 *buf, int len); + //public bool memcpy(uint64 addr, uint8 *dst, uint8 *src, int len); + /* ... */ +} - /* Generic Iterator interfaced with r_iter */ +/* Generic Iterator interfaced with r_iter */ #if 0 // XXX not yet supported by valaswig :// - [Compact] - [CCode (cheader_filename="r_array.h", cprefix="r_array_", cname="void*")] - public class rArray { - public rArray (int size); - public unowned G cur (); - public bool next (); - public void rewind (); - public unowned G get (); - public unowned rArray get_n (int idx); - public unowned G prev (); - public void delete (); - public unowned G first (); - public void @foreach (rArrayCallback cb); - public unowned G free (); - public void set (int idx, owned G data); - public rArray iterator (); - /* defining the callback here results in signature of: - static gint __lambda1__void*r_iter_callback (IterableObject* foo, gpointer self) { - ^---- wtf! - iter.vala:55.23-55.28: error: The name `name' does not exist in the context of `G' - public delegate int rIterCallback (G foo); - */ - } - /* TODO: move this declaration inside rIter to have access to the Generic type */ - public delegate int rArrayCallback (void *foo); +[Compact] +[CCode (cheader_filename="r_array.h", cprefix="r_array_", cname="void*")] +public class RArray { + public RArray (int size); + public unowned G cur (); + public bool next (); + public void rewind (); + public unowned G get (); + public unowned rArray get_n (int idx); + public unowned G prev (); + public void delete (); + public unowned G first (); + public void @foreach (rArrayCallback cb); + public unowned G free (); + public void set (int idx, owned G data); + public rArray iterator (); + /* defining the callback here results in signature of: + static gint __lambda1__void*r_iter_callback (IterableObject* foo, gpointer self) { + ^---- wtf! + iter.vala:55.23-55.28: error: The name `name' does not exist in the context of `G' + public delegate int rIterCallback (G foo); + */ +} +/* TODO: move this declaration inside rIter to have access to the Generic type */ +public delegate int rArrayCallback (void *foo); #endif #if 0 - /* TODO: to be removed. not fully compliant */ - [Compact] - [CCode (cprefix="ralist_", cheader_filename="r_types.h,list.h", cname="struct list_head")] - public class KernelList { - public KernelList (); - [CCode (cname="ralist_next")] - public bool next(); - [CCode (cname="ralist_append")] - public void append(owned G foo); - [CCode (cname="")] - public G @free(G arg); - [CCode (cname="ralist_get", generic_type_pos=2)] - public unowned G get(); - [CCode (cname="ralist_iterator")] - public KernelList iterator(); - } +/* TODO: to be removed. not fully compliant */ +[Compact] +[CCode (cprefix="ralist_", cheader_filename="r_types.h,list.h", cname="struct list_head")] +public class KernelList { + public KernelList (); + [CCode (cname="ralist_next")] + public bool next(); + [CCode (cname="ralist_append")] + public void append(owned G foo); + [CCode (cname="")] + public G @free(G arg); + [CCode (cname="ralist_get", generic_type_pos=2)] + public unowned G get(); + [CCode (cname="ralist_iterator")] + public KernelList iterator(); +} #endif - [Compact] - [CCode (cprefix="r_list_", cheader_filename="r_util.h", cname="struct r_list_t")] - public class rList { - public rList (); - public void append(owned G foo); - public void prepend(owned G foo); - //public unowned G get(); - //public rListIter iterator(); - } - - [Compact] - [CCode (cprefix="r_list_iter_", cheader_filename="r_list.h", cname="struct r_list_iter_t")] - public class rListIter { - public bool next(); - // public G @free(G arg); - public unowned G get(); - } - - /* TODO: deprecated by r_iter ??? */ -/* - [Compact] - [CCode (cprefix="rarray_", cheader_filename="r_types.h", cname="void")] - public static class rArray { - [CCode (cname="rarray_next", generic_type_pos=2)] - public bool next(); //int type=0); - [CCode (cname="")] - public G @free(G arg); - [CCode (cname="rarray_get", generic_type_pos=2)] - public unowned G get(); //int type=0); - [CCode (cname="rarray_iterator")] //, generic_type_pos=2)] - public rArray iterator(); - } -*/ +[Compact] +[CCode (cprefix="r_list_", cheader_filename="r_util.h", cname="struct r_list_t")] +public class RList { + public RList (); + public void append(owned G foo); + public void prepend(owned G foo); + //public unowned G get(); + //public rListIter iterator(); } + +[Compact] +[CCode (cprefix="r_list_iter_", cheader_filename="r_list.h", cname="struct r_list_iter_t")] +public class RListIter { + public bool next(); +// public G @free(G arg); + public unowned G get(); +} + +/* TODO: deprecated by r_iter ??? */ +/* +[Compact] +[CCode (cprefix="rarray_", cheader_filename="r_types.h", cname="void")] +public static class rArray { + [CCode (cname="rarray_next", generic_type_pos=2)] + public bool next(); //int type=0); + [CCode (cname="")] + public G @free(G arg); + [CCode (cname="rarray_get", generic_type_pos=2)] + public unowned G get(); //int type=0); + [CCode (cname="rarray_iterator")] //, generic_type_pos=2)] + public rArray iterator(); +} +*/ diff --git a/swig/Makefile b/swig/Makefile index 7a5ae3f617..9f0bd2d613 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -54,8 +54,8 @@ oldtest: python test.py clean: - rm -rf python/*.so python/*.c python/*.i - rm -rf perl/*.so perl/*.pm perl/*.c perl/*.i - rm -rf ruby/*.so ruby/*.c ruby/*.i + rm -rf python/*.so python/*.c python/*.i python/libr* + rm -rf perl/*.so perl/*.pm perl/*.c perl/*.i perl/libr* + rm -rf ruby/*.so ruby/*.c ruby/*.i ruby/libr* .PHONY: ruby python perl clean oldtest test all diff --git a/swig/do-swig.sh b/swig/do-swig.sh index 6ba0f833f5..117386cd3b 100755 --- a/swig/do-swig.sh +++ b/swig/do-swig.sh @@ -1,4 +1,6 @@ #!/bin/sh +# + LNG=$1 MOD=$2 if [ -z "${MOD}" ]; then @@ -10,4 +12,8 @@ cd ${LNG} #valaswig-cc ${LNG} ${MOD} -I../../libr/include ../../libr/vapi/${MOD}.vapi -l${MOD} -L../../libr/$(echo ${MOD} | sed -e s,r_,,) -valaswig-cc ${LNG} ${MOD} -I../../libr/include ../../libr/vapi/${MOD} `pkg-config --libs ${MOD}` +echo LIBS = `pkg-config --libs ${MOD}` + +valaswig-cc ${LNG} ${MOD} \ + --vapidir=../../libr/vapi -I../../libr/include \ + ../../libr/vapi/${MOD} `pkg-config --libs ${MOD}` diff --git a/swig/python/test-r_asm.py b/swig/python/test-r_asm.py index bcdf438c71..b9d9cee166 100644 --- a/swig/python/test-r_asm.py +++ b/swig/python/test-r_asm.py @@ -11,7 +11,7 @@ def disasm(a, arch, op): else: print "HEX: %s"%code.buf_hex -a = rAsm() +a = RAsm() print "---[ name ]-----[ description ]----------" a.list() diff --git a/swig/python/test-r_bp.py b/swig/python/test-r_bp.py index a7bf5232a0..14427c15a0 100755 --- a/swig/python/test-r_bp.py +++ b/swig/python/test-r_bp.py @@ -2,7 +2,7 @@ from r_bp import * -a = rBreakpoint () +a = RBreakpoint () a.use ('x86') a.add_hw (0x8048000, 10, 0) a.add_sw (0x8048000, 10, 0) diff --git a/swig/python/test-r_hash.py b/swig/python/test-r_hash.py index a8e9822b08..81166ce8f5 100644 --- a/swig/python/test-r_hash.py +++ b/swig/python/test-r_hash.py @@ -1,7 +1,7 @@ #from r2.r_hash import rHash, Size_MD4 -from libr import rHash, Size_MD4 +from libr import RHash, Size_MD4 -hash = rHash(False) +hash = RHash(False) ret = hash.do_md4 ("food", 4) str = "md4: " for i in range(0, Size_MD4): diff --git a/swig/ruby/test-r_bp.rb b/swig/ruby/test-r_bp.rb index b1697654a4..56085a819f 100755 --- a/swig/ruby/test-r_bp.rb +++ b/swig/ruby/test-r_bp.rb @@ -1,8 +1,8 @@ #!/usr/bin/ruby -require 'r_bp' +require 'libr' -bp = R_bp::RBreakpoint.new +bp = Libr::RBreakpoint.new bp.use('x86'); bp.add_hw(0x8048400,0,0); bp.list(0) diff --git a/swig/ruby/test-r_core.rb b/swig/ruby/test-r_core.rb new file mode 100755 index 0000000000..97bc9c5214 --- /dev/null +++ b/swig/ruby/test-r_core.rb @@ -0,0 +1,7 @@ +#!/usr/bin/ruby + +require 'libr' + +core = Libr::RCore.new +core.file_open("/bin/ls", 0); +print core.cmd_str("pd 20");