+2000-04-19 Danilo Almeida <dalmeida@mit.edu>
+
+ * Makefile.in: Link in getopt library on Windows.
+
+ * klist.c: Use getopt so that we can parse combined options (e.g.,
+ -an or -45).
+
2000-03-07 Danilo Almeida <dalmeida@mit.edu>
* klist.M: Get man page up-to-date.
klist: klist.o $(KRB4COMPAT_DEPLIBS)
$(CC_LINK) -o $@ klist.o $(KRB4COMPAT_LIBS)
-$(OUTPRE)klist.exe: $(OUTPRE)klist.obj $(KLIB) $(CLIB)
+$(OUTPRE)klist.exe: $(OUTPRE)klist.obj $(BUILDTOP)\util\windows\$(OUTPRE)getopt.lib $(KLIB) $(CLIB)
link $(EXE_LINKOPTS) -out:$@ $** wsock32.lib
clean-unix::
#include <netdb.h>
#endif
+extern int optind;
+
int show_flags = 0, show_time = 0, status_only = 0, show_keys = 0;
int show_etype = 0, show_addresses = 0, no_resolve = 0;
char *defname;
int argc;
char **argv;
{
+ int c;
char *name;
int mode;
int use_k5 = 0, use_k4 = 0;
progname = GET_PROGNAME(argv[0]);
- argv++;
name = NULL;
mode = DEFAULT;
- while (*argv) {
- if ((*argv)[0] != '-') {
- if (name) usage();
- name = *argv;
- } else switch ((*argv)[1]) {
+ while ((c = getopt(argc, argv, "fetKsnack45")) != -1) {
+ switch (c) {
case 'f':
show_flags = 1;
break;
usage();
break;
}
- argv++;
}
if (no_resolve && !show_addresses) {
usage();
}
+ if (argc - optind > 1) {
+ fprintf(stderr, "Extra arguments (starting with \"%s\").\n",
+ argv[optind+1]);
+ usage();
+ }
+
+ name = (optind == argc-1) ? argv[optind] : 0;
+
if (!use_k5 && !use_k4)
{
use_k5 = default_k5;