2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 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 2, 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-unindex.c
22 * @brief unindex files published on GNUnet
23 * @author Christian Grothoff
24 * @author Krista Bennett
25 * @author James Blackwell
26 * @author Igor Wronsky
29 #include "gnunet_fs_service.h"
35 static const struct GNUNET_CONFIGURATION_Handle *cfg;
37 static struct GNUNET_FS_Handle *ctx;
39 static struct GNUNET_FS_UnindexContext *uc;
43 * Called by FS client to give information about the progress of an
47 * @param info details about the event, specifying the event type
48 * and various bits about the event
49 * @return client-context (for the next progress call
50 * for this operation; should be set to NULL for
51 * SUSPEND and STOPPED events). The value returned
52 * will be passed to future callbacks in the respective
53 * field in the GNUNET_FS_ProgressInfo struct.
56 progress_cb (void *cls,
57 const struct GNUNET_FS_ProgressInfo *info)
61 case GNUNET_FS_STATUS_UNINDEX_START:
63 case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
66 _("Unindexing at %llu/%llu (%s remaining)\n"),
67 (unsigned long long) info->value.unindex.completed,
68 (unsigned long long) info->value.unindex.size,
69 GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta));
71 case GNUNET_FS_STATUS_UNINDEX_ERROR:
73 _("Error unindexing: %s.\n"),
74 info->value.unindex.specifics.error.message);
75 GNUNET_FS_unindex_stop (uc);
77 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
79 _("Unindexing done.\n"));
80 GNUNET_FS_unindex_stop (uc);
82 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
87 _("Unexpected status: %d\n"),
96 * Main function that will be run by the scheduler.
99 * @param sched the scheduler to use
100 * @param args remaining command-line arguments
101 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
102 * @param c configuration
106 struct GNUNET_SCHEDULER_Handle *sched,
109 const struct GNUNET_CONFIGURATION_Handle *c)
111 /* check arguments */
112 if ( (args[0] == NULL) || (args[1] != NULL) )
115 ("You must specify one and only one filename for unindexing.\n"));
120 ctx = GNUNET_FS_start (sched,
125 GNUNET_FS_FLAGS_NONE,
126 GNUNET_FS_OPTIONS_END);
130 _("Could not initialize `%s' subsystem.\n"),
135 uc = GNUNET_FS_unindex (ctx,
140 _("Could not start unindex operation.\n"));
141 GNUNET_FS_stop (ctx);
147 * gnunet-unindex command line options
149 static struct GNUNET_GETOPT_CommandLineOption options[] = {
150 {'V', "verbose", NULL,
151 gettext_noop ("be verbose (print progress information)"),
152 0, &GNUNET_GETOPT_set_one, &verbose},
153 GNUNET_GETOPT_OPTION_END
158 * The main function to unindex content.
160 * @param argc number of arguments from the command line
161 * @param argv command line arguments
162 * @return 0 ok, 1 on error
165 main (int argc, char *const *argv)
168 GNUNET_PROGRAM_run (argc,
173 options, &run, NULL)) ? ret : 1;
176 /* end of gnunet-unindex.c */