summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a7aac97)
raw | patch | inline | side by side (parent: a7aac97)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 4 Apr 2006 18:46:08 +0000 (18:46 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 4 Apr 2006 18:46:08 +0000 (18:46 +0000) |
program/CONTRIBUTORS | patch | blob | history | |
program/src/rrd_tool.c | patch | blob | history |
diff --git a/program/CONTRIBUTORS b/program/CONTRIBUTORS
index d7eb4b0523d4461420c16bef128f881e66c00998..edfde57998b923aafe93a3c4ed77dc2ddda12743 100644 (file)
--- a/program/CONTRIBUTORS
+++ b/program/CONTRIBUTORS
Rainer Bawidamann <Rainer.Bawidamann with informatik.uni-ulm.de>
Roman Hoogant <rhoogant with ee.ethz.ch>
Ronan Mullally <ronan in 4L.ie>
+Roger J. Meier <roger.meier in terreactive.ch> (arbitrary linelength in rrdtool)
Russ Wright <rwwright with home.com>
Sean Summers <sean with Fenstermaker.com> (RPM .spec)
Selena M Brewington <smbrewin with ichips.intel.com> add_ds
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index dd3f0f9197e1b266bfdbfad6a9103c91c39a68bc..8bd4ded24e84251ad2f1b369b3fee363bc025d4a 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
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);
}
}
- while (fgets(aLine, sizeof(aLine)-1, stdin)){
+ while (fgetslong(&aLine, stdin)){
if ((argc = CountArgs(aLine)) == 0) {
printf("ERROR: not enough arguments\n");
}
}
}
fflush(stdout); /* this is important for pipes to work */
+ free(aLine);
}
}
else if (argc == 2)