summaryrefslogtreecommitdiff
path: root/src/analysis/db/items
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/items')
-rw-r--r--src/analysis/db/items/bookmark.c48
-rw-r--r--src/analysis/db/items/comment.c92
-rw-r--r--src/analysis/db/items/move.c53
-rw-r--r--src/analysis/db/items/switcher.c74
4 files changed, 126 insertions, 141 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;
}
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index c021e44..15d541b 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -36,7 +36,6 @@
#include "../collection-int.h"
#include "../item-int.h"
#include "../../human/asm/lang.h"
-#include "../../../common/io.h"
#include "../../../common/extstr.h"
#include "../../../glibext/linegen-int.h"
@@ -97,10 +96,10 @@ static void g_db_comment_finalize(GDbComment *);
static gint g_db_comment_cmp(GDbComment *, GDbComment *, bool);
/* Importe la définition d'un commentaire dans un flux réseau. */
-static bool g_db_comment_recv_from_fd(GDbComment *, int, int);
+static bool g_db_comment_unpack(GDbComment *, packed_buffer *);
/* Exporte la définition d'un commentaire dans un flux réseau. */
-static bool g_db_comment_send_to_fd(const GDbComment *, int, int);
+static bool g_db_comment_pack(const GDbComment *, packed_buffer *);
/* Construit la description humaine d'un commentaire. */
static void g_db_comment_build_label(GDbComment *);
@@ -227,8 +226,8 @@ static void g_db_comment_class_init(GDbCommentClass *klass)
item->cmp = (cmp_db_item_fc)g_db_comment_cmp;
- item->recv = (recv_db_item_fc)g_db_comment_recv_from_fd;
- item->send = (send_db_item_fc)g_db_comment_send_to_fd;
+ item->unpack = (unpack_db_item_fc)g_db_comment_unpack;
+ item->pack = (pack_db_item_fc)g_db_comment_pack;
item->build_label = (build_item_label_fc)g_db_comment_build_label;
item->apply = (run_item_fc)g_db_comment_apply;
@@ -443,8 +442,7 @@ static gint g_db_comment_cmp(GDbComment *a, GDbComment *b, bool with)
/******************************************************************************
* *
* Paramètres : comment = commentaire avec 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 commentaire dans un flux réseau. *
* *
@@ -454,37 +452,39 @@ static gint g_db_comment_cmp(GDbComment *a, GDbComment *b, bool with)
* *
******************************************************************************/
-static bool g_db_comment_recv_from_fd(GDbComment *comment, int fd, int flags)
+static bool g_db_comment_unpack(GDbComment *comment, packed_buffer *pbuf)
{
- bool status; /* Bilan d'opération initiale */
- uint32_t val32; /* Valeur sur 32 bits */
- uint8_t val8; /* Valeur sur 8 bits */
-
- status = G_DB_ITEM_CLASS(g_db_comment_parent_class)->recv(G_DB_ITEM(comment), fd, flags);
- if (!status) return false;
-
- if (!recv_vmpa(&comment->addr, fd, flags))
- return false;
+ bool result; /* Bilan à retourner */
+ uint32_t tmp32; /* Valeur sur 32 bits */
+ uint8_t tmp8; /* Valeur sur 8 bits */
- status = safe_recv(fd, &val32, sizeof(uint32_t), MSG_WAITALL | flags);
- if (!status) return false;
-
- comment->flags = be32toh(val32);
+ result = G_DB_ITEM_CLASS(g_db_comment_parent_class)->unpack(G_DB_ITEM(comment), pbuf);
- if (!recv_rle_string(&comment->text, fd, flags))
- return false;
+ if (result)
+ result = unpack_vmpa(&comment->addr, pbuf);
- status = safe_recv(fd, &val8, sizeof(uint8_t), MSG_WAITALL | flags);
- if (!status) return false;
+ if (result)
+ {
+ result = extend_packed_buffer(pbuf, &tmp32, sizeof(uint32_t), true);
+ comment->flags = tmp32;
+ }
- comment->inlined = val8;
+ if (result)
+ result = unpack_rle_string(&comment->text, pbuf);
- status = safe_recv(fd, &val8, sizeof(uint8_t), MSG_WAITALL | flags);
- if (!status) return false;
+ if (result)
+ {
+ result = extend_packed_buffer(pbuf, &tmp8, sizeof(uint8_t), true);
+ comment->inlined = tmp8;
+ }
- comment->repeatable = val8;
+ if (result)
+ {
+ result = extend_packed_buffer(pbuf, &tmp8, sizeof(uint8_t), true);
+ comment->repeatable = tmp8;
+ }
- return true;
+ return result;
}
@@ -492,8 +492,7 @@ static bool g_db_comment_recv_from_fd(GDbComment *comment, int fd, int flags)
/******************************************************************************
* *
* Paramètres : comment = 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 commentaire dans un flux réseau. *
* *
@@ -503,29 +502,28 @@ static bool g_db_comment_recv_from_fd(GDbComment *comment, int fd, int flags)
* *
******************************************************************************/
-static bool g_db_comment_send_to_fd(const GDbComment *comment, int fd, int flags)
+static bool g_db_comment_pack(const GDbComment *comment, packed_buffer *pbuf)
{
- bool status; /* Bilan d'opération initiale */
+ bool result; /* Bilan à retourner */
- status = G_DB_ITEM_CLASS(g_db_comment_parent_class)->send(G_DB_ITEM(comment), fd, MSG_MORE | flags);
- if (!status) return false;
+ result = G_DB_ITEM_CLASS(g_db_comment_parent_class)->pack(G_DB_ITEM(comment), pbuf);
- if (!send_vmpa(&comment->addr, fd, MSG_MORE | flags))
- return false;
+ if (result)
+ result = pack_vmpa(&comment->addr, pbuf);
- status = safe_send(fd, (uint32_t []) { htobe32(comment->flags) }, sizeof(uint32_t), MSG_MORE | flags);
- if (!status) return false;
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint32_t []) { comment->flags }, sizeof(uint32_t), true);
- if (!send_rle_string(&comment->text, fd, MSG_MORE | flags))
- return false;
+ if (result)
+ result = pack_rle_string(&comment->text, pbuf);
- status = safe_send(fd, (uint8_t []) { (uint8_t)comment->inlined }, sizeof(uint8_t), MSG_MORE | flags);
- if (!status) return false;
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint8_t []) { comment->inlined }, sizeof(uint8_t), true);
- status = safe_send(fd, (uint8_t []) { (uint8_t)comment->repeatable }, sizeof(uint8_t), flags);
- if (!status) return false;
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint8_t []) { comment->repeatable }, sizeof(uint8_t), true);
- return true;
+ return result;
}
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;
}
diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c
index 5a03e8e..01c1910 100644
--- a/src/analysis/db/items/switcher.c
+++ b/src/analysis/db/items/switcher.c
@@ -34,9 +34,6 @@
#include "../collection-int.h"
#include "../item-int.h"
-#include "../../../common/io.h"
-
-
@@ -81,10 +78,10 @@ static void g_db_switcher_finalize(GDbSwitcher *);
static gint g_db_switcher_cmp(GDbSwitcher *, GDbSwitcher *, bool);
/* Importe la définition d'un signet depuis un flux réseau. */
-static bool g_db_switcher_recv_from_fd(GDbSwitcher *, int, int);
+static bool g_db_switcher_unpack(GDbSwitcher *, packed_buffer *);
/* Exporte la définition d'un signet dans un flux réseau. */
-static bool g_db_switcher_send_to_fd(const GDbSwitcher *, int, int);
+static bool g_db_switcher_pack(const GDbSwitcher *, packed_buffer *);
/* Construit la description humaine d'un signet sur un tampon. */
static void g_db_switcher_build_label(GDbSwitcher *);
@@ -185,8 +182,8 @@ static void g_db_switcher_class_init(GDbSwitcherClass *klass)
item->cmp = (cmp_db_item_fc)g_db_switcher_cmp;
- item->recv = (recv_db_item_fc)g_db_switcher_recv_from_fd;
- item->send = (send_db_item_fc)g_db_switcher_send_to_fd;
+ item->unpack = (unpack_db_item_fc)g_db_switcher_unpack;
+ item->pack = (pack_db_item_fc)g_db_switcher_pack;
item->build_label = (build_item_label_fc)g_db_switcher_build_label;
item->apply = (run_item_fc)g_db_switcher_apply;
@@ -358,8 +355,7 @@ static gint g_db_switcher_cmp(GDbSwitcher *a, GDbSwitcher *b, bool with)
/******************************************************************************
* *
* Paramètres : switcher = bascule d'affichage aux infos à 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 depuis un flux réseau. *
* *
@@ -369,31 +365,33 @@ static gint g_db_switcher_cmp(GDbSwitcher *a, GDbSwitcher *b, bool with)
* *
******************************************************************************/
-static bool g_db_switcher_recv_from_fd(GDbSwitcher *switcher, int fd, int flags)
+static bool g_db_switcher_unpack(GDbSwitcher *switcher, packed_buffer *pbuf)
{
- bool status; /* Bilan d'opération initiale */
- uint32_t val32; /* Valeur sur 32 bits */
+ bool result; /* Bilan à retourner */
+ uint32_t tmp32; /* Valeur sur 32 bits */
- status = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->recv(G_DB_ITEM(switcher), fd, flags);
- if (!status) return false;
+ result = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->unpack(G_DB_ITEM(switcher), pbuf);
- if (!recv_vmpa(&switcher->addr, fd, flags))
- return false;
-
- status = safe_recv(fd, &val32, sizeof(uint32_t), MSG_WAITALL | flags);
- if (!status) return false;
+ if (result)
+ result = unpack_vmpa(&switcher->addr, pbuf);
- switcher->index = be32toh(val32);
+ if (result)
+ {
+ result = extract_packed_buffer(pbuf, &tmp32, sizeof(uint32_t), true);
+ switcher->index = tmp32;
+ }
- status = safe_recv(fd, &val32, sizeof(uint32_t), MSG_WAITALL | flags);
- if (!status) return false;
+ if (result)
+ {
+ result = extract_packed_buffer(pbuf, &tmp32, sizeof(uint32_t), true);
+ switcher->display = tmp32;
- switcher->display = be32toh(val32);
+ if (switcher->display > IOD_COUNT)
+ result = false;
- if (switcher->display > IOD_COUNT)
- return false;
+ }
- return true;
+ return result;
}
@@ -401,8 +399,7 @@ static bool g_db_switcher_recv_from_fd(GDbSwitcher *switcher, int fd, int flags)
/******************************************************************************
* *
* Paramètres : switcher = bascule d'affichage aux infos à 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'une bascule d'affichage d'opérande. *
* *
@@ -412,23 +409,22 @@ static bool g_db_switcher_recv_from_fd(GDbSwitcher *switcher, int fd, int flags)
* *
******************************************************************************/
-static bool g_db_switcher_send_to_fd(const GDbSwitcher *switcher, int fd, int flags)
+static bool g_db_switcher_pack(const GDbSwitcher *switcher, packed_buffer *pbuf)
{
- bool status; /* Bilan d'opération initiale */
+ bool result; /* Bilan à retourner */
- status = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->send(G_DB_ITEM(switcher), fd, MSG_MORE | flags);
- if (!status) return false;
+ result = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->pack(G_DB_ITEM(switcher), pbuf);
- if (!send_vmpa(&switcher->addr, fd, MSG_MORE | flags))
- return false;
+ if (result)
+ result = pack_vmpa(&switcher->addr, pbuf);
- status = safe_send(fd, (uint32_t []) { htobe32(switcher->index) }, sizeof(uint32_t), MSG_MORE | flags);
- if (!status) return false;
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint32_t []) { switcher->index }, sizeof(uint32_t), true);
- status = safe_send(fd, (uint32_t []) { htobe32(switcher->display) }, sizeof(uint32_t), flags);
- if (!status) return false;
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint32_t []) { switcher->display }, sizeof(uint32_t), true);
- return true;
+ return result;
}