1/* $NetBSD$ */ 2 3/* lutil_meter.h - progress meters */ 4/* OpenLDAP: pkg/ldap/include/lutil_meter.h,v 1.1.2.1 2009/02/05 20:10:59 quanah Exp */ 5/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright (c) 2009 by Matthew Backes, Symas Corp. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18/* ACKNOWLEDGEMENTS: 19 * This work was initially developed by Matthew Backes for inclusion 20 * in OpenLDAP software. 21 */ 22 23#ifndef _LUTIL_METER_H 24#define _LUTIL_METER_H 25 26#include "portable.h" 27 28#include <limits.h> 29#include <stdio.h> 30#include <sys/types.h> 31 32#include <ac/stdlib.h> 33#include <ac/time.h> 34 35typedef struct { 36 int (*display_open) (void **datap); 37 int (*display_update) (void **datap, double frac, time_t remaining_time, time_t elapsed, double byte_rate); 38 int (*display_close) (void **datap); 39} lutil_meter_display_t; 40 41typedef struct { 42 int (*estimator_open) (void **datap); 43 int (*estimator_update) (void **datap, double start, double frac, time_t *remaining_time); 44 int (*estimator_close) (void **datap); 45} lutil_meter_estimator_t; 46 47typedef struct { 48 const lutil_meter_display_t *display; 49 void * display_data; 50 const lutil_meter_estimator_t *estimator; 51 void * estimator_data; 52 double start_time; 53 double last_update; 54 unsigned long goal_value; 55 unsigned long last_position; 56} lutil_meter_t; 57 58extern const lutil_meter_display_t lutil_meter_text_display; 59extern const lutil_meter_estimator_t lutil_meter_linear_estimator; 60 61extern int lutil_meter_open ( 62 lutil_meter_t *lutil_meter, 63 const lutil_meter_display_t *display, 64 const lutil_meter_estimator_t *estimator, 65 unsigned long goal_value); 66extern int lutil_meter_update ( 67 lutil_meter_t *lutil_meter, 68 unsigned long position, 69 int force); 70extern int lutil_meter_close (lutil_meter_t *lutil_meter); 71 72#endif /* _LUTIL_METER_H */ 73