diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/transport/transport-testing-filenames.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/transport/transport-testing-filenames.c')
-rw-r--r-- | src/transport/transport-testing-filenames.c | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/src/transport/transport-testing-filenames.c b/src/transport/transport-testing-filenames.c index 4c2fbd3f5..865907007 100644 --- a/src/transport/transport-testing-filenames.c +++ b/src/transport/transport-testing-filenames.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file transport-testing-filenames.c | 21 | * @file transport-testing-filenames.c |
22 | * @brief convenience string manipulation functions for tests | 22 | * @brief convenience string manipulation functions for tests |
@@ -33,49 +33,49 @@ | |||
33 | * @return extracted file name, has to be freed by caller | 33 | * @return extracted file name, has to be freed by caller |
34 | */ | 34 | */ |
35 | static char * | 35 | static char * |
36 | extract_filename (const char *file) | 36 | extract_filename(const char *file) |
37 | { | 37 | { |
38 | char *pch = GNUNET_strdup (file); | 38 | char *pch = GNUNET_strdup(file); |
39 | char *backup = pch; | 39 | char *backup = pch; |
40 | char *filename = NULL; | 40 | char *filename = NULL; |
41 | char *res; | 41 | char *res; |
42 | 42 | ||
43 | #if WINDOWS | 43 | #if WINDOWS |
44 | if ((strlen (pch) >= 3) && pch[1] == ':') | 44 | if ((strlen(pch) >= 3) && pch[1] == ':') |
45 | { | ||
46 | if (NULL != strstr (pch, "\\")) | ||
47 | { | 45 | { |
48 | pch = strtok (pch, "\\"); | 46 | if (NULL != strstr(pch, "\\")) |
49 | while (pch != NULL) | 47 | { |
50 | { | 48 | pch = strtok(pch, "\\"); |
51 | pch = strtok (NULL, "\\"); | 49 | while (pch != NULL) |
52 | if (pch != NULL) | 50 | { |
53 | filename = pch; | 51 | pch = strtok(NULL, "\\"); |
54 | } | 52 | if (pch != NULL) |
53 | filename = pch; | ||
54 | } | ||
55 | } | ||
55 | } | 56 | } |
56 | } | ||
57 | if (filename != NULL) | 57 | if (filename != NULL) |
58 | pch = filename; /* If we miss the next condition, filename = pch will | 58 | pch = filename; /* If we miss the next condition, filename = pch will |
59 | * not harm us. | 59 | * not harm us. |
60 | */ | 60 | */ |
61 | #endif | 61 | #endif |
62 | if (NULL != strstr (pch, "/")) | 62 | if (NULL != strstr(pch, "/")) |
63 | { | ||
64 | pch = strtok (pch, "/"); | ||
65 | while (pch != NULL) | ||
66 | { | 63 | { |
67 | pch = strtok (NULL, "/"); | 64 | pch = strtok(pch, "/"); |
68 | if (pch != NULL) | 65 | while (pch != NULL) |
69 | { | 66 | { |
70 | filename = pch; | 67 | pch = strtok(NULL, "/"); |
71 | } | 68 | if (pch != NULL) |
69 | { | ||
70 | filename = pch; | ||
71 | } | ||
72 | } | ||
72 | } | 73 | } |
73 | } | ||
74 | else | 74 | else |
75 | filename = pch; | 75 | filename = pch; |
76 | 76 | ||
77 | res = GNUNET_strdup (filename); | 77 | res = GNUNET_strdup(filename); |
78 | GNUNET_free (backup); | 78 | GNUNET_free(backup); |
79 | return res; | 79 | return res; |
80 | } | 80 | } |
81 | 81 | ||
@@ -88,9 +88,9 @@ extract_filename (const char *file) | |||
88 | * @return the result | 88 | * @return the result |
89 | */ | 89 | */ |
90 | char * | 90 | char * |
91 | GNUNET_TRANSPORT_TESTING_get_test_name (const char *file) | 91 | GNUNET_TRANSPORT_TESTING_get_test_name(const char *file) |
92 | { | 92 | { |
93 | char *backup = extract_filename (file); | 93 | char *backup = extract_filename(file); |
94 | char *filename = backup; | 94 | char *filename = backup; |
95 | char *dotexe; | 95 | char *dotexe; |
96 | char *ret; | 96 | char *ret; |
@@ -99,18 +99,18 @@ GNUNET_TRANSPORT_TESTING_get_test_name (const char *file) | |||
99 | return NULL; | 99 | return NULL; |
100 | 100 | ||
101 | /* remove "lt-" */ | 101 | /* remove "lt-" */ |
102 | filename = strstr (filename, "test"); | 102 | filename = strstr(filename, "test"); |
103 | if (NULL == filename) | 103 | if (NULL == filename) |
104 | { | 104 | { |
105 | GNUNET_free (backup); | 105 | GNUNET_free(backup); |
106 | return NULL; | 106 | return NULL; |
107 | } | 107 | } |
108 | 108 | ||
109 | /* remove ".exe" */ | 109 | /* remove ".exe" */ |
110 | if (NULL != (dotexe = strstr (filename, ".exe"))) | 110 | if (NULL != (dotexe = strstr(filename, ".exe"))) |
111 | dotexe[0] = '\0'; | 111 | dotexe[0] = '\0'; |
112 | ret = GNUNET_strdup (filename); | 112 | ret = GNUNET_strdup(filename); |
113 | GNUNET_free (backup); | 113 | GNUNET_free(backup); |
114 | return ret; | 114 | return ret; |
115 | } | 115 | } |
116 | 116 | ||
@@ -122,12 +122,12 @@ GNUNET_TRANSPORT_TESTING_get_test_name (const char *file) | |||
122 | * @return the result | 122 | * @return the result |
123 | */ | 123 | */ |
124 | char * | 124 | char * |
125 | GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file) | 125 | GNUNET_TRANSPORT_TESTING_get_test_source_name(const char *file) |
126 | { | 126 | { |
127 | char *src = extract_filename (file); | 127 | char *src = extract_filename(file); |
128 | char *split; | 128 | char *split; |
129 | 129 | ||
130 | split = strstr (src, "."); | 130 | split = strstr(src, "."); |
131 | if (NULL != split) | 131 | if (NULL != split) |
132 | split[0] = '\0'; | 132 | split[0] = '\0'; |
133 | return src; | 133 | return src; |
@@ -142,40 +142,40 @@ GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file) | |||
142 | * @return the result | 142 | * @return the result |
143 | */ | 143 | */ |
144 | char * | 144 | char * |
145 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file, | 145 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name(const char *file, |
146 | const char *test) | 146 | const char *test) |
147 | { | 147 | { |
148 | char *filename; | 148 | char *filename; |
149 | char *dotexe; | 149 | char *dotexe; |
150 | char *e = extract_filename (file); | 150 | char *e = extract_filename(file); |
151 | char *t = extract_filename (test); | 151 | char *t = extract_filename(test); |
152 | char *ret; | 152 | char *ret; |
153 | 153 | ||
154 | if (NULL == e) | 154 | if (NULL == e) |
155 | goto fail; | 155 | goto fail; |
156 | /* remove "lt-" */ | 156 | /* remove "lt-" */ |
157 | filename = strstr (e, "tes"); | 157 | filename = strstr(e, "tes"); |
158 | if (NULL == filename) | 158 | if (NULL == filename) |
159 | goto fail; | 159 | goto fail; |
160 | /* remove ".exe" */ | 160 | /* remove ".exe" */ |
161 | if (NULL != (dotexe = strstr (filename, ".exe"))) | 161 | if (NULL != (dotexe = strstr(filename, ".exe"))) |
162 | dotexe[0] = '\0'; | 162 | dotexe[0] = '\0'; |
163 | 163 | ||
164 | /* find last _ */ | 164 | /* find last _ */ |
165 | filename = strstr (filename, t); | 165 | filename = strstr(filename, t); |
166 | if (NULL == filename) | 166 | if (NULL == filename) |
167 | goto fail; | 167 | goto fail; |
168 | /* copy plugin */ | 168 | /* copy plugin */ |
169 | filename += strlen (t); | 169 | filename += strlen(t); |
170 | if ('\0' != *filename) | 170 | if ('\0' != *filename) |
171 | filename++; | 171 | filename++; |
172 | ret = GNUNET_strdup (filename); | 172 | ret = GNUNET_strdup(filename); |
173 | goto suc; | 173 | goto suc; |
174 | fail: | 174 | fail: |
175 | ret = NULL; | 175 | ret = NULL; |
176 | suc: | 176 | suc: |
177 | GNUNET_free (t); | 177 | GNUNET_free(t); |
178 | GNUNET_free (e); | 178 | GNUNET_free(e); |
179 | return ret; | 179 | return ret; |
180 | } | 180 | } |
181 | 181 | ||
@@ -189,10 +189,10 @@ suc: | |||
189 | * @return the result | 189 | * @return the result |
190 | */ | 190 | */ |
191 | char * | 191 | char * |
192 | GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, | 192 | GNUNET_TRANSPORT_TESTING_get_config_name(const char *file, |
193 | int count) | 193 | int count) |
194 | { | 194 | { |
195 | char *filename = extract_filename (file); | 195 | char *filename = extract_filename(file); |
196 | char *backup = filename; | 196 | char *backup = filename; |
197 | char *dotexe; | 197 | char *dotexe; |
198 | char *ret; | 198 | char *ret; |
@@ -200,20 +200,20 @@ GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, | |||
200 | if (NULL == filename) | 200 | if (NULL == filename) |
201 | return NULL; | 201 | return NULL; |
202 | /* remove "lt-" */ | 202 | /* remove "lt-" */ |
203 | filename = strstr (filename, "test"); | 203 | filename = strstr(filename, "test"); |
204 | if (NULL == filename) | 204 | if (NULL == filename) |
205 | goto fail; | 205 | goto fail; |
206 | /* remove ".exe" */ | 206 | /* remove ".exe" */ |
207 | if (NULL != (dotexe = strstr (filename, ".exe"))) | 207 | if (NULL != (dotexe = strstr(filename, ".exe"))) |
208 | dotexe[0] = '\0'; | 208 | dotexe[0] = '\0'; |
209 | GNUNET_asprintf (&ret, | 209 | GNUNET_asprintf(&ret, |
210 | "%s_peer%u.conf", | 210 | "%s_peer%u.conf", |
211 | filename, | 211 | filename, |
212 | count); | 212 | count); |
213 | GNUNET_free (backup); | 213 | GNUNET_free(backup); |
214 | return ret; | 214 | return ret; |
215 | fail: | 215 | fail: |
216 | GNUNET_free (backup); | 216 | GNUNET_free(backup); |
217 | return NULL; | 217 | return NULL; |
218 | } | 218 | } |
219 | 219 | ||