2 This file is part of GNUnet.
3 Copyright (C) 2011 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
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/>.
19 * @file fs/gnunet-fs.c
20 * @brief special file-sharing functions
21 * @author Christian Grothoff
24 #include "gnunet_fs_service.h"
32 * Handle to FS service.
34 static struct GNUNET_FS_Handle *fs;
39 static int list_indexed_files;
44 static unsigned int verbose;
48 * Print indexed filenames to stdout.
51 * @param filename the name of the file
52 * @param file_id hash of the contents of the indexed file
53 * @return GNUNET_OK to continue iteration
56 print_indexed (void *cls, const char *filename, const struct GNUNET_HashCode * file_id)
65 FPRINTF (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
67 FPRINTF (stdout, "%s\n", filename);
73 * Main function that will be run by the scheduler.
76 * @param args remaining command-line arguments
77 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
78 * @param cfg configuration
81 run (void *cls, char *const *args, const char *cfgfile,
82 const struct GNUNET_CONFIGURATION_Handle *cfg)
84 if (list_indexed_files)
86 fs = GNUNET_FS_start (cfg, "gnunet-fs", NULL, NULL, GNUNET_FS_FLAGS_NONE,
87 GNUNET_FS_OPTIONS_END);
93 if (NULL == GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL))
104 * The main function to access special file-sharing functions.
106 * @param argc number of arguments from the command line
107 * @param argv command line arguments
108 * @return 0 ok, 1 on error
111 main (int argc, char *const *argv)
113 struct GNUNET_GETOPT_CommandLineOption options[] = {
115 GNUNET_GETOPT_option_flag ('i',
117 gettext_noop ("print a list of all indexed files"),
118 &list_indexed_files),
120 GNUNET_GETOPT_option_verbose (&verbose),
121 GNUNET_GETOPT_OPTION_END
124 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
127 GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]",
128 gettext_noop ("Special file-sharing operations"),
129 options, &run, NULL)) ? ret : 1;
130 GNUNET_free ((void*) argv);
134 /* end of gnunet-fs.c */