+ if (line[*eaten] == ':') {
+ (*eaten) += 1;
+ } else if (line[*eaten] == '\0') {
+ dprintf("- done parsing line\n");
+ return 0;
+ } else {
+ dprintf("- found %s instead of just STACK\n", &line[*eaten]);
+ rrd_set_error("STACK expected but %s found", &line[*eaten]);
+ return 1;
+ }
+ } else
+ dprintf("- not STACKing\n");
+ }
+
+ dprintf("- still more, should be dashes[=...]\n");
+ dprintf("- parsing '%s'\n", &line[*eaten]);
+ if (line[*eaten] != '\0') {
+ /* parse dash arguments here. Possible options:
+ - dashes
+ - dashes=n_on[,n_off[,n_on,n_off]]
+ - dashes[=n_on[,n_off[,n_on,n_off]]]:dash-offset=offset
+ allowing 64 characters for definition of dash style */
+ j = scan_for_col(&line[*eaten], 64, tmpstr);
+ /* start with dashes */
+ if (strcmp(tmpstr, "dashes") == 0) {
+ /* if line was "dashes" or "dashes:dash-offset=xdashes="
+ tmpstr will be "dashes" */
+ dprintf("- found %s\n", tmpstr);
+ /* initialise all required variables we need for dashed lines
+ using default dash length of 5 pixels */
+ gdp->dash = 1;
+ gdp->p_dashes = (double *) malloc(sizeof(double));
+ gdp->p_dashes[0] = 5;
+ gdp->ndash = 1;
+ gdp->offset = 0;
+ (*eaten) += j;
+ } else if (sscanf(tmpstr, "dashes=%s", tmpstr)) {
+ /* dashes=n_on[,n_off[,n_on,n_off]] */
+ char csv[64];
+ char *pch;
+ float dsh;
+ int count = 0;
+ char *saveptr;
+
+ strcpy(csv, tmpstr);
+
+ pch = strtok_r(tmpstr, ",", &saveptr);
+ while (pch != NULL) {
+ pch = strtok_r(NULL, ",", &saveptr);
+ count++;
+ }
+ dprintf("- %d dash value(s) found: ", count);
+ if (count > 0) {
+ gdp->dash = 1;
+ gdp->ndash = count;
+ gdp->p_dashes = (double *) malloc(sizeof(double) * count);
+ pch = strtok_r(csv, ",", &saveptr);
+ count = 0;
+ while (pch != NULL) {
+ if (sscanf(pch, "%f", &dsh)) {
+ gdp->p_dashes[count] = (double) dsh;
+ dprintf("%.1f ", gdp->p_dashes[count]);
+ count++;
+ }
+ pch = strtok_r(NULL, ",", &saveptr);
+ }
+ dprintf("\n");
+ } else
+ dprintf("- syntax error. No dash lengths found!\n");
+ (*eaten) += j;
+ } else
+ dprintf("- error: expected dashes[=...], found %s\n", tmpstr);
+ if (line[*eaten] == ':') {
+ (*eaten) += 1;
+ } else if (line[*eaten] == '\0') {
+ dprintf("- done parsing line\n");
+ return 0;
+ }
+ /* dashes[=n_on[,n_off[,n_on,n_off]]]:dash-offset=offset
+ allowing 16 characters for dash-offset=....
+ => 4 characters for the offset value */
+ j = scan_for_col(&line[*eaten], 16, tmpstr);
+ if (sscanf(tmpstr, "dash-offset=%lf", &gdp->offset)) {
+ dprintf("- found dash-offset=%.1f\n", gdp->offset);
+ gdp->dash = 1;
+ (*eaten) += j;
+ if (line[*eaten] == ':')
+ (*eaten) += 1;
+ }
+ if (line[*eaten] == '\0') {
+ dprintf("- done parsing line\n");
+ return 0;