]> arthur.barton.de Git - netatalk.git/blob - bin/nbp/nbpunrgstr.c
Initial revision
[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 #include  <sys/types.h>
25 #include  <netatalk/endian.h>
26 #include  <netatalk/at.h>
27 #include  <stdio.h>
28 #include  <string.h>
29
30 Usage( av0 )
31     char        *av0;
32 {
33     char        *p;
34
35     if (( p = strrchr( av0, '/' )) == 0 ) {
36         p = av0;
37     } else {
38         p++;
39     }
40
41     fprintf( stderr, "Usage: %s [ -A address ] obj:type@zone\n", p );
42     exit( 1 );
43 }
44
45 main( ac, av )
46     int         ac;
47     char        **av;
48 {
49     char                *Obj = 0, *Type = 0, *Zone = 0;
50     struct at_addr      addr;
51     int                 c;
52
53     extern char         *optarg;
54     extern int          optind;
55     
56     memset(&addr, 0, sizeof(addr));
57     while ((c = getopt(ac, av, "A:")) != EOF) {
58       switch (c) {
59       case 'A':
60         if (!atalk_aton(optarg, &addr)) {
61           fprintf(stderr, "Bad address.\n");
62           exit(1);
63         }
64         break;
65       default:
66         Usage(av[0]);
67         break;
68       }
69     }
70
71     if (ac - optind != 1) {
72         Usage( av[ 0 ] );
73     }
74
75     /*
76      * Get the name. If Type or Obj aren't specified, error.
77      */
78     if ( nbp_name( av[optind], &Obj, &Type, &Zone ) || !Obj || !Type ) {
79         Usage( av[ 0 ] );
80     }
81
82     if ( nbp_unrgstr( Obj, Type, Zone, &addr ) < 0 ) {
83         fprintf( stderr, "Can't unregister %s:%s@%s\n", Obj, Type,
84                 Zone ? Zone : "*" );
85         exit( 1 );
86     }
87 }