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 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-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 cleanup_task (void *cls,
44 const struct GNUNET_SCHEDULER_TaskContext *tc)
52 shutdown_task (void *cls,
53 const struct GNUNET_SCHEDULER_TaskContext *tc)
55 struct GNUNET_FS_UnindexContext *u;
61 GNUNET_FS_unindex_stop (u);
66 * Called by FS client to give information about the progress of an
70 * @param info details about the event, specifying the event type
71 * and various bits about the event
72 * @return client-context (for the next progress call
73 * for this operation; should be set to NULL for
74 * SUSPEND and STOPPED events). The value returned
75 * will be passed to future callbacks in the respective
76 * field in the GNUNET_FS_ProgressInfo struct.
79 progress_cb (void *cls,
80 const struct GNUNET_FS_ProgressInfo *info)
86 case GNUNET_FS_STATUS_UNINDEX_START:
88 case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
91 s = GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta);
93 _("Unindexing at %llu/%llu (%s remaining)\n"),
94 (unsigned long long) info->value.unindex.completed,
95 (unsigned long long) info->value.unindex.size,
100 case GNUNET_FS_STATUS_UNINDEX_ERROR:
102 _("Error unindexing: %s.\n"),
103 info->value.unindex.specifics.error.message);
104 GNUNET_SCHEDULER_shutdown ();
106 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
108 _("Unindexing done.\n"));
109 GNUNET_SCHEDULER_shutdown ();
111 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
112 GNUNET_SCHEDULER_add_continuation (&cleanup_task,
114 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
118 _("Unexpected status: %d\n"),
127 * Main function that will be run by the scheduler.
130 * @param args remaining command-line arguments
131 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
132 * @param c configuration
138 const struct GNUNET_CONFIGURATION_Handle *c)
140 /* check arguments */
141 if ( (args[0] == NULL) || (args[1] != NULL) )
144 ("You must specify one and only one filename for unindexing.\n"));
149 ctx = GNUNET_FS_start (cfg,
153 GNUNET_FS_FLAGS_NONE,
154 GNUNET_FS_OPTIONS_END);
158 _("Could not initialize `%s' subsystem.\n"),
163 uc = GNUNET_FS_unindex_start (ctx,
169 _("Could not start unindex operation.\n"));
170 GNUNET_FS_stop (ctx);
173 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
180 * The main function to unindex content.
182 * @param argc number of arguments from the command line
183 * @param argv command line arguments
184 * @return 0 ok, 1 on error
187 main (int argc, char *const *argv)
189 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
190 {'V', "verbose", NULL,
191 gettext_noop ("be verbose (print progress information)"),
192 0, &GNUNET_GETOPT_set_one, &verbose},
193 GNUNET_GETOPT_OPTION_END
196 GNUNET_PROGRAM_run (argc,
198 "gnunet-unindex [OPTIONS] FILENAME",
200 ("Unindex a file that was previously indexed with gnunet-publish."),
201 options, &run, NULL)) ? ret : 1;
204 /* end of gnunet-unindex.c */