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/bookmark.c | |
parent | 7d153f7d3a32a66d3eaf5199d396debbe3b675f5 (diff) |
Defined abstract packed buffers to transfert data.
Diffstat (limited to 'src/analysis/db/items/bookmark.c')
-rw-r--r-- | src/analysis/db/items/bookmark.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c index 6289588..9d3b691 100644 --- a/src/analysis/db/items/bookmark.c +++ b/src/analysis/db/items/bookmark.c @@ -76,10 +76,10 @@ static void g_db_bookmark_finalize(GDbBookmark *); static gint g_db_bookmark_cmp(GDbBookmark *, GDbBookmark *, bool); /* Importe la définition d'un signet dans un flux réseau. */ -static bool g_db_bookmark_recv_from_fd(GDbBookmark *, int, int); +static bool g_db_bookmark_unpack(GDbBookmark *, packed_buffer *); /* Exporte la définition d'un signet dans un flux réseau. */ -static bool g_db_bookmark_send_to_fd(const GDbBookmark *, int, int); +static bool g_db_bookmark_pack(const GDbBookmark *, packed_buffer *); /* Construit la description humaine d'un signet sur un tampon. */ static void g_db_bookmark_build_label(GDbBookmark *); @@ -179,8 +179,8 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass) item->cmp = (cmp_db_item_fc)g_db_bookmark_cmp; - item->recv = (recv_db_item_fc)g_db_bookmark_recv_from_fd; - item->send = (send_db_item_fc)g_db_bookmark_send_to_fd; + item->unpack = (unpack_db_item_fc)g_db_bookmark_unpack; + item->pack = (pack_db_item_fc)g_db_bookmark_pack; item->build_label = (build_item_label_fc)g_db_bookmark_build_label; item->apply = (run_item_fc)g_db_bookmark_apply; @@ -312,8 +312,7 @@ static gint g_db_bookmark_cmp(GDbBookmark *a, GDbBookmark *b, bool with) /****************************************************************************** * * * Paramètres : bookmark = signet dont les informations sont à charger. [OUT]* -* fd = flux ouvert en lecture pour l'importation. * -* flags = éventuelles options d'envoi supplémentaires. * +* pbuf = paquet de données où venir inscrire les infos. * * * * Description : Importe la définition d'un signet dans un flux réseau. * * * @@ -323,20 +322,19 @@ static gint g_db_bookmark_cmp(GDbBookmark *a, GDbBookmark *b, bool with) * * ******************************************************************************/ -static bool g_db_bookmark_recv_from_fd(GDbBookmark *bookmark, int fd, int flags) +static bool g_db_bookmark_unpack(GDbBookmark *bookmark, packed_buffer *pbuf) { - bool status; /* Bilan d'opération initiale */ + bool result; /* Bilan à retourner */ - status = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->recv(G_DB_ITEM(bookmark), fd, flags); - if (!status) return false; + result = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->unpack(G_DB_ITEM(bookmark), pbuf); - if (!recv_vmpa(&bookmark->addr, fd, flags)) - return false; + if (result) + result = unpack_vmpa(&bookmark->addr, pbuf); - if (!recv_rle_string(&bookmark->comment, fd, flags)) - return false; + if (result) + result = unpack_rle_string(&bookmark->comment, pbuf); - return true; + return result; } @@ -344,8 +342,7 @@ static bool g_db_bookmark_recv_from_fd(GDbBookmark *bookmark, int fd, int flags) /****************************************************************************** * * * Paramètres : bookmark = informations à sauvegarder. * -* fd = flux ouvert en écriture pour l'exportation. * -* flags = éventuelles options d'envoi supplémentaires. * +* pbuf = paquet de données où venir inscrire les infos. * * * * Description : Exporte la définition d'un signet dans un flux réseau. * * * @@ -355,20 +352,19 @@ static bool g_db_bookmark_recv_from_fd(GDbBookmark *bookmark, int fd, int flags) * * ******************************************************************************/ -static bool g_db_bookmark_send_to_fd(const GDbBookmark *bookmark, int fd, int flags) +static bool g_db_bookmark_pack(const GDbBookmark *bookmark, packed_buffer *pbuf) { - bool status; /* Bilan d'opération initiale */ + bool result; /* Bilan à retourner */ - status = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->send(G_DB_ITEM(bookmark), fd, MSG_MORE | flags); - if (!status) return false; + result = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->pack(G_DB_ITEM(bookmark), pbuf); - if (!send_vmpa(&bookmark->addr, fd, MSG_MORE | flags)) - return false; + if (result) + result = pack_vmpa(&bookmark->addr, pbuf); - if (!send_rle_string(&bookmark->comment, fd, flags)) - return false; + if (result) + result = pack_rle_string(&bookmark->comment, pbuf); - return true; + return result; } |