14137ff4cSJacques Vidrine /* 24137ff4cSJacques Vidrine * Copyright (c) 2001 Kungliga Tekniska H�gskolan 34137ff4cSJacques Vidrine * (Royal Institute of Technology, Stockholm, Sweden). 44137ff4cSJacques Vidrine * All rights reserved. 54137ff4cSJacques Vidrine * 64137ff4cSJacques Vidrine * Redistribution and use in source and binary forms, with or without 74137ff4cSJacques Vidrine * modification, are permitted provided that the following conditions 84137ff4cSJacques Vidrine * are met: 94137ff4cSJacques Vidrine * 104137ff4cSJacques Vidrine * 1. Redistributions of source code must retain the above copyright 114137ff4cSJacques Vidrine * notice, this list of conditions and the following disclaimer. 124137ff4cSJacques Vidrine * 134137ff4cSJacques Vidrine * 2. Redistributions in binary form must reproduce the above copyright 144137ff4cSJacques Vidrine * notice, this list of conditions and the following disclaimer in the 154137ff4cSJacques Vidrine * documentation and/or other materials provided with the distribution. 164137ff4cSJacques Vidrine * 174137ff4cSJacques Vidrine * 3. Neither the name of the Institute nor the names of its contributors 184137ff4cSJacques Vidrine * may be used to endorse or promote products derived from this software 194137ff4cSJacques Vidrine * without specific prior written permission. 204137ff4cSJacques Vidrine * 214137ff4cSJacques Vidrine * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 224137ff4cSJacques Vidrine * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 234137ff4cSJacques Vidrine * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 244137ff4cSJacques Vidrine * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 254137ff4cSJacques Vidrine * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 264137ff4cSJacques Vidrine * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 274137ff4cSJacques Vidrine * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 284137ff4cSJacques Vidrine * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 294137ff4cSJacques Vidrine * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 304137ff4cSJacques Vidrine * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 314137ff4cSJacques Vidrine * SUCH DAMAGE. 324137ff4cSJacques Vidrine */ 334137ff4cSJacques Vidrine 344137ff4cSJacques Vidrine #include "krb5_locl.h" 354137ff4cSJacques Vidrine 364137ff4cSJacques Vidrine RCSID("$Id: krbhst-test.c,v 1.2 2001/06/17 12:22:59 assar Exp $"); 374137ff4cSJacques Vidrine 384137ff4cSJacques Vidrine int 394137ff4cSJacques Vidrine main(int argc, char **argv) 404137ff4cSJacques Vidrine { 414137ff4cSJacques Vidrine int i, j; 424137ff4cSJacques Vidrine krb5_context context; 434137ff4cSJacques Vidrine int types[] = {KRB5_KRBHST_KDC, KRB5_KRBHST_ADMIN, KRB5_KRBHST_CHANGEPW, 444137ff4cSJacques Vidrine KRB5_KRBHST_KRB524}; 454137ff4cSJacques Vidrine const char *type_str[] = {"kdc", "admin", "changepw", "krb524"}; 464137ff4cSJacques Vidrine 474137ff4cSJacques Vidrine krb5_init_context (&context); 484137ff4cSJacques Vidrine for(i = 1; i < argc; i++) { 494137ff4cSJacques Vidrine krb5_krbhst_handle handle; 504137ff4cSJacques Vidrine char host[MAXHOSTNAMELEN]; 514137ff4cSJacques Vidrine 524137ff4cSJacques Vidrine for (j = 0; j < sizeof(types)/sizeof(*types); ++j) { 534137ff4cSJacques Vidrine printf ("%s for %s:\n", type_str[j], argv[i]); 544137ff4cSJacques Vidrine 554137ff4cSJacques Vidrine krb5_krbhst_init(context, argv[i], types[j], &handle); 564137ff4cSJacques Vidrine while(krb5_krbhst_next_as_string(context, handle, 574137ff4cSJacques Vidrine host, sizeof(host)) == 0) 584137ff4cSJacques Vidrine printf("%s\n", host); 594137ff4cSJacques Vidrine krb5_krbhst_reset(context, handle); 604137ff4cSJacques Vidrine printf ("\n"); 614137ff4cSJacques Vidrine } 624137ff4cSJacques Vidrine } 634137ff4cSJacques Vidrine return 0; 644137ff4cSJacques Vidrine } 65