2010-02-25 23:37:49 +00:00
|
|
|
/* radare - LGPL - Copyright 2010 pancake<nopcode.org> */
|
|
|
|
|
|
|
|
/* covardly copied from r_cmd */
|
|
|
|
|
|
|
|
#include "../config.h"
|
|
|
|
#include <r_cmd.h>
|
|
|
|
#include <r_list.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2010-05-25 23:42:22 +00:00
|
|
|
static struct r_cmd_plugin_t *cmd_static_plugins[] =
|
2010-02-25 23:37:49 +00:00
|
|
|
{ R_CMD_STATIC_PLUGINS };
|
|
|
|
|
2010-05-26 16:25:35 +00:00
|
|
|
R_API int r_cmd_plugin_add(struct r_cmd_t *cmd, struct r_cmd_plugin_t *plugin) {
|
2010-02-25 23:37:49 +00:00
|
|
|
r_list_append (cmd->plist, plugin);
|
|
|
|
return R_TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-26 16:25:35 +00:00
|
|
|
R_API int r_cmd_plugin_init(struct r_cmd_t *cmd) {
|
2010-02-25 23:37:49 +00:00
|
|
|
int i;
|
|
|
|
cmd->plist = r_list_new ();
|
|
|
|
for (i=0; cmd_static_plugins[i]; i++)
|
2010-05-26 16:25:35 +00:00
|
|
|
if (!r_cmd_plugin_add (cmd, cmd_static_plugins[i])) {
|
2010-02-25 23:37:49 +00:00
|
|
|
eprintf ("Error loading cmd plugin\n");
|
|
|
|
return R_FALSE;
|
|
|
|
}
|
|
|
|
return R_TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-26 16:25:35 +00:00
|
|
|
R_API int r_cmd_plugin_check(struct r_cmd_t *cmd, const char *a0) {
|
2010-02-25 23:37:49 +00:00
|
|
|
RListIter *iter;
|
2010-05-25 23:42:22 +00:00
|
|
|
RCmdPlugin *cp;
|
2010-02-25 23:37:49 +00:00
|
|
|
|
|
|
|
iter = r_list_iterator (cmd->plist);
|
|
|
|
while (r_list_iter_next (iter)) {
|
2010-05-25 23:42:22 +00:00
|
|
|
cp = (RCmdPlugin*) r_list_iter_get (iter);
|
2010-02-25 23:37:49 +00:00
|
|
|
if (cp->call (NULL, a0))
|
|
|
|
return R_TRUE;
|
|
|
|
}
|
|
|
|
return R_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// TODO: must return an r_iter ator
|
2010-05-26 16:25:35 +00:00
|
|
|
R_API int r_cmd_plugin_list(struct r_cmd_t *cmd) {
|
2010-02-25 23:37:49 +00:00
|
|
|
int n = 0;
|
|
|
|
struct list_head *pos;
|
2010-05-26 22:57:25 +00:00
|
|
|
cmd->printf ("IO plugins:\n");
|
2010-02-25 23:37:49 +00:00
|
|
|
list_for_each_prev(pos, &cmd->plist) {
|
|
|
|
struct r_cmd_list_t *il = list_entry(pos, struct r_cmd_list_t, list);
|
|
|
|
cmd->printf(" - %s\n", il->plugin->name);
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
#endif
|