Code

Imported upstream version 1.4.8
[pkg-rrdtool.git] / src / rrd_format.c
index b925b286cc1dd52fc5e2ab4d9fac2765e3877fef..9dc4c13277b3f9ee92cfcebab4841900493e50ed 100644 (file)
@@ -1,9 +1,9 @@
 /*****************************************************************************
- * RRDtool 1.3.1  Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.4.8  Copyright by Tobi Oetiker, 1997-2013
  *****************************************************************************
  * rrd_format.c  RRD Database Format helper functions
  *****************************************************************************
- * $Id: rrd_format.c 1447 2008-07-23 13:02:26Z oetiker $
+ * $Id$
  * $Log$
  * Revision 1.5  2004/05/18 18:53:03  oetiker
  * big spell checking patch -- slif@bellsouth.net
@@ -48,6 +48,9 @@
  *
  *****************************************************************************/
 #include "rrd_tool.h"
+#ifdef WIN32
+#include "stdlib.h"
+#endif
 
 #define converter(VV,VVV) \
    if (strcmp(#VV, string) == 0) return VVV;
@@ -62,7 +65,7 @@ enum dst_en dst_conv(
         converter(DERIVE, DST_DERIVE)
         converter(COMPUTE, DST_CDEF)
         rrd_set_error("unknown data acquisition function '%s'", string);
-    return (-1);
+    return (enum dst_en)(-1);
 }
 
 
@@ -81,7 +84,7 @@ enum cf_en cf_conv(
         converter(DEVSEASONAL, CF_DEVSEASONAL)
         converter(FAILURES, CF_FAILURES)
         rrd_set_error("unknown consolidation function '%s'", string);
-    return (-1);
+    return (enum cf_en)(-1);
 }
 
 #undef converter
@@ -98,3 +101,15 @@ long ds_match(
     rrd_set_error("unknown data source name '%s'", ds_nam);
     return -1;
 }
+
+off_t rrd_get_header_size(
+    rrd_t *rrd)
+{
+    return sizeof(stat_head_t) + \
+        sizeof(ds_def_t) * rrd->stat_head->ds_cnt + \
+        sizeof(rra_def_t) * rrd->stat_head->rra_cnt + \
+        ( atoi(rrd->stat_head->version) < 3 ? sizeof(time_t) : sizeof(live_head_t) ) + \
+        sizeof(pdp_prep_t) * rrd->stat_head->ds_cnt + \
+        sizeof(cdp_prep_t) * rrd->stat_head->ds_cnt * rrd->stat_head->rra_cnt + \
+        sizeof(rra_ptr_t) * rrd->stat_head->rra_cnt;
+}