diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/fs/gnunet-unindex.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/fs/gnunet-unindex.c')
-rw-r--r-- | src/fs/gnunet-unindex.c | 161 |
1 files changed, 83 insertions, 78 deletions
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c index 4d13e7ef3..873dfa5eb 100644 --- a/src/fs/gnunet-unindex.c +++ b/src/fs/gnunet-unindex.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file fs/gnunet-unindex.c | 21 | * @file fs/gnunet-unindex.c |
22 | * @brief unindex files published on GNUnet | 22 | * @brief unindex files published on GNUnet |
@@ -40,24 +40,24 @@ static struct GNUNET_FS_UnindexContext *uc; | |||
40 | 40 | ||
41 | 41 | ||
42 | static void | 42 | static void |
43 | cleanup_task (void *cls) | 43 | cleanup_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 | ||
50 | static void | 50 | static void |
51 | shutdown_task (void *cls) | 51 | shutdown_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,43 +74,48 @@ shutdown_task (void *cls) | |||
74 | * field in the GNUNET_FS_ProgressInfo struct. | 74 | * field in the GNUNET_FS_ProgressInfo struct. |
75 | */ | 75 | */ |
76 | static void * | 76 | static void * |
77 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | 77 | progress_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 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | ||
86 | if (verbose) | ||
87 | { | 82 | { |
88 | s = GNUNET_STRINGS_relative_time_to_string (info->value.unindex.eta, | 83 | case GNUNET_FS_STATUS_UNINDEX_START: |
89 | GNUNET_YES); | 84 | break; |
90 | fprintf (stdout, | 85 | |
91 | _ ("Unindexing at %llu/%llu (%s remaining)\n"), | 86 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: |
92 | (unsigned long long) info->value.unindex.completed, | 87 | if (verbose) |
93 | (unsigned long long) info->value.unindex.size, | 88 | { |
94 | s); | 89 | s = GNUNET_STRINGS_relative_time_to_string(info->value.unindex.eta, |
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; | ||
95 | } | 118 | } |
96 | break; | ||
97 | case GNUNET_FS_STATUS_UNINDEX_ERROR: | ||
98 | fprintf (stderr, | ||
99 | _ ("Error unindexing: %s.\n"), | ||
100 | info->value.unindex.specifics.error.message); | ||
101 | GNUNET_SCHEDULER_shutdown (); | ||
102 | break; | ||
103 | case GNUNET_FS_STATUS_UNINDEX_COMPLETED: | ||
104 | fprintf (stdout, "%s", _ ("Unindexing done.\n")); | ||
105 | GNUNET_SCHEDULER_shutdown (); | ||
106 | break; | ||
107 | case GNUNET_FS_STATUS_UNINDEX_STOPPED: | ||
108 | GNUNET_SCHEDULER_add_now (&cleanup_task, NULL); | ||
109 | break; | ||
110 | default: | ||
111 | fprintf (stderr, _ ("Unexpected status: %d\n"), info->status); | ||
112 | break; | ||
113 | } | ||
114 | return NULL; | 119 | return NULL; |
115 | } | 120 | } |
116 | 121 | ||
@@ -124,39 +129,39 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
124 | * @param c configuration | 129 | * @param c configuration |
125 | */ | 130 | */ |
126 | static void | 131 | static void |
127 | run (void *cls, | 132 | run(void *cls, |
128 | char *const *args, | 133 | char *const *args, |
129 | const char *cfgfile, | 134 | const char *cfgfile, |
130 | const struct GNUNET_CONFIGURATION_Handle *c) | 135 | const struct GNUNET_CONFIGURATION_Handle *c) |
131 | { | 136 | { |
132 | /* check arguments */ | 137 | /* check arguments */ |
133 | if ((args[0] == NULL) || (args[1] != NULL)) | 138 | if ((args[0] == NULL) || (args[1] != NULL)) |
134 | { | 139 | { |
135 | 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")); |
136 | ret = -1; | 141 | ret = -1; |
137 | return; | 142 | return; |
138 | } | 143 | } |
139 | cfg = c; | 144 | cfg = c; |
140 | ctx = GNUNET_FS_start (cfg, | 145 | ctx = GNUNET_FS_start(cfg, |
141 | "gnunet-unindex", | 146 | "gnunet-unindex", |
142 | &progress_cb, | 147 | &progress_cb, |
143 | NULL, | 148 | NULL, |
144 | GNUNET_FS_FLAGS_NONE, | 149 | GNUNET_FS_FLAGS_NONE, |
145 | GNUNET_FS_OPTIONS_END); | 150 | GNUNET_FS_OPTIONS_END); |
146 | if (NULL == ctx) | 151 | if (NULL == ctx) |
147 | { | 152 | { |
148 | fprintf (stderr, _ ("Could not initialize `%s' subsystem.\n"), "FS"); | 153 | fprintf(stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); |
149 | ret = 1; | 154 | ret = 1; |
150 | return; | 155 | return; |
151 | } | 156 | } |
152 | uc = GNUNET_FS_unindex_start (ctx, args[0], NULL); | 157 | uc = GNUNET_FS_unindex_start(ctx, args[0], NULL); |
153 | if (NULL == uc) | 158 | if (NULL == uc) |
154 | { | 159 | { |
155 | fprintf (stderr, "%s", _ ("Could not start unindex operation.\n")); | 160 | fprintf(stderr, "%s", _("Could not start unindex operation.\n")); |
156 | GNUNET_FS_stop (ctx); | 161 | GNUNET_FS_stop(ctx); |
157 | return; | 162 | return; |
158 | } | 163 | } |
159 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 164 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, NULL); |
160 | } | 165 | } |
161 | 166 | ||
162 | 167 | ||
@@ -168,30 +173,30 @@ run (void *cls, | |||
168 | * @return 0 ok, 1 on error | 173 | * @return 0 ok, 1 on error |
169 | */ | 174 | */ |
170 | int | 175 | int |
171 | main (int argc, char *const *argv) | 176 | main(int argc, char *const *argv) |
172 | { | 177 | { |
173 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 178 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
179 | GNUNET_GETOPT_option_verbose(&verbose), | ||
174 | 180 | ||
175 | GNUNET_GETOPT_option_verbose (&verbose), | 181 | GNUNET_GETOPT_OPTION_END |
176 | 182 | }; | |
177 | GNUNET_GETOPT_OPTION_END}; | ||
178 | 183 | ||
179 | 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)) |
180 | return 2; | 185 | return 2; |
181 | 186 | ||
182 | ret = (GNUNET_OK == | 187 | ret = (GNUNET_OK == |
183 | GNUNET_PROGRAM_run ( | 188 | GNUNET_PROGRAM_run( |
184 | argc, | 189 | argc, |
185 | argv, | 190 | argv, |
186 | "gnunet-unindex [OPTIONS] FILENAME", | 191 | "gnunet-unindex [OPTIONS] FILENAME", |
187 | gettext_noop ( | 192 | gettext_noop( |
188 | "Unindex a file that was previously indexed with gnunet-publish."), | 193 | "Unindex a file that was previously indexed with gnunet-publish."), |
189 | options, | 194 | options, |
190 | &run, | 195 | &run, |
191 | NULL)) | 196 | NULL)) |
192 | ? ret | 197 | ? ret |
193 | : 1; | 198 | : 1; |
194 | GNUNET_free ((void *) argv); | 199 | GNUNET_free((void *)argv); |
195 | return ret; | 200 | return ret; |
196 | } | 201 | } |
197 | 202 | ||