X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=d63dbc5dce0bc3a27576d4d156d7185f1313da23;hp=0152dd1a801348d10c0401f8a54331d753de7562;hb=3f3ba4efe16c38860f9ec66c6219711af435e366;hpb=c112f7c06e534ce7a5a4e25b6f7f742aeb051850 diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 0152dd1..d63dbc5 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2rc3 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2rc4 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd__graph.c produce graphs from data in rrdfiles ****************************************************************************/ @@ -9,7 +9,7 @@ #include "rrd_tool.h" -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) #include #include #endif @@ -27,9 +27,6 @@ /* some constant definitions */ -#ifdef WIN32 -char rrd_win_default_font[80]; -#endif #ifndef RRD_DEFAULT_FONT /* there is special code later to pick Cour.ttf when running on windows */ @@ -2100,7 +2097,9 @@ graph_size_location(image_desc_t *im, int elements Xtitle =0, Ytitle =0, Xylabel =0, Yylabel =0, Xmain =0, Ymain =0, +#ifdef WITH_PIECHART Xpie =0, Ypie =0, +#endif Xxlabel =0, Yxlabel =0, #if 0 Xlegend =0, Ylegend =0, @@ -2108,18 +2107,22 @@ graph_size_location(image_desc_t *im, int elements Xspacing =10, Yspacing =10; if (im->extra_flags & ONLY_GRAPH) { - Xspacing =0; - Yspacing =0; - } else { - if (im->ylegend[0] != '\0') { + im->xorigin =0; + im->ximg = im->xsize; + im->yimg = im->ysize; + im->yorigin = im->ysize; + return 0; + } + + if (im->ylegend[0] != '\0' ) { Xvertical = im->text_prop[TEXT_PROP_UNIT].size *2; Yvertical = gfx_get_text_width(im->canvas, 0, im->text_prop[TEXT_PROP_UNIT].font, im->text_prop[TEXT_PROP_UNIT].size, im->tabwidth,im->ylegend, 0); - } } + if (im->title[0] != '\0') { /* The title is placed "inbetween" two text lines so it ** automatically has some vertical spacing. The horizontal @@ -2165,23 +2168,22 @@ graph_size_location(image_desc_t *im, int elements ** forget about it at all; the legend will have to fit in the ** size already allocated. */ - im->ximg = Xmain; + im->ximg = Xylabel + Xmain + 2 * Xspacing; - if ( !(im->extra_flags & ONLY_GRAPH) ) { - im->ximg = Xylabel + Xmain + Xpie + 2 * Xspacing; - } +#ifdef WITH_PIECHART + im->ximg += Xpie; +#endif if (Xmain) im->ximg += Xspacing; +#ifdef WITH_PIECHART if (Xpie) im->ximg += Xspacing; +#endif - if (im->extra_flags & ONLY_GRAPH) { - im->xorigin = 0; - } else { - im->xorigin = Xspacing + Xylabel; - } + im->xorigin = Xspacing + Xylabel; if (Xtitle > im->ximg) im->ximg = Xtitle; - if (Xvertical) { + + if (Xvertical) { /* unit description */ im->ximg += Xvertical; im->xorigin += Xvertical; } @@ -2198,19 +2200,13 @@ graph_size_location(image_desc_t *im, int elements /* reserve space for main and/or pie */ - if (im->extra_flags & ONLY_GRAPH) { - im->yimg = Ymain; - } else { - im->yimg = Ymain + Yxlabel; - } + im->yimg = Ymain + Yxlabel; +#ifdef WITH_PIECHART if (im->yimg < Ypie) im->yimg = Ypie; +#endif - if (im->extra_flags & ONLY_GRAPH) { - im->yorigin = im->yimg; - } else { - im->yorigin = im->yimg - Yxlabel; - } + im->yorigin = im->yimg - Yxlabel; /* reserve space for the title *or* some padding above the graph */ if (Ytitle) { @@ -2570,7 +2566,7 @@ graph_paint(image_desc_t *im, char ***calcpr) if (strcmp(im->graphfile,"-")==0) { fo = im->graphhandle ? im->graphhandle : stdout; -#ifdef WIN32 +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) /* Change translation mode for stdout to BINARY */ _setmode( _fileno( fo ), O_BINARY ); #endif @@ -2769,19 +2765,34 @@ rrd_graph_init(image_desc_t *im) for(i=0;igraph_col[i]=graph_col[i]; -#ifdef WIN32 + +#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) { char *windir; + char rrd_win_default_font[1000]; windir = getenv("windir"); /* %windir% is something like D:\windows or C:\winnt */ if (windir != NULL) { - strcpy(rrd_win_default_font,windir); + strncpy(rrd_win_default_font,windir,999); + rrd_win_default_font[999] = '\0'; strcat(rrd_win_default_font,"\\fonts\\cour.ttf"); - for(i=0;itext_prop[i].size = text_prop[i].size; strcpy(im->text_prop[i].font,text_prop[i].font); @@ -2911,6 +2922,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) &im->xlab_user.precis, &stroff) == 7 && stroff != 0){ strncpy(im->xlab_form, optarg+stroff, sizeof(im->xlab_form) - 1); + im->xlab_form[sizeof(im->xlab_form)-1] = '\0'; if((int)(im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1){ rrd_set_error("unknown keyword %s",scan_gtm); return;