aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-unindex.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-09-06 21:03:16 +0000
committerChristian Grothoff <christian@grothoff.org>2009-09-06 21:03:16 +0000
commit2a534fc5efadca1b65648efb903c3b4c17ac33ad (patch)
treed20be6f1d2ce6faff9ae6475c507f2aa33691e16 /src/fs/gnunet-unindex.c
parentc263f813925949b97bfd899e174eefe4ecccced8 (diff)
downloadgnunet-2a534fc5efadca1b65648efb903c3b4c17ac33ad.tar.gz
gnunet-2a534fc5efadca1b65648efb903c3b4c17ac33ad.zip
fs tools
Diffstat (limited to 'src/fs/gnunet-unindex.c')
-rw-r--r--src/fs/gnunet-unindex.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index 2dfef9432..9b335eec0 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -24,24 +24,20 @@
24 * @author Krista Bennett 24 * @author Krista Bennett
25 * @author James Blackwell 25 * @author James Blackwell
26 * @author Igor Wronsky 26 * @author Igor Wronsky
27 *
28 * TODO:
29 * - progress callback
30 * - error checking
31 */ 27 */
32#include "platform.h" 28#include "platform.h"
33#include "gnunet_fs_service.h" 29#include "gnunet_fs_service.h"
34 30
35static int ret; 31static int ret;
36 32
33static int verbose;
34
37static const struct GNUNET_CONFIGURATION_Handle *cfg; 35static const struct GNUNET_CONFIGURATION_Handle *cfg;
38 36
39static struct GNUNET_FS_Handle *ctx; 37static struct GNUNET_FS_Handle *ctx;
40 38
41static struct GNUNET_FS_UnindexContext *uc; 39static struct GNUNET_FS_UnindexContext *uc;
42 40
43static struct GNUNET_TIME_Absolute start_time;
44
45 41
46/** 42/**
47 * Called by FS client to give information about the progress of an 43 * Called by FS client to give information about the progress of an
@@ -60,6 +56,38 @@ static void *
60progress_cb (void *cls, 56progress_cb (void *cls,
61 const struct GNUNET_FS_ProgressInfo *info) 57 const struct GNUNET_FS_ProgressInfo *info)
62{ 58{
59 switch (info->status)
60 {
61 case GNUNET_FS_STATUS_UNINDEX_START:
62 break;
63 case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
64 if (verbose)
65 fprintf (stdout,
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));
70 break;
71 case GNUNET_FS_STATUS_UNINDEX_ERROR:
72 fprintf (stderr,
73 _("Error unindexing: %s.\n"),
74 info->value.unindex.specifics.error.message);
75 GNUNET_FS_unindex_stop (uc);
76 break;
77 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
78 fprintf (stdout,
79 _("Unindexing done.\n"));
80 GNUNET_FS_unindex_stop (uc);
81 break;
82 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
83 GNUNET_FS_stop (ctx);
84 break;
85 default:
86 fprintf (stderr,
87 _("Unexpected status: %d\n"),
88 info->status);
89 break;
90 }
63 return NULL; 91 return NULL;
64} 92}
65 93
@@ -93,7 +121,9 @@ run (void *cls,
93 cfg, 121 cfg,
94 "gnunet-unindex", 122 "gnunet-unindex",
95 &progress_cb, 123 &progress_cb,
96 NULL); 124 NULL,
125 GNUNET_FS_FLAGS_NONE,
126 GNUNET_FS_OPTIONS_END);
97 if (NULL == ctx) 127 if (NULL == ctx)
98 { 128 {
99 fprintf (stderr, 129 fprintf (stderr,
@@ -102,9 +132,14 @@ run (void *cls,
102 ret = 1; 132 ret = 1;
103 return; 133 return;
104 } 134 }
105 start_time = GNUNET_TIME_absolute_get ();
106 uc = GNUNET_FS_unindex (ctx, 135 uc = GNUNET_FS_unindex (ctx,
107 args[0]); 136 args[0]);
137 if (NULL == uc)
138 {
139 fprintf (stderr,
140 _("Could not start unindex operation.\n"));
141 GNUNET_FS_stop (ctx);
142 }
108} 143}
109 144
110 145
@@ -112,6 +147,9 @@ run (void *cls,
112 * gnunet-unindex command line options 147 * gnunet-unindex command line options
113 */ 148 */
114static struct GNUNET_GETOPT_CommandLineOption options[] = { 149static struct GNUNET_GETOPT_CommandLineOption options[] = {
150 {'V', "verbose", NULL,
151 gettext_noop ("be verbose (print progress information)"),
152 0, &GNUNET_GETOPT_set_one, &verbose},
115 GNUNET_GETOPT_OPTION_END 153 GNUNET_GETOPT_OPTION_END
116}; 154};
117 155