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);
450 sscanf(&line[*eaten], "%li%n", &gdp->shval, &i);
451 if (i != (int) strlen(&line[*eaten])) {
452 rrd_set_error("Not a valid offset: %s in line %s", &line[*eaten],
457 dprintf("- offset is number %li\n", gdp->shval);
463 /* XPORT:_def_or_cdef[:legend]
466 const char *const line,
467 unsigned int *const eaten,
468 graph_desc_t *const gdp,
469 image_desc_t *const im)
471 if ((gdp->vidx = rrd_parse_find_vname(line, eaten, gdp, im)) < 0)
474 switch (im->gdes[gdp->vidx].gf) {
477 dprintf("- vname is of type DEF or CDEF, OK\n");
480 rrd_set_error("Cannot xport a VDEF: '%s' in line '%s'\n",
481 im->gdes[gdp->vidx].vname, line);
484 rrd_set_error("Encountered unknown type variable '%s' in line '%s'",
485 im->gdes[gdp->vidx].vname, line);
488 dprintf("- looking for legend in '%s'\n", &line[*eaten]);
489 if (rrd_parse_legend(line, eaten, gdp))
494 int rrd_parse_textalign(
495 const char *const line,
496 unsigned int *const eaten,
497 graph_desc_t *const gdp)
499 if (strcmp(&line[*eaten], "left") == 0) {
500 gdp->txtalign = TXA_LEFT;
501 } else if (strcmp(&line[*eaten], "right") == 0) {
502 gdp->txtalign = TXA_RIGHT;
503 } else if (strcmp(&line[*eaten], "justified") == 0) {
504 gdp->txtalign = TXA_JUSTIFIED;
505 } else if (strcmp(&line[*eaten], "center") == 0) {
506 gdp->txtalign = TXA_CENTER;
508 rrd_set_error("Unknown alignement type '%s'", &line[*eaten]);
511 *eaten += strlen(&line[*eaten]);
516 /* Parsing of PART, VRULE, HRULE, LINE, AREA, STACK and TICK
517 ** is done in one function.
519 ** Stacking PART, VRULE, HRULE or TICK is not allowed.
521 ** If a number (which is valid to enter) is more than a
522 ** certain amount of characters, it is caught as an error.
523 ** While this is arguable, so is entering fixed numbers
524 ** with more than MAX_VNAME_LEN significant digits.
526 int rrd_parse_PVHLAST(
527 const char *const line,
528 unsigned int *const eaten,
529 graph_desc_t *const gdp,
530 image_desc_t *const im)
534 char tmpstr[MAX_VNAME_LEN + 10]; /* vname#RRGGBBAA\0 */
535 static int spacecnt = 0;
538 float one_space = gfx_get_text_width(im, 0,
540 text_prop[TEXT_PROP_LEGEND].
543 text_prop[TEXT_PROP_LEGEND].
545 im->tabwidth, " ") / 4.0;
546 float target_space = gfx_get_text_width(im, 0,
549 [TEXT_PROP_LEGEND].font,
552 [TEXT_PROP_LEGEND].size,
555 spacecnt = target_space / one_space;
556 dprintf("- spacecnt: %i onespace: %f targspace: %f\n", spacecnt,
557 one_space, target_space);
561 dprintf("- parsing '%s'\n", &line[*eaten]);
563 /* have simpler code in the drawing section */
564 if (gdp->gf == GF_STACK) {
568 i = scan_for_col(&line[*eaten], MAX_VNAME_LEN + 9, tmpstr);
569 if (line[*eaten + i] != '\0' && line[*eaten + i] != ':') {
570 rrd_set_error("Cannot parse line '%s'", line);
575 while (j > 0 && tmpstr[j] != '#')
582 * tmpstr[0] containing vname
583 * tmpstr[j] if j!=0 then containing color
584 * i size of vname + color
585 * j if j!=0 then size of vname
589 * If it is an existing vname, that's OK, provided that it is a
590 * valid type (need time for VRULE, not a float)
591 * Else see if it parses as a number.
593 dprintf("- examining string '%s'\n", tmpstr);
594 if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
595 dprintf("- found vname: '%s' vidx %li\n", tmpstr, gdp->vidx);
602 if (im->gdes[gdp->vidx].gf != GF_VDEF) {
603 rrd_set_error("Using vname %s of wrong type in line %s\n",
604 im->gdes[gdp->gf].vname, line);
611 dprintf("- it is not an existing vname\n");
615 sscanf(tmpstr, "%li%n", &gdp->xrule, &k);
616 if (((j != 0) && (k == j)) || ((j == 0) && (k == i))) {
617 dprintf("- found time: %li\n", gdp->xrule);
619 dprintf("- is is not a valid number: %li\n", gdp->xrule);
621 ("parameter '%s' does not represent time in line %s\n",
627 sscanf(tmpstr, "%lf%n", &gdp->yrule, &k);
628 if (((j != 0) && (k == j)) || ((j == 0) && (k == i))) {
629 dprintf("- found number: %f\n", gdp->yrule);
631 dprintf("- is is not a valid number: %li\n", gdp->xrule);
633 ("parameter '%s' does not represent a number in line %s\n",
642 dprintf("- examining color '%s'\n", &tmpstr[j]);
643 if (rrd_parse_color(&tmpstr[j], gdp)) {
644 rrd_set_error("Could not parse color in '%s'", &tmpstr[j]);
647 dprintf("- parsed color %0.0f,%0.0f,%0.0f,%0.0f\n", gdp->col.red,
648 gdp->col.green, gdp->col.blue, gdp->col.alpha);
651 dprintf("- no color present in '%s'\n", tmpstr);
654 (*eaten) += i; /* after vname#color */
655 if (line[*eaten] != '\0') {
656 (*eaten)++; /* after colon */
659 if (gdp->gf == GF_TICK) {
660 dprintf("- parsing '%s'\n", &line[*eaten]);
661 dprintf("- looking for optional TICK number\n");
663 sscanf(&line[*eaten], "%lf%n", &gdp->yrule, &j);
665 if (line[*eaten + j] != '\0' && line[*eaten + j] != ':') {
666 rrd_set_error("Cannot parse TICK fraction '%s'", line);
669 dprintf("- found number %f\n", gdp->yrule);
670 if (gdp->yrule > 1.0 || gdp->yrule < -1.0) {
671 rrd_set_error("Tick factor should be <= 1.0");
676 dprintf("- not found, defaulting to 0.1\n");
679 if (line[*eaten] == '\0') {
680 dprintf("- done parsing line\n");
683 if (line[*eaten] == ':') {
686 rrd_set_error("Can't make sense of that TICK line");
692 dprintf("- parsing '%s'\n", &line[*eaten]);
694 /* Legend is next. A legend without a color is an error.
695 ** Stacking an item without having a legend is OK however
696 ** then an empty legend should be specified.
697 ** LINE:val#color:STACK means legend is string "STACK"
698 ** LINE:val#color::STACK means no legend, and do STACK
699 ** LINE:val:STACK is an error (legend but no color)
700 ** LINE:val::STACK means no legend, and do STACK
704 char *linecp = strdup(line);
706 dprintf("- looking for optional legend\n");
708 dprintf("- examining '%s'\n", &line[*eaten]);
709 if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') {
712 /* If the legend is not empty, it has to be prefixed with spacecnt ' ' characters. This then gets
713 * replaced by the color box later on. */
714 for (spi = 0; spi < spacecnt && (*eaten) > 1; spi++) {
715 linecp[--(*eaten)] = ' ';
719 if (rrd_parse_legend(linecp, eaten, gdp))
725 dprintf("- found legend '%s'\n", &gdp->legend[2]);
727 dprintf("- skipping empty legend\n");
728 if (line[*eaten] != '\0' && line[*eaten] != ':') {
729 rrd_set_error("Legend set but no color: %s", &line[*eaten]);
733 if (line[*eaten] == '\0') {
734 dprintf("- done parsing line\n");
737 (*eaten)++; /* after colon */
739 /* PART, HRULE, VRULE and TICK cannot be stacked. */
740 if ((gdp->gf == GF_HRULE)
741 || (gdp->gf == GF_VRULE)
742 || (gdp->gf == GF_TICK)
746 dprintf("- parsing '%s'\n", &line[*eaten]);
747 if (line[*eaten] != '\0') {
748 dprintf("- still more, should be STACK\n");
749 j = scan_for_col(&line[*eaten], 5, tmpstr);
750 if (line[*eaten + j] != '\0' && line[*eaten + j] != ':') {
752 rrd_set_error("STACK expected and not found");
755 if (!strcmp("STACK", tmpstr)) {
756 dprintf("- found STACK\n");
760 rrd_set_error("STACK expected and not found");
764 if (line[*eaten] == '\0') {
765 dprintf("- done parsing line\n");
769 dprintf("- parsing '%s'\n", &line[*eaten]);
774 int rrd_parse_make_vname(
775 const char *const line,
776 unsigned int *const eaten,
777 graph_desc_t *const gdp,
778 image_desc_t *const im)
780 char tmpstr[MAX_VNAME_LEN + 10];
783 sscanf(&line[*eaten], DEF_NAM_FMT "=%n", tmpstr, &i);
785 rrd_set_error("Cannot parse vname from '%s'", line);
788 dprintf("- found candidate '%s'\n", tmpstr);
790 if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
791 rrd_set_error("Attempting to reuse '%s'", im->gdes[gdp->vidx].vname);
794 strcpy(gdp->vname, tmpstr);
795 dprintf("- created vname '%s' vidx %lu\n", gdp->vname, im->gdes_c - 1);
801 const char *const line,
802 unsigned int *const eaten,
803 graph_desc_t *const gdp,
804 image_desc_t *const im)
807 char command[7]; /* step, start, end, reduce */
809 struct rrd_time_value start_tv, end_tv;
810 time_t start_tmp = 0, end_tmp = 0;
811 char *parsetime_error = NULL;
813 start_tv.type = end_tv.type = ABSOLUTE_TIME;
814 start_tv.offset = end_tv.offset = 0;
815 localtime_r(&gdp->start, &start_tv.tm);
816 localtime_r(&gdp->end, &end_tv.tm);
818 dprintf("- parsing '%s'\n", &line[*eaten]);
819 dprintf("- from line '%s'\n", line);
821 if (rrd_parse_make_vname(line, eaten, gdp, im))
823 i = scan_for_col(&line[*eaten], sizeof(gdp->rrd) - 1, gdp->rrd);
824 if (line[*eaten + i] != ':') {
825 rrd_set_error("Problems reading database name");
829 dprintf("- using file '%s'\n", gdp->rrd);
832 sscanf(&line[*eaten], DS_NAM_FMT ":%n", gdp->ds_nam, &i);
834 rrd_set_error("Cannot parse DS in '%s'", line);
838 dprintf("- using DS '%s'\n", gdp->ds_nam);
840 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf))
842 gdp->cf_reduce = gdp->cf;
844 if (line[*eaten] == '\0')
848 dprintf("- optional parameter follows: %s\n", &line[*eaten]);
850 sscanf(&line[*eaten], "%6[a-z]=%n", command, &i);
852 rrd_set_error("Parse error in '%s'", line);
856 dprintf("- processing '%s'\n", command);
857 if (!strcmp("reduce", command)) {
858 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf_reduce))
860 if (line[*eaten] != '\0')
862 } else if (!strcmp("step", command)) {
864 sscanf(&line[*eaten], "%lu%n", &gdp->step, &i);
865 gdp->step_orig = gdp->step;
867 dprintf("- using step %lu\n", gdp->step);
868 } else if (!strcmp("start", command)) {
869 i = scan_for_col(&line[*eaten], 255, tmpstr);
871 if ((parsetime_error = parsetime(tmpstr, &start_tv))) {
872 rrd_set_error("start time: %s", parsetime_error);
875 dprintf("- done parsing: '%s'\n", &line[*eaten]);
876 } else if (!strcmp("end", command)) {
877 i = scan_for_col(&line[*eaten], 255, tmpstr);
879 if ((parsetime_error = parsetime(tmpstr, &end_tv))) {
880 rrd_set_error("end time: %s", parsetime_error);
883 dprintf("- done parsing: '%s'\n", &line[*eaten]);
885 rrd_set_error("Parse error in '%s'", line);
888 if (line[*eaten] == '\0')
890 if (line[*eaten] != ':') {
891 dprintf("- Expected to see end of string but got '%s'\n",
893 rrd_set_error("Parse error in '%s'", line);
898 if (proc_start_end(&start_tv, &end_tv, &start_tmp, &end_tmp) == -1) {
899 /* error string is set in parsetime.c */
902 if (start_tmp < 3600 * 24 * 365 * 10) {
903 rrd_set_error("the first entry to fetch should be "
904 "after 1980 (%ld)", start_tmp);
908 if (end_tmp < start_tmp) {
909 rrd_set_error("start (%ld) should be less than end (%ld)",
914 gdp->start = start_tmp;
916 gdp->start_orig = start_tmp;
917 gdp->end_orig = end_tmp;
919 dprintf("- start time %lu\n", gdp->start);
920 dprintf("- end time %lu\n", gdp->end);
926 const char *const line,
927 unsigned int *const eaten,
928 graph_desc_t *const gdp,
929 image_desc_t *const im)
931 char tmpstr[MAX_VNAME_LEN + 1]; /* vname\0 */
934 dprintf("- parsing '%s'\n", &line[*eaten]);
935 if (rrd_parse_make_vname(line, eaten, gdp, im))
938 sscanf(&line[*eaten], DEF_NAM_FMT ",%n", tmpstr, &i);
940 rrd_set_error("Cannot parse line '%s'", line);
943 if ((gdp->vidx = find_var(im, tmpstr)) < 0) {
944 rrd_set_error("Not a valid vname: %s in line %s", tmpstr, line);
947 if (im->gdes[gdp->vidx].gf != GF_DEF && im->gdes[gdp->vidx].gf != GF_CDEF) {
948 rrd_set_error("variable '%s' not DEF nor "
949 "CDEF in VDEF '%s'", tmpstr, gdp->vname);
952 dprintf("- found vname: '%s' vidx %li\n", tmpstr, gdp->vidx);
955 dprintf("- calling vdef_parse with param '%s'\n", &line[*eaten]);
956 vdef_parse(gdp, &line[*eaten]);
957 while (line[*eaten] != '\0' && line[*eaten] != ':')
964 const char *const line,
965 unsigned int *const eaten,
966 graph_desc_t *const gdp,
967 image_desc_t *const im)
969 dprintf("- parsing '%s'\n", &line[*eaten]);
970 if (rrd_parse_make_vname(line, eaten, gdp, im))
972 if ((gdp->rpnp = rpn_parse((void *) im, &line[*eaten], &find_var_wrapper)
974 rrd_set_error("invalid rpn expression in: %s", &line[*eaten]);
977 while (line[*eaten] != '\0' && line[*eaten] != ':')
982 void rrd_graph_script(
985 image_desc_t *const im,
990 /* save state for STACK backward compat function */
991 enum gf_en last_gf = GF_PRINT;
992 float last_linewidth = 0.0;
994 for (i = optind + optno; i < argc; i++) {
996 unsigned int eaten = 0;
999 return; /* the error string is already set */
1000 gdp = &im->gdes[im->gdes_c - 1];
1005 if (rrd_parse_find_gf(argv[i], &eaten, gdp))
1009 case GF_SHIFT: /* vname:value */
1010 if (rrd_parse_shift(argv[i], &eaten, gdp, im))
1013 case GF_TEXTALIGN: /* left|right|center|justified */
1014 if (rrd_parse_textalign(argv[i], &eaten, gdp))
1018 if (rrd_parse_xport(argv[i], &eaten, gdp, im))
1021 case GF_PRINT: /* vname:CF:format -or- vname:format */
1023 case GF_GPRINT: /* vname:CF:format -or- vname:format */
1024 if (rrd_parse_print(argv[i], &eaten, gdp, im))
1027 case GF_COMMENT: /* text */
1028 if (rrd_parse_legend(argv[i], &eaten, gdp))
1031 case GF_VRULE: /* value#color[:legend] */
1032 case GF_HRULE: /* value#color[:legend] */
1033 case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */
1034 case GF_AREA: /* vname-or-value[#color[:legend]][:STACK] */
1035 case GF_TICK: /* vname#color[:num[:legend]] */
1036 if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
1039 last_linewidth = gdp->linewidth;
1041 case GF_STACK: /* vname-or-value[#color[:legend]] */
1042 if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
1044 if (last_gf == GF_LINE || last_gf == GF_AREA) {
1046 gdp->linewidth = last_linewidth;
1048 rrd_set_error("STACK must follow LINE or AREA! command:\n%s",
1049 &argv[i][eaten], argv[i]);
1053 /* data acquisition */
1054 case GF_DEF: /* vname=x:DS:CF:[:step=#][:start=#][:end=#] */
1055 if (rrd_parse_def(argv[i], &eaten, gdp, im))
1058 case GF_CDEF: /* vname=rpn-expression */
1059 if (rrd_parse_cdef(argv[i], &eaten, gdp, im))
1062 case GF_VDEF: /* vname=rpn-expression */
1063 if (rrd_parse_vdef(argv[i], &eaten, gdp, im))
1068 dprintf("used %i out of %zi chars\n", eaten, strlen(argv[i]));
1069 dprintf("parsed line: '%s'\n", argv[i]);
1070 dprintf("remaining: '%s'\n", &argv[i][eaten]);
1071 if (eaten >= strlen(argv[i]))
1072 dprintf("Command finished successfully\n");
1074 if (eaten < strlen(argv[i])) {
1075 rrd_set_error("I don't understand '%s' in command: '%s'.",
1076 &argv[i][eaten], argv[i]);