diff options
Diffstat (limited to 'src/analysis/db/client.c')
-rw-r--r-- | src/analysis/db/client.c | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/src/analysis/db/client.c b/src/analysis/db/client.c index beb30c1..4c525e1 100644 --- a/src/analysis/db/client.c +++ b/src/analysis/db/client.c @@ -104,6 +104,12 @@ static bool g_hub_client_start_common(GHubClient *, char *); /* Assure l'accueil des nouvelles mises à jour. */ static void *g_hub_client_update(GHubClient *); +/* Identifie le canal de communication pour envois au serveur. */ +static SSL *g_hub_client_get_ssl_fd(GHubClient *); + +/* Marque le canal de communication comme disponible. */ +static void g_hub_client_put_ssl_fd(GHubClient *, SSL *); + /* Indique le type défini pour une description de client à l'écoute. */ @@ -890,7 +896,7 @@ void g_hub_client_stop(GHubClient *client) * * ******************************************************************************/ -SSL *g_hub_client_get_ssl_fd(GHubClient *client) +static SSL *g_hub_client_get_ssl_fd(GHubClient *client) { SSL *result; /* Canal à retourner */ #ifndef NDEBUG @@ -932,7 +938,7 @@ SSL *g_hub_client_get_ssl_fd(GHubClient *client) * * ******************************************************************************/ -void g_hub_client_put_ssl_fd(GHubClient *client, SSL *tls_fd) +static void g_hub_client_put_ssl_fd(GHubClient *client, SSL *tls_fd) { g_mutex_unlock(&client->sending_lock); @@ -986,6 +992,63 @@ bool g_hub_client_save(GHubClient *client) /****************************************************************************** * * +* Paramètres : client = client pour les accès distants à manipuler. * +* item = élémnent à pousser vers un serveur de collection. * +* * +* Description : Ajoute un élément à la collection d'un serveur. * +* * +* Retour : true si la commande a bien été envoyée, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_hub_client_add_item(GHubClient *client, const GDbItem *item) +{ + bool result; /* Bilan partiel à remonter */ + packed_buffer out_pbuf; /* Tampon d'émission */ + SSL *tls_fd; /* Canal de communication SSL */ + DBFeatures feature; /* Domaine de fonctionnalité */ + GDbCollection *collec; /* Collection visée au final */ + + init_packed_buffer(&out_pbuf); + + tls_fd = g_hub_client_get_ssl_fd(client); + + if (tls_fd == NULL) + result = false; + + else + { + feature = g_db_item_get_feature(item); + + collec = find_collection_in_list(client->collections, feature); + if (collec == NULL) + { + result = false; + goto bad_item_feature; + } + + result = g_db_collection_pack(collec, &out_pbuf, DBA_ADD_ITEM, item); + + if (result) + result = ssl_send_packed_buffer(&out_pbuf, tls_fd); + + bad_item_feature: + + g_hub_client_put_ssl_fd(client, tls_fd); + + } + + exit_packed_buffer(&out_pbuf); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : client = client pour les accès distants à manipuler. * * timestamp = date du dernier élément à garder comme actif. * * * |