2 * $Id: nbprgstr.c,v 1.9 2009-10-29 11:35:58 didg Exp $
4 * Copyright (c) 1990,1993 Regents of The University of Michigan.
5 * All Rights Reserved. See COPYRIGHT.
10 #endif /* HAVE_CONFIG_H */
15 #include <sys/types.h>
16 #include <sys/param.h>
18 #include <netatalk/endian.h>
19 #include <netatalk/at.h>
20 #include <atalk/netddp.h>
21 #include <atalk/nbp.h>
22 #include <atalk/util.h>
23 #include <atalk/unicode.h>
25 static void Usage(char *av0)
29 if (( p = strrchr( av0, '/' )) == NULL ) {
35 fprintf( stderr, "Usage: %s [ -A address ] [-m Mac charset] [ -p port] obj:type@zone\n", p );
39 int main(int ac, char **av)
41 struct sockaddr_at addr;
42 struct at_addr ataddr;
43 char *Obj = NULL, *Type = NULL, *Zone = NULL;
44 char *convname = NULL;
46 charset_t chMac = CH_MAC;
51 memset(&ataddr, 0, sizeof(ataddr));
52 while (( c = getopt( ac, av, "p:A:m:" )) != EOF ) {
55 if (!atalk_aton(optarg, &ataddr)) {
56 fprintf(stderr, "Bad address.\n");
62 if ((charset_t)-1 == (chMac = add_charset(optarg)) ) {
63 fprintf(stderr, "Invalid Mac charset.\n");
69 port = atoi( optarg );
77 if ( ac - optind != 1 ) {
81 /* Convert the name */
82 if ((size_t)(-1) == convert_string_allocate(CH_UNIX, chMac,
83 av[optind], -1, &convname))
84 convname = av[optind];
87 * Get the name. If Type or Obj aren't specified, error.
89 if ( nbp_name( convname, &Obj, &Type, &Zone ) || !Obj || !Type ) {
93 memset(&addr, 0, sizeof(addr));
94 memcpy(&addr.sat_addr, &ataddr, sizeof(addr.sat_addr));
95 if ((s = netddp_open(&addr, NULL)) < 0)
102 if ( nbp_rgstr( &addr, Obj, Type, Zone ) < 0 ) {
103 perror( "nbp_rgstr" );
104 fprintf( stderr, "Can't register %s:%s@%s\n", Obj, Type,