add option parsing

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9044 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
2000-09-10 19:19:20 +00:00
parent 47b95f3233
commit 9c1353f1f8
4 changed files with 117 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska H<>gskolan
* Copyright (c) 1997, 1998, 2000 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -41,12 +41,39 @@ do_del_entry(krb5_principal principal, void *data)
return kadm5_delete_principal(kadm_handle, principal);
}
static struct getargs args[] = {
{ "help", 'h', arg_flag, NULL }
};
static int num_args = sizeof(args) / sizeof(args[0]);
static void
usage(void)
{
arg_printusage (args, num_args, "delete", "principal...");
}
int
del_entry(int argc, char **argv)
{
int optind = 0;
int help_flag = 0;
int i;
krb5_error_code ret;
args[0].value = &help_flag;
if(getarg(args, num_args, argc, argv, &optind)) {
usage ();
return 0;
}
if(optind == argc || help_flag) {
usage ();
return 0;
}
for(i = 1; i < argc; i++)
ret = foreach_principal(argv[i], do_del_entry, NULL);
return 0;