2 * $Id: nbpunrgstr.c,v 1.8 2009-10-14 01:38:28 didg Exp $
4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
7 * Permission to use, copy, modify, and distribute this software and
8 * its documentation for any purpose and without fee is hereby granted,
9 * provided that the above copyright notice appears in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation, and that the name of The University
12 * of Michigan not be used in advertising or publicity pertaining to
13 * distribution of the software without specific, written prior
14 * permission. This software is supplied as is without expressed or
15 * implied warranties of any kind.
17 * Research Systems Unix Group
18 * The University of Michigan
20 * 535 W. William Street
23 * netatalk@itd.umich.edu
28 #endif /* HAVE_CONFIG_H */
30 #include <sys/types.h>
36 #endif /* HAVE_UNISTD_H */
37 #include <netatalk/endian.h>
38 #include <netatalk/at.h>
39 #include <atalk/util.h>
40 #include <atalk/nbp.h>
42 #include <atalk/unicode.h>
44 static void Usage(char *av0)
48 if (( p = strrchr( av0, '/' )) == 0 ) {
54 fprintf( stderr, "Usage: %s [ -A address ] [ -m Mac charset] obj:type@zone\n", p );
58 int main(int ac, char **av)
60 char *Obj = 0, *Type = 0, *Zone = 0;
64 charset_t chMac = CH_MAC;
69 memset(&addr, 0, sizeof(addr));
70 while ((c = getopt(ac, av, "A:m:")) != EOF) {
73 if (!atalk_aton(optarg, &addr)) {
74 fprintf(stderr, "Bad address.\n");
79 if ((charset_t)-1 == (chMac = add_charset(optarg)) ) {
80 fprintf(stderr, "Invalid Mac charset.\n");
91 if (ac - optind != 1) {
95 /* Convert the name */
96 if ((size_t)(-1) == convert_string_allocate(CH_UNIX, chMac,
97 av[optind], strlen(av[optind]), &convname))
98 convname = av[optind];
101 * Get the name. If Type or Obj aren't specified, error.
103 if ( nbp_name( convname, &Obj, &Type, &Zone ) || !Obj || !Type ) {
107 if ( nbp_unrgstr( Obj, Type, Zone, &addr ) < 0 ) {
108 fprintf( stderr, "Can't unregister %s:%s@%s\n", Obj, Type,