X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_tool.c;h=8bd4ded24e84251ad2f1b369b3fee363bc025d4a;hb=02f15efd404a828391c966322986457805f386a6;hp=2e0bf9cf92e30b050887d48fec2e97b4dd5368d3;hpb=5f5778fabce271e9c1e5f06d6e588c5bb092d889;p=rrdtool.git diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 2e0bf9c..8bd4ded 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -22,7 +22,7 @@ void PrintUsage(char *cmd) { char help_main[] = - "RRDtool " PACKAGE_VERSION " Copyright 1997-2005 by Tobias Oetiker \n" + "RRDtool " PACKAGE_VERSION " Copyright 1997-2006 by Tobias Oetiker \n" " Compiled " __DATE__ " " __TIME__ "\n\n" "Usage: rrdtool [options] command command_options\n\n"; @@ -114,9 +114,10 @@ void PrintUsage(char *cmd) "\t\t[-f|--imginfo printfstr]\n" "\t\t[-a|--imgformat PNG]\n" "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n" - "\t\t[DEF:vname=rrd:ds-name:CF]\n" - "\t\t[CDEF:vname=rpn-expression]\n"; + "\t\t[-W|--watermark string]\n" + "\t\t[DEF:vname=rrd:ds-name:CF]\n"; char help_graph3[] = + "\t\t[CDEF:vname=rpn-expression]\n" "\t\t[VDEF:vdefname=rpn-expression]\n" "\t\t[PRINT:vdefname:format]\n" "\t\t[GPRINT:vdefname:format]\n" @@ -294,11 +295,34 @@ void PrintUsage(char *cmd) fputs(help_lic, stdout); } +static char *fgetslong(char **aLinePtr, FILE *stream) +{ + char *linebuf; + size_t bufsize = MAX_LENGTH; + int eolpos = 0; + + if (feof(stream)) return *aLinePtr = 0; + if (!(linebuf = malloc(bufsize))) { + perror("fgetslong: malloc"); + exit(1); + } + linebuf[0] = '\0'; + while (fgets(linebuf + eolpos, MAX_LENGTH, stream)) { + eolpos += strlen(linebuf + eolpos); + if (linebuf[eolpos - 1] == '\n') return *aLinePtr = linebuf; + bufsize += MAX_LENGTH; + if (!(linebuf = realloc(linebuf, bufsize))) { + perror("fgetslong: realloc"); + exit(1); + } + } + return *aLinePtr = linebuf[0] ? linebuf : 0; +} int main(int argc, char *argv[]) { char **myargv; - char aLine[MAX_LENGTH]; + char *aLine; char *firstdir=""; #ifdef MUST_DISABLE_SIGFPE signal(SIGFPE,SIG_IGN); @@ -361,9 +385,9 @@ int main(int argc, char *argv[]) } } - while (fgets(aLine, sizeof(aLine)-1, stdin)){ + while (fgetslong(&aLine, stdin)){ if ((argc = CountArgs(aLine)) == 0) { - fprintf(stderr,"ERROR: not enough arguments\n"); + printf("ERROR: not enough arguments\n"); } if ((myargv = (char **) malloc((argc+1) * sizeof(char *))) == NULL) { @@ -396,6 +420,7 @@ int main(int argc, char *argv[]) } } fflush(stdout); /* this is important for pipes to work */ + free(aLine); } } else if (argc == 2) @@ -650,8 +675,15 @@ int HandleInputLine(int argc, char **argv, FILE* out) double ymin,ymax; int i; int tostdout = (strcmp(argv[2],"-") == 0); + int imginfo = 0; + for (i=2;i