]> arthur.barton.de Git - netatalk.git/blob - bin/nbp/nbpunrgstr.c
Added checks for config.h in bin/ code
[netatalk.git] / bin / nbp / nbpunrgstr.c
1 /*
2  * Copyright (c) 1990,1991 Regents of The University of Michigan.
3  * All Rights Reserved.
4  *
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.
14  *
15  *      Research Systems Unix Group
16  *      The University of Michigan
17  *      c/o Mike Clark
18  *      535 W. William Street
19  *      Ann Arbor, Michigan
20  *      +1-313-763-0525
21  *      netatalk@itd.umich.edu
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include  <sys/types.h>
29 #include  <netatalk/endian.h>
30 #include  <netatalk/at.h>
31 #include  <stdio.h>
32 #include  <string.h>
33
34 Usage( av0 )
35     char        *av0;
36 {
37     char        *p;
38
39     if (( p = strrchr( av0, '/' )) == 0 ) {
40         p = av0;
41     } else {
42         p++;
43     }
44
45     fprintf( stderr, "Usage: %s [ -A address ] obj:type@zone\n", p );
46     exit( 1 );
47 }
48
49 main( ac, av )
50     int         ac;
51     char        **av;
52 {
53     char                *Obj = 0, *Type = 0, *Zone = 0;
54     struct at_addr      addr;
55     int                 c;
56
57     extern char         *optarg;
58     extern int          optind;
59     
60     memset(&addr, 0, sizeof(addr));
61     while ((c = getopt(ac, av, "A:")) != EOF) {
62       switch (c) {
63       case 'A':
64         if (!atalk_aton(optarg, &addr)) {
65           fprintf(stderr, "Bad address.\n");
66           exit(1);
67         }
68         break;
69       default:
70         Usage(av[0]);
71         break;
72       }
73     }
74
75     if (ac - optind != 1) {
76         Usage( av[ 0 ] );
77     }
78
79     /*
80      * Get the name. If Type or Obj aren't specified, error.
81      */
82     if ( nbp_name( av[optind], &Obj, &Type, &Zone ) || !Obj || !Type ) {
83         Usage( av[ 0 ] );
84     }
85
86     if ( nbp_unrgstr( Obj, Type, Zone, &addr ) < 0 ) {
87         fprintf( stderr, "Can't unregister %s:%s@%s\n", Obj, Type,
88                 Zone ? Zone : "*" );
89         exit( 1 );
90     }
91 }