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);
601 if (im->gdes[gdp->vidx].gf != GF_VDEF) {
602 rrd_set_error("Using vname %s of wrong type in line %s\n",
603 im->gdes[gdp->gf].vname, line);
611 dprintf("- it is not an existing vname\n");
615 sscanf(tmpstr, "%li%n",&time_tmp , &k);
616 gdp->xrule = time_tmp;
617 if (((j != 0) && (k == j)) || ((j == 0) && (k == i))) {
618 dprintf("- found time: %li\n", gdp->xrule);
620 dprintf("- is is not a valid number: %li\n", gdp->xrule);
622 ("parameter '%s' does not represent time in line %s\n",
628 sscanf(tmpstr, "%lf%n", &gdp->yrule, &k);
629 if (((j != 0) && (k == j)) || ((j == 0) && (k == i))) {
630 dprintf("- found number: %lf\n", gdp->yrule);
632 dprintf("- is is not a valid number: %lf\n", gdp->yrule);
634 ("parameter '%s' does not represent a number in line %s\n",
643 dprintf("- examining color '%s'\n", &tmpstr[j]);
644 if (rrd_parse_color(&tmpstr[j], gdp)) {
645 rrd_set_error("Could not parse color in '%s'", &tmpstr[j]);
648 dprintf("- parsed color %0.0f,%0.0f,%0.0f,%0.0f\n", gdp->col.red,
649 gdp->col.green, gdp->col.blue, gdp->col.alpha);
652 dprintf("- no color present in '%s'\n", tmpstr);
655 (*eaten) += i; /* after vname#color */
656 if (line[*eaten] != '\0') {
657 (*eaten)++; /* after colon */
660 if (gdp->gf == GF_TICK) {
661 dprintf("- parsing '%s'\n", &line[*eaten]);
662 dprintf("- looking for optional TICK number\n");
664 sscanf(&line[*eaten], "%lf%n", &gdp->yrule, &j);
666 if (line[*eaten + j] != '\0' && line[*eaten + j] != ':') {
667 rrd_set_error("Cannot parse TICK fraction '%s'", line);
670 dprintf("- found number %f\n", gdp->yrule);
671 if (gdp->yrule > 1.0 || gdp->yrule < -1.0) {
672 rrd_set_error("Tick factor should be <= 1.0");
677 dprintf("- not found, defaulting to 0.1\n");
680 if (line[*eaten] == '\0') {
681 dprintf("- done parsing line\n");
684 if (line[*eaten] == ':') {
687 rrd_set_error("Can't make sense of that TICK line");
693 dprintf("- parsing '%s'\n", &line[*eaten]);
695 /* Legend is next. A legend without a color is an error.
696 ** Stacking an item without having a legend is OK however
697 ** then an empty legend should be specified.
698 ** LINE:val#color:STACK means legend is string "STACK"
699 ** LINE:val#color::STACK means no legend, and do STACK
700 ** LINE:val:STACK is an error (legend but no color)
701 ** LINE:val::STACK means no legend, and do STACK
705 char *linecp = strdup(line);
707 dprintf("- looking for optional legend\n");
709 dprintf("- examining '%s'\n", &line[*eaten]);
710 if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') {
713 /* If the legend is not empty, it has to be prefixed with spacecnt ' ' characters. This then gets
714 * replaced by the color box later on. */
715 for (spi = 0; spi < spacecnt && (*eaten) > 1; spi++) {
716 linecp[--(*eaten)] = ' ';
720 if (rrd_parse_legend(linecp, eaten, gdp))
726 dprintf("- found legend '%s'\n", &gdp->legend[2]);
728 dprintf("- skipping empty legend\n");
729 if (line[*eaten] != '\0' && line[*eaten] != ':') {
730 rrd_set_error("Legend set but no color: %s", &line[*eaten]);
734 if (line[*eaten] == '\0') {
735 dprintf("- done parsing line\n");
738 (*eaten)++; /* after colon */
740 /* PART, HRULE, VRULE and TICK cannot be stacked. */
741 if ((gdp->gf == GF_HRULE)
742 || (gdp->gf == GF_VRULE)
743 || (gdp->gf == GF_TICK)
747 dprintf("- parsing '%s'\n", &line[*eaten]);
748 if (line[*eaten] != '\0') {
749 dprintf("- still more, should be STACK\n");
750 j = scan_for_col(&line[*eaten], 5, tmpstr);
751 if (line[*eaten + j] != '\0' && line[*eaten + j] != ':') {
753 rrd_set_error("STACK expected and not found");
756 if (!strcmp("STACK", tmpstr)) {
757 dprintf("- found STACK\n");
761 rrd_set_error("STACK expected and not found");
765 if (line[*eaten] == '\0') {
766 dprintf("- done parsing line\n");
770 dprintf("- parsing '%s'\n", &line[*eaten]);
775 int rrd_parse_make_vname(
776 const char *const line,
777 unsigned int *const eaten,
778 graph_desc_t *const gdp,
779 image_desc_t *const im)
781 char tmpstr[MAX_VNAME_LEN + 10];
784 sscanf(&line[*eaten], DEF_NAM_FMT "=%n", tmpstr, &i);
786 rrd_set_error("Cannot parse vname from '%s'", line);
789 dprintf("- found candidate '%s'\n", tmpstr);
791 if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
792 rrd_set_error("Attempting to reuse '%s'", im->gdes[gdp->vidx].vname);
795 strcpy(gdp->vname, tmpstr);
796 dprintf("- created vname '%s' vidx %lu\n", gdp->vname, im->gdes_c - 1);
802 const char *const line,
803 unsigned int *const eaten,
804 graph_desc_t *const gdp,
805 image_desc_t *const im)
808 char command[7]; /* step, start, end, reduce */
810 struct rrd_time_value start_tv, end_tv;
811 time_t start_tmp = 0, end_tmp = 0;
812 char *parsetime_error = NULL;
814 start_tv.type = end_tv.type = ABSOLUTE_TIME;
815 start_tv.offset = end_tv.offset = 0;
816 localtime_r(&gdp->start, &start_tv.tm);
817 localtime_r(&gdp->end, &end_tv.tm);
819 dprintf("- parsing '%s'\n", &line[*eaten]);
820 dprintf("- from line '%s'\n", line);
822 if (rrd_parse_make_vname(line, eaten, gdp, im))
824 i = scan_for_col(&line[*eaten], sizeof(gdp->rrd) - 1, gdp->rrd);
825 if (line[*eaten + i] != ':') {
826 rrd_set_error("Problems reading database name");
830 dprintf("- using file '%s'\n", gdp->rrd);
833 sscanf(&line[*eaten], DS_NAM_FMT ":%n", gdp->ds_nam, &i);
835 rrd_set_error("Cannot parse DS in '%s'", line);
839 dprintf("- using DS '%s'\n", gdp->ds_nam);
841 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf))
843 gdp->cf_reduce = gdp->cf;
845 if (line[*eaten] == '\0')
849 dprintf("- optional parameter follows: %s\n", &line[*eaten]);
851 sscanf(&line[*eaten], "%6[a-z]=%n", command, &i);
853 rrd_set_error("Parse error in '%s'", line);
857 dprintf("- processing '%s'\n", command);
858 if (!strcmp("reduce", command)) {
859 if (rrd_parse_CF(line, eaten, gdp, &gdp->cf_reduce))
861 if (line[*eaten] != '\0')
863 } else if (!strcmp("step", command)) {
865 sscanf(&line[*eaten], "%lu%n", &gdp->step, &i);
866 gdp->step_orig = gdp->step;
868 dprintf("- using step %lu\n", gdp->step);
869 } else if (!strcmp("start", command)) {
870 i = scan_for_col(&line[*eaten], 255, tmpstr);
872 if ((parsetime_error = parsetime(tmpstr, &start_tv))) {
873 rrd_set_error("start time: %s", parsetime_error);
876 dprintf("- done parsing: '%s'\n", &line[*eaten]);
877 } else if (!strcmp("end", command)) {
878 i = scan_for_col(&line[*eaten], 255, tmpstr);
880 if ((parsetime_error = parsetime(tmpstr, &end_tv))) {
881 rrd_set_error("end time: %s", parsetime_error);
884 dprintf("- done parsing: '%s'\n", &line[*eaten]);
886 rrd_set_error("Parse error in '%s'", line);
889 if (line[*eaten] == '\0')
891 if (line[*eaten] != ':') {
892 dprintf("- Expected to see end of string but got '%s'\n",
894 rrd_set_error("Parse error in '%s'", line);
899 if (proc_start_end(&start_tv, &end_tv, &start_tmp, &end_tmp) == -1) {
900 /* error string is set in parsetime.c */
903 if (start_tmp < 3600 * 24 * 365 * 10) {
904 rrd_set_error("the first entry to fetch should be "
905 "after 1980 (%ld)", start_tmp);
909 if (end_tmp < start_tmp) {
910 rrd_set_error("start (%ld) should be less than end (%ld)",
915 gdp->start = start_tmp;
917 gdp->start_orig = start_tmp;
918 gdp->end_orig = end_tmp;
920 dprintf("- start time %lu\n", gdp->start);
921 dprintf("- end time %lu\n", gdp->end);
927 const char *const line,
928 unsigned int *const eaten,
929 graph_desc_t *const gdp,
930 image_desc_t *const im)
932 char tmpstr[MAX_VNAME_LEN + 1]; /* vname\0 */
935 dprintf("- parsing '%s'\n", &line[*eaten]);
936 if (rrd_parse_make_vname(line, eaten, gdp, im))
939 sscanf(&line[*eaten], DEF_NAM_FMT ",%n", tmpstr, &i);
941 rrd_set_error("Cannot parse line '%s'", line);
944 if ((gdp->vidx = find_var(im, tmpstr)) < 0) {
945 rrd_set_error("Not a valid vname: %s in line %s", tmpstr, line);
948 if (im->gdes[gdp->vidx].gf != GF_DEF && im->gdes[gdp->vidx].gf != GF_CDEF) {
949 rrd_set_error("variable '%s' not DEF nor "
950 "CDEF in VDEF '%s'", tmpstr, gdp->vname);
953 dprintf("- found vname: '%s' vidx %li\n", tmpstr, gdp->vidx);
956 dprintf("- calling vdef_parse with param '%s'\n", &line[*eaten]);
957 vdef_parse(gdp, &line[*eaten]);
958 while (line[*eaten] != '\0' && line[*eaten] != ':')
965 const char *const line,
966 unsigned int *const eaten,
967 graph_desc_t *const gdp,
968 image_desc_t *const im)
970 dprintf("- parsing '%s'\n", &line[*eaten]);
971 if (rrd_parse_make_vname(line, eaten, gdp, im))
973 if ((gdp->rpnp = rpn_parse((void *) im, &line[*eaten], &find_var_wrapper)
975 rrd_set_error("invalid rpn expression in: %s", &line[*eaten]);
978 while (line[*eaten] != '\0' && line[*eaten] != ':')
983 void rrd_graph_script(
986 image_desc_t *const im,
991 /* save state for STACK backward compat function */
992 enum gf_en last_gf = GF_PRINT;
993 float last_linewidth = 0.0;
995 for (i = optind + optno; i < argc; i++) {
997 unsigned int eaten = 0;
1000 return; /* the error string is already set */
1001 gdp = &im->gdes[im->gdes_c - 1];
1006 if (rrd_parse_find_gf(argv[i], &eaten, gdp))
1010 case GF_SHIFT: /* vname:value */
1011 if (rrd_parse_shift(argv[i], &eaten, gdp, im))
1014 case GF_TEXTALIGN: /* left|right|center|justified */
1015 if (rrd_parse_textalign(argv[i], &eaten, gdp))
1019 if (rrd_parse_xport(argv[i], &eaten, gdp, im))
1022 case GF_PRINT: /* vname:CF:format -or- vname:format */
1024 case GF_GPRINT: /* vname:CF:format -or- vname:format */
1025 if (rrd_parse_print(argv[i], &eaten, gdp, im))
1028 case GF_COMMENT: /* text */
1029 if (rrd_parse_legend(argv[i], &eaten, gdp))
1032 case GF_VRULE: /* value#color[:legend] */
1033 case GF_HRULE: /* value#color[:legend] */
1034 case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */
1035 case GF_AREA: /* vname-or-value[#color[:legend]][:STACK] */
1036 case GF_TICK: /* vname#color[:num[:legend]] */
1037 if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
1040 last_linewidth = gdp->linewidth;
1042 case GF_STACK: /* vname-or-value[#color[:legend]] */
1043 if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
1045 if (last_gf == GF_LINE || last_gf == GF_AREA) {
1047 gdp->linewidth = last_linewidth;
1049 rrd_set_error("STACK must follow LINE or AREA! command:\n%s",
1050 &argv[i][eaten], argv[i]);
1054 /* data acquisition */
1055 case GF_DEF: /* vname=x:DS:CF:[:step=#][:start=#][:end=#] */
1056 if (rrd_parse_def(argv[i], &eaten, gdp, im))
1059 case GF_CDEF: /* vname=rpn-expression */
1060 if (rrd_parse_cdef(argv[i], &eaten, gdp, im))
1063 case GF_VDEF: /* vname=rpn-expression */
1064 if (rrd_parse_vdef(argv[i], &eaten, gdp, im))
1069 dprintf("used %i out of %zi chars\n", eaten, strlen(argv[i]));
1070 dprintf("parsed line: '%s'\n", argv[i]);
1071 dprintf("remaining: '%s'\n", &argv[i][eaten]);
1072 if (eaten >= strlen(argv[i]))
1073 dprintf("Command finished successfully\n");
1075 if (eaten < strlen(argv[i])) {
1076 rrd_set_error("I don't understand '%s' in command: '%s'.",
1077 &argv[i][eaten], argv[i]);