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/fs/test_fs_download.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/fs/test_fs_download.c')
-rw-r--r-- | src/fs/test_fs_download.c | 419 |
1 files changed, 215 insertions, 204 deletions
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 242e6f1aa..f7c35a680 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.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 | /** | 21 | /** |
22 | * @file fs/test_fs_download.c | 22 | * @file fs/test_fs_download.c |
@@ -38,12 +38,12 @@ | |||
38 | /** | 38 | /** |
39 | * How long until we give up on transmitting the message? | 39 | * How long until we give up on transmitting the message? |
40 | */ | 40 | */ |
41 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 41 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120) |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * How long should our test-content live? | 44 | * How long should our test-content live? |
45 | */ | 45 | */ |
46 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 46 | #define LIFETIME GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 15) |
47 | 47 | ||
48 | static unsigned int anonymity_level; | 48 | static unsigned int anonymity_level; |
49 | 49 | ||
@@ -67,187 +67,198 @@ static int err; | |||
67 | 67 | ||
68 | 68 | ||
69 | static void | 69 | static void |
70 | timeout_kill_task (void *cls) | 70 | timeout_kill_task(void *cls) |
71 | { | 71 | { |
72 | if (NULL != download) | 72 | if (NULL != download) |
73 | { | 73 | { |
74 | GNUNET_FS_download_stop (download, GNUNET_YES); | 74 | GNUNET_FS_download_stop(download, GNUNET_YES); |
75 | download = NULL; | 75 | download = NULL; |
76 | } | 76 | } |
77 | else if (NULL != publish) | 77 | else if (NULL != publish) |
78 | { | 78 | { |
79 | GNUNET_FS_publish_stop (publish); | 79 | GNUNET_FS_publish_stop(publish); |
80 | publish = NULL; | 80 | publish = NULL; |
81 | } | 81 | } |
82 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout downloading file\n"); | 82 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Timeout downloading file\n"); |
83 | timeout_kill = NULL; | 83 | timeout_kill = NULL; |
84 | err = 1; | 84 | err = 1; |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | static void | 88 | static void |
89 | abort_publish_task (void *cls) | 89 | abort_publish_task(void *cls) |
90 | { | 90 | { |
91 | if (NULL != publish) | 91 | if (NULL != publish) |
92 | { | 92 | { |
93 | GNUNET_FS_publish_stop (publish); | 93 | GNUNET_FS_publish_stop(publish); |
94 | publish = NULL; | 94 | publish = NULL; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | static void | 99 | static void |
100 | stop_fs_task (void *cls) | 100 | stop_fs_task(void *cls) |
101 | { | 101 | { |
102 | GNUNET_FS_stop (fs); | 102 | GNUNET_FS_stop(fs); |
103 | fs = NULL; | 103 | fs = NULL; |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | static void | 107 | static void |
108 | abort_download_task (void *cls) | 108 | abort_download_task(void *cls) |
109 | { | 109 | { |
110 | uint64_t size; | 110 | uint64_t size; |
111 | 111 | ||
112 | if (NULL != download) | 112 | if (NULL != download) |
113 | { | 113 | { |
114 | GNUNET_FS_download_stop (download, GNUNET_YES); | 114 | GNUNET_FS_download_stop(download, GNUNET_YES); |
115 | download = NULL; | 115 | download = NULL; |
116 | } | 116 | } |
117 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO)); | 117 | GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_size(fn, &size, GNUNET_YES, GNUNET_NO)); |
118 | GNUNET_assert (size == FILESIZE); | 118 | GNUNET_assert(size == FILESIZE); |
119 | GNUNET_DISK_directory_remove (fn); | 119 | GNUNET_DISK_directory_remove(fn); |
120 | GNUNET_free (fn); | 120 | GNUNET_free(fn); |
121 | fn = NULL; | 121 | fn = NULL; |
122 | GNUNET_SCHEDULER_cancel (timeout_kill); | 122 | GNUNET_SCHEDULER_cancel(timeout_kill); |
123 | timeout_kill = NULL; | 123 | timeout_kill = NULL; |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | static void * | 127 | static void * |
128 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | 128 | progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *event) |
129 | { | 129 | { |
130 | |||
131 | switch (event->status) | 130 | switch (event->status) |
132 | { | 131 | { |
133 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 132 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 133 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
135 | "Publish is progressing (%llu/%llu at level %u off %llu)...\n", | 134 | "Publish is progressing (%llu/%llu at level %u off %llu)...\n", |
136 | (unsigned long long) event->value.publish.completed, | 135 | (unsigned long long)event->value.publish.completed, |
137 | (unsigned long long) event->value.publish.size, | 136 | (unsigned long long)event->value.publish.size, |
138 | event->value.publish.specifics.progress.depth, | 137 | event->value.publish.specifics.progress.depth, |
139 | (unsigned long long) event->value.publish.specifics. | 138 | (unsigned long long)event->value.publish.specifics. |
140 | progress.offset); | 139 | progress.offset); |
141 | break; | 140 | break; |
142 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: | 141 | |
143 | break; | 142 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: |
144 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | 143 | break; |
145 | fprintf (stdout, | 144 | |
146 | "Publishing complete, %llu kb/s.\n", | 145 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: |
147 | (unsigned long long) (FILESIZE * 1000000LL / | 146 | fprintf(stdout, |
148 | (1 + | 147 | "Publishing complete, %llu kb/s.\n", |
149 | GNUNET_TIME_absolute_get_duration | 148 | (unsigned long long)(FILESIZE * 1000000LL / |
150 | (start).rel_value_us) / 1024LL)); | 149 | (1 + |
151 | GAUGER ("FS", | 150 | GNUNET_TIME_absolute_get_duration |
152 | (GNUNET_YES == indexed) | 151 | (start).rel_value_us) / 1024LL)); |
153 | ? "Publishing speed (indexing)" | 152 | GAUGER("FS", |
154 | : "Publishing speed (insertion)", | 153 | (GNUNET_YES == indexed) |
155 | (unsigned long long) (FILESIZE * 1000000LL / | 154 | ? "Publishing speed (indexing)" |
156 | (1 + | 155 | : "Publishing speed (insertion)", |
157 | GNUNET_TIME_absolute_get_duration | 156 | (unsigned long long)(FILESIZE * 1000000LL / |
158 | (start).rel_value_us) / 1024LL), "kb/s"); | 157 | (1 + |
159 | fn = GNUNET_DISK_mktemp ("gnunet-download-test-dst"); | 158 | GNUNET_TIME_absolute_get_duration |
160 | start = GNUNET_TIME_absolute_get (); | 159 | (start).rel_value_us) / 1024LL), "kb/s"); |
161 | download = | 160 | fn = GNUNET_DISK_mktemp("gnunet-download-test-dst"); |
162 | GNUNET_FS_download_start (fs, | 161 | start = GNUNET_TIME_absolute_get(); |
163 | event->value.publish.specifics. | 162 | download = |
164 | completed.chk_uri, NULL, fn, NULL, 0, | 163 | GNUNET_FS_download_start(fs, |
165 | FILESIZE, anonymity_level, | 164 | event->value.publish.specifics. |
166 | GNUNET_FS_DOWNLOAD_OPTION_NONE, | 165 | completed.chk_uri, NULL, fn, NULL, 0, |
167 | "download", NULL); | 166 | FILESIZE, anonymity_level, |
168 | GNUNET_assert (download != NULL); | 167 | GNUNET_FS_DOWNLOAD_OPTION_NONE, |
169 | break; | 168 | "download", NULL); |
170 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: | 169 | GNUNET_assert(download != NULL); |
171 | fprintf (stdout, | 170 | break; |
172 | "Download complete, %llu kb/s.\n", | 171 | |
173 | (unsigned long long) (FILESIZE * 1000000LL / | 172 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: |
174 | (1 + | 173 | fprintf(stdout, |
175 | GNUNET_TIME_absolute_get_duration | 174 | "Download complete, %llu kb/s.\n", |
176 | (start).rel_value_us) / 1024LL)); | 175 | (unsigned long long)(FILESIZE * 1000000LL / |
177 | GAUGER ("FS", | 176 | (1 + |
178 | (GNUNET_YES == indexed) | 177 | GNUNET_TIME_absolute_get_duration |
179 | ? "Local download speed (indexed)" | 178 | (start).rel_value_us) / 1024LL)); |
180 | : "Local download speed (inserted)", | 179 | GAUGER("FS", |
181 | (unsigned long long) (FILESIZE * 1000000LL / | 180 | (GNUNET_YES == indexed) |
181 | ? "Local download speed (indexed)" | ||
182 | : "Local download speed (inserted)", | ||
183 | (unsigned long long)(FILESIZE * 1000000LL / | ||
182 | (1 + | 184 | (1 + |
183 | GNUNET_TIME_absolute_get_duration | 185 | GNUNET_TIME_absolute_get_duration |
184 | (start).rel_value_us) / 1024LL), "kb/s"); | 186 | (start).rel_value_us) / 1024LL), "kb/s"); |
185 | GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); | 187 | GNUNET_SCHEDULER_add_now(&abort_download_task, NULL); |
186 | break; | 188 | break; |
187 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | 189 | |
188 | GNUNET_assert (download == event->value.download.dc); | 190 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: |
189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 191 | GNUNET_assert(download == event->value.download.dc); |
190 | "Download is progressing (%llu/%llu at level %u off %llu)...\n", | 192 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
191 | (unsigned long long) event->value.download.completed, | 193 | "Download is progressing (%llu/%llu at level %u off %llu)...\n", |
192 | (unsigned long long) event->value.download.size, | 194 | (unsigned long long)event->value.download.completed, |
193 | event->value.download.specifics.progress.depth, | 195 | (unsigned long long)event->value.download.size, |
194 | (unsigned long long) event->value.download.specifics. | 196 | event->value.download.specifics.progress.depth, |
195 | progress.offset); | 197 | (unsigned long long)event->value.download.specifics. |
196 | break; | 198 | progress.offset); |
197 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 199 | break; |
198 | fprintf (stderr, "Error publishing file: %s\n", | 200 | |
199 | event->value.publish.specifics.error.message); | 201 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
200 | GNUNET_break (0); | 202 | fprintf(stderr, "Error publishing file: %s\n", |
201 | GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); | 203 | event->value.publish.specifics.error.message); |
202 | GNUNET_SCHEDULER_shutdown (); | 204 | GNUNET_break(0); |
203 | break; | 205 | GNUNET_SCHEDULER_add_now(&abort_publish_task, NULL); |
204 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: | 206 | GNUNET_SCHEDULER_shutdown(); |
205 | fprintf (stderr, "Error downloading file: %s\n", | 207 | break; |
206 | event->value.download.specifics.error.message); | 208 | |
207 | GNUNET_SCHEDULER_add_now (&abort_download_task, NULL); | 209 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: |
208 | GNUNET_SCHEDULER_shutdown (); | 210 | fprintf(stderr, "Error downloading file: %s\n", |
209 | break; | 211 | event->value.download.specifics.error.message); |
210 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | 212 | GNUNET_SCHEDULER_add_now(&abort_download_task, NULL); |
211 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: | 213 | GNUNET_SCHEDULER_shutdown(); |
212 | break; | 214 | break; |
213 | case GNUNET_FS_STATUS_PUBLISH_START: | 215 | |
214 | GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx)); | 216 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: |
215 | GNUNET_assert (NULL == event->value.publish.pctx); | 217 | case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE: |
216 | GNUNET_assert (FILESIZE == event->value.publish.size); | 218 | break; |
217 | GNUNET_assert (0 == event->value.publish.completed); | 219 | |
218 | GNUNET_assert (1 == event->value.publish.anonymity); | 220 | case GNUNET_FS_STATUS_PUBLISH_START: |
219 | break; | 221 | GNUNET_assert(0 == strcmp("publish-context", event->value.publish.cctx)); |
220 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | 222 | GNUNET_assert(NULL == event->value.publish.pctx); |
221 | GNUNET_assert (publish == event->value.publish.pc); | 223 | GNUNET_assert(FILESIZE == event->value.publish.size); |
222 | GNUNET_assert (FILESIZE == event->value.publish.size); | 224 | GNUNET_assert(0 == event->value.publish.completed); |
223 | GNUNET_assert (1 == event->value.publish.anonymity); | 225 | GNUNET_assert(1 == event->value.publish.anonymity); |
224 | GNUNET_SCHEDULER_add_now (&stop_fs_task, NULL); | 226 | break; |
225 | break; | 227 | |
226 | case GNUNET_FS_STATUS_DOWNLOAD_START: | 228 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: |
227 | GNUNET_assert (0 == strcmp ("download", event->value.download.cctx)); | 229 | GNUNET_assert(publish == event->value.publish.pc); |
228 | GNUNET_assert (NULL == event->value.download.pctx); | 230 | GNUNET_assert(FILESIZE == event->value.publish.size); |
229 | GNUNET_assert (NULL != event->value.download.uri); | 231 | GNUNET_assert(1 == event->value.publish.anonymity); |
230 | GNUNET_assert (0 == strcmp (fn, event->value.download.filename)); | 232 | GNUNET_SCHEDULER_add_now(&stop_fs_task, NULL); |
231 | GNUNET_assert (FILESIZE == event->value.download.size); | 233 | break; |
232 | GNUNET_assert (0 == event->value.download.completed); | 234 | |
233 | GNUNET_assert (1 == event->value.download.anonymity); | 235 | case GNUNET_FS_STATUS_DOWNLOAD_START: |
234 | break; | 236 | GNUNET_assert(0 == strcmp("download", event->value.download.cctx)); |
235 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | 237 | GNUNET_assert(NULL == event->value.download.pctx); |
236 | GNUNET_assert (download == event->value.download.dc); | 238 | GNUNET_assert(NULL != event->value.download.uri); |
237 | GNUNET_SCHEDULER_add_now (&abort_publish_task, NULL); | 239 | GNUNET_assert(0 == strcmp(fn, event->value.download.filename)); |
238 | break; | 240 | GNUNET_assert(FILESIZE == event->value.download.size); |
239 | default: | 241 | GNUNET_assert(0 == event->value.download.completed); |
240 | printf ("Unexpected event: %d\n", event->status); | 242 | GNUNET_assert(1 == event->value.download.anonymity); |
241 | break; | 243 | break; |
242 | } | 244 | |
245 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | ||
246 | GNUNET_assert(download == event->value.download.dc); | ||
247 | GNUNET_SCHEDULER_add_now(&abort_publish_task, NULL); | ||
248 | break; | ||
249 | |||
250 | default: | ||
251 | printf("Unexpected event: %d\n", event->status); | ||
252 | break; | ||
253 | } | ||
243 | return NULL; | 254 | return NULL; |
244 | } | 255 | } |
245 | 256 | ||
246 | 257 | ||
247 | static void | 258 | static void |
248 | run (void *cls, | 259 | run(void *cls, |
249 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 260 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
250 | struct GNUNET_TESTING_Peer *peer) | 261 | struct GNUNET_TESTING_Peer *peer) |
251 | { | 262 | { |
252 | const char *binary_name = cls; | 263 | const char *binary_name = cls; |
253 | const char *keywords[] = { | 264 | const char *keywords[] = { |
@@ -262,89 +273,89 @@ run (void *cls, | |||
262 | struct GNUNET_FS_BlockOptions bo; | 273 | struct GNUNET_FS_BlockOptions bo; |
263 | 274 | ||
264 | if (GNUNET_YES == | 275 | if (GNUNET_YES == |
265 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | 276 | GNUNET_CONFIGURATION_get_value_yesno(cfg, |
266 | "download-test", | 277 | "download-test", |
267 | "USE_STREAM")) | 278 | "USE_STREAM")) |
268 | anonymity_level = 0; | 279 | anonymity_level = 0; |
269 | else | 280 | else |
270 | anonymity_level = 1; | 281 | anonymity_level = 1; |
271 | fs = GNUNET_FS_start (cfg, binary_name, &progress_cb, NULL, | 282 | fs = GNUNET_FS_start(cfg, binary_name, &progress_cb, NULL, |
272 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 283 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
273 | GNUNET_assert (NULL != fs); | 284 | GNUNET_assert(NULL != fs); |
274 | buf = GNUNET_malloc (FILESIZE); | 285 | buf = GNUNET_malloc(FILESIZE); |
275 | for (i = 0; i < FILESIZE; i++) | 286 | for (i = 0; i < FILESIZE; i++) |
276 | buf[i] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 256); | 287 | buf[i] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 256); |
277 | meta = GNUNET_CONTAINER_meta_data_create (); | 288 | meta = GNUNET_CONTAINER_meta_data_create(); |
278 | kuri = GNUNET_FS_uri_ksk_create_from_args (2, keywords); | 289 | kuri = GNUNET_FS_uri_ksk_create_from_args(2, keywords); |
279 | bo.content_priority = 42; | 290 | bo.content_priority = 42; |
280 | bo.anonymity_level = anonymity_level; | 291 | bo.anonymity_level = anonymity_level; |
281 | bo.replication_level = 0; | 292 | bo.replication_level = 0; |
282 | bo.expiration_time = GNUNET_TIME_relative_to_absolute (LIFETIME); | 293 | bo.expiration_time = GNUNET_TIME_relative_to_absolute(LIFETIME); |
283 | 294 | ||
284 | if (GNUNET_YES == | 295 | if (GNUNET_YES == |
285 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | 296 | GNUNET_CONFIGURATION_get_value_yesno(cfg, |
286 | "download-test", | 297 | "download-test", |
287 | "USE_INDEX")) | 298 | "USE_INDEX")) |
288 | { | 299 | { |
289 | fn1 = GNUNET_DISK_mktemp ("gnunet-download-indexed-test"); | 300 | fn1 = GNUNET_DISK_mktemp("gnunet-download-indexed-test"); |
290 | GNUNET_assert (FILESIZE == | 301 | GNUNET_assert(FILESIZE == |
291 | GNUNET_DISK_fn_write (fn1, buf, FILESIZE, | 302 | GNUNET_DISK_fn_write(fn1, buf, FILESIZE, |
292 | GNUNET_DISK_PERM_USER_READ | | 303 | GNUNET_DISK_PERM_USER_READ | |
293 | GNUNET_DISK_PERM_USER_WRITE)); | 304 | GNUNET_DISK_PERM_USER_WRITE)); |
294 | GNUNET_free (buf); | 305 | GNUNET_free(buf); |
295 | fi = GNUNET_FS_file_information_create_from_file (fs, "publish-context", fn1, | 306 | fi = GNUNET_FS_file_information_create_from_file(fs, "publish-context", fn1, |
296 | kuri, meta, GNUNET_YES, | 307 | kuri, meta, GNUNET_YES, |
297 | &bo); | 308 | &bo); |
298 | indexed = GNUNET_YES; | 309 | indexed = GNUNET_YES; |
299 | } | 310 | } |
300 | else | 311 | else |
301 | { | 312 | { |
302 | fi = GNUNET_FS_file_information_create_from_data (fs, "publish-context", | 313 | fi = GNUNET_FS_file_information_create_from_data(fs, "publish-context", |
303 | FILESIZE, buf, kuri, meta, | 314 | FILESIZE, buf, kuri, meta, |
304 | GNUNET_NO, &bo); | 315 | GNUNET_NO, &bo); |
305 | /* note: buf will be free'd as part of 'fi' now */ | 316 | /* note: buf will be free'd as part of 'fi' now */ |
306 | indexed = GNUNET_NO; | 317 | indexed = GNUNET_NO; |
307 | } | 318 | } |
308 | GNUNET_FS_uri_destroy (kuri); | 319 | GNUNET_FS_uri_destroy(kuri); |
309 | GNUNET_CONTAINER_meta_data_destroy (meta); | 320 | GNUNET_CONTAINER_meta_data_destroy(meta); |
310 | GNUNET_assert (NULL != fi); | 321 | GNUNET_assert(NULL != fi); |
311 | timeout_kill = | 322 | timeout_kill = |
312 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &timeout_kill_task, NULL); | 323 | GNUNET_SCHEDULER_add_delayed(TIMEOUT, &timeout_kill_task, NULL); |
313 | start = GNUNET_TIME_absolute_get (); | 324 | start = GNUNET_TIME_absolute_get(); |
314 | publish = | 325 | publish = |
315 | GNUNET_FS_publish_start (fs, fi, NULL, NULL, NULL, | 326 | GNUNET_FS_publish_start(fs, fi, NULL, NULL, NULL, |
316 | GNUNET_FS_PUBLISH_OPTION_NONE); | 327 | GNUNET_FS_PUBLISH_OPTION_NONE); |
317 | GNUNET_assert (publish != NULL); | 328 | GNUNET_assert(publish != NULL); |
318 | } | 329 | } |
319 | 330 | ||
320 | 331 | ||
321 | int | 332 | int |
322 | main (int argc, char *argv[]) | 333 | main(int argc, char *argv[]) |
323 | { | 334 | { |
324 | const char *binary_name; | 335 | const char *binary_name; |
325 | const char *config_name; | 336 | const char *config_name; |
326 | 337 | ||
327 | binary_name = "test-fs-download"; | 338 | binary_name = "test-fs-download"; |
328 | config_name = "test_fs_download_data.conf"; | 339 | config_name = "test_fs_download_data.conf"; |
329 | if (NULL != strstr (argv[0], "indexed")) | 340 | if (NULL != strstr(argv[0], "indexed")) |
330 | { | 341 | { |
331 | binary_name = "test-fs-download-indexed"; | 342 | binary_name = "test-fs-download-indexed"; |
332 | config_name = "test_fs_download_indexed.conf"; | 343 | config_name = "test_fs_download_indexed.conf"; |
333 | } | 344 | } |
334 | if (NULL != strstr (argv[0], "cadet")) | 345 | if (NULL != strstr(argv[0], "cadet")) |
335 | { | 346 | { |
336 | binary_name = "test-fs-download-cadet"; | 347 | binary_name = "test-fs-download-cadet"; |
337 | config_name = "test_fs_download_cadet.conf"; | 348 | config_name = "test_fs_download_cadet.conf"; |
338 | } | 349 | } |
339 | if (0 != GNUNET_TESTING_peer_run (binary_name, | 350 | if (0 != GNUNET_TESTING_peer_run(binary_name, |
340 | config_name, | 351 | config_name, |
341 | &run, (void *) binary_name)) | 352 | &run, (void *)binary_name)) |
342 | return 1; | 353 | return 1; |
343 | if (NULL != fn1) | 354 | if (NULL != fn1) |
344 | { | 355 | { |
345 | unlink (fn1); | 356 | unlink(fn1); |
346 | GNUNET_free (fn1); | 357 | GNUNET_free(fn1); |
347 | } | 358 | } |
348 | return err; | 359 | return err; |
349 | } | 360 | } |
350 | 361 | ||