cleanup option parsing

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5769 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1999-03-27 11:49:38 +00:00
parent 06d8c5702a
commit ce40cf9200

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 1998, 1999 Kungliga Tekniska H<>gskolan * Copyright (c) 1997-1999 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* 3. All advertising materials mentioning features or use of this software * 3. Neither the name of the Institute nor the names of its contributors
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* H<>gskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
* without specific prior written permission. * without specific prior written permission.
* *
@@ -48,7 +43,9 @@ RCSID("$Id$");
static int help_flag; static int help_flag;
static int version_flag; static int version_flag;
static int crete_user; #if 0
static int create_user;
#endif
static getarg_strings cells; static getarg_strings cells;
static char *realm; static char *realm;
static getarg_strings files; static getarg_strings files;
@@ -56,17 +53,16 @@ static int unlog_flag;
static int verbose; static int verbose;
struct getargs args[] = { struct getargs args[] = {
{ "help", 'h', arg_flag, &help_flag, NULL, NULL }, { "cell", 'c', arg_strings, &cells, "cell to get tokens for", "cell" },
{ "version", 0, arg_flag, &version_flag, NULL, NULL }, { "file", 'p', arg_strings, &files, "file to get tokens for", "path" },
{ "verbose", 'v', arg_flag, &verbose, NULL, NULL }, { "realm", 'k', arg_string, &realm, "realm for afs cell", "realm" },
{ "unlog", 'u', arg_flag, &unlog_flag, "remove tokens" },
#if 0 #if 0
{ "create-user", 0, arg_flag, &crete_user, { "create-user", 0, arg_flag, &create_user, "create user if not found" },
"create user if not found", NULL },
#endif #endif
{ "cell", 'c', arg_strings, &cells, "cell to get tokens for", "cell" }, { "verbose",'v', arg_flag, &verbose },
{ "realm", 'k', arg_string, &realm, "realm for afs cell", "realm" }, { "version", 0, arg_flag, &version_flag },
{ "file", 'p', arg_strings, &files, "file to get tokens for", "path" }, { "help", 'h', arg_flag, &help_flag },
{ "unlog", 'u', arg_flag, &unlog_flag, "remove tokens", NULL },
}; };
static int num_args = sizeof(args) / sizeof(args[0]); static int num_args = sizeof(args) / sizeof(args[0]);
@@ -184,10 +180,6 @@ main(int argc, char **argv)
set_progname(argv[0]); set_progname(argv[0]);
krb5_init_context(&context);
if(!k_hasafs())
krb5_errx(context, 1,
"AFS doesn't seem to be present on this machine");
if(getarg(args, num_args, argc, argv, &optind)) if(getarg(args, num_args, argc, argv, &optind))
usage(1); usage(1);
if(help_flag) if(help_flag)
@@ -196,6 +188,12 @@ main(int argc, char **argv)
print_version(NULL); print_version(NULL);
exit(0); exit(0);
} }
krb5_init_context(&context);
if(!k_hasafs())
krb5_errx(context, 1,
"AFS doesn't seem to be present on this machine");
if(unlog_flag){ if(unlog_flag){
k_unlog(); k_unlog();
exit(0); exit(0);