summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-03-27 12:03:00 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-03-27 12:03:00 -0400
commit1f5816e6fd4ea335fefff8b4d40872724fb415fa (patch)
tree5851f82df5ac578ba641d998a75ccc757b3df01e /gpsmon.c
parentdaf2e8b8bad74f350406eea4c9939654926d6c39 (diff)
downloadgpsd-1f5816e6fd4ea335fefff8b4d40872724fb415fa.tar.gz
Change the -l option of gpsmon so it enable logging at srartup.
The old -l option (list types) becomes -L. We did this so the 'l' option will be consistent with the 'l' command. Should be OK since gpsmon is not something anyone will use in a script.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gpsmon.c b/gpsmon.c
index 3e62f065..5f5f21f4 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -414,7 +414,7 @@ int main (int argc, char **argv)
(void)putenv("TZ=GMT"); // for ctime()
/*@ +observertrans @*/
/*@ -branchstate @*/
- while ((option = getopt(argc, argv, "D:F:Vhl")) != -1) {
+ while ((option = getopt(argc, argv, "D:F:LVhl:")) != -1) {
switch (option) {
case 'D':
debuglevel = atoi(optarg);
@@ -425,7 +425,7 @@ int main (int argc, char **argv)
case 'V':
(void)printf("gpsmon: %s (revision %s)\n", VERSION, REVISION);
exit(0);
- case 'l': /* list known device types */
+ case 'L': /* list known device types */
(void) fputs("General commands available per type. '+' means there are private commands.\n", stdout);
for (active = monitor_objects; *active; active++) {
(void)fputs("i l q ^S ^Q", stdout);
@@ -463,6 +463,13 @@ int main (int argc, char **argv)
(void)fputc('\n', stdout);
}
exit(0);
+ case 'l': /* enable logging at startup */
+ logfile = fopen(optarg, "w");
+ if (logfile == NULL) {
+ (void)fprintf(stderr, "Couldn't open logfile for writing.\n");
+ exit(1);
+ }
+ break;
case 'h': case '?': default:
(void)fputs("usage: gpsmon [-?hVl] [-D debuglevel] [-F controlsock] [server[:port:[device]]]\n", stderr);
exit(1);