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