diff --git a/lib/krb5/krbhst-test.c b/lib/krb5/krbhst-test.c index d5b8de4d0..84481011b 100644 --- a/lib/krb5/krbhst-test.c +++ b/lib/krb5/krbhst-test.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001 Kungliga Tekniska Högskolan + * Copyright (c) 2001 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,8 +33,31 @@ #include "krb5_locl.h" +#include +#include + RCSID("$Id$"); +static int version_flag = 0; +static int help_flag = 0; + +static struct getargs args[] = { + {"version", 0, arg_flag, &version_flag, + "print version", NULL }, + {"help", 0, arg_flag, &help_flag, + NULL, NULL } +}; + +static void +usage (int ret) +{ + arg_printusage (args, + sizeof(args)/sizeof(*args), + NULL, + "[realms ...]"); + exit (ret); +} + int main(int argc, char **argv) { @@ -43,9 +66,26 @@ main(int argc, char **argv) int types[] = {KRB5_KRBHST_KDC, KRB5_KRBHST_ADMIN, KRB5_KRBHST_CHANGEPW, KRB5_KRBHST_KRB524}; const char *type_str[] = {"kdc", "admin", "changepw", "krb524"}; + int optind = 0; + setprogname (argv[0]); + + if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind)) + usage(1); + + if (help_flag) + usage (0); + + if(version_flag){ + print_version(NULL); + exit(0); + } + + argc -= optind; + argv += optind; + krb5_init_context (&context); - for(i = 1; i < argc; i++) { + for(i = 0; i < argc; i++) { krb5_krbhst_handle handle; char host[MAXHOSTNAMELEN]; diff --git a/lib/krb5/test_get_addrs.c b/lib/krb5/test_get_addrs.c index 7a645a93e..24863fedd 100644 --- a/lib/krb5/test_get_addrs.c +++ b/lib/krb5/test_get_addrs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan + * Copyright (c) 2000 - 2002 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -32,6 +32,7 @@ #include "krb5_locl.h" #include +#include RCSID("$Id$"); @@ -50,12 +51,49 @@ print_addresses (krb5_context context, const krb5_addresses *addrs) } } +static int version_flag = 0; +static int help_flag = 0; + +static struct getargs args[] = { + {"version", 0, arg_flag, &version_flag, + "print version", NULL }, + {"help", 0, arg_flag, &help_flag, + NULL, NULL } +}; + +static void +usage (int ret) +{ + arg_printusage (args, + sizeof(args)/sizeof(*args), + NULL, + ""); + exit (ret); +} + int main(int argc, char **argv) { krb5_context context; krb5_error_code ret; krb5_addresses addrs; + int optind = 0; + + setprogname (argv[0]); + + if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind)) + usage(1); + + if (help_flag) + usage (0); + + if(version_flag){ + print_version(NULL); + exit(0); + } + + argc -= optind; + argv += optind; ret = krb5_init_context(&context); if (ret)