diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2012-01-10 13:46:22 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2012-01-10 13:46:22 -0500 |
commit | 9afafead1e53c96ee67fa98f6534d5b719ab9854 (patch) | |
tree | d07b04d2e5466089e9087f9eb0f4a6693d114f72 /gpxlogger.c | |
parent | b34bd07cbdbbf17212417265c6b62456175fde1a (diff) | |
download | gpsd-9afafead1e53c96ee67fa98f6534d5b719ab9854.tar.gz |
Hurd patch to support ulimited-length filenames, with a splint fix.
Diffstat (limited to 'gpxlogger.c')
-rw-r--r-- | gpxlogger.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gpxlogger.c b/gpxlogger.c index 5403adba..070d3c36 100644 --- a/gpxlogger.c +++ b/gpxlogger.c @@ -233,22 +233,26 @@ int main(int argc, char **argv) break; case 'f': /* Output file name. */ { - char fname[PATH_MAX]; + char *fname = NULL; time_t t; - size_t s; + size_t s = 0; + size_t fnamesize = strlen(optarg); t = time(NULL); - s = strftime(fname, sizeof(fname), optarg, localtime(&t)); - if (s == 0) { - syslog(LOG_ERR, - "Bad template \"%s\", logging to stdout.", optarg); - break; + while (s == 0) { + fnamesize += 1024; + fname = realloc(fname, fnamesize); + assert(fname != NULL); /* pacify splint */ + s = strftime(fname, fnamesize - 1, optarg, localtime(&t)); } + assert(fname != NULL); /* pacify splint */ + fname[s] = '\0';; logfile = fopen(fname, "w"); if (logfile == NULL) syslog(LOG_ERR, "Failed to open %s: %s, logging to stdout.", fname, strerror(errno)); + free(fname); break; } case 'i': /* set polling interfal */ |