aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2010-03-17 21:29:47 -0500
committerPeter Seebach <peter.seebach@windriver.com>2010-03-17 21:50:18 -0500
commit69984c7a2765b88bb3369177a2a519d1d2ac67f7 (patch)
treed15059c708172932d58890b26f4aae33d4a02738
parentc5816032f96e0732a25c5bba8c4ec7ce05fb5066 (diff)
downloadpseudo-69984c7a2765b88bb3369177a2a519d1d2ac67f7.tar.gz
pseudo-69984c7a2765b88bb3369177a2a519d1d2ac67f7.tar.bz2
pseudo-69984c7a2765b88bb3369177a2a519d1d2ac67f7.zip
Add -h option to pseudo.
Add the -h (help) option to pseudo, and document -h for both pseudo and pseudolog.
-rw-r--r--ChangeLog.txt4
-rw-r--r--pseudo.111
-rw-r--r--pseudo.c21
-rw-r--r--pseudolog.17
4 files changed, 33 insertions, 10 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 138e54c..eb14704 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,7 @@
+2010-03-17:
+ * (seebs) fixup help options
+ * (seebs) use strerror() in a couple more places
+
2010-03-16:
* (seebs) Fix missing error checking noted by comp.lang.c reader.
diff --git a/pseudo.1 b/pseudo.1
index 35c3c69..43721ab 100644
--- a/pseudo.1
+++ b/pseudo.1
@@ -23,6 +23,8 @@
.RB [ \-t\ timeout ]
.RB [ command ]
.PP
+.B pseudo \-h
+.PP
.B pseudo
.RB [ \-P\ prefix ]
.B \-S
@@ -64,9 +66,16 @@ can then start the server automatically.
The
.I pseudo
-command can be invoked in one of four possible modes:
+command can be invoked in one of five possible modes:
.TP 8
+.B \-h
+The
+.B \-h
+option causes
+.I pseudo
+to print a usage message and exit.
+.TP 8
.B \-V
The
.B \-V
diff --git a/pseudo.c b/pseudo.c
index 515f447..447f602 100644
--- a/pseudo.c
+++ b/pseudo.c
@@ -47,11 +47,13 @@ int opt_S = 0;
static int pseudo_op(pseudo_msg_t *msg, const char *tag);
void
-usage(void) {
- pseudo_diag("Usage: pseudo [-dflv] [-P prefix] [-t timeout] [command]\n");
- pseudo_diag(" pseudo [-dflv] [-P prefix] -S\n");
- pseudo_diag(" pseudo [-dflv] [-P prefix] -V\n");
- exit(1);
+usage(int status) {
+ FILE *f = status ? stderr : stdout;
+ fputs("Usage: pseudo [-dflv] [-P prefix] [-t timeout] [command]\n", f);
+ fputs(" pseudo -h\n", f);
+ fputs(" pseudo [-dflv] [-P prefix] -S\n", f);
+ fputs(" pseudo [-dflv] [-P prefix] -V\n", f);
+ exit(status);
}
/* main server process */
@@ -92,7 +94,7 @@ main(int argc, char *argv[]) {
* wrong. The + suppresses this annoying behavior, but may not
* be compatible with sane option libraries.
*/
- while ((o = getopt(argc, argv, "+dflP:St:vV")) != -1) {
+ while ((o = getopt(argc, argv, "+dfhlP:St:vV")) != -1) {
switch (o) {
case 'd':
/* run as daemon */
@@ -102,6 +104,9 @@ main(int argc, char *argv[]) {
/* run foregrounded */
opt_f = 1;
break;
+ case 'h':
+ usage(0);
+ break;
case 'l':
optptr += snprintf(optptr, PATH_MAX - (optptr - opts),
"%s-l", optptr > opts ? " " : "");
@@ -117,7 +122,7 @@ main(int argc, char *argv[]) {
pseudo_server_timeout = strtol(optarg, &s, 10);
if (*s && !isspace(*s)) {
pseudo_diag("Timeout must be an integer value.\n");
- usage();
+ usage(EXIT_FAILURE);
}
optptr += snprintf(optptr, PATH_MAX - (optptr - opts),
"%s-t %d", optptr > opts ? " " : "",
@@ -136,7 +141,7 @@ main(int argc, char *argv[]) {
break;
case '?':
pseudo_diag("unknown/invalid argument (option '%c').\n", optopt);
- usage();
+ usage(EXIT_FAILURE);
break;
}
}
diff --git a/pseudolog.1 b/pseudolog.1
index 6bb0bd9..21b2908 100644
--- a/pseudolog.1
+++ b/pseudolog.1
@@ -17,7 +17,7 @@
.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
.TH pseudolog 1 "pseudo - pretending to be root"
.SH SYNOPSIS
-.B pseudolog -l
+.B pseudolog \-l
.RB [ \-Pv ]
[
.B \-E
@@ -35,6 +35,8 @@
.B \-F
.I format
]
+.PP
+.B pseudolog \-h
.RI [ SPECIFICATIONS ]
.SH DESCRIPTION
The
@@ -54,6 +56,9 @@ section below.
The following other options are supported:
.TP 8
+.B \-h
+Print a usage message and exit.
+.TP 8
.B \-D
Restrict query output to distinct rows. Rows will have members defined by
the