fix ifdef use
[rrdtool.git] / src / rrd_tool.c
index cc2aede..d46d195 100644 (file)
@@ -8,6 +8,8 @@
 #include "../win32/config.h"
 #include <stdlib.h>
 #include <sys/stat.h>
+#include <io.h>
+#include <fcntl.h>
 #else
 #ifdef HAVE_CONFIG_H
 #include "../rrd_config.h"
@@ -414,6 +416,12 @@ int main(
        according to localeconv(3) */       
     setlocale(LC_ALL, "");
 
+#if defined(WIN32) && !defined(__CYGWIN__)
+    setmode(fileno(stdout), O_BINARY);
+    setmode(fileno(stdin), O_BINARY);
+#endif
+
+
 #if defined(HAVE_LIBINTL_H) && defined(BUILD_LIBINTL)
     bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
     textdomain(GETTEXT_PACKAGE);
@@ -695,6 +703,7 @@ int HandleInputLine(
             free(data);
         }
     } else if (strcmp("xport", argv[1]) == 0) {
+#ifdef HAVE_RRD_GRAPH
         int       xxsize;
         unsigned long int j = 0;
         time_t    start, end, ti;
@@ -771,7 +780,11 @@ int HandleInputLine(
             setlocale(LC_NUMERIC, old_locale);
         }
         free(vtag);
+#else
+        rrd_set_error("the instance of rrdtool has been compiled without graphics");
+#endif
     } else if (strcmp("graph", argv[1]) == 0) {
+#ifdef HAVE_RRD_GRAPH
         char    **calcpr;
 
 #ifdef notused /*XXX*/
@@ -805,7 +818,11 @@ int HandleInputLine(
             }
         }
 
+#else
+       rrd_set_error("the instance of rrdtool has been compiled without graphics");
+#endif
     } else if (strcmp("graphv", argv[1]) == 0) {
+#ifdef HAVE_RRD_GRAPH
         rrd_info_t *grinfo = NULL;  /* 1 to distinguish it from the NULL that rrd_graph sends in */
 
         grinfo = rrd_graph_v(argc - 1, &argv[1]);
@@ -813,7 +830,9 @@ int HandleInputLine(
             rrd_info_print(grinfo);
             rrd_info_free(grinfo);
         }
-
+#else
+       rrd_set_error("the instance of rrdtool has been compiled without graphics");
+#endif
     } else if (strcmp("tune", argv[1]) == 0)
         rrd_tune(argc - 1, &argv[1]);
 #ifndef WIN32