Back to index

openldap  2.4.31
lutil_meter.h
Go to the documentation of this file.
00001 /* lutil_meter.h - progress meters */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright (c) 2009 by Matthew Backes, Symas Corp.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 /* ACKNOWLEDGEMENTS:
00017  * This work was initially developed by Matthew Backes for inclusion
00018  * in OpenLDAP software.
00019  */
00020 
00021 #ifndef _LUTIL_METER_H
00022 #define _LUTIL_METER_H
00023 
00024 #include "portable.h"
00025 
00026 #include <limits.h>
00027 #include <stdio.h>
00028 #include <sys/types.h>
00029 
00030 #include <ac/stdlib.h>
00031 #include <ac/time.h>
00032 
00033 typedef struct {
00034        int (*display_open) (void **datap);
00035        int (*display_update) (void **datap, double frac, time_t remaining_time, time_t elapsed, double byte_rate);
00036        int (*display_close) (void **datap);
00037 } lutil_meter_display_t;
00038 
00039 typedef struct {
00040        int (*estimator_open) (void **datap);
00041        int (*estimator_update) (void **datap, double start, double frac, time_t *remaining_time);
00042        int (*estimator_close) (void **datap);
00043 } lutil_meter_estimator_t;
00044 
00045 typedef struct {
00046        const lutil_meter_display_t *display;
00047        void * display_data;
00048        const lutil_meter_estimator_t *estimator;
00049        void * estimator_data;
00050        double start_time;
00051        double last_update;
00052        unsigned long goal_value;
00053        unsigned long last_position;
00054 } lutil_meter_t;
00055 
00056 extern const lutil_meter_display_t lutil_meter_text_display;
00057 extern const lutil_meter_estimator_t lutil_meter_linear_estimator;
00058 
00059 extern int lutil_meter_open (
00060        lutil_meter_t *lutil_meter,
00061        const lutil_meter_display_t *display, 
00062        const lutil_meter_estimator_t *estimator,
00063        unsigned long goal_value);
00064 extern int lutil_meter_update (
00065        lutil_meter_t *lutil_meter,
00066        unsigned long position,
00067        int force);
00068 extern int lutil_meter_close (lutil_meter_t *lutil_meter);
00069 
00070 #endif /* _LUTIL_METER_H */