Home | History | Annotate | Line # | Download | only in ftp
      1  1.9    lukem /*	$NetBSD: progressbar.h,v 1.9 2021/01/06 04:43:14 lukem Exp $	*/
      2  1.1    jhawk 
      3  1.1    jhawk /*-
      4  1.9    lukem  * Copyright (c) 1996-2021 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  *
     19  1.1    jhawk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1    jhawk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1    jhawk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1    jhawk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1    jhawk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1    jhawk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1    jhawk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1    jhawk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1    jhawk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1    jhawk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1    jhawk  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1    jhawk  */
     31  1.1    jhawk 
     32  1.1    jhawk #ifndef STANDALONE_PROGRESS
     33  1.1    jhawk #include <setjmp.h>
     34  1.1    jhawk #endif	/* !STANDALONE_PROGRESS */
     35  1.1    jhawk 
     36  1.1    jhawk #ifndef	GLOBAL
     37  1.1    jhawk #define	GLOBAL	extern
     38  1.1    jhawk #endif
     39  1.1    jhawk 
     40  1.1    jhawk 
     41  1.1    jhawk #define	STALLTIME	5	/* # of seconds of no xfer before "stalling" */
     42  1.1    jhawk 
     43  1.1    jhawk typedef void (*sigfunc)(int);
     44  1.1    jhawk 
     45  1.1    jhawk 
     46  1.1    jhawk GLOBAL	FILE   *ttyout;		/* stdout, or stderr if retrieving to stdout */
     47  1.1    jhawk 
     48  1.1    jhawk GLOBAL	int	progress;	/* display transfer progress bar */
     49  1.1    jhawk GLOBAL	int	ttywidth;	/* width of tty */
     50  1.1    jhawk 
     51  1.1    jhawk GLOBAL	off_t	bytes;		/* current # of bytes read */
     52  1.1    jhawk GLOBAL	off_t	filesize;	/* size of file being transferred */
     53  1.1    jhawk GLOBAL	off_t	restart_point;	/* offset to restart transfer */
     54  1.4  hubertf GLOBAL	char   *prefix;		/* Text written left of progress bar */
     55  1.1    jhawk 
     56  1.1    jhawk 
     57  1.1    jhawk #ifndef	STANDALONE_PROGRESS
     58  1.1    jhawk GLOBAL	int	fromatty;	/* input is from a terminal */
     59  1.1    jhawk GLOBAL	int	verbose;	/* print messages coming back from server */
     60  1.1    jhawk GLOBAL	int	quit_time;	/* maximum time to wait if stalled */
     61  1.1    jhawk 
     62  1.8    lukem GLOBAL	const char  *direction;	/* direction transfer is occurring */
     63  1.1    jhawk 
     64  1.1    jhawk GLOBAL	sigjmp_buf toplevel;	/* non-local goto stuff for cmd scanner */
     65  1.1    jhawk #endif	/* !STANDALONE_PROGRESS */
     66  1.1    jhawk 
     67  1.2    grant int	foregroundproc(void);
     68  1.1    jhawk void	alarmtimer(int);
     69  1.1    jhawk void	progressmeter(int);
     70  1.1    jhawk sigfunc	xsignal(int, sigfunc);
     71  1.1    jhawk 
     72  1.1    jhawk #ifndef STANDALONE_PROGRESS
     73  1.1    jhawk void	psummary(int);
     74  1.1    jhawk void	ptransfer(int);
     75  1.1    jhawk #endif	/* !STANDALONE_PROGRESS */
     76  1.1    jhawk 
     77  1.1    jhawk #ifdef NO_LONG_LONG
     78  1.1    jhawk # define LLF		"%ld"
     79  1.1    jhawk # define LLFP(x)	"%" x "ld"
     80  1.1    jhawk # define LLT		long
     81  1.1    jhawk # define ULLF		"%lu"
     82  1.1    jhawk # define ULLFP(x)	"%" x "lu"
     83  1.1    jhawk # define ULLT		unsigned long
     84  1.1    jhawk #else
     85  1.1    jhawk # define LLF		"%lld"
     86  1.1    jhawk # define LLFP(x)	"%" x "lld"
     87  1.1    jhawk # define LLT		long long
     88  1.1    jhawk # define ULLF		"%llu"
     89  1.1    jhawk # define ULLFP(x)	"%" x "llu"
     90  1.1    jhawk # define ULLT		unsigned long long
     91  1.1    jhawk #endif
     92