* progress in moving all the fileaccess over to a wrapper system that can do fd based...
[rrdtool.git] / src / rrd_tool.h
index 76bd7a7..f8ab9c4 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.0.33  Copyright Tobias Oetiker, 1997 - 2000
+ * RRDtool 1.2.23  Copyright by Tobi Oetiker, 1997-2007
  *****************************************************************************
  * rrd_tool.h   Common Header File
  *****************************************************************************/
@@ -7,83 +7,40 @@
 extern "C" {
 #endif
 
-
 #ifndef _RRD_TOOL_H
 #define _RRD_TOOL_H
 
-#ifdef WIN32
-#include "../confignt/config.h"
-#else
 #ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "../rrd_config.h"
+#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
+#include "../win32/config.h"
 #endif
 
-#ifdef MUST_DISABLE_SIGFPE
-#include <signal.h>
-#endif
+#include "rrd.h"
 
-#ifdef MUST_DISABLE_FPMASK
-#include <floatingpoint.h>
-#endif
-    
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-
-#if HAVE_SYS_PARAM_H
-#  include <sys/param.h>
-#endif
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
 
-#ifndef MAXPATH
-#  define MAXPATH 1024
-#endif
+/* Win32 only includes */
 
-#if HAVE_MATH_H
-# include <math.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#if HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#if HAVE_SYS_TIMES_H
-# include <sys/times.h>
-#endif
-#if HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#if (defined(__svr4__) && defined(__sun__))
-/* Solaris headers (pre 2.6) don't have a getrusage prototype.
-   Use this instead. */
-extern int getrusage(int, struct rusage *);
-#endif /* __svr4__ && __sun__ */
-#endif
+#include <float.h>        /* for _isnan  */
+#include <io.h>           /* for chdir   */
 
-#include "rrd.h"
+struct tm* localtime_r(const time_t *timep, struct tm* result);
+char* ctime_r(const time_t *timep, char* result);
+struct tm* gmtime_r(const time_t *timep, struct tm* result);
+char *strtok_r(char *str, const char *sep, char **last);
 
-#ifndef WIN32
+#else
 
 /* unix-only includes */
-#ifndef isnan
+#if !defined isnan && !defined HAVE_ISNAN
 int isnan(double value);
 #endif
 
-#else
-
-/* Win32 only includes */
-
-#include <float.h>        /* for _isnan  */
-#define isnan _isnan
-#define finite _finite
-#define isinf(a) (_fpclass(a) == _FPCLASS_NINF || _fpclass(a) == _FPCLASS_PINF)
 #endif
 
 /* local include files -- need to be after the system ones */
-#include "getopt.h"
+#include "rrd_getopt.h"
 #include "rrd_format.h"
 
 #ifndef max
@@ -92,19 +49,21 @@ int isnan(double value);
 
 #ifndef min
 #define min(a,b) ((a) < (b) ? (a) : (b))
-#endif                                                   
+#endif
 
 #define DIM(x) (sizeof(x)/sizeof(x[0]))
 
 /* rrd info interface */
 enum info_type   { RD_I_VAL=0,
               RD_I_CNT,
-              RD_I_STR  };
+              RD_I_STR, 
+                  RD_I_INT };
 
 typedef union infoval { 
     unsigned long u_cnt; 
     rrd_value_t   u_val;
     char         *u_str;
+    int                  u_int;
 } infoval;
 
 typedef struct info_t {
@@ -114,17 +73,19 @@ typedef struct info_t {
     struct info_t   *next;
 } info_t;
 
-
 info_t *rrd_info(int, char **);
+int rrd_lastupdate(int argc, char **argv, time_t *last_update,
+                unsigned long *ds_cnt, char ***ds_namv, char ***last_ds);
+info_t *rrd_update_v(int, char **);
+char * sprintf_alloc(char *, ...);
+info_t *info_push(info_t *, char *, enum info_type, infoval);
 
 /* HELPER FUNCTIONS */
 
-int GifSize(FILE *, long *, long *);
-int PngSize(FILE *, long *, long *);
 int PngSize(FILE *, long *, long *);
 
-int rrd_create_fn(char *file_name, rrd_t *rrd);
-int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
+int rrd_create_fn(const char *file_name, rrd_t *rrd);
+int rrd_fetch_fn(const char *filename, enum cf_en cf_idx,
                 time_t *start,time_t *end,
                 unsigned long *step,
                 unsigned long *ds_cnt,
@@ -132,19 +93,32 @@ int rrd_fetch_fn(char *filename, enum cf_en cf_idx,
                 rrd_value_t **data);
 
 void rrd_free(rrd_t *rrd);
+void rrd_freemem(void *mem);
 void rrd_init(rrd_t *rrd);
 
-int rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr);
-int readfile(char *file, char **buffer, int skipfirst);
+rrd_file_t* rrd_open(const char * const file_name, rrd_t *rrd, unsigned rdwr);
+int rrd_close(rrd_file_t* rrd_file);
+ssize_t rrd_read(rrd_file_t* rrd_file, void*buf, size_t count);
+ssize_t rrd_write(rrd_file_t* rrd_file, const void*buf, size_t count);
+void rrd_flush(rrd_file_t* rrd_file);
+off_t rrd_seek(rrd_file_t* rrd_file, off_t off, int whence);
+off_t rrd_tell(rrd_file_t* rrd_file);
+int readfile(const char *file, char **buffer, int skipfirst);
 
 #define RRD_READONLY    0
 #define RRD_READWRITE   1
+#define RRD_CREAT       2
 
-enum cf_en cf_conv(char *string);
+enum cf_en cf_conv(const char *string);
 enum dst_en dst_conv(char *string);
 long ds_match(rrd_t *rrd,char *ds_nam);
 double rrd_diff(char *a, char *b);
 
+    /* rrd_strerror is thread safe, but still it uses a global buffer
+       (but one per thread), thus subsequent calls within a single
+       thread overwrite the same buffer */
+const char *rrd_strerror(int err);
+
 #endif
 
 #ifdef  __cplusplus