aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing-filenames.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-10-04 22:52:00 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-10-04 22:52:00 +0200
commit5df04510362413a6c215365879058f5c445e1f3c (patch)
tree3c17f355f98529ba36cd4626b723240a7ef429d2 /src/transport/transport-testing-filenames.c
parent9ff663cc02f81cd842fb07e7c29c44a809368423 (diff)
downloadgnunet-5df04510362413a6c215365879058f5c445e1f3c.tar.gz
gnunet-5df04510362413a6c215365879058f5c445e1f3c.zip
Remove most of old transport, ATS and PEERINFO. Disable TESTBED and related tests
Diffstat (limited to 'src/transport/transport-testing-filenames.c')
-rw-r--r--src/transport/transport-testing-filenames.c175
1 files changed, 0 insertions, 175 deletions
diff --git a/src/transport/transport-testing-filenames.c b/src/transport/transport-testing-filenames.c
deleted file mode 100644
index ee7b0aacf..000000000
--- a/src/transport/transport-testing-filenames.c
+++ /dev/null
@@ -1,175 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file transport-testing-filenames.c
22 * @brief convenience string manipulation functions for tests
23 * @author Matthias Wachs
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "transport-testing.h"
28
29
30/**
31 * Removes all directory separators from absolute filename
32 *
33 * @param file the absolute file name, e.g. as found in argv[0]
34 * @return extracted file name, has to be freed by caller
35 */
36static char *
37extract_filename (const char *file)
38{
39 char *pch = GNUNET_strdup (file);
40 char *backup = pch;
41 char *filename = NULL;
42 char *res;
43
44 if (NULL != strstr (pch, "/"))
45 {
46 pch = strtok (pch, "/");
47 while (pch != NULL)
48 {
49 pch = strtok (NULL, "/");
50 if (pch != NULL)
51 {
52 filename = pch;
53 }
54 }
55 }
56 else
57 filename = pch;
58
59 res = GNUNET_strdup (filename);
60 GNUNET_free (backup);
61 return res;
62}
63
64
65char *
66GNUNET_TRANSPORT_TESTING_get_test_name (const char *file)
67{
68 char *backup = extract_filename (file);
69 char *filename = backup;
70 char *dotexe;
71 char *ret;
72
73 if (NULL == filename)
74 return NULL;
75
76 /* remove "lt-" */
77 filename = strstr (filename, "test");
78 if (NULL == filename)
79 {
80 GNUNET_free (backup);
81 return NULL;
82 }
83
84 /* remove ".exe" */
85 if (NULL != (dotexe = strstr (filename, ".exe")))
86 dotexe[0] = '\0';
87 ret = GNUNET_strdup (filename);
88 GNUNET_free (backup);
89 return ret;
90}
91
92
93char *
94GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file)
95{
96 char *src = extract_filename (file);
97 char *split;
98
99 split = strstr (src, ".");
100 if (NULL != split)
101 split[0] = '\0';
102 return src;
103}
104
105
106char *
107GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file,
108 const char *test)
109{
110 char *filename;
111 char *dotexe;
112 char *e = extract_filename (file);
113 char *t = extract_filename (test);
114 char *ret;
115
116 if (NULL == e)
117 goto fail;
118 /* remove "lt-" */
119 filename = strstr (e, "tes");
120 if (NULL == filename)
121 goto fail;
122 /* remove ".exe" */
123 if (NULL != (dotexe = strstr (filename, ".exe")))
124 dotexe[0] = '\0';
125
126 /* find last _ */
127 filename = strstr (filename, t);
128 if (NULL == filename)
129 goto fail;
130 /* copy plugin */
131 filename += strlen (t);
132 if ('\0' != *filename)
133 filename++;
134 ret = GNUNET_strdup (filename);
135 goto suc;
136fail:
137 ret = NULL;
138suc:
139 GNUNET_free (t);
140 GNUNET_free (e);
141 return ret;
142}
143
144
145char *
146GNUNET_TRANSPORT_TESTING_get_config_name (const char *file,
147 int count)
148{
149 char *filename = extract_filename (file);
150 char *backup = filename;
151 char *dotexe;
152 char *ret;
153
154 if (NULL == filename)
155 return NULL;
156 /* remove "lt-" */
157 filename = strstr (filename, "test");
158 if (NULL == filename)
159 goto fail;
160 /* remove ".exe" */
161 if (NULL != (dotexe = strstr (filename, ".exe")))
162 dotexe[0] = '\0';
163 GNUNET_asprintf (&ret,
164 "%s_peer%u.conf",
165 filename,
166 count);
167 GNUNET_free (backup);
168 return ret;
169fail:
170 GNUNET_free (backup);
171 return NULL;
172}
173
174
175/* end of transport-testing-filenames.c */