* Avoid dupped langs plugins in queue

* Hardcode vala plugin by default
This commit is contained in:
pancake 2011-02-06 18:44:56 +01:00
parent 6db4e28e02
commit 986f66c14f
4 changed files with 26 additions and 19 deletions

16
TODO
View File

@ -43,6 +43,14 @@ pancake
earada earada
------ ------
- r_bin_demangle (); // r_util maybe?
* _ZN7WebCore11CounterNode7recountERKNS_12AtomicStringE
- demangle c++ and objc names
WebCore.CounterNode.recount(AtomicString)
_ZN = begin of stream
0-9+ = count of chars
E = end of stream
RKNS_ = start of arguments
* Fix avr/ppc code analysis // fix or use or what? :) * Fix avr/ppc code analysis // fix or use or what? :)
* Implement print Zoom mode (copypasta from r1) (useful for forensics) <-- MUST * Implement print Zoom mode (copypasta from r1) (useful for forensics) <-- MUST
* mount /mnt/ must chop last '/' * mount /mnt/ must chop last '/'
@ -97,14 +105,6 @@ nibble
- "wx jeje" does not says "invalid hexpair string" (must report error) - "wx jeje" does not says "invalid hexpair string" (must report error)
- allow to hook r_asm_disassemble and assemble with custom callbacks - allow to hook r_asm_disassemble and assemble with custom callbacks
- extend a disassembler with own instructions. - extend a disassembler with own instructions.
- r_bin_demangle (); // r_util maybe?
* _ZN7WebCore11CounterNode7recountERKNS_12AtomicStringE
- demangle c++ and objc names
WebCore.CounterNode.recount(AtomicString)
_ZN = begin of stream
0-9+ = count of chars
E = end of stream
RKNS_ = start of arguments
Assembler Assembler

View File

@ -46,6 +46,7 @@ R_API int r_lang_run(RLang *lang, const char *code, int len);
R_API int r_lang_run_file(RLang *lang, const char *file); R_API int r_lang_run_file(RLang *lang, const char *file);
R_API int r_lang_prompt(RLang *lang); R_API int r_lang_prompt(RLang *lang);
R_API void r_lang_plugin_free (RLang *lang, RLangPlugin *p); R_API void r_lang_plugin_free (RLang *lang, RLangPlugin *p);
R_API RLangPlugin *r_lang_get (RLang *lang, const char *name);
// TODO: rename r_Lang_add for r_lang_plugin_add // TODO: rename r_Lang_add for r_lang_plugin_add
R_API int r_lang_define(RLang *lang, const char *type, const char *name, void *value); R_API int r_lang_define(RLang *lang, const char *type, const char *name, void *value);

View File

@ -13,6 +13,7 @@ R_API RLang *r_lang_new() {
lang->langs->free = (RListFree)r_lang_plugin_free; lang->langs->free = (RListFree)r_lang_plugin_free;
lang->defs = r_list_new (); lang->defs = r_list_new ();
lang->defs->free = (RListFree)r_lang_def_free; lang->defs->free = (RListFree)r_lang_def_free;
r_lang_add (lang, &r_lang_plugin_vala);
} }
return lang; return lang;
} }
@ -85,7 +86,7 @@ R_API void r_lang_plugin_free (RLang *lang, RLangPlugin *p) {
} }
R_API int r_lang_add(RLang *lang, RLangPlugin *foo) { R_API int r_lang_add(RLang *lang, RLangPlugin *foo) {
if (foo) { if (foo && (!r_lang_get (lang, foo->name))) {
if (foo->init) if (foo->init)
foo->init (lang->user); foo->init (lang->user);
r_list_append (lang->langs, foo); r_list_append (lang->langs, foo);
@ -103,16 +104,23 @@ R_API int r_lang_list(RLang *lang) {
return R_FALSE; return R_FALSE;
} }
R_API int r_lang_use(RLang *lang, const char *name) { R_API RLangPlugin *r_lang_get (RLang *lang, const char *name) {
RListIter *iter; RListIter *iter;
RLangPlugin *h; RLangPlugin *h;
r_list_foreach (lang->langs, iter, h) { r_list_foreach (lang->langs, iter, h) {
if (!strcmp (h->name, name)) { if (!strcmp (h->name, name)) {
lang->cur = h; return h;
return R_TRUE;
} }
} }
lang->cur = NULL; return NULL;
}
R_API int r_lang_use(RLang *lang, const char *name) {
RLangPlugin *h = r_lang_get (lang, name);
if (h) {
lang->cur = h;
return R_TRUE;
}
return R_FALSE; return R_FALSE;
} }

View File

@ -1,17 +1,15 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */ /* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
/* vala extension for libr (radare2) */ /* vala extension for libr (radare2) */
// TODO: add support for Genie // TODO: add support for Genie
// TODO: add cache directory (~/.r2/cache)
#include "r_lib.h" #include "r_lib.h"
#include "r_core.h" #include "r_core.h"
#include "r_lang.h" #include "r_lang.h"
#define LIBDIR PREFIX"/lib"
static int r_vala_file(RLang *lang, const char *file) { static int r_vala_file(RLang *lang, const char *file) {
void *lib; void *lib;
char *p, name[512]; char *p, name[512], buf[512];
char buf[512];
if (!strstr (file, ".vala")) if (!strstr (file, ".vala"))
sprintf (name, "%s.vala", file); sprintf (name, "%s.vala", file);
@ -58,8 +56,8 @@ static int vala_run(RLang *lang, const char *code, int len) {
fputs (code, fd); fputs (code, fd);
fputs (";\n}\n", fd); fputs (";\n}\n", fd);
fclose (fd); fclose (fd);
r_vala_file (lang->user, ".tmp.vala"); // r_vala_file (lang->user, ".tmp.vala");
r_file_rm (".tmp.vala"); // r_file_rm (".tmp.vala");
} else eprintf ("Cannot open .tmp.vala\n"); } else eprintf ("Cannot open .tmp.vala\n");
return R_TRUE; return R_TRUE;
} }