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