1237285Sscottl/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ 2237285Sscottl 3237285Sscottl/*- 4237285Sscottl * Copyright (c) 1997-2012 The NetBSD Foundation, Inc. 5237285Sscottl * All rights reserved. 6237285Sscottl * 7237285Sscottl * This code is derived from software contributed to The NetBSD Foundation 8237285Sscottl * by Luke Mewburn. 9237285Sscottl * 10237285Sscottl * Redistribution and use in source and binary forms, with or without 11237285Sscottl * modification, are permitted provided that the following conditions 12237285Sscottl * are met: 13237285Sscottl * 1. Redistributions of source code must retain the above copyright 14237285Sscottl * notice, this list of conditions and the following disclaimer. 15237285Sscottl * 2. Redistributions in binary form must reproduce the above copyright 16237285Sscottl * notice, this list of conditions and the following disclaimer in the 17237285Sscottl * documentation and/or other materials provided with the distribution. 18237285Sscottl * 19237285Sscottl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20237285Sscottl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21237285Sscottl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22237285Sscottl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23237285Sscottl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24237285Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25237285Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26237285Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27237285Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28237285Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29237285Sscottl * POSSIBILITY OF SUCH DAMAGE. 30237285Sscottl * 31237285Sscottl * $FreeBSD$ 32237285Sscottl */ 33237285Sscottl 34237285Sscottl#ifndef PROGRESS_H_ 35237285Sscottl#define PROGRESS_H_ 20100228 36237285Sscottl 37237285Sscottl#include <sys/types.h> 38237285Sscottl 39237285Sscottl#include <inttypes.h> 40237285Sscottl 41237285Sscottl/* structure used to display a progress meter */ 42237285Sscottltypedef struct progress_t { 43237285Sscottl char *prefix; /* any prefix explanation */ 44237285Sscottl uint64_t size; /* total of bytes/units to be counted */ 45237285Sscottl uint64_t done; /* number of units counted to date */ 46237285Sscottl uint64_t percent; /* cache the percentage complete */ 47237285Sscottl time_t start; /* time we started this */ 48237285Sscottl time_t now; /* time now */ 49237285Sscottl time_t eta; /* estimated # of secs until completion */ 50237285Sscottl int64_t elapsed; /* cached # of elapsed seconds */ 51237285Sscottl int32_t ttywidth; /* width of tty in columns */ 52237285Sscottl} progress_t; 53237285Sscottl 54237285Sscottlint progress_init(progress_t */*meter*/, const char */*prefix*/, uint64_t /*size*/); 55237285Sscottlint progress_update(progress_t */*meter*/, uint64_t /*done*/); 56237285Sscottlint progress_draw(progress_t */*meter*/); 57237285Sscottlint progress_reset_size(progress_t */*meter*/, uint64_t /*size*/); 58237285Sscottlint progress_complete(progress_t */*meter*/, uint64_t /*done*/); 59237285Sscottl 60237285Sscottl#endif 61