Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rparse to rcore binding for afen #346

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions afen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Install:

meson install -C build

## Running:
## Run:

r2 -e asm.pseudo=true <file>
r2 -e asm.parser=rparse-afen -e asm.pseudo=true <file>

## Usage:

Expand Down
32 changes: 20 additions & 12 deletions afen/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ 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);
Expand All @@ -31,29 +30,37 @@ static int r_afen_parse(RParse *p, const char *data, char *str) {
}

strcpy (str, input);
return res;
return true;
}

// RParse plugin Definition Info
RParsePlugin r_parse_plugin_afen = {
.name = "rparse-afen",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about naming it “afen”

Suggested change
.name = "rparse-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) {
static int r_core_fini_afen(void *user, const char *input) {
r_list_free(old_names);
r_list_free(new_names);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before (


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);
Expand All @@ -71,17 +78,18 @@ static int r_cmd_afen_client(void *user, const char *input) {
return false;
}

// PLUGIN Definition Info

// RCore plugin Definition Info
RCorePlugin r_core_plugin_afen = {
.meta = {
.name = "core-afen",
.desc = "Rename expressions",
.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
};


Expand Down
Loading