Merge branch 'master' into ff/rrdd
authorFlorian Forster <octo@leeloo.home.verplant.org>
Sun, 14 Sep 2008 08:23:10 +0000 (10:23 +0200)
committerFlorian Forster <octo@leeloo.home.verplant.org>
Sun, 14 Sep 2008 08:23:10 +0000 (10:23 +0200)
configure.ac
doc/rrdgraph.pod
src/Makefile.am
src/rrd_config_bottom.h [new file with mode: 0644]
src/rrd_format.h
src/rrd_graph.c

index 01cb808..451502c 100644 (file)
@@ -52,14 +52,13 @@ AC_PREREQ(2.59)
 dnl At the TOP of the HEADER
 
 AH_TOP([
-
 #ifndef RRD_CONFIG_H
 #define RRD_CONFIG_H
+
 /* IEEE can be prevented from raising signals with fpsetmask(0) */
 #undef MUST_DISABLE_FPMASK
 
 /* IEEE math only works if SIGFPE gets actively set to IGNORE */
-
 #undef MUST_DISABLE_SIGFPE
 
 /* realloc does not support NULL as argument */
@@ -72,241 +71,17 @@ AH_TOP([
 # endif
 #endif
 
- ])
+])
 
 AH_BOTTOM([
-/* make sure that we pickup the correct stuff from all headers */
-#ifdef HAVE_FEATURES_H
-#undef _XOPEN_SOURCE /* keep unmodified */
-#undef _BSD_SOURCE /* keep unmodified */
-#define _XOPEN_SOURCE 600
-#define _BSD_SOURCE 1
-# include <features.h>
-#endif
-
-/* FreeBSD 4.8 wants this included BEFORE sys/types.h */
-#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-#ifndef MAXPATH
-# ifdef PATH_MAX
-#  define MAXPATH PATH_MAX
-# endif
-#endif
-#ifndef MAXPATH
-/* else try the BSD variant */
-# ifdef MAXPATHLEN
-#  define MAXPATH MAXPATHLEN
-# endif
-#endif
-
-#ifdef HAVE_ERRNO_H
-# include <errno.h>
-#endif
-
-#if !defined HAVE_MADVISE && defined HAVE_POSIX_MADVISE
-/* use posix_madvise family */
-# define madvise posix_madvise
-# define MADV_NORMAL POSIX_MADV_NORMAL
-# define MADV_RANDOM POSIX_MADV_RANDOM
-# define MADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL
-# define MADV_WILLNEED POSIX_MADV_WILLNEED
-# define MADV_DONTNEED POSIX_MADV_DONTNEED
-#endif
-#if defined HAVE_MADVISE || defined HAVE_POSIX_MADVISE
-# define USE_MADVISE 1
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
 
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#ifdef HAVE_SYS_TIMES_H
-# include <sys/times.h>
-#endif
-
-#ifdef HAVE_SYS_RESOURCE_H
-# include <sys/resource.h>
-#if (defined(__svr4__) && defined(__sun__))
-/* Solaris headers (pre 2.6) do not have a getrusage prototype. 
-   Use this instead. */
-extern int getrusage(int, struct rusage *);
-#endif /* __svr4__ && __sun__ */
-#endif
-
-
-/* define strrchr, strchr and memcpy, memmove in terms of bsd funcs
-   make sure you are NOT using bcopy, index or rindex in the code */
-      
-#ifdef STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_STRCHR
-#  define strchr index
-#  define strrchr rindex
-# endif
-char *strchr (), *strrchr ();
-# ifndef HAVE_MEMMOVE
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-#  define memmove(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#ifdef NO_NULL_REALLOC
-# define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))
-#else
-# define rrd_realloc(a,b) realloc((a), (b))
-#endif
-
-#ifdef NEED_MALLOC_MALLOC_H
+#ifdef MUST_HAVE_MALLOC_MALLOC_H
 #  include <malloc/malloc.h>
 #endif
 
-#ifdef HAVE_STDIO_H
-# include <stdio.h>
-#endif
+#include <rrd_config_bottom.h>
 
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
 #endif
-
-#ifdef HAVE_CTYPE_H
-# include <ctype.h>
-#endif
-
-#ifdef HAVE_DIRENT_H
-# include <dirent.h>
-# define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
-# ifdef HAVE_SYS_NDIR_H
-#  include <sys/ndir.h>
-# endif
-# ifdef HAVE_SYS_DIR_H
-#  include <sys/dir.h>
-# endif
-# ifdef HAVE_NDIR_H
-#  include <ndir.h>
-# endif
-#endif
-
-#ifdef MUST_DISABLE_SIGFPE
-# include <signal.h>
-#endif
-
-#ifdef MUST_DISABLE_FPMASK
-# include <floatingpoint.h>
-#endif
-
-
-#ifdef HAVE_MATH_H
-# include <math.h>
-#endif
-
-#ifdef HAVE_FLOAT_H
-# include <float.h>
-#endif
-
-#ifdef HAVE_IEEEFP_H
-# include <ieeefp.h>
-#endif
-
-#ifdef HAVE_FP_CLASS_H
-# include <fp_class.h>
-#endif
-
-/* for Solaris */
-#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
-#  define HAVE_ISINF 1
-#  ifdef isinf
-#  undef isinf /* confuse autoconf */
-#  endif
-#  define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
-#endif
-
-/* solaris 10 it defines isnan such that only forte can compile it ... bad bad  */
-#if (defined(HAVE_ISNAN) && defined(isnan) && defined(HAVE_FPCLASS))
-#  undef isnan /* confuse autoconf to NOT remove this */
-#  define isnan(a) (fpclass(a) == FP_SNAN || fpclass(a) == FP_QNAN)
-#endif
-
-/* for OSF1 Digital Unix */
-#if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
-#  define HAVE_ISINF 1
-#  define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
-#endif
-
-#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
-#  define HAVE_ISINF 1
-#  define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
-#endif
-
-#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
-#  define HAVE_ISINF 1
-#  define isinf(a) (fpclassify(a) == FP_INFINITE)
-#endif
-
-/* for AIX */
-#if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
-#  define HAVE_ISINF 1
-#  define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
-#endif
-
-#if (! defined (HAVE_FINITE) && defined (HAVE_ISFINITE))
-#  define HAVE_FINITE 1
-#  define finite(a) isfinite(a)
-#endif
-
-#if (! defined(HAVE_FINITE) && defined(HAVE_ISNAN) && defined(HAVE_ISINF))
-#  define HAVE_FINITE 1
-#  define finite(a) (! isnan(a) && ! isinf(a))
-#endif
-
-#ifndef HAVE_FINITE
-#error "Can't compile without finite function"
-#endif
-
-#ifndef HAVE_ISINF
-#error "Can't compile without isinf function"
-#endif
-
-#if (! defined(HAVE_FDATASYNC) && defined(HAVE_FSYNC))
-#define fdatasync fsync
-#endif
-
-#if (!defined(HAVE_FDATASYNC) && !defined(HAVE_FSYNC))
-#error "Can't compile with without fsync and fdatasync"
-#endif
-
-#endif /* RRD_CONFIG_H */
 ])
 
 dnl Process Special Options
