diff options
author | Colin Watson <cjwatson@debian.org> | 2003-09-01 18:52:37 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2003-09-01 18:52:37 +0000 |
commit | 854156dd39acbde9b4a47ec0fc54a042ea7358e0 (patch) | |
tree | 96755f8590acc2146f4b4ef5b5cdba600e5d9353 /progressmeter.c | |
parent | fad82e8999e790899083f9e22a1841148d746df6 (diff) | |
parent | 053db7da5ce09acdf742789d9d1a05e81d4861d0 (diff) |
Import OpenSSH 3.6.1p2.
Diffstat (limited to 'progressmeter.c')
-rw-r--r-- | progressmeter.c | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/progressmeter.c b/progressmeter.c index 343e1b7d5..90eb97f37 100644 --- a/progressmeter.c +++ b/progressmeter.c | |||
@@ -24,15 +24,10 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | /* | 26 | /* |
27 | * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. | 27 | * Parts from: |
28 | * All rights reserved. | ||
29 | * | 28 | * |
30 | * This code is derived from software contributed to The NetBSD Foundation | 29 | * Copyright (c) 1983, 1990, 1992, 1993, 1995 |
31 | * by Luke Mewburn. | 30 | * The Regents of the University of California. All rights reserved. |
32 | * | ||
33 | * This code is derived from software contributed to The NetBSD Foundation | ||
34 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | ||
35 | * NASA Ames Research Center. | ||
36 | * | 31 | * |
37 | * Redistribution and use in source and binary forms, with or without | 32 | * Redistribution and use in source and binary forms, with or without |
38 | * modification, are permitted provided that the following conditions | 33 | * modification, are permitted provided that the following conditions |
@@ -44,27 +39,28 @@ | |||
44 | * documentation and/or other materials provided with the distribution. | 39 | * documentation and/or other materials provided with the distribution. |
45 | * 3. All advertising materials mentioning features or use of this software | 40 | * 3. All advertising materials mentioning features or use of this software |
46 | * must display the following acknowledgement: | 41 | * must display the following acknowledgement: |
47 | * This product includes software developed by the NetBSD | 42 | * This product includes software developed by the University of |
48 | * Foundation, Inc. and its contributors. | 43 | * California, Berkeley and its contributors. |
49 | * 4. Neither the name of The NetBSD Foundation nor the names of its | 44 | * 4. Neither the name of the University nor the names of its contributors |
50 | * contributors may be used to endorse or promote products derived | 45 | * may be used to endorse or promote products derived from this software |
51 | * from this software without specific prior written permission. | 46 | * without specific prior written permission. |
47 | * | ||
48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
58 | * SUCH DAMAGE. | ||
52 | * | 59 | * |
53 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | ||
54 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | ||
55 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
56 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | ||
57 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
58 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
59 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
60 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
61 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
62 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
63 | * POSSIBILITY OF SUCH DAMAGE. | ||
64 | */ | 60 | */ |
65 | 61 | ||
66 | #include "includes.h" | 62 | #include "includes.h" |
67 | RCSID("$OpenBSD: progressmeter.c,v 1.6 2003/04/07 21:58:05 millert Exp $"); | 63 | RCSID("$OpenBSD: progressmeter.c,v 1.3 2003/03/17 10:38:38 markus Exp $"); |
68 | 64 | ||
69 | #ifdef HAVE_LIBGEN_H | 65 | #ifdef HAVE_LIBGEN_H |
70 | #include <libgen.h> | 66 | #include <libgen.h> |
@@ -215,19 +211,36 @@ draw_progress_meter() | |||
215 | 211 | ||
216 | nspaces = MIN(get_tty_width() - 79, sizeof(spaces) - 1); | 212 | nspaces = MIN(get_tty_width() - 79, sizeof(spaces) - 1); |
217 | 213 | ||
214 | #ifdef HAVE_LONG_LONG_INT | ||
218 | snprintf(buf, sizeof(buf), | 215 | snprintf(buf, sizeof(buf), |
219 | "\r%-45.45s%.*s%3d%% %4lld%c%c %3lld.%01d%cB/s", | 216 | "\r%-45.45s%.*s%3d%% %4lld%c%c %3lld.%01d%cB/s", |
220 | curfile, | 217 | curfile, |
221 | nspaces, | 218 | nspaces, |
222 | spaces, | 219 | spaces, |
223 | ratio, | 220 | ratio, |
224 | (int64_t)abbrevsize, | 221 | (long long)abbrevsize, |
222 | prefixes[ai], | ||
223 | ai == 0 ? ' ' : 'B', | ||
224 | (long long)(bytespersec / 1024), | ||
225 | (int)((bytespersec % 1024) * 10 / 1024), | ||
226 | prefixes[bi] | ||
227 | ); | ||
228 | #else | ||
229 | /* XXX: Handle integer overflow? */ | ||
230 | snprintf(buf, sizeof(buf), | ||
231 | "\r%-45.45s%.*s%3d%% %4lu%c%c %3lu.%01d%cB/s", | ||
232 | curfile, | ||
233 | nspaces, | ||
234 | spaces, | ||
235 | ratio, | ||
236 | (u_long)abbrevsize, | ||
225 | prefixes[ai], | 237 | prefixes[ai], |
226 | ai == 0 ? ' ' : 'B', | 238 | ai == 0 ? ' ' : 'B', |
227 | (int64_t)(bytespersec / 1024), | 239 | (u_long)(bytespersec / 1024), |
228 | (int)((bytespersec % 1024) * 10 / 1024), | 240 | (int)((bytespersec % 1024) * 10 / 1024), |
229 | prefixes[bi] | 241 | prefixes[bi] |
230 | ); | 242 | ); |
243 | #endif | ||
231 | 244 | ||
232 | if (cursize <= 0 || elapsed <= 0.0 || cursize > totalbytes) { | 245 | if (cursize <= 0 || elapsed <= 0.0 || cursize > totalbytes) { |
233 | snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), | 246 | snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), |