Rizin
unix-like reverse engineering framework and cli tools
cplugin.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2010-2020 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <config.h>
5 #include <rz_core.h>
6 #include <rz_cmd.h>
7 #include <rz_list.h>
8 #include <stdio.h>
9 
11 
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 }
26 
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 }
36 
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
#define RZ_CORE_STATIC_PLUGINS
Definition: config.h:23
#define RZ_API
RZ_API bool rz_core_plugin_init(RzCore *core)
Definition: cplugin.c:37
RZ_API bool rz_core_plugin_fini(RzCore *core)
Definition: cplugin.c:12
RZ_API bool rz_core_plugin_add(RzCore *core, RzCorePlugin *plugin)
Definition: cplugin.c:27
static RzCorePlugin * core_static_plugins[]
Definition: cplugin.c:10
#define NULL
Definition: cris-opc.c:27
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
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
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
#define eprintf(x, y...)
Definition: rlcc.c:7
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
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
RzCorePluginFini fini
Definition: rz_core.h:130
RzList * plugins
List of registered core plugins.
Definition: rz_core.h:299