summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-03 13:16:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-03 13:16:32 (GMT)
commit7b9727379e1c3f2aefc4ac0db0e91d0cfb0a481f (patch)
tree7f9f7d53b93c188b57848cdc4b337808594a0723 /src/analysis/binary.c
parentd1df89e49a2e8723337570debcf36907b1eded62 (diff)
Built a dialog box to change storage options.
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r--src/analysis/binary.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index c327696..6cc3c74 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -69,7 +69,7 @@ struct _GLoadedBinary
char *username; /* Identifiant de l'utilisateur*/
bool username_changed; /* Mémorise les changements */
- bool local_storage; /* Enregistrements locaux ? */
+ bool use_remote; /* Enregistrements distants ? */
char *remote_host; /* Nom du serveur distant */
unsigned short remote_port; /* Port du serveur distant */
@@ -230,7 +230,7 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
{
binary->username = strdup("default");
- binary->local_storage = true;
+ binary->use_remote = false;
binary->remote_host = strdup("localhost");
binary->remote_port = 1337;
@@ -437,10 +437,10 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
storage_path = strdup(path);
storage_path = stradd(storage_path, "/Storage");
- value = get_node_prop_value(context, storage_path, "local");
+ value = get_node_prop_value(context, storage_path, "remote");
if (value == NULL) goto glbls_no_storage_config;
- binary->local_storage = (strcmp(value, "true") == 0);
+ binary->use_remote = (strcmp(value, "true") == 0);
free(value);
@@ -559,8 +559,8 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
storage_path = strdup(path);
storage_path = stradd(storage_path, "/Storage");
- result &= add_string_attribute_to_node(xdoc, context, storage_path, "local",
- binary->local_storage ? "true" : "false");
+ result &= add_string_attribute_to_node(xdoc, context, storage_path, "remote",
+ binary->use_remote ? "true" : "false");
/* Nom d'utilisateur */
@@ -681,9 +681,9 @@ void g_loaded_binary_set_username(GLoadedBinary *binary, const char *username)
* *
******************************************************************************/
-bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
+bool g_loaded_binary_use_remote_storage(const GLoadedBinary *binary)
{
- return binary->local_storage;
+ return binary->use_remote;
}
@@ -691,7 +691,7 @@ bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
-* local = statut de l'utilisation du serveur local. *
+* use = statut de l'utilisation du serveur distant. *
* *
* Description : Définit si tous les enregistrements sont locaux ou non. *
* *
@@ -701,11 +701,11 @@ bool g_loaded_binary_get_local_storage(const GLoadedBinary *binary)
* *
******************************************************************************/
-void g_loaded_binary_set_local_storage(GLoadedBinary *binary, bool local)
+void g_loaded_binary_set_remote_storage_usage(GLoadedBinary *binary, bool use)
{
- binary->local_storage = local;
+ binary->use_remote = use;
- if (local)
+ if (use)
/* TODO : reload conn ! */;
else
/* TODO : stop conn ! */;
@@ -1029,18 +1029,36 @@ GDbClient *g_loaded_binary_get_db_client(const GLoadedBinary *binary)
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
+* count = taille de la liste constituée. [OUT] *
* *
* Description : Fournit l'ensemble des collections utilisées par un binaire. *
* *
-* Retour : Collections en place. *
+* Retour : Liste de collections en place à libérer après usage. *
* *
* Remarques : - *
* *
******************************************************************************/
-GList *g_loaded_binary_get_all_collections(const GLoadedBinary *binary)
+GDbCollection **g_loaded_binary_get_all_collections(const GLoadedBinary *binary, size_t *count)
{
- return binary->collections;
+ GDbCollection **result; /* Liste à retourner */
+ GList *c; /* Boucle de parcours #1 */
+ size_t i; /* Boucle de parcours #2 */
+
+ *count = g_list_length(binary->collections);
+
+ result = malloc(*count * sizeof(GDbCollection *));
+
+ for (c = g_list_first(binary->collections), i = 0; c != NULL; c = g_list_next(c), i++)
+ {
+ assert(i < *count);
+
+ result[i] = G_DB_COLLECTION(c->data);
+ g_object_ref(G_OBJECT(result[i]));
+
+ }
+
+ return result;
}