diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-09-08 17:41:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-09-08 17:41:58 (GMT) |
commit | 1430874c1ce9d5e38a23bf27049ebc5f6a6619bb (patch) | |
tree | 5b57937b6b5a98244b8d63f969d2350eb00739ec /src | |
parent | 8002f34e4060e25cb3acee76a0c2ae2970f9e9dc (diff) |
Provided a way to save the database updates from Python.
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/binary.c | 7 | ||||
-rw-r--r-- | src/analysis/binary.h | 4 | ||||
-rw-r--r-- | src/analysis/db/client.c | 21 | ||||
-rw-r--r-- | src/gui/panels/history.c | 4 |
4 files changed, 20 insertions, 16 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 639d6cc..5d72c41 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -958,9 +958,10 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *binary) /****************************************************************************** * * -* Paramètres : binary = élément binaire à consulter. * +* Paramètres : binary = élément binaire à consulter. * +* internal = sélectionne le client à renvoyer selon sa nature. * * * -* Description : Fournit le client assurant la liaison avec un serveur. * +* Description : Fournit un client assurant la liaison avec un serveur. * * * * Retour : Client connecté ou NULL. * * * @@ -968,7 +969,7 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *binary) * * ******************************************************************************/ -GHubClient *g_loaded_binary_get_db_client(const GLoadedBinary *binary) +GHubClient *g_loaded_binary_get_client(const GLoadedBinary *binary, bool internal) { GHubClient *result; /* Instance à retourner */ diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 9b3aa6b..36966c9 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -116,8 +116,8 @@ bool g_loaded_binary_save_cache(const GLoadedBinary *); /* -------------------------- MANIPULATION DES COLLECTIONS -------------------------- */ -/* Fournit le client assurant la liaison avec un serveur. */ -GHubClient *g_loaded_binary_get_db_client(const GLoadedBinary *); +/* Fournit un client assurant la liaison avec un serveur. */ +GHubClient *g_loaded_binary_get_client(const GLoadedBinary *, bool); /* Fournit l'ensemble des collections utilisées par un binaire. */ GDbCollection **g_loaded_binary_get_all_collections(const GLoadedBinary *, size_t *); diff --git a/src/analysis/db/client.c b/src/analysis/db/client.c index 2bfa978..329d57d 100644 --- a/src/analysis/db/client.c +++ b/src/analysis/db/client.c @@ -61,8 +61,6 @@ struct _GHubClient { GObject parent; /* A laisser en premier */ - const char *name; /* Désignation du binaire */ - rle_string hash; /* Empreinte du binaire lié */ GList *collections; /* Collections d'un binaire */ @@ -756,10 +754,10 @@ static void *g_hub_client_update(GHubClient *client) if (error == DBE_NONE) log_variadic_message(LMT_INFO, _("Archive saved for binary '%s'"), - client->name); + get_rle_string(&client->hash)); else log_variadic_message(LMT_ERROR, _("Failed to save the archive for binary '%s'"), - client->name); + get_rle_string(&client->hash)); break; @@ -951,16 +949,21 @@ void g_hub_client_put_ssl_fd(GHubClient *client, SSL *tls_fd) bool g_hub_client_save(GHubClient *client) { bool result; /* Bilan partiel à remonter */ - int sent; /* Quantité de données traitées*/ + packed_buffer out_pbuf; /* Tampon d'émission */ + + init_packed_buffer(&out_pbuf); g_hub_client_get_ssl_fd(client); - sent = SSL_write(client->tls_fd, (uint32_t []) { htobe32(DBC_SAVE) }, sizeof(uint32_t)); + result = extend_packed_buffer(&out_pbuf, (uint32_t []) { DBC_SAVE }, sizeof(uint32_t), true); - result = (sent == sizeof(uint32_t)); + if (result) + result = ssl_send_packed_buffer(&out_pbuf, client->tls_fd); g_hub_client_put_ssl_fd(client, client->tls_fd); + exit_packed_buffer(&out_pbuf); + return result; } @@ -993,11 +996,11 @@ bool g_hub_client_set_last_active(GHubClient *client, timestamp_t timestamp) if (result) result = pack_timestamp(×tamp, &out_pbuf); - g_hub_client_put_ssl_fd(client, client->tls_fd); - if (result) result = ssl_send_packed_buffer(&out_pbuf, client->tls_fd); + g_hub_client_put_ssl_fd(client, client->tls_fd); + exit_packed_buffer(&out_pbuf); return result; diff --git a/src/gui/panels/history.c b/src/gui/panels/history.c index 4383ed6..ac33c2c 100644 --- a/src/gui/panels/history.c +++ b/src/gui/panels/history.c @@ -614,7 +614,7 @@ static void do_history_undo(GtkButton *button, GHistoryPanel *panel) gtk_tree_model_get(model, &iter, HTC_ITEM, &item, -1); - client = g_loaded_binary_get_db_client(panel->binary); + client = g_loaded_binary_get_client(panel->binary, true); g_hub_client_set_last_active(client, g_db_item_get_timestamp(item)); g_object_unref(G_OBJECT(client)); @@ -658,7 +658,7 @@ static void do_history_redo(GtkButton *button, GHistoryPanel *panel) { gtk_tree_model_get(model, &iter, HTC_ITEM, &item, -1); - client = g_loaded_binary_get_db_client(panel->binary); + client = g_loaded_binary_get_client(panel->binary, true); g_hub_client_set_last_active(client, g_db_item_get_timestamp(item)); g_object_unref(G_OBJECT(client)); |