summaryrefslogtreecommitdiff
path: root/src/analysis/db/item.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/item.c')
-rw-r--r--src/analysis/db/item.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/analysis/db/item.c b/src/analysis/db/item.c
index 3fc6f6f..013703d 100644
--- a/src/analysis/db/item.c
+++ b/src/analysis/db/item.c
@@ -403,11 +403,9 @@ bool g_db_item_apply(GDbItem *item, GLoadedBinary *binary)
{
bool result; /* Bilan à faire remonter */
- result = G_DB_ITEM_GET_CLASS(item)->apply(item, binary);
+ assert(g_db_item_is_active(item));
-#ifdef DEBUG
- item->applied = true;
-#endif
+ result = G_DB_ITEM_GET_CLASS(item)->apply(item, binary);
return result;
@@ -431,9 +429,7 @@ bool g_db_item_cancel(GDbItem *item, GLoadedBinary *binary)
{
bool result; /* Bilan à faire remonter */
-#ifdef DEBUG
- assert(item->applied);
-#endif
+ assert(!g_db_item_is_active(item));
result = G_DB_ITEM_GET_CLASS(item)->cancel(item, binary);
@@ -482,23 +478,51 @@ timestamp_t g_db_item_get_timestamp(const GDbItem *item)
/******************************************************************************
* *
-* Paramètres : item = élément de collection à mettre à jour. *
-* first = horodatage du premier élément désactivé ou NULL. *
+* Paramètres : item = élément de collection à mettre à jour. *
+* binary = binaire chargé en mémoire à modifier. *
+* first = horodatage du premier élément désactivé ou NULL. *
* *
* Description : Active ou désactive un élément de collection en place. *
* *
-* Retour : - *
+* Retour : Bilan de la mise à jour de l'élément. *
* *
* Remarques : - *
* *
******************************************************************************/
-void g_db_item_set_activity(GDbItem *item, timestamp_t *first)
+bool g_db_item_set_activity(GDbItem *item, GLoadedBinary *binary, timestamp_t *first)
{
+ bool result; /* Bilan à faire remonter */
+ bool active; /* Etat avant changement */
+
+ active = g_db_item_is_active(item);
+
+ /* Archivage de l'état */
+
if (first == NULL)
+ {
+ assert(!active);
item->timestamp = item->created;
+ }
else
+ {
+ assert(active);
item->timestamp = --(*first);
+ }
+
+ /* Application de l'état */
+
+ if (binary != NULL)
+ {
+ if (active)
+ result = g_db_item_cancel(item, binary);
+ else
+ result = g_db_item_apply(item, binary);
+ }
+ else
+ result = true;
+
+ return result;
}