Rizin
unix-like reverse engineering framework and cli tools
cplugin.c File Reference
#include <config.h>
#include <rz_core.h>
#include <rz_cmd.h>
#include <rz_list.h>
#include <stdio.h>

Go to the source code of this file.

Functions

RZ_API bool rz_core_plugin_fini (RzCore *core)
 
RZ_API bool rz_core_plugin_add (RzCore *core, RzCorePlugin *plugin)
 
RZ_API bool rz_core_plugin_init (RzCore *core)
 

Variables

static RzCorePlugincore_static_plugins [] = { RZ_CORE_STATIC_PLUGINS }
 

Function Documentation

◆ rz_core_plugin_add()

RZ_API bool rz_core_plugin_add ( RzCore core,
RzCorePlugin plugin 
)

Definition at line 27 of file cplugin.c.

27  {
28  rz_return_val_if_fail(core, false);
29  rz_return_val_if_fail(plugin && plugin->init && plugin->name && plugin->author && plugin->license, false);
30  if (!plugin->init(core)) {
31  return false;
32  }
33  rz_list_append(core->plugins, plugin);
34  return true;
35 }
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
const char * license
Definition: rz_core.h:126
RzCorePluginInit init
Definition: rz_core.h:129
const char * author
Definition: rz_core.h:127
const char * name
Definition: rz_core.h:124
RzList * plugins
List of registered core plugins.
Definition: rz_core.h:299

References rz_core_plugin_t::author, rz_core_plugin_t::init, rz_core_plugin_t::license, rz_core_plugin_t::name, rz_core_t::plugins, rz_list_append(), and rz_return_val_if_fail.

Referenced by __lib_core_cb(), and rz_core_plugin_init().

◆ rz_core_plugin_fini()

RZ_API bool rz_core_plugin_fini ( RzCore core)

Definition at line 12 of file cplugin.c.

12  {
13  rz_return_val_if_fail(core->plugins, false);
14 
16  RzCorePlugin *plugin;
17  rz_list_foreach (core->plugins, iter, plugin) {
18  if (plugin->fini) {
19  plugin->fini(core);
20  }
21  }
22  rz_list_free(core->plugins);
23  core->plugins = NULL;
24  return true;
25 }
#define NULL
Definition: cris-opc.c:27
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RzCorePluginFini fini
Definition: rz_core.h:130

References rz_core_plugin_t::fini, NULL, rz_core_t::plugins, rz_list_free(), and rz_return_val_if_fail.

Referenced by rz_core_fini().

◆ rz_core_plugin_init()

RZ_API bool rz_core_plugin_init ( RzCore core)

Definition at line 37 of file cplugin.c.

37  {
38  int i;
39  core->plugins = rz_list_newf(NULL); // memleak or dblfree
40  for (i = 0; i < RZ_ARRAY_SIZE(core_static_plugins); i++) {
42  eprintf("Error loading core plugin\n");
43  return false;
44  }
45  }
46  return true;
47 }
lzma_index ** i
Definition: index.h:629
RZ_API bool rz_core_plugin_add(RzCore *core, RzCorePlugin *plugin)
Definition: cplugin.c:27
static RzCorePlugin * core_static_plugins[]
Definition: cplugin.c:10
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
#define eprintf(x, y...)
Definition: rlcc.c:7
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300

References core_static_plugins, eprintf, i, NULL, rz_core_t::plugins, RZ_ARRAY_SIZE, rz_core_plugin_add(), and rz_list_newf().

Referenced by rz_core_init().

Variable Documentation

◆ core_static_plugins

RzCorePlugin* core_static_plugins[] = { RZ_CORE_STATIC_PLUGINS }
static

Definition at line 10 of file cplugin.c.

Referenced by rz_core_plugin_init().