progressbar.h revision 1.4 1 1.4 hubertf /* $NetBSD: progressbar.h,v 1.4 2004/03/09 17:04:24 hubertf Exp $ */
2 1.1 jhawk
3 1.1 jhawk /*-
4 1.3 lukem * Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
5 1.1 jhawk * All rights reserved.
6 1.1 jhawk *
7 1.1 jhawk * This code is derived from software contributed to The NetBSD Foundation
8 1.1 jhawk * by Luke Mewburn.
9 1.1 jhawk *
10 1.1 jhawk * Redistribution and use in source and binary forms, with or without
11 1.1 jhawk * modification, are permitted provided that the following conditions
12 1.1 jhawk * are met:
13 1.1 jhawk * 1. Redistributions of source code must retain the above copyright
14 1.1 jhawk * notice, this list of conditions and the following disclaimer.
15 1.1 jhawk * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 jhawk * notice, this list of conditions and the following disclaimer in the
17 1.1 jhawk * documentation and/or other materials provided with the distribution.
18 1.1 jhawk * 3. All advertising materials mentioning features or use of this software
19 1.1 jhawk * must display the following acknowledgement:
20 1.1 jhawk * This product includes software developed by the NetBSD
21 1.1 jhawk * Foundation, Inc. and its contributors.
22 1.1 jhawk * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 jhawk * contributors may be used to endorse or promote products derived
24 1.1 jhawk * from this software without specific prior written permission.
25 1.1 jhawk *
26 1.1 jhawk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 jhawk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 jhawk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 jhawk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 jhawk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 jhawk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 jhawk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 jhawk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 jhawk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 jhawk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 jhawk * POSSIBILITY OF SUCH DAMAGE.
37 1.1 jhawk */
38 1.1 jhawk
39 1.1 jhawk #ifndef STANDALONE_PROGRESS
40 1.1 jhawk #include <setjmp.h>
41 1.1 jhawk #endif /* !STANDALONE_PROGRESS */
42 1.1 jhawk
43 1.1 jhawk #ifndef GLOBAL
44 1.1 jhawk #define GLOBAL extern
45 1.1 jhawk #endif
46 1.1 jhawk
47 1.1 jhawk
48 1.1 jhawk #define STALLTIME 5 /* # of seconds of no xfer before "stalling" */
49 1.1 jhawk
50 1.1 jhawk typedef void (*sigfunc)(int);
51 1.1 jhawk
52 1.1 jhawk
53 1.1 jhawk GLOBAL FILE *ttyout; /* stdout, or stderr if retrieving to stdout */
54 1.1 jhawk
55 1.1 jhawk GLOBAL int progress; /* display transfer progress bar */
56 1.1 jhawk GLOBAL int ttywidth; /* width of tty */
57 1.1 jhawk
58 1.1 jhawk GLOBAL off_t bytes; /* current # of bytes read */
59 1.1 jhawk GLOBAL off_t filesize; /* size of file being transferred */
60 1.1 jhawk GLOBAL off_t restart_point; /* offset to restart transfer */
61 1.4 hubertf GLOBAL char *prefix; /* Text written left of progress bar */
62 1.1 jhawk
63 1.1 jhawk
64 1.1 jhawk #ifndef STANDALONE_PROGRESS
65 1.1 jhawk GLOBAL int fromatty; /* input is from a terminal */
66 1.1 jhawk GLOBAL int verbose; /* print messages coming back from server */
67 1.1 jhawk GLOBAL int quit_time; /* maximum time to wait if stalled */
68 1.1 jhawk
69 1.1 jhawk GLOBAL char *direction; /* direction transfer is occurring */
70 1.1 jhawk
71 1.1 jhawk GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */
72 1.1 jhawk #endif /* !STANDALONE_PROGRESS */
73 1.1 jhawk
74 1.2 grant int foregroundproc(void);
75 1.1 jhawk void alarmtimer(int);
76 1.1 jhawk void progressmeter(int);
77 1.1 jhawk sigfunc xsignal(int, sigfunc);
78 1.1 jhawk sigfunc xsignal_restart(int, sigfunc, int);
79 1.1 jhawk
80 1.1 jhawk #ifndef STANDALONE_PROGRESS
81 1.1 jhawk void psummary(int);
82 1.1 jhawk void ptransfer(int);
83 1.1 jhawk #endif /* !STANDALONE_PROGRESS */
84 1.1 jhawk
85 1.1 jhawk
86 1.1 jhawk #ifdef NO_LONG_LONG
87 1.1 jhawk # define LLF "%ld"
88 1.1 jhawk # define LLFP(x) "%" x "ld"
89 1.1 jhawk # define LLT long
90 1.1 jhawk # define ULLF "%lu"
91 1.1 jhawk # define ULLFP(x) "%" x "lu"
92 1.1 jhawk # define ULLT unsigned long
93 1.1 jhawk #else
94 1.1 jhawk # define LLF "%lld"
95 1.1 jhawk # define LLFP(x) "%" x "lld"
96 1.1 jhawk # define LLT long long
97 1.1 jhawk # define ULLF "%llu"
98 1.1 jhawk # define ULLFP(x) "%" x "llu"
99 1.1 jhawk # define ULLT unsigned long long
100 1.1 jhawk #endif
101