diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-05-08 09:28:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-05-08 09:28:58 (GMT) |
commit | 86ba53836168bcc591f532f2419fa290de601572 (patch) | |
tree | 91c96614d6f7e3fd75800a52c0166c91c7f8ef31 /src/analysis/db/items/switcher.c | |
parent | 28e53c2498903090182ebeb128347fcd92896cd9 (diff) |
Updated the core functions dealing with SQLite databases.
Diffstat (limited to 'src/analysis/db/items/switcher.c')
-rw-r--r-- | src/analysis/db/items/switcher.c | 129 |
1 files changed, 74 insertions, 55 deletions
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]; |