summaryrefslogtreecommitdiff
path: root/src/plugins/plugin.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2011-10-01 17:20:50 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2011-10-01 17:20:50 (GMT)
commit02cb3aa4e7b18b644b034a5c659c332becf99c9b (patch)
tree8d816e5f93820c6ef5ba804d7c0776a65d78329a /src/plugins/plugin.c
parente0266175537ec220544c050874be215b11c902fa (diff)
Defined the first real [python] plugin.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@210 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/plugins/plugin.c')
-rw-r--r--src/plugins/plugin.c81
1 files changed, 67 insertions, 14 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 2443768..ce8ef37 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -99,7 +99,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
{
GPluginModule *result; /* Structure à retourner */
get_plugin_action_fc __get_type; /* Type(s) de greffon */
- get_plugin_action_fc __get_action; /* Actions du greffon */
+ get_plugin_action_fc get_action; /* Actions du greffon */
result = g_object_new(G_TYPE_PLUGIN_MODULE, NULL);
@@ -107,6 +107,21 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
result->module = g_module_open(filename, G_MODULE_BIND_LAZY);
+ if (!result->module)
+ {
+ printf("err null mod\n");
+ return NULL;
+
+ }
+
+
+ if (!g_module_symbol(result->module, "init_plugin", (gpointer *)&result->init))
+ {
+ printf("Err plugin init sym\n");
+ /* TODO */
+ }
+
+ /*
if (!g_module_symbol(result->module, "get_plugin_type", (gpointer *)&__get_type))
@@ -119,20 +134,20 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
printf("Plugin type :: 0x%08x\n", result->type);
+ */
-
-#if 1
- if (!g_module_symbol(result->module, "get_plugin_action", (gpointer *)&__get_action))
+ if (!g_module_symbol(result->module, "get_plugin_action", (gpointer *)&get_action))
{
printf("Err plugin get_action sym\n");
//g_object_destroy(result);
return NULL;
}
- result->action = __get_action();
+ result->get_action = get_action;
+ /*
if (result->action & (PGA_DISASSEMBLE | PGA_CODE_PROCESS))
{
if (!g_module_symbol(result->module, "execute_action_on_binary", (gpointer *)&result->exec_on_bin))
@@ -144,14 +159,7 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
}
-#endif
-
-
- if (!g_module_symbol(result->module, "init_plugin", (gpointer *)&result->init))
- {
- printf("Err plugin init sym\n");
- /* TODO */
- }
+ */
@@ -188,11 +196,56 @@ GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
PluginAction g_plugin_module_get_action(const GPluginModule *plugin)
{
- return plugin->action;
+ return plugin->get_action(plugin);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : plugin = greffon de prise en charge à utiliser. *
+* filename = éventuel nom de fichier associé ou NULL. [OUT] *
+* data = données chargées. [OUT] *
+* length = quantité de ces données. [OUT] *
+* *
+* Description : Identifie un format à associer à un contenu binaire. *
+* *
+* Retour : Bilan de la recherche de correspondances. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+MatchingFormatAction g_plugin_module_is_matching(const GPluginModule *plugin, char **filename, bin_t **data, off_t *length)
+{
+ MatchingFormatAction result; /* Valeur à retourner */
+ char *old_filename; /* Ancien nom de fichier */
+ bin_t *old_data; /* Ancien contenu binaire */
+
+ if (plugin->is_matching == NULL)
+ return MFA_NONE;
+
+ old_filename = *filename;
+ old_data = *data;
+
+ result = plugin->is_matching(plugin, filename, data, length);
+
+ if (result == MFA_RELOAD)
+ {
+ if (old_filename != NULL)
+ free(old_filename);
+ free(old_data);
+ }
+
+ return result;
}
+
+
+
+
/******************************************************************************
* *
* Paramètres : plugin = greffon à consulter. *