1 /****************************************************************************
2 * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007
3 ****************************************************************************
4 * rrd_graph_helper.c commandline parser functions
5 * this code initially written by Alex van den Bogaerdt
6 ****************************************************************************/
10 #define dprintf if (gdp->debug) printf
14 * we use the following:
16 * i=0; sscanf(&line[*eaten], "what to find%n", variables, &i)
18 * Usually you want to find a separator as well. Example:
19 * i=0; sscanf(&line[*eaten], "%li:%n", &someint, &i)
21 * When the separator is not found, i is not set and thus remains zero.
22 * Another way would be to compare strlen() to i
24 * Why is this important? Because 12345abc should not be matched as
30 * "if ((gdp->vidx=find_var(im, l))!=-1)" is not good enough, at least
33 * A vname as a result of a VDEF is quite different from a vname
34 * resulting of a DEF or CDEF.
39 * A vname called "123" is not to be parsed as the number 123
43 /* Define prototypes for the parsing methods.
45 const char *const line - a fixed pointer to a fixed string
46 unsigned int *const eaten - a fixed pointer to a changing index in that line
47 graph_desc_t *const gdp - a fixed pointer to a changing graph description
48 image_desc_t *const im - a fixed pointer to a changing image description
51 int rrd_parse_find_gf(
65 int rrd_parse_textalign(
95 int rrd_parse_PVHLAST(
101 int rrd_parse_make_vname(
105 image_desc_t *const);
107 int rrd_parse_find_vname(
111 image_desc_t *const);
117 image_desc_t *const);
123 image_desc_t *const);
129 image_desc_t *const);
131 int rrd_parse_find_gf(
132 const char *const line,
133 unsigned int *const eaten,
134 graph_desc_t *const gdp)
136 char funcname[11], c1 = 0;
139 /* start an argument with DEBUG to be able to see how it is parsed */
140 sscanf(&line[*eaten], "DEBUG%n", &i);
145 dprintf("Scanning line '%s'\n", &line[*eaten]);
149 sscanf(&line[*eaten], "%10[A-Z]%n%c", funcname, &i, &c1);
151 rrd_set_error("Could not make sense out of '%s'", line);
155 if ((int) (gdp->gf = gf_conv(funcname)) == -1) {
156 rrd_set_error("'%s' is not a valid function name", funcname);
159 dprintf("- found function name '%s'\n", funcname);
163 rrd_set_error("Function %s needs parameters. Line: %s\n", funcname,
170 /* Some commands have a parameter before the colon
171 * (currently only LINE)
177 dprintf("- - using default width of 1\n");
180 sscanf(&line[*eaten], "%lf:%n", &gdp->linewidth, &i);
182 rrd_set_error("Cannot parse line width '%s' in line '%s'\n",
183 &line[*eaten], line);
186 dprintf("- - scanned width %f\n", gdp->linewidth);
187 if (isnan(gdp->linewidth)) {
189 ("LINE width '%s' is not a number in line '%s'\n",
190 &line[*eaten], line);
193 if (isinf(gdp->linewidth)) {
195 ("LINE width '%s' is out of range in line '%s'\n",
196 &line[*eaten], line);
199 if (gdp->linewidth < 0) {
201 ("LINE width '%s' is less than 0 in line '%s'\n",
202 &line[*eaten], line);
212 rrd_set_error("Malformed '%s' command in line '%s'\n", &line[*eaten],
216 if (line[*eaten] == '\0') {
217 rrd_set_error("Expected some arguments after '%s'\n", line);
223 int rrd_parse_legend(
224 const char *const line,
225 unsigned int *const eaten,
226 graph_desc_t *const gdp)
230 if (line[*eaten] == '\0' || line[*eaten] == ':') {
231 dprintf("- no (or: empty) legend found\n");
235 i = scan_for_col(&line[*eaten], FMT_LEG_LEN, gdp->legend);
239 if (line[*eaten] != '\0' && line[*eaten] != ':') {
240 rrd_set_error("Legend too long");
248 const char *const string,
249 graph_desc_t *const gdp)
251 unsigned int r = 0, g = 0, b = 0, a = 0, i;
253 /* matches the following formats:
261 while (string[i] && isxdigit((unsigned int) string[i]))
263 if (string[i] != '\0')
264 return 1; /* garbage follows hexdigits */
268 sscanf(string, "%1x%1x%1x%1x", &r, &g, &b, &a);
278 sscanf(string, "%02x%02x%02x%02x", &r, &g, &b, &a);
283 return 1; /* wrong number of digits */
285 gdp->col = gfx_hex_to_col(r << 24 | g << 16 | b << 8 | a);
290 const char *const line,
291 unsigned int *const eaten,
292 graph_desc_t *const gdp,
295 char symname[CF_NAM_SIZE];
298 sscanf(&line[*eaten], CF_NAM_FMT "%n", symname, &i);
299 if ((!i) || ((line[(*eaten) + i] != '\0') && (line[(*eaten) + i] != ':'))) {
300 rrd_set_error("Cannot parse CF in '%s'", line);
304 dprintf("- using CF '%s'\n", symname);
306 if ((int) (*cf = cf_conv(symname)) == -1) {
307 rrd_set_error("Unknown CF '%s' in '%s'", symname, line);
311 if (line[*eaten] != '\0')
316 /* Try to match next token as a vname.
319 * -1 an error occured and the error string is set
320 * other the vname index number
322 * *eaten is incremented only when a vname is found.
324 int rrd_parse_find_vname(
325 const char *const line,
326 unsigned int *const eaten,
327 graph_desc_t *const gdp,
328 image_desc_t *const im)
330 char tmpstr[MAX_VNAME_LEN + 1];
335 sscanf(&line[*eaten], DEF_NAM_FMT "%n", tmpstr, &i);
337 rrd_set_error("Could not parse line '%s'", line);
340 if (line[*eaten + i] != ':' && line[*eaten + i] != '\0') {
341 rrd_set_error("Could not parse line '%s'", line);
344 dprintf("- Considering '%s'\n", tmpstr);
346 if ((vidx = find_var(im, tmpstr)) < 0) {
347 dprintf("- Not a vname\n");
348 rrd_set_error("Not a valid vname: %s in line %s", tmpstr, line);
351 dprintf("- Found vname '%s' vidx '%li'\n", tmpstr, gdp->vidx);
352 if (line[*eaten + i] == ':')
358 /* Parsing old-style xPRINT and new-style xPRINT */
360 const char *const line,
361 unsigned int *const eaten,
362 graph_desc_t *const gdp,
363 image_desc_t *const im)
365 /* vname:CF:format in case of DEF-based vname
366 ** vname:CF:format in case of CDEF-based vname
367 ** vname:format[:strftime] in case of VDEF-based vname
369 if ((gdp->vidx = rrd_parse_find_vname(line, eaten, gdp, im)) < 0)
372 switch (im->gdes[gdp->vidx].gf) {
375 dprintf("- vname is of type DEF or CDEF, looking for CF\n");
376 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf))
380 dprintf("- vname is of type VDEF\n");
383 rrd_set_error("Encountered unknown type variable '%s'",
384 im->gdes[gdp->vidx].vname);
388 if (rrd_parse_legend(line, eaten, gdp))
390 /* for *PRINT the legend itself gets rendered later. We only
391 get the format at this juncture */
392 strcpy(gdp->format, gdp->legend);
393 gdp->legend[0] = '\0';
394 /* this is a very crud test, parsing :style flags should be in a function */
395 if (im->gdes[gdp->vidx].gf == GF_VDEF
396 && strcmp(line + (*eaten), ":strftime") == 0) {
398 (*eaten) += strlen(":strftime");
403 /* SHIFT:_def_or_cdef:_vdef_or_number_
406 const char *const line,
407 unsigned int *const eaten,
408 graph_desc_t *const gdp,
409 image_desc_t *const im)
413 if ((gdp->vidx = rrd_parse_find_vname(line, eaten, gdp, im)) < 0)
416 switch (im->gdes[gdp->vidx].gf) {
419 dprintf("- vname is of type DEF or CDEF, OK\n");
422 rrd_set_error("Cannot shift a VDEF: '%s' in line '%s'\n",
423 im->gdes[gdp->vidx].vname, line);
426 rrd_set_error("Encountered unknown type variable '%s' in line '%s'",
427 im->gdes[gdp->vidx].vname, line);
431 if ((gdp->shidx = rrd_parse_find_vname(line, eaten, gdp, im)) >= 0) {
432 switch (im->gdes[gdp->shidx].gf) {
435 rrd_set_error("Offset cannot be a (C)DEF: '%s' in line '%s'\n",
436 im->gdes[gdp->shidx].vname, line);
439 dprintf("- vname is of type VDEF, OK\n");
443 ("Encountered unknown type variable '%s' in line '%s'",
444 im->gdes[gdp->vidx].vname, line);
451 sscanf(&line[*eaten], "%li%n", &time_tmp, &i);
452 gdp->shval = time_tmp;
453 if (i != (int) strlen(&line[*eaten])) {
454 rrd_set_error("Not a valid offset: %s in line %s", &line[*eaten],
459 dprintf("- offset is number %li\n", gdp->shval);
465 /* XPORT:_def_or_cdef[:legend]
468 const char *const line,
469 unsigned int *const eaten,
470 graph_desc_t *const gdp,
471 image_desc_t *const im)
473 if ((gdp->vidx = rrd_parse_find_vname(line, eaten, gdp, im)) < 0)
476 switch (im->gdes[gdp->vidx].gf) {
479 dprintf("- vname is of type DEF or CDEF, OK\n");
482 rrd_set_error("Cannot xport a VDEF: '%s' in line '%s'\n",
483 im->gdes[gdp->vidx].vname, line);
486 rrd_set_error("Encountered unknown type variable '%s' in line '%s'",
487 im->gdes[gdp->vidx].vname, line);
490 dprintf("- looking for legend in '%s'\n", &line[*eaten]);
491 if (rrd_parse_legend(line, eaten, gdp))
496 int rrd_parse_textalign(
497 const char *const line,
498 unsigned int *const eaten,
499 graph_desc_t *const gdp)
501 if (strcmp(&line[*eaten], "left") == 0) {
502 gdp->txtalign = TXA_LEFT;
503 } else if (strcmp(&line[*eaten], "right") == 0) {
504 gdp->txtalign = TXA_RIGHT;
505 } else if (strcmp(&line[*eaten], "justified") == 0) {
506 gdp->txtalign = TXA_JUSTIFIED;
507 } else if (strcmp(&line[*eaten], "center") == 0) {
508 gdp->txtalign = TXA_CENTER;
510 rrd_set_error("Unknown alignement type '%s'", &line[*eaten]);
513 *eaten += strlen(&line[*eaten]);
518 /* Parsing of PART, VRULE, HRULE, LINE, AREA, STACK and TICK
519 ** is done in one function.
521 ** Stacking PART, VRULE, HRULE or TICK is not allowed.
523 ** If a number (which is valid to enter) is more than a
524 ** certain amount of characters, it is caught as an error.
525 ** While this is arguable, so is entering fixed numbers
526 ** with more than MAX_VNAME_LEN significant digits.
528 int rrd_parse_PVHLAST(
529 const char *const line,
530 unsigned int *const eaten,
531 graph_desc_t *const gdp,
532 image_desc_t *const im)
536 char tmpstr[MAX_VNAME_LEN + 10]; /* vname#RRGGBBAA\0 */
537 static int spacecnt = 0;
540 float one_space = gfx_get_text_width(im, 0,
542 text_prop[TEXT_PROP_LEGEND].
545 text_prop[TEXT_PROP_LEGEND].
547 im->tabwidth, " ") / 4.0;
548 float target_space = gfx_get_text_width(im, 0,
551 [TEXT_PROP_LEGEND].font,
554 [TEXT_PROP_LEGEND].size,
557 spacecnt = target_space / one_space;
558 dprintf("- spacecnt: %i onespace: %f targspace: %f\n", spacecnt,
559 one_space, target_space);
563 dprintf("- parsing '%s'\n", &line[*eaten]);
565 /* have simpler code in the drawing section */
566 if (gdp->gf == GF_STACK) {
570 i = scan_for_col(&line[*eaten], MAX_VNAME_LEN + 9, tmpstr);
571 if (line[*eaten + i] != '\0' && line[*eaten + i] != ':') {
572 rrd_set_error("Cannot parse line '%s'", line);
577 while (j > 0 && tmpstr[j] != '#')
584 * tmpstr[0] containing vname
585 * tmpstr[j] if j!=0 then containing color
586 * i size of vname + color
587 * j if j!=0 then size of vname
591 * If it is an existing vname, that's OK, provided that it is a
592 * valid type (need time for VRULE, not a float)
593 * Else see if it parses as a number.
595 dprintf("- examining string '%s'\n", tmpstr);
596 if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
597 dprintf("- found vname: '%s' vidx %li\n", tmpstr, gdp->vidx);
604 if (im->gdes[gdp->vidx].gf != GF_VDEF) {
605 rrd_set_error("Using vname %s of wrong type in line %s\n",
606 im->gdes[gdp->gf].vname, line);
614 dprintf("- it is not an existing vname\n");
618 sscanf(tmpstr, "%li%n",&time_tmp , &k);
619 gdp->xrule = time_tmp;
620 if (((j != 0) && (k == j)) || ((j == 0) && (k == i))) {
621 dprintf("- found time: %li\n", gdp->xrule);
623 dprintf("- is is not a valid number: %li\n", gdp->xrule);
625 ("parameter '%s' does not represent time in line %s\n",
631 sscanf(tmpstr, "%lf%n", &gdp->yrule, &k);
632 if (((j != 0) && (k == j)) || ((j == 0) && (k == i))) {
633 dprintf("- found number: %lf\n", gdp->yrule);
635 dprintf("- is is not a valid number: %lf\n", gdp->yrule);
637 ("parameter '%s' does not represent a number in line %s\n",
646 dprintf("- examining color '%s'\n", &tmpstr[j]);
647 if (rrd_parse_color(&tmpstr[j], gdp)) {
648 rrd_set_error("Could not parse color in '%s'", &tmpstr[j]);
651 dprintf("- parsed color %0.0f,%0.0f,%0.0f,%0.0f\n", gdp->col.red,
652 gdp->col.green, gdp->col.blue, gdp->col.alpha);
655 dprintf("- no color present in '%s'\n", tmpstr);
658 (*eaten) += i; /* after vname#color */
659 if (line[*eaten] != '\0') {
660 (*eaten)++; /* after colon */
663 if (gdp->gf == GF_TICK) {
664 dprintf("- parsing '%s'\n", &line[*eaten]);
665 dprintf("- looking for optional TICK number\n");
667 sscanf(&line[*eaten], "%lf%n", &gdp->yrule, &j);
669 if (line[*eaten + j] != '\0' && line[*eaten + j] != ':') {
670 rrd_set_error("Cannot parse TICK fraction '%s'", line);
673 dprintf("- found number %f\n", gdp->yrule);
674 if (gdp->yrule > 1.0 || gdp->yrule < -1.0) {
675 rrd_set_error("Tick factor should be <= 1.0");
680 dprintf("- not found, defaulting to 0.1\n");
683 if (line[*eaten] == '\0') {
684 dprintf("- done parsing line\n");
687 if (line[*eaten] == ':') {
690 rrd_set_error("Can't make sense of that TICK line");
696 dprintf("- parsing '%s'\n", &line[*eaten]);
698 /* Legend is next. A legend without a color is an error.
699 ** Stacking an item without having a legend is OK however
700 ** then an empty legend should be specified.
701 ** LINE:val#color:STACK means legend is string "STACK"
702 ** LINE:val#color::STACK means no legend, and do STACK
703 ** LINE:val:STACK is an error (legend but no color)
704 ** LINE:val::STACK means no legend, and do STACK
708 char *linecp = strdup(line);
710 dprintf("- looking for optional legend\n");
712 dprintf("- examining '%s'\n", &line[*eaten]);
713 if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') {
716 /* If the legend is not empty, it has to be prefixed with spacecnt ' ' characters. This then gets
717 * replaced by the color box later on. */
718 for (spi = 0; spi < spacecnt && (*eaten) > 1; spi++) {
719 linecp[--(*eaten)] = ' ';
723 if (rrd_parse_legend(linecp, eaten, gdp))
729 dprintf("- found legend '%s'\n", &gdp->legend[2]);
731 dprintf("- skipping empty legend\n");
732 if (line[*eaten] != '\0' && line[*eaten] != ':') {
733 rrd_set_error("Legend set but no color: %s", &line[*eaten]);
737 if (line[*eaten] == '\0') {
738 dprintf("- done parsing line\n");
741 (*eaten)++; /* after colon */
743 /* PART, HRULE, VRULE and TICK cannot be stacked. */
744 if ((gdp->gf == GF_HRULE)
745 || (gdp->gf == GF_VRULE)
746 || (gdp->gf == GF_TICK)
750 dprintf("- parsing '%s'\n", &line[*eaten]);
751 if (line[*eaten] != '\0') {
752 dprintf("- still more, should be STACK\n");
753 j = scan_for_col(&line[*eaten], 5, tmpstr);
754 if (line[*eaten + j] != '\0' && line[*eaten + j] != ':') {
756 rrd_set_error("STACK expected and not found");
759 if (!strcmp("STACK", tmpstr)) {
760 dprintf("- found STACK\n");
764 rrd_set_error("STACK expected and not found");
768 if (line[*eaten] == '\0') {
769 dprintf("- done parsing line\n");
773 dprintf("- parsing '%s'\n", &line[*eaten]);
778 int rrd_parse_make_vname(
779 const char *const line,
780 unsigned int *const eaten,
781 graph_desc_t *const gdp,
782 image_desc_t *const im)
784 char tmpstr[MAX_VNAME_LEN + 10];
787 sscanf(&line[*eaten], DEF_NAM_FMT "=%n", tmpstr, &i);
789 rrd_set_error("Cannot parse vname from '%s'", line);
792 dprintf("- found candidate '%s'\n", tmpstr);
794 if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
795 rrd_set_error("Attempting to reuse '%s'", im->gdes[gdp->vidx].vname);
798 strcpy(gdp->vname, tmpstr);
799 dprintf("- created vname '%s' vidx %lu\n", gdp->vname, im->gdes_c - 1);
805 const char *const line,
806 unsigned int *const eaten,
807 graph_desc_t *const gdp,
808 image_desc_t *const im)
811 char command[7]; /* step, start, end, reduce */
813 struct rrd_time_value start_tv, end_tv;
814 time_t start_tmp = 0, end_tmp = 0;
815 char *parsetime_error = NULL;
817 start_tv.type = end_tv.type = ABSOLUTE_TIME;
818 start_tv.offset = end_tv.offset = 0;
819 localtime_r(&gdp->start, &start_tv.tm);
820 localtime_r(&gdp->end, &end_tv.tm);
822 dprintf("- parsing '%s'\n", &line[*eaten]);
823 dprintf("- from line '%s'\n", line);
825 if (rrd_parse_make_vname(line, eaten, gdp, im))
827 i = scan_for_col(&line[*eaten], sizeof(gdp->rrd) - 1, gdp->rrd);
828 if (line[*eaten + i] != ':') {
829 rrd_set_error("Problems reading database name");
833 dprintf("- using file '%s'\n", gdp->rrd);
836 sscanf(&line[*eaten], DS_NAM_FMT ":%n", gdp->ds_nam, &i);
838 rrd_set_error("Cannot parse DS in '%s'", line);
842 dprintf("- using DS '%s'\n", gdp->ds_nam);
844 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf))
846 gdp->cf_reduce = gdp->cf;
848 if (line[*eaten] == '\0')
852 dprintf("- optional parameter follows: %s\n", &line[*eaten]);
854 sscanf(&line[*eaten], "%6[a-z]=%n", command, &i);
856 rrd_set_error("Parse error in '%s'", line);
860 dprintf("- processing '%s'\n", command);
861 if (!strcmp("reduce", command)) {
862 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf_reduce))
864 if (line[*eaten] != '\0')
866 } else if (!strcmp("step", command)) {
868 sscanf(&line[*eaten], "%lu%n", &gdp->step, &i);
869 gdp->step_orig = gdp->step;
871 dprintf("- using step %lu\n", gdp->step);
872 } else if (!strcmp("start", command)) {
873 i = scan_for_col(&line[*eaten], 255, tmpstr);
875 if ((parsetime_error = parsetime(tmpstr, &start_tv))) {
876 rrd_set_error("start time: %s", parsetime_error);
879 dprintf("- done parsing: '%s'\n", &line[*eaten]);
880 } else if (!strcmp("end", command)) {
881 i = scan_for_col(&line[*eaten], 255, tmpstr);
883 if ((parsetime_error = parsetime(tmpstr, &end_tv))) {
884 rrd_set_error("end time: %s", parsetime_error);
887 dprintf("- done parsing: '%s'\n", &line[*eaten]);
889 rrd_set_error("Parse error in '%s'", line);
892 if (line[*eaten] == '\0')
894 if (line[*eaten] != ':') {
895 dprintf("- Expected to see end of string but got '%s'\n",
897 rrd_set_error("Parse error in '%s'", line);
902 if (proc_start_end(&start_tv, &end_tv, &start_tmp, &end_tmp) == -1) {
903 /* error string is set in parsetime.c */
906 if (start_tmp < 3600 * 24 * 365 * 10) {
907 rrd_set_error("the first entry to fetch should be "
908 "after 1980 (%ld)", start_tmp);
912 if (end_tmp < start_tmp) {
913 rrd_set_error("start (%ld) should be less than end (%ld)",
918 gdp->start = start_tmp;
920 gdp->start_orig = start_tmp;
921 gdp->end_orig = end_tmp;
923 dprintf("- start time %lu\n", gdp->start);
924 dprintf("- end time %lu\n", gdp->end);
930 const char *const line,
931 unsigned int *const eaten,
932 graph_desc_t *const gdp,
933 image_desc_t *const im)
935 char tmpstr[MAX_VNAME_LEN + 1]; /* vname\0 */
938 dprintf("- parsing '%s'\n", &line[*eaten]);
939 if (rrd_parse_make_vname(line, eaten, gdp, im))
942 sscanf(&line[*eaten], DEF_NAM_FMT ",%n", tmpstr, &i);
944 rrd_set_error("Cannot parse line '%s'", line);
947 if ((gdp->vidx = find_var(im, tmpstr)) < 0) {
948 rrd_set_error("Not a valid vname: %s in line %s", tmpstr, line);
951 if (im->gdes[gdp->vidx].gf != GF_DEF && im->gdes[gdp->vidx].gf != GF_CDEF) {
952 rrd_set_error("variable '%s' not DEF nor "
953 "CDEF in VDEF '%s'", tmpstr, gdp->vname);
956 dprintf("- found vname: '%s' vidx %li\n", tmpstr, gdp->vidx);
959 dprintf("- calling vdef_parse with param '%s'\n", &line[*eaten]);
960 vdef_parse(gdp, &line[*eaten]);
961 while (line[*eaten] != '\0' && line[*eaten] != ':')
968 const char *const line,
969 unsigned int *const eaten,
970 graph_desc_t *const gdp,
971 image_desc_t *const im)
973 dprintf("- parsing '%s'\n", &line[*eaten]);
974 if (rrd_parse_make_vname(line, eaten, gdp, im))
976 if ((gdp->rpnp = rpn_parse((void *) im, &line[*eaten], &find_var_wrapper)
978 rrd_set_error("invalid rpn expression in: %s", &line[*eaten]);
981 while (line[*eaten] != '\0' && line[*eaten] != ':')
986 void rrd_graph_script(
989 image_desc_t *const im,
994 /* save state for STACK backward compat function */
995 enum gf_en last_gf = GF_PRINT;
996 float last_linewidth = 0.0;
998 for (i = optind + optno; i < argc; i++) {
1000 unsigned int eaten = 0;
1003 return; /* the error string is already set */
1004 gdp = &im->gdes[im->gdes_c - 1];
1009 if (rrd_parse_find_gf(argv[i], &eaten, gdp))
1013 case GF_SHIFT: /* vname:value */
1014 if (rrd_parse_shift(argv[i], &eaten, gdp, im))
1017 case GF_TEXTALIGN: /* left|right|center|justified */
1018 if (rrd_parse_textalign(argv[i], &eaten, gdp))
1022 if (rrd_parse_xport(argv[i], &eaten, gdp, im))
1025 case GF_PRINT: /* vname:CF:format -or- vname:format */
1027 case GF_GPRINT: /* vname:CF:format -or- vname:format */
1028 if (rrd_parse_print(argv[i], &eaten, gdp, im))
1031 case GF_COMMENT: /* text */
1032 if (rrd_parse_legend(argv[i], &eaten, gdp))
1035 case GF_VRULE: /* value#color[:legend] */
1036 case GF_HRULE: /* value#color[:legend] */
1037 case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */
1038 case GF_AREA: /* vname-or-value[#color[:legend]][:STACK] */
1039 case GF_TICK: /* vname#color[:num[:legend]] */
1040 if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
1043 last_linewidth = gdp->linewidth;
1045 case GF_STACK: /* vname-or-value[#color[:legend]] */
1046 if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
1048 if (last_gf == GF_LINE || last_gf == GF_AREA) {
1050 gdp->linewidth = last_linewidth;
1052 rrd_set_error("STACK must follow LINE or AREA! command:\n%s",
1053 &argv[i][eaten], argv[i]);
1057 /* data acquisition */
1058 case GF_DEF: /* vname=x:DS:CF:[:step=#][:start=#][:end=#] */
1059 if (rrd_parse_def(argv[i], &eaten, gdp, im))
1062 case GF_CDEF: /* vname=rpn-expression */
1063 if (rrd_parse_cdef(argv[i], &eaten, gdp, im))
1066 case GF_VDEF: /* vname=rpn-expression */
1067 if (rrd_parse_vdef(argv[i], &eaten, gdp, im))
1072 dprintf("used %i out of %zi chars\n", eaten, strlen(argv[i]));
1073 dprintf("parsed line: '%s'\n", argv[i]);
1074 dprintf("remaining: '%s'\n", &argv[i][eaten]);
1075 if (eaten >= strlen(argv[i]))
1076 dprintf("Command finished successfully\n");
1078 if (eaten < strlen(argv[i])) {
1079 rrd_set_error("I don't understand '%s' in command: '%s'.",
1080 &argv[i][eaten], argv[i]);