summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-08-29 22:16:59 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-08-29 22:16:59 (GMT)
commit14f1b8ff552dfb8aef6c66b3c65e816aa7820bb0 (patch)
tree735e01df60a21d6c9ecb961af36ab61aefec6d2f /src/analysis/binary.c
parentfa40856e942a7e1bd1cb2729645182c1fa717468 (diff)
Removed code relative to the old share server version.
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r--src/analysis/binary.c79
1 files changed, 20 insertions, 59 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 5ac8e04..ec129b1 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -70,7 +70,7 @@ struct _GLoadedBinary
bool use_remote; /* Enregistrements distants ? */
char *remote_host; /* Nom du serveur distant */
- unsigned short remote_port; /* Port du serveur distant */
+ char *remote_port; /* Port du serveur distant */
GHubClient *local; /* Enregistrements locaux */
GHubClient *remote; /* Enregistrements distants */
@@ -246,7 +246,7 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
binary->use_remote = false;
binary->remote_host = strdup("localhost");
- binary->remote_port = 1337;
+ binary->remote_port = strdup("1337");
binary->storages[DBF_BOOKMARKS] = DBS_ALL_LOCAL;
binary->storages[DBF_COMMENTS] = DBS_ALL_LOCAL;
@@ -446,7 +446,7 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
char *storage_path; /* Partie "Enregistrement" */
char *value; /* Valeur lue à partie du XML */
char *access; /* Chemin d'accès à un élément */
- unsigned short port; /* Port de communication */
+ char *port; /* Port de communication */
DBFeatures i; /* Boucle de parcours */
result = true;
@@ -484,17 +484,21 @@ static bool g_loaded_binary_load_storage(GLoadedBinary *binary, xmlXPathContext
value = get_node_prop_value(context, access, "port");
if (value == NULL) goto glbls_features;
- port = atoi(value);
-
- free(value);
+ port = value;
value = get_node_prop_value(context, access, "host");
- if (value == NULL) goto glbls_features;
+ if (value == NULL)
+ {
+ free(port);
+ goto glbls_features;
+ }
g_loaded_binary_set_remote_server(binary, value, port);
free(value);
+ free(port);
+
glbls_features:
free(access);
@@ -571,7 +575,6 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
bool result; /* Bilan à faire remonter */
char *storage_path; /* Partie "Enregistrement" */
char *access; /* Chemin d'accès à un élément */
- char port_str[sizeof(XSTR(USHRT_MAX)) + 1]; /* Version chaînée */
DBFeatures i; /* Boucle de parcours */
result = true;
@@ -598,8 +601,7 @@ static bool g_loaded_binary_save_storage(const GLoadedBinary *binary, xmlDoc *xd
result &= add_string_attribute_to_node(xdoc, context, access, "host", binary->remote_host);
- sprintf(port_str, "%hu", binary->remote_port);
- result &= add_string_attribute_to_node(xdoc, context, access, "port", port_str);
+ result &= add_string_attribute_to_node(xdoc, context, access, "port", binary->remote_port);
free(access);
@@ -747,7 +749,7 @@ void g_loaded_binary_set_remote_storage_usage(GLoadedBinary *binary, bool use)
* *
******************************************************************************/
-void g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char **host, unsigned short *port)
+void g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char **host, const char **port)
{
*host = binary->remote_host;
*port = binary->remote_port;
@@ -769,12 +771,13 @@ void g_loaded_binary_get_remote_server(const GLoadedBinary *binary, const char *
* *
******************************************************************************/
-void g_loaded_binary_set_remote_server(GLoadedBinary *binary, const char *host, unsigned short port)
+void g_loaded_binary_set_remote_server(GLoadedBinary *binary, const char *host, const char *port)
{
free(binary->remote_host);
binary->remote_host = strdup(host);
- binary->remote_port = port;
+ free(binary->remote_port);
+ binary->remote_port = strdup(port);
}
@@ -835,25 +838,9 @@ void g_loaded_binary_set_storage(GLoadedBinary *binary, DBFeatures feature, DBSt
static bool g_loaded_binary_connect_internal(GLoadedBinary *binary)
{
bool result; /* Bilan à retourner */
- const char *tmp; /* Stockage temporaire */
- char *author; /* Identification à diffuser */
- char *priv; /* Chemin de la clef privée */
GBinContent *content; /* Contenu bianire manipulé */
const gchar *checksum; /* Identifiant de binaire */
- result = false;
-
- /* Utilisateur représenté */
-
- if (!g_generic_config_get_value(get_main_configuration(), MPK_AUTHOR_NAME, &tmp))
- goto glbcl_exit;
-
- author = strdup(tmp);
-
- /* Chemin vers la clef privée */
-
- priv = get_xdg_config_dir("chrysalide" G_DIR_SEPARATOR_S "id_rsa.priv");
-
/* Détermination de l'identifiant */
content = g_binary_format_get_content(G_BIN_FORMAT(binary->format));
@@ -862,15 +849,10 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary)
/* Tentative de connexion */
- binary->local = g_hub_client_new(/*author, priv,
- g_loaded_binary_get_name(binary, false),
- */checksum,
- binary->collections);
+ binary->local = g_hub_client_new(checksum, binary->collections);
result = g_hub_client_start_internal(binary->local);
- glbcl_exit:
-
return result;
}
@@ -891,27 +873,11 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary)
static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
{
bool result; /* Bilan à retourner */
- const char *tmp; /* Stockage temporaire */
- char *author; /* Identification à diffuser */
- char *priv; /* Chemin de la clef privée */
GBinContent *content; /* Contenu bianire manipulé */
const gchar *checksum; /* Identifiant de binaire */
- result = false;
-
assert(binary->remote == NULL);
- /* Utilisateur représenté */
-
- if (!g_generic_config_get_value(get_main_configuration(), MPK_AUTHOR_NAME, &tmp))
- goto glbcl_exit;
-
- author = strdup(tmp);
-
- /* Chemin vers la clef privée */
-
- priv = get_xdg_config_dir("chrysalide" G_DIR_SEPARATOR_S "id_rsa.priv");
-
/* Détermination de l'identifiant */
content = g_binary_format_get_content(G_BIN_FORMAT(binary->format));
@@ -920,24 +886,19 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary)
/* Tentative de connexion */
- binary->remote = g_hub_client_new(/*author, priv,
- g_loaded_binary_get_name(binary, false),
- */checksum,
- binary->collections);
+ binary->remote = g_hub_client_new(checksum, binary->collections);
- result = g_hub_client_start_remote(binary->local, binary->remote_host, "1337", true);//binary->remote_port);
+ result = g_hub_client_start_remote(binary->local, binary->remote_host, binary->remote_port, true);
if (!result)
{
- log_variadic_message(LMT_ERROR, _("Failed to connect to remote host '%s:%hu'"),
+ log_variadic_message(LMT_ERROR, _("Failed to connect to remote host '%s:%s'"),
binary->remote_host, binary->remote_port);
g_clear_object(&binary->remote);
}
- glbcl_exit:
-
return result;
}