1 /* $NetBSD: progressbar.h,v 1.9 2009/05/20 12:53:47 lukem Exp $ */
2 /* from NetBSD: progressbar.h,v 1.8 2009/04/12 10:18:52 lukem Exp */
5 * Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
8 * This code is derived from software contributed to The NetBSD Foundation
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef STANDALONE_PROGRESS
35 #endif /* !STANDALONE_PROGRESS */
42 #define STALLTIME 5 /* # of seconds of no xfer before "stalling" */
44 typedef void (*sigfunc)(int);
47 GLOBAL FILE *ttyout; /* stdout, or stderr if retrieving to stdout */
49 GLOBAL int progress; /* display transfer progress bar */
50 GLOBAL int ttywidth; /* width of tty */
52 GLOBAL off_t bytes; /* current # of bytes read */
53 GLOBAL off_t filesize; /* size of file being transferred */
54 GLOBAL off_t restart_point; /* offset to restart transfer */
55 GLOBAL char *prefix; /* Text written left of progress bar */
58 #ifndef STANDALONE_PROGRESS
59 GLOBAL int fromatty; /* input is from a terminal */
60 GLOBAL int verbose; /* print messages coming back from server */
61 GLOBAL int quit_time; /* maximum time to wait if stalled */
63 GLOBAL const char *direction; /* direction transfer is occurring */
65 GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */
66 #endif /* !STANDALONE_PROGRESS */
68 int foregroundproc(void);
70 void progressmeter(int);
71 sigfunc xsignal(int, sigfunc);
72 sigfunc xsignal_restart(int, sigfunc, int);
74 #ifndef STANDALONE_PROGRESS
77 #endif /* !STANDALONE_PROGRESS */
81 # define LLFP(x) "%" x "ld"
84 # define ULLFP(x) "%" x "lu"
85 # define ULLT unsigned long
87 #if defined(HAVE_PRINTF_QD)
89 # define LLFP(x) "%" x "qd"
90 # define LLT long long
92 # define ULLFP(x) "%" x "qu"
93 # define ULLT unsigned long long
94 #else /* !defined(HAVE_PRINTF_QD) */
96 # define LLFP(x) "%" x "lld"
97 # define LLT long long
99 # define ULLFP(x) "%" x "llu"
100 # define ULLT unsigned long long
101 #endif /* !defined(HAVE_PRINTF_QD) */