summaryrefslogtreecommitdiff
path: root/src/arch
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/arch
parent28e53c2498903090182ebeb128347fcd92896cd9 (diff)
Updated the core functions dealing with SQLite databases.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/vmpa.c81
-rw-r--r--src/arch/vmpa.h5
2 files changed, 26 insertions, 60 deletions
diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c
index 0c0511b..a2a3ba5 100644
--- a/src/arch/vmpa.c
+++ b/src/arch/vmpa.c
@@ -715,44 +715,6 @@ char *create_vmpa_db_table(const char *base)
/******************************************************************************
* *
-* Paramètres : base = tronc commun pour les champs de la base de données. *
-* values = tableau d'éléments à compléter. [OUT] *
-* count = nombre de descriptions renseignées. [OUT] *
-* *
-* Description : Décrit les colonnes utiles à un chargement de données. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool setup_load_for_vmpa(const char *base, bound_value **values, size_t *count)
-{
- bound_value *value; /* Valeur à éditer / définir */
-
- (*count) += 2;
- *values = (bound_value *)realloc(*values, (*count) * sizeof(bound_value));
-
- value = &(*values)[*count - 2];
-
- asprintf(&value->name, "%s%sphys", base != NULL ? base : "", base != NULL ? "_" : "");
- value->built_name = true;
- value->type = SQLITE_NATIVE;
-
- value = &(*values)[*count - 1];
-
- asprintf(&value->name, "%s%svirt", base != NULL ? base : "", base != NULL ? "_" : "");
- value->built_name = true;
- value->type = SQLITE_NATIVE;
-
- return true;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : addr = localisation dont la définition est à définir. *
* base = tronc commun pour les champs de la base de données. *
* values = tableau d'éléments à consulter. *
@@ -839,40 +801,47 @@ bool load_vmpa(vmpa2t *addr, const char *base, const bound_value *values, size_t
* *
******************************************************************************/
-bool prepare_vmpa_db_statement(const vmpa2t *addr, const char *base, bound_value **values, size_t *count)
+bool store_vmpa(const vmpa2t *addr, const char *base, bound_value **values, size_t *count)
{
bound_value *value; /* Valeur à éditer / définir */
- *values = (bound_value *)realloc(*values, ++(*count) * sizeof(bound_value));
- value = &(*values)[*count - 1];
+ *count += 2;
+ *values = realloc(*values, *count * sizeof(bound_value));
+
+ value = &(*values)[*count - 2];
asprintf(&value->name, "%s%sphys", base != NULL ? base : "", base != NULL ? "_" : "");
value->built_name = true;
- if (addr->physical != VMPA_NO_PHYSICAL)
- {
- value->type = SQLITE_INT64;
- value->integer64 = addr->physical;
- }
- else
+ value->has_value = (addr != NULL);
+
+ if (value->has_value)
{
- value->type = SQLITE_NULL;
+ if (addr->physical != VMPA_NO_PHYSICAL)
+ {
+ value->type = SQLITE_INT64;
+ value->integer64 = addr->physical;
+ }
+ else
+ value->type = SQLITE_NULL;
}
- *values = (bound_value *)realloc(*values, ++(*count) * sizeof(bound_value));
value = &(*values)[*count - 1];
asprintf(&value->name, "%s%svirt", base != NULL ? base : "", base != NULL ? "_" : "");
value->built_name = true;
- if (addr->virtual != VMPA_NO_VIRTUAL)
- {
- value->type = SQLITE_INT64;
- value->integer64 = addr->virtual;
- }
- else
+ value->has_value = (addr != NULL);
+
+ if (value->has_value)
{
- value->type = SQLITE_NULL;
+ if (addr->virtual != VMPA_NO_VIRTUAL)
+ {
+ value->type = SQLITE_INT64;
+ value->integer64 = addr->virtual;
+ }
+ else
+ value->type = SQLITE_NULL;
}
return true;
diff --git a/src/arch/vmpa.h b/src/arch/vmpa.h
index fc997e5..8dfc646 100644
--- a/src/arch/vmpa.h
+++ b/src/arch/vmpa.h
@@ -145,14 +145,11 @@ vmpa2t *string_to_vmpa_virt(const char *);
/* Donne les éléments requis pour la construction d'une table. */
char *create_vmpa_db_table(const char *);
-/* Décrit les colonnes utiles à un chargement de données. */
-bool setup_load_for_vmpa(const char *, bound_value **, size_t *);
-
/* Charge les valeurs utiles pour une localisation. */
bool load_vmpa(vmpa2t *, const char *, const bound_value *, size_t);
/* Constitue les champs destinés à une insertion / modification. */
-bool prepare_vmpa_db_statement(const vmpa2t *, const char *, bound_value **, size_t *);
+bool store_vmpa(const vmpa2t *, const char *, bound_value **, size_t *);