summaryrefslogtreecommitdiff
path: root/src/analysis/db/items
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
parent28e53c2498903090182ebeb128347fcd92896cd9 (diff)
Updated the core functions dealing with SQLite databases.
Diffstat (limited to 'src/analysis/db/items')
-rw-r--r--src/analysis/db/items/bookmark.c74
-rw-r--r--src/analysis/db/items/comment.c183
-rw-r--r--src/analysis/db/items/move.c80
-rw-r--r--src/analysis/db/items/switcher.c129
4 files changed, 266 insertions, 200 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;
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index 7eb7906..6ac37fd 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -113,12 +113,12 @@ static bool g_db_comment_apply(GDbComment *, GLoadedBinary *);
/* Annule l'impression d'un commentaire dans du code de binaire. */
static bool g_db_comment_cancel(GDbComment *, GLoadedBinary *);
-/* Constitue les champs destinés à une insertion / modification. */
-static bool g_db_comment_prepare_db_statement(GDbComment *, bound_value **, size_t *);
-
/* Charge les valeurs utiles pour un commentaire. */
static bool g_db_comment_load(GDbComment *, const bound_value *, size_t);
+/* Constitue les champs destinés à une insertion / modification. */
+static bool g_db_comment_store(GDbComment *, bound_value **, size_t *);
+
/* Associe un contenu formaté supplémentaire à un commentaire. */
static void g_db_comment_add_rle_string(GDbComment *, const rle_string *);
@@ -236,8 +236,8 @@ static void g_db_comment_class_init(GDbCommentClass *klass)
item->apply = (run_item_fc)g_db_comment_apply;
item->cancel = (run_item_fc)g_db_comment_cancel;
- item->prepare_stmt = (prepare_db_statement)g_db_comment_prepare_db_statement;
item->load = (load_db_item_fc)g_db_comment_load;
+ item->store = (store_db_item_fc)g_db_comment_store;
}
@@ -694,8 +694,7 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap
if (apply)
{
comment->old_count = scount;
- comment->old_inlined = (GLineGenerator **)realloc(comment->old_inlined,
- comment->old_count * sizeof(GLineGenerator *));
+ comment->old_inlined = realloc(comment->old_inlined, comment->old_count * sizeof(GLineGenerator *));
}
for (i = 0; i < scount && result; i++)
@@ -805,7 +804,7 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap
assert(comment->old_count == 0);
comment->old_count = 1;
- comment->oldies = (GDbComment **)calloc(comment->old_count, sizeof(GDbComment *));
+ comment->oldies = calloc(comment->old_count, sizeof(GDbComment *));
}
@@ -876,8 +875,7 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap
if (apply)
{
comment->old_count += scount;
- comment->oldies = (GDbComment **)realloc(comment->oldies,
- comment->old_count * sizeof(GDbComment *));
+ comment->oldies = realloc(comment->oldies, comment->old_count * sizeof(GDbComment *));
}
for (i = 0; i < scount && result; i++)
@@ -970,73 +968,6 @@ static bool g_db_comment_cancel(GDbComment *comment, GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : comment = base d'éléments sur laquelle s'appuyer. *
-* values = couples de champs et de valeurs à lier. [OUT] *
-* count = nombre de ces couples. [OUT] *
-* *
-* Description : Constitue les champs destinés à une insertion / modification.*
-* *
-* Retour : Etat du besoin en sauvegarde. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_db_comment_prepare_db_statement(GDbComment *comment, bound_value **values, size_t *count)
-{
- bool status; /* Bilan d'opération initiale */
- bound_value *value; /* Valeur à éditer / définir */
- rle_string text; /* Texte brut récupéré */
-
- status = G_DB_ITEM_CLASS(g_db_comment_parent_class)->prepare_stmt(G_DB_ITEM(comment), values, count);
- if (!status) return false;
-
- status = prepare_vmpa_db_statement(&comment->addr, NULL, values, count);
- if (!status) return false;
-
- *count += 1;
- *values = (bound_value *)realloc(*values, *count * sizeof(bound_value));
-
- value = &(*values)[*count - 1];
-
- value->cname = "flags";
- value->built_name = false;
- value->type = SQLITE_INTEGER;
- value->integer = comment->flags;
- value->delete = NULL;
-
- init_dynamic_rle_string(&text, g_db_comment_get_text(comment));
- status &= prepare_db_statement_for_rle_string(&text, "text", values, count);
- exit_rle_string(&text);
-
- if (!status) return false;
-
- *count += 2;
- *values = (bound_value *)realloc(*values, *count * sizeof(bound_value));
-
- value = &(*values)[*count - 2];
-
- value->cname = "inlined";
- value->built_name = false;
- value->type = SQLITE_BOOLEAN;
- value->boolean = comment->inlined;
- value->delete = NULL;
-
- value = &(*values)[*count - 1];
-
- value->cname = "repeatable";
- value->built_name = false;
- value->type = SQLITE_BOOLEAN;
- value->boolean = comment->repeatable;
- value->delete = NULL;
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : comment = commentaire textuel à charger depuis les réponses. *
* values = tableau d'éléments à consulter. *
* count = nombre de descriptions renseignées. *
@@ -1101,6 +1032,98 @@ static bool g_db_comment_load(GDbComment *comment, const bound_value *values, si
/******************************************************************************
* *
+* Paramètres : comment = base d'éléments sur laquelle s'appuyer. *
+* values = couples de champs et de valeurs à lier. [OUT] *
+* count = nombre de ces couples. [OUT] *
+* *
+* Description : Constitue les champs destinés à une insertion / modification.*
+* *
+* Retour : Etat du besoin en sauvegarde. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_db_comment_store(GDbComment *comment, bound_value **values, size_t *count)
+{
+ bool status; /* Bilan d'opération initiale */
+ bound_value *value; /* Valeur à éditer / définir */
+ rle_string text; /* Texte brut récupéré */
+
+ if (comment == NULL)
+ status = G_DB_ITEM_CLASS(g_db_comment_parent_class)->store(NULL, values, count);
+ else
+ status = G_DB_ITEM_CLASS(g_db_comment_parent_class)->store(G_DB_ITEM(comment), values, count);
+
+ if (!status) return false;
+
+ if (comment == NULL)
+ status = store_vmpa(NULL, NULL, values, count);
+ else
+ status = store_vmpa(&comment->addr, NULL, values, count);
+
+ if (!status) return false;
+
+ *count += 1;
+ *values = realloc(*values, *count * sizeof(bound_value));
+
+ value = &(*values)[*count - 1];
+
+ value->cname = "flags";
+ value->built_name = false;
+ value->type = SQLITE_INTEGER;
+ value->integer = comment->flags;
+ value->delete = NULL;
+
+ value->has_value = (comment != NULL);
+
+ if (value->has_value)
+ {
+ init_dynamic_rle_string(&text, g_db_comment_get_text(comment));
+ status = store_rle_string(&text, "text", values, count);
+ exit_rle_string(&text);
+ }
+
+ if (!status) return false;
+
+ *count += 2;
+ *values = realloc(*values, *count * sizeof(bound_value));
+
+ value = &(*values)[*count - 2];
+
+ value->cname = "inlined";
+ value->built_name = false;
+ value->type = SQLITE_BOOLEAN;
+
+ value->has_value = (comment != NULL);
+
+ if (value->has_value)
+ {
+ value->boolean = comment->inlined;
+ value->delete = NULL;
+ }
+
+ value = &(*values)[*count - 1];
+
+ value->cname = "repeatable";
+ value->built_name = false;
+ value->type = SQLITE_BOOLEAN;
+
+ value->has_value = (comment != NULL);
+
+ if (value->has_value)
+ {
+ value->boolean = comment->repeatable;
+ value->delete = NULL;
+ }
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : comment = informations à consulter. *
* *
* Description : Fournit l'adresse associée à un commentaire. *
@@ -1649,11 +1672,11 @@ static bool g_comment_collection_setup_load(GCommentCollection *collec, bound_va
values, count);
if (!status) return false;
- if (!setup_load_for_vmpa(NULL, values, count))
+ if (!store_vmpa(NULL, NULL, values, count))
return false;
*count += 1;
- *values = (bound_value *)realloc(*values, *count * sizeof(bound_value));
+ *values = realloc(*values, *count * sizeof(bound_value));
value = &(*values)[*count - 1];
@@ -1661,11 +1684,11 @@ static bool g_comment_collection_setup_load(GCommentCollection *collec, bound_va
value->built_name = false;
value->type = SQLITE_INTEGER;
- if (!setup_load_of_rle_string(NULL, "text", values, count))
+ if (!store_rle_string(NULL, "text", values, count))
return false;
*count += 2;
- *values = (bound_value *)realloc(*values, *count * sizeof(bound_value));
+ *values = realloc(*values, *count * sizeof(bound_value));
value = &(*values)[*count - 2];
diff --git a/src/analysis/db/items/move.c b/src/analysis/db/items/move.c
index 6929ec3..286215b 100644
--- a/src/analysis/db/items/move.c
+++ b/src/analysis/db/items/move.c
@@ -95,12 +95,12 @@ static bool g_db_move_apply(GDbMove *, GLoadedBinary *);
/* Annule un déplacement au sein d'une zone de code. */
static bool g_db_move_cancel(GDbMove *, GLoadedBinary *);
-/* Constitue les champs destinés à une insertion / modification. */
-static bool g_db_move_prepare_db_statement(const GDbMove *, bound_value **, size_t *);
-
/* Charge les valeurs utiles pour un déplacement dans du code. */
static bool g_db_move_load(GDbMove *, const bound_value *, size_t);
+/* Constitue les champs destinés à une insertion / modification. */
+static bool g_db_move_store(const GDbMove *, bound_value **, size_t *);
+
/* ---------------------- DEFINITION DE LA COLLECTION ASSOCIEE ---------------------- */
@@ -188,8 +188,8 @@ static void g_db_move_class_init(GDbMoveClass *klass)
item->apply = (run_item_fc)g_db_move_apply;
item->cancel = (run_item_fc)g_db_move_cancel;
- item->prepare_stmt = (prepare_db_statement)g_db_move_prepare_db_statement;
item->load = (load_db_item_fc)g_db_move_load;
+ item->store = (store_db_item_fc)g_db_move_store;
}
@@ -455,7 +455,7 @@ static bool g_db_move_run(const GDbMove *move, GLineCursor *cursor)
if (G_IS_LOADED_PANEL(panel))
{
- params = (move_params *)calloc(1, sizeof(move_params));
+ params = calloc(1, sizeof(move_params));
params->panel = panel;
params->cursor = cursor;
@@ -527,63 +527,75 @@ static bool g_db_move_cancel(GDbMove *move, GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : move = 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 : move = 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 déplacement dans du code. *
* *
-* Retour : Etat du besoin en sauvegarde. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-static bool g_db_move_prepare_db_statement(const GDbMove *move, bound_value **values, size_t *count)
+static bool g_db_move_load(GDbMove *move, 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_move_parent_class)->prepare_stmt(G_DB_ITEM(move), values, count);
- if (!status) return false;
+ result = G_DB_ITEM_CLASS(g_db_move_parent_class)->load(G_DB_ITEM(move), values, count);
- status = g_line_cursor_prepare_db_statement(move->src, "src", values, count);
- if (!status) return false;
+ if (result)
+ result = g_line_cursor_load(move->src, "src", values, count);
- status = g_line_cursor_prepare_db_statement(move->src, "dest", values, count);
- if (!status) return false;
+ if (result)
+ result = g_line_cursor_load(move->dest, "dest", values, count);
- return true;
+ return result;
}
/******************************************************************************
* *
-* Paramètres : move = bascule d'affichage à charger depuis les réponses. *
-* values = tableau d'éléments à consulter. *
-* count = nombre de descriptions renseignées. *
+* Paramètres : move = 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 déplacement dans du code. *
+* 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_move_load(GDbMove *move, const bound_value *values, size_t count)
+static bool g_db_move_store(const GDbMove *move, 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_move_parent_class)->load(G_DB_ITEM(move), values, count);
+ if (move == NULL)
+ status = G_DB_ITEM_CLASS(g_db_move_parent_class)->store(NULL, values, count);
+ else
+ status = G_DB_ITEM_CLASS(g_db_move_parent_class)->store(G_DB_ITEM(move), values, count);
- if (result)
- result = g_line_cursor_load(move->src, "src", values, count);
+ if (!status) return false;
- if (result)
- result = g_line_cursor_load(move->dest, "dest", values, count);
+ if (move == NULL)
+ status = g_line_cursor_setup_load(move->src, "src", values, count);
+ else
+ status = g_line_cursor_store(move->src, "src", values, count);
- return result;
+ if (!status) return false;
+
+ if (move == NULL)
+ status = g_line_cursor_setup_load(move->dest, "dest", values, count);
+ else
+ status = g_line_cursor_store(move->dest, "dest", values, count);
+
+ if (!status) return false;
+
+ return true;
}
@@ -783,10 +795,10 @@ static bool g_move_collection_setup_load(GMoveCollection *collec, bound_value **
values, count);
if (!status) return false;
- if (!g_binary_cursor_setup_load("src", values, count))
+ if (!g_binary_cursor_store(NULL, "src", values, count))
return false;
- if (!g_binary_cursor_setup_load("dest", values, count))
+ if (!g_binary_cursor_store(NULL, "dest", values, count))
return false;
return true;
diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c
index b4f0379..e086b14 100644
--- a/src/analysis/db/items/switcher.c
+++ b/src/analysis/db/items/switcher.c
@@ -95,12 +95,11 @@ static bool g_db_switcher_apply(GDbSwitcher *, GLoadedBinary *);
/* Annule une bascule d'affichage d'opérande sur un binaire. */
static bool g_db_switcher_cancel(GDbSwitcher *, GLoadedBinary *);
-/* Constitue les champs destinés à une insertion / modification. */
-static bool g_db_switcher_prepare_db_statement(const GDbSwitcher *, bound_value **, size_t *);
-
/* Charge les valeurs utiles pour un basculement d'affichage. */
static bool g_db_switcher_load(GDbSwitcher *, const bound_value *, size_t);
+/* Constitue les champs destinés à une insertion / modification. */
+static bool g_db_switcher_store(const GDbSwitcher *, bound_value **, size_t *);
@@ -189,8 +188,8 @@ static void g_db_switcher_class_init(GDbSwitcherClass *klass)
item->apply = (run_item_fc)g_db_switcher_apply;
item->cancel = (run_item_fc)g_db_switcher_cancel;
- item->prepare_stmt = (prepare_db_statement)g_db_switcher_prepare_db_statement;
item->load = (load_db_item_fc)g_db_switcher_load;
+ item->store = (store_db_item_fc)g_db_switcher_store;
}
@@ -638,55 +637,6 @@ static bool g_db_switcher_cancel(GDbSwitcher *switcher, GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : switcher = base d'éléments sur laquelle s'appuyer. *
-* values = couples de champs et de valeurs à lier. [OUT] *
-* count = nombre de ces couples. [OUT] *
-* *
-* Description : Constitue les champs destinés à une insertion / modification.*
-* *
-* Retour : Etat du besoin en sauvegarde. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_db_switcher_prepare_db_statement(const GDbSwitcher *switcher, bound_value **values, size_t *count)
-{
- bool status; /* Bilan d'opération initiale */
- bound_value *value; /* Valeur à éditer / définir */
-
- status = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->prepare_stmt(G_DB_ITEM(switcher), values, count);
- if (!status) return false;
-
- status = prepare_vmpa_db_statement(&switcher->addr, NULL, values, count);
- if (!status) return false;
-
- *count += 2;
- *values = (bound_value *)realloc(*values, *count * sizeof(bound_value));
-
- value = &(*values)[*count - 2];
-
- value->cname = "op_index";
- value->built_name = false;
- value->type = SQLITE_INTEGER;
- value->integer = switcher->index;
- value->delete = NULL;
-
- value = &(*values)[*count - 1];
-
- value->cname = "type";
- value->built_name = false;
- value->type = SQLITE_INTEGER;
- value->integer = switcher->display;
- value->delete = NULL;
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : switcher = bascule d'affichage à charger depuis les réponses.*
* values = tableau d'éléments à consulter. *
* count = nombre de descriptions renseignées. *
@@ -733,6 +683,75 @@ static bool g_db_switcher_load(GDbSwitcher *switcher, const bound_value *values,
}
+/******************************************************************************
+* *
+* Paramètres : switcher = base d'éléments sur laquelle s'appuyer. *
+* values = couples de champs et de valeurs à lier. [OUT] *
+* count = nombre de ces couples. [OUT] *
+* *
+* Description : Constitue les champs destinés à une insertion / modification.*
+* *
+* Retour : Etat du besoin en sauvegarde. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_db_switcher_store(const GDbSwitcher *switcher, bound_value **values, size_t *count)
+{
+ bool status; /* Bilan d'opération initiale */
+ bound_value *value; /* Valeur à éditer / définir */
+
+ if (switcher == NULL)
+ status = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->store(NULL, values, count);
+ else
+ status = G_DB_ITEM_CLASS(g_db_switcher_parent_class)->store(G_DB_ITEM(switcher), values, count);
+
+ if (!status) return false;
+
+ if (switcher == NULL)
+ status = store_vmpa(NULL, NULL, values, count);
+ else
+ status = store_vmpa(&switcher->addr, NULL, values, count);
+
+ if (!status) return false;
+
+ *count += 2;
+ *values = realloc(*values, *count * sizeof(bound_value));
+
+ value = &(*values)[*count - 2];
+
+ value->cname = "op_index";
+ value->built_name = false;
+ value->type = SQLITE_INTEGER;
+
+ value->has_value = (switcher != NULL);
+
+ if (value->has_value)
+ {
+ value->integer = switcher->index;
+ value->delete = NULL;
+ }
+
+ value = &(*values)[*count - 1];
+
+ value->cname = "type";
+ value->built_name = false;
+ value->type = SQLITE_INTEGER;
+
+ value->has_value = (switcher != NULL);
+
+ if (value->has_value)
+ {
+ value->integer = switcher->display;
+ value->delete = NULL;
+ }
+
+ return true;
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* DEFINITION DE LA COLLECTION ASSOCIEE */
@@ -927,11 +946,11 @@ static bool g_switcher_collection_setup_load(GSwitcherCollection *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;
*count += 2;
- *values = (bound_value *)realloc(*values, *count * sizeof(bound_value));
+ *values = realloc(*values, *count * sizeof(bound_value));
value = &(*values)[*count - 2];