Add pkgname in RLibStruct for r2pm on outdated plugins ##core (#15813)

This commit is contained in:
radare 2020-01-15 09:49:41 +01:00 committed by GitHub
parent f64f2211fb
commit 31e71d340f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 1 deletions

View File

@ -101,6 +101,19 @@ R_API void r_core_loadlibs_init(RCore *core) {
core->times->loadlibs_init_time = r_sys_now () - prev;
}
static bool __isScriptFilename(const char *name) {
const char *ext = r_str_lchr (name, '.');
if (ext) {
ext++;
if (!strcmp (ext, "py")
|| !strcmp (ext, "js")
|| !strcmp (ext, "lua")) {
return true;
}
}
return false;
}
R_API int r_core_loadlibs(RCore *core, int where, const char *path) {
ut64 prev = r_sys_now ();
__loadSystemPlugins (core, where, path);
@ -115,7 +128,7 @@ R_API int r_core_loadlibs(RCore *core, int where, const char *path) {
RListIter *iter;
char *file;
r_list_foreach (files, iter, file) {
bool isScript = r_str_endswith (file, ".py") || r_str_endswith (file, ".js") || r_str_endswith (file, ".lua");
bool isScript = __isScriptFilename (file);
if (isScript) {
r_core_cmdf (core, ". %s/%s", homeplugindir, file);
}

View File

@ -87,6 +87,7 @@ typedef struct r_cmd_descriptor_t {
struct r_cmd_descriptor_t *sub[127];
} RCmdDescriptor;
// TODO: move into r_core.h
typedef struct r_core_plugin_t {
const char *name;
const char *desc;

View File

@ -59,6 +59,7 @@ typedef struct r_lib_struct_t {
void *data; /* pointer to data handled by plugin handler */
const char *version; /* r2 version */
void (*free)(void *data);
const char *pkgname; /* pkgname associated to this plugin */
} RLibStruct;
typedef RLibStruct* (*RLibStructFunc) (void);

View File

@ -303,6 +303,9 @@ R_API int r_lib_open_ptr(RLib *lib, const char *file, void *handler, RLibStruct
if (strcmp (stru->version, R2_VERSION)) {
eprintf ("Module version mismatch %s (%s) vs (%s)\n",
file, stru->version, R2_VERSION);
if (stru->pkgname) {
printf ("r2pm -ci %s\n", stru->pkgname);
}
return -1;
}
}