diff options
Diffstat (limited to 'src/fs/gnunet-publish.c')
-rw-r--r-- | src/fs/gnunet-publish.c | 1024 |
1 files changed, 512 insertions, 512 deletions
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 24baa4d38..ff56dac8c 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c | |||
@@ -148,41 +148,41 @@ static struct GNUNET_IDENTITY_Handle *identity; | |||
148 | * @param cls NULL | 148 | * @param cls NULL |
149 | */ | 149 | */ |
150 | static void | 150 | static void |
151 | do_stop_task(void *cls) | 151 | do_stop_task (void *cls) |
152 | { | 152 | { |
153 | struct GNUNET_FS_PublishContext *p; | 153 | struct GNUNET_FS_PublishContext *p; |
154 | 154 | ||
155 | if (NULL != ds) | 155 | if (NULL != ds) |
156 | { | 156 | { |
157 | GNUNET_FS_directory_scan_abort(ds); | 157 | GNUNET_FS_directory_scan_abort (ds); |
158 | ds = NULL; | 158 | ds = NULL; |
159 | } | 159 | } |
160 | if (NULL != identity) | 160 | if (NULL != identity) |
161 | { | 161 | { |
162 | GNUNET_IDENTITY_disconnect(identity); | 162 | GNUNET_IDENTITY_disconnect (identity); |
163 | identity = NULL; | 163 | identity = NULL; |
164 | } | 164 | } |
165 | if (NULL != pc) | 165 | if (NULL != pc) |
166 | { | 166 | { |
167 | p = pc; | 167 | p = pc; |
168 | pc = NULL; | 168 | pc = NULL; |
169 | GNUNET_FS_publish_stop(p); | 169 | GNUNET_FS_publish_stop (p); |
170 | } | 170 | } |
171 | if (NULL != ctx) | 171 | if (NULL != ctx) |
172 | { | 172 | { |
173 | GNUNET_FS_stop(ctx); | 173 | GNUNET_FS_stop (ctx); |
174 | ctx = NULL; | 174 | ctx = NULL; |
175 | } | 175 | } |
176 | if (NULL != meta) | 176 | if (NULL != meta) |
177 | { | 177 | { |
178 | GNUNET_CONTAINER_meta_data_destroy(meta); | 178 | GNUNET_CONTAINER_meta_data_destroy (meta); |
179 | meta = NULL; | 179 | meta = NULL; |
180 | } | 180 | } |
181 | if (NULL != uri) | 181 | if (NULL != uri) |
182 | { | 182 | { |
183 | GNUNET_FS_uri_destroy(uri); | 183 | GNUNET_FS_uri_destroy (uri); |
184 | uri = NULL; | 184 | uri = NULL; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
@@ -200,105 +200,105 @@ do_stop_task(void *cls) | |||
200 | * field in the GNUNET_FS_ProgressInfo struct. | 200 | * field in the GNUNET_FS_ProgressInfo struct. |
201 | */ | 201 | */ |
202 | static void * | 202 | static void * |
203 | progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info) | 203 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) |
204 | { | 204 | { |
205 | const char *s; | 205 | const char *s; |
206 | char *suri; | 206 | char *suri; |
207 | 207 | ||
208 | switch (info->status) | 208 | switch (info->status) |
209 | { | ||
210 | case GNUNET_FS_STATUS_PUBLISH_START: | ||
211 | break; | ||
212 | |||
213 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | ||
214 | if (verbose) | ||
209 | { | 215 | { |
210 | case GNUNET_FS_STATUS_PUBLISH_START: | 216 | s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.eta, |
211 | break; | 217 | GNUNET_YES); |
212 | 218 | fprintf (stdout, | |
213 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 219 | _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"), |
214 | if (verbose) | 220 | info->value.publish.filename, |
215 | { | 221 | (unsigned long long) info->value.publish.completed, |
216 | s = GNUNET_STRINGS_relative_time_to_string(info->value.publish.eta, | 222 | (unsigned long long) info->value.publish.size, |
217 | GNUNET_YES); | 223 | s); |
218 | fprintf(stdout, | ||
219 | _("Publishing `%s' at %llu/%llu (%s remaining)\n"), | ||
220 | info->value.publish.filename, | ||
221 | (unsigned long long)info->value.publish.completed, | ||
222 | (unsigned long long)info->value.publish.size, | ||
223 | s); | ||
224 | } | ||
225 | break; | ||
226 | |||
227 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: | ||
228 | if (verbose) | ||
229 | { | ||
230 | s = GNUNET_STRINGS_relative_time_to_string(info->value.publish.specifics | ||
231 | .progress_directory.eta, | ||
232 | GNUNET_YES); | ||
233 | fprintf(stdout, | ||
234 | _("Publishing `%s' at %llu/%llu (%s remaining)\n"), | ||
235 | info->value.publish.filename, | ||
236 | (unsigned long long) | ||
237 | info->value.publish.specifics.progress_directory.completed, | ||
238 | (unsigned long long) | ||
239 | info->value.publish.specifics.progress_directory.total, | ||
240 | s); | ||
241 | } | ||
242 | break; | ||
243 | |||
244 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | ||
245 | fprintf(stderr, | ||
246 | _("Error publishing: %s.\n"), | ||
247 | info->value.publish.specifics.error.message); | ||
248 | ret = 1; | ||
249 | GNUNET_SCHEDULER_shutdown(); | ||
250 | break; | ||
251 | |||
252 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | ||
253 | fprintf(stdout, | ||
254 | _("Publishing `%s' done.\n"), | ||
255 | info->value.publish.filename); | ||
256 | suri = | ||
257 | GNUNET_FS_uri_to_string(info->value.publish.specifics.completed.chk_uri); | ||
258 | fprintf(stdout, _("URI is `%s'.\n"), suri); | ||
259 | GNUNET_free(suri); | ||
260 | if (NULL != info->value.publish.specifics.completed.sks_uri) | ||
261 | { | ||
262 | suri = GNUNET_FS_uri_to_string( | ||
263 | info->value.publish.specifics.completed.sks_uri); | ||
264 | fprintf(stdout, _("Namespace URI is `%s'.\n"), suri); | ||
265 | GNUNET_free(suri); | ||
266 | } | ||
267 | if (NULL == info->value.publish.pctx) | ||
268 | { | ||
269 | ret = 0; | ||
270 | GNUNET_SCHEDULER_shutdown(); | ||
271 | } | ||
272 | break; | ||
273 | |||
274 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | ||
275 | GNUNET_break(NULL == pc); | ||
276 | return NULL; | ||
277 | |||
278 | case GNUNET_FS_STATUS_UNINDEX_START: | ||
279 | fprintf(stderr, "%s", _("Starting cleanup after abort\n")); | ||
280 | return NULL; | ||
281 | |||
282 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | ||
283 | return NULL; | ||
284 | |||
285 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | ||
286 | fprintf(stderr, "%s", _("Cleanup after abort completed.\n")); | ||
287 | GNUNET_FS_unindex_stop(info->value.unindex.uc); | ||
288 | return NULL; | ||
289 | |||
290 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | ||
291 | fprintf(stderr, "%s", _("Cleanup after abort failed.\n")); | ||
292 | GNUNET_FS_unindex_stop(info->value.unindex.uc); | ||
293 | return NULL; | ||
294 | |||
295 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | ||
296 | return NULL; | ||
297 | |||
298 | default: | ||
299 | fprintf(stderr, _("Unexpected status: %d\n"), info->status); | ||
300 | return NULL; | ||
301 | } | 224 | } |
225 | break; | ||
226 | |||
227 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY: | ||
228 | if (verbose) | ||
229 | { | ||
230 | s = GNUNET_STRINGS_relative_time_to_string (info->value.publish.specifics | ||
231 | .progress_directory.eta, | ||
232 | GNUNET_YES); | ||
233 | fprintf (stdout, | ||
234 | _ ("Publishing `%s' at %llu/%llu (%s remaining)\n"), | ||
235 | info->value.publish.filename, | ||
236 | (unsigned long long) | ||
237 | info->value.publish.specifics.progress_directory.completed, | ||
238 | (unsigned long long) | ||
239 | info->value.publish.specifics.progress_directory.total, | ||
240 | s); | ||
241 | } | ||
242 | break; | ||
243 | |||
244 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | ||
245 | fprintf (stderr, | ||
246 | _ ("Error publishing: %s.\n"), | ||
247 | info->value.publish.specifics.error.message); | ||
248 | ret = 1; | ||
249 | GNUNET_SCHEDULER_shutdown (); | ||
250 | break; | ||
251 | |||
252 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | ||
253 | fprintf (stdout, | ||
254 | _ ("Publishing `%s' done.\n"), | ||
255 | info->value.publish.filename); | ||
256 | suri = | ||
257 | GNUNET_FS_uri_to_string (info->value.publish.specifics.completed.chk_uri); | ||
258 | fprintf (stdout, _ ("URI is `%s'.\n"), suri); | ||
259 | GNUNET_free (suri); | ||
260 | if (NULL != info->value.publish.specifics.completed.sks_uri) | ||
261 | { | ||
262 | suri = GNUNET_FS_uri_to_string ( | ||
263 | info->value.publish.specifics.completed.sks_uri); | ||
264 | fprintf (stdout, _ ("Namespace URI is `%s'.\n"), suri); | ||
265 | GNUNET_free (suri); | ||
266 | } | ||
267 | if (NULL == info->value.publish.pctx) | ||
268 | { | ||
269 | ret = 0; | ||
270 | GNUNET_SCHEDULER_shutdown (); | ||
271 | } | ||
272 | break; | ||
273 | |||
274 | case GNUNET_FS_STATUS_PUBLISH_STOPPED: | ||
275 | GNUNET_break (NULL == pc); | ||
276 | return NULL; | ||
277 | |||
278 | case GNUNET_FS_STATUS_UNINDEX_START: | ||
279 | fprintf (stderr, "%s", _ ("Starting cleanup after abort\n")); | ||
280 | return NULL; | ||
281 | |||
282 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | ||
283 | return NULL; | ||
284 | |||
285 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | ||
286 | fprintf (stderr, "%s", _ ("Cleanup after abort completed.\n")); | ||
287 | GNUNET_FS_unindex_stop (info->value.unindex.uc); | ||
288 | return NULL; | ||
289 | |||
290 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | ||
291 | fprintf (stderr, "%s", _ ("Cleanup after abort failed.\n")); | ||
292 | GNUNET_FS_unindex_stop (info->value.unindex.uc); | ||
293 | return NULL; | ||
294 | |||
295 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | ||
296 | return NULL; | ||
297 | |||
298 | default: | ||
299 | fprintf (stderr, _ ("Unexpected status: %d\n"), info->status); | ||
300 | return NULL; | ||
301 | } | ||
302 | return ""; /* non-null */ | 302 | return ""; /* non-null */ |
303 | } | 303 | } |
304 | 304 | ||
@@ -317,13 +317,13 @@ progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
317 | * @return always 0 | 317 | * @return always 0 |
318 | */ | 318 | */ |
319 | static int | 319 | static int |
320 | meta_printer(void *cls, | 320 | meta_printer (void *cls, |
321 | const char *plugin_name, | 321 | const char *plugin_name, |
322 | enum EXTRACTOR_MetaType type, | 322 | enum EXTRACTOR_MetaType type, |
323 | enum EXTRACTOR_MetaFormat format, | 323 | enum EXTRACTOR_MetaFormat format, |
324 | const char *data_mime_type, | 324 | const char *data_mime_type, |
325 | const char *data, | 325 | const char *data, |
326 | size_t data_size) | 326 | size_t data_size) |
327 | { | 327 | { |
328 | if ((EXTRACTOR_METAFORMAT_UTF8 != format) && | 328 | if ((EXTRACTOR_METAFORMAT_UTF8 != format) && |
329 | (EXTRACTOR_METAFORMAT_C_STRING != format)) | 329 | (EXTRACTOR_METAFORMAT_C_STRING != format)) |
@@ -331,9 +331,9 @@ meta_printer(void *cls, | |||
331 | if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type) | 331 | if (EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME == type) |
332 | return 0; | 332 | return 0; |
333 | #if HAVE_LIBEXTRACTOR | 333 | #if HAVE_LIBEXTRACTOR |
334 | fprintf(stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string(type), data); | 334 | fprintf (stdout, "\t%s - %s\n", EXTRACTOR_metatype_to_string (type), data); |
335 | #else | 335 | #else |
336 | fprintf(stdout, "\t%d - %s\n", type, data); | 336 | fprintf (stdout, "\t%d - %s\n", type, data); |
337 | #endif | 337 | #endif |
338 | return 0; | 338 | return 0; |
339 | } | 339 | } |
@@ -348,9 +348,9 @@ meta_printer(void *cls, | |||
348 | * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort | 348 | * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort |
349 | */ | 349 | */ |
350 | static int | 350 | static int |
351 | keyword_printer(void *cls, const char *keyword, int is_mandatory) | 351 | keyword_printer (void *cls, const char *keyword, int is_mandatory) |
352 | { | 352 | { |
353 | fprintf(stdout, "\t%s\n", keyword); | 353 | fprintf (stdout, "\t%s\n", keyword); |
354 | return GNUNET_OK; | 354 | return GNUNET_OK; |
355 | } | 355 | } |
356 | 356 | ||
@@ -373,14 +373,14 @@ keyword_printer(void *cls, const char *keyword, int is_mandatory) | |||
373 | * to abort the iteration | 373 | * to abort the iteration |
374 | */ | 374 | */ |
375 | static int | 375 | static int |
376 | publish_inspector(void *cls, | 376 | publish_inspector (void *cls, |
377 | struct GNUNET_FS_FileInformation *fi, | 377 | struct GNUNET_FS_FileInformation *fi, |
378 | uint64_t length, | 378 | uint64_t length, |
379 | struct GNUNET_CONTAINER_MetaData *m, | 379 | struct GNUNET_CONTAINER_MetaData *m, |
380 | struct GNUNET_FS_Uri **uri, | 380 | struct GNUNET_FS_Uri **uri, |
381 | struct GNUNET_FS_BlockOptions *bo, | 381 | struct GNUNET_FS_BlockOptions *bo, |
382 | int *do_index, | 382 | int *do_index, |
383 | void **client_info) | 383 | void **client_info) |
384 | { | 384 | { |
385 | char *fn; | 385 | char *fn; |
386 | char *fs; | 386 | char *fs; |
@@ -389,50 +389,50 @@ publish_inspector(void *cls, | |||
389 | if (cls == fi) | 389 | if (cls == fi) |
390 | return GNUNET_OK; | 390 | return GNUNET_OK; |
391 | if ((disable_extractor) && (NULL != *uri)) | 391 | if ((disable_extractor) && (NULL != *uri)) |
392 | { | 392 | { |
393 | GNUNET_FS_uri_destroy(*uri); | 393 | GNUNET_FS_uri_destroy (*uri); |
394 | *uri = NULL; | 394 | *uri = NULL; |
395 | } | 395 | } |
396 | if (NULL != topKeywords) | 396 | if (NULL != topKeywords) |
397 | { | ||
398 | if (NULL != *uri) | ||
397 | { | 399 | { |
398 | if (NULL != *uri) | 400 | new_uri = GNUNET_FS_uri_ksk_merge (topKeywords, *uri); |
399 | { | 401 | GNUNET_FS_uri_destroy (*uri); |
400 | new_uri = GNUNET_FS_uri_ksk_merge(topKeywords, *uri); | 402 | *uri = new_uri; |
401 | GNUNET_FS_uri_destroy(*uri); | 403 | GNUNET_FS_uri_destroy (topKeywords); |
402 | *uri = new_uri; | ||
403 | GNUNET_FS_uri_destroy(topKeywords); | ||
404 | } | ||
405 | else | ||
406 | { | ||
407 | *uri = topKeywords; | ||
408 | } | ||
409 | topKeywords = NULL; | ||
410 | } | 404 | } |
411 | if (NULL != meta) | 405 | else |
412 | { | 406 | { |
413 | GNUNET_CONTAINER_meta_data_merge(m, meta); | 407 | *uri = topKeywords; |
414 | GNUNET_CONTAINER_meta_data_destroy(meta); | ||
415 | meta = NULL; | ||
416 | } | 408 | } |
409 | topKeywords = NULL; | ||
410 | } | ||
411 | if (NULL != meta) | ||
412 | { | ||
413 | GNUNET_CONTAINER_meta_data_merge (m, meta); | ||
414 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
415 | meta = NULL; | ||
416 | } | ||
417 | if (enable_creation_time) | 417 | if (enable_creation_time) |
418 | GNUNET_CONTAINER_meta_data_add_publication_date(m); | 418 | GNUNET_CONTAINER_meta_data_add_publication_date (m); |
419 | if (extract_only) | 419 | if (extract_only) |
420 | { | 420 | { |
421 | fn = GNUNET_CONTAINER_meta_data_get_by_type( | 421 | fn = GNUNET_CONTAINER_meta_data_get_by_type ( |
422 | m, | 422 | m, |
423 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); | 423 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); |
424 | fs = GNUNET_STRINGS_byte_size_fancy(length); | 424 | fs = GNUNET_STRINGS_byte_size_fancy (length); |
425 | fprintf(stdout, _("Meta data for file `%s' (%s)\n"), fn, fs); | 425 | fprintf (stdout, _ ("Meta data for file `%s' (%s)\n"), fn, fs); |
426 | GNUNET_CONTAINER_meta_data_iterate(m, &meta_printer, NULL); | 426 | GNUNET_CONTAINER_meta_data_iterate (m, &meta_printer, NULL); |
427 | fprintf(stdout, _("Keywords for file `%s' (%s)\n"), fn, fs); | 427 | fprintf (stdout, _ ("Keywords for file `%s' (%s)\n"), fn, fs); |
428 | GNUNET_free(fn); | 428 | GNUNET_free (fn); |
429 | GNUNET_free(fs); | 429 | GNUNET_free (fs); |
430 | if (NULL != *uri) | 430 | if (NULL != *uri) |
431 | GNUNET_FS_uri_ksk_get_keywords(*uri, &keyword_printer, NULL); | 431 | GNUNET_FS_uri_ksk_get_keywords (*uri, &keyword_printer, NULL); |
432 | fprintf(stdout, "%s", "\n"); | 432 | fprintf (stdout, "%s", "\n"); |
433 | } | 433 | } |
434 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory(m)) | 434 | if (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (m)) |
435 | GNUNET_FS_file_information_inspect(fi, &publish_inspector, fi); | 435 | GNUNET_FS_file_information_inspect (fi, &publish_inspector, fi); |
436 | return GNUNET_OK; | 436 | return GNUNET_OK; |
437 | } | 437 | } |
438 | 438 | ||
@@ -447,16 +447,16 @@ publish_inspector(void *cls, | |||
447 | * @param emsg error message, NULL on success | 447 | * @param emsg error message, NULL on success |
448 | */ | 448 | */ |
449 | static void | 449 | static void |
450 | uri_sks_continuation(void *cls, | 450 | uri_sks_continuation (void *cls, |
451 | const struct GNUNET_FS_Uri *sks_uri, | 451 | const struct GNUNET_FS_Uri *sks_uri, |
452 | const char *emsg) | 452 | const char *emsg) |
453 | { | 453 | { |
454 | if (NULL != emsg) | 454 | if (NULL != emsg) |
455 | { | 455 | { |
456 | fprintf(stderr, "%s\n", emsg); | 456 | fprintf (stderr, "%s\n", emsg); |
457 | ret = 1; | 457 | ret = 1; |
458 | } | 458 | } |
459 | GNUNET_SCHEDULER_shutdown(); | 459 | GNUNET_SCHEDULER_shutdown (); |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
@@ -470,33 +470,33 @@ uri_sks_continuation(void *cls, | |||
470 | * @param emsg error message, NULL on success | 470 | * @param emsg error message, NULL on success |
471 | */ | 471 | */ |
472 | static void | 472 | static void |
473 | uri_ksk_continuation(void *cls, | 473 | uri_ksk_continuation (void *cls, |
474 | const struct GNUNET_FS_Uri *ksk_uri, | 474 | const struct GNUNET_FS_Uri *ksk_uri, |
475 | const char *emsg) | 475 | const char *emsg) |
476 | { | 476 | { |
477 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; | 477 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; |
478 | 478 | ||
479 | if (NULL != emsg) | 479 | if (NULL != emsg) |
480 | { | 480 | { |
481 | fprintf(stderr, "%s\n", emsg); | 481 | fprintf (stderr, "%s\n", emsg); |
482 | ret = 1; | 482 | ret = 1; |
483 | } | 483 | } |
484 | if (NULL == namespace) | 484 | if (NULL == namespace) |
485 | { | 485 | { |
486 | GNUNET_SCHEDULER_shutdown(); | 486 | GNUNET_SCHEDULER_shutdown (); |
487 | return; | 487 | return; |
488 | } | 488 | } |
489 | priv = GNUNET_IDENTITY_ego_get_private_key(namespace); | 489 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); |
490 | GNUNET_FS_publish_sks(ctx, | 490 | GNUNET_FS_publish_sks (ctx, |
491 | priv, | 491 | priv, |
492 | this_id, | 492 | this_id, |
493 | next_id, | 493 | next_id, |
494 | meta, | 494 | meta, |
495 | uri, | 495 | uri, |
496 | &bo, | 496 | &bo, |
497 | GNUNET_FS_PUBLISH_OPTION_NONE, | 497 | GNUNET_FS_PUBLISH_OPTION_NONE, |
498 | &uri_sks_continuation, | 498 | &uri_sks_continuation, |
499 | NULL); | 499 | NULL); |
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
@@ -508,52 +508,52 @@ uri_ksk_continuation(void *cls, | |||
508 | * @return handle with the information for the publishing operation | 508 | * @return handle with the information for the publishing operation |
509 | */ | 509 | */ |
510 | static struct GNUNET_FS_FileInformation * | 510 | static struct GNUNET_FS_FileInformation * |
511 | get_file_information(struct GNUNET_FS_ShareTreeItem *item) | 511 | get_file_information (struct GNUNET_FS_ShareTreeItem *item) |
512 | { | 512 | { |
513 | struct GNUNET_FS_FileInformation *fi; | 513 | struct GNUNET_FS_FileInformation *fi; |
514 | struct GNUNET_FS_FileInformation *fic; | 514 | struct GNUNET_FS_FileInformation *fic; |
515 | struct GNUNET_FS_ShareTreeItem *child; | 515 | struct GNUNET_FS_ShareTreeItem *child; |
516 | 516 | ||
517 | if (GNUNET_YES == item->is_directory) | 517 | if (GNUNET_YES == item->is_directory) |
518 | { | ||
519 | if (NULL == item->meta) | ||
520 | item->meta = GNUNET_CONTAINER_meta_data_create (); | ||
521 | GNUNET_CONTAINER_meta_data_delete (item->meta, | ||
522 | EXTRACTOR_METATYPE_MIMETYPE, | ||
523 | NULL, | ||
524 | 0); | ||
525 | GNUNET_FS_meta_data_make_directory (item->meta); | ||
526 | if (NULL == item->ksk_uri) | ||
518 | { | 527 | { |
519 | if (NULL == item->meta) | 528 | const char *mime = GNUNET_FS_DIRECTORY_MIME; |
520 | item->meta = GNUNET_CONTAINER_meta_data_create(); | 529 | item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, &mime); |
521 | GNUNET_CONTAINER_meta_data_delete(item->meta, | ||
522 | EXTRACTOR_METATYPE_MIMETYPE, | ||
523 | NULL, | ||
524 | 0); | ||
525 | GNUNET_FS_meta_data_make_directory(item->meta); | ||
526 | if (NULL == item->ksk_uri) | ||
527 | { | ||
528 | const char *mime = GNUNET_FS_DIRECTORY_MIME; | ||
529 | item->ksk_uri = GNUNET_FS_uri_ksk_create_from_args(1, &mime); | ||
530 | } | ||
531 | else | ||
532 | GNUNET_FS_uri_ksk_add_keyword(item->ksk_uri, | ||
533 | GNUNET_FS_DIRECTORY_MIME, | ||
534 | GNUNET_NO); | ||
535 | fi = GNUNET_FS_file_information_create_empty_directory(ctx, | ||
536 | NULL, | ||
537 | item->ksk_uri, | ||
538 | item->meta, | ||
539 | &bo, | ||
540 | item->filename); | ||
541 | for (child = item->children_head; child; child = child->next) | ||
542 | { | ||
543 | fic = get_file_information(child); | ||
544 | GNUNET_break(GNUNET_OK == GNUNET_FS_file_information_add(fi, fic)); | ||
545 | } | ||
546 | } | 530 | } |
547 | else | 531 | else |
532 | GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, | ||
533 | GNUNET_FS_DIRECTORY_MIME, | ||
534 | GNUNET_NO); | ||
535 | fi = GNUNET_FS_file_information_create_empty_directory (ctx, | ||
536 | NULL, | ||
537 | item->ksk_uri, | ||
538 | item->meta, | ||
539 | &bo, | ||
540 | item->filename); | ||
541 | for (child = item->children_head; child; child = child->next) | ||
548 | { | 542 | { |
549 | fi = GNUNET_FS_file_information_create_from_file(ctx, | 543 | fic = get_file_information (child); |
550 | NULL, | 544 | GNUNET_break (GNUNET_OK == GNUNET_FS_file_information_add (fi, fic)); |
551 | item->filename, | ||
552 | item->ksk_uri, | ||
553 | item->meta, | ||
554 | !do_insert, | ||
555 | &bo); | ||
556 | } | 545 | } |
546 | } | ||
547 | else | ||
548 | { | ||
549 | fi = GNUNET_FS_file_information_create_from_file (ctx, | ||
550 | NULL, | ||
551 | item->filename, | ||
552 | item->ksk_uri, | ||
553 | item->meta, | ||
554 | ! do_insert, | ||
555 | &bo); | ||
556 | } | ||
557 | return fi; | 557 | return fi; |
558 | } | 558 | } |
559 | 559 | ||
@@ -565,46 +565,46 @@ get_file_information(struct GNUNET_FS_ShareTreeItem *item) | |||
565 | * @param directory_scan_result result from the directory scan, freed in this function | 565 | * @param directory_scan_result result from the directory scan, freed in this function |
566 | */ | 566 | */ |
567 | static void | 567 | static void |
568 | directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result) | 568 | directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) |
569 | { | 569 | { |
570 | struct GNUNET_FS_FileInformation *fi; | 570 | struct GNUNET_FS_FileInformation *fi; |
571 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; | 571 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; |
572 | 572 | ||
573 | fi = get_file_information(directory_scan_result); | 573 | fi = get_file_information (directory_scan_result); |
574 | GNUNET_FS_share_tree_free(directory_scan_result); | 574 | GNUNET_FS_share_tree_free (directory_scan_result); |
575 | if (NULL == fi) | 575 | if (NULL == fi) |
576 | { | 576 | { |
577 | fprintf(stderr, "%s", _("Could not publish\n")); | 577 | fprintf (stderr, "%s", _ ("Could not publish\n")); |
578 | ret = 1; | 578 | ret = 1; |
579 | GNUNET_SCHEDULER_shutdown(); | 579 | GNUNET_SCHEDULER_shutdown (); |
580 | return; | 580 | return; |
581 | } | 581 | } |
582 | GNUNET_FS_file_information_inspect(fi, &publish_inspector, NULL); | 582 | GNUNET_FS_file_information_inspect (fi, &publish_inspector, NULL); |
583 | if (extract_only) | 583 | if (extract_only) |
584 | { | 584 | { |
585 | GNUNET_FS_file_information_destroy(fi, NULL, NULL); | 585 | GNUNET_FS_file_information_destroy (fi, NULL, NULL); |
586 | GNUNET_SCHEDULER_shutdown(); | 586 | GNUNET_SCHEDULER_shutdown (); |
587 | return; | 587 | return; |
588 | } | 588 | } |
589 | if (NULL == namespace) | 589 | if (NULL == namespace) |
590 | priv = NULL; | 590 | priv = NULL; |
591 | else | 591 | else |
592 | priv = GNUNET_IDENTITY_ego_get_private_key(namespace); | 592 | priv = GNUNET_IDENTITY_ego_get_private_key (namespace); |
593 | pc = GNUNET_FS_publish_start(ctx, | 593 | pc = GNUNET_FS_publish_start (ctx, |
594 | fi, | 594 | fi, |
595 | priv, | 595 | priv, |
596 | this_id, | 596 | this_id, |
597 | next_id, | 597 | next_id, |
598 | (do_simulate) | 598 | (do_simulate) |
599 | ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY | 599 | ? GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY |
600 | : GNUNET_FS_PUBLISH_OPTION_NONE); | 600 | : GNUNET_FS_PUBLISH_OPTION_NONE); |
601 | if (NULL == pc) | 601 | if (NULL == pc) |
602 | { | 602 | { |
603 | fprintf(stderr, "%s", _("Could not start publishing.\n")); | 603 | fprintf (stderr, "%s", _ ("Could not start publishing.\n")); |
604 | ret = 1; | 604 | ret = 1; |
605 | GNUNET_SCHEDULER_shutdown(); | 605 | GNUNET_SCHEDULER_shutdown (); |
606 | return; | 606 | return; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | 609 | ||
610 | 610 | ||
@@ -620,63 +620,63 @@ directory_trim_complete(struct GNUNET_FS_ShareTreeItem *directory_scan_result) | |||
620 | * @param reason kind of progress we are making | 620 | * @param reason kind of progress we are making |
621 | */ | 621 | */ |
622 | static void | 622 | static void |
623 | directory_scan_cb(void *cls, | 623 | directory_scan_cb (void *cls, |
624 | const char *filename, | 624 | const char *filename, |
625 | int is_directory, | 625 | int is_directory, |
626 | enum GNUNET_FS_DirScannerProgressUpdateReason reason) | 626 | enum GNUNET_FS_DirScannerProgressUpdateReason reason) |
627 | { | 627 | { |
628 | struct GNUNET_FS_ShareTreeItem *directory_scan_result; | 628 | struct GNUNET_FS_ShareTreeItem *directory_scan_result; |
629 | 629 | ||
630 | switch (reason) | 630 | switch (reason) |
631 | { | ||
632 | case GNUNET_FS_DIRSCANNER_FILE_START: | ||
633 | if (verbose > 1) | ||
631 | { | 634 | { |
632 | case GNUNET_FS_DIRSCANNER_FILE_START: | 635 | if (is_directory == GNUNET_YES) |
633 | if (verbose > 1) | 636 | fprintf (stdout, _ ("Scanning directory `%s'.\n"), filename); |
634 | { | 637 | else |
635 | if (is_directory == GNUNET_YES) | 638 | fprintf (stdout, _ ("Scanning file `%s'.\n"), filename); |
636 | fprintf(stdout, _("Scanning directory `%s'.\n"), filename); | ||
637 | else | ||
638 | fprintf(stdout, _("Scanning file `%s'.\n"), filename); | ||
639 | } | ||
640 | break; | ||
641 | |||
642 | case GNUNET_FS_DIRSCANNER_FILE_IGNORED: | ||
643 | fprintf(stderr, | ||
644 | _("There was trouble processing file `%s', skipping it.\n"), | ||
645 | filename); | ||
646 | break; | ||
647 | |||
648 | case GNUNET_FS_DIRSCANNER_ALL_COUNTED: | ||
649 | if (verbose) | ||
650 | fprintf(stdout, "%s", _("Preprocessing complete.\n")); | ||
651 | break; | ||
652 | |||
653 | case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: | ||
654 | if (verbose > 2) | ||
655 | fprintf(stdout, | ||
656 | _("Extracting meta data from file `%s' complete.\n"), | ||
657 | filename); | ||
658 | break; | ||
659 | |||
660 | case GNUNET_FS_DIRSCANNER_FINISHED: | ||
661 | if (verbose > 1) | ||
662 | fprintf(stdout, "%s", _("Meta data extraction has finished.\n")); | ||
663 | directory_scan_result = GNUNET_FS_directory_scan_get_result(ds); | ||
664 | ds = NULL; | ||
665 | GNUNET_FS_share_tree_trim(directory_scan_result); | ||
666 | directory_trim_complete(directory_scan_result); | ||
667 | break; | ||
668 | |||
669 | case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: | ||
670 | fprintf(stdout, "%s", _("Error scanning directory.\n")); | ||
671 | ret = 1; | ||
672 | GNUNET_SCHEDULER_shutdown(); | ||
673 | break; | ||
674 | |||
675 | default: | ||
676 | GNUNET_assert(0); | ||
677 | break; | ||
678 | } | 639 | } |
679 | fflush(stdout); | 640 | break; |
641 | |||
642 | case GNUNET_FS_DIRSCANNER_FILE_IGNORED: | ||
643 | fprintf (stderr, | ||
644 | _ ("There was trouble processing file `%s', skipping it.\n"), | ||
645 | filename); | ||
646 | break; | ||
647 | |||
648 | case GNUNET_FS_DIRSCANNER_ALL_COUNTED: | ||
649 | if (verbose) | ||
650 | fprintf (stdout, "%s", _ ("Preprocessing complete.\n")); | ||
651 | break; | ||
652 | |||
653 | case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: | ||
654 | if (verbose > 2) | ||
655 | fprintf (stdout, | ||
656 | _ ("Extracting meta data from file `%s' complete.\n"), | ||
657 | filename); | ||
658 | break; | ||
659 | |||
660 | case GNUNET_FS_DIRSCANNER_FINISHED: | ||
661 | if (verbose > 1) | ||
662 | fprintf (stdout, "%s", _ ("Meta data extraction has finished.\n")); | ||
663 | directory_scan_result = GNUNET_FS_directory_scan_get_result (ds); | ||
664 | ds = NULL; | ||
665 | GNUNET_FS_share_tree_trim (directory_scan_result); | ||
666 | directory_trim_complete (directory_scan_result); | ||
667 | break; | ||
668 | |||
669 | case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: | ||
670 | fprintf (stdout, "%s", _ ("Error scanning directory.\n")); | ||
671 | ret = 1; | ||
672 | GNUNET_SCHEDULER_shutdown (); | ||
673 | break; | ||
674 | |||
675 | default: | ||
676 | GNUNET_assert (0); | ||
677 | break; | ||
678 | } | ||
679 | fflush (stdout); | ||
680 | } | 680 | } |
681 | 681 | ||
682 | 682 | ||
@@ -687,67 +687,67 @@ directory_scan_cb(void *cls, | |||
687 | * @param args0 filename to publish | 687 | * @param args0 filename to publish |
688 | */ | 688 | */ |
689 | static void | 689 | static void |
690 | identity_continuation(const char *args0) | 690 | identity_continuation (const char *args0) |
691 | { | 691 | { |
692 | char *ex; | 692 | char *ex; |
693 | char *emsg; | 693 | char *emsg; |
694 | 694 | ||
695 | if ((NULL != pseudonym) && (NULL == namespace)) | 695 | if ((NULL != pseudonym) && (NULL == namespace)) |
696 | { | 696 | { |
697 | fprintf(stderr, _("Selected pseudonym `%s' unknown\n"), pseudonym); | 697 | fprintf (stderr, _ ("Selected pseudonym `%s' unknown\n"), pseudonym); |
698 | ret = 1; | 698 | ret = 1; |
699 | GNUNET_SCHEDULER_shutdown(); | 699 | GNUNET_SCHEDULER_shutdown (); |
700 | return; | 700 | return; |
701 | } | 701 | } |
702 | if (NULL != uri_string) | 702 | if (NULL != uri_string) |
703 | { | ||
704 | emsg = NULL; | ||
705 | if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg))) | ||
703 | { | 706 | { |
704 | emsg = NULL; | 707 | fprintf (stderr, _ ("Failed to parse URI: %s\n"), emsg); |
705 | if (NULL == (uri = GNUNET_FS_uri_parse(uri_string, &emsg))) | 708 | GNUNET_free (emsg); |
706 | { | 709 | ret = 1; |
707 | fprintf(stderr, _("Failed to parse URI: %s\n"), emsg); | 710 | GNUNET_SCHEDULER_shutdown (); |
708 | GNUNET_free(emsg); | ||
709 | ret = 1; | ||
710 | GNUNET_SCHEDULER_shutdown(); | ||
711 | return; | ||
712 | } | ||
713 | GNUNET_FS_publish_ksk(ctx, | ||
714 | topKeywords, | ||
715 | meta, | ||
716 | uri, | ||
717 | &bo, | ||
718 | GNUNET_FS_PUBLISH_OPTION_NONE, | ||
719 | &uri_ksk_continuation, | ||
720 | NULL); | ||
721 | return; | 711 | return; |
722 | } | 712 | } |
713 | GNUNET_FS_publish_ksk (ctx, | ||
714 | topKeywords, | ||
715 | meta, | ||
716 | uri, | ||
717 | &bo, | ||
718 | GNUNET_FS_PUBLISH_OPTION_NONE, | ||
719 | &uri_ksk_continuation, | ||
720 | NULL); | ||
721 | return; | ||
722 | } | ||
723 | if (GNUNET_OK != | 723 | if (GNUNET_OK != |
724 | GNUNET_CONFIGURATION_get_value_string(cfg, "FS", "EXTRACTORS", &ex)) | 724 | GNUNET_CONFIGURATION_get_value_string (cfg, "FS", "EXTRACTORS", &ex)) |
725 | ex = NULL; | 725 | ex = NULL; |
726 | if (0 != access(args0, R_OK)) | 726 | if (0 != access (args0, R_OK)) |
727 | { | 727 | { |
728 | fprintf(stderr, | 728 | fprintf (stderr, |
729 | _("Failed to access `%s': %s\n"), | 729 | _ ("Failed to access `%s': %s\n"), |
730 | args0, | 730 | args0, |
731 | strerror(errno)); | 731 | strerror (errno)); |
732 | GNUNET_free_non_null(ex); | 732 | GNUNET_free_non_null (ex); |
733 | return; | 733 | return; |
734 | } | 734 | } |
735 | ds = GNUNET_FS_directory_scan_start(args0, | 735 | ds = GNUNET_FS_directory_scan_start (args0, |
736 | disable_extractor, | 736 | disable_extractor, |
737 | ex, | 737 | ex, |
738 | &directory_scan_cb, | 738 | &directory_scan_cb, |
739 | NULL); | 739 | NULL); |
740 | if (NULL == ds) | 740 | if (NULL == ds) |
741 | { | 741 | { |
742 | fprintf( | 742 | fprintf ( |
743 | stderr, | 743 | stderr, |
744 | "%s", | 744 | "%s", |
745 | _( | 745 | _ ( |
746 | "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n")); | 746 | "Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n")); |
747 | GNUNET_free_non_null(ex); | 747 | GNUNET_free_non_null (ex); |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | GNUNET_free_non_null(ex); | 750 | GNUNET_free_non_null (ex); |
751 | } | 751 | } |
752 | 752 | ||
753 | 753 | ||
@@ -763,21 +763,21 @@ identity_continuation(const char *args0) | |||
763 | * must thus no longer be used | 763 | * must thus no longer be used |
764 | */ | 764 | */ |
765 | static void | 765 | static void |
766 | identity_cb(void *cls, | 766 | identity_cb (void *cls, |
767 | struct GNUNET_IDENTITY_Ego *ego, | 767 | struct GNUNET_IDENTITY_Ego *ego, |
768 | void **ctx, | 768 | void **ctx, |
769 | const char *name) | 769 | const char *name) |
770 | { | 770 | { |
771 | const char *args0 = cls; | 771 | const char *args0 = cls; |
772 | 772 | ||
773 | if (NULL == ego) | 773 | if (NULL == ego) |
774 | { | 774 | { |
775 | identity_continuation(args0); | 775 | identity_continuation (args0); |
776 | return; | 776 | return; |
777 | } | 777 | } |
778 | if (NULL == name) | 778 | if (NULL == name) |
779 | return; | 779 | return; |
780 | if (0 == strcmp(name, pseudonym)) | 780 | if (0 == strcmp (name, pseudonym)) |
781 | namespace = ego; | 781 | namespace = ego; |
782 | } | 782 | } |
783 | 783 | ||
@@ -791,82 +791,82 @@ identity_cb(void *cls, | |||
791 | * @param c configuration | 791 | * @param c configuration |
792 | */ | 792 | */ |
793 | static void | 793 | static void |
794 | run(void *cls, | 794 | run (void *cls, |
795 | char *const *args, | 795 | char *const *args, |
796 | const char *cfgfile, | 796 | const char *cfgfile, |
797 | const struct GNUNET_CONFIGURATION_Handle *c) | 797 | const struct GNUNET_CONFIGURATION_Handle *c) |
798 | { | 798 | { |
799 | /* check arguments */ | 799 | /* check arguments */ |
800 | if ((NULL != uri_string) && (extract_only)) | 800 | if ((NULL != uri_string) && (extract_only)) |
801 | { | 801 | { |
802 | printf(_("Cannot extract metadata from a URI!\n")); | 802 | printf (_ ("Cannot extract metadata from a URI!\n")); |
803 | ret = -1; | 803 | ret = -1; |
804 | return; | 804 | return; |
805 | } | 805 | } |
806 | if (((NULL == uri_string) || (extract_only)) && | 806 | if (((NULL == uri_string) || (extract_only)) && |
807 | ((NULL == args[0]) || (NULL != args[1]))) | 807 | ((NULL == args[0]) || (NULL != args[1]))) |
808 | { | ||
809 | printf (_ ("You must specify one and only one filename for insertion.\n")); | ||
810 | ret = -1; | ||
811 | return; | ||
812 | } | ||
813 | if ((NULL != uri_string) && (NULL != args[0])) | ||
814 | { | ||
815 | printf (_ ("You must NOT specify an URI and a filename.\n")); | ||
816 | ret = -1; | ||
817 | return; | ||
818 | } | ||
819 | if (NULL != pseudonym) | ||
820 | { | ||
821 | if (NULL == this_id) | ||
808 | { | 822 | { |
809 | printf(_("You must specify one and only one filename for insertion.\n")); | 823 | fprintf (stderr, |
824 | _ ("Option `%s' is required when using option `%s'.\n"), | ||
825 | "-t", | ||
826 | "-P"); | ||
810 | ret = -1; | 827 | ret = -1; |
811 | return; | 828 | return; |
812 | } | 829 | } |
813 | if ((NULL != uri_string) && (NULL != args[0])) | 830 | } |
831 | else | ||
832 | { /* ordinary insertion checks */ | ||
833 | if (NULL != next_id) | ||
814 | { | 834 | { |
815 | printf(_("You must NOT specify an URI and a filename.\n")); | 835 | fprintf (stderr, |
836 | _ ("Option `%s' makes no sense without option `%s'.\n"), | ||
837 | "-N", | ||
838 | "-P"); | ||
816 | ret = -1; | 839 | ret = -1; |
817 | return; | 840 | return; |
818 | } | 841 | } |
819 | if (NULL != pseudonym) | 842 | if (NULL != this_id) |
820 | { | 843 | { |
821 | if (NULL == this_id) | 844 | fprintf (stderr, |
822 | { | 845 | _ ("Option `%s' makes no sense without option `%s'.\n"), |
823 | fprintf(stderr, | 846 | "-t", |
824 | _("Option `%s' is required when using option `%s'.\n"), | 847 | "-P"); |
825 | "-t", | 848 | ret = -1; |
826 | "-P"); | 849 | return; |
827 | ret = -1; | ||
828 | return; | ||
829 | } | ||
830 | } | ||
831 | else | ||
832 | { /* ordinary insertion checks */ | ||
833 | if (NULL != next_id) | ||
834 | { | ||
835 | fprintf(stderr, | ||
836 | _("Option `%s' makes no sense without option `%s'.\n"), | ||
837 | "-N", | ||
838 | "-P"); | ||
839 | ret = -1; | ||
840 | return; | ||
841 | } | ||
842 | if (NULL != this_id) | ||
843 | { | ||
844 | fprintf(stderr, | ||
845 | _("Option `%s' makes no sense without option `%s'.\n"), | ||
846 | "-t", | ||
847 | "-P"); | ||
848 | ret = -1; | ||
849 | return; | ||
850 | } | ||
851 | } | 850 | } |
851 | } | ||
852 | cfg = c; | 852 | cfg = c; |
853 | ctx = GNUNET_FS_start(cfg, | 853 | ctx = GNUNET_FS_start (cfg, |
854 | "gnunet-publish", | 854 | "gnunet-publish", |
855 | &progress_cb, | 855 | &progress_cb, |
856 | NULL, | 856 | NULL, |
857 | GNUNET_FS_FLAGS_NONE, | 857 | GNUNET_FS_FLAGS_NONE, |
858 | GNUNET_FS_OPTIONS_END); | 858 | GNUNET_FS_OPTIONS_END); |
859 | if (NULL == ctx) | 859 | if (NULL == ctx) |
860 | { | 860 | { |
861 | fprintf(stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); | 861 | fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS"); |
862 | ret = 1; | 862 | ret = 1; |
863 | return; | 863 | return; |
864 | } | 864 | } |
865 | GNUNET_SCHEDULER_add_shutdown(&do_stop_task, NULL); | 865 | GNUNET_SCHEDULER_add_shutdown (&do_stop_task, NULL); |
866 | if (NULL != pseudonym) | 866 | if (NULL != pseudonym) |
867 | identity = GNUNET_IDENTITY_connect(cfg, &identity_cb, args[0]); | 867 | identity = GNUNET_IDENTITY_connect (cfg, &identity_cb, args[0]); |
868 | else | 868 | else |
869 | identity_continuation(args[0]); | 869 | identity_continuation (args[0]); |
870 | } | 870 | } |
871 | 871 | ||
872 | 872 | ||
@@ -878,121 +878,121 @@ run(void *cls, | |||
878 | * @return 0 ok, 1 on error | 878 | * @return 0 ok, 1 on error |
879 | */ | 879 | */ |
880 | int | 880 | int |
881 | main(int argc, char *const *argv) | 881 | main (int argc, char *const *argv) |
882 | { | 882 | { |
883 | struct GNUNET_GETOPT_CommandLineOption options[] = | 883 | struct GNUNET_GETOPT_CommandLineOption options[] = |
884 | { GNUNET_GETOPT_option_uint('a', | 884 | { GNUNET_GETOPT_option_uint ('a', |
885 | "anonymity", | 885 | "anonymity", |
886 | "LEVEL", | 886 | "LEVEL", |
887 | gettext_noop( | 887 | gettext_noop ( |
888 | "set the desired LEVEL of sender-anonymity"), | 888 | "set the desired LEVEL of sender-anonymity"), |
889 | &bo.anonymity_level), | 889 | &bo.anonymity_level), |
890 | GNUNET_GETOPT_option_flag( | 890 | GNUNET_GETOPT_option_flag ( |
891 | 'D', | 891 | 'D', |
892 | "disable-extractor", | 892 | "disable-extractor", |
893 | gettext_noop("do not use libextractor to add keywords or metadata"), | 893 | gettext_noop ("do not use libextractor to add keywords or metadata"), |
894 | &disable_extractor), | 894 | &disable_extractor), |
895 | GNUNET_GETOPT_option_flag('E', | 895 | GNUNET_GETOPT_option_flag ('E', |
896 | "enable-creation-time", | 896 | "enable-creation-time", |
897 | gettext_noop( | 897 | gettext_noop ( |
898 | "enable adding the creation time to the " | 898 | "enable adding the creation time to the " |
899 | "metadata of the uploaded file"), | 899 | "metadata of the uploaded file"), |
900 | &enable_creation_time), | 900 | &enable_creation_time), |
901 | GNUNET_GETOPT_option_flag('e', | 901 | GNUNET_GETOPT_option_flag ('e', |
902 | "extract", | 902 | "extract", |
903 | gettext_noop( | 903 | gettext_noop ( |
904 | "print list of extracted keywords that would " | 904 | "print list of extracted keywords that would " |
905 | "be used, but do not perform upload"), | 905 | "be used, but do not perform upload"), |
906 | &extract_only), | 906 | &extract_only), |
907 | GNUNET_FS_GETOPT_KEYWORDS( | 907 | GNUNET_FS_GETOPT_KEYWORDS ( |
908 | 'k', | 908 | 'k', |
909 | "key", | 909 | "key", |
910 | "KEYWORD", | 910 | "KEYWORD", |
911 | gettext_noop( | 911 | gettext_noop ( |
912 | "add an additional keyword for the top-level " | 912 | "add an additional keyword for the top-level " |
913 | "file or directory (this option can be specified multiple times)"), | 913 | "file or directory (this option can be specified multiple times)"), |
914 | &topKeywords), | 914 | &topKeywords), |
915 | GNUNET_FS_GETOPT_METADATA( | 915 | GNUNET_FS_GETOPT_METADATA ( |
916 | 'm', | 916 | 'm', |
917 | "meta", | 917 | "meta", |
918 | "TYPE:VALUE", | 918 | "TYPE:VALUE", |
919 | gettext_noop("set the meta-data for the given TYPE to the given VALUE"), | 919 | gettext_noop ("set the meta-data for the given TYPE to the given VALUE"), |
920 | &meta), | 920 | &meta), |
921 | GNUNET_GETOPT_option_flag( | 921 | GNUNET_GETOPT_option_flag ( |
922 | 'n', | 922 | 'n', |
923 | "noindex", | 923 | "noindex", |
924 | gettext_noop("do not index, perform full insertion (stores " | 924 | gettext_noop ("do not index, perform full insertion (stores " |
925 | "entire file in encrypted form in GNUnet database)"), | 925 | "entire file in encrypted form in GNUnet database)"), |
926 | &do_insert), | 926 | &do_insert), |
927 | GNUNET_GETOPT_option_string( | 927 | GNUNET_GETOPT_option_string ( |
928 | 'N', | 928 | 'N', |
929 | "next", | 929 | "next", |
930 | "ID", | 930 | "ID", |
931 | gettext_noop("specify ID of an updated version to be " | 931 | gettext_noop ("specify ID of an updated version to be " |
932 | "published in the future (for namespace insertions only)"), | 932 | "published in the future (for namespace insertions only)"), |
933 | &next_id), | 933 | &next_id), |
934 | GNUNET_GETOPT_option_uint('p', | 934 | GNUNET_GETOPT_option_uint ('p', |
935 | "priority", | 935 | "priority", |
936 | "PRIORITY", | 936 | "PRIORITY", |
937 | gettext_noop( | 937 | gettext_noop ( |
938 | "specify the priority of the content"), | 938 | "specify the priority of the content"), |
939 | &bo.content_priority), | 939 | &bo.content_priority), |
940 | GNUNET_GETOPT_option_string('P', | 940 | GNUNET_GETOPT_option_string ('P', |
941 | "pseudonym", | 941 | "pseudonym", |
942 | "NAME", | 942 | "NAME", |
943 | gettext_noop( | 943 | gettext_noop ( |
944 | "publish the files under the pseudonym " | 944 | "publish the files under the pseudonym " |
945 | "NAME (place file into namespace)"), | 945 | "NAME (place file into namespace)"), |
946 | &pseudonym), | 946 | &pseudonym), |
947 | GNUNET_GETOPT_option_uint('r', | 947 | GNUNET_GETOPT_option_uint ('r', |
948 | "replication", | 948 | "replication", |
949 | "LEVEL", | 949 | "LEVEL", |
950 | gettext_noop( | 950 | gettext_noop ( |
951 | "set the desired replication LEVEL"), | 951 | "set the desired replication LEVEL"), |
952 | &bo.replication_level), | 952 | &bo.replication_level), |
953 | GNUNET_GETOPT_option_flag('s', | 953 | GNUNET_GETOPT_option_flag ('s', |
954 | "simulate-only", | 954 | "simulate-only", |
955 | gettext_noop( | 955 | gettext_noop ( |
956 | "only simulate the process but do not do " | 956 | "only simulate the process but do not do " |
957 | "any actual publishing (useful to compute URIs)"), | 957 | "any actual publishing (useful to compute URIs)"), |
958 | &do_simulate), | 958 | &do_simulate), |
959 | GNUNET_GETOPT_option_string('t', | 959 | GNUNET_GETOPT_option_string ('t', |
960 | "this", | 960 | "this", |
961 | "ID", | 961 | "ID", |
962 | gettext_noop( | 962 | gettext_noop ( |
963 | "set the ID of this version of the publication " | 963 | "set the ID of this version of the publication " |
964 | "(for namespace insertions only)"), | 964 | "(for namespace insertions only)"), |
965 | &this_id), | 965 | &this_id), |
966 | GNUNET_GETOPT_option_string( | 966 | GNUNET_GETOPT_option_string ( |
967 | 'u', | 967 | 'u', |
968 | "uri", | 968 | "uri", |
969 | "URI", | 969 | "URI", |
970 | gettext_noop( | 970 | gettext_noop ( |
971 | "URI to be published (can be used instead of passing a " | 971 | "URI to be published (can be used instead of passing a " |
972 | "file to add keywords to the file with the respective URI)"), | 972 | "file to add keywords to the file with the respective URI)"), |
973 | &uri_string), | 973 | &uri_string), |
974 | 974 | ||
975 | GNUNET_GETOPT_option_verbose(&verbose), | 975 | GNUNET_GETOPT_option_verbose (&verbose), |
976 | 976 | ||
977 | GNUNET_GETOPT_OPTION_END }; | 977 | GNUNET_GETOPT_OPTION_END }; |
978 | 978 | ||
979 | bo.expiration_time = | 979 | bo.expiration_time = |
980 | GNUNET_TIME_year_to_time(GNUNET_TIME_get_current_year() + 2); | 980 | GNUNET_TIME_year_to_time (GNUNET_TIME_get_current_year () + 2); |
981 | 981 | ||
982 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) | 982 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
983 | return 2; | 983 | return 2; |
984 | ret = | 984 | ret = |
985 | (GNUNET_OK == | 985 | (GNUNET_OK == |
986 | GNUNET_PROGRAM_run(argc, | 986 | GNUNET_PROGRAM_run (argc, |
987 | argv, | 987 | argv, |
988 | "gnunet-publish [OPTIONS] FILENAME", | 988 | "gnunet-publish [OPTIONS] FILENAME", |
989 | gettext_noop("Publish a file or directory on GNUnet"), | 989 | gettext_noop ("Publish a file or directory on GNUnet"), |
990 | options, | 990 | options, |
991 | &run, | 991 | &run, |
992 | NULL)) | 992 | NULL)) |
993 | ? ret | 993 | ? ret |
994 | : 1; | 994 | : 1; |
995 | GNUNET_free((void *)argv); | 995 | GNUNET_free ((void *) argv); |
996 | return ret; | 996 | return ret; |
997 | } | 997 | } |
998 | 998 | ||