@@ -526,7 +301,7 @@ volatile int x;volatile float f;  ]], [[x = isinf(f)]])],[AC_MSG_RESULT(yes)
       AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])
 
 dnl finite is BSD, isfinite is C99, so prefer the latter
-AC_CACHE_CHECK([whether isfinite is broken],[have_broken_isfinite],[
+AC_CACHE_CHECK([whether isfinite is broken],[ac_cv_have_broken_isfinite],[
 AC_TRY_RUN([
 #ifdef HAVE_MATH_H
 #include <math.h>
@@ -545,24 +320,30 @@ int main ()
 #endif
 #endif
 return 0;
-}],[
-have_broken_isfinite=no],have_broken_isfinite=yes,[
+}],[ac_cv_have_broken_isfinite=no],[ac_cv_have_broken_isfinite=yes],[
 case "${target}" in
-  hppa*-*-hpux*) have_broken_isfinite=yes ;;
-  *-sun-solaris2.8) have_broken_isfinite=yes ;;
-  *) have_broken_isfinite=no ;;
+  hppa*-*-hpux*) ac_cv_have_broken_isfinite=yes ;;
+  *-sun-solaris2.8) ac_cv_have_broken_isfinite=yes ;;
+  *) ac_cv_have_broken_isfinite=no ;;
 esac])
 ])
