diff options
author | nectar <nectar@FreeBSD.org> | 2002-08-30 21:23:27 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2002-08-30 21:23:27 +0000 |
commit | a77dba08ca7d8ad2f2dcd653974ac66df78cfa49 (patch) | |
tree | 6015f89700252fb05eb8fa267c46dba41913e9d8 /crypto/heimdal/appl/afsutil/pagsh.c | |
parent | 69a91bec14ec3ad49d1c8a82c40a796755f9e4a3 (diff) | |
download | FreeBSD-src-a77dba08ca7d8ad2f2dcd653974ac66df78cfa49.zip FreeBSD-src-a77dba08ca7d8ad2f2dcd653974ac66df78cfa49.tar.gz |
Import of Heimdal Kerberos from KTH repository circa 2002/08/29.
Diffstat (limited to 'crypto/heimdal/appl/afsutil/pagsh.c')
-rw-r--r-- | crypto/heimdal/appl/afsutil/pagsh.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/crypto/heimdal/appl/afsutil/pagsh.c b/crypto/heimdal/appl/afsutil/pagsh.c index 006b357..d61dba2 100644 --- a/crypto/heimdal/appl/afsutil/pagsh.c +++ b/crypto/heimdal/appl/afsutil/pagsh.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -35,7 +35,7 @@ #include <config.h> #endif -RCSID("$Id: pagsh.c,v 1.4 2000/10/02 05:05:53 assar Exp $"); +RCSID("$Id: pagsh.c,v 1.6 2002/08/23 17:54:20 assar Exp $"); #include <stdio.h> #include <stdlib.h> @@ -62,6 +62,26 @@ RCSID("$Id: pagsh.c,v 1.4 2000/10/02 05:05:53 assar Exp $"); #include <err.h> #include <roken.h> +#include <getarg.h> + +static int help_flag; +static int version_flag; +static int c_flag; + +struct getargs getargs[] = { + { NULL, 'c', arg_flag, &c_flag }, + { "version", 0, arg_flag, &version_flag }, + { "help", 'h', arg_flag, &help_flag }, +}; + +static int num_args = sizeof(getargs) / sizeof(getargs[0]); + +static void +usage(int ecode) +{ + arg_printusage(getargs, num_args, NULL, "command [args...]"); + exit(ecode); +} /* * Run command with a new ticket file / credentials cache / token @@ -77,6 +97,20 @@ main(int argc, char **argv) char *path; char **args; int i; + int optind = 0; + + set_progname(argv[0]); + if(getarg(getargs, num_args, argc, argv, &optind)) + usage(1); + if(help_flag) + usage(0); + if(version_flag) { + print_version(NULL); + exit(0); + } + + argc -= optind; + argv += optind; #ifdef KRB5 snprintf (tf, sizeof(tf), "%sXXXXXX", KRB5_DEFAULT_CCROOT); @@ -101,8 +135,6 @@ main(int argc, char **argv) errx (1, "Out of memory allocating %lu bytes", (unsigned long)((argc + 10)*sizeof(char *))); - argv++; - if(*argv == NULL) { path = getenv("SHELL"); if(path == NULL){ @@ -110,7 +142,6 @@ main(int argc, char **argv) path = strdup(pw->pw_shell); } } else { - if(strcmp(*argv, "-c") == 0) argv++; path = strdup(*argv++); } if (path == NULL) |