summaryrefslogtreecommitdiff
path: root/src/analysis/db/items/bookmark.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-05-08 09:28:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-05-08 09:28:58 (GMT)
commit86ba53836168bcc591f532f2419fa290de601572 (patch)
tree91c96614d6f7e3fd75800a52c0166c91c7f8ef31 /src/analysis/db/items/bookmark.c
parent28e53c2498903090182ebeb128347fcd92896cd9 (diff)
Updated the core functions dealing with SQLite databases.
Diffstat (limited to 'src/analysis/db/items/bookmark.c')
-rw-r--r--src/analysis/db/items/bookmark.c74
1 files changed, 43 insertions, 31 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c
index d3010dd..5d6ccfa 100644
--- a/src/analysis/db/items/bookmark.c
+++ b/src/analysis/db/items/bookmark.c
@@ -93,12 +93,12 @@ static bool g_db_bookmark_apply(GDbBookmark *, GLoadedBinary *);
/* Annule un signet sur un tampon de binaire chargé. */
static bool g_db_bookmark_cancel(GDbBookmark *, GLoadedBinary *);
-/* Constitue les champs destinés à une insertion / modification. */
-static bool g_db_bookmark_prepare_db_statement(const GDbBookmark *, bound_value **, size_t *);
-
/* Charge les valeurs utiles pour un signet. */
static bool g_db_bookmark_load(GDbBookmark *, const bound_value *, size_t);
+/* Constitue les champs destinés à une insertion / modification. */
+static bool g_db_bookmark_store(const GDbBookmark *, bound_value **, size_t *);
+
/* ---------------------- DEFINITION DE LA COLLECTION ASSOCIEE ---------------------- */
@@ -186,8 +186,8 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass)
item->apply = (run_item_fc)g_db_bookmark_apply;
item->cancel = (run_item_fc)g_db_bookmark_cancel;
- item->prepare_stmt = (prepare_db_statement)g_db_bookmark_prepare_db_statement;
item->load = (load_db_item_fc)g_db_bookmark_load;
+ item->store = (store_db_item_fc)g_db_bookmark_store;
}
@@ -492,61 +492,73 @@ static bool g_db_bookmark_cancel(GDbBookmark *bookmark, GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : bookmark = base d'éléments sur laquelle s'appuyer. *
-* values = couples de champs et de valeurs à lier. [OUT] *
-* count = nombre de ces couples. [OUT] *
+* Paramètres : bookmark = bascule d'affichage à charger depuis les réponses.*
+* values = tableau d'éléments à consulter. *
+* count = nombre de descriptions renseignées. *
* *
-* Description : Constitue les champs destinés à une insertion / modification.*
+* Description : Charge les valeurs utiles pour un signet. *
* *
-* Retour : Etat du besoin en sauvegarde. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_db_bookmark_prepare_db_statement(const GDbBookmark *bookmark, bound_value **values, size_t *count)
+static bool g_db_bookmark_load(GDbBookmark *bookmark, const bound_value *values, size_t count)
{
- bool status; /* Bilan d'opération initiale */
+ bool result; /* Bilan à faire remonter */
- status = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->prepare_stmt(G_DB_ITEM(bookmark), values, count);
- if (!status) return false;
+ result = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->load(G_DB_ITEM(bookmark), values, count);
- status = prepare_vmpa_db_statement(&bookmark->addr, NULL, values, count);
- if (!status) return false;
+ result &= load_vmpa(&bookmark->addr, NULL, values, count);
- status &= prepare_db_statement_for_rle_string(&bookmark->comment, "comment", values, count);
- if (!status) return false;
+ result &= load_rle_string(&bookmark->comment, "comment", values, count);
- return true;
+ return result;
}
/******************************************************************************
* *
-* Paramètres : bookmark = bascule d'affichage à charger depuis les réponses.*
-* values = tableau d'éléments à consulter. *
-* count = nombre de descriptions renseignées. *
+* Paramètres : bookmark = base d'éléments sur laquelle s'appuyer. *
+* values = couples de champs et de valeurs à lier. [OUT] *
+* count = nombre de ces couples. [OUT] *
* *
-* Description : Charge les valeurs utiles pour un signet. *
+* Description : Constitue les champs destinés à une insertion / modification.*
* *
-* Retour : Bilan de l'opération. *
+* Retour : Etat du besoin en sauvegarde. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_db_bookmark_load(GDbBookmark *bookmark, const bound_value *values, size_t count)
+static bool g_db_bookmark_store(const GDbBookmark *bookmark, bound_value **values, size_t *count)
{
- bool result; /* Bilan à faire remonter */
+ bool status; /* Bilan d'opération initiale */
- result = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->load(G_DB_ITEM(bookmark), values, count);
+ if (bookmark == NULL)
+ status = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->store(NULL, values, count);
+ else
+ status = G_DB_ITEM_CLASS(g_db_bookmark_parent_class)->store(G_DB_ITEM(bookmark), values, count);
- result &= load_vmpa(&bookmark->addr, NULL, values, count);
+ if (!status) return false;
- result &= load_rle_string(&bookmark->comment, "comment", values, count);
+ if (bookmark == NULL)
+ status = store_vmpa(NULL, NULL, values, count);
+ else
+ status = store_vmpa(&bookmark->addr, NULL, values, count);
- return result;
+ if (!status) return false;
+
+ if (bookmark == NULL)
+ status &= store_rle_string(NULL, "comment", values, count);
+ else
+ status &= store_rle_string(&bookmark->comment, "comment", values, count);
+
+ if (!status) return false;
+
+ return true;
}
@@ -801,10 +813,10 @@ static bool g_bookmark_collection_setup_load(GBookmarkCollection *collec, bound_
values, count);
if (!status) return false;
- if (!setup_load_for_vmpa(NULL, values, count))
+ if (!store_vmpa(NULL, NULL, values, count))
return false;
- if (!setup_load_of_rle_string(NULL, "comment", values, count))
+ if (!store_rle_string(NULL, "comment", values, count))
return false;
return true;