static int testCanonicalize () { char *fn = GNUNET_strdup ("ab?><|cd*ef:/g\""); GNUNET_DISK_filename_canonicalize (fn); if (0 != strcmp (fn, "ab____cd_ef__g_")) { GNUNET_free (fn); return 1; } GNUNET_free (fn); return 0; }
/** * Called by FS client to give information about the progress of an * operation. * * @param cls closure * @param info details about the event, specifying the event type * and various bits about the event * @return client-context (for the next progress call * for this operation; should be set to NULL for * SUSPEND and STOPPED events). The value returned * will be passed to future callbacks in the respective * field in the GNUNET_FS_ProgressInfo struct. */ static void * progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) { static unsigned int cnt; int is_directory; char *uri; char *filename; switch (info->status) { case GNUNET_FS_STATUS_SEARCH_START: break; case GNUNET_FS_STATUS_SEARCH_RESULT: if (db != NULL) GNUNET_FS_directory_builder_add (db, info->value.search.specifics.result.uri, info->value.search.specifics.result.meta, NULL); uri = GNUNET_FS_uri_to_string (info->value.search.specifics.result.uri); printf ("#%u:\n", cnt++); filename = GNUNET_CONTAINER_meta_data_get_by_type (info->value.search. specifics.result.meta, EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); is_directory = GNUNET_FS_meta_data_test_for_directory (info->value.search. specifics.result.meta); if (filename != NULL) { GNUNET_DISK_filename_canonicalize (filename); if (GNUNET_YES == is_directory) printf ("gnunet-download -o \"%s%s\" -R %s\n", filename, GNUNET_FS_DIRECTORY_EXT, uri); else printf ("gnunet-download -o \"%s\" %s\n", filename, uri); } else if (GNUNET_YES == is_directory) printf ("gnunet-download -o \"collection%s\" -R %s\n", GNUNET_FS_DIRECTORY_EXT, uri); else printf ("gnunet-download %s\n", uri); if (verbose) GNUNET_CONTAINER_meta_data_iterate (info->value.search.specifics. result.meta, &item_printer, NULL); printf ("\n"); fflush (stdout); GNUNET_free_non_null (filename); GNUNET_free (uri); results++; if ((results_limit > 0) && (results >= results_limit)) GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_SEARCH_UPDATE: break; case GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED: /* ignore */ break; case GNUNET_FS_STATUS_SEARCH_ERROR: FPRINTF (stderr, _("Error searching: %s.\n"), info->value.search.specifics.error.message); GNUNET_SCHEDULER_shutdown (); break; case GNUNET_FS_STATUS_SEARCH_STOPPED: GNUNET_SCHEDULER_add_now (&clean_task, NULL); break; default: FPRINTF (stderr, _("Unexpected status: %d\n"), info->status); break; } return NULL; }