-if test "x$have_broken_isfinite" = "xno"; then
+
+dnl the test does not seem to work on solaris 2.8
+dnl so lets fix this by hand
+case "${target}" in
+  *-sun-solaris2.8) ac_cv_have_broken_isfinite=yes ;;
+esac
+
+if test "x$ac_cv_have_broken_isfinite" = "xno"; then
   AC_DEFINE(HAVE_ISFINITE)
 else
-AC_CHECK_FUNCS(finite,[],
-  [AC_CHECK_FUNCS(isfinite,[],
-      [AC_MSG_CHECKING(for isfinite with <math.h>)
-       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>
+  AC_CHECK_FUNCS(finite,[],
+      [AC_CHECK_FUNCS(isfinite,[],
+         [AC_MSG_CHECKING(for isfinite with <math.h>)
+          AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>
 volatile int x;volatile float f;  ]],[[x = isfinite(f)]])],[AC_MSG_RESULT(yes)
                AC_DEFINE(HAVE_ISFINITE)],[AC_MSG_RESULT(no)])])])
-fi
+fi  
 
 AC_FULL_IEEE
 
@@ -661,8 +442,8 @@ AC_LINK_IFELSE(
                 [[#include <stdlib.h>
                   #include <malloc/malloc.h>]],
                 [[malloc(1)]]
-                        ),
-          [AC_DEFINE(NEED_MALLOC_MALLOC_H)
+                        ),[
+           AC_DEFINE([MUST_HAVE_MALLOC_MALLOC_H])
            AC_MSG_RESULT([yes we do])],
           [AC_MSG_ERROR([Can not figure how to compile malloc])]
       )
index 1d6081d..94260d9 100644 (file)
@@ -296,7 +296,7 @@ I<COLORTAG> is one of C<BACK> background, C<CANVAS> for the background of
 the actual graph, C<SHADEA> for the left and top border, C<SHADEB> for the
 right and bottom border, C<GRID>, C<MGRID> for the major grid, C<FONT> for
 the color of the font, C<AXIS> for the axis of the graph, C<FRAME> for the
-line around the color spots and finally C<ARROW> for the arrow head pointing
+line around the color spots, and finally C<ARROW> for the arrow head pointing
 up and forward. Each color is composed out of three hexadecimal numbers
 specifying its rgb color component (00 is off, FF is maximum) of red, green
 and blue. Optionally you may add another hexadecimal number specifying the
@@ -311,10 +311,11 @@ Zoom the graphics by the given amount. The factor must be E<gt> 0
 
 [B<-n>|B<--font> I<FONTTAG>B<:>I<size>B<:>[I<font>]]
 
-This lets you customize which font to use for the various text
-elements on the RRD graphs. C<DEFAULT> sets the default value for all
-elements, C<TITLE> for the title, C<AXIS> for the axis labels, C<UNIT>
-for the vertical unit label, C<LEGEND> for the graph legend.
+This lets you customize which font to use for the various text elements on
+the RRD graphs. C<DEFAULT> sets the default value for all elements, C<TITLE>
+for the title, C<AXIS> for the axis labels, C<UNIT> for the vertical unit
+label, C<LEGEND> for the graph legend, C<WATERMARK> for the watermark on the
+edge of the graph.
 
 Use Times for the title: C<--font TITLE:13:Times>
 
index 663d1a1..420aeab 100644 (file)
@@ -50,7 +50,7 @@ RRD_C_FILES =         \
 noinst_HEADERS = \
        unused.h \
        rrd_getopt.h rrd_parsetime.h \
-       rrd_i18n.h \
+       rrd_config_bottom.h rrd_i18n.h \
        rrd_format.h rrd_tool.h rrd_xport.h rrd.h rrd_rpncalc.h \
        rrd_hw.h rrd_hw_math.h rrd_hw_update.h \
        fnv.h rrd_graph.h \
diff --git a/src/rrd_config_bottom.h b/src/rrd_config_bottom.h
new file mode 100644 (file)
index 0000000..ec191b9
--- /dev/null
@@ -0,0 +1,236 @@
+#ifndef RRD_CONFIG_BOTTOM_H
+#define RRD_CONFIG_BOTTOM_H
+
+/* make sure that we pickup the correct stuff from all headers */
+#ifdef HAVE_FEATURES_H
+# ifdef _XOPEN_SOURCE
+#   undef _XOPEN_SOURCE
+# endif
+# ifdef _BSD_SOURCE
+#  undef _BSD_SOURCE
+# endif
+# define _XOPEN_SOURCE 600
+# define _BSD_SOURCE 1
+# include <features.h>
+#endif
+
+/* FreeBSD 4.8 wants this included BEFORE sys/types.h */
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+#ifndef MAXPATH
+# ifdef PATH_MAX
+#  define MAXPATH PATH_MAX
+# endif
+#endif
+#ifndef MAXPATH
+/* else try the BSD variant */
+# ifdef MAXPATHLEN
+#  define MAXPATH MAXPATHLEN
+# endif
+#endif
+
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+
+#if !defined HAVE_MADVISE && defined HAVE_POSIX_MADVISE
+/* use posix_madvise family */
+# define madvise posix_madvise
+# define MADV_NORMAL POSIX_MADV_NORMAL
+# define MADV_RANDOM POSIX_MADV_RANDOM
+# define MADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL
+# define MADV_WILLNEED POSIX_MADV_WILLNEED
+# define MADV_DONTNEED POSIX_MADV_DONTNEED
+#endif
+#if defined HAVE_MADVISE || defined HAVE_POSIX_MADVISE
+# define USE_MADVISE 1
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#ifdef HAVE_SYS_TIMES_H
+# include <sys/times.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#if (defined(__svr4__) && defined(__sun__))
+/* Solaris headers (pre 2.6) do not have a getrusage prototype. 
+   Use this instead. */
+extern int getrusage(int, struct rusage *);
+#endif /* __svr4__ && __sun__ */
+#endif
+
+
+/* define strrchr, strchr and memcpy, memmove in terms of bsd funcs
+   make sure you are NOT using bcopy, index or rindex in the code */
+      
+#ifdef STDC_HEADERS
+# include <string.h>
+#else
+# ifndef HAVE_STRCHR
+#  define strchr index
+#  define strrchr rindex
+# endif
+char *strchr (), *strrchr ();
+# ifndef HAVE_MEMMOVE
+#  define memcpy(d, s, n) bcopy ((s), (d), (n))
+#  define memmove(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#ifdef NO_NULL_REALLOC
+# define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))
+#else
+# define rrd_realloc(a,b) realloc((a), (b))
+#endif
+
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#ifdef HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# ifdef HAVE_SYS_NDIR_H
+#  include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+#  include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+#  include <ndir.h>
+# endif
+#endif
+
+#ifdef MUST_DISABLE_SIGFPE
+# include <signal.h>
+#endif
+
+#ifdef MUST_DISABLE_FPMASK
+# include <floatingpoint.h>
+#endif
+
+
+#ifdef HAVE_MATH_H
+# include <math.h>
+#endif
+
+#ifdef HAVE_FLOAT_H
+# include <float.h>
+#endif
+
+#ifdef HAVE_IEEEFP_H
+# include <ieeefp.h>
+#endif
+
+#ifdef HAVE_FP_CLASS_H
+# include <fp_class.h>
+#endif
+
+/* for Solaris */
+#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
+#  define HAVE_ISINF 1
+#  ifdef isinf
+#  undef isinf
+#  endif
+#  define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
+#endif
+
+/* solaris 10 it defines isnan such that only forte can compile it ... bad bad  */
+#if (defined(HAVE_ISNAN) && defined(isnan) && defined(HAVE_FPCLASS))
+#  undef isnan
+#  define isnan(a) (fpclass(a) == FP_SNAN || fpclass(a) == FP_QNAN)
+#endif
+
+/* for OSF1 Digital Unix */
+#if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
+#  define HAVE_ISINF 1
+#  define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
+#endif
+
+#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
+#  define HAVE_ISINF 1
+#  define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
+#endif
+
+#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
+#  define HAVE_ISINF 1
+#  define isinf(a) (fpclassify(a) == FP_INFINITE)
+#endif
+
+/* for AIX */
+#if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
+#  define HAVE_ISINF 1
+#  define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
+#endif
+
+#if (! defined (HAVE_FINITE) && defined (HAVE_ISFINITE))
+#  define HAVE_FINITE 1
+#  define finite(a) isfinite(a)
+#endif
+
+#if (! defined(HAVE_FINITE) && defined(HAVE_ISNAN) && defined(HAVE_ISINF))
+#  define HAVE_FINITE 1
+#  define finite(a) (! isnan(a) && ! isinf(a))
+#endif
+
+#ifndef HAVE_FINITE
+#error "Can't compile without finite function"
+#endif
+
+#ifndef HAVE_ISINF
+#error "Can't compile without isinf function"
+#endif
+
+#if (! defined(HAVE_FDATASYNC) && defined(HAVE_FSYNC))
+#define fdatasync fsync
+#endif
+
+#if (!defined(HAVE_FDATASYNC) && !defined(HAVE_FSYNC))
+#error "Can't compile with without fsync and fdatasync"
+#endif
+
+#endif /* RRD_CONFIG_BOTTOM_H */
+
index dd07f51..e9e6f11 100644 (file)
@@ -245,7 +245,7 @@ enum rra_par_en { RRA_cdp_xff_val = 0,  /* what part of the consolidated
     RRA_delta_neg = 2,
     /* RRA_dependent_rra_idx = 3, */
     RRA_window_len = 4,
-    RRA_failure_threshold = 5,
+    RRA_failure_threshold = 5
     /* For CF_FAILURES, number of violations within the last
      * window required to mark a failure. */
 };
index dc12ed6..ea5d8c3 100644 (file)
@@ -3713,11 +3713,17 @@ rrd_info_t *rrd_graph_v(
 static void 
 rrd_set_font_desc (
     image_desc_t *im,int prop,char *font, double size ){
-    strncpy(im->text_prop[prop].font, font, sizeof(text_prop[prop].font) - 1);        
-    im->text_prop[prop].font[sizeof(text_prop[prop].font) - 1] = '\0';   
-    im->text_prop[prop].size = size;
-    im->text_prop[prop].font_desc =   pango_font_description_from_string( font );
-    pango_font_description_set_size(im->text_prop[prop].font_desc, size * PANGO_SCALE);
+    if (font){
+        strncpy(im->text_prop[prop].font, font, sizeof(text_prop[prop].font) - 1);        
+        im->text_prop[prop].font[sizeof(text_prop[prop].font) - 1] = '\0';   
+        im->text_prop[prop].font_desc = pango_font_description_from_string( font );        
+    };
+    if (size > 0){  
+        im->text_prop[prop].size = size;
+    };
+    if (im->text_prop[prop].font_desc && im->text_prop[prop].size ){
+        pango_font_description_set_size(im->text_prop[prop].font_desc, im->text_prop[prop].size * PANGO_SCALE);
+    };
 }
 
 void rrd_graph_init(