diff options
author | ng0 <ng0@n0.is> | 2019-09-06 22:46:29 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-06 22:46:29 +0000 |
commit | 6e599264ad13e8fc105493d74d7c11d46f8739ed (patch) | |
tree | 169bef1ecbade5a659831fb169f3ae6943af127f /src/fs/gnunet-unindex.c | |
parent | 4f13bc15113021ebf71d5d81e99bc29f8a07fc9c (diff) | |
download | gnunet-6e599264ad13e8fc105493d74d7c11d46f8739ed.tar.gz gnunet-6e599264ad13e8fc105493d74d7c11d46f8739ed.zip |
first step to remove plibc
Diffstat (limited to 'src/fs/gnunet-unindex.c')
-rw-r--r-- | src/fs/gnunet-unindex.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index f9a3f8f3a..4d13e7ef3 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c | |||
@@ -85,26 +85,30 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
85 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | 85 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: |
86 | if (verbose) | 86 | if (verbose) |
87 | { | 87 | { |
88 | s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta, GNUNET_YES); | 88 | s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta, |
89 | FPRINTF (stdout, _("Unindexing at %llu/%llu (%s remaining)\n"), | 89 | GNUNET_YES); |
90 | fprintf (stdout, | ||
91 | _ ("Unindexing at %llu/%llu (%s remaining)\n"), | ||
90 | (unsigned long long) info->value.unindex.completed, | 92 | (unsigned long long) info->value.unindex.completed, |
91 | (unsigned long long) info->value.unindex.size, s); | 93 | (unsigned long long) info->value.unindex.size, |
94 | s); | ||
92 | } | 95 | } |
93 | break; | 96 | break; |
94 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | 97 | case GNUNET_FS_STATUS_UNINDEX_ERROR: |
95 | FPRINTF (stderr, _("Error unindexing: %s.\n"), | 98 | fprintf (stderr, |
99 | _ ("Error unindexing: %s.\n"), | ||
96 | info->value.unindex.specifics.error.message); | 100 | info->value.unindex.specifics.error.message); |
97 | GNUNET_SCHEDULER_shutdown (); | 101 | GNUNET_SCHEDULER_shutdown (); |
98 | break; | 102 | break; |
99 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | 103 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: |
100 | FPRINTF (stdout, "%s", _("Unindexing done.\n")); | 104 | fprintf (stdout, "%s", _ ("Unindexing done.\n")); |
101 | GNUNET_SCHEDULER_shutdown (); | 105 | GNUNET_SCHEDULER_shutdown (); |
102 | break; | 106 | break; |
103 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | 107 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: |
104 | GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); | 108 | GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); |
105 | break; | 109 | break; |
106 | default: | 110 | default: |
107 | FPRINTF (stderr, _("Unexpected status: %d\n"), info->status); | 111 | fprintf (stderr, _ ("Unexpected status: %d\n"), info->status); |
108 | break; | 112 | break; |
109 | } | 113 | } |
110 | return NULL; | 114 | return NULL; |
@@ -120,35 +124,39 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
120 | * @param c configuration | 124 | * @param c configuration |
121 | */ | 125 | */ |
122 | static void | 126 | static void |
123 | run (void *cls, char *const *args, const char *cfgfile, | 127 | run (void *cls, |
128 | char *const *args, | ||
129 | const char *cfgfile, | ||
124 | const struct GNUNET_CONFIGURATION_Handle *c) | 130 | const struct GNUNET_CONFIGURATION_Handle *c) |
125 | { | 131 | { |
126 | /* check arguments */ | 132 | /* check arguments */ |
127 | if ((args[0] == NULL) || (args[1] != NULL)) | 133 | if ((args[0] == NULL) || (args[1] != NULL)) |
128 | { | 134 | { |
129 | printf (_("You must specify one and only one filename for unindexing.\n")); | 135 | printf (_ ("You must specify one and only one filename for unindexing.\n")); |
130 | ret = -1; | 136 | ret = -1; |
131 | return; | 137 | return; |
132 | } | 138 | } |
133 | cfg = c; | 139 | cfg = c; |
134 | ctx = | 140 | ctx = GNUNET_FS_start (cfg, |
135 | GNUNET_FS_start (cfg, "gnunet-unindex", &progress_cb, NULL, | 141 | "gnunet-unindex", |
136 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 142 | &progress_cb, |
143 | NULL, | ||
144 | GNUNET_FS_FLAGS_NONE, | ||
145 | GNUNET_FS_OPTIONS_END); | ||
137 | if (NULL == ctx) | 146 | if (NULL == ctx) |
138 | { | 147 | { |
139 | FPRINTF (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); | 148 | fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS"); |
140 | ret = 1; | 149 | ret = 1; |
141 | return; | 150 | return; |
142 | } | 151 | } |
143 | uc = GNUNET_FS_unindex_start (ctx, args[0], NULL); | 152 | uc = GNUNET_FS_unindex_start (ctx, args[0], NULL); |
144 | if (NULL == uc) | 153 | if (NULL == uc) |
145 | { | 154 | { |
146 | FPRINTF (stderr, "%s", _("Could not start unindex operation.\n")); | 155 | fprintf (stderr, "%s", _ ("Could not start unindex operation.\n")); |
147 | GNUNET_FS_stop (ctx); | 156 | GNUNET_FS_stop (ctx); |
148 | return; | 157 | return; |
149 | } | 158 | } |
150 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 159 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
151 | NULL); | ||
152 | } | 160 | } |
153 | 161 | ||
154 | 162 | ||
@@ -166,18 +174,24 @@ main (int argc, char *const *argv) | |||
166 | 174 | ||
167 | GNUNET_GETOPT_option_verbose (&verbose), | 175 | GNUNET_GETOPT_option_verbose (&verbose), |
168 | 176 | ||
169 | GNUNET_GETOPT_OPTION_END | 177 | GNUNET_GETOPT_OPTION_END}; |
170 | }; | ||
171 | 178 | ||
172 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 179 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
173 | return 2; | 180 | return 2; |
174 | 181 | ||
175 | ret = (GNUNET_OK == | 182 | ret = (GNUNET_OK == |
176 | GNUNET_PROGRAM_run (argc, argv, "gnunet-unindex [OPTIONS] FILENAME", | 183 | GNUNET_PROGRAM_run ( |
177 | gettext_noop | 184 | argc, |
178 | ("Unindex a file that was previously indexed with gnunet-publish."), | 185 | argv, |
179 | options, &run, NULL)) ? ret : 1; | 186 | "gnunet-unindex [OPTIONS] FILENAME", |
180 | GNUNET_free ((void*) argv); | 187 | gettext_noop ( |
188 | "Unindex a file that was previously indexed with gnunet-publish."), | ||
189 | options, | ||
190 | &run, | ||
191 | NULL)) | ||
192 | ? ret | ||
193 | : 1; | ||
194 | GNUNET_free ((void *) argv); | ||
181 | return ret; | 195 | return ret; |
182 | } | 196 | } |
183 | 197 | ||