aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs.c')
-rw-r--r--src/fs/gnunet-fs.c152
1 files changed, 0 insertions, 152 deletions
diff --git a/src/fs/gnunet-fs.c b/src/fs/gnunet-fs.c
deleted file mode 100644
index 70a0034a0..000000000
--- a/src/fs/gnunet-fs.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011 GNUnet e.V.
4
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.
9
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.
14
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/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file fs/gnunet-fs.c
22 * @brief special file-sharing functions
23 * @author Christian Grothoff
24 */
25#include "platform.h"
26#include "gnunet_fs_service.h"
27
28/**
29 * Return value.
30 */
31static int ret;
32
33/**
34 * Handle to FS service.
35 */
36static struct GNUNET_FS_Handle *fs;
37
38/**
39 * Option -i given?
40 */
41static int list_indexed_files;
42
43/**
44 * Option -v given?
45 */
46static unsigned int verbose;
47
48
49/**
50 * Print indexed filenames to stdout.
51 *
52 * @param cls closure
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
56 */
57static int
58print_indexed (void *cls,
59 const char *filename,
60 const struct GNUNET_HashCode *file_id)
61{
62 if (NULL == filename)
63 {
64 GNUNET_FS_stop (fs);
65 fs = NULL;
66 return GNUNET_OK;
67 }
68 if (verbose)
69 fprintf (stdout, "%s: %s\n", GNUNET_h2s (file_id), filename);
70 else
71 fprintf (stdout, "%s\n", filename);
72 return GNUNET_OK;
73}
74
75
76/**
77 * Main function that will be run by the scheduler.
78 *
79 * @param cls closure
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
83 */
84static void
85run (void *cls,
86 char *const *args,
87 const char *cfgfile,
88 const struct GNUNET_CONFIGURATION_Handle *cfg)
89{
90 if (list_indexed_files)
91 {
92 fs = GNUNET_FS_start (cfg,
93 "gnunet-fs",
94 NULL,
95 NULL,
96 GNUNET_FS_FLAGS_NONE,
97 GNUNET_FS_OPTIONS_END);
98 if (NULL == fs)
99 {
100 ret = 1;
101 return;
102 }
103 if (NULL == GNUNET_FS_get_indexed_files (fs, &print_indexed, NULL))
104 {
105 ret = 2;
106 GNUNET_FS_stop (fs);
107 fs = NULL;
108 return;
109 }
110 }
111}
112
113
114/**
115 * The main function to access special file-sharing functions.
116 *
117 * @param argc number of arguments from the command line
118 * @param argv command line arguments
119 * @return 0 ok, 1 on error
120 */
121int
122main (int argc, char *const *argv)
123{
124 struct GNUNET_GETOPT_CommandLineOption options[] = {
125 GNUNET_GETOPT_option_flag ('i',
126 "list-indexed",
127 gettext_noop (
128 "print a list of all indexed files"),
129 &list_indexed_files),
130
131 GNUNET_GETOPT_option_verbose (&verbose),
132 GNUNET_GETOPT_OPTION_END
133 };
134
135 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
136 return 2;
137 ret = (GNUNET_OK ==
138 GNUNET_PROGRAM_run (argc,
139 argv,
140 "gnunet-fs [OPTIONS]",
141 gettext_noop ("Special file-sharing operations"),
142 options,
143 &run,
144 NULL))
145 ? ret
146 : 1;
147 GNUNET_free_nz ((void *) argv);
148 return ret;
149}
150
151
152/* end of gnunet-fs.c */