2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose and without fee is hereby granted,
7 * provided that the above copyright notice appears in all copies and
8 * that both that copyright notice and this permission notice appear
9 * in supporting documentation, and that the name of The University
10 * of Michigan not be used in advertising or publicity pertaining to
11 * distribution of the software without specific, written prior
12 * permission. This software is supplied as is without expressed or
13 * implied warranties of any kind.
15 * Research Systems Unix Group
16 * The University of Michigan
18 * 535 W. William Street
21 * netatalk@itd.umich.edu
24 #include <sys/types.h>
25 #include <netatalk/endian.h>
26 #include <netatalk/at.h>
27 #include <atalk/nbp.h>
28 #include <atalk/util.h>
31 #if !defined( sun ) || !defined( i386 )
44 if (( p = strrchr( av0, '/' )) == 0 ) {
50 printf( "Usage:\t%s [ -A address ] [ -r responses] [ obj:type@zone ]\n", p );
60 int i, c, nresp = 1000;
66 memset(&addr, 0, sizeof(addr));
67 while (( c = getopt( ac, av, "r:A:" )) != EOF ) {
70 if (!atalk_aton(optarg, &addr)) {
71 fprintf(stderr, "Bad address.\n");
76 nresp = atoi( optarg );
85 if (( nn = (struct nbpnve *)malloc( nresp * sizeof( struct nbpnve )))
91 if ( ac - optind > 1 ) {
97 * Get default values from the environment. We need to copy out
98 * the results, here, since nbp_name returns it's parameters
99 * in static space, and we'll clobber them when we call it again
102 if (( name = getenv( "NBPLKUP" )) != NULL ) {
103 if ( nbp_name( name, &Obj, &Type, &Zone )) {
105 "Environment variable syntax error: NBPLKUP = %s\n",
110 if (( name = (char *)malloc( strlen( Obj ) + 1 )) == NULL ) {
117 if (( name = (char *)malloc( strlen( Type ) + 1 )) == NULL ) {
121 strcpy( name, Type );
124 if (( name = (char *)malloc( strlen( Zone ) + 1 )) == NULL ) {
128 strcpy( name, Zone );
133 if ( ac - optind == 1 ) {
134 if ( nbp_name( av[ optind ], &Obj, &Type, &Zone )) {
140 if (( c = nbp_lookup( Obj, Type, Zone, nn, nresp, &addr)) < 0 ) {
141 perror( "nbp_lookup" );
144 for ( i = 0; i < c; i++ ) {
145 printf( "%31.*s:%-34.*s %u.%u:%u\n",
146 nn[ i ].nn_objlen, nn[ i ].nn_obj,
147 nn[ i ].nn_typelen, nn[ i ].nn_type,
148 ntohs( nn[ i ].nn_sat.sat_addr.s_net ),
149 nn[ i ].nn_sat.sat_addr.s_node,
150 nn[ i ].nn_sat.sat_port );