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