1223328Sgavin/* $NetBSD: progressbar.h,v 1.9 2009/05/20 12:53:47 lukem Exp $ */ 2223328Sgavin/* from NetBSD: progressbar.h,v 1.8 2009/04/12 10:18:52 lukem Exp */ 3116424Smikeh 4116424Smikeh/*- 5223328Sgavin * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. 6116424Smikeh * All rights reserved. 7116424Smikeh * 8116424Smikeh * This code is derived from software contributed to The NetBSD Foundation 9116424Smikeh * by Luke Mewburn. 10116424Smikeh * 11116424Smikeh * Redistribution and use in source and binary forms, with or without 12116424Smikeh * modification, are permitted provided that the following conditions 13116424Smikeh * are met: 14116424Smikeh * 1. Redistributions of source code must retain the above copyright 15116424Smikeh * notice, this list of conditions and the following disclaimer. 16116424Smikeh * 2. Redistributions in binary form must reproduce the above copyright 17116424Smikeh * notice, this list of conditions and the following disclaimer in the 18116424Smikeh * documentation and/or other materials provided with the distribution. 19116424Smikeh * 20116424Smikeh * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21116424Smikeh * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22116424Smikeh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23116424Smikeh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24116424Smikeh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25116424Smikeh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26116424Smikeh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27116424Smikeh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28116424Smikeh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29116424Smikeh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30116424Smikeh * POSSIBILITY OF SUCH DAMAGE. 31116424Smikeh */ 32116424Smikeh 33116424Smikeh#ifndef STANDALONE_PROGRESS 34116424Smikeh#include <setjmp.h> 35116424Smikeh#endif /* !STANDALONE_PROGRESS */ 36116424Smikeh 37116424Smikeh#ifndef GLOBAL 38116424Smikeh#define GLOBAL extern 39116424Smikeh#endif 40116424Smikeh 41116424Smikeh 42116424Smikeh#define STALLTIME 5 /* # of seconds of no xfer before "stalling" */ 43116424Smikeh 44116424Smikehtypedef void (*sigfunc)(int); 45116424Smikeh 46116424Smikeh 47116424SmikehGLOBAL FILE *ttyout; /* stdout, or stderr if retrieving to stdout */ 48116424Smikeh 49116424SmikehGLOBAL int progress; /* display transfer progress bar */ 50116424SmikehGLOBAL int ttywidth; /* width of tty */ 51116424Smikeh 52116424SmikehGLOBAL off_t bytes; /* current # of bytes read */ 53116424SmikehGLOBAL off_t filesize; /* size of file being transferred */ 54116424SmikehGLOBAL off_t restart_point; /* offset to restart transfer */ 55128671SmikehGLOBAL char *prefix; /* Text written left of progress bar */ 56116424Smikeh 57116424Smikeh 58116424Smikeh#ifndef STANDALONE_PROGRESS 59116424SmikehGLOBAL int fromatty; /* input is from a terminal */ 60116424SmikehGLOBAL int verbose; /* print messages coming back from server */ 61116424SmikehGLOBAL int quit_time; /* maximum time to wait if stalled */ 62116424Smikeh 63223328SgavinGLOBAL const char *direction; /* direction transfer is occurring */ 64116424Smikeh 65116424SmikehGLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */ 66116424Smikeh#endif /* !STANDALONE_PROGRESS */ 67116424Smikeh 68116424Smikehint foregroundproc(void); 69116424Smikehvoid alarmtimer(int); 70116424Smikehvoid progressmeter(int); 71116424Smikehsigfunc xsignal(int, sigfunc); 72116424Smikehsigfunc xsignal_restart(int, sigfunc, int); 73116424Smikeh 74116424Smikeh#ifndef STANDALONE_PROGRESS 75116424Smikehvoid psummary(int); 76116424Smikehvoid ptransfer(int); 77116424Smikeh#endif /* !STANDALONE_PROGRESS */ 78116424Smikeh 79116424Smikeh#ifdef NO_LONG_LONG 80116424Smikeh# define LLF "%ld" 81116424Smikeh# define LLFP(x) "%" x "ld" 82116424Smikeh# define LLT long 83116424Smikeh# define ULLF "%lu" 84116424Smikeh# define ULLFP(x) "%" x "lu" 85116424Smikeh# define ULLT unsigned long 86116424Smikeh#else 87223328Sgavin#if defined(HAVE_PRINTF_QD) 88223328Sgavin# define LLF "%qd" 89223328Sgavin# define LLFP(x) "%" x "qd" 90223328Sgavin# define LLT long long 91223328Sgavin# define ULLF "%qu" 92223328Sgavin# define ULLFP(x) "%" x "qu" 93223328Sgavin# define ULLT unsigned long long 94223328Sgavin#else /* !defined(HAVE_PRINTF_QD) */ 95116424Smikeh# define LLF "%lld" 96116424Smikeh# define LLFP(x) "%" x "lld" 97116424Smikeh# define LLT long long 98116424Smikeh# define ULLF "%llu" 99116424Smikeh# define ULLFP(x) "%" x "llu" 100116424Smikeh# define ULLT unsigned long long 101223328Sgavin#endif /* !defined(HAVE_PRINTF_QD) */ 102116424Smikeh#endif 103