diff options
Diffstat (limited to 'src/analysis/db/analyst.c')
-rw-r--r-- | src/analysis/db/analyst.c | 99 |
1 files changed, 45 insertions, 54 deletions
diff --git a/src/analysis/db/analyst.c b/src/analysis/db/analyst.c index 2e1cc23..43fb840 100644 --- a/src/analysis/db/analyst.c +++ b/src/analysis/db/analyst.c @@ -29,59 +29,13 @@ #include <string.h> -#include "client-int.h" +#include "analyst-int.h" #include "../storage/storage.h" #include "../../core/logs.h" - - - - -/* ------------------------- PRISES EN COMPTE DES COMMANDES ------------------------- */ - - - - - - -/* Description de client à l'écoute (instance) */ -struct _GAnalystClient -{ - GHubClient parent; /* A laisser en premier */ - - char *cnt_hash; /* Empreinte du binaire lié */ - char *cnt_class; /* Interprétation du contenu */ - - GLoadedContent *loaded; /* Contenu chargé */ - GList *collections; /* Collections d'un binaire */ - - bool can_get_updates; /* Réception de maj possibles ?*/ - - snapshot_info_t *snapshots; /* Liste des instantanés */ - size_t snap_count; /* Taille de cette liste */ - GMutex snap_lock; /* Concurrence des accès */ - - snapshot_id_t current; /* Instantané courant */ - bool has_current; /* Validité de l'identifiant */ - GMutex cur_lock; /* Concurrence des accès */ - -}; - -/* Description de client à l'écoute (classe) */ -struct _GAnalystClientClass -{ - GHubClientClass parent; /* A laisser en premier */ - - /* Signaux */ - - void (* ready) (GAnalystClient *); - void (* server_status_changed) (GAnalystClient *, LoadingStatusHint); - void (* snapshots_updated) (GAnalystClient *); - void (* snapshot_changed) (GAnalystClient *); - -}; +/* ----------------------- DEFINITION D'ANALYSTE COMME CLIENT ----------------------- */ /* Initialise la classe des descriptions de fichier binaire. */ @@ -118,7 +72,6 @@ static bool g_analyst_client_handle_loading_hints(GAnalystClient *, packed_buffe - /* ---------------------------------------------------------------------------------- */ /* GLUES POUR LA GLIB */ /* ---------------------------------------------------------------------------------- */ @@ -158,6 +111,9 @@ GType g_loading_status_hint_type(void) +/* ---------------------------------------------------------------------------------- */ +/* DEFINITION D'ANALYSTE COMME CLIENT */ +/* ---------------------------------------------------------------------------------- */ /* Indique le type défini pour une description de client à l'écoute. */ @@ -330,7 +286,7 @@ static void g_analyst_client_finalize(GAnalystClient *client) * collections = ensemble de collections existantes. * * loaded = éventuel élément local préchargé. * * * -* Description : Prépare un client pour une connexion à une BD. * +* Description : Met en place un client pour une connexion à une BD. * * * * Retour : Structure mise en place ou NULL en cas d'échec. * * * @@ -341,16 +297,51 @@ static void g_analyst_client_finalize(GAnalystClient *client) GAnalystClient *g_analyst_client_new(const char *hash, const char *class, GList *collections, GLoadedContent *loaded) { GAnalystClient *result; /* Adresse à retourner */ + bool status; /* Bilan de l'initialisation */ result = g_object_new(G_TYPE_ANALYST_CLIENT, NULL); - result->cnt_hash = strdup(hash); - result->cnt_class = strdup(class); + status = g_analyst_client_setup(result, hash, class, collections, loaded); + + assert(status); + + if (!status) + g_clear_object(&result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : client = client pour les accès distants à initialiser. * +* hash = empreinte d'un binaire en cours d'analyse. * +* class = nature de l'interprétation de ce contenu. * +* collections = ensemble de collections existantes. * +* loaded = éventuel élément local préchargé. * +* * +* Description : Prépare un client pour une connexion à une BD. * +* * +* Retour : Structure mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_analyst_client_setup(GAnalystClient *client, const char *hash, const char *class, GList *collections, GLoadedContent *loaded) +{ + bool result; /* Bilan à retourner */ + + result = true; + + client->cnt_hash = strdup(hash); + client->cnt_class = strdup(class); - result->loaded = loaded; + client->loaded = loaded; if (loaded != NULL) g_object_ref(G_OBJECT(loaded)); - result->collections = collections; + client->collections = collections; return result; |