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 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.
16 * @file fs/gnunet-fs.c
17 * @brief special file-sharing functions
18 * @author Christian Grothoff
21 #include "gnunet_fs_service.h"
29 * Handle to FS service.
31 static struct GNUNET_FS_Handle *fs;
36 static int list_indexed_files;
41 static unsigned int verbose;
45 * Print indexed filenames to stdout.
48 * @param filename the name of the file
49 * @param file_id hash of the contents of the indexed file
50 * @return GNUNET_OK to continue iteration
53 print_indexed (void *cls, const char *filename, const struct GNUNET_HashCode * file_id)
62 FPRINTF (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
64 FPRINTF (stdout, "%s\n", filename);
70 * Main function that will be run by the scheduler.
73 * @param args remaining command-line arguments
74 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
75 * @param cfg configuration
78 run (void *cls, char *const *args, const char *cfgfile,
79 const struct GNUNET_CONFIGURATION_Handle *cfg)
81 if (list_indexed_files)
83 fs = GNUNET_FS_start (cfg, "gnunet-fs", NULL, NULL, GNUNET_FS_FLAGS_NONE,
84 GNUNET_FS_OPTIONS_END);
90 if (NULL == GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL))
101 * The main function to access special file-sharing functions.
103 * @param argc number of arguments from the command line
104 * @param argv command line arguments
105 * @return 0 ok, 1 on error
108 main (int argc, char *const *argv)
110 struct GNUNET_GETOPT_CommandLineOption options[] = {
112 GNUNET_GETOPT_option_flag ('i',
114 gettext_noop ("print a list of all indexed files"),
115 &list_indexed_files),
117 GNUNET_GETOPT_option_verbose (&verbose),
118 GNUNET_GETOPT_OPTION_END
121 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
124 GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]",
125 gettext_noop ("Special file-sharing operations"),
126 options, &run, NULL)) ? ret : 1;
127 GNUNET_free ((void*) argv);
131 /* end of gnunet-fs.c */