Code

extra output formats for rrd_graph -- martin sperl
[rrdtool.git] / src / rrd_graph.c
index aa561f6ed4e922e1fd5721505e93946a0e282bc5..aba5b6f70493cf288c8ae181e86089c4cbf50ee4 100644 (file)
@@ -91,8 +91,7 @@ xlab_t    xlab[] = {
     ,
     {3600, 0, TMT_DAY, 1, TMT_WEEK, 1, TMT_WEEK, 1, 7 * 24 * 3600, week_fmt}
     ,
-    {3 * 3600, 0, TMT_WEEK, 1, TMT_MONTH, 1, TMT_WEEK, 2, 7 * 24 * 3600,
-     week_fmt}
+    {3 * 3600, 0, TMT_WEEK, 1, TMT_MONTH, 1, TMT_WEEK, 2, 7 * 24 * 3600, week_fmt}
     ,
     {6 * 3600, 0, TMT_MONTH, 1, TMT_MONTH, 1, TMT_MONTH, 1, 30 * 24 * 3600,
      "%b"}
@@ -257,6 +256,13 @@ enum gfx_if_en if_conv(
     conv_if(SVG, IF_SVG);
     conv_if(EPS, IF_EPS);
     conv_if(PDF, IF_PDF);
+    conv_if(XML, IF_XML);
+    conv_if(XMLENUM, IF_XMLENUM);
+    conv_if(CSV, IF_CSV);
+    conv_if(TSV, IF_TSV);
+    conv_if(SSV, IF_SSV);
+    conv_if(JSON, IF_JSON);
+    conv_if(JSONTIME, IF_JSONTIME);
 
     return (enum gfx_if_en)(-1);
 }
@@ -413,8 +419,11 @@ void auto_scale(
     }
 }
 
+/* power prefixes */
 
 static char si_symbol[] = {
+    'y',                /* 10e-24 Yocto */
+    'z',                /* 10e-21 Zepto */
     'a',                /* 10e-18 Atto */
     'f',                /* 10e-15 Femto */
     'p',                /* 10e-12 Pico */
@@ -428,8 +437,10 @@ static char si_symbol[] = {
     'T',                /* 10e12  Tera */
     'P',                /* 10e15  Peta */
     'E',                /* 10e18  Exa */
+    'Z',                /* 10e21  Zeta */
+    'Y'                 /* 10e24  Yotta */
 };
-static const int si_symbcenter = 6;
+static const int si_symbcenter = 8;
 
 /* find SI magnitude symbol for the numbers on the y-axis*/
 void si_unit(
@@ -1786,6 +1797,7 @@ int leg_place(
                 prt_fctn != 'j' &&
                 prt_fctn != 'c' &&
                 prt_fctn != 'u' &&
+                prt_fctn != '.' &&
                 prt_fctn != 's' && prt_fctn != '\0' && prt_fctn != 'g') {
                 free(legspace);
                 rrd_set_error
@@ -1797,6 +1809,10 @@ int leg_place(
             if (prt_fctn == 'n') {
                 prt_fctn = 'l';
             }
+            /* \. is a null operation to allow strings ending in \x */
+            if (prt_fctn == '.') {
+                prt_fctn = '\0';
+            }
 
             /* remove exess space from the end of the legend for \g */
             while (prt_fctn == 'g' &&
@@ -3396,6 +3412,14 @@ int graph_paint(
         cairo_svg_surface_restrict_to_version
             (im->surface, CAIRO_SVG_VERSION_1_1);
         break;
+    case IF_XML:
+    case IF_XMLENUM:
+    case IF_CSV:
+    case IF_TSV:
+    case IF_SSV:
+    case IF_JSON:
+    case IF_JSONTIME:
+        break;
     };
     cairo_destroy(im->cr);
     im->cr = cairo_create(im->surface);
@@ -4008,6 +4032,10 @@ int rrd_graph(
 ** - options parsing  now in rrd_graph_options()
 ** - script parsing   now in rrd_graph_script()
 */
+
+/* have no better idea where to put it - rrd.h does not work */
+int       rrd_graph_xport(image_desc_t *);
+
 rrd_info_t *rrd_graph_v(
     int argc,
     char **argv)
@@ -4059,6 +4087,10 @@ rrd_info_t *rrd_graph_v(
         return NULL;
     }
 
+    if (im.imgformat >= IF_XML) {
+      rrd_graph_xport(&im);
+   } else {
+
     /* Everything is now read and the actual work can start */
 
     if (graph_paint(&im) == -1) {
@@ -4066,7 +4098,7 @@ rrd_info_t *rrd_graph_v(
         im_free(&im);
         return NULL;
     }
-
+   }
 
     /* The image is generated and needs to be output.
      ** Also, if needed, print a line with information about the image.