Home | History | Annotate | Line # | Download | only in ftp
progressbar.h revision 1.1
      1  1.1  jhawk /*	$NetBSD: progressbar.h,v 1.1 2003/01/21 16:08:08 jhawk Exp $	*/
      2  1.1  jhawk 
      3  1.1  jhawk /*-
      4  1.1  jhawk  * Copyright (c) 1996-2002 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 /*
     40  1.1  jhawk  * Copyright (c) 1985, 1989, 1993, 1994
     41  1.1  jhawk  *	The Regents of the University of California.  All rights reserved.
     42  1.1  jhawk  *
     43  1.1  jhawk  * Redistribution and use in source and binary forms, with or without
     44  1.1  jhawk  * modification, are permitted provided that the following conditions
     45  1.1  jhawk  * are met:
     46  1.1  jhawk  * 1. Redistributions of source code must retain the above copyright
     47  1.1  jhawk  *    notice, this list of conditions and the following disclaimer.
     48  1.1  jhawk  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.1  jhawk  *    notice, this list of conditions and the following disclaimer in the
     50  1.1  jhawk  *    documentation and/or other materials provided with the distribution.
     51  1.1  jhawk  * 3. All advertising materials mentioning features or use of this software
     52  1.1  jhawk  *    must display the following acknowledgement:
     53  1.1  jhawk  *	This product includes software developed by the University of
     54  1.1  jhawk  *	California, Berkeley and its contributors.
     55  1.1  jhawk  * 4. Neither the name of the University nor the names of its contributors
     56  1.1  jhawk  *    may be used to endorse or promote products derived from this software
     57  1.1  jhawk  *    without specific prior written permission.
     58  1.1  jhawk  *
     59  1.1  jhawk  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     60  1.1  jhawk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     61  1.1  jhawk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     62  1.1  jhawk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     63  1.1  jhawk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     64  1.1  jhawk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     65  1.1  jhawk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     66  1.1  jhawk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     67  1.1  jhawk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     68  1.1  jhawk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     69  1.1  jhawk  * SUCH DAMAGE.
     70  1.1  jhawk  *
     71  1.1  jhawk  *	from: ftp_var.h	8.4 (Berkeley) 10/9/94
     72  1.1  jhawk  *      from: extern.h	8.3 (Berkeley) 10/9/94
     73  1.1  jhawk  */
     74  1.1  jhawk 
     75  1.1  jhawk /*
     76  1.1  jhawk  * Copyright (C) 1997 and 1998 WIDE Project.
     77  1.1  jhawk  * All rights reserved.
     78  1.1  jhawk  *
     79  1.1  jhawk  * Redistribution and use in source and binary forms, with or without
     80  1.1  jhawk  * modification, are permitted provided that the following conditions
     81  1.1  jhawk  * are met:
     82  1.1  jhawk  * 1. Redistributions of source code must retain the above copyright
     83  1.1  jhawk  *    notice, this list of conditions and the following disclaimer.
     84  1.1  jhawk  * 2. Redistributions in binary form must reproduce the above copyright
     85  1.1  jhawk  *    notice, this list of conditions and the following disclaimer in the
     86  1.1  jhawk  *    documentation and/or other materials provided with the distribution.
     87  1.1  jhawk  * 3. Neither the name of the project nor the names of its contributors
     88  1.1  jhawk  *    may be used to endorse or promote products derived from this software
     89  1.1  jhawk  *    without specific prior written permission.
     90  1.1  jhawk  *
     91  1.1  jhawk  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     92  1.1  jhawk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     93  1.1  jhawk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     94  1.1  jhawk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     95  1.1  jhawk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     96  1.1  jhawk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     97  1.1  jhawk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     98  1.1  jhawk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     99  1.1  jhawk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    100  1.1  jhawk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    101  1.1  jhawk  * SUCH DAMAGE.
    102  1.1  jhawk  */
    103  1.1  jhawk 
    104  1.1  jhawk #ifndef STANDALONE_PROGRESS
    105  1.1  jhawk #include <setjmp.h>
    106  1.1  jhawk #endif	/* !STANDALONE_PROGRESS */
    107  1.1  jhawk 
    108  1.1  jhawk #ifndef	GLOBAL
    109  1.1  jhawk #define	GLOBAL	extern
    110  1.1  jhawk #endif
    111  1.1  jhawk 
    112  1.1  jhawk 
    113  1.1  jhawk #define	STALLTIME	5	/* # of seconds of no xfer before "stalling" */
    114  1.1  jhawk 
    115  1.1  jhawk typedef void (*sigfunc)(int);
    116  1.1  jhawk 
    117  1.1  jhawk 
    118  1.1  jhawk GLOBAL	FILE   *ttyout;		/* stdout, or stderr if retrieving to stdout */
    119  1.1  jhawk 
    120  1.1  jhawk GLOBAL	int	progress;	/* display transfer progress bar */
    121  1.1  jhawk GLOBAL	int	ttywidth;	/* width of tty */
    122  1.1  jhawk 
    123  1.1  jhawk GLOBAL	off_t	bytes;		/* current # of bytes read */
    124  1.1  jhawk GLOBAL	off_t	filesize;	/* size of file being transferred */
    125  1.1  jhawk GLOBAL	off_t	restart_point;	/* offset to restart transfer */
    126  1.1  jhawk 
    127  1.1  jhawk 
    128  1.1  jhawk #ifndef	STANDALONE_PROGRESS
    129  1.1  jhawk GLOBAL	int	fromatty;	/* input is from a terminal */
    130  1.1  jhawk GLOBAL	int	verbose;	/* print messages coming back from server */
    131  1.1  jhawk GLOBAL	int	quit_time;	/* maximum time to wait if stalled */
    132  1.1  jhawk 
    133  1.1  jhawk GLOBAL	char   *direction;	/* direction transfer is occurring */
    134  1.1  jhawk 
    135  1.1  jhawk GLOBAL	sigjmp_buf toplevel;	/* non-local goto stuff for cmd scanner */
    136  1.1  jhawk #endif	/* !STANDALONE_PROGRESS */
    137  1.1  jhawk 
    138  1.1  jhawk void	alarmtimer(int);
    139  1.1  jhawk void	progressmeter(int);
    140  1.1  jhawk sigfunc	xsignal(int, sigfunc);
    141  1.1  jhawk sigfunc	xsignal_restart(int, sigfunc, int);
    142  1.1  jhawk 
    143  1.1  jhawk #ifndef STANDALONE_PROGRESS
    144  1.1  jhawk int	foregroundproc(void);
    145  1.1  jhawk void	psummary(int);
    146  1.1  jhawk void	ptransfer(int);
    147  1.1  jhawk #endif	/* !STANDALONE_PROGRESS */
    148  1.1  jhawk 
    149  1.1  jhawk 
    150  1.1  jhawk #ifdef NO_LONG_LONG
    151  1.1  jhawk # define LLF		"%ld"
    152  1.1  jhawk # define LLFP(x)	"%" x "ld"
    153  1.1  jhawk # define LLT		long
    154  1.1  jhawk # define ULLF		"%lu"
    155  1.1  jhawk # define ULLFP(x)	"%" x "lu"
    156  1.1  jhawk # define ULLT		unsigned long
    157  1.1  jhawk #else
    158  1.1  jhawk # define LLF		"%lld"
    159  1.1  jhawk # define LLFP(x)	"%" x "lld"
    160  1.1  jhawk # define LLT		long long
    161  1.1  jhawk # define ULLF		"%llu"
    162  1.1  jhawk # define ULLFP(x)	"%" x "llu"
    163  1.1  jhawk # define ULLT		unsigned long long
    164  1.1  jhawk #endif
    165