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