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