- int stroff;
- char *parsetime_error = NULL;
- char scan_gtm[12],scan_mtm[12],scan_ltm[12],col_nam[12];
- time_t start_tmp=0,end_tmp=0;
- long long_tmp;
- struct time_value start_tv, end_tv;
- gfx_color_t color;
-
- parsetime("end-24h", &start_tv);
- parsetime("now", &end_tv);
-
- while (1){
- static struct option long_options[] =
- {
- {"start", required_argument, 0, 's'},
- {"end", required_argument, 0, 'e'},
- {"x-grid", required_argument, 0, 'x'},
- {"y-grid", required_argument, 0, 'y'},
- {"vertical-label",required_argument,0,'v'},
- {"width", required_argument, 0, 'w'},
- {"height", required_argument, 0, 'h'},
- {"interlaced", no_argument, 0, 'i'},
- {"upper-limit",required_argument, 0, 'u'},
- {"lower-limit",required_argument, 0, 'l'},
- {"rigid", no_argument, 0, 'r'},
- {"base", required_argument, 0, 'b'},
- {"logarithmic",no_argument, 0, 'o'},
- {"color", required_argument, 0, 'c'},
- {"font", required_argument, 0, 'n'},
- {"title", required_argument, 0, 't'},
- {"imginfo", required_argument, 0, 'f'},
- {"imgformat", required_argument, 0, 'a'},
- {"lazy", no_argument, 0, 'z'},
- {"zoom", required_argument, 0, 'm'},
- {"no-legend", no_argument, 0, 'g'},
- {"alt-y-grid", no_argument, 0, 257 },
- {"alt-autoscale", no_argument, 0, 258 },
- {"alt-autoscale-max", no_argument, 0, 259 },
- {"units-exponent",required_argument, 0, 260},
- {"step", required_argument, 0, 261},
- {0,0,0,0}};
- int option_index = 0;
- int opt;
-
-
- opt = getopt_long(argc, argv,
- "s:e:x:y:v:w:h:iu:l:rb:oc:n:m:t:f:a:z:g",
- long_options, &option_index);
-
- if (opt == EOF)
- break;
-
- switch(opt) {
- case 257:
- im->extra_flags |= ALTYGRID;
- break;
- case 258:
- im->extra_flags |= ALTAUTOSCALE;
- break;
- case 259:
- im->extra_flags |= ALTAUTOSCALE_MAX;
- break;
- case 'g':
- im->extra_flags |= NOLEGEND;
- break;
- case 260:
- im->unitsexponent = atoi(optarg);
- break;
- case 261:
- im->step = atoi(optarg);
- break;
- case 's':
- if ((parsetime_error = parsetime(optarg, &start_tv))) {
- rrd_set_error( "start time: %s", parsetime_error );
- return;
- }
- break;
- case 'e':
- if ((parsetime_error = parsetime(optarg, &end_tv))) {
- rrd_set_error( "end time: %s", parsetime_error );
- return;
- }
- break;
- case 'x':
- if(strcmp(optarg,"none") == 0){
- im->draw_x_grid=0;
- break;
- };
-
- if(sscanf(optarg,
- "%10[A-Z]:%ld:%10[A-Z]:%ld:%10[A-Z]:%ld:%ld:%n",
- scan_gtm,
- &im->xlab_user.gridst,
- scan_mtm,
- &im->xlab_user.mgridst,
- scan_ltm,
- &im->xlab_user.labst,
- &im->xlab_user.precis,
- &stroff) == 7 && stroff != 0){
- strncpy(im->xlab_form, optarg+stroff, sizeof(im->xlab_form) - 1);
- if((im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1){
- rrd_set_error("unknown keyword %s",scan_gtm);
- return;
- } else if ((im->xlab_user.mgridtm = tmt_conv(scan_mtm)) == -1){
- rrd_set_error("unknown keyword %s",scan_mtm);
- return;
- } else if ((im->xlab_user.labtm = tmt_conv(scan_ltm)) == -1){
- rrd_set_error("unknown keyword %s",scan_ltm);
- return;
- }
- im->xlab_user.minsec = 1;
- im->xlab_user.stst = im->xlab_form;
- } else {
- rrd_set_error("invalid x-grid format");
- return;
- }
- break;
- case 'y':
-
- if(strcmp(optarg,"none") == 0){
- im->draw_y_grid=0;
- break;
- };
-
- if(sscanf(optarg,
- "%lf:%d",
- &im->ygridstep,
- &im->ylabfact) == 2) {
- if(im->ygridstep<=0){
- rrd_set_error("grid step must be > 0");
- return;
- } else if (im->ylabfact < 1){
- rrd_set_error("label factor must be > 0");
- return;
- }
- } else {
- rrd_set_error("invalid y-grid format");
- return;
- }
- break;
- case 'v':
- strncpy(im->ylegend,optarg,150);
- im->ylegend[150]='\0';
- break;
- case 'u':
- im->maxval = atof(optarg);
- break;
- case 'l':
- im->minval = atof(optarg);
- break;
- case 'b':
- im->base = atol(optarg);
- if(im->base != 1024 && im->base != 1000 ){
- rrd_set_error("the only sensible value for base apart from 1000 is 1024");
- return;
- }
- break;
- case 'w':
- long_tmp = atol(optarg);
- if (long_tmp < 10) {
- rrd_set_error("width below 10 pixels");
- return;
- }
- im->xsize = long_tmp;
- break;
- case 'h':
- long_tmp = atol(optarg);
- if (long_tmp < 10) {
- rrd_set_error("height below 10 pixels");
- return;
- }
- im->ysize = long_tmp;
- break;
- case 'i':
- im->canvas->interlaced = 1;
- break;
- case 'r':
- im->rigid = 1;
- break;
- case 'f':
- im->imginfo = optarg;
- break;
- case 'a':
- if((im->canvas->imgformat = if_conv(optarg)) == -1) {
- rrd_set_error("unsupported graphics format '%s'",optarg);
- return;
- }
- break;
- case 'z':
- im->lazy = 1;
- break;
- case 'o':
- im->logarithmic = 1;
- if (isnan(im->minval))
- im->minval=1;
- break;
- case 'c':
+ int stroff;
+ char *parsetime_error = NULL;
+ char scan_gtm[12], scan_mtm[12], scan_ltm[12], col_nam[12];
+ time_t start_tmp = 0, end_tmp = 0;
+ long long_tmp;
+ rrd_time_value_t start_tv, end_tv;
+ long unsigned int color;
+
+ /* defines for long options without a short equivalent. should be bytes,
+ and may not collide with (the ASCII value of) short options */
+#define LONGOPT_UNITS_SI 255
+
+/* *INDENT-OFF* */
+ struct option long_options[] = {
+ { "alt-autoscale", no_argument, 0, 'A'},
+ { "imgformat", required_argument, 0, 'a'},
+ { "font-smoothing-threshold", required_argument, 0, 'B'},
+ { "base", required_argument, 0, 'b'},
+ { "color", required_argument, 0, 'c'},
+ { "full-size-mode", no_argument, 0, 'D'},
+ { "daemon", required_argument, 0, 'd'},
+ { "slope-mode", no_argument, 0, 'E'},
+ { "end", required_argument, 0, 'e'},
+ { "force-rules-legend", no_argument, 0, 'F'},
+ { "imginfo", required_argument, 0, 'f'},
+ { "graph-render-mode", required_argument, 0, 'G'},
+ { "no-legend", no_argument, 0, 'g'},
+ { "height", required_argument, 0, 'h'},
+ { "no-minor", no_argument, 0, 'I'},
+ { "interlaced", no_argument, 0, 'i'},
+ { "alt-autoscale-min", no_argument, 0, 'J'},
+ { "only-graph", no_argument, 0, 'j'},
+ { "units-length", required_argument, 0, 'L'},
+ { "lower-limit", required_argument, 0, 'l'},
+ { "alt-autoscale-max", no_argument, 0, 'M'},
+ { "zoom", required_argument, 0, 'm'},
+ { "no-gridfit", no_argument, 0, 'N'},
+ { "font", required_argument, 0, 'n'},
+ { "logarithmic", no_argument, 0, 'o'},
+ { "pango-markup", no_argument, 0, 'P'},
+ { "font-render-mode", required_argument, 0, 'R'},
+ { "rigid", no_argument, 0, 'r'},
+ { "step", required_argument, 0, 'S'},
+ { "start", required_argument, 0, 's'},
+ { "tabwidth", required_argument, 0, 'T'},
+ { "title", required_argument, 0, 't'},
+ { "upper-limit", required_argument, 0, 'u'},
+ { "vertical-label", required_argument, 0, 'v'},
+ { "watermark", required_argument, 0, 'W'},
+ { "width", required_argument, 0, 'w'},
+ { "units-exponent", required_argument, 0, 'X'},
+ { "x-grid", required_argument, 0, 'x'},
+ { "alt-y-grid", no_argument, 0, 'Y'},
+ { "y-grid", required_argument, 0, 'y'},
+ { "lazy", no_argument, 0, 'z'},
+ { "units", required_argument, 0, LONGOPT_UNITS_SI},
+ { "alt-y-mrtg", no_argument, 0, 1000}, /* this has no effect it is just here to save old apps from crashing when they use it */
+ { "disable-rrdtool-tag",no_argument, 0, 1001},
+ { "right-axis", required_argument, 0, 1002},
+ { "right-axis-label", required_argument, 0, 1003},
+ { "right-axis-format", required_argument, 0, 1004},
+ { "legend-position", required_argument, 0, 1005},
+ { "legend-direction", required_argument, 0, 1006},
+ { "border", required_argument, 0, 1007},
+ { "grid-dash", required_argument, 0, 1008},
+ { "dynamic-labels", no_argument, 0, 1009},
+ { 0, 0, 0, 0}
+};
+/* *INDENT-ON* */
+
+ optind = 0;
+ opterr = 0; /* initialize getopt */
+ rrd_parsetime("end-24h", &start_tv);
+ rrd_parsetime("now", &end_tv);
+ while (1) {
+ int option_index = 0;
+ int opt;
+ int col_start, col_end;
+
+ opt = getopt_long(argc, argv,
+ "Aa:B:b:c:Dd:Ee:Ff:G:gh:IiJjL:l:Nn:Bb:oPR:rS:s:T:t:u:v:W:w:X:x:Yy:z",
+ long_options, &option_index);
+ if (opt == EOF)
+ break;
+ switch (opt) {
+ case 'I':
+ im->extra_flags |= NOMINOR;
+ break;
+ case 'Y':
+ im->extra_flags |= ALTYGRID;
+ break;
+ case 'A':
+ im->extra_flags |= ALTAUTOSCALE;
+ break;
+ case 'J':
+ im->extra_flags |= ALTAUTOSCALE_MIN;
+ break;
+ case 'M':
+ im->extra_flags |= ALTAUTOSCALE_MAX;
+ break;
+ case 'j':
+ im->extra_flags |= ONLY_GRAPH;
+ break;
+ case 'g':
+ im->extra_flags |= NOLEGEND;
+ break;
+ case 1005:
+ if (strcmp(optarg, "north") == 0) {
+ im->legendposition = NORTH;
+ } else if (strcmp(optarg, "west") == 0) {
+ im->legendposition = WEST;
+ } else if (strcmp(optarg, "south") == 0) {
+ im->legendposition = SOUTH;
+ } else if (strcmp(optarg, "east") == 0) {
+ im->legendposition = EAST;
+ } else {
+ rrd_set_error("unknown legend-position '%s'", optarg);
+ return;
+ }
+ break;
+ case 1006:
+ if (strcmp(optarg, "topdown") == 0) {
+ im->legenddirection = TOP_DOWN;
+ } else if (strcmp(optarg, "bottomup") == 0) {
+ im->legenddirection = BOTTOM_UP;
+ } else {
+ rrd_set_error("unknown legend-position '%s'", optarg);
+ return;
+ }
+ break;
+ case 'F':
+ im->extra_flags |= FORCE_RULES_LEGEND;
+ break;
+ case 1001:
+ im->extra_flags |= NO_RRDTOOL_TAG;
+ break;
+ case LONGOPT_UNITS_SI:
+ if (im->extra_flags & FORCE_UNITS) {
+ rrd_set_error("--units can only be used once!");
+ return;
+ }
+ if (strcmp(optarg, "si") == 0)
+ im->extra_flags |= FORCE_UNITS_SI;
+ else {
+ rrd_set_error("invalid argument for --units: %s", optarg);
+ return;
+ }
+ break;
+ case 'X':
+ im->unitsexponent = atoi(optarg);
+ break;
+ case 'L':
+ im->unitslength = atoi(optarg);
+ im->forceleftspace = 1;
+ break;
+ case 'T':
+ im->tabwidth = atof(optarg);
+ break;
+ case 'S':
+ im->step = atoi(optarg);
+ break;
+ case 'N':
+ im->gridfit = 0;
+ break;
+ case 'P':
+ im->with_markup = 1;
+ break;
+ case 's':
+ if ((parsetime_error = rrd_parsetime(optarg, &start_tv))) {
+ rrd_set_error("start time: %s", parsetime_error);
+ return;
+ }
+ break;
+ case 'e':
+ if ((parsetime_error = rrd_parsetime(optarg, &end_tv))) {
+ rrd_set_error("end time: %s", parsetime_error);
+ return;
+ }
+ break;
+ case 'x':
+ if (strcmp(optarg, "none") == 0) {
+ im->draw_x_grid = 0;
+ break;
+ };
+ if (sscanf(optarg,
+ "%10[A-Z]:%ld:%10[A-Z]:%ld:%10[A-Z]:%ld:%ld:%n",
+ scan_gtm,
+ &im->xlab_user.gridst,
+ scan_mtm,
+ &im->xlab_user.mgridst,
+ scan_ltm,
+ &im->xlab_user.labst,
+ &im->xlab_user.precis, &stroff) == 7 && stroff != 0) {
+ strncpy(im->xlab_form, optarg + stroff,
+ sizeof(im->xlab_form) - 1);
+ im->xlab_form[sizeof(im->xlab_form) - 1] = '\0';
+ if ((int)
+ (im->xlab_user.gridtm = tmt_conv(scan_gtm)) == -1) {
+ rrd_set_error("unknown keyword %s", scan_gtm);
+ return;
+ } else if ((int)
+ (im->xlab_user.mgridtm = tmt_conv(scan_mtm))
+ == -1) {
+ rrd_set_error("unknown keyword %s", scan_mtm);
+ return;
+ } else if ((int)
+ (im->xlab_user.labtm = tmt_conv(scan_ltm)) == -1) {
+ rrd_set_error("unknown keyword %s", scan_ltm);
+ return;
+ }
+ im->xlab_user.minsec = 1;
+ im->xlab_user.stst = im->xlab_form;
+ } else {
+ rrd_set_error("invalid x-grid format");
+ return;
+ }
+ break;
+ case 'y':
+
+ if (strcmp(optarg, "none") == 0) {
+ im->draw_y_grid = 0;
+ break;
+ };
+ if (sscanf(optarg, "%lf:%d", &im->ygridstep, &im->ylabfact) == 2) {
+ if (im->ygridstep <= 0) {
+ rrd_set_error("grid step must be > 0");
+ return;
+ } else if (im->ylabfact < 1) {
+ rrd_set_error("label factor must be > 0");
+ return;
+ }
+ } else {
+ rrd_set_error("invalid y-grid format");
+ return;
+ }
+ break;
+ case 1007:
+ im->draw_3d_border = atoi(optarg);
+ break;
+ case 1008: /* grid-dash */
+ if(sscanf(optarg,
+ "%lf:%lf",
+ &im->grid_dash_on,
+ &im->grid_dash_off) != 2) {
+ rrd_set_error("expected grid-dash format float:float");
+ return;
+ }
+ break;
+ case 1009: /* enable dynamic labels */
+ im->dynamic_labels = 1;
+ break;
+ case 1002: /* right y axis */
+