diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-02-28 18:58:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-02-28 18:58:57 (GMT) |
commit | 027305c2447b05de2c576e3f5ee32ced400f439f (patch) | |
tree | 96f35ddcd87129f3c4ccec69e8fa0216654215c9 /src/analysis/db/items/move.c | |
parent | 7d153f7d3a32a66d3eaf5199d396debbe3b675f5 (diff) |
Defined abstract packed buffers to transfert data.
Diffstat (limited to 'src/analysis/db/items/move.c')
-rw-r--r-- | src/analysis/db/items/move.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/analysis/db/items/move.c b/src/analysis/db/items/move.c index c781170..ddbcab1 100644 --- a/src/analysis/db/items/move.c +++ b/src/analysis/db/items/move.c @@ -35,7 +35,6 @@ #include "../collection-int.h" #include "../item-int.h" -#include "../../../common/io.h" #include "../../../gui/editem.h" #include "../../../gtkext/gtkdisplaypanel.h" @@ -81,10 +80,10 @@ static void g_db_move_finalize(GDbMove *); static gint g_db_move_cmp(GDbMove *, GDbMove *, bool); /* Importe la définition d'un déplacement depuis un flux réseau. */ -static bool g_db_move_recv_from_fd(GDbMove *, int, int); +static bool g_db_move_unpack(GDbMove *, packed_buffer *); /* Exporte la définition d'un déplacement dans un flux réseau. */ -static bool g_db_move_send_to_fd(const GDbMove *, int, int); +static bool g_db_move_pack(const GDbMove *, packed_buffer *); /* Construit la description humaine d'un déplacement. */ static void g_db_move_build_label(GDbMove *); @@ -185,8 +184,8 @@ static void g_db_move_class_init(GDbMoveClass *klass) item->cmp = (cmp_db_item_fc)g_db_move_cmp; - item->recv = (recv_db_item_fc)g_db_move_recv_from_fd; - item->send = (send_db_item_fc)g_db_move_send_to_fd; + item->unpack = (unpack_db_item_fc)g_db_move_unpack; + item->pack = (pack_db_item_fc)g_db_move_pack; item->build_label = (build_item_label_fc)g_db_move_build_label; item->apply = (run_item_fc)g_db_move_apply; @@ -314,9 +313,8 @@ static gint g_db_move_cmp(GDbMove *a, GDbMove *b, bool with) /****************************************************************************** * * -* Paramètres : move = bascule d'affichage aux infos à charger. [OUT] * -* fd = flux ouvert en lecture pour l'importation. * -* flags = éventuelles options d'envoi supplémentaires. * +* Paramètres : move = bascule d'affichage aux infos à charger. [OUT] * +* pbuf = paquet de données où venir inscrire les infos. * * * * Description : Importe la définition d'un déplacement depuis un flux réseau.* * * @@ -326,29 +324,27 @@ static gint g_db_move_cmp(GDbMove *a, GDbMove *b, bool with) * * ******************************************************************************/ -static bool g_db_move_recv_from_fd(GDbMove *move, int fd, int flags) +static bool g_db_move_unpack(GDbMove *move, packed_buffer *pbuf) { - bool status; /* Bilan d'opération initiale */ + bool result; /* Bilan à retourner */ - status = G_DB_ITEM_CLASS(g_db_move_parent_class)->recv(G_DB_ITEM(move), fd, flags); - if (!status) return false; + result = G_DB_ITEM_CLASS(g_db_move_parent_class)->unpack(G_DB_ITEM(move), pbuf); - if (!recv_vmpa(&move->src, fd, flags)) - return false; + if (result) + result = pack_vmpa(&move->src, pbuf); - if (!recv_vmpa(&move->dest, fd, flags)) - return false; + if (result) + result = pack_vmpa(&move->dest, pbuf); - return true; + return result; } /****************************************************************************** * * -* Paramètres : move = bascule d'affichage aux infos à sauvegarder. * -* fd = flux ouvert en écriture pour l'exportation. * -* flags = éventuelles options d'envoi supplémentaires. * +* Paramètres : move = bascule d'affichage aux infos à sauvegarder. * +* pbuf = paquet de données où venir inscrire les infos. * * * * Description : Exporte la définition d'un déplacement dans un flux réseau. * * * @@ -358,20 +354,19 @@ static bool g_db_move_recv_from_fd(GDbMove *move, int fd, int flags) * * ******************************************************************************/ -static bool g_db_move_send_to_fd(const GDbMove *move, int fd, int flags) +static bool g_db_move_pack(const GDbMove *move, packed_buffer *pbuf) { - bool status; /* Bilan d'opération initiale */ + bool result; /* Bilan à retourner */ - status = G_DB_ITEM_CLASS(g_db_move_parent_class)->send(G_DB_ITEM(move), fd, MSG_MORE | flags); - if (!status) return false; + result = G_DB_ITEM_CLASS(g_db_move_parent_class)->pack(G_DB_ITEM(move), pbuf); - if (!send_vmpa(&move->src, fd, MSG_MORE | flags)) - return false; + if (result) + result = pack_vmpa(&move->src, pbuf); - if (!send_vmpa(&move->dest, fd, flags)) - return false; + if (result) + result = pack_vmpa(&move->dest, pbuf); - return true; + return result; } |