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