* Fix build of python plugin in ArchLinux (python2.6 instead of 2.5)
* Simplify the perl plugin * Drop stupid \n debug in dietline O:)
This commit is contained in:
parent
5832a61958
commit
33d94abaec
3 changed files with 25 additions and 80 deletions
|
|
@ -5,8 +5,15 @@ all: lua.so dummy.so ruby.so python.so perl.so
|
|||
@true
|
||||
|
||||
python.so:
|
||||
-${CC} ${CFLAGS} -I/usr/include/python2.5 \
|
||||
-fPIC -shared -o python.so python.c -lpython >/dev/null 2>&1
|
||||
-gcc -lpython >/dev/null 2>&1 ; \
|
||||
if [ $$? = 0 ]; then \
|
||||
${CC} ${CFLAGS} -I/usr/include/python2.5 \
|
||||
-fPIC -shared -o python.so python.c -lpython ; \
|
||||
else \
|
||||
${CC} ${CFLAGS} -I/usr/include/python2.5 \
|
||||
-fPIC -shared -o python.so python.c \
|
||||
-I/usr/include/python2.6/ -lpython2.6 ; \
|
||||
fi
|
||||
|
||||
lua.so: lua.o
|
||||
-${CC} ${CFLAGS} -fPIC -shared -o lua.so lua.c -Wl,-R..
|
||||
|
|
|
|||
|
|
@ -13,69 +13,29 @@
|
|||
#include "r_core.h"
|
||||
static struct r_core_t *core = NULL;
|
||||
|
||||
extern PerlInterpreter *my_perl;
|
||||
PerlInterpreter *my_perl = NULL;
|
||||
static PerlInterpreter *my_perl = NULL;
|
||||
|
||||
extern void xs_init (pTHX);
|
||||
|
||||
void radare_perl(pTHX_ CV* cv)
|
||||
static void perl_radare_cmd(pTHX_ CV* cv)
|
||||
{
|
||||
char *cmd;
|
||||
dXSARGS;
|
||||
|
||||
char *str;
|
||||
dXSARGS;
|
||||
cmd = sv_pv(ST(0));
|
||||
str = r_core_cmd_str(core, cmd);
|
||||
ST(0) = newSVpvn(str, strlen(str));
|
||||
free(str);
|
||||
XSRETURN(1);
|
||||
#if 0
|
||||
if (!config.debug) {
|
||||
char *str;
|
||||
cmd = sv_pv(ST(0));
|
||||
str = pipe_command_to_string(cmd);
|
||||
ST(0) = newSVpvn(str, strlen(str));
|
||||
free(str);
|
||||
XSRETURN(1);
|
||||
} else {
|
||||
char str[4096];
|
||||
// XXX pipe_stdout_to_tmp_file is a br0ken idea
|
||||
str[0]='\0';
|
||||
cmd = sv_pv(ST(0));
|
||||
if (! pipe_stdout_to_tmp_file(file, cmd) ) {
|
||||
ST(0) = newSVpvn("", 0);
|
||||
return;
|
||||
}
|
||||
fd = fopen(file, "r");
|
||||
if (fd == NULL) {
|
||||
fprintf(stderr, "Cannot open tmpfile\n");
|
||||
unlink(file);
|
||||
ST(0) = newSVpvn("", 0);
|
||||
return;
|
||||
} else {
|
||||
while(!feof(fd)) {
|
||||
fgets(buf, 1023, fd);
|
||||
if (feof(fd)) break;
|
||||
if (strlen(buf)+strlen(str)> 4000) {
|
||||
fprintf(stderr, "Input line too large\n");
|
||||
break;
|
||||
}
|
||||
strcat(str, buf);
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
unlink(file);
|
||||
}
|
||||
#endif
|
||||
str = items; /* dummy */
|
||||
}
|
||||
|
||||
void xs_init(pTHX)
|
||||
static void xs_init(pTHX)
|
||||
{
|
||||
newXS("r", radare_perl, __FILE__);
|
||||
newXS("r", perl_radare_cmd, __FILE__);
|
||||
}
|
||||
|
||||
static int init(void *user)
|
||||
{
|
||||
char *perl_embed[] = { "", "-e", "0" };
|
||||
core = user;
|
||||
my_perl = perl_alloc();
|
||||
if (my_perl == NULL) {
|
||||
|
|
@ -83,6 +43,7 @@ static int init(void *user)
|
|||
return R_FALSE;
|
||||
}
|
||||
perl_construct(my_perl);
|
||||
perl_parse(my_perl, xs_init, 3, perl_embed, (char **)NULL);
|
||||
|
||||
return R_TRUE;
|
||||
}
|
||||
|
|
@ -96,44 +57,22 @@ static int fini(void *user)
|
|||
return R_TRUE;
|
||||
}
|
||||
|
||||
/* TODO: handle multi-line */
|
||||
static int prompt(void *user)
|
||||
{
|
||||
char str[1025];
|
||||
|
||||
/* prepare array */
|
||||
{
|
||||
char *perl_embed[] = { "", "-e", "0" };
|
||||
perl_parse(my_perl, xs_init, 3, perl_embed, (char **)NULL);
|
||||
}
|
||||
while(1) {
|
||||
printf("perl> ");
|
||||
fflush(stdout);
|
||||
fgets(str, 1023, stdin);
|
||||
if (feof(stdin))
|
||||
break;
|
||||
str[strlen(str)-1]='\0';
|
||||
if (!strcmp(str, "q"))
|
||||
break;
|
||||
eval_pv(str, TRUE);
|
||||
}
|
||||
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int run(void *user, const char *code, int len)
|
||||
{
|
||||
/* TODO: catcth errors */
|
||||
eval_pv(code, TRUE);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int run_file(void *user, const char *file)
|
||||
static int setargv(void *user, int argc, char **argv)
|
||||
{
|
||||
perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static const char *help =
|
||||
"Perl plugin usage:\n"
|
||||
" print \"r(pd 10)\\n\";\n";
|
||||
" print \"r(\"pd 10\")\\n\";\n";
|
||||
|
||||
static struct r_lang_handle_t r_lang_plugin_perl = {
|
||||
.name = "perl",
|
||||
|
|
@ -141,10 +80,10 @@ static struct r_lang_handle_t r_lang_plugin_perl = {
|
|||
.init = &init,
|
||||
.fini = &fini,
|
||||
.help = &help,
|
||||
.prompt = &prompt,
|
||||
.prompt = NULL,
|
||||
.run = &run,
|
||||
.run_file = &run_file,
|
||||
.set_argv = NULL,
|
||||
.run_file = NULL,
|
||||
.set_argv = setargv,
|
||||
};
|
||||
|
||||
struct r_lib_struct_t radare_plugin = {
|
||||
|
|
|
|||
|
|
@ -649,6 +649,5 @@ _end:
|
|||
r_line_hist_list();
|
||||
return r_line_nullstr;
|
||||
}
|
||||
IFDBG write(1,"\n",1);
|
||||
return r_line_buffer;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue