NULL);
}
+
static int
check ()
{
#endif
NULL);
- char *pch = strdup (argv[0]);
- char *backup = pch;
- char *filename = NULL;
- char *dotexe;
int nat_res;
- /* get executable filename */
- pch = strtok (pch, "/");
- while (pch != NULL)
- {
- pch = strtok (NULL, "/");
- if (pch != NULL)
- filename = pch;
- }
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- /* create cfg filename */
- GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
- GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
- GNUNET_free (backup);
-
if ((strstr (argv[0], "tcp_nat") != NULL) ||
(strstr (argv[0], "udp_nat") != NULL))
{
}
}
+
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
ret = check ();
GNUNET_free (cfg_file_p1);
#endif
NULL);
- char *pch = strdup (argv[0]);
- char *backup = pch;
- char *filename = NULL;
- char *dotexe;
int nat_res;
- /* get executable filename */
- pch = strtok (pch, "/");
- while (pch != NULL)
- {
- pch = strtok (NULL, "/");
- if (pch != NULL)
- filename = pch;
- }
- /* remove "lt-" */
- filename = strstr (filename, "tes");
- if (NULL != (dotexe = strstr (filename, ".exe")))
- dotexe[0] = '\0';
-
- /* create cfg filename */
- GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
- GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
- GNUNET_free (backup);
-
if ((strstr (argv[0], "tcp_nat") != NULL) ||
(strstr (argv[0], "udp_nat") != NULL))
{
}
}
+
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
ret = check ();
GNUNET_free (cfg_file_p1);
if (NULL != (dotexe = strstr (filename, ".exe")))
dotexe[0] = '\0';
- /* create cfg filename */
- GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
- GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
-
split = strstr (src_name, ".");
if (split != NULL)
{
return 0;
}
}
+
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
ret = check ();
GNUNET_free (cfg_file_p1);
GNUNET_free (cfg_file_p2);
+
GNUNET_free_non_null (test_name);
return ret;
if (NULL != (dotexe = strstr (filename, ".exe")))
dotexe[0] = '\0';
- /* create cfg filename */
- GNUNET_asprintf (&cfg_file_p1, "%s_peer1.conf", filename);
- GNUNET_asprintf (&cfg_file_p2, "%s_peer2.conf", filename);
-
split = strstr (src_name, ".");
if (split != NULL)
{
return 0;
}
}
+
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
+ GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
+
ret = check ();
GNUNET_free (cfg_file_p1);
GNUNET_free (cfg_file_p2);
+
GNUNET_free_non_null (test_name);
return ret;
GNUNET_free (cc);
}
+/*
+ * Some utility functions
+ */
+
+/**
+ * this function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
+ * if existing ".exe"-prefix and adds the peer-number
+ * @param file filename of the test, e.g. argv[0]
+ * @param cfgname where to write the result
+ * @param count peer number
+ */
+void
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **cfgname,
+ int count)
+{
+ char *pch = strdup (file);
+ char *backup = pch;
+ char *filename = NULL;
+ char *dotexe;
+
+
+ /* get executable filename */
+ pch = strtok (pch, "/");
+ while (pch != NULL)
+ {
+ pch = strtok (NULL, "/");
+ if (pch != NULL)
+ filename = pch;
+ }
+ /* remove "lt-" */
+ filename = strstr (filename, "tes");
+ if (NULL != (dotexe = strstr (filename, ".exe")))
+ dotexe[0] = '\0';
+
+ /* create cfg filename */
+ GNUNET_asprintf (cfgname, "%s_peer%u.conf", filename, count);
+
+ GNUNET_free (backup);
+}
+
/* end of transport_testing.h */
void
GNUNET_TRANSPORT_TESTING_connect_peers_cancel (void *cc);
+/*
+ * Some utility functions
+ */
+
+/**
+ * this function takes the filename (e.g. argv[0), removes a "lt-"-prefix and
+ * if existing ".exe"-prefix and adds the peer-number
+ * @param file filename of the test, e.g. argv[0]
+ * @param cfgname where to write the result
+ * @param count peer number
+ */
+void
+GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, char **cfgname,
+ int count);
+
/* end of transport_testing.h */