read_msg.o \
read_pwd.o \
realm_dom.o \
+ realm_iter.o \
sendto_kdc.o \
sn2princ.o \
timeofday.o \
read_msg.$(OBJEXT) \
read_pwd.$(OBJEXT) \
realm_dom.$(OBJEXT) \
+ realm_iter.$(OBJEXT) \
sendto_kdc.$(OBJEXT) \
sn2princ.$(OBJEXT) \
timeofday.$(OBJEXT) \
$(srcdir)/read_msg.c \
$(srcdir)/read_pwd.c \
$(srcdir)/realm_dom.c \
+ $(srcdir)/realm_iter.c \
$(srcdir)/port2ip.c \
$(srcdir)/sendto_kdc.c \
$(srcdir)/sn2princ.c \
T_AN_TO_LN_OBJS = t_an_to_ln.o an_to_ln.o
+T_REALM_ITER_OBJS = t_realm_iter.o realm_iter.o
+
t_std_conf: $(T_STD_CONF_OBJS) $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o t_std_conf $(T_STD_CONF_OBJS) $(KRB5_BASE_LIBS)
t_an_to_ln: $(T_AN_TO_LN_OBJS) $(KRB5_BASE_DEPLIBS)
$(CC_LINK) -o t_an_to_ln $(T_AN_TO_LN_OBJS) $(KRB5_BASE_LIBS)
+t_realm_iter: $(T_REALM_ITER_OBJS) $(KRB5_BASE_DEPLIBS)
+ $(CC_LINK) -o t_realm_iter $(T_REALM_ITER_OBJS) $(KRB5_BASE_LIBS)
+
check-unix:: $(TEST_PROGS)
KRB5_CONFIG=$(srcdir)/td_krb5.conf ; export KRB5_CONFIG ;\
$(KRB5_RUN_ENV) ./t_std_conf -d -s NEW.DEFAULT.REALM -d \
--- /dev/null
+/*
+ * lib/krb5/os/realm_init.c
+ *
+ * Copyright 1998 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * krb5_realm_iterate()
+ */
+
+#include "k5-int.h"
+#include <ctype.h>
+#include <stdio.h>
+
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_realm_iterator_create(context, iter_p)
+ krb5_context context;
+ void **iter_p;
+{
+ static const char *names[] = { "realms", 0 };
+
+ return profile_iterator_create(context->profile, names,
+ PROFILE_ITER_LIST_SECTION |
+ PROFILE_ITER_SECTIONS_ONLY,
+ iter_p);
+}
+
+KRB5_DLLIMP krb5_error_code KRB5_CALLCONV
+krb5_realm_iterator(context, iter_p, ret_realm)
+ krb5_context context;
+ void **iter_p;
+ char **ret_realm;
+{
+ return profile_iterator(iter_p, ret_realm, 0);
+}
+
+KRB5_DLLIMP void KRB5_CALLCONV
+krb5_realm_iterator_free(context, iter_p)
+ krb5_context context;
+ void **iter_p;
+{
+ profile_iterator_free(iter_p);
+}
+
+KRB5_DLLIMP void KRB5_CALLCONV
+krb5_free_realm_string(context, str)
+ krb5_context context;
+ char *str;
+{
+ profile_release_string(str);
+}
--- /dev/null
+#include "krb5.h"
+
+#include <stdio.h>
+
+void test_realm_iterator(ctx)
+{
+ krb5_error_code retval;
+ char *realm;
+ void *iter;
+
+ if ((retval = krb5_realm_iterator_create(ctx, &iter))) {
+ com_err("krb5_realm_iterator_create", retval, 0);
+ return;
+ }
+ while (iter) {
+ if ((retval = krb5_realm_iterator(ctx, &iter, &realm))) {
+ com_err("krb5_realm_iterator", retval, 0);
+ krb5_realm_iterator_free(ctx, &iter);
+ return;
+ }
+ if (realm) {
+ printf("Realm: '%s'\n", realm);
+ krb5_free_realm_string(ctx, realm);
+ }
+ }
+}
+
+int main(argc, argv)
+ int argc;
+ char **argv;
+{
+ krb5_context ctx;
+ krb5_error_code retval;
+
+ retval = krb5_init_context(&ctx);
+ if (retval) {
+ fprintf(stderr, "krb5_init_context returned error %ld\n",
+ retval);
+ exit(1);
+ }
+
+ test_realm_iterator(ctx);
+
+ krb5_free_context(ctx);
+ return 0;
+}