diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-08-05 21:25:55 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-08-05 21:25:55 (GMT) |
commit | b5c6bcea25b1b840fd6c8e89a4a3c9fbd83ba84b (patch) | |
tree | de253301956b1cf249ae27cf1af146c3184af67f /src/analysis/db/item.c | |
parent | d0a25ef16eef28d0cc355b00f5874c6c28004c78 (diff) |
Run updates on collected items activity changes.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@567 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/db/item.c')
-rw-r--r-- | src/analysis/db/item.c | 46 |
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; } |