* Refactoring
- Remove all init functions (included in _new) - Update vapi's (needs more work)
This commit is contained in:
parent
92dee96dad
commit
7abcfe6852
|
@ -20,25 +20,10 @@ static RAnalVarType anal_default_vartypes[] =
|
|||
{ NULL, NULL, 0 }};
|
||||
|
||||
R_API RAnal *r_anal_new() {
|
||||
return r_anal_init (R_NEW (RAnal));
|
||||
}
|
||||
|
||||
R_API RAnal *r_anal_free(RAnal *a) {
|
||||
if (a) {
|
||||
/* TODO: Free a->anals here */
|
||||
if (a->bbs)
|
||||
r_list_destroy (a->bbs);
|
||||
if (a->fcns)
|
||||
r_list_destroy (a->fcns);
|
||||
if (a->vartypes)
|
||||
r_list_destroy (a->vartypes);
|
||||
}
|
||||
free (a);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API RAnal *r_anal_init(RAnal *anal) {
|
||||
RAnal *anal;
|
||||
int i;
|
||||
|
||||
anal = R_NEW (RAnal);
|
||||
if (anal) {
|
||||
memset (anal, 0, sizeof (RAnal));
|
||||
anal->bbs = r_anal_bb_list_new ();
|
||||
|
@ -56,6 +41,20 @@ R_API RAnal *r_anal_init(RAnal *anal) {
|
|||
return anal;
|
||||
}
|
||||
|
||||
R_API RAnal *r_anal_free(RAnal *anal) {
|
||||
if (anal) {
|
||||
/* TODO: Free a->anals here */
|
||||
if (anal->bbs)
|
||||
r_list_destroy (anal->bbs);
|
||||
if (anal->fcns)
|
||||
r_list_destroy (anal->fcns);
|
||||
if (anal->vartypes)
|
||||
r_list_destroy (anal->vartypes);
|
||||
}
|
||||
free (anal);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API void r_anal_set_user_ptr(RAnal *anal, void *user) {
|
||||
anal->user = user;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,16 @@
|
|||
#include <r_list.h>
|
||||
|
||||
R_API RAnalAop *r_anal_aop_new() {
|
||||
return r_anal_aop_init (R_NEW (RAnalAop));
|
||||
RAnalAop *aop;
|
||||
|
||||
aop = R_NEW (RAnalAop);
|
||||
if (aop) {
|
||||
memset (aop, 0, sizeof (RAnalAop));
|
||||
aop->addr = -1;
|
||||
aop->jump = -1;
|
||||
aop->fail = -1;
|
||||
}
|
||||
return aop;
|
||||
}
|
||||
|
||||
R_API RList *r_anal_aop_list_new() {
|
||||
|
@ -20,16 +29,6 @@ R_API void r_anal_aop_free(void *aop) {
|
|||
free (aop);
|
||||
}
|
||||
|
||||
R_API RAnalAop *r_anal_aop_init(RAnalAop *aop) {
|
||||
if (aop) {
|
||||
memset (aop, 0, sizeof (RAnalAop));
|
||||
aop->addr = -1;
|
||||
aop->jump = -1;
|
||||
aop->fail = -1;
|
||||
}
|
||||
return aop;
|
||||
}
|
||||
|
||||
R_API int r_anal_aop(RAnal *anal, RAnalAop *aop, ut64 addr, const ut8 *data, int len) {
|
||||
if (anal && aop && anal->cur && anal->cur->aop)
|
||||
return anal->cur->aop (anal, aop, addr, data, len);
|
||||
|
|
|
@ -7,7 +7,17 @@
|
|||
#include <r_list.h>
|
||||
|
||||
R_API RAnalBB *r_anal_bb_new() {
|
||||
return r_anal_bb_init (R_NEW (RAnalBB));
|
||||
RAnalBB *bb;
|
||||
|
||||
bb = R_NEW (RAnalBB);
|
||||
if (bb) {
|
||||
memset (bb, 0, sizeof (RAnalBB));
|
||||
bb->addr = -1;
|
||||
bb->jump = -1;
|
||||
bb->fail = -1;
|
||||
bb->aops = r_anal_aop_list_new();
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
R_API RList *r_anal_bb_list_new() {
|
||||
|
@ -22,17 +32,6 @@ R_API void r_anal_bb_free(void *bb) {
|
|||
free (bb);
|
||||
}
|
||||
|
||||
R_API RAnalBB *r_anal_bb_init(RAnalBB *bb) {
|
||||
if (bb) {
|
||||
memset (bb, 0, sizeof (RAnalBB));
|
||||
bb->addr = -1;
|
||||
bb->jump = -1;
|
||||
bb->fail = -1;
|
||||
bb->aops = r_anal_aop_list_new();
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
R_API int r_anal_bb(RAnal *anal, RAnalBB *bb, ut64 addr, ut8 *buf, ut64 len) {
|
||||
RAnalAop *aop;
|
||||
int oplen, idx = 0;
|
||||
|
|
|
@ -7,7 +7,18 @@
|
|||
#include <r_list.h>
|
||||
|
||||
R_API RAnalFcn *r_anal_fcn_new() {
|
||||
return r_anal_fcn_init (R_NEW (RAnalFcn));
|
||||
RAnalFcn *fcn;
|
||||
|
||||
fcn = R_NEW (RAnalFcn);
|
||||
if (fcn) {
|
||||
memset (fcn, 0, sizeof (RAnalFcn));
|
||||
fcn->addr = -1;
|
||||
fcn->stack = 0;
|
||||
fcn->vars = r_anal_var_list_new ();
|
||||
fcn->refs = r_anal_ref_list_new ();
|
||||
fcn->xrefs = r_anal_ref_list_new ();
|
||||
}
|
||||
return fcn;
|
||||
}
|
||||
|
||||
R_API RList *r_anal_fcn_list_new() {
|
||||
|
@ -30,18 +41,6 @@ R_API void r_anal_fcn_free(void *fcn) {
|
|||
free (fcn);
|
||||
}
|
||||
|
||||
R_API RAnalFcn *r_anal_fcn_init(RAnalFcn *fcn) {
|
||||
if (fcn) {
|
||||
memset (fcn, 0, sizeof (RAnalFcn));
|
||||
fcn->addr = -1;
|
||||
fcn->stack = 0;
|
||||
fcn->vars = r_anal_var_list_new ();
|
||||
fcn->refs = r_anal_ref_list_new ();
|
||||
fcn->xrefs = r_anal_ref_list_new ();
|
||||
}
|
||||
return fcn;
|
||||
}
|
||||
|
||||
R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len) {
|
||||
RAnalRef *ref, *refi;
|
||||
RListIter *iter;
|
||||
|
|
|
@ -7,7 +7,12 @@
|
|||
#include <r_list.h>
|
||||
|
||||
R_API RAnalRef *r_anal_ref_new() {
|
||||
return r_anal_ref_init (R_NEW (RAnalRef));
|
||||
RAnalRef *ref;
|
||||
|
||||
ref = R_NEW (RAnalRef);
|
||||
if (ref)
|
||||
*ref = -1;
|
||||
return ref;
|
||||
}
|
||||
|
||||
R_API RList *r_anal_ref_list_new() {
|
||||
|
@ -19,9 +24,3 @@ R_API RList *r_anal_ref_list_new() {
|
|||
R_API void r_anal_ref_free(void *ref) {
|
||||
free (ref);
|
||||
}
|
||||
|
||||
R_API RAnalRef *r_anal_ref_init(RAnalRef *ref) {
|
||||
if (ref)
|
||||
*ref = -1;
|
||||
return ref;
|
||||
}
|
||||
|
|
|
@ -7,15 +7,32 @@
|
|||
#include <r_list.h>
|
||||
|
||||
R_API RAnalVar *r_anal_var_new() {
|
||||
return r_anal_var_init (R_NEW (RAnalVar));
|
||||
RAnalVar *var;
|
||||
|
||||
var = R_NEW (RAnalVar);
|
||||
if (var) {
|
||||
memset (var, 0, sizeof (RAnalVar));
|
||||
var->accesses = r_anal_var_access_list_new ();
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
R_API RAnalVarType *r_anal_var_type_new() {
|
||||
return r_anal_var_type_init (R_NEW (RAnalVarType));
|
||||
RAnalVarType *vartype;
|
||||
|
||||
vartype = R_NEW (RAnalVarType);
|
||||
if (vartype)
|
||||
memset (vartype, 0, sizeof (RAnalVarType));
|
||||
return vartype;
|
||||
}
|
||||
|
||||
R_API RAnalVarAccess *r_anal_var_access_new() {
|
||||
return r_anal_var_access_init (R_NEW (RAnalVarAccess));
|
||||
RAnalVarAccess *access;
|
||||
|
||||
access = R_NEW (RAnalVarAccess);
|
||||
if (access)
|
||||
memset (access, 0, sizeof (RAnalVarAccess));
|
||||
return access;
|
||||
}
|
||||
|
||||
R_API RList *r_anal_var_list_new() {
|
||||
|
@ -62,26 +79,6 @@ R_API void r_anal_var_access_free(void *access) {
|
|||
free (access);
|
||||
}
|
||||
|
||||
R_API RAnalVar *r_anal_var_init(RAnalVar *var) {
|
||||
if (var) {
|
||||
memset (var, 0, sizeof (RAnalVar));
|
||||
var->accesses = r_anal_var_access_list_new ();
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
R_API RAnalVarType *r_anal_var_type_init(RAnalVarType *vartype) {
|
||||
if (vartype)
|
||||
memset (vartype, 0, sizeof (RAnalVarType));
|
||||
return vartype;
|
||||
}
|
||||
|
||||
R_API RAnalVarAccess *r_anal_var_access_init(RAnalVarAccess *access) {
|
||||
if (access)
|
||||
memset (access, 0, sizeof (RAnalVarAccess));
|
||||
return access;
|
||||
}
|
||||
|
||||
R_API int r_anal_var_type_add(RAnal *anal, const char *name, int size, const char *fmt) {
|
||||
RAnalVarType *t;
|
||||
|
||||
|
|
|
@ -47,7 +47,22 @@ static inline int r_asm_pseudo_byte(struct r_asm_aop_t *aop, char *input) {
|
|||
}
|
||||
|
||||
R_API RAsm *r_asm_new() {
|
||||
return r_asm_init (R_NEW (RAsm));
|
||||
RAsm *a;
|
||||
int i;
|
||||
|
||||
a = R_NEW (RAsm);
|
||||
if (a) {
|
||||
a->user = NULL;
|
||||
a->cur = NULL;
|
||||
a->bits = 32;
|
||||
a->big_endian = 0;
|
||||
a->syntax = R_ASM_SYNTAX_INTEL;
|
||||
a->pc = 0;
|
||||
INIT_LIST_HEAD (&a->asms);
|
||||
for (i=0; asm_static_plugins[i]; i++)
|
||||
r_asm_add (a, asm_static_plugins[i]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
R_API void r_asm_free(struct r_asm_t *a) {
|
||||
|
@ -66,22 +81,6 @@ R_API const char *r_asm_fastcall(struct r_asm_t *a, int idx, int num) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
R_API struct r_asm_t *r_asm_init(struct r_asm_t *a) {
|
||||
int i;
|
||||
if (a) {
|
||||
a->user = NULL;
|
||||
a->cur = NULL;
|
||||
a->bits = 32;
|
||||
a->big_endian = 0;
|
||||
a->syntax = R_ASM_SYNTAX_INTEL;
|
||||
a->pc = 0;
|
||||
INIT_LIST_HEAD (&a->asms);
|
||||
for (i=0; asm_static_plugins[i]; i++)
|
||||
r_asm_add (a, asm_static_plugins[i]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
R_API void r_asm_set_user_ptr(struct r_asm_t *a, void *user) {
|
||||
a->user = user;
|
||||
}
|
||||
|
|
|
@ -4,22 +4,19 @@
|
|||
#include <r_asm.h>
|
||||
|
||||
R_API RAsmCode *r_asm_code_new() {
|
||||
RAsmCode *acode = R_NEW (RAsmCode);
|
||||
if (!acode)
|
||||
return NULL;
|
||||
r_asm_code_init(acode);
|
||||
RAsmCode *acode;
|
||||
|
||||
acode = R_NEW (RAsmCode);
|
||||
if (acode) {
|
||||
acode->len = 0;
|
||||
acode->equs = NULL;
|
||||
acode->buf_asm = NULL;
|
||||
acode->buf_hex = NULL;
|
||||
acode->buf = NULL;
|
||||
}
|
||||
return acode;
|
||||
}
|
||||
|
||||
R_API int r_asm_code_init(struct r_asm_code_t *acode) {
|
||||
acode->len = 0;
|
||||
acode->equs = NULL;
|
||||
acode->buf_asm = NULL;
|
||||
acode->buf_hex = NULL;
|
||||
acode->buf = NULL;
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API void* r_asm_code_free(struct r_asm_code_t *acode) {
|
||||
if (!acode)
|
||||
return NULL;
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <r_util.h>
|
||||
#include <r_lib.h>
|
||||
|
||||
static struct r_lib_t l;
|
||||
static struct r_asm_t a;
|
||||
static struct r_lib_t *l;
|
||||
static struct r_asm_t *a;
|
||||
static int coutput = R_FALSE;
|
||||
|
||||
static int rasm_show_help() {
|
||||
|
@ -58,8 +58,8 @@ static int rasm_disasm(char *buf, ut64 offset, ut64 len, int ascii, int bin) {
|
|||
if (!len || clen <= len)
|
||||
len = clen;
|
||||
|
||||
r_asm_set_pc (&a, offset);
|
||||
if (!(acode = r_asm_mdisassemble (&a, data, len)))
|
||||
r_asm_set_pc (a, offset);
|
||||
if (!(acode = r_asm_mdisassemble (a, data, len)))
|
||||
return 0;
|
||||
printf ("%s\n", acode->buf_asm);
|
||||
ret = acode->len;
|
||||
|
@ -95,15 +95,15 @@ static int rasm_asm(char *buf, ut64 offset, ut64 len, int bin) {
|
|||
return 1;
|
||||
}
|
||||
#endif
|
||||
r_asm_set_pc (&a, offset);
|
||||
if (!(acode = r_asm_massemble (&a, buf)))
|
||||
r_asm_set_pc (a, offset);
|
||||
if (!(acode = r_asm_massemble (a, buf)))
|
||||
return 0;
|
||||
if (bin)
|
||||
for (i = 0; i < acode->len; i++)
|
||||
printf ("%c", acode->buf[i]);
|
||||
else print_buf (acode->buf_hex);
|
||||
for (ret = 0, idx = acode->len; idx < len; idx+=ret) {
|
||||
if (!(ret = r_asm_assemble (&a, &aop, "nop")))
|
||||
if (!(ret = r_asm_assemble (a, &aop, "nop")))
|
||||
return 0;
|
||||
if (bin)
|
||||
for (i = 0; i < ret; i++)
|
||||
|
@ -119,7 +119,7 @@ static int rasm_asm(char *buf, ut64 offset, ut64 len, int bin) {
|
|||
static int __lib_asm_cb(struct r_lib_plugin_t *pl, void *user, void *data)
|
||||
{
|
||||
RAsmHandle *hand = (struct r_asm_handle_t *)data;
|
||||
r_asm_add (&a, hand);
|
||||
r_asm_add (a, hand);
|
||||
return R_TRUE;
|
||||
}
|
||||
static int __lib_asm_dt(struct r_lib_plugin_t *pl, void *p, void *u) { return R_TRUE; }
|
||||
|
@ -131,16 +131,16 @@ int main(int argc, char *argv[])
|
|||
int dis = 0, ascii = 0, bin = 0, ret = 0, bits = 32, c;
|
||||
ut64 len = 0, idx = 0;
|
||||
|
||||
r_asm_init (&a);
|
||||
r_lib_init (&l, "radare_plugin");
|
||||
r_lib_add_handler (&l, R_LIB_TYPE_ASM, "(dis)assembly plugins",
|
||||
a = r_asm_new ();
|
||||
l = r_lib_new ("radare_plugin");
|
||||
r_lib_add_handler (l, R_LIB_TYPE_ASM, "(dis)assembly plugins",
|
||||
&__lib_asm_cb, &__lib_asm_dt, NULL);
|
||||
r_lib_opendir (&l, r_sys_getenv ("LIBR_PLUGINS"));
|
||||
r_lib_opendir (l, r_sys_getenv ("LIBR_PLUGINS"));
|
||||
|
||||
if (argc<2)
|
||||
return rasm_show_help ();
|
||||
|
||||
r_asm_use (&a, "x86"); // XXX: do not harcode default arch
|
||||
r_asm_use (a, "x86"); // XXX: do not harcode default arch
|
||||
while ((c = getopt (argc, argv, "CVa:b:s:do:Bl:hLf:")) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
|
@ -157,8 +157,8 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 's':
|
||||
if (!strcmp (optarg, "att"))
|
||||
r_asm_set_syntax (&a, R_ASM_SYNTAX_ATT);
|
||||
else r_asm_set_syntax (&a, R_ASM_SYNTAX_INTEL);
|
||||
r_asm_set_syntax (a, R_ASM_SYNTAX_ATT);
|
||||
else r_asm_set_syntax (a, R_ASM_SYNTAX_INTEL);
|
||||
break;
|
||||
case 'd':
|
||||
dis = 1;
|
||||
|
@ -173,10 +173,10 @@ int main(int argc, char *argv[])
|
|||
len = r_num_math (NULL, optarg);
|
||||
break;
|
||||
case 'L':
|
||||
r_asm_list (&a);
|
||||
r_asm_list (a);
|
||||
exit (1);
|
||||
case 'e':
|
||||
r_asm_set_big_endian (&a, R_TRUE);
|
||||
r_asm_set_big_endian (a, R_TRUE);
|
||||
break;
|
||||
case 'V':
|
||||
printf ("rasm2 v"VERSION"\n");
|
||||
|
@ -187,17 +187,17 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (arch) {
|
||||
if (!r_asm_use (&a, arch)) {
|
||||
if (!r_asm_use (a, arch)) {
|
||||
eprintf ("Error: Unknown asm plugin '%s'\n", arch);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp (arch, "bf"))
|
||||
ascii = 1;
|
||||
} else if (!r_asm_use (&a, "x86")) {
|
||||
} else if (!r_asm_use (a, "x86")) {
|
||||
eprintf ("Error: Cannot find asm.x86 plugin\n");
|
||||
return 0;
|
||||
}
|
||||
if (!r_asm_set_bits (&a, bits))
|
||||
if (!r_asm_set_bits (a, bits))
|
||||
eprintf ("cannot set bits (triying with 32)\n");
|
||||
|
||||
if (file) {
|
||||
|
|
|
@ -127,15 +127,6 @@ R_API void* r_bin_free(RBin *bin) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
R_API int r_bin_init(RBin *bin) {
|
||||
int i;
|
||||
memset (bin, 0, sizeof(RBin));
|
||||
INIT_LIST_HEAD (&bin->bins);
|
||||
for (i=0;bin_static_plugins[i];i++)
|
||||
r_bin_add (bin, bin_static_plugins[i]);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API int r_bin_list(RBin *bin) {
|
||||
struct list_head *pos;
|
||||
|
||||
|
@ -243,9 +234,15 @@ R_API int r_bin_has_dbg_relocs (RBin *bin) {
|
|||
|
||||
R_API RBin* r_bin_new() {
|
||||
RBin *bin;
|
||||
if (!(bin = R_NEW (RBin)))
|
||||
return NULL;
|
||||
r_bin_init (bin);
|
||||
int i;
|
||||
|
||||
bin = R_NEW (RBin);
|
||||
if (bin) {
|
||||
memset (bin, 0, sizeof(RBin));
|
||||
INIT_LIST_HEAD (&bin->bins);
|
||||
for (i=0;bin_static_plugins[i];i++)
|
||||
r_bin_add (bin, bin_static_plugins[i]);
|
||||
}
|
||||
return bin;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define ACTION_LIBS 0x0200
|
||||
#define ACTION_SRCLINE 0x0400
|
||||
|
||||
static struct r_lib_t l;
|
||||
static struct r_lib_t *l;
|
||||
static struct r_bin_t *bin = NULL;
|
||||
static int rad = R_FALSE;
|
||||
static int rw = R_FALSE;
|
||||
|
@ -520,15 +520,15 @@ int main(int argc, char **argv)
|
|||
const char *plugin_name = NULL;
|
||||
|
||||
bin = r_bin_new ();
|
||||
r_lib_init (&l, "radare_plugin");
|
||||
r_lib_add_handler (&l, R_LIB_TYPE_BIN, "bin plugins",
|
||||
l = r_lib_new ("radare_plugin");
|
||||
r_lib_add_handler (l, R_LIB_TYPE_BIN, "bin plugins",
|
||||
&__lib_bin_cb, &__lib_bin_dt, NULL);
|
||||
|
||||
{ /* load plugins everywhere */
|
||||
char *homeplugindir = r_str_home (".radare/plugins");
|
||||
r_lib_opendir (&l, getenv ("LIBR_PLUGINS"));
|
||||
r_lib_opendir (&l, homeplugindir);
|
||||
r_lib_opendir (&l, LIBDIR"/radare2/");
|
||||
r_lib_opendir (l, getenv ("LIBR_PLUGINS"));
|
||||
r_lib_opendir (l, homeplugindir);
|
||||
r_lib_opendir (l, LIBDIR"/radare2/");
|
||||
}
|
||||
|
||||
while ((c = getopt (argc, argv, "m:@:VisSzIHelwO:o:f:rvLh")) != -1) {
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
static struct r_bp_handle_t *bp_static_plugins[] =
|
||||
{ R_BP_STATIC_PLUGINS };
|
||||
|
||||
R_API RBreakpoint *r_bp_init(RBreakpoint *bp) {
|
||||
R_API RBreakpoint *r_bp_new() {
|
||||
RBreakpoint *bp;
|
||||
int i;
|
||||
|
||||
bp = R_NEW (RBreakpoint);
|
||||
if (bp) {
|
||||
bp->cur = NULL;
|
||||
bp->nbps = 0;
|
||||
|
@ -25,10 +28,6 @@ R_API RBreakpoint *r_bp_init(RBreakpoint *bp) {
|
|||
return bp;
|
||||
}
|
||||
|
||||
R_API RBreakpoint *r_bp_new() {
|
||||
return r_bp_init (R_NEW (RBreakpoint));
|
||||
}
|
||||
|
||||
R_API RBreakpoint *r_bp_free(RBreakpoint *bp) {
|
||||
/* XXX : properly destroy bp list */
|
||||
free (bp);
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
#include <r_cmd.h>
|
||||
#include <r_util.h>
|
||||
|
||||
R_API RCmd *r_cmd_init(RCmd *cmd) {
|
||||
R_API RCmd *r_cmd_new () {
|
||||
RCmd *cmd;
|
||||
int i;
|
||||
|
||||
cmd = R_NEW (RCmd);
|
||||
if (cmd) {
|
||||
INIT_LIST_HEAD (&cmd->lcmds);
|
||||
for (i=0;i<255;i++)
|
||||
|
@ -16,10 +19,6 @@ R_API RCmd *r_cmd_init(RCmd *cmd) {
|
|||
return cmd;
|
||||
}
|
||||
|
||||
R_API RCmd *r_cmd_new () {
|
||||
return r_cmd_init (R_NEW (RCmd));
|
||||
}
|
||||
|
||||
R_API int r_cmd_set_data(struct r_cmd_t *cmd, void *data) {
|
||||
cmd->data = data;
|
||||
return 1;
|
||||
|
|
|
@ -18,23 +18,23 @@ int cmd_echo(void *data, const char *input) {
|
|||
|
||||
int main()
|
||||
{
|
||||
struct r_cmd_t cmd;
|
||||
struct r_cmd_t *cmd;
|
||||
|
||||
r_cmd_init(&cmd);
|
||||
cmd = r_cmd_new();
|
||||
|
||||
r_cmd_add(&cmd, "e", "echo message", &cmd_echo);
|
||||
r_cmd_add(&cmd, "q", "quit program", &cmd_quit);
|
||||
r_cmd_add(cmd, "e", "echo message", &cmd_echo);
|
||||
r_cmd_add(cmd, "q", "quit program", &cmd_quit);
|
||||
|
||||
r_cmd_add_long(&cmd, "echo", "e", "echo message");
|
||||
r_cmd_add_long(&cmd, "exit", "q", "quit program");
|
||||
r_cmd_add_long(cmd, "echo", "e", "echo message");
|
||||
r_cmd_add_long(cmd, "exit", "q", "quit program");
|
||||
|
||||
r_cmd_call(&cmd, "e hello world short");
|
||||
r_cmd_call_long(&cmd, "echo hello world long");
|
||||
r_cmd_call_long(&cmd, "exit");
|
||||
if (!r_cmd_call(&cmd, "**dummy**"))
|
||||
r_cmd_call(cmd, "e hello world short");
|
||||
r_cmd_call_long(cmd, "echo hello world long");
|
||||
r_cmd_call_long(cmd, "exit");
|
||||
if (!r_cmd_call(cmd, "**dummy**"))
|
||||
eprintf ("==> Cannot call **dummy**\n");
|
||||
else eprintf ("==> **dummy** called\n");
|
||||
r_cmd_call(&cmd, "quit");
|
||||
r_cmd_call(cmd, "quit");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -281,18 +281,17 @@ R_API void r_config_lock(RConfig *cfg, int l) {
|
|||
cfg->lock = l;
|
||||
}
|
||||
|
||||
R_API int r_config_init(RConfig *cfg, void *user) {
|
||||
cfg->user = user;
|
||||
cfg->n_nodes = 0;
|
||||
cfg->lock = 0;
|
||||
cfg->printf = (void *)printf;
|
||||
INIT_LIST_HEAD (&(cfg->nodes));
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API RConfig *r_config_new(void *user) {
|
||||
RConfig *cfg = R_NEW (RConfig);
|
||||
r_config_init (cfg, user);
|
||||
RConfig *cfg;
|
||||
|
||||
cfg = R_NEW (RConfig);
|
||||
if (cfg) {
|
||||
cfg->user = user;
|
||||
cfg->n_nodes = 0;
|
||||
cfg->lock = 0;
|
||||
cfg->printf = (void *)printf;
|
||||
INIT_LIST_HEAD (&(cfg->nodes));
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,24 +41,6 @@ R_API void r_cons_break_end() {
|
|||
}
|
||||
|
||||
R_API RCons *r_cons_new () {
|
||||
r_cons_init ();
|
||||
return &I;
|
||||
}
|
||||
|
||||
R_API RCons *r_cons_free (RCons *foo) {
|
||||
/* do nothing */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if __WINDOWS__
|
||||
static HANDLE h;
|
||||
static BOOL __w32_control(DWORD type) {
|
||||
if (type == CTRL_C_EVENT)
|
||||
break_signal (2); // SIGINT
|
||||
}
|
||||
#endif
|
||||
|
||||
R_API int r_cons_init() {
|
||||
I.is_interactive = R_TRUE;
|
||||
I.breaked = R_FALSE;
|
||||
I.noflush = R_FALSE;
|
||||
|
@ -87,9 +69,22 @@ R_API int r_cons_init() {
|
|||
#endif
|
||||
//r_cons_palette_init(NULL);
|
||||
r_cons_reset ();
|
||||
return R_TRUE;
|
||||
return &I;
|
||||
}
|
||||
|
||||
R_API RCons *r_cons_free (RCons *foo) {
|
||||
/* do nothing */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if __WINDOWS__
|
||||
static HANDLE h;
|
||||
static BOOL __w32_control(DWORD type) {
|
||||
if (type == CTRL_C_EVENT)
|
||||
break_signal (2); // SIGINT
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MOAR 4096*4
|
||||
static void palloc(int moar) {
|
||||
if (I.buffer == NULL) {
|
||||
|
|
|
@ -5,7 +5,7 @@ int main()
|
|||
{
|
||||
char buf[1024];
|
||||
|
||||
r_cons_init();
|
||||
r_cons_new();
|
||||
|
||||
r_cons_strcat("Hello World\n");
|
||||
r_cons_flush();
|
||||
|
|
|
@ -131,8 +131,8 @@ R_API int r_core_init(RCore *core) {
|
|||
core->bin = r_bin_new ();
|
||||
r_bin_set_user_ptr (core->bin, core);
|
||||
core->meta = r_meta_new ();
|
||||
r_cons_init ();
|
||||
r_line_init ();
|
||||
r_cons_new ();
|
||||
r_line_new ();
|
||||
core->io = r_io_new ();
|
||||
core->sign = r_sign_new ();
|
||||
r_cons_singleton()->user_fgets = (void *)myfgets;
|
||||
|
|
16
libr/db/db.c
16
libr/db/db.c
|
@ -7,15 +7,15 @@ Configurable options:
|
|||
- allow dupped nodes? (two times the same pointer?)
|
||||
#endif
|
||||
|
||||
R_API void r_db_init(struct r_db_t *db) {
|
||||
memset(&db->blocks, '\0', sizeof(db->blocks));
|
||||
db->id_min = -1;
|
||||
db->id_max = -1;
|
||||
}
|
||||
|
||||
R_API struct r_db_t *r_db_new() {
|
||||
struct r_db_t *db = (struct r_db_t *)malloc(sizeof(struct r_db_t));
|
||||
r_db_init(db);
|
||||
struct r_db_t *db;
|
||||
|
||||
db = R_NEW (RDatabase);
|
||||
if (db) {
|
||||
memset(&db->blocks, '\0', sizeof(db->blocks));
|
||||
db->id_min = -1;
|
||||
db->id_max = -1;
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@ static int r_debug_recoil(struct r_debug_t *dbg) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
R_API struct r_debug_t *r_debug_init(struct r_debug_t *dbg, int hard) {
|
||||
R_API struct r_debug_t *r_debug_new(int hard) {
|
||||
RDebug *dbg;
|
||||
|
||||
dbg = R_NEW (RDebug);
|
||||
if (dbg) {
|
||||
dbg->pid = -1;
|
||||
dbg->tid = -1;
|
||||
|
@ -47,10 +50,6 @@ R_API struct r_debug_t *r_debug_init(struct r_debug_t *dbg, int hard) {
|
|||
return dbg;
|
||||
}
|
||||
|
||||
R_API struct r_debug_t *r_debug_new() {
|
||||
return r_debug_init (R_NEW (RDebug), R_TRUE);
|
||||
}
|
||||
|
||||
R_API struct r_debug_t *r_debug_free(struct r_debug_t *dbg) {
|
||||
// TODO: free it correctly
|
||||
//r_bp_free(&dbg->bp);
|
||||
|
|
|
@ -40,7 +40,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
dbg = r_debug_new ();
|
||||
dbg = r_debug_new (R_TRUE);
|
||||
printf("Supported debugger backends:\n");
|
||||
|
||||
ret = r_debug_use (dbg, "native");
|
||||
|
|
|
@ -2,17 +2,16 @@
|
|||
|
||||
#include <r_diff.h>
|
||||
|
||||
R_API int r_diff_init(RDiff *d, ut64 off_a, ut64 off_b) {
|
||||
d->delta = 1;
|
||||
d->user = NULL;
|
||||
d->off_a = off_a;
|
||||
d->off_b = off_b;
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API RDiff *r_diff_new(ut64 off_a, ut64 off_b) {
|
||||
RDiff *d = R_NEW (RDiff);
|
||||
r_diff_init (d, off_a, off_b);
|
||||
RDiff *d;
|
||||
|
||||
d = R_NEW (RDiff);
|
||||
if (d) {
|
||||
d->delta = 1;
|
||||
d->user = NULL;
|
||||
d->off_a = off_a;
|
||||
d->off_b = off_b;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ enum {
|
|||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct r_diff_t d;
|
||||
struct r_diff_t *d;
|
||||
int c, delta = 0;
|
||||
char *file, *file2;
|
||||
ut8 *bufa, *bufb;
|
||||
|
@ -98,10 +98,11 @@ int main(int argc, char **argv) {
|
|||
|
||||
switch(mode) {
|
||||
case MODE_DIFF:
|
||||
r_diff_init (&d, 0LL, 0LL);
|
||||
r_diff_set_delta (&d, delta);
|
||||
r_diff_set_callback (&d, &cb, (void *)(size_t)rad);
|
||||
r_diff_buffers (&d, bufa, sza, bufb, szb);
|
||||
d = r_diff_new (0LL, 0LL);
|
||||
r_diff_set_delta (d, delta);
|
||||
r_diff_set_callback (d, &cb, (void *)(size_t)rad);
|
||||
r_diff_buffers (d, bufa, sza, bufb, szb);
|
||||
r_diff_free (d);
|
||||
break;
|
||||
case MODE_DIST:
|
||||
r_diff_buffers_distance (NULL, bufa, sza, bufb, szb, &count, &sim);
|
||||
|
|
|
@ -16,43 +16,43 @@ int cb(struct r_diff_t *d, void *user, struct r_diff_op_t *op)
|
|||
|
||||
int test_equal()
|
||||
{
|
||||
struct r_diff_t d;
|
||||
struct r_diff_t *d;
|
||||
char *bufa = "helloworld";
|
||||
char *bufb = "heprswarld";
|
||||
|
||||
printf("Diffing '%s' vs '%s'\n", bufa, bufb);
|
||||
r_diff_init(&d, 0, 0);
|
||||
r_diff_set_delta(&d, 0);
|
||||
r_diff_set_callback(&d, &cb, NULL);
|
||||
r_diff_buffers(&d, (ut8*)bufa, strlen(bufa), (ut8*)bufb, strlen((char*)bufb));
|
||||
d = r_diff_new (0, 0);
|
||||
r_diff_set_delta(d, 0);
|
||||
r_diff_set_callback(d, &cb, NULL);
|
||||
r_diff_buffers(d, (ut8*)bufa, strlen(bufa), (ut8*)bufb, strlen((char*)bufb));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int test_diff()
|
||||
{
|
||||
struct r_diff_t d;
|
||||
struct r_diff_t *d;
|
||||
char *bufa = "hello";
|
||||
char *bufb = "hellpworld";
|
||||
|
||||
printf("Truncated diffing '%s' vs '%s'\n", bufa, bufb);
|
||||
r_diff_init(&d, 0, 0);
|
||||
r_diff_set_delta(&d, 0);
|
||||
r_diff_set_callback(&d, &cb, NULL);
|
||||
r_diff_buffers(&d, (ut8*)bufa, strlen(bufa), (ut8*)bufb, strlen(bufb));
|
||||
d = r_diff_new (0, 0);
|
||||
r_diff_set_delta(d, 0);
|
||||
r_diff_set_callback(d, &cb, NULL);
|
||||
r_diff_buffers(d, (ut8*)bufa, strlen(bufa), (ut8*)bufb, strlen(bufb));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int test_delta()
|
||||
{
|
||||
struct r_diff_t d;
|
||||
struct r_diff_t *d;
|
||||
char *bufa = "hello";
|
||||
char *bufb = "heprpworld";
|
||||
|
||||
printf("Delta diffing '%s' vs '%s'\n", bufa, bufb);
|
||||
r_diff_init(&d, 0, 0);
|
||||
r_diff_set_delta(&d, 1);
|
||||
r_diff_set_callback(&d, &cb, NULL);
|
||||
r_diff_buffers(&d, (ut8*)bufa, strlen(bufa), (ut8*)bufb, strlen(bufb));
|
||||
r_diff_new(0, 0);
|
||||
r_diff_set_delta(d, 1);
|
||||
r_diff_set_callback(d, &cb, NULL);
|
||||
r_diff_buffers(d, (ut8*)bufa, strlen(bufa), (ut8*)bufb, strlen(bufb));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,20 +32,6 @@ static int cmp(const void *a, const void *b) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_flag_init(RFlag *f) {
|
||||
int i;
|
||||
INIT_LIST_HEAD (&f->flags);
|
||||
f->space_idx = -1;
|
||||
f->space_idx2 = -1;
|
||||
#if USE_BTREE
|
||||
btree_init (&f->tree);
|
||||
btree_init (&f->ntree);
|
||||
#endif
|
||||
for (i=0;i<R_FLAG_SPACES_MAX;i++)
|
||||
f->space[i] = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_flag_sort(RFlag *f, int namesort) {
|
||||
int ret = R_FALSE;
|
||||
int changes;
|
||||
|
@ -92,8 +78,21 @@ R_API RFlag * r_flag_free(RFlag *f) {
|
|||
}
|
||||
|
||||
R_API RFlag * r_flag_new() {
|
||||
RFlag *f = R_NEW (RFlag);
|
||||
r_flag_init (f);
|
||||
RFlag *f;
|
||||
int i;
|
||||
|
||||
f = R_NEW (RFlag);
|
||||
if (f) {
|
||||
INIT_LIST_HEAD (&f->flags);
|
||||
f->space_idx = -1;
|
||||
f->space_idx2 = -1;
|
||||
#if USE_BTREE
|
||||
btree_init (&f->tree);
|
||||
btree_init (&f->ntree);
|
||||
#endif
|
||||
for (i=0;i<R_FLAG_SPACES_MAX;i++)
|
||||
f->space[i] = NULL;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,38 +2,39 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
struct r_flag_t flags;
|
||||
struct r_flag_t *flags;
|
||||
struct r_flag_item_t *fi;
|
||||
|
||||
r_cons_init ();
|
||||
r_flag_init(&flags);
|
||||
r_flag_set(&flags, "foo", 1024, 50, 0);
|
||||
r_cons_new ();
|
||||
flags = r_flag_new(flags);
|
||||
r_flag_set(flags, "foo", 1024, 50, 0);
|
||||
|
||||
fi = r_flag_get_i(&flags, 1024);
|
||||
fi = r_flag_get_i(flags, 1024);
|
||||
if (fi) printf("FLAG FOUND '%s'\n", fi->name);
|
||||
else printf("FLAG NOT FOUND\n");
|
||||
|
||||
r_flag_set(&flags, "foo", 300LL, 0, 0);
|
||||
fi = r_flag_get_i(&flags, 0);
|
||||
r_flag_set(flags, "foo", 300LL, 0, 0);
|
||||
fi = r_flag_get_i(flags, 0);
|
||||
if (fi) printf("FLAG FOUND '%s'\n", fi->name);
|
||||
else printf("FLAG NOT FOUND\n");
|
||||
|
||||
fi = r_flag_get(&flags, "foo");
|
||||
fi = r_flag_get(flags, "foo");
|
||||
if (fi) printf("FLAG FOUND '%s'\n", fi->name);
|
||||
else printf("FLAG NOT FOUND\n");
|
||||
|
||||
r_cons_printf ("--- pre ---\n");
|
||||
r_flag_list (&flags, 0);
|
||||
r_flag_list (flags, 0);
|
||||
r_cons_flush ();
|
||||
|
||||
r_cons_printf ("--- sort ---\n");
|
||||
r_cons_flush ();
|
||||
r_flag_sort (&flags, 0);
|
||||
r_flag_sort (flags, 0);
|
||||
|
||||
r_cons_printf ("--- list ---\n");
|
||||
r_cons_flush ();
|
||||
r_flag_list (&flags, 1);
|
||||
r_flag_list (flags, 1);
|
||||
r_cons_flush ();
|
||||
r_flag_free (flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,21 +10,19 @@ void mdfour(ut8 *out, const ut8 *in, int n);
|
|||
|
||||
#define CHKFLAG(f,x) if (f==0||f&x)
|
||||
|
||||
R_API void r_hash_init(struct r_hash_t *ctx, int rst, int flags)
|
||||
R_API struct r_hash_t *r_hash_new(int rst, int flags)
|
||||
{
|
||||
CHKFLAG(flags,R_HASH_MD5) MD5Init(&ctx->md5);
|
||||
CHKFLAG(flags,R_HASH_SHA1) SHA1_Init(&ctx->sha1);
|
||||
CHKFLAG(flags,R_HASH_SHA256) SHA256_Init(&ctx->sha256);
|
||||
CHKFLAG(flags,R_HASH_SHA384) SHA384_Init(&ctx->sha384);
|
||||
CHKFLAG(flags,R_HASH_SHA512) SHA512_Init(&ctx->sha512);
|
||||
ctx->rst = rst;
|
||||
}
|
||||
RHash *ctx;
|
||||
|
||||
R_API struct r_hash_t *r_hash_new(int rst)
|
||||
{
|
||||
struct r_hash_t *ctx;
|
||||
ctx = malloc(sizeof(struct r_hash_t));
|
||||
r_hash_init(ctx, rst, R_HASH_ALL);
|
||||
ctx = R_NEW (RHash);
|
||||
if (ctx) {
|
||||
CHKFLAG(flags,R_HASH_MD5) MD5Init(&ctx->md5);
|
||||
CHKFLAG(flags,R_HASH_SHA1) SHA1_Init(&ctx->sha1);
|
||||
CHKFLAG(flags,R_HASH_SHA256) SHA256_Init(&ctx->sha256);
|
||||
CHKFLAG(flags,R_HASH_SHA384) SHA384_Init(&ctx->sha384);
|
||||
CHKFLAG(flags,R_HASH_SHA512) SHA512_Init(&ctx->sha512);
|
||||
ctx->rst = rst;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,61 +8,66 @@ int main(int argc, char **argv)
|
|||
int fd;
|
||||
ut8 *buf;
|
||||
ut64 size;
|
||||
struct r_io_t io;
|
||||
struct r_io_t *io;
|
||||
|
||||
if (argc<2) {
|
||||
printf("Usage: %s [file]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
r_io_init(&io);
|
||||
io = r_io_new();
|
||||
|
||||
fd = r_io_open(&io, argv[1], R_IO_READ, 0);
|
||||
fd = r_io_open(io, argv[1], R_IO_READ, 0);
|
||||
if (fd == -1) {
|
||||
printf("Cannot open file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* get file size */
|
||||
size = r_io_size(&io, fd);
|
||||
size = r_io_size(io, fd);
|
||||
eprintf ("AAA: %lli\n", size);
|
||||
|
||||
/* read bytes */
|
||||
buf = (ut8*) malloc(size);
|
||||
if (buf == NULL) {
|
||||
printf("Too big file\n");
|
||||
r_io_close(io, fd);
|
||||
r_io_free (io);
|
||||
return 1;
|
||||
r_io_close(&io, fd);
|
||||
}
|
||||
|
||||
memset(buf, 0, size);
|
||||
r_io_read(&io, buf, size);
|
||||
r_io_read(io, buf, size);
|
||||
printf("----\n%s\n----\n", buf);
|
||||
|
||||
printf("file size = %"PFMT64d"\n", size);
|
||||
printf("CRC32: 0x%08x\n", r_hash_crc32(buf, size));
|
||||
|
||||
{
|
||||
struct r_hash_t ctx;
|
||||
struct r_hash_t *ctx;
|
||||
const ut8 *c;
|
||||
int i;
|
||||
//r_hash_init(&ctx, R_TRUE, R_HASH_ALL);
|
||||
c = r_hash_do_md5(&ctx, buf, size);
|
||||
ctx = r_hash_new (R_TRUE, R_HASH_ALL);
|
||||
c = r_hash_do_md5(ctx, buf, size);
|
||||
printf("MD5: ");
|
||||
for(i=0;i<R_HASH_SIZE_MD5;i++) { printf("%02x", c[i]); }
|
||||
printf("\n");
|
||||
|
||||
c = r_hash_do_sha1(&ctx, buf, size);
|
||||
c = r_hash_do_sha1(ctx, buf, size);
|
||||
printf("SHA1: ");
|
||||
for(i=0;i<R_HASH_SIZE_SHA1;i++) { printf("%02x", c[i]); }
|
||||
printf("\n");
|
||||
|
||||
c = r_hash_do_sha256(&ctx, buf, size);
|
||||
c = r_hash_do_sha256(ctx, buf, size);
|
||||
printf("SHA256: ");
|
||||
for(i=0;i<R_HASH_SIZE_SHA256;i++) { printf("%02x", c[i]); }
|
||||
printf("\n");
|
||||
r_hash_free (ctx);
|
||||
}
|
||||
|
||||
r_io_close(&io, fd);
|
||||
r_io_close(io, fd);
|
||||
r_io_free (io);
|
||||
free (buf);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,32 +6,32 @@
|
|||
|
||||
static int do_hash(const char *algo, const ut8 *buf, int len, int bsize)
|
||||
{
|
||||
struct r_hash_t ctx;
|
||||
struct r_hash_t *ctx;
|
||||
const ut8 *c;
|
||||
int i, j, dlen;
|
||||
ut64 algobit = r_hash_name_to_bits (algo);
|
||||
|
||||
if (algobit == R_HASH_NONE) {
|
||||
fprintf(stderr, "Invalid hashing algorithm specified\n");
|
||||
return 1;
|
||||
}
|
||||
if (bsize>len)
|
||||
bsize = len;
|
||||
|
||||
r_hash_init(&ctx, R_TRUE, algobit);
|
||||
|
||||
ctx = r_hash_new (R_TRUE, algobit);
|
||||
/* iterate over all algorithm bits */
|
||||
for(i=1;i<0xf00000;i<<=1) {
|
||||
if (algobit & i) {
|
||||
dlen = r_hash_calculate(&ctx, algobit&i, buf, len);
|
||||
dlen = r_hash_calculate(ctx, algobit&i, buf, len);
|
||||
if (dlen) {
|
||||
c = ctx.digest;
|
||||
c = ctx->digest;
|
||||
printf("%s: ", r_hash_name(i));
|
||||
for(j=0;j<dlen;j++)
|
||||
printf("%02x", c[j]);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
r_hash_free (ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,6 @@ typedef struct r_anal_handle_t {
|
|||
/* anal.c */
|
||||
R_API RAnal *r_anal_new();
|
||||
R_API RAnal *r_anal_free(RAnal *r);
|
||||
R_API RAnal *r_anal_init(RAnal *anal);
|
||||
R_API void r_anal_set_user_ptr(RAnal *anal, void *user);
|
||||
R_API int r_anal_add(RAnal *anal, struct r_anal_handle_t *foo);
|
||||
R_API int r_anal_list(RAnal *anal);
|
||||
|
@ -216,7 +215,6 @@ R_API char *r_anal_strmask (RAnal *anal, const char *data);
|
|||
R_API RAnalBB *r_anal_bb_new();
|
||||
R_API RList *r_anal_bb_list_new();
|
||||
R_API void r_anal_bb_free(void *bb);
|
||||
R_API RAnalBB *r_anal_bb_init(struct r_anal_bb_t *bb);
|
||||
R_API int r_anal_bb(RAnal *anal, struct r_anal_bb_t *bb,
|
||||
ut64 addr, ut8 *buf, ut64 len);
|
||||
R_API int r_anal_bb_split(RAnal *anal, RAnalBB *bb, RList *bbs, ut64 addr);
|
||||
|
@ -228,7 +226,6 @@ R_API int r_anal_bb_del(RAnal *anal, ut64 addr);
|
|||
R_API RAnalAop *r_anal_aop_new();
|
||||
R_API RList *r_anal_aop_list_new();
|
||||
R_API void r_anal_aop_free(void *aop);
|
||||
R_API RAnalAop *r_anal_aop_init(struct r_anal_aop_t *aop);
|
||||
R_API int r_anal_aop(RAnal *anal, RAnalAop *aop, ut64 addr,
|
||||
const ut8 *data, int len);
|
||||
|
||||
|
@ -236,7 +233,6 @@ R_API int r_anal_aop(RAnal *anal, RAnalAop *aop, ut64 addr,
|
|||
R_API RAnalFcn *r_anal_fcn_new();
|
||||
R_API RList *r_anal_fcn_list_new();
|
||||
R_API void r_anal_fcn_free(void *fcn);
|
||||
R_API RAnalFcn *r_anal_fcn_init(RAnalFcn *fcn);
|
||||
R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len);
|
||||
R_API int r_anal_fcn_add(RAnal *anal, ut64 addr, ut64 size, const char *name);
|
||||
R_API int r_anal_fcn_del(RAnal *anal, ut64 addr);
|
||||
|
@ -246,7 +242,6 @@ R_API RList *r_anal_fcn_bb_list(RAnal *anal, RAnalFcn *fcn);
|
|||
R_API RAnalRef *r_anal_ref_new();
|
||||
R_API RList *r_anal_ref_list_new();
|
||||
R_API void r_anal_ref_free(void *ref);
|
||||
R_API RAnalRef *r_anal_ref_init(RAnalRef *ref);
|
||||
|
||||
/* var.c */
|
||||
R_API RAnalVar *r_anal_var_new();
|
||||
|
@ -258,9 +253,6 @@ R_API RList *r_anal_var_access_list_new();
|
|||
R_API void r_anal_var_free(void *var);
|
||||
R_API void r_anal_var_type_free(void *vartype);
|
||||
R_API void r_anal_var_access_free(void *access);
|
||||
R_API RAnalVar *r_anal_var_init(RAnalVar *var);
|
||||
R_API RAnalVarType *r_anal_var_type_init(RAnalVarType *vartype);
|
||||
R_API RAnalVarAccess *r_anal_var_access_init(RAnalVarAccess *access);
|
||||
R_API int r_anal_var_type_add(RAnal *anal, const char *name, int size, const char *fmt);
|
||||
R_API int r_anal_var_type_del(RAnal *anal, const char *name);
|
||||
R_API RAnalVarType *r_anal_var_type_get(RAnal *anal, const char *name);
|
||||
|
|
|
@ -103,7 +103,6 @@ R_API const char *r_asm_fastcall(RAsm *a, int idx, int num);
|
|||
|
||||
R_API void r_asm_free(RAsm *a);
|
||||
R_API void* r_asm_code_free(struct r_asm_code_t *acode);
|
||||
R_API RAsm *r_asm_init(RAsm *a);
|
||||
R_API int r_asm_modify(RAsm *a, ut8 *buf, int field, ut64 val);
|
||||
R_API void r_asm_set_user_ptr(RAsm *a, void *user);
|
||||
R_API int r_asm_add(RAsm *a, struct r_asm_handle_t *foo);
|
||||
|
@ -120,7 +119,6 @@ R_API struct r_asm_code_t* r_asm_massemble(RAsm *a, const char *buf);
|
|||
|
||||
/* code.c */
|
||||
R_API RAsmCode *r_asm_code_new();
|
||||
R_API int r_asm_code_init(struct r_asm_code_t *acode);
|
||||
R_API void* r_asm_code_free(struct r_asm_code_t *acode);
|
||||
R_API int r_asm_code_set_equ (RAsmCode *code, const char *key, const char *value);
|
||||
R_API char *r_asm_code_equ_replace (RAsmCode *code, char *str);
|
||||
|
|
|
@ -140,7 +140,6 @@ typedef struct r_bin_write_t {
|
|||
/* bin.c */
|
||||
R_API int r_bin_add(RBin *bin, RBinHandle *foo);
|
||||
R_API void* r_bin_free(RBin *bin);
|
||||
R_API int r_bin_init(RBin *bin);
|
||||
R_API int r_bin_list(RBin *bin);
|
||||
R_API int r_bin_load(RBin *bin, const char *file, const char *plugin_name);
|
||||
R_API ut64 r_bin_get_baddr(RBin *bin);
|
||||
|
|
|
@ -82,7 +82,6 @@ typedef struct r_bp_trace_t {
|
|||
} RBreakpointTrace;
|
||||
|
||||
#ifdef R_API
|
||||
R_API RBreakpoint *r_bp_init(RBreakpoint *bp);
|
||||
R_API RBreakpoint *r_bp_new();
|
||||
R_API RBreakpoint *r_bp_free(RBreakpoint *bp);
|
||||
|
||||
|
|
|
@ -78,7 +78,6 @@ R_API int r_cmd_macro_call(struct r_cmd_macro_t *mac, const char *name);
|
|||
R_API int r_cmd_macro_break(struct r_cmd_macro_t *mac, const char *value);
|
||||
|
||||
R_API RCmd *r_cmd_new();
|
||||
R_API RCmd * r_cmd_init(struct r_cmd_t *cmd);
|
||||
R_API int r_cmd_set_data(struct r_cmd_t *cmd, void *data);
|
||||
R_API int r_cmd_add(struct r_cmd_t *cmd, const char *command, const char *desc, r_cmd_callback(callback));
|
||||
R_API int r_cmd_add_long(struct r_cmd_t *cmd, const char *longcmd, const char *shortcmd, const char *desc);
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef struct r_config_t {
|
|||
#ifdef R_API
|
||||
R_API RConfig *r_config_new(void *user);
|
||||
R_API int r_config_free(RConfig *cfg);
|
||||
R_API int r_config_init(RConfig *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);
|
||||
|
|
|
@ -158,9 +158,6 @@ R_API void r_cons_break_end();
|
|||
R_API int r_cons_pipe_open(const char *file, int append);
|
||||
R_API void r_cons_pipe_close(int fd);
|
||||
|
||||
/* constructor */
|
||||
R_API int r_cons_init();
|
||||
|
||||
/* control */
|
||||
R_API void r_cons_reset();
|
||||
R_API void r_cons_clear();
|
||||
|
|
|
@ -37,7 +37,6 @@ typedef struct r_db_table_t {
|
|||
} RDatabaseTable;
|
||||
|
||||
#ifdef R_API
|
||||
R_API void r_db_init(struct r_db_t *db);
|
||||
R_API struct r_db_t *r_db_new();
|
||||
R_API struct r_db_block_t *r_db_block_new();
|
||||
R_API int r_db_add_id(struct r_db_t *db, int off, int size);
|
||||
|
|
|
@ -148,8 +148,7 @@ R_API int r_debug_handle_add(struct r_debug_t *dbg, struct r_debug_handle_t *foo
|
|||
R_API int r_debug_handle_init(struct r_debug_t *dbg);
|
||||
R_API int r_debug_handle_list(struct r_debug_t *dbg);
|
||||
|
||||
R_API struct r_debug_t *r_debug_init(struct r_debug_t *dbg, int hard);
|
||||
R_API struct r_debug_t *r_debug_new();
|
||||
R_API struct r_debug_t *r_debug_new(int hard);
|
||||
R_API struct r_debug_t *r_debug_free(struct r_debug_t *dbg);
|
||||
|
||||
/* send signals */
|
||||
|
|
|
@ -31,7 +31,6 @@ typedef int (*RDiffCallback)(RDiff *diff, void *user, RDiffOp *op);
|
|||
/* XXX: this api needs to be reviewed , constructor with offa+offb?? */
|
||||
#ifdef R_API
|
||||
R_API struct r_diff_t *r_diff_new(ut64 off_a, ut64 off_b);
|
||||
R_API int r_diff_init(struct r_diff_t *d, ut64 off_a, ut64 off_b);
|
||||
R_API struct r_diff_t *r_diff_free(struct r_diff_t *d);
|
||||
|
||||
R_API int r_diff_buffers(struct r_diff_t *d, const ut8 *a, ut32 la, const ut8 *b, ut32 lb);
|
||||
|
|
|
@ -40,7 +40,6 @@ typedef struct r_flag_t {
|
|||
#ifdef R_API
|
||||
R_API struct r_flag_t * r_flag_new();
|
||||
R_API RFlag * r_flag_free(RFlag *f);
|
||||
R_API int r_flag_init(struct r_flag_t *f);
|
||||
R_API void r_flag_list(struct r_flag_t *f, int rad);
|
||||
R_API RFlagItem *r_flag_get(RFlag *f, const char *name);
|
||||
R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off);
|
||||
|
|
|
@ -70,8 +70,7 @@ typedef struct r_hash_t {
|
|||
|
||||
#ifdef R_API
|
||||
/* OO */
|
||||
R_API struct r_hash_t *r_hash_new(int _init);
|
||||
R_API void r_hash_init(struct r_hash_t *ptr, int rst, int flags);
|
||||
R_API struct r_hash_t *r_hash_new(int rst, int flags);
|
||||
R_API void r_hash_free(struct r_hash_t *ctx);
|
||||
|
||||
/* methods */
|
||||
|
|
|
@ -160,7 +160,6 @@ R_API struct r_io_handle_t *r_io_handle_resolve(RIO *io, const char *filename);
|
|||
R_API struct r_io_handle_t *r_io_handle_resolve_fd(RIO *io, int fd);
|
||||
|
||||
/* io/io.c */
|
||||
R_API RIO* r_io_init(RIO *io);
|
||||
R_API int r_io_set_write_mask(RIO *io, const ut8 *buf, int len);
|
||||
R_API int r_io_open(RIO *io, const char *file, int flags, int mode);
|
||||
R_API int r_io_open_as(RIO *io, const char *urihandler, const char *file, int flags, int mode);
|
||||
|
|
|
@ -36,7 +36,6 @@ typedef struct r_lang_def_t {
|
|||
R_API struct r_lang_t *r_lang_new();
|
||||
R_API void *r_lang_free(struct r_lang_t *lang);
|
||||
R_API int r_lang_setup(RLang *lang);
|
||||
R_API struct r_lang_t *r_lang_init(struct r_lang_t *lang);
|
||||
R_API int r_lang_add(struct r_lang_t *lang, struct r_lang_handle_t *foo);
|
||||
R_API int r_lang_list(struct r_lang_t *lang);
|
||||
R_API int r_lang_use(struct r_lang_t *lang, const char *name);
|
||||
|
|
|
@ -84,7 +84,6 @@ R_API int r_lib_dl_check_filename(const char *file);
|
|||
|
||||
/* high level api */
|
||||
R_API struct r_lib_t *r_lib_new(const char *symname);
|
||||
R_API struct r_lib_t *r_lib_init(struct r_lib_t *lib, const char *symname);
|
||||
R_API struct r_lib_t *r_lib_free(struct r_lib_t *lib);
|
||||
R_API int r_lib_run_handler(struct r_lib_t *lib, struct r_lib_plugin_t *plugin, struct r_lib_struct_t *symbol);
|
||||
R_API struct r_lib_handler_t *r_lib_get_handler(struct r_lib_t *lib, int type);
|
||||
|
|
|
@ -48,7 +48,6 @@ typedef struct r_line_t {
|
|||
//extern RLine r_line_instance;
|
||||
R_API RLine *r_line_new ();
|
||||
R_API RLine *r_line_singleton ();
|
||||
R_API RLine *r_line_init();
|
||||
R_API void r_line_free ();
|
||||
|
||||
R_API int r_line_hist_load(const char *file);
|
||||
|
|
|
@ -61,7 +61,6 @@ enum {
|
|||
};
|
||||
|
||||
#ifdef R_API
|
||||
R_API int r_meta_init(struct r_meta_t *m);
|
||||
R_API struct r_meta_t *r_meta_new();
|
||||
R_API void r_meta_free(struct r_meta_t *m);
|
||||
R_API int r_meta_count(struct r_meta_t *m, int type, ut64 from, ut64 to, struct r_meta_count_t *c);
|
||||
|
|
|
@ -30,7 +30,6 @@ typedef struct r_parse_handle_t {
|
|||
/* parse.c */
|
||||
R_API struct r_parse_t *r_parse_new();
|
||||
R_API void r_parse_free(struct r_parse_t *p);
|
||||
R_API struct r_parse_t *r_parse_init(struct r_parse_t *p);
|
||||
R_API void r_parse_set_user_ptr(struct r_parse_t *p, void *user);
|
||||
R_API int r_parse_add(struct r_parse_t *p, struct r_parse_handle_t *foo);
|
||||
R_API int r_parse_list(struct r_parse_t *p);
|
||||
|
|
|
@ -29,7 +29,6 @@ typedef struct r_print_t {
|
|||
#ifdef R_API
|
||||
R_API char *r_print_hexpair(RPrint *p, const char *str);
|
||||
R_API RPrint *r_print_new();
|
||||
R_API RPrint *r_print_init(RPrint *p);
|
||||
R_API RPrint *r_print_free(RPrint *p);
|
||||
R_API void r_print_set_flags(RPrint *p, int _flags);
|
||||
void r_print_unset_flags(RPrint *p, int flags);
|
||||
|
|
|
@ -63,7 +63,6 @@ typedef struct r_search_t {
|
|||
|
||||
R_API RSearch *r_search_new(int mode);
|
||||
R_API int r_search_set_mode(RSearch *s, int mode);
|
||||
R_API int r_search_init(RSearch *s, int mode);
|
||||
R_API RSearch *r_search_free(RSearch *s);
|
||||
|
||||
/* keyword management */
|
||||
|
|
|
@ -34,7 +34,6 @@ typedef int (*RSignCallback)(RSignItem *si, void *user);
|
|||
|
||||
#ifdef R_API
|
||||
R_API RSign *r_sign_new();
|
||||
R_API RSign *r_sign_init(RSign *sig);
|
||||
R_API int r_sign_add(RSign *sig, RAnal *anal, int type,
|
||||
const char *name, const char *arg);
|
||||
R_API RSign *r_sign_free(RSign *sig);
|
||||
|
|
|
@ -44,7 +44,6 @@ typedef struct r_syscall_arch_handle_t {
|
|||
#ifdef R_API
|
||||
R_API RSyscall *r_syscall_new();
|
||||
R_API void r_syscall_free(RSyscall *ctx);
|
||||
R_API void r_syscall_init(RSyscall *ctx);
|
||||
R_API int r_syscall_setup(RSyscall *ctx, const char *arch, const char *os);
|
||||
R_API int r_syscall_setup_file(RSyscall *ctx, const char *path);
|
||||
R_API RSyscallItem *r_syscall_get(RSyscall *ctx, int num, int swi);
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef struct r_th_lock_t {
|
|||
|
||||
typedef struct r_th_t {
|
||||
R_TH_TID tid;
|
||||
struct r_th_lock_t lock;
|
||||
struct r_th_lock_t *lock;
|
||||
R_TH_FUNCTION(fun);
|
||||
void *user; // user pointer
|
||||
int running;
|
||||
|
@ -50,7 +50,6 @@ typedef struct r_th_pool_t {
|
|||
|
||||
#ifdef R_API
|
||||
R_API struct r_th_t *r_th_new(R_TH_FUNCTION(fun), void *user, int delay);
|
||||
R_API int r_th_init(struct r_th_t *th, R_TH_FUNCTION(fun), void *user, int delay);
|
||||
R_API int r_th_start(struct r_th_t *th, int enable);
|
||||
R_API int r_th_wait(struct r_th_t *th);
|
||||
R_API int r_th_wait_async(struct r_th_t *th);
|
||||
|
@ -58,7 +57,6 @@ R_API void r_th_break(struct r_th_t *th);
|
|||
R_API int r_th_wait(struct r_th_t *th);
|
||||
R_API void *r_th_free(struct r_th_t *th);
|
||||
|
||||
R_API int r_th_lock_init(struct r_th_lock_t *thl);
|
||||
R_API struct r_th_lock_t *r_th_lock_new();
|
||||
R_API int r_th_lock_wait(struct r_th_lock_t *th);
|
||||
R_API int r_th_lock_check(struct r_th_lock_t *thl);
|
||||
|
|
|
@ -134,7 +134,6 @@ enum {
|
|||
R_API RNum *r_num_new(RNumCallback cb, void *ptr);
|
||||
|
||||
#define R_BUF_CUR -1
|
||||
R_API RBuffer *r_buf_init(RBuffer *b);
|
||||
R_API RBuffer *r_buf_new();
|
||||
R_API int r_buf_set_bits(RBuffer *b, int bitoff, int bitsize, ut64 value);
|
||||
R_API int r_buf_set_bytes(RBuffer *b, ut8 *buf, int length);
|
||||
|
@ -145,12 +144,10 @@ R_API int r_buf_fwrite_at (RBuffer *b, ut64 addr, ut8 *buf, const char *fmt, int
|
|||
R_API void r_buf_free(RBuffer *b);
|
||||
|
||||
R_API struct r_mem_pool_t* r_mem_pool_deinit(struct r_mem_pool_t *pool);
|
||||
R_API struct r_mem_pool_t* r_mem_pool_init(struct r_mem_pool_t *pool, int nodesize, int poolsize, int poolcount);
|
||||
R_API struct r_mem_pool_t *r_mem_pool_new(int nodesize, int poolsize, int poolcount);
|
||||
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 void r_cache_free(struct r_cache_t *c);
|
||||
R_API char *r_cache_get(struct r_cache_t *c, ut64 addr);
|
||||
|
@ -173,7 +170,6 @@ R_API void r_num_minmax_swap(ut64 *a, ut64 *b);
|
|||
R_API void r_num_minmax_swap_i(int *a, int *b); // XXX this can be a cpp macro :??
|
||||
R_API ut64 r_num_math(struct r_num_t *num, const char *str);
|
||||
R_API ut64 r_num_get(struct r_num_t *num, const char *str);
|
||||
R_API void r_num_init(struct r_num_t *num);
|
||||
|
||||
/* TODO ..use as uppercase maybe? they are macros! */
|
||||
#define r_offsetof(type, member) ((unsigned long) &((type*)0)->member)
|
||||
|
@ -282,7 +278,6 @@ R_API int r_log_error(const char *str);
|
|||
R_API int r_log_progress(const char *str, int percent);
|
||||
|
||||
/* Ranges */
|
||||
R_API int r_range_init(struct r_range_t *r);
|
||||
R_API RRange *r_range_new();
|
||||
R_API RRange *r_range_new_from_string(const char *string);
|
||||
R_API RRange *r_range_free(RRange *r);
|
||||
|
|
32
libr/io/io.c
32
libr/io/io.c
|
@ -7,22 +7,22 @@
|
|||
// TODO: R_API int r_io_fetch(struct r_io_t *io, ut8 *buf, int len)
|
||||
// --- check for EXEC perms in section (use cached read to accelerate)
|
||||
|
||||
R_API struct r_io_t *r_io_init(struct r_io_t *io) {
|
||||
if (!io) return NULL;
|
||||
io->write_mask_fd = -1;
|
||||
io->redirect = NULL;
|
||||
io->printf = (void*) printf;
|
||||
r_io_cache_init (io);
|
||||
r_io_map_init (io);
|
||||
r_io_section_init (io);
|
||||
r_io_handle_init (io);
|
||||
r_io_desc_init (io);
|
||||
r_io_undo_init (io);
|
||||
return io;
|
||||
}
|
||||
|
||||
R_API struct r_io_t *r_io_new() {
|
||||
return r_io_init (R_NEW (struct r_io_t));
|
||||
RIO *io;
|
||||
|
||||
io = R_NEW (struct r_io_t);
|
||||
if (io) {
|
||||
io->write_mask_fd = -1;
|
||||
io->redirect = NULL;
|
||||
io->printf = (void*) printf;
|
||||
r_io_cache_init (io);
|
||||
r_io_map_init (io);
|
||||
r_io_section_init (io);
|
||||
r_io_handle_init (io);
|
||||
r_io_desc_init (io);
|
||||
r_io_undo_init (io);
|
||||
}
|
||||
return io;
|
||||
}
|
||||
|
||||
R_API RBuffer *r_io_read_buf(struct r_io_t *io, ut64 addr, int len) {
|
||||
|
@ -286,7 +286,7 @@ R_API ut64 r_io_seek(struct r_io_t *io, ut64 offset, int whence) {
|
|||
|
||||
R_API ut64 r_io_size(RIO *io, int fd) {
|
||||
ut64 size, here;
|
||||
fd = r_io_set_fd (io, fd);
|
||||
r_io_set_fd (io, fd);
|
||||
here = r_io_seek (io, 0, R_IO_SEEK_CUR);
|
||||
size = r_io_seek (io, 0, R_IO_SEEK_END);
|
||||
r_io_seek (io, here, R_IO_SEEK_SET);
|
||||
|
|
|
@ -4,18 +4,20 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct r_io_t *io;
|
||||
char buf[4096];
|
||||
int fd;
|
||||
struct r_io_t io;
|
||||
int fd, ret;
|
||||
|
||||
r_io_init(&io);
|
||||
|
||||
fd = r_io_open(&io, argc>1?argv[1]:"/etc/issue", R_IO_READ, 0);
|
||||
io = r_io_new();
|
||||
if (io == NULL)
|
||||
return 1;
|
||||
fd = r_io_open(io, argc>1?argv[1]:"/etc/issue", R_IO_READ, 0);
|
||||
memset(buf, '\0', 4096);
|
||||
//r_io_set_fd(&io, fd);
|
||||
r_io_read (&io, (ut8*)buf, sizeof (buf));
|
||||
|
||||
r_io_read (io, (ut8*)buf, sizeof (buf));
|
||||
puts(buf);
|
||||
|
||||
return r_io_close(&io, fd);
|
||||
ret = r_io_close(io, fd);
|
||||
r_io_free (io);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -2,27 +2,29 @@
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[1024];
|
||||
int fd;
|
||||
struct r_io_t io;
|
||||
char *file;
|
||||
|
||||
r_io_init(&io);
|
||||
struct r_io_t *io;
|
||||
char buf[1024], *file;
|
||||
int fd, ret;
|
||||
|
||||
io = r_io_new();
|
||||
if (io == NULL)
|
||||
return 1;
|
||||
file = argc>1?argv[1]:"/bin/ls";
|
||||
fd = r_io_open(&io, file, R_IO_READ, 0);
|
||||
fd = r_io_open(io, file, R_IO_READ, 0);
|
||||
if (fd == -1) {
|
||||
printf("Cannot open file '%s'\n", file);
|
||||
r_io_free (io);
|
||||
return 1;
|
||||
}
|
||||
printf("FD = %d\n", fd);
|
||||
r_io_seek(&io, 1, R_IO_SEEK_SET);
|
||||
r_io_seek(io, 1, R_IO_SEEK_SET);
|
||||
memset(buf, '\0', sizeof(buf));
|
||||
r_io_read (&io, (ut8 *)buf, 4);
|
||||
r_io_read (io, (ut8 *)buf, 4);
|
||||
buf[4]='\0';
|
||||
printf("%"PFMT64x"\n", r_io_read_i(&io, 0LL, 4, 0));
|
||||
|
||||
printf("%"PFMT64x"\n", r_io_read_i(io, 0LL, 4, 0));
|
||||
puts(buf);
|
||||
ret = r_io_close(io, fd);
|
||||
r_io_free (io);
|
||||
|
||||
return r_io_close(&io, fd);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
#include <r_lang.h>
|
||||
#include <r_util.h>
|
||||
|
||||
R_API RLang *r_lang_init(RLang *lang) {
|
||||
R_API RLang *r_lang_new() {
|
||||
RLang *lang;
|
||||
|
||||
lang = R_NEW (RLang);
|
||||
if (lang) {
|
||||
lang->user = NULL;
|
||||
INIT_LIST_HEAD (&lang->langs);
|
||||
|
@ -12,11 +15,6 @@ R_API RLang *r_lang_init(RLang *lang) {
|
|||
return lang;
|
||||
}
|
||||
|
||||
R_API RLang *r_lang_new() {
|
||||
RLang *lang = R_NEW (RLang);
|
||||
return r_lang_init (lang);
|
||||
}
|
||||
|
||||
R_API void *r_lang_free(RLang *lang) {
|
||||
r_lang_undef (lang);
|
||||
// TODO: remove langs plugins
|
||||
|
|
|
@ -59,7 +59,10 @@ R_API int r_lib_dl_close(void *handle) {
|
|||
|
||||
/* ---- */
|
||||
|
||||
R_API RLib *r_lib_init(RLib *lib, const char *symname) {
|
||||
R_API RLib *r_lib_new(const char *symname) {
|
||||
RLib *lib;
|
||||
|
||||
lib = R_NEW (RLib);
|
||||
if (lib) {
|
||||
INIT_LIST_HEAD (&lib->handlers);
|
||||
INIT_LIST_HEAD (&lib->plugins);
|
||||
|
@ -68,11 +71,6 @@ R_API RLib *r_lib_init(RLib *lib, const char *symname) {
|
|||
return lib;
|
||||
}
|
||||
|
||||
R_API RLib *r_lib_new(const char *symname) {
|
||||
RLib *lib = R_NEW (RLib);
|
||||
return r_lib_init (lib, symname);
|
||||
}
|
||||
|
||||
R_API RLib *r_lib_free(RLib *lib) {
|
||||
/* TODO: iterate over libraries and free them all */
|
||||
/* TODO: iterate over handlers and free them all */
|
||||
|
|
|
@ -13,17 +13,13 @@ R_API RLine *r_line_singleton () {
|
|||
return &r_line_instance;
|
||||
}
|
||||
|
||||
R_API RLine *r_line_init () {
|
||||
R_API RLine *r_line_new () {
|
||||
I.prompt = strdup ("> ");
|
||||
if (!r_line_dietline_init ())
|
||||
eprintf ("error: r_line_dietline_init\n");
|
||||
return &I;
|
||||
}
|
||||
|
||||
R_API RLine *r_line_new () {
|
||||
return r_line_init ();
|
||||
}
|
||||
|
||||
R_API void r_line_free () {
|
||||
// XXX: prompt out of the heap?
|
||||
free ((void*)I.prompt);
|
||||
|
|
|
@ -12,8 +12,8 @@ static int complete (void *pline) {
|
|||
int main()
|
||||
{
|
||||
const char *str;
|
||||
RLine *line = r_line_init ();
|
||||
r_cons_init ();
|
||||
RLine *line = r_line_new ();
|
||||
r_cons_new ();
|
||||
|
||||
line->completion.run = complete;
|
||||
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
|
||||
#include <r_meta.h>
|
||||
|
||||
R_API int r_meta_init(struct r_meta_t *m) {
|
||||
INIT_LIST_HEAD(&m->data);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API struct r_meta_t *r_meta_new() {
|
||||
struct r_meta_t *m = R_NEW(struct r_meta_t);
|
||||
r_meta_init(m);
|
||||
RMeta *m;
|
||||
|
||||
m = R_NEW (RMeta);
|
||||
if (m)
|
||||
INIT_LIST_HEAD(&m->data);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,17 +11,11 @@ static struct r_parse_handle_t *parse_static_plugins[] =
|
|||
{ R_PARSE_STATIC_PLUGINS };
|
||||
|
||||
R_API struct r_parse_t *r_parse_new() {
|
||||
struct r_parse_t *p = R_NEW(struct r_parse_t);
|
||||
return r_parse_init(p);
|
||||
}
|
||||
|
||||
R_API void r_parse_free(struct r_parse_t *p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
R_API struct r_parse_t *r_parse_init(struct r_parse_t *p) {
|
||||
RParse *p;
|
||||
int i;
|
||||
|
||||
p = R_NEW(RParse);
|
||||
if (p) {
|
||||
int i;
|
||||
p->user = NULL;
|
||||
INIT_LIST_HEAD(&p->parsers);
|
||||
for(i=0;parse_static_plugins[i];i++)
|
||||
|
@ -30,6 +24,10 @@ R_API struct r_parse_t *r_parse_init(struct r_parse_t *p) {
|
|||
return p;
|
||||
}
|
||||
|
||||
R_API void r_parse_free(struct r_parse_t *p) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
R_API void r_parse_set_user_ptr(struct r_parse_t *p, void *user) {
|
||||
p->user = user;
|
||||
}
|
||||
|
|
|
@ -4,32 +4,31 @@
|
|||
#include "r_print.h"
|
||||
#include "r_util.h"
|
||||
|
||||
R_API RPrint *r_print_init(RPrint *p) {
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
/* read callback */
|
||||
p->user = NULL;
|
||||
p->read_at = NULL;
|
||||
p->printf = printf;
|
||||
p->interrupt = 0;
|
||||
|
||||
strcpy (p->datefmt, "%Y:%m:%d %H:%M:%S %z");
|
||||
|
||||
/* setup prefs */
|
||||
p->bigendian = 0;
|
||||
p->width = 78;
|
||||
p->cur_enabled = R_FALSE;
|
||||
p->cur = p->ocur = -1;
|
||||
p->addrmod = 4;
|
||||
p->flags = \
|
||||
R_PRINT_FLAGS_COLOR |
|
||||
R_PRINT_FLAGS_HEADER |
|
||||
R_PRINT_FLAGS_ADDRMOD;
|
||||
return p;
|
||||
}
|
||||
|
||||
R_API RPrint *r_print_new() {
|
||||
return r_print_init (R_NEW (RPrint));
|
||||
RPrint *p;
|
||||
|
||||
p = R_NEW (RPrint);
|
||||
if (p) {
|
||||
/* read callback */
|
||||
p->user = NULL;
|
||||
p->read_at = NULL;
|
||||
p->printf = printf;
|
||||
p->interrupt = 0;
|
||||
|
||||
strcpy (p->datefmt, "%Y:%m:%d %H:%M:%S %z");
|
||||
|
||||
/* setup prefs */
|
||||
p->bigendian = 0;
|
||||
p->width = 78;
|
||||
p->cur_enabled = R_FALSE;
|
||||
p->cur = p->ocur = -1;
|
||||
p->addrmod = 4;
|
||||
p->flags = \
|
||||
R_PRINT_FLAGS_COLOR |
|
||||
R_PRINT_FLAGS_HEADER |
|
||||
R_PRINT_FLAGS_ADDRMOD;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
R_API void r_print_set_flags(RPrint *p, int _flags) {
|
||||
|
|
|
@ -8,7 +8,7 @@ int main()
|
|||
|
||||
p = r_print_new();
|
||||
p->printf = (void*)r_cons_printf;
|
||||
r_cons_init();
|
||||
r_cons_new();
|
||||
r_print_format(p, 0LL, buf, 10, "xxd foo bar cow");
|
||||
r_print_format(p, 0LL, buf, 10, "xxd");
|
||||
r_cons_flush();
|
||||
|
|
|
@ -6,7 +6,7 @@ int main()
|
|||
struct r_print_t *p;
|
||||
ut8 *buf = (ut8*)main;
|
||||
|
||||
r_cons_init();
|
||||
r_cons_new();
|
||||
p = r_print_new();
|
||||
r_print_hexdump(p, (ut64)(ut32)(main), buf, 128, 16, 1);
|
||||
r_cons_flush();
|
||||
|
|
|
@ -2,31 +2,27 @@
|
|||
|
||||
#include <r_search.h>
|
||||
|
||||
R_API int r_search_init(RSearch *s, int mode) {
|
||||
memset (s,'\0', sizeof (RSearch));
|
||||
if (!r_search_set_mode (s, mode)) {
|
||||
eprintf ("Cannot init search for mode %d\n", mode);
|
||||
return R_FALSE;
|
||||
}
|
||||
s->mode = mode;
|
||||
s->user = NULL;
|
||||
s->callback = NULL;
|
||||
s->distance = 0;
|
||||
s->pattern_size = 0;
|
||||
s->string_max = 255;
|
||||
s->string_min = 3;
|
||||
s->hits = r_list_new ();
|
||||
// TODO: review those mempool sizes. ensure never gets NULL
|
||||
s->pool = r_mem_pool_new (sizeof (RSearchHit), 1024, 10);
|
||||
INIT_LIST_HEAD (&(s->kws));
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API RSearch *r_search_new(int mode) {
|
||||
RSearch *s = R_NEW (RSearch);
|
||||
if (!r_search_init (s, mode)) {
|
||||
r_search_free (s);
|
||||
s = NULL;
|
||||
RSearch *s;
|
||||
|
||||
s = R_NEW (RSearch);
|
||||
if (s) {
|
||||
memset (s,'\0', sizeof (RSearch));
|
||||
if (!r_search_set_mode (s, mode)) {
|
||||
eprintf ("Cannot init search for mode %d\n", mode);
|
||||
return R_FALSE;
|
||||
}
|
||||
s->mode = mode;
|
||||
s->user = NULL;
|
||||
s->callback = NULL;
|
||||
s->distance = 0;
|
||||
s->pattern_size = 0;
|
||||
s->string_max = 255;
|
||||
s->string_min = 3;
|
||||
s->hits = r_list_new ();
|
||||
// TODO: review those mempool sizes. ensure never gets NULL
|
||||
s->pool = r_mem_pool_new (sizeof (RSearchHit), 1024, 10);
|
||||
INIT_LIST_HEAD (&(s->kws));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <r_lib.h>
|
||||
#include <r_io.h>
|
||||
|
||||
static struct r_io_t io;
|
||||
static struct r_io_t *io;
|
||||
static int fd = -1;
|
||||
static int rad = 0;
|
||||
struct r_search_t *rs;
|
||||
|
@ -72,20 +72,20 @@ static int show_help(char *argv0, int line) {
|
|||
static int rafind_open(char *file) {
|
||||
int ret, last = 0;
|
||||
struct list_head *pos;
|
||||
r_io_init(&io);
|
||||
io = r_io_new();
|
||||
|
||||
fd = r_io_open(&io, file, R_IO_READ, 0);
|
||||
fd = r_io_open(io, file, R_IO_READ, 0);
|
||||
if (fd == -1) {
|
||||
fprintf (stderr, "Cannot open file '%s'\n", file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
r_cons_init();
|
||||
r_cons_new();
|
||||
rs = r_search_new(mode);
|
||||
buffer = malloc(bsize);
|
||||
r_search_set_callback(rs, &hit, buffer);
|
||||
if (to == -1) {
|
||||
to = r_io_size(&io, fd);
|
||||
to = r_io_size(io, fd);
|
||||
}
|
||||
if (mode == R_SEARCH_KEYWORD) {
|
||||
list_for_each(pos, &(kws_head)) {
|
||||
|
@ -98,14 +98,14 @@ static int rafind_open(char *file) {
|
|||
}
|
||||
curfile = file;
|
||||
r_search_begin(rs);
|
||||
r_io_seek(&io, from, R_IO_SEEK_SET);
|
||||
r_io_seek(io, from, R_IO_SEEK_SET);
|
||||
//printf("; %s 0x%08"PFMT64x"-0x%08"PFMT64x"\n", file, from, to);
|
||||
for(cur=from; !last && cur<to;cur+=bsize) {
|
||||
if ((cur+bsize)>to) {
|
||||
bsize = to-cur;
|
||||
last=1;
|
||||
}
|
||||
ret = r_io_read(&io, buffer, bsize);
|
||||
ret = r_io_read(io, buffer, bsize);
|
||||
if (ret == 0) {
|
||||
if (nonstop) continue;
|
||||
// fprintf(stderr, "Error reading at 0x%08"PFMT64x"\n", cur);
|
||||
|
@ -177,6 +177,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
for (;optind < argc;optind++)
|
||||
rafind_open(argv[optind]);
|
||||
|
||||
r_search_free (rs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
#include <r_anal.h>
|
||||
|
||||
R_API RSign *r_sign_new() {
|
||||
return r_sign_init (R_NEW (RSign));
|
||||
}
|
||||
RSign *sig;
|
||||
|
||||
R_API RSign *r_sign_init(RSign *sig) {
|
||||
sig = R_NEW (RSign);
|
||||
if (sig) {
|
||||
sig->s_byte = sig->s_anal = 0;
|
||||
sig->prefix[0] = '\0';
|
||||
|
|
|
@ -18,9 +18,9 @@ int main(int argc, char **argv) {
|
|||
int c;
|
||||
int action = 0;
|
||||
int rad = 0;
|
||||
RSign sig;
|
||||
RSign *sig;
|
||||
|
||||
r_sign_init (&sig);
|
||||
sig = r_sign_new ();
|
||||
|
||||
while ((c=getopt (argc, argv, "o:hrs:iV")) !=-1) {
|
||||
switch (c) {
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char **argv) {
|
|||
if (argv[optind]==NULL)
|
||||
return rasign_show_help ();
|
||||
|
||||
r_sign_list (&sig, 0);
|
||||
r_sign_list (sig, 0);
|
||||
|
||||
switch (action) {
|
||||
case 's':
|
||||
|
@ -57,5 +57,8 @@ int main(int argc, char **argv) {
|
|||
//r_sign_generate (&sig, argv[optind], stdout);
|
||||
break;
|
||||
}
|
||||
|
||||
r_sign_free (sig);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,11 +23,6 @@ R_API RSyscall* r_syscall_new() {
|
|||
return ctx;
|
||||
}
|
||||
|
||||
R_API void r_syscall_init(RSyscall *ctx) {
|
||||
ctx->fd = NULL;
|
||||
ctx->sysptr = syscalls_linux_x86;
|
||||
}
|
||||
|
||||
R_API void r_syscall_free(RSyscall *ctx) {
|
||||
free (ctx);
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
#include "r_syscall.h"
|
||||
|
||||
int main() {
|
||||
struct r_syscall_t ctx;
|
||||
struct r_syscall_t *ctx;
|
||||
|
||||
r_syscall_init (&ctx);
|
||||
r_syscall_setup (&ctx, "x86", "linux");
|
||||
ctx = r_syscall_new ();
|
||||
r_syscall_setup (ctx, "x86", "linux");
|
||||
|
||||
printf("4 = %s\n", r_syscall_get_i(&ctx, 4, -1));
|
||||
printf("write = %d\n", r_syscall_get_num(&ctx, "write"));
|
||||
printf("4 = %s\n", r_syscall_get_i(ctx, 4, -1));
|
||||
printf("write = %d\n", r_syscall_get_num(ctx, "write"));
|
||||
|
||||
r_syscall_free (ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,24 +4,20 @@
|
|||
|
||||
/* locks/mutex/sems */
|
||||
|
||||
R_API int r_th_lock_init(struct r_th_lock_t *thl)
|
||||
{
|
||||
int ret;
|
||||
thl->refs = 0;
|
||||
#if HAVE_PTHREAD
|
||||
ret = pthread_mutex_init (&thl->lock, NULL)?R_TRUE:R_FALSE;
|
||||
#elif __WIN32__
|
||||
//thl->lock = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
InitializeCriticalSection(&thl->lock);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API struct r_th_lock_t *r_th_lock_new()
|
||||
{
|
||||
struct r_th_lock_t *thl = R_NEW(struct r_th_lock_t);
|
||||
if (!r_th_lock_init(thl))
|
||||
R_FREE(thl);
|
||||
RThreadLock *thl;
|
||||
|
||||
thl = R_NEW(RThreadLock);
|
||||
if (thl) {
|
||||
thl->refs = 0;
|
||||
#if HAVE_PTHREAD
|
||||
pthread_mutex_init (&thl->lock, NULL);
|
||||
#elif __WIN32__
|
||||
//thl->lock = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
InitializeCriticalSection(&thl->lock);
|
||||
#endif
|
||||
}
|
||||
return thl;
|
||||
}
|
||||
|
||||
|
|
53
libr/th/th.c
53
libr/th/th.c
|
@ -9,17 +9,17 @@ static void *_r_th_launcher(void *_th) {
|
|||
th->ready = R_TRUE;
|
||||
#if __UNIX__
|
||||
if (th->delay>0) sleep(th->delay);
|
||||
else if (th->delay<0) r_th_lock_wait(&th->lock);
|
||||
else if (th->delay<0) r_th_lock_wait(th->lock);
|
||||
#else
|
||||
if (th->delay<0) r_th_lock_wait(&th->lock);
|
||||
if (th->delay<0) r_th_lock_wait(th->lock);
|
||||
#endif
|
||||
|
||||
do {
|
||||
r_th_lock_leave(&th->lock);
|
||||
r_th_lock_leave(th->lock);
|
||||
th->running = R_TRUE;
|
||||
ret = th->fun(th);
|
||||
th->running = R_FALSE;
|
||||
r_th_lock_enter(&th->lock);
|
||||
r_th_lock_enter(th->lock);
|
||||
} while(ret);
|
||||
|
||||
#if HAVE_PTHREAD
|
||||
|
@ -28,35 +28,31 @@ static void *_r_th_launcher(void *_th) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_th_init(struct r_th_t *th, R_TH_FUNCTION(fun), void *user, int delay) {
|
||||
int ret = R_TRUE;
|
||||
|
||||
r_th_lock_init(&th->lock);
|
||||
th->running = R_FALSE;
|
||||
th->fun = fun;
|
||||
th->user = user;
|
||||
th->delay = delay;
|
||||
th->breaked = R_FALSE;
|
||||
th->ready = R_FALSE;
|
||||
#if HAVE_PTHREAD
|
||||
if (pthread_create(&th->tid, NULL, _r_th_launcher, th))
|
||||
ret = R_FALSE;
|
||||
#elif __WIN32__
|
||||
th->tid = CreateThread(NULL, 0, _r_th_launcher, th, 0, &th->tid);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_th_push_task(struct r_th_t *th, void *user) {
|
||||
int ret = R_TRUE;
|
||||
th->user = user;
|
||||
r_th_lock_leave(&th->lock);
|
||||
r_th_lock_leave(th->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API struct r_th_t *r_th_new(R_TH_FUNCTION(fun), void *user, int delay) {
|
||||
struct r_th_t *th = R_NEW (struct r_th_t);
|
||||
r_th_init (th, fun, user, delay);
|
||||
RThread *th;
|
||||
|
||||
th = R_NEW (RThread);
|
||||
if (th) {
|
||||
th->lock = r_th_lock_new();
|
||||
th->running = R_FALSE;
|
||||
th->fun = fun;
|
||||
th->user = user;
|
||||
th->delay = delay;
|
||||
th->breaked = R_FALSE;
|
||||
th->ready = R_FALSE;
|
||||
#if HAVE_PTHREAD
|
||||
pthread_create(&th->tid, NULL, _r_th_launcher, th);
|
||||
#elif __WIN32__
|
||||
th->tid = CreateThread(NULL, 0, _r_th_launcher, th, 0, &th->tid);
|
||||
#endif
|
||||
}
|
||||
return th;
|
||||
}
|
||||
|
||||
|
@ -80,13 +76,13 @@ R_API int r_th_start(struct r_th_t *th, int enable) {
|
|||
if (!th->running) {
|
||||
// start thread
|
||||
while (!th->ready);
|
||||
r_th_lock_leave (&th->lock);
|
||||
r_th_lock_leave (th->lock);
|
||||
}
|
||||
} else {
|
||||
if (th->running) {
|
||||
// stop thread
|
||||
r_th_kill (th, 0);
|
||||
r_th_lock_enter (&th->lock); // deadlock?
|
||||
r_th_lock_enter (th->lock); // deadlock?
|
||||
}
|
||||
}
|
||||
th->running = enable;
|
||||
|
@ -109,6 +105,7 @@ R_API int r_th_wait_async(struct r_th_t *th) {
|
|||
|
||||
R_API void *r_th_free(struct r_th_t *th) {
|
||||
r_th_kill (th, R_TRUE);
|
||||
r_th_lock_free (th->lock);
|
||||
free (th);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@ struct r_class_t {
|
|||
#define r_buf_init(x) r_buf_class->init
|
||||
#endif
|
||||
|
||||
R_API struct r_buf_t *r_buf_init(RBuffer *b) {
|
||||
R_API struct r_buf_t *r_buf_new() {
|
||||
RBuffer *b;
|
||||
|
||||
b = R_NEW (RBuffer);
|
||||
if (b) {
|
||||
b->buf = NULL;
|
||||
b->length = 0;
|
||||
|
@ -24,11 +27,6 @@ R_API struct r_buf_t *r_buf_init(RBuffer *b) {
|
|||
return b;
|
||||
}
|
||||
|
||||
R_API struct r_buf_t *r_buf_new() {
|
||||
RBuffer *b = R_NEW (RBuffer);
|
||||
return r_buf_init (b);
|
||||
}
|
||||
|
||||
R_API int r_buf_set_bits(RBuffer *b, int bitoff, int bitsize, ut64 value) {
|
||||
// TODO: implement r_buf_set_bits
|
||||
// TODO: get the implementation from reg/value.c ?
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
|
||||
#include <r_util.h>
|
||||
|
||||
R_API void r_cache_init(struct r_cache_t *c)
|
||||
{
|
||||
INIT_LIST_HEAD(&c->items);
|
||||
}
|
||||
|
||||
R_API struct r_cache_t *r_cache_new()
|
||||
{
|
||||
struct r_cache_t *a = R_NEW(struct r_cache_t);
|
||||
r_cache_init(a);
|
||||
RCache *a;
|
||||
|
||||
a = R_NEW (RCache);
|
||||
if (a)
|
||||
INIT_LIST_HEAD(&a->items);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,17 +14,13 @@
|
|||
#define r_flist_unref(x) x
|
||||
#endif
|
||||
|
||||
R_API void **r_flist_init(void **it, int n) {
|
||||
*it = it;
|
||||
memset (++it, 0, (n+1) * sizeof (void*));
|
||||
return it;
|
||||
}
|
||||
|
||||
R_API void **r_flist_new(int n) {
|
||||
void **it;
|
||||
if (!(it = (void **)malloc ((n+2) * sizeof (void*))))
|
||||
return NULL;
|
||||
return r_flist_init (it, n);
|
||||
*it = it;
|
||||
memset (++it, 0, (n+1) * sizeof (void*));
|
||||
return it;
|
||||
}
|
||||
|
||||
R_API void **r_flist_prev(void **it) {
|
||||
|
|
|
@ -42,16 +42,17 @@ R_API void r_num_minmax_swap_i(int *a, int *b) {
|
|||
}
|
||||
|
||||
R_API void r_num_init(struct r_num_t *num) {
|
||||
num->callback = NULL;
|
||||
num->userptr = NULL;
|
||||
num->value = 0LL;
|
||||
}
|
||||
|
||||
R_API RNum *r_num_new(RNumCallback cb, void *ptr) {
|
||||
RNum *num = (RNum *) malloc (sizeof (RNum));
|
||||
r_num_init (num);
|
||||
num->callback = cb;
|
||||
num->userptr = ptr;
|
||||
RNum *num;
|
||||
|
||||
num = R_NEW (RNum);
|
||||
if (num) {
|
||||
num->value = 0LL;
|
||||
num->callback = cb;
|
||||
num->userptr = ptr;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,29 +19,25 @@ R_API RMemoryPool* r_mem_pool_deinit(RMemoryPool *pool) {
|
|||
return pool;
|
||||
}
|
||||
|
||||
R_API RMemoryPool* r_mem_pool_init(RMemoryPool *pool, int nsize, int psize, int pcount) {
|
||||
if (pool) {
|
||||
if (psize<1)
|
||||
psize = ALLOC_POOL_SIZE;
|
||||
if (pcount<1)
|
||||
pcount = ALLOC_POOL_COUNT;
|
||||
R_API RMemoryPool *r_mem_pool_new(int nodesize, int poolsize, int poolcount) {
|
||||
RMemoryPool *mp;
|
||||
|
||||
mp = R_NEW (RMemoryPool);
|
||||
if (mp) {
|
||||
if (poolsize<1)
|
||||
poolsize = ALLOC_POOL_SIZE;
|
||||
if (poolcount<1)
|
||||
poolcount = ALLOC_POOL_COUNT;
|
||||
// TODO: assert nodesize?;
|
||||
pool->poolsize = psize;
|
||||
pool->poolcount = pcount;
|
||||
pool->nodesize = nsize;
|
||||
pool->npool = -1;
|
||||
pool->ncount = pool->poolsize; // force init
|
||||
pool->nodes = (void**) malloc (sizeof (void*) * pool->poolcount);
|
||||
if (pool->nodes == NULL)
|
||||
mp->poolsize = poolsize;
|
||||
mp->poolcount = poolcount;
|
||||
mp->nodesize = nodesize;
|
||||
mp->npool = -1;
|
||||
mp->ncount = mp->poolsize; // force init
|
||||
mp->nodes = (void**) malloc (sizeof (void*) * mp->poolcount);
|
||||
if (mp->nodes == NULL)
|
||||
return NULL;
|
||||
}
|
||||
return pool;
|
||||
}
|
||||
|
||||
R_API RMemoryPool *r_mem_pool_new(int nodesize, int poolsize, int poolcount) {
|
||||
RMemoryPool *mp = R_NEW (struct r_mem_pool_t);
|
||||
if (!r_mem_pool_init (mp, nodesize, poolsize, poolcount))
|
||||
r_mem_pool_free (mp);
|
||||
return mp;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,15 @@
|
|||
|
||||
//void (*ranges_new_callback)(struct range_t *r) = NULL;
|
||||
|
||||
R_API int r_range_init(RRange *r) {
|
||||
r->count = 0;
|
||||
r->changed = 0;
|
||||
INIT_LIST_HEAD (&r->ranges);
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API RRange *r_range_new() {
|
||||
RRange *r = R_NEW (RRange);
|
||||
if (r == NULL)
|
||||
return NULL;
|
||||
r_range_init (r);
|
||||
RRange *r;
|
||||
|
||||
r = R_NEW (RRange);
|
||||
if (r) {
|
||||
r->count = 0;
|
||||
r->changed = 0;
|
||||
INIT_LIST_HEAD (&r->ranges);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ public class RAnal {
|
|||
public RList <VariableType> vartypes;
|
||||
|
||||
public RAnal ();
|
||||
//public weak RAnal init ();
|
||||
public bool set_bits (int bits);
|
||||
public bool set_big_endian (bool big);
|
||||
//public bool set_pc (uint64 addr);
|
||||
|
|
|
@ -56,7 +56,6 @@ public class Radare.RAsm {
|
|||
public void *aux;
|
||||
|
||||
public RAsm();
|
||||
public unowned RAsm init();
|
||||
public int list();
|
||||
public bool use(string name);
|
||||
public bool set_bits(int bits);
|
||||
|
|
|
@ -3,7 +3,6 @@ namespace Radare {
|
|||
[Compact]
|
||||
[CCode (cprefix="r_config_", cname="struct r_config_t", free_function="r_config_free")]
|
||||
public class RConfig {
|
||||
public void init (void *user);
|
||||
//TODO: public void setup_file(string file);
|
||||
|
||||
public int eval(string str);
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace Radare {
|
|||
/* TODO: bold colors */
|
||||
}
|
||||
#endif
|
||||
public static bool init (); /* you have to call this before using it */
|
||||
|
||||
public static bool is_interactive;
|
||||
public static bool is_html;
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
public class Radare.RDatabase {
|
||||
/* lifecycle */
|
||||
public RDatabase();
|
||||
/**
|
||||
* Initializes a database object
|
||||
*/
|
||||
public void init();
|
||||
public void free();
|
||||
|
||||
/* storage */
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Radare {
|
|||
[CCode (cname="struct r_flag_t", free_function="r_flag_free", cprefix="r_flag_")]
|
||||
public class RFlag {
|
||||
public RFlag();
|
||||
public int init();
|
||||
public void list(bool rad);
|
||||
public RFlagItem get(string name);
|
||||
public RFlagItem get_i(uint64 addr);
|
||||
|
|
|
@ -40,8 +40,6 @@ public class Radare.RHash {
|
|||
|
||||
/* methods */
|
||||
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);
|
||||
public uint8 *do_md5(uint8 *input, uint32 len);
|
||||
public uint8 *do_sha1(uint8 *input, uint32 len);
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace Radare {
|
|||
|
||||
|
||||
public void cache_enable(bool rd, bool wr);
|
||||
public void cache_init();
|
||||
public void cache_write(uint64 addr, ref uint8 *buf, int len);
|
||||
public void cache_read(uint64 addr, ref uint8 *buf, int len);
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Radare {
|
|||
[CCode (cheader_filename="r_lib.h", cprefix="r_lib_", cname="struct r_lib_t", free_function="r_lib_free")]
|
||||
public class RLib {
|
||||
public RLib (string symname);
|
||||
public RLib init(string symname);
|
||||
public bool close(string file);
|
||||
public int opendir(string path);
|
||||
//public string types_get(int idx);
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Radare {
|
|||
[CCode (cheader_filename="r_lib.h", cprefix="r_lib_", cname="struct r_lib_t", free_function="r_lib_free")]
|
||||
public class RLine {
|
||||
public RLine(string symname);
|
||||
public bool init ();
|
||||
public bool readline (int argc, char **argv);
|
||||
|
||||
public bool hist_load (string file);
|
||||
|
|
|
@ -7,7 +7,6 @@ namespace Radare {
|
|||
public class RParse {
|
||||
public RParse();
|
||||
|
||||
public int init();
|
||||
public int list();
|
||||
public bool use(string name);
|
||||
public bool assemble(ref string dst, string src);
|
||||
|
|
Loading…
Reference in New Issue