diff --git a/afen/README.md b/afen/README.md index a4fcbbc81..98ee8d4c4 100644 --- a/afen/README.md +++ b/afen/README.md @@ -19,9 +19,9 @@ Install: meson install -C build -## Running: +## Run: - r2 -e asm.pseudo=true + r2 -e asm.parser=afen -e asm.pseudo=true ## Usage: diff --git a/afen/src/main.c b/afen/src/main.c index fb45926f6..109cfd80d 100644 --- a/afen/src/main.c +++ b/afen/src/main.c @@ -8,13 +8,12 @@ static RList *old_names; static RList *new_names; // afen parser -static int r_afen_parse(RParse *p, const char *data, char *str) { - int res = true; +static int r_parse_afen(RParse *p, const char *data, char *str) { char *input = strdup (data); - int n = r_list_length(old_names); + int n = r_list_length (old_names); - if (n){ + if (n) { RListIter *s_iter_old = NULL; RListIter *s_iter_new = NULL; @@ -24,54 +23,63 @@ static int r_afen_parse(RParse *p, const char *data, char *str) { for (int i = 0; i < n; ++i) { input = r_str_replace_all (input, s_iter_old->data, s_iter_new->data); - s_iter_old = r_list_iter_get_next(s_iter_old); - s_iter_new = r_list_iter_get_next(s_iter_new); + s_iter_old = r_list_iter_get_next (s_iter_old); + s_iter_new = r_list_iter_get_next (s_iter_new); } } strcpy (str, input); - return res; + return true; } +// RParse plugin Definition Info +RParsePlugin r_parse_plugin_afen = { + .name = "afen", + .desc = "Afen parse plugin", + .parse = r_parse_afen, +}; + // sets afen parser -static int r_cmd_init(void *user, const char *input) { +static int r_core_init_afen(void *user, const char *input) { RCmd *rcmd = (RCmd *) user; RCore *core = (RCore *) rcmd->data; + + r_parse_plugin_add (core->parser, &r_parse_plugin_afen); + old_names = r_list_new (); new_names = r_list_new (); - - core->parser->cur->parse = r_afen_parse; return true; } -static int r_cmd_fini(void *user, const char *input) { - r_list_free(old_names); - r_list_free(new_names); +static int r_core_fini_afen(void *user, const char *input) { + r_list_free (old_names); + r_list_free (new_names); return true; } -static int r_cmd_afen_client(void *user, const char *input) { +static int r_core_call_afen(void *user, const char *input) { if (r_str_startswith (input, "afen")) { - int *argc = (int*) malloc(sizeof(int)); - char **argv = r_str_argv(input, argc); + int *argc = (int*) malloc (sizeof (int)); + char **argv = r_str_argv (input, argc); if (*argc != 3) { - r_cons_printf("Usage: afen new_name old_name\n"); + r_cons_printf ("Usage: afen new_name old_name\n"); return true; } - r_list_append(new_names, argv[1]); - r_list_append(old_names, argv[2]); + r_list_append (new_names, argv[1]); + r_list_append (old_names, argv[2]); return true; } return false; } -// PLUGIN Definition Info + +// RCore plugin Definition Info RCorePlugin r_core_plugin_afen = { .meta = { .name = "core-afen", @@ -79,9 +87,9 @@ RCorePlugin r_core_plugin_afen = { .author = "satk0", .license = "GPLv3", }, - .call = r_cmd_afen_client, - .init = r_cmd_init, - .fini = r_cmd_fini + .call = r_core_call_afen, + .init = r_core_init_afen, + .fini = r_core_fini_afen };