2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
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;
50 * Shutdown this process.
56 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
64 * Print indexed filenames to stdout.
67 * @param filename the name of the file
68 * @param file_id hash of the contents of the indexed file
69 * @return GNUNET_OK to continue iteration
72 print_indexed (void *cls, const char *filename, const GNUNET_HashCode * file_id)
75 FPRINTF (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
77 FPRINTF (stdout, "%s\n", filename);
83 * Main function that will be run by the scheduler.
86 * @param args remaining command-line arguments
87 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
88 * @param cfg configuration
91 run (void *cls, char *const *args, const char *cfgfile,
92 const struct GNUNET_CONFIGURATION_Handle *cfg)
94 if (list_indexed_files)
96 fs = GNUNET_FS_start (cfg, "gnunet-fs", NULL, NULL, GNUNET_FS_FLAGS_NONE,
97 GNUNET_FS_OPTIONS_END);
103 GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL, &do_shutdown, NULL);
108 * The main function to access special file-sharing functions.
110 * @param argc number of arguments from the command line
111 * @param argv command line arguments
112 * @return 0 ok, 1 on error
115 main (int argc, char *const *argv)
117 static struct GNUNET_GETOPT_CommandLineOption options[] = {
118 {'i', "list-indexed", NULL,
119 gettext_noop ("print a list of all indexed files"), 0,
120 &GNUNET_GETOPT_set_one, &list_indexed_files},
121 GNUNET_GETOPT_OPTION_VERBOSE (&verbose),
122 GNUNET_GETOPT_OPTION_END
125 GNUNET_PROGRAM_run (argc, argv, "gnunet-fs [OPTIONS]",
126 gettext_noop ("Special file-sharing operations"),
127 options, &run, NULL)) ? ret : 1;
130 /* end of gnunet-fs.c */