#ifndef _DLOG_H_
#define _DLOG_H_

#include <time.h>

#define DLOG_MAX_SET 32

typedef struct {
  time_t last, start;
  float version, undef;
  int period, headsize, fsize, nset, nlen;
  int fd, pos;
  char name[128];
} DlogSet;


int DlogOpen(DlogSet *dset, char *name, int write);
/* open existing dlog set */

int DlogCreate(DlogSet *dset, char *name, time_t start, int nset, int nlen, int period, float undef);
/* create new dlog file */

int DlogPut(DlogSet *dset, time_t time, int nset, float val[]);
/* put values to dlog set */

int DlogGet(DlogSet *dset, int iset, int nmax, double *starttime, float *x, float *y);
/* get one dataset from dlog set

   iset is the dataset to be returned
   nmax is the maximal number of points to be returned
   x, y: the data (arrays declared with at least nmax elements)

   on success, the return value is the effective length of returned data
*/

int DlogGetMany(DlogSet *dset, int nset, int nmax, double *starttime, float x[], float y[], int index[]);
/* get many datasets from dlog set

   nset is the nember of datasets to be returned
   nmax is the maximal number of points to be returned
   x, y: the data, one dataset after an other (arrays declared with at least nmax elements)
   index must be an array of at least nset elements.
     it returns the start indices in x[] and y[] of the data sets.

   on success, the return value is the effective length of returned data
*/

int DlogUpd(DlogSet *dset);
/* update pointer */

int DlogClose(DlogSet *dset);
/* close dlog set */

#endif /* _DLOG_H_ */
