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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
21 * @file fs/gnunet-fs.c
22 * @brief special file-sharing functions
23 * @author Christian Grothoff
26 #include "gnunet_fs_service.h"
34 * Handle to FS service.
36 static struct GNUNET_FS_Handle *fs;
41 static int list_indexed_files;
46 static unsigned int verbose;
50 * Print indexed filenames to stdout.
53 * @param filename the name of the file
54 * @param file_id hash of the contents of the indexed file
55 * @return GNUNET_OK to continue iteration
58 print_indexed (void *cls,
60 const struct GNUNET_HashCode *file_id)
69 fprintf (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
71 fprintf (stdout, "%s\n", filename);
77 * Main function that will be run by the scheduler.
80 * @param args remaining command-line arguments
81 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
82 * @param cfg configuration
88 const struct GNUNET_CONFIGURATION_Handle *cfg)
90 if (list_indexed_files)
92 fs = GNUNET_FS_start (cfg,
97 GNUNET_FS_OPTIONS_END);
103 if (NULL == GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL))
115 * The main function to access special file-sharing functions.
117 * @param argc number of arguments from the command line
118 * @param argv command line arguments
119 * @return 0 ok, 1 on error
122 main (int argc, char *const *argv)
124 struct GNUNET_GETOPT_CommandLineOption options[] = {
125 GNUNET_GETOPT_option_flag ('i',
128 "print a list of all indexed files"),
129 &list_indexed_files),
131 GNUNET_GETOPT_option_verbose (&verbose),
132 GNUNET_GETOPT_OPTION_END
135 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
138 GNUNET_PROGRAM_run (argc,
140 "gnunet-fs [OPTIONS]",
141 gettext_noop ("Special file-sharing operations"),
147 GNUNET_free ((void *) argv);
152 /* end of gnunet-fs.c */