X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffs%2Fgnunet-fs.c;h=d48f0d884e1d790a9d2b4035c3f8648805536b53;hb=26d1b687ca01be01505b69ff48ae5d3e0cd4186e;hp=8cf08ec28b67e0fafccea76acc4c4d4916f70ccc;hpb=416c2f5a713b93ba689a8cd1e038682a53e6bc17;p=oweals%2Fgnunet.git diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c index 8cf08ec28..d48f0d884 100644 --- a/src/fs/gnunet-fs.c +++ b/src/fs/gnunet-fs.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2011 Christian Grothoff (and other contributing authors) + Copyright (C) 2011 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -46,20 +46,6 @@ static int list_indexed_files; static int verbose; -/** - * Shutdown this process. - * - * @param cls unused - * @param tc unused - */ -static void -do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - GNUNET_FS_stop (fs); - fs = NULL; -} - - /** * Print indexed filenames to stdout. * @@ -69,8 +55,14 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @return GNUNET_OK to continue iteration */ static int -print_indexed (void *cls, const char *filename, const GNUNET_HashCode * file_id) +print_indexed (void *cls, const char *filename, const struct GNUNET_HashCode * file_id) { + if (NULL == filename) + { + GNUNET_FS_stop (fs); + fs = NULL; + return GNUNET_OK; + } if (verbose) FPRINTF (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename); else @@ -100,7 +92,13 @@ run (void *cls, char *const *args, const char *cfgfile, ret = 1; return; } - GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL, &do_shutdown, NULL); + if (NULL == GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL)) + { + ret = 2; + GNUNET_FS_stop (fs); + fs = NULL; + return; + } } } @@ -121,10 +119,15 @@ main (int argc, char *const *argv) GNUNET_GETOPT_OPTION_VERBOSE (&verbose), GNUNET_GETOPT_OPTION_END }; - return (GNUNET_OK == - GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]", - gettext_noop ("Special file-sharing operations"), - options, &run, NULL)) ? ret : 1; + + if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) + return 2; + ret = (GNUNET_OK == + GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]", + gettext_noop ("Special file-sharing operations"), + options, &run, NULL)) ? ret : 1; + GNUNET_free ((void*) argv); + return ret; } /* end of gnunet-fs.c */