actually use getarg
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11224 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -66,18 +66,20 @@ RCSID("$Id$");
|
|||||||
|
|
||||||
static int help_flag;
|
static int help_flag;
|
||||||
static int version_flag;
|
static int version_flag;
|
||||||
|
static int c_flag;
|
||||||
|
|
||||||
struct getargs args[] = {
|
struct getargs getargs[] = {
|
||||||
|
{ NULL, 'c', arg_flag, &c_flag },
|
||||||
{ "version", 0, arg_flag, &version_flag },
|
{ "version", 0, arg_flag, &version_flag },
|
||||||
{ "help", 'h', arg_flag, &help_flag },
|
{ "help", 'h', arg_flag, &help_flag },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int num_args = sizeof(args) / sizeof(args[0]);
|
static int num_args = sizeof(getargs) / sizeof(getargs[0]);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(int ecode)
|
usage(int ecode)
|
||||||
{
|
{
|
||||||
arg_printusage(args, num_args, NULL, "[cell]... [path]...");
|
arg_printusage(getargs, num_args, NULL, "command [args...]");
|
||||||
exit(ecode);
|
exit(ecode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +97,20 @@ main(int argc, char **argv)
|
|||||||
char *path;
|
char *path;
|
||||||
char **args;
|
char **args;
|
||||||
int i;
|
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
|
#ifdef KRB5
|
||||||
snprintf (tf, sizeof(tf), "%sXXXXXX", KRB5_DEFAULT_CCROOT);
|
snprintf (tf, sizeof(tf), "%sXXXXXX", KRB5_DEFAULT_CCROOT);
|
||||||
@@ -119,8 +135,6 @@ main(int argc, char **argv)
|
|||||||
errx (1, "Out of memory allocating %lu bytes",
|
errx (1, "Out of memory allocating %lu bytes",
|
||||||
(unsigned long)((argc + 10)*sizeof(char *)));
|
(unsigned long)((argc + 10)*sizeof(char *)));
|
||||||
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
if(*argv == NULL) {
|
if(*argv == NULL) {
|
||||||
path = getenv("SHELL");
|
path = getenv("SHELL");
|
||||||
if(path == NULL){
|
if(path == NULL){
|
||||||
@@ -128,7 +142,6 @@ main(int argc, char **argv)
|
|||||||
path = strdup(pw->pw_shell);
|
path = strdup(pw->pw_shell);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(strcmp(*argv, "-c") == 0) argv++;
|
|
||||||
path = strdup(*argv++);
|
path = strdup(*argv++);
|
||||||
}
|
}
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
|
Reference in New Issue
Block a user