, VDEF_LSLCORREL /* least squares line correlation coefficient */
, VDEF_PERCENTNAN /* Nth percentile ignoring NAN*/
};
-enum text_prop_en {
+enum text_prop_en {
TEXT_PROP_DEFAULT = 0, /* default settings */
TEXT_PROP_TITLE, /* properties for the title */
TEXT_PROP_AXIS, /* for the numbers next to the axis */
enum legend_pos{ NORTH = 0, WEST, SOUTH, EAST };
enum legend_direction { TOP_DOWN = 0, BOTTOM_UP, BOTTOM_UP2 };
-enum gfx_if_en { IF_PNG = 0, IF_SVG, IF_EPS, IF_PDF,
+enum gfx_if_en { IF_PNG = 0, IF_SVG, IF_EPS, IF_PDF,
IF_XML=128, IF_CSV=129, IF_TSV=130, IF_SSV=131, IF_JSON=132,
IF_XMLENUM=133, IF_JSONTIME=134
};
keyvalue_t *kv_args; /* key value arguments */
} parsedargs_t;
void initParsedArguments(parsedargs_t*);
+void resetParsedArguments(parsedargs_t*);
void freeParsedArguments(parsedargs_t*);
int addToArguments(parsedargs_t*, char*, char*, char*, int);
int parseArguments(const char*, parsedargs_t*);
double second_axis_scale; /* relative to the first axis (0 to disable) */
double second_axis_shift; /* how much is it shifted vs the first axis */
char *second_axis_legend; /* label to put on the seond axis */
- char *second_axis_format; /* format for the numbers on the scond axis */
+ char *second_axis_format; /* format for the numbers on the scond axis */
char *primary_axis_format; /* format for the numbers on the primary axis */
double ygridstep; /* user defined step for y grid */
int ylabfact; /* every how many y grid shall a label be written ? */
time_t start, end; /* what time does the graph cover */
unsigned long step; /* any preference for the default step ? */
rrd_value_t minval, maxval; /* extreme values in the data */
- int rigid; /* do not expand range even with
+ int rigid; /* do not expand range even with
values outside */
ygrid_scale_t ygrid_scale; /* calculated y axis grid info */
int gridfit; /* adjust y-axis range etc so all
grindlines falls in integer pixel values */
- char *imginfo; /* construct an <IMG ... tag and return
+ char *imginfo; /* construct an <IMG ... tag and return
as first retval */
enum gfx_if_en imgformat; /* image format */
char *daemon_addr; /* rrdcached connection string */
double x,
double y);
-/* create a rect that has a gradient from color1 to color2 in height pixels
+/* create a rect that has a gradient from color1 to color2 in height pixels
* height > 0:
* gradient starts at top and goes down a fixed number of pixels (fire style)
* height < 0:
gfx_color_t color1,
gfx_color_t color2,
double height);
-
+
/* close current path so it ends at the same point as it started */
initParsedArguments(pa);
}
+void resetParsedArguments(parsedargs_t* pa) {
+ if (pa->kv_args) {
+ for(int i=0;i<pa->kv_cnt;i++) {
+ if (pa->kv_args[i].flag!=255) {
+ pa->kv_args[i].flag=0;
+ }
+ }
+ }
+}
+
void dumpKeyValue(char* pre,keyvalue_t* t) {
if (t) {
fprintf(stderr,"%s%i: '%s' = '%s' %i\n",
#define PARSE_VNAMECOLORFRACTIONLEGEND (PARSE_VNAMECOLORLEGEND|PARSE_FRACTION)
#define PARSE_VNAMERPN (PARSE_POSITIONAL|PARSE_VNAMEDEF|PARSE_RPN)
#define PARSE_VNAMEREFPOS (PARSE_POSITIONAL|PARSE_VNAMEREF)
+/* a retry parsing */
+#define PARSE_RETRY (1ULL<<54)
GHashTable* gdef_map;
if ((bits&PARSE_FIELD1)&&((bits&(PARSE_FIELD2|PARSE_FIELD3|PARSE_FIELD4)))) {
rrd_set_error("newGraphDescription: bad bitfield1 value %08llx",bits);return NULL; }
/* the normal handler that adds to img */
- if (gdes_alloc(im)) { return NULL; }
+ if ((!(bits & PARSE_RETRY)) && (gdes_alloc(im))) { return NULL; }
/* set gdp */
graph_desc_t *gdp= &im->gdes[im->gdes_c - 1];
/* set some generic things */
gdp->gf=gf;
- if (1) {
+ {
char *t,*x;
long debug=0;
if ((t=getKeyValueArgument("debug",1,pa)) && ((getLong(t,&debug,&x,10)))) {
- rrd_set_error("Bad debug value: %s",t); return NULL; }
+ rrd_set_error("Bad debug value: %s",t);
+ return NULL;
+ }
gdp->debug=debug;
}
if (bitscmp(PARSE_COLOR2) && (! color2) && (h2)) { color2=h2;}
}
+ /* clean up vname escaping on second tries */
+ if (bits & PARSE_RETRY) {
+ if (vname && (*vname>128)) {
+ *vname-=128;
+ }
+ }
+
/* check if we are reusing the vname */
if (vname) {
int idx=find_var(im, vname);
|PARSE_END
|PARSE_REDUCE
);
- if (!gdp) { return 1;}
+ /* retry in case of errors modifying the name*/
+ if (!gdp) {
+ rrd_clear_error();
+ /* restart from scratch */
+ resetParsedArguments(pa);
+ /* but modify the first parameter */
+ keyvalue_t *first= getFirstUnusedArgument(0,pa);
+ *(first->key)+=128;
+ /* now run it */
+ gdp=newGraphDescription(im,gf,pa,
+ PARSE_VNAMERRDDSCF
+ |PARSE_START
+ |PARSE_STEP
+ |PARSE_END
+ |PARSE_REDUCE
+ |PARSE_RETRY
+ );
+ if (!gdp) { return 1;}
+ }
if (gdp->step == 0){
gdp->step = im->step; /* initialize with image wide step */
if (first) {
gdp->cf=cf_conv(first->value);
if (((int)gdp->cf)==-1) {
- rrd_set_error("bad CF: %s",first->value); return 1; }
+ rrd_set_error("bad CF for DEF/CDEF: %s",first->value); return 1; }
} else { rrd_set_error("No positional CDEF"); return 1; }
}
break;
/* now let us handle the field based on the first command or cmd=...*/
char*cmd=NULL;
/* and try to get via cmd */
- char* t=getKeyValueArgument("cmd",1,&pa);
+ char* t=getKeyValueArgument("cmd",255,&pa);
if (t) {
cmd=t;
- } else if ((t=getKeyValueArgument("pos0",1,&pa))) {
+ } else if ((t=getKeyValueArgument("pos0",255,&pa))) {
cmd=t;
} else {
rrd_set_error("no command set in argument %s",pa.arg_orig);