More work on ctypes+rcore

This commit is contained in:
pancake 2013-09-24 23:03:39 +02:00
parent 360222d31e
commit 800c1de3a4
6 changed files with 47 additions and 1 deletions

View File

@ -17,6 +17,11 @@ R_API RCore *r_core_cast(void *p) {
return (RCore*)p;
}
R_API void r_core_cmd_flush (RCore *core) {
// alias
r_cons_flush ();
}
static int core_cmd_callback (void *user, const char *cmd) {
RCore *core = (RCore *)user;
return r_core_cmd0 (core, cmd);

View File

@ -176,6 +176,7 @@ R_API int r_core_fgets(char *buf, int len);
R_API int r_core_cmdf(void *user, const char *fmt, ...);
R_API int r_core_flush(void *user, const char *cmd);
R_API int r_core_cmd0(void *user, const char *cmd);
R_API void r_core_cmd_flush (RCore *core);
R_API void r_core_cmd_init(RCore *core);
R_API int r_core_cmd_pipe(RCore *core, char *radare_cmd, char *shell_cmd);
R_API char *r_core_cmd_str(RCore *core, const char *cmd);

View File

@ -2,5 +2,6 @@ LANG=ctypes
LANG_EXT=py
LIBS_PFX=
FORCE_SOEXT=1
MY_SOEXT=py
include ../rules.mk

View File

@ -0,0 +1,38 @@
from r_core import *
def flush(c):
c = RCons()
c.flush()
def flush2(c):
k = c.cons
k.__init_methods__()
k.flush()
def flush3(c):
k = c.cons
k.__init_methods__()
k.flush()
cons = RCons()
c = RCore ()
#c.__init_methods__ ()
h = c.file_open ("/bin/ls", 0, 0);
c.bin_load (None)
print (c.cmd_str ("px"))
c.cmd0 ("pd 10 @ entry0")
c.cmd0 ("px 20 @ 0")
print ("*** "+c.cmd_str('p8 16'))
c.cmd0 ("p8 20")
c.cmd_flush()
print "---"
c.cmd0 ("p8 20 @ $$+1")
#c.cmd_flush()
flush2(c)
# WTF WHY c = RCons instead of RCore?!?!?
c.cmd0 ("pd 3")
flush(c)

View File

@ -60,7 +60,7 @@ ifneq ($(SAVED),)
mkdir -p .skip
cp $(SAVED) .skip
endif
rm -f *.${SOEXT} r_*
rm -f r_*.${SOEXT}
ifneq ($(SAVED),)
cd .skip ; cp * ..
rm -rf .skip

View File

@ -101,6 +101,7 @@ public class RCore {
//public int cmdf(...);
public int cmd(string cmd, bool log);
public int cmd0(string cmd);
public void cmd_flush ();
public void cmd_init ();
// XXX. must be const in .h public int cmd_foreach(string cmd, string each);