summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-23 23:46:56 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-23 23:46:56 -0700
commit0193fcd1732c2ee37896ae779b97a8b2ee79a3c1 (patch)
tree8ebafabf574a7d029fea238ede8fbe060d2f267d
parentc74119a641e3c4fc74deaf8f47d3faf589d0d196 (diff)
Print which option was in error along with usage message
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xfindproxy.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/xfindproxy.c b/xfindproxy.c
index 775321e..5ca21db 100644
--- a/xfindproxy.c
+++ b/xfindproxy.c
@@ -116,6 +116,18 @@ cvthexkey(const char *hexstr, char **ptrp) /* turn hex key string into octets */
return (int) len;
}
+static void _X_NORETURN
+usage (void)
+{
+ fprintf (stderr,
+ "usage: xfindproxy -server serverAddr -name serviceName"
+ " [-manager managerAddr]\n"
+ " [-auth] [-host hostAddr] [-options opts]\n"
+ "-manager can be omitted only if PROXY_MANAGER is in the environment\n");
+ exit (1);
+}
+
+
int
main(int argc, char *argv[])
{
@@ -180,13 +192,23 @@ main(int argc, char *argv[])
}
usage:
- fprintf (stderr,
- "usage: xfindproxy -server serverAddr -name serviceName [-manager managerAddr] [-auth] [-host hostAddr] [-options opts]\n-manager can be omitted only if PROXY_MANAGER is in the environment\n");
- exit (1);
+ if (i >= argc)
+ fprintf (stderr, "%s: %s requires an argument\n",
+ argv[0], argv[i-1]);
+ else
+ fprintf (stderr, "%s: unrecognized argument '%s'\n",
+ argv[0], argv[i]);
+ usage();
}
- if (serviceName == NULL || serverAddress == NULL)
- goto usage;
+ if (serviceName == NULL) {
+ fprintf (stderr, "%s: -name serviceName must be specified\n", argv[0]);
+ usage();
+ }
+ if (serverAddress == NULL) {
+ fprintf (stderr, "%s: -server serverAddr must be specified\n", argv[0]);
+ usage();
+ }
if (managerAddress == NULL) {
managerAddress = getenv("PROXY_MANAGER");