diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-10-19 12:50:37 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-10-19 12:50:37 (GMT) |
commit | d7c69bcb27a7d06932cd25021144b6cbbe4eb82f (patch) | |
tree | b014aa31a1c9d9ce4afddf505b727cabacf15e44 /src/analysis/db/misc/snapshot.c | |
parent | bcdf953ef6616c404d013f3473fb12a7bf43440b (diff) |
Exchanged the list of all snapshots.
Diffstat (limited to 'src/analysis/db/misc/snapshot.c')
-rw-r--r-- | src/analysis/db/misc/snapshot.c | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/src/analysis/db/misc/snapshot.c b/src/analysis/db/misc/snapshot.c index 546191b..9aa096f 100644 --- a/src/analysis/db/misc/snapshot.c +++ b/src/analysis/db/misc/snapshot.c @@ -41,6 +41,25 @@ * * * Paramètres : id = identifiant d'instantané à initialiser. [OUT] * * * +* Description : Prépare un identifiant pour instantané à une définition. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void setup_empty_snapshot_id(snapshot_id_t *id) +{ + memset(id, 0, sizeof(snapshot_id_t)); + +} + + +/****************************************************************************** +* * +* Paramètres : id = identifiant d'instantané à initialiser. [OUT] * +* * * Description : Construit un identifiant pour instantané de base de données. * * * * Retour : Bilan de l'opération. * @@ -214,6 +233,32 @@ bool pack_snapshot_id(const snapshot_id_t *id, packed_buffer *pbuf) * * * Paramètres : info = description d'instantané à initialiser. [OUT] * * * +* Description : Prépare une description pour instantané à une définition. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void setup_empty_snapshot_info(snapshot_info_t *info) +{ + setup_empty_snapshot_id(&info->parent_id); + + setup_empty_snapshot_id(&info->id); + + setup_empty_timestamp(&info->created); + + info->name = NULL; + info->desc = NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : info = description d'instantané à initialiser. [OUT] * +* * * Description : Construit une description pour instantané de base de données.* * * * Retour : Bilan de l'opération. * @@ -226,7 +271,10 @@ bool init_snapshot_info(snapshot_info_t *info) { bool result; /* Bilan à retourner */ - result = init_snapshot_id(&info->id); + result = init_snapshot_id_from_text(&info->parent_id, NO_SNAPSHOT_ROOT); + + if (result) + result = init_snapshot_id(&info->id); if (result) result = init_timestamp(&info->created); @@ -262,7 +310,10 @@ bool init_snapshot_info_from_text(snapshot_info_t *info, const char *id, uint64_ { bool result; /* Bilan à retourner */ - result = init_snapshot_id_from_text(&info->id, id); + result = init_snapshot_id_from_text(&info->parent_id, NO_SNAPSHOT_ROOT); + + if (result) + result = init_snapshot_id_from_text(&info->id, id); if (result) result = init_timestamp_from_value(&info->created, created); @@ -332,6 +383,8 @@ void copy_snapshot_info(snapshot_info_t *dest, const snapshot_info_t *src) { exit_snapshot_info(dest); + copy_snapshot_id(&dest->parent_id, &src->parent_id); + copy_snapshot_id(&dest->id, &src->id); copy_timestamp(&dest->created, &src->created); @@ -362,19 +415,26 @@ bool unpack_snapshot_info(snapshot_info_t *info, packed_buffer *pbuf) { bool result; /* Bilan à retourner */ rle_string string; /* Chaîne à transmettre */ + const char *text; /* Valeur textuelle obtenue */ - result = unpack_snapshot_id(&info->id, pbuf); + result = unpack_snapshot_id(&info->parent_id, pbuf); + + if (result) + result = unpack_snapshot_id(&info->id, pbuf); if (result) result = unpack_timestamp(&info->created, pbuf); if (result) { + init_static_rle_string(&string, NULL); + result = unpack_rle_string(&string, pbuf); if (result) { - info->name = strdup(get_rle_string(&string)); + text = get_rle_string(&string); + info->name = (text != NULL ? strdup(text) : NULL); exit_rle_string(&string); } @@ -382,11 +442,14 @@ bool unpack_snapshot_info(snapshot_info_t *info, packed_buffer *pbuf) if (result) { + init_static_rle_string(&string, NULL); + result = unpack_rle_string(&string, pbuf); if (result) { - info->desc = strdup(get_rle_string(&string)); + text = get_rle_string(&string); + info->desc = (text != NULL ? strdup(text) : NULL); exit_rle_string(&string); } @@ -415,7 +478,10 @@ bool pack_snapshot_info(const snapshot_info_t *info, packed_buffer *pbuf) bool result; /* Bilan à retourner */ rle_string string; /* Chaîne à transmettre */ - result = pack_snapshot_id(&info->id, pbuf); + result = pack_snapshot_id(&info->parent_id, pbuf); + + if (result) + result = pack_snapshot_id(&info->id, pbuf); if (result) result = pack_timestamp(&info->created, pbuf); |