From 15bec1f951708a370e2c6cc2ffd48286ca68015b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 23 Jun 2014 09:08:06 +0000 Subject: -fix URI test to handle new encoder, print both SKS and CHK URIs when publishing to namespace --- src/fs/fs_api.c | 17 +++++ src/fs/fs_api.h | 8 ++- src/fs/fs_file_information.c | 5 +- src/fs/fs_publish.c | 102 +++++++++++++++++++----------- src/fs/gnunet-publish.c | 147 ++++++++++++++++++++++++++++++------------- src/fs/test_fs_uri.c | 6 +- 6 files changed, 200 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 7b800c1f1..ab04b86b7 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c @@ -873,6 +873,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, char b; char *ksks; char *chks; + char *skss; char *filename; uint32_t dsize; @@ -885,6 +886,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, ret->h = h; ksks = NULL; chks = NULL; + skss = NULL; filename = NULL; if ((GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "metadata", &ret->meta)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "ksk-uri", &ksks, 32 * 1024)) || @@ -895,6 +897,10 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, ( (NULL != chks) && ( (NULL == (ret->chk_uri = GNUNET_FS_uri_parse (chks, NULL))) || (GNUNET_YES != GNUNET_FS_uri_test_chk (ret->chk_uri))) ) || + (GNUNET_OK != GNUNET_BIO_read_string (rh, "sks-uri", &skss, 1024)) || + ( (NULL != skss) && + ( (NULL == (ret->sks_uri = GNUNET_FS_uri_parse (skss, NULL))) || + (GNUNET_YES != GNUNET_FS_uri_test_sks (ret->sks_uri))) ) || (GNUNET_OK != read_start_time (rh, &ret->start_time)) || (GNUNET_OK != GNUNET_BIO_read_string (rh, "emsg", &ret->emsg, 16 * 1024)) || (GNUNET_OK != @@ -1054,11 +1060,13 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, filename = NULL; } GNUNET_free_non_null (ksks); + GNUNET_free_non_null (skss); GNUNET_free_non_null (chks); return ret; cleanup: GNUNET_free_non_null (ksks); GNUNET_free_non_null (chks); + GNUNET_free_non_null (skss); GNUNET_free_non_null (filename); GNUNET_FS_file_information_destroy (ret, NULL, NULL); return NULL; @@ -1267,6 +1275,7 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) char b; char *ksks; char *chks; + char *skss; if (NULL == fi->serialization) fi->serialization = @@ -1299,10 +1308,15 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) chks = GNUNET_FS_uri_to_string (fi->chk_uri); else chks = NULL; + if (NULL != fi->sks_uri) + skss = GNUNET_FS_uri_to_string (fi->sks_uri); + else + skss = NULL; if ((GNUNET_OK != GNUNET_BIO_write (wh, &b, sizeof (b))) || (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, fi->meta)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, ksks)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, chks)) || + (GNUNET_OK != GNUNET_BIO_write_string (wh, skss)) || (GNUNET_OK != write_start_time (wh, fi->start_time)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->emsg)) || (GNUNET_OK != GNUNET_BIO_write_string (wh, fi->filename)) || @@ -1319,6 +1333,8 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation *fi) chks = NULL; GNUNET_free_non_null (ksks); ksks = NULL; + GNUNET_free_non_null (skss); + skss = NULL; switch (b) { @@ -1410,6 +1426,7 @@ cleanup: (void) GNUNET_BIO_write_close (wh); GNUNET_free_non_null (chks); GNUNET_free_non_null (ksks); + GNUNET_free_non_null (skss); fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization); if (NULL != fn) diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index 77e26e155..2cbbade8f 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h @@ -268,6 +268,12 @@ struct GNUNET_FS_FileInformation */ struct GNUNET_FS_Uri *chk_uri; + /** + * SKS URI for this file or directory. NULL if + * we have not yet computed it. + */ + struct GNUNET_FS_Uri *sks_uri; + /** * Block options for the file. */ @@ -735,7 +741,7 @@ GNUNET_FS_search_probe_progress_ (void *cls, /** * Main function that performs the upload. * - * @param cls "struct GNUNET_FS_PublishContext" identifies the upload + * @param cls `struct GNUNET_FS_PublishContext` identifies the upload * @param tc task context */ void diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index d369598ef..f004e4b29 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -436,7 +436,10 @@ GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi, } GNUNET_free_non_null (fi->filename); GNUNET_free_non_null (fi->emsg); - GNUNET_free_non_null (fi->chk_uri); + if (NULL != fi->sks_uri) + GNUNET_FS_uri_destroy (fi->sks_uri); + if (NULL != fi->chk_uri) + GNUNET_FS_uri_destroy (fi->chk_uri); /* clean up serialization */ if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization))) GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 2075c5f2b..c9e2b0e6a 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -17,7 +17,6 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * @file fs/fs_publish.c * @brief publish a file or directory in GNUnet @@ -25,7 +24,6 @@ * @author Krista Bennett * @author Christian Grothoff */ - #include "platform.h" #include "gnunet_constants.h" #include "gnunet_signatures.h" @@ -57,9 +55,10 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, pi->value.publish.pctx = (NULL == p->dir) ? NULL : p->dir->client_info; pi->value.publish.filename = p->filename; pi->value.publish.size = - (p->is_directory == GNUNET_YES) ? p->data.dir.dir_size : p->data.file.file_size; + (GNUNET_YES == p->is_directory) ? p->data.dir.dir_size : p->data.file.file_size; pi->value.publish.eta = - GNUNET_TIME_calculate_eta (p->start_time, offset, pi->value.publish.size); + GNUNET_TIME_calculate_eta (p->start_time, offset, + pi->value.publish.size); pi->value.publish.completed = offset; pi->value.publish.duration = GNUNET_TIME_absolute_get_duration (p->start_time); @@ -77,8 +76,9 @@ GNUNET_FS_publish_make_status_ (struct GNUNET_FS_ProgressInfo *pi, static void publish_cleanup (struct GNUNET_FS_PublishContext *pc) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up publish context (done!)\n"); - if (pc->fhc != NULL) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Cleaning up publish context (done!)\n"); + if (NULL != pc->fhc) { GNUNET_CRYPTO_hash_file_cancel (pc->fhc); pc->fhc = NULL; @@ -87,12 +87,12 @@ publish_cleanup (struct GNUNET_FS_PublishContext *pc) GNUNET_free_non_null (pc->nid); GNUNET_free_non_null (pc->nuid); GNUNET_free_non_null (pc->serialization); - if (pc->dsh != NULL) + if (NULL != pc->dsh) { GNUNET_DATASTORE_disconnect (pc->dsh, GNUNET_NO); pc->dsh = NULL; } - if (pc->client != NULL) + if (NULL != pc->client) { GNUNET_CLIENT_disconnect (pc->client); pc->client = NULL; @@ -122,7 +122,9 @@ ds_put_cont (void *cls, int success, pc->qre = NULL; if (GNUNET_SYSERR == success) { - GNUNET_asprintf (&pc->fi_pos->emsg, _("Publishing failed: %s"), msg); + GNUNET_asprintf (&pc->fi_pos->emsg, + _("Publishing failed: %s"), + msg); pi.status = GNUNET_FS_STATUS_PUBLISH_ERROR; pi.value.publish.eta = GNUNET_TIME_UNIT_FOREVER_REL; pi.value.publish.specifics.error.message = pc->fi_pos->emsg; @@ -160,10 +162,10 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, pi.status = GNUNET_FS_STATUS_PUBLISH_COMPLETED; pi.value.publish.eta = GNUNET_TIME_UNIT_ZERO; pi.value.publish.specifics.completed.chk_uri = p->chk_uri; + pi.value.publish.specifics.completed.sks_uri = p->sks_uri; p->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, p, - GNUNET_ntohll (p->chk_uri->data. - chk.file_length)); + p->data.file.file_size); } @@ -178,7 +180,8 @@ signal_publish_completion (struct GNUNET_FS_FileInformation *p, */ static void signal_publish_error (struct GNUNET_FS_FileInformation *p, - struct GNUNET_FS_PublishContext *pc, const char *emsg) + struct GNUNET_FS_PublishContext *pc, + const char *emsg) { struct GNUNET_FS_ProgressInfo pi; @@ -225,12 +228,13 @@ finish_release_reserve (void *cls, int success, * We've finished publishing the SBlock as part of a larger upload. * Check the result and complete the larger upload. * - * @param cls the "struct GNUNET_FS_PublishContext*" of the larger upload + * @param cls the `struct GNUNET_FS_PublishContext *` of the larger upload * @param uri URI of the published SBlock * @param emsg NULL on success, otherwise error message */ static void -publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, +publish_sblocks_cont (void *cls, + const struct GNUNET_FS_Uri *uri, const char *emsg) { struct GNUNET_FS_PublishContext *pc = cls; @@ -242,6 +246,11 @@ publish_sblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, GNUNET_FS_publish_sync_ (pc); return; } + if (NULL != uri) + { + /* sks publication, remember namespace URI */ + pc->fi->sks_uri = GNUNET_FS_uri_dup (uri); + } GNUNET_assert (pc->qre == NULL); if ((pc->dsh != NULL) && (pc->rid != 0)) { @@ -291,7 +300,8 @@ publish_sblock (struct GNUNET_FS_PublishContext *pc) * @param emsg NULL on success, otherwise error message */ static void -publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, +publish_kblocks_cont (void *cls, + const struct GNUNET_FS_Uri *uri, const char *emsg) { struct GNUNET_FS_PublishContext *pc = cls; @@ -309,7 +319,9 @@ publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pc->upload_task); pc->upload_task = GNUNET_SCHEDULER_add_with_priority - (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, &GNUNET_FS_publish_main_, pc); + (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, + &GNUNET_FS_publish_main_, + pc); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -343,7 +355,11 @@ publish_kblocks_cont (void *cls, const struct GNUNET_FS_Uri *uri, * @return number of bytes copied to buf, 0 on error */ static size_t -block_reader (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) +block_reader (void *cls, + uint64_t offset, + size_t max, + void *buf, + char **emsg) { struct GNUNET_FS_PublishContext *pc = cls; struct GNUNET_FS_FileInformation *p; @@ -884,9 +900,9 @@ GNUNET_FS_publish_main_ (void *cls, if (0 == p->bo.anonymity_level) { /* zero anonymity, box CHK URI in LOC URI */ - loc = - GNUNET_FS_uri_loc_create (p->chk_uri, pc->h->cfg, - p->bo.expiration_time); + loc = GNUNET_FS_uri_loc_create (p->chk_uri, + pc->h->cfg, + p->bo.expiration_time); GNUNET_FS_uri_destroy (p->chk_uri); p->chk_uri = loc; GNUNET_FS_file_information_sync_ (p); @@ -895,8 +911,13 @@ GNUNET_FS_publish_main_ (void *cls, /* upload of "p" complete, publish KBlocks! */ if (NULL != p->keywords) { - pc->ksk_pc = GNUNET_FS_publish_ksk (pc->h, p->keywords, p->meta, p->chk_uri, &p->bo, - pc->options, &publish_kblocks_cont, pc); + pc->ksk_pc = GNUNET_FS_publish_ksk (pc->h, + p->keywords, + p->meta, + p->chk_uri, + &p->bo, + pc->options, + &publish_kblocks_cont, pc); } else { @@ -910,9 +931,9 @@ GNUNET_FS_publish_main_ (void *cls, { p->data.file.do_index = GNUNET_NO; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("Can not index file `%s': %s. Will try to insert instead.\n"), - "", _("needs to be an actual file")); + _("Can not index file `%s': %s. Will try to insert instead.\n"), + "", + _("needs to be an actual file")); GNUNET_FS_file_information_sync_ (p); publish_content (pc); return; @@ -1239,14 +1260,15 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, { GNUNET_assert (NULL == ret->qre); GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _ - ("Reserving space for %u entries and %llu bytes for publication\n"), + _("Reserving space for %u entries and %llu bytes for publication\n"), (unsigned int) ret->reserve_entries, (unsigned long long) ret->reserve_space); ret->qre = GNUNET_DATASTORE_reserve (ret->dsh, ret->reserve_space, - ret->reserve_entries, UINT_MAX, UINT_MAX, - GNUNET_TIME_UNIT_FOREVER_REL, &finish_reserve, + ret->reserve_entries, + UINT_MAX, UINT_MAX, + GNUNET_TIME_UNIT_FOREVER_REL, + &finish_reserve, ret); } else @@ -1275,9 +1297,12 @@ GNUNET_FS_publish_start (struct GNUNET_FS_Handle *h, * @return #GNUNET_OK to continue (always) */ static int -fip_signal_stop (void *cls, struct GNUNET_FS_FileInformation *fi, - uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, - struct GNUNET_FS_Uri **uri, struct GNUNET_FS_BlockOptions *bo, +fip_signal_stop (void *cls, + struct GNUNET_FS_FileInformation *fi, + uint64_t length, + struct GNUNET_CONTAINER_MetaData *meta, + struct GNUNET_FS_Uri **uri, + struct GNUNET_FS_BlockOptions *bo, int *do_index, void **client_info) { struct GNUNET_FS_PublishContext *pc = cls; @@ -1324,7 +1349,8 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) struct GNUNET_FS_ProgressInfo pi; uint64_t off; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publish stop called\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Publish stop called\n"); GNUNET_FS_end_top (pc->h, pc->top); if (NULL != pc->ksk_pc) { @@ -1344,16 +1370,19 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) pc->skip_next_fi_callback = GNUNET_YES; GNUNET_FS_file_information_inspect (pc->fi, &fip_signal_stop, pc); - if (pc->fi->serialization != NULL) + if (NULL != pc->fi->serialization) { GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_FILE_INFO, pc->fi->serialization); GNUNET_free (pc->fi->serialization); pc->fi->serialization = NULL; } - off = (pc->fi->chk_uri == NULL) ? 0 : GNUNET_ntohll (pc->fi->chk_uri->data.chk.file_length); + if (NULL == pc->fi->chk_uri) + off = 0; /* won't be completed anymore */ + else + off = pc->fi->is_directory ? pc->fi->data.dir.contents_completed : pc->fi->data.file.file_size; /* we were done */ - if (pc->serialization != NULL) + if (NULL != pc->serialization) { GNUNET_FS_remove_sync_file_ (pc->h, GNUNET_FS_SYNC_PATH_MASTER_PUBLISH, pc->serialization); @@ -1371,5 +1400,4 @@ GNUNET_FS_publish_stop (struct GNUNET_FS_PublishContext *pc) } - /* end of fs_publish.c */ diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index f192a0a90..f8396416c 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -154,11 +154,17 @@ static struct GNUNET_IDENTITY_Handle *identity; * @param tc scheduler context */ static void -do_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +do_stop_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) { struct GNUNET_FS_PublishContext *p; kill_task = GNUNET_SCHEDULER_NO_TASK; + if (NULL != identity) + { + GNUNET_IDENTITY_disconnect (identity); + identity = NULL; + } if (NULL != pc) { p = pc; @@ -213,7 +219,8 @@ stop_scanner_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * field in the GNUNET_FS_ProgressInfo struct. */ static void * -progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) +progress_cb (void *cls, + const struct GNUNET_FS_ProgressInfo *info) { const char *s; char *suri; @@ -257,19 +264,28 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL); break; case GNUNET_FS_STATUS_PUBLISH_COMPLETED: - FPRINTF (stdout, _("Publishing `%s' done.\n"), + FPRINTF (stdout, + _("Publishing `%s' done.\n"), info->value.publish.filename); suri = GNUNET_FS_uri_to_string (info->value.publish.specifics. - completed.chk_uri); - FPRINTF (stdout, _("URI is `%s'.\n"), suri); + completed.chk_uri); + FPRINTF (stdout, + _("URI is `%s'.\n"), + suri); GNUNET_free (suri); + if (NULL != info->value.publish.specifics.completed.sks_uri) + { + suri = GNUNET_FS_uri_to_string (info->value.publish.specifics. + completed.sks_uri); + FPRINTF (stdout, + _("Namespace URI is `%s'.\n"), + suri); + GNUNET_free (suri); + } if (NULL == info->value.publish.pctx) { if (GNUNET_SCHEDULER_NO_TASK != kill_task) - { GNUNET_SCHEDULER_cancel (kill_task); - kill_task = GNUNET_SCHEDULER_NO_TASK; - } kill_task = GNUNET_SCHEDULER_add_now (&do_stop_task, NULL); } ret = 0; @@ -280,7 +296,9 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) case GNUNET_FS_STATUS_UNINDEX_PROGRESS: return NULL; case GNUNET_FS_STATUS_UNINDEX_COMPLETED: - FPRINTF (stderr, "%s", _("Cleanup after abort complete.\n")); + FPRINTF (stderr, + "%s", + _("Cleanup after abort complete.\n")); return NULL; default: FPRINTF (stderr, _("Unexpected status: %d\n"), info->status); @@ -300,12 +318,15 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) * @param format format of data * @param data_mime_type mime type of data * @param data value of the meta data - * @param data_size number of bytes in data + * @param data_size number of bytes in @a data * @return always 0 */ static int -meta_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, const char *data_mime_type, +meta_printer (void *cls, + const char *plugin_name, + enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, + const char *data_mime_type, const char *data, size_t data_size) { if ((EXTRACTOR_METAFORMAT_UTF8 != format) && @@ -324,10 +345,12 @@ meta_printer (void *cls, const char *plugin_name, enum EXTRACTOR_MetaType type, * @param cls closure * @param keyword the keyword * @param is_mandatory is the keyword mandatory (in a search) - * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to abort */ static int -keyword_printer (void *cls, const char *keyword, int is_mandatory) +keyword_printer (void *cls, + const char *keyword, + int is_mandatory) { FPRINTF (stdout, "\t%s\n", keyword); return GNUNET_OK; @@ -347,15 +370,18 @@ keyword_printer (void *cls, const char *keyword, int is_mandatory) * @param bo block options * @param do_index should we index? * @param client_info pointer to client context set upon creation (can be modified) - * @return GNUNET_OK to continue, GNUNET_NO to remove - * this entry from the directory, GNUNET_SYSERR + * @return #GNUNET_OK to continue, #GNUNET_NO to remove + * this entry from the directory, #GNUNET_SYSERR * to abort the iteration */ static int -publish_inspector (void *cls, struct GNUNET_FS_FileInformation *fi, - uint64_t length, struct GNUNET_CONTAINER_MetaData *m, +publish_inspector (void *cls, + struct GNUNET_FS_FileInformation *fi, + uint64_t length, + struct GNUNET_CONTAINER_MetaData *m, struct GNUNET_FS_Uri **uri, - struct GNUNET_FS_BlockOptions *bo, int *do_index, + struct GNUNET_FS_BlockOptions *bo, + int *do_index, void **client_info) { char *fn; @@ -423,7 +449,8 @@ publish_inspector (void *cls, struct GNUNET_FS_FileInformation *fi, * @param emsg error message, NULL on success */ static void -uri_sks_continuation (void *cls, const struct GNUNET_FS_Uri *sks_uri, +uri_sks_continuation (void *cls, + const struct GNUNET_FS_Uri *sks_uri, const char *emsg) { if (NULL != emsg) @@ -540,7 +567,9 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) GNUNET_FS_share_tree_free (directory_scan_result); if (NULL == fi) { - FPRINTF (stderr, "%s", _("Could not publish\n")); + FPRINTF (stderr, + "%s", + _("Could not publish\n")); GNUNET_SCHEDULER_shutdown (); ret = 1; return; @@ -563,7 +592,9 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) GNUNET_FS_PUBLISH_OPTION_NONE); if (NULL == pc) { - FPRINTF (stderr, "%s", _("Could not start publishing.\n")); + FPRINTF (stderr, + "%s", + _("Could not start publishing.\n")); GNUNET_SCHEDULER_shutdown (); ret = 1; return; @@ -577,9 +608,9 @@ directory_trim_complete (struct GNUNET_FS_ShareTreeItem *directory_scan_result) * * @param cls closure * @param filename which file we are making progress on - * @param is_directory GNUNET_YES if this is a directory, - * GNUNET_NO if this is a file - * GNUNET_SYSERR if it is neither (or unknown) + * @param is_directory #GNUNET_YES if this is a directory, + * #GNUNET_NO if this is a file + * #GNUNET_SYSERR if it is neither (or unknown) * @param reason kind of progress we are making */ static void @@ -596,9 +627,13 @@ directory_scan_cb (void *cls, if (verbose > 1) { if (is_directory == GNUNET_YES) - FPRINTF (stdout, _("Scanning directory `%s'.\n"), filename); + FPRINTF (stdout, + _("Scanning directory `%s'.\n"), + filename); else - FPRINTF (stdout, _("Scanning file `%s'.\n"), filename); + FPRINTF (stdout, + _("Scanning file `%s'.\n"), + filename); } break; case GNUNET_FS_DIRSCANNER_FILE_IGNORED: @@ -608,22 +643,30 @@ directory_scan_cb (void *cls, break; case GNUNET_FS_DIRSCANNER_ALL_COUNTED: if (verbose) - FPRINTF (stdout, "%s", _("Preprocessing complete.\n")); + FPRINTF (stdout, + "%s", + _("Preprocessing complete.\n")); break; case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED: if (verbose > 2) - FPRINTF (stdout, _("Extracting meta data from file `%s' complete.\n"), filename); + FPRINTF (stdout, + _("Extracting meta data from file `%s' complete.\n"), + filename); break; case GNUNET_FS_DIRSCANNER_FINISHED: if (verbose > 1) - FPRINTF (stdout, "%s", _("Meta data extraction has finished.\n")); + FPRINTF (stdout, + "%s", + _("Meta data extraction has finished.\n")); directory_scan_result = GNUNET_FS_directory_scan_get_result (ds); ds = NULL; GNUNET_FS_share_tree_trim (directory_scan_result); directory_trim_complete (directory_scan_result); break; case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: - FPRINTF (stdout, "%s", _("Internal error scanning directory.\n")); + FPRINTF (stdout, + "%s", + _("Internal error scanning directory.\n")); if (kill_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (kill_task); @@ -654,7 +697,9 @@ identity_continuation (const char *args0) if ( (NULL != pseudonym) && (NULL == namespace) ) { - FPRINTF (stderr, _("Selected pseudonym `%s' unknown\n"), pseudonym); + FPRINTF (stderr, + _("Selected pseudonym `%s' unknown\n"), + pseudonym); GNUNET_SCHEDULER_shutdown (); return; } @@ -663,14 +708,19 @@ identity_continuation (const char *args0) emsg = NULL; if (NULL == (uri = GNUNET_FS_uri_parse (uri_string, &emsg))) { - FPRINTF (stderr, _("Failed to parse URI: %s\n"), emsg); + FPRINTF (stderr, + _("Failed to parse URI: %s\n"), + emsg); GNUNET_free (emsg); GNUNET_SCHEDULER_shutdown (); ret = 1; return; } - GNUNET_FS_publish_ksk (ctx, topKeywords, meta, uri, &bo, - GNUNET_FS_PUBLISH_OPTION_NONE, &uri_ksk_continuation, + GNUNET_FS_publish_ksk (ctx, topKeywords, + meta, uri, + &bo, + GNUNET_FS_PUBLISH_OPTION_NONE, + &uri_ksk_continuation, NULL); return; } @@ -693,7 +743,8 @@ identity_continuation (const char *args0) if (NULL == ds) { FPRINTF (stderr, - "%s", _("Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n")); + "%s", + _("Failed to start meta directory scanner. Is gnunet-helper-publish-fs installed?\n")); GNUNET_free_non_null (ex); return; } @@ -725,6 +776,8 @@ identity_cb (void *cls, identity_continuation (args0); return; } + if (NULL == name) + return; if (0 == strcmp (name, pseudonym)) namespace = ego; } @@ -739,7 +792,9 @@ identity_cb (void *cls, * @param c configuration */ static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, + char *const *args, + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { /* check arguments */ @@ -776,14 +831,16 @@ run (void *cls, char *const *args, const char *cfgfile, { /* ordinary insertion checks */ if (NULL != next_id) { - FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), + FPRINTF (stderr, + _("Option `%s' makes no sense without option `%s'.\n"), "-N", "-P"); ret = -1; return; } if (NULL != this_id) { - FPRINTF (stderr, _("Option `%s' makes no sense without option `%s'.\n"), + FPRINTF (stderr, + _("Option `%s' makes no sense without option `%s'.\n"), "-t", "-P"); ret = -1; return; @@ -795,16 +852,20 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); if (NULL == ctx) { - FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); + FPRINTF (stderr, + _("Could not initialize `%s' subsystem.\n"), + "FS"); ret = 1; return; } kill_task = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &do_stop_task, - NULL); + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, + &do_stop_task, + NULL); if (NULL != pseudonym) identity = GNUNET_IDENTITY_connect (cfg, - &identity_cb, args[0]); + &identity_cb, + args[0]); else identity_continuation (args[0]); } diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c index b9296bcb6..afc80ef71 100644 --- a/src/fs/test_fs_uri.c +++ b/src/fs/test_fs_uri.c @@ -181,7 +181,7 @@ testNamespace (int i) if (NULL != (ret = GNUNET_FS_uri_parse - ("gnunet://fs/sks/D1KJS9H2A82Q65VKQ0ML3RFU6U1D3V/test", &emsg))) + ("gnunet://fs/sks/XQHH4R288W26EBV369F6RCE0PJVJTX2Y74Q2FJPMPGA31HJX2JG/this", &emsg))) { GNUNET_FS_uri_destroy (ret); GNUNET_assert (0); @@ -273,7 +273,7 @@ testFile (int i) GNUNET_free (emsg); ret = GNUNET_FS_uri_parse - ("gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42", + ("gnunet://fs/chk/4QZP479A9SKGFNMQ2ZBCYE71YV2QMTVGWTVPB6A10ASVCKXDHB05DKPSC7ZF6E9P9W1VE47394EQY7NXA47Q6R35M7P1MJPGP59D1Z8.D54QD1K5XCG5878T6YZ19AM60MQ6FC0YNVK7QY08KK0KM0FJJ3KQWYG112FN5T07KN7J0X35DF6WVBT9B8ZMZ3X2BXJ22X3KFQ6MV2G.42", &emsg); if (ret == NULL) { @@ -299,7 +299,7 @@ testFile (int i) uri = GNUNET_FS_uri_to_string (ret); if (0 != strcmp (uri, - "gnunet://fs/chk/C282GG70GKK41O4551011DO413KFBVTVMQG1OG30I0K4045N0G41HAPB82G680A02JRVVFO8URVRU2F159011DO41000000022RG820.RNVVVVOOLCLK065B5D04HTNVNSIB2AI022RG8200HSLK1CO1000ATQ98824DMA2032LIMG50CG0K057NVUVG200000H000004400000.42")) + "gnunet://fs/chk/4QZP479A9SKGFNMQ2ZBCYE71YV2QMTVGWTVPB6A10ASVCKXDHB05DKPSC7ZF6E9P9W1VE47394EQY7NXA47Q6R35M7P1MJPGP59D1Z8.D54QD1K5XCG5878T6YZ19AM60MQ6FC0YNVK7QY08KK0KM0FJJ3KQWYG112FN5T07KN7J0X35DF6WVBT9B8ZMZ3X2BXJ22X3KFQ6MV2G.42")) { GNUNET_free (uri); GNUNET_FS_uri_destroy (ret); -- cgit v1.2.3