diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/transport/transport-testing-filenames.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/transport/transport-testing-filenames.c')
-rw-r--r-- | src/transport/transport-testing-filenames.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/src/transport/transport-testing-filenames.c b/src/transport/transport-testing-filenames.c index 8d493864e..7c136b690 100644 --- a/src/transport/transport-testing-filenames.c +++ b/src/transport/transport-testing-filenames.c | |||
@@ -33,30 +33,30 @@ | |||
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 (NULL != strstr(pch, "/")) | 43 | if (NULL != strstr (pch, "/")) |
44 | { | ||
45 | pch = strtok (pch, "/"); | ||
46 | while (pch != NULL) | ||
44 | { | 47 | { |
45 | pch = strtok(pch, "/"); | 48 | pch = strtok (NULL, "/"); |
46 | while (pch != NULL) | 49 | if (pch != NULL) |
47 | { | 50 | { |
48 | pch = strtok(NULL, "/"); | 51 | filename = pch; |
49 | if (pch != NULL) | 52 | } |
50 | { | ||
51 | filename = pch; | ||
52 | } | ||
53 | } | ||
54 | } | 53 | } |
54 | } | ||
55 | else | 55 | else |
56 | filename = pch; | 56 | filename = pch; |
57 | 57 | ||
58 | res = GNUNET_strdup(filename); | 58 | res = GNUNET_strdup (filename); |
59 | GNUNET_free(backup); | 59 | GNUNET_free (backup); |
60 | return res; | 60 | return res; |
61 | } | 61 | } |
62 | 62 | ||
@@ -69,9 +69,9 @@ extract_filename(const char *file) | |||
69 | * @return the result | 69 | * @return the result |
70 | */ | 70 | */ |
71 | char * | 71 | char * |
72 | GNUNET_TRANSPORT_TESTING_get_test_name(const char *file) | 72 | GNUNET_TRANSPORT_TESTING_get_test_name (const char *file) |
73 | { | 73 | { |
74 | char *backup = extract_filename(file); | 74 | char *backup = extract_filename (file); |
75 | char *filename = backup; | 75 | char *filename = backup; |
76 | char *dotexe; | 76 | char *dotexe; |
77 | char *ret; | 77 | char *ret; |
@@ -80,18 +80,18 @@ GNUNET_TRANSPORT_TESTING_get_test_name(const char *file) | |||
80 | return NULL; | 80 | return NULL; |
81 | 81 | ||
82 | /* remove "lt-" */ | 82 | /* remove "lt-" */ |
83 | filename = strstr(filename, "test"); | 83 | filename = strstr (filename, "test"); |
84 | if (NULL == filename) | 84 | if (NULL == filename) |
85 | { | 85 | { |
86 | GNUNET_free(backup); | 86 | GNUNET_free (backup); |
87 | return NULL; | 87 | return NULL; |
88 | } | 88 | } |
89 | 89 | ||
90 | /* remove ".exe" */ | 90 | /* remove ".exe" */ |
91 | if (NULL != (dotexe = strstr(filename, ".exe"))) | 91 | if (NULL != (dotexe = strstr (filename, ".exe"))) |
92 | dotexe[0] = '\0'; | 92 | dotexe[0] = '\0'; |
93 | ret = GNUNET_strdup(filename); | 93 | ret = GNUNET_strdup (filename); |
94 | GNUNET_free(backup); | 94 | GNUNET_free (backup); |
95 | return ret; | 95 | return ret; |
96 | } | 96 | } |
97 | 97 | ||
@@ -103,12 +103,12 @@ GNUNET_TRANSPORT_TESTING_get_test_name(const char *file) | |||
103 | * @return the result | 103 | * @return the result |
104 | */ | 104 | */ |
105 | char * | 105 | char * |
106 | GNUNET_TRANSPORT_TESTING_get_test_source_name(const char *file) | 106 | GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file) |
107 | { | 107 | { |
108 | char *src = extract_filename(file); | 108 | char *src = extract_filename (file); |
109 | char *split; | 109 | char *split; |
110 | 110 | ||
111 | split = strstr(src, "."); | 111 | split = strstr (src, "."); |
112 | if (NULL != split) | 112 | if (NULL != split) |
113 | split[0] = '\0'; | 113 | split[0] = '\0'; |
114 | return src; | 114 | return src; |
@@ -123,40 +123,40 @@ GNUNET_TRANSPORT_TESTING_get_test_source_name(const char *file) | |||
123 | * @return the result | 123 | * @return the result |
124 | */ | 124 | */ |
125 | char * | 125 | char * |
126 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name(const char *file, | 126 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *file, |
127 | const char *test) | 127 | const char *test) |
128 | { | 128 | { |
129 | char *filename; | 129 | char *filename; |
130 | char *dotexe; | 130 | char *dotexe; |
131 | char *e = extract_filename(file); | 131 | char *e = extract_filename (file); |
132 | char *t = extract_filename(test); | 132 | char *t = extract_filename (test); |
133 | char *ret; | 133 | char *ret; |
134 | 134 | ||
135 | if (NULL == e) | 135 | if (NULL == e) |
136 | goto fail; | 136 | goto fail; |
137 | /* remove "lt-" */ | 137 | /* remove "lt-" */ |
138 | filename = strstr(e, "tes"); | 138 | filename = strstr (e, "tes"); |
139 | if (NULL == filename) | 139 | if (NULL == filename) |
140 | goto fail; | 140 | goto fail; |
141 | /* remove ".exe" */ | 141 | /* remove ".exe" */ |
142 | if (NULL != (dotexe = strstr(filename, ".exe"))) | 142 | if (NULL != (dotexe = strstr (filename, ".exe"))) |
143 | dotexe[0] = '\0'; | 143 | dotexe[0] = '\0'; |
144 | 144 | ||
145 | /* find last _ */ | 145 | /* find last _ */ |
146 | filename = strstr(filename, t); | 146 | filename = strstr (filename, t); |
147 | if (NULL == filename) | 147 | if (NULL == filename) |
148 | goto fail; | 148 | goto fail; |
149 | /* copy plugin */ | 149 | /* copy plugin */ |
150 | filename += strlen(t); | 150 | filename += strlen (t); |
151 | if ('\0' != *filename) | 151 | if ('\0' != *filename) |
152 | filename++; | 152 | filename++; |
153 | ret = GNUNET_strdup(filename); | 153 | ret = GNUNET_strdup (filename); |
154 | goto suc; | 154 | goto suc; |
155 | fail: | 155 | fail: |
156 | ret = NULL; | 156 | ret = NULL; |
157 | suc: | 157 | suc: |
158 | GNUNET_free(t); | 158 | GNUNET_free (t); |
159 | GNUNET_free(e); | 159 | GNUNET_free (e); |
160 | return ret; | 160 | return ret; |
161 | } | 161 | } |
162 | 162 | ||
@@ -170,10 +170,10 @@ suc: | |||
170 | * @return the result | 170 | * @return the result |
171 | */ | 171 | */ |
172 | char * | 172 | char * |
173 | GNUNET_TRANSPORT_TESTING_get_config_name(const char *file, | 173 | GNUNET_TRANSPORT_TESTING_get_config_name (const char *file, |
174 | int count) | 174 | int count) |
175 | { | 175 | { |
176 | char *filename = extract_filename(file); | 176 | char *filename = extract_filename (file); |
177 | char *backup = filename; | 177 | char *backup = filename; |
178 | char *dotexe; | 178 | char *dotexe; |
179 | char *ret; | 179 | char *ret; |
@@ -181,20 +181,20 @@ GNUNET_TRANSPORT_TESTING_get_config_name(const char *file, | |||
181 | if (NULL == filename) | 181 | if (NULL == filename) |
182 | return NULL; | 182 | return NULL; |
183 | /* remove "lt-" */ | 183 | /* remove "lt-" */ |
184 | filename = strstr(filename, "test"); | 184 | filename = strstr (filename, "test"); |
185 | if (NULL == filename) | 185 | if (NULL == filename) |
186 | goto fail; | 186 | goto fail; |
187 | /* remove ".exe" */ | 187 | /* remove ".exe" */ |
188 | if (NULL != (dotexe = strstr(filename, ".exe"))) | 188 | if (NULL != (dotexe = strstr (filename, ".exe"))) |
189 | dotexe[0] = '\0'; | 189 | dotexe[0] = '\0'; |
190 | GNUNET_asprintf(&ret, | 190 | GNUNET_asprintf (&ret, |
191 | "%s_peer%u.conf", | 191 | "%s_peer%u.conf", |
192 | filename, | 192 | filename, |
193 | count); | 193 | count); |
194 | GNUNET_free(backup); | 194 | GNUNET_free (backup); |
195 | return ret; | 195 | return ret; |
196 | fail: | 196 | fail: |
197 | GNUNET_free(backup); | 197 | GNUNET_free (backup); |
198 | return NULL; | 198 | return NULL; |
199 | } | 199 | } |
200 | 200 | ||