diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/fs/gnunet-download.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/gnunet-download.c')
-rw-r--r-- | src/fs/gnunet-download.c | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c index fc0b768d9..9f18cb99c 100644 --- a/src/fs/gnunet-download.c +++ b/src/fs/gnunet-download.c | |||
@@ -97,8 +97,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
97 | { | 97 | { |
98 | case GNUNET_FS_STATUS_DOWNLOAD_START: | 98 | case GNUNET_FS_STATUS_DOWNLOAD_START: |
99 | if (verbose > 1) | 99 | if (verbose > 1) |
100 | fprintf (stderr, | 100 | fprintf (stderr, _("Starting download `%s'.\n"), |
101 | _("Starting download `%s'.\n"), info->value.download.filename); | 101 | info->value.download.filename); |
102 | break; | 102 | break; |
103 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | 103 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: |
104 | if (verbose) | 104 | if (verbose) |
@@ -106,8 +106,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
106 | s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta); | 106 | s = GNUNET_STRINGS_relative_time_to_string (info->value.download.eta); |
107 | t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * | 107 | t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * |
108 | 1000LL / | 108 | 1000LL / |
109 | (info->value.download. | 109 | (info->value.download.duration. |
110 | duration.rel_value + 1)); | 110 | rel_value + 1)); |
111 | fprintf (stdout, | 111 | fprintf (stdout, |
112 | _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"), | 112 | _("Downloading `%s' at %llu/%llu (%s remaining, %s/s)\n"), |
113 | info->value.download.filename, | 113 | info->value.download.filename, |
@@ -118,15 +118,14 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
118 | } | 118 | } |
119 | break; | 119 | break; |
120 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: | 120 | case GNUNET_FS_STATUS_DOWNLOAD_ERROR: |
121 | fprintf (stderr, | 121 | fprintf (stderr, _("Error downloading: %s.\n"), |
122 | _("Error downloading: %s.\n"), | ||
123 | info->value.download.specifics.error.message); | 122 | info->value.download.specifics.error.message); |
124 | GNUNET_SCHEDULER_shutdown (); | 123 | GNUNET_SCHEDULER_shutdown (); |
125 | break; | 124 | break; |
126 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: | 125 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: |
127 | s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 / | 126 | s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 / |
128 | (info->value.download. | 127 | (info->value.download.duration. |
129 | duration.rel_value + 1)); | 128 | rel_value + 1)); |
130 | fprintf (stdout, _("Downloading `%s' done (%s/s).\n"), | 129 | fprintf (stdout, _("Downloading `%s' done (%s/s).\n"), |
131 | info->value.download.filename, s); | 130 | info->value.download.filename, s); |
132 | GNUNET_free (s); | 131 | GNUNET_free (s); |
@@ -135,8 +134,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
135 | break; | 134 | break; |
136 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | 135 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: |
137 | if (info->value.download.dc == dc) | 136 | if (info->value.download.dc == dc) |
138 | GNUNET_SCHEDULER_add_continuation (&cleanup_task, | 137 | GNUNET_SCHEDULER_add_continuation (&cleanup_task, NULL, |
139 | NULL, | ||
140 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 138 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
141 | break; | 139 | break; |
142 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | 140 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: |
@@ -159,9 +157,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
159 | * @param c configuration | 157 | * @param c configuration |
160 | */ | 158 | */ |
161 | static void | 159 | static void |
162 | run (void *cls, | 160 | run (void *cls, char *const *args, const char *cfgfile, |
163 | char *const *args, | 161 | const struct GNUNET_CONFIGURATION_Handle *c) |
164 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
165 | { | 162 | { |
166 | struct GNUNET_FS_Uri *uri; | 163 | struct GNUNET_FS_Uri *uri; |
167 | char *emsg; | 164 | char *emsg; |
@@ -195,15 +192,12 @@ run (void *cls, | |||
195 | return; | 192 | return; |
196 | } | 193 | } |
197 | cfg = c; | 194 | cfg = c; |
198 | ctx = GNUNET_FS_start (cfg, | 195 | ctx = |
199 | "gnunet-download", | 196 | GNUNET_FS_start (cfg, "gnunet-download", &progress_cb, NULL, |
200 | &progress_cb, | 197 | GNUNET_FS_FLAGS_NONE, |
201 | NULL, | 198 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, parallelism, |
202 | GNUNET_FS_FLAGS_NONE, | 199 | GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, |
203 | GNUNET_FS_OPTIONS_DOWNLOAD_PARALLELISM, | 200 | request_parallelism, GNUNET_FS_OPTIONS_END); |
204 | parallelism, | ||
205 | GNUNET_FS_OPTIONS_REQUEST_PARALLELISM, | ||
206 | request_parallelism, GNUNET_FS_OPTIONS_END); | ||
207 | if (NULL == ctx) | 201 | if (NULL == ctx) |
208 | { | 202 | { |
209 | fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); | 203 | fprintf (stderr, _("Could not initialize `%s' subsystem.\n"), "FS"); |
@@ -216,11 +210,7 @@ run (void *cls, | |||
216 | options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; | 210 | options |= GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE; |
217 | if (local_only) | 211 | if (local_only) |
218 | options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY; | 212 | options |= GNUNET_FS_DOWNLOAD_OPTION_LOOPBACK_ONLY; |
219 | dc = GNUNET_FS_download_start (ctx, | 213 | dc = GNUNET_FS_download_start (ctx, uri, NULL, filename, NULL, 0, |
220 | uri, | ||
221 | NULL, | ||
222 | filename, NULL, | ||
223 | 0, | ||
224 | GNUNET_FS_uri_chk_get_file_size (uri), | 214 | GNUNET_FS_uri_chk_get_file_size (uri), |
225 | anonymity, options, NULL, NULL); | 215 | anonymity, options, NULL, NULL); |
226 | GNUNET_FS_uri_destroy (uri); | 216 | GNUNET_FS_uri_destroy (uri); |
@@ -230,8 +220,8 @@ run (void *cls, | |||
230 | ctx = NULL; | 220 | ctx = NULL; |
231 | return; | 221 | return; |
232 | } | 222 | } |
233 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 223 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
234 | &shutdown_task, NULL); | 224 | NULL); |
235 | } | 225 | } |
236 | 226 | ||
237 | 227 | ||
@@ -275,9 +265,7 @@ main (int argc, char *const *argv) | |||
275 | GNUNET_GETOPT_OPTION_END | 265 | GNUNET_GETOPT_OPTION_END |
276 | }; | 266 | }; |
277 | return (GNUNET_OK == | 267 | return (GNUNET_OK == |
278 | GNUNET_PROGRAM_run (argc, | 268 | GNUNET_PROGRAM_run (argc, argv, "gnunet-download [OPTIONS] URI", |
279 | argv, | ||
280 | "gnunet-download [OPTIONS] URI", | ||
281 | gettext_noop | 269 | gettext_noop |
282 | ("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"), | 270 | ("Download files from GNUnet using a GNUnet CHK or LOC URI (gnunet://fs/chk/...)"), |
283 | options, &run, NULL)) ? ret : 1; | 271 | options, &run, NULL)) ? ret : 1; |