aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-unindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-unindex.c')
-rw-r--r--src/fs/gnunet-unindex.c154
1 files changed, 77 insertions, 77 deletions
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index 873dfa5eb..88825fa60 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -40,24 +40,24 @@ static struct GNUNET_FS_UnindexContext *uc;
40 40
41 41
42static void 42static void
43cleanup_task(void *cls) 43cleanup_task (void *cls)
44{ 44{
45 GNUNET_FS_stop(ctx); 45 GNUNET_FS_stop (ctx);
46 ctx = NULL; 46 ctx = NULL;
47} 47}
48 48
49 49
50static void 50static void
51shutdown_task(void *cls) 51shutdown_task (void *cls)
52{ 52{
53 struct GNUNET_FS_UnindexContext *u; 53 struct GNUNET_FS_UnindexContext *u;
54 54
55 if (uc != NULL) 55 if (uc != NULL)
56 { 56 {
57 u = uc; 57 u = uc;
58 uc = NULL; 58 uc = NULL;
59 GNUNET_FS_unindex_stop(u); 59 GNUNET_FS_unindex_stop (u);
60 } 60 }
61} 61}
62 62
63/** 63/**
@@ -74,48 +74,48 @@ shutdown_task(void *cls)
74 * field in the GNUNET_FS_ProgressInfo struct. 74 * field in the GNUNET_FS_ProgressInfo struct.
75 */ 75 */
76static void * 76static void *
77progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info) 77progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
78{ 78{
79 const char *s; 79 const char *s;
80 80
81 switch (info->status) 81 switch (info->status)
82 {
83 case GNUNET_FS_STATUS_UNINDEX_START:
84 break;
85
86 case GNUNET_FS_STATUS_UNINDEX_PROGRESS:
87 if (verbose)
82 { 88 {
83 case GNUNET_FS_STATUS_UNINDEX_START: 89 s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta,
84 break; 90 GNUNET_YES);
85 91 fprintf (stdout,
86 case GNUNET_FS_STATUS_UNINDEX_PROGRESS: 92 _ ("Unindexing at %llu/%llu (%s remaining)\n"),
87 if (verbose) 93 (unsigned long long) info->value.unindex.completed,
88 { 94 (unsigned long long) info->value.unindex.size,
89 s = GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta, 95 s);
90 GNUNET_YES);
91 fprintf(stdout,
92 _("Unindexing at %llu/%llu (%s remaining)\n"),
93 (unsigned long long)info->value.unindex.completed,
94 (unsigned long long)info->value.unindex.size,
95 s);
96 }
97 break;
98
99 case GNUNET_FS_STATUS_UNINDEX_ERROR:
100 fprintf(stderr,
101 _("Error unindexing: %s.\n"),
102 info->value.unindex.specifics.error.message);
103 GNUNET_SCHEDULER_shutdown();
104 break;
105
106 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
107 fprintf(stdout, "%s", _("Unindexing done.\n"));
108 GNUNET_SCHEDULER_shutdown();
109 break;
110
111 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
112 GNUNET_SCHEDULER_add_now(&cleanup_task, NULL);
113 break;
114
115 default:
116 fprintf(stderr, _("Unexpected status: %d\n"), info->status);
117 break;
118 } 96 }
97 break;
98
99 case GNUNET_FS_STATUS_UNINDEX_ERROR:
100 fprintf (stderr,
101 _ ("Error unindexing: %s.\n"),
102 info->value.unindex.specifics.error.message);
103 GNUNET_SCHEDULER_shutdown ();
104 break;
105
106 case GNUNET_FS_STATUS_UNINDEX_COMPLETED:
107 fprintf (stdout, "%s", _ ("Unindexing done.\n"));
108 GNUNET_SCHEDULER_shutdown ();
109 break;
110
111 case GNUNET_FS_STATUS_UNINDEX_STOPPED:
112 GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
113 break;
114
115 default:
116 fprintf (stderr, _ ("Unexpected status: %d\n"), info->status);
117 break;
118 }
119 return NULL; 119 return NULL;
120} 120}
121 121
@@ -129,39 +129,39 @@ progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
129 * @param c configuration 129 * @param c configuration
130 */ 130 */
131static void 131static void
132run(void *cls, 132run (void *cls,
133 char *const *args, 133 char *const *args,
134 const char *cfgfile, 134 const char *cfgfile,
135 const struct GNUNET_CONFIGURATION_Handle *c) 135 const struct GNUNET_CONFIGURATION_Handle *c)
136{ 136{
137 /* check arguments */ 137 /* check arguments */
138 if ((args[0] == NULL) || (args[1] != NULL)) 138 if ((args[0] == NULL) || (args[1] != NULL))
139 { 139 {
140 printf(_("You must specify one and only one filename for unindexing.\n")); 140 printf (_ ("You must specify one and only one filename for unindexing.\n"));
141 ret = -1; 141 ret = -1;
142 return; 142 return;
143 } 143 }
144 cfg = c; 144 cfg = c;
145 ctx = GNUNET_FS_start(cfg, 145 ctx = GNUNET_FS_start (cfg,
146 "gnunet-unindex", 146 "gnunet-unindex",
147 &progress_cb, 147 &progress_cb,
148 NULL, 148 NULL,
149 GNUNET_FS_FLAGS_NONE, 149 GNUNET_FS_FLAGS_NONE,
150 GNUNET_FS_OPTIONS_END); 150 GNUNET_FS_OPTIONS_END);
151 if (NULL == ctx) 151 if (NULL == ctx)
152 { 152 {
153 fprintf(stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); 153 fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS");
154 ret = 1; 154 ret = 1;
155 return; 155 return;
156 } 156 }
157 uc = GNUNET_FS_unindex_start(ctx, args[0], NULL); 157 uc = GNUNET_FS_unindex_start (ctx, args[0], NULL);
158 if (NULL == uc) 158 if (NULL == uc)
159 { 159 {
160 fprintf(stderr, "%s", _("Could not start unindex operation.\n")); 160 fprintf (stderr, "%s", _ ("Could not start unindex operation.\n"));
161 GNUNET_FS_stop(ctx); 161 GNUNET_FS_stop (ctx);
162 return; 162 return;
163 } 163 }
164 GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); 164 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
165} 165}
166 166
167 167
@@ -173,30 +173,30 @@ run(void *cls,
173 * @return 0 ok, 1 on error 173 * @return 0 ok, 1 on error
174 */ 174 */
175int 175int
176main(int argc, char *const *argv) 176main (int argc, char *const *argv)
177{ 177{
178 struct GNUNET_GETOPT_CommandLineOption options[] = { 178 struct GNUNET_GETOPT_CommandLineOption options[] = {
179 GNUNET_GETOPT_option_verbose(&verbose), 179 GNUNET_GETOPT_option_verbose (&verbose),
180 180
181 GNUNET_GETOPT_OPTION_END 181 GNUNET_GETOPT_OPTION_END
182 }; 182 };
183 183
184 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) 184 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
185 return 2; 185 return 2;
186 186
187 ret = (GNUNET_OK == 187 ret = (GNUNET_OK ==
188 GNUNET_PROGRAM_run( 188 GNUNET_PROGRAM_run (
189 argc, 189 argc,
190 argv, 190 argv,
191 "gnunet-unindex [OPTIONS] FILENAME", 191 "gnunet-unindex [OPTIONS] FILENAME",
192 gettext_noop( 192 gettext_noop (
193 "Unindex a file that was previously indexed with gnunet-publish."), 193 "Unindex a file that was previously indexed with gnunet-publish."),
194 options, 194 options,
195 &run, 195 &run,
196 NULL)) 196 NULL))
197 ? ret 197 ? ret
198 : 1; 198 : 1;
199 GNUNET_free((void *)argv); 199 GNUNET_free ((void *) argv);
200 return ret; 200 return ret;
201} 201}
202 202