1104869Sru/* $NetBSD: progressbar.c,v 1.21 2009/04/12 10:18:52 lukem Exp $ */ 2104869Sru 3104869Sru/*- 4114412Sru * Copyright (c) 1997-2012 The NetBSD Foundation, Inc. 5104869Sru * All rights reserved. 6104869Sru * 7104869Sru * This code is derived from software contributed to The NetBSD Foundation 8104869Sru * by Luke Mewburn. 9151504Sru * 10151504Sru * Redistribution and use in source and binary forms, with or without 11151504Sru * modification, are permitted provided that the following conditions 12104869Sru * are met: 13104869Sru * 1. Redistributions of source code must retain the above copyright 14104869Sru * notice, this list of conditions and the following disclaimer. 15104869Sru * 2. Redistributions in binary form must reproduce the above copyright 16104869Sru * notice, this list of conditions and the following disclaimer in the 17104869Sru * documentation and/or other materials provided with the distribution. 18151504Sru * 19151504Sru * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20151504Sru * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21114412Sru * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22151504Sru * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23151504Sru * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24151504Sru * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25114412Sru * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26104869Sru * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27104869Sru * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28114412Sru * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29104869Sru * POSSIBILITY OF SUCH DAMAGE. 30104869Sru * 31114412Sru * $FreeBSD$ 32104869Sru */ 33104869Sru 34114412Sru#ifndef PROGRESS_H_ 35104869Sru#define PROGRESS_H_ 20100228 36104869Sru 37114412Sru#include <sys/types.h> 38104869Sru 39104869Sru#include <inttypes.h> 40114412Sru 41114412Sru/* structure used to display a progress meter */ 42114412Srutypedef struct progress_t { 43114412Sru char *prefix; /* any prefix explanation */ 44114412Sru uint64_t size; /* total of bytes/units to be counted */ 45114412Sru uint64_t done; /* number of units counted to date */ 46151504Sru uint64_t percent; /* cache the percentage complete */ 47151504Sru time_t start; /* time we started this */ 48151504Sru time_t now; /* time now */ 49114412Sru time_t eta; /* estimated # of secs until completion */ 50104869Sru int64_t elapsed; /* cached # of elapsed seconds */ 51104869Sru int32_t ttywidth; /* width of tty in columns */ 52114412Sru} progress_t; 53104869Sru 54104869Sruint progress_init(progress_t */*meter*/, const char */*prefix*/, uint64_t /*size*/); 55114412Sruint progress_update(progress_t */*meter*/, uint64_t /*done*/); 56114412Sruint progress_draw(progress_t */*meter*/); 57114412Sruint progress_reset_size(progress_t */*meter*/, uint64_t /*size*/); 58104869Sruint progress_complete(progress_t */*meter*/, uint64_t /*done*/); 59104869Sru 60104869Sru#endif 61114412Sru