summaryrefslogtreecommitdiff
path: root/src/analysis/db/misc/timestamp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/misc/timestamp.c')
-rw-r--r--src/analysis/db/misc/timestamp.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/analysis/db/misc/timestamp.c b/src/analysis/db/misc/timestamp.c
index 6c7a47f..aa9f758 100644
--- a/src/analysis/db/misc/timestamp.c
+++ b/src/analysis/db/misc/timestamp.c
@@ -24,15 +24,11 @@
#include "timestamp.h"
-#include <endian.h>
#include <malloc.h>
#include <sqlite3.h>
#include <time.h>
-#include "../../../common/io.h"
-
-
/******************************************************************************
* *
@@ -117,8 +113,7 @@ int cmp_timestamp(const timestamp_t *t1, const timestamp_t *t2)
/******************************************************************************
* *
* Paramètres : timestamp = informations à constituer. [OUT] *
-* fd = flux ouvert en lecture pour l'importation. *
-* flags = éventuelles options de réception supplémentaires.*
+* pbuf = paquet de données où venir puiser les infos. *
* *
* Description : Importe la définition d'un horodatage. *
* *
@@ -128,17 +123,13 @@ int cmp_timestamp(const timestamp_t *t1, const timestamp_t *t2)
* *
******************************************************************************/
-bool recv_timestamp(timestamp_t *timestamp, int fd, int flags)
+bool unpack_timestamp(timestamp_t *timestamp, packed_buffer *pbuf)
{
- uint64_t val64; /* Valeur sur 64 bits */
- bool status; /* Bilan d'une opération */
+ bool result; /* Bilan à retourner */
- status = safe_recv(fd, &val64, sizeof(uint64_t), MSG_WAITALL | flags);
- if (!status) return false;
+ result = extract_packed_buffer(pbuf, (uint64_t *)timestamp, sizeof(uint64_t), true);
- *timestamp = be64toh(val64);
-
- return true;
+ return result;
}
@@ -146,8 +137,7 @@ bool recv_timestamp(timestamp_t *timestamp, int fd, int flags)
/******************************************************************************
* *
* Paramètres : timestamp = informations à sauvegarer. *
-* 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 horodatage. *
* *
@@ -157,14 +147,13 @@ bool recv_timestamp(timestamp_t *timestamp, int fd, int flags)
* *
******************************************************************************/
-bool send_timestamp(const timestamp_t *timestamp, int fd, int flags)
+bool pack_timestamp(const timestamp_t *timestamp, packed_buffer *pbuf)
{
- bool status; /* Bilan d'une opération */
+ bool result; /* Bilan à retourner */
- status = safe_send(fd, (uint64_t []) { htobe64(*timestamp) }, sizeof(uint64_t), flags);
- if (!status) return false;
+ result = extend_packed_buffer(pbuf, (uint64_t *)timestamp, sizeof(uint64_t), true);
- return true;
+ return result;
}