summaryrefslogtreecommitdiff
path: root/src/analysis/db/item.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-29 21:27:03 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-29 21:27:03 (GMT)
commit3a83a06db8ee27eafcd0219d1d26bf2af23737f5 (patch)
tree163ea7fbe1435b9f380e7ae96dfc36d8f16d1d0a /src/analysis/db/item.c
parent55bc8570f25a479b222733c4093f9ae996c9f68e (diff)
Cleaned the DB code a little bit.
Diffstat (limited to 'src/analysis/db/item.c')
-rw-r--r--src/analysis/db/item.c105
1 files changed, 12 insertions, 93 deletions
diff --git a/src/analysis/db/item.c b/src/analysis/db/item.c
index c880d65..8fc1763 100644
--- a/src/analysis/db/item.c
+++ b/src/analysis/db/item.c
@@ -311,9 +311,8 @@ int g_db_item_cmp_with_timestamp(const timestamp_t *ts, const GDbItem **b)
/******************************************************************************
* *
-* Paramètres : a = premier élément à analyser. *
-* b = second élément à analyser. *
-* with = précise les horodatages à prendre en compte. *
+* Paramètres : a = premier élément à analyser. *
+* b = second élément à analyser. *
* *
* Description : Effectue la comparaison entre deux éléments de collection. *
* *
@@ -323,16 +322,20 @@ int g_db_item_cmp_with_timestamp(const timestamp_t *ts, const GDbItem **b)
* *
******************************************************************************/
-gint g_db_item_cmp(GDbItem *a, GDbItem *b, bool with)
+gint g_db_item_cmp(const GDbItem *a, const GDbItem *b)
{
gint result; /* Bilan à retourner */
+ GDbItemClass *class; /* Classe liée à l'instance */
char *label_a; /* Etiquette de l'élément A */
char *label_b; /* Etiquette de l'élément B */
- if (with)
- result = cmp_timestamp(&a->created, &b->created);
- else
- result = 0;
+ result = g_db_item_cmp_timestamp(&a, &b);
+
+ if (result == 0)
+ {
+ class = G_DB_ITEM_GET_CLASS(a);
+ result = class->cmp(a, b);
+ }
if (result == 0)
{
@@ -353,46 +356,6 @@ gint g_db_item_cmp(GDbItem *a, GDbItem *b, bool with)
/******************************************************************************
* *
-* Paramètres : a = premier élément à analyser. *
-* b = second élément à analyser. *
-* *
-* Description : Effectue la comparaison entre deux éléments de collection. *
-* *
-* Retour : Bilan de la comparaison : -1, 0 ou 1. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-gint g_db_item_compare_with_timestamp(GDbItem *a, GDbItem *b)
-{
- return G_DB_ITEM_GET_CLASS(a)->cmp(a, b, true);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : a = premier élément à analyser. *
-* b = second élément à analyser. *
-* *
-* Description : Effectue la comparaison entre deux éléments de collection. *
-* *
-* Retour : Bilan de la comparaison : -1, 0 ou 1. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-gint g_db_item_compare_without_timestamp(GDbItem *a, GDbItem *b)
-{
- return G_DB_ITEM_GET_CLASS(a)->cmp(a, b, false);
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : item = base d'éléments à charger. [OUT] *
* pbuf = paquet de données où venir puiser les infos. *
* *
@@ -570,7 +533,7 @@ bool g_db_item_cancel(GDbItem *item, GLoadedBinary *binary)
* *
******************************************************************************/
-char *g_db_item_get_label(GDbItem *item)
+char *g_db_item_get_label(const GDbItem *item)
{
char *result; /* Description à retourner */
GDbItemClass *class; /* Classe de l'instance */
@@ -696,50 +659,6 @@ DbItemFlags g_db_item_get_flags(const GDbItem *item)
}
-/******************************************************************************
-* *
-* Paramètres : item = élément de collection à mettre à jour. *
-* binary = binaire chargé en mémoire à modifier. *
-* *
-* Description : Active ou désactive un élément de collection en place. *
-* *
-* Retour : Bilan de la mise à jour de l'élément. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool g_db_item_switch_state(GDbItem *item, GLoadedBinary *binary)
-{
- bool result; /* Bilan à faire remonter */
- bool enabled; /* Etat avant changement */
-
- enabled = !g_db_item_has_flag(item, DIF_DISABLED);
-
- /* Archivage de l'état */
-
- if (enabled)
- g_db_item_add_flag(item, DIF_DISABLED);
- else
- g_db_item_remove_flag(item, DIF_DISABLED);
-
- /* Application de l'état */
-
- if (binary != NULL)
- {
- if (enabled)
- result = g_db_item_cancel(item, binary);
- else
- result = g_db_item_apply(item, binary);
- }
- else
- result = true;
-
- return result;
-
-}
-
-
/* ---------------------------------------------------------------------------------- */
/* MANIPULATIONS AVEC UNE BASE DE DONNEES */