2 * $Id: nbprgstr.c,v 1.5 2005-04-28 20:49:20 bfernhomberg 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>
30 if (( p = strrchr( av0, '/' )) == 0 ) {
36 fprintf( stderr, "Usage: %s [ -A address ] [-m Mac charset] [ -p port] obj:type@zone\n", p );
44 struct sockaddr_at addr;
45 struct at_addr ataddr;
46 char *Obj = 0, *Type = 0, *Zone = 0;
49 charset_t chMac = CH_MAC;
54 memset(&ataddr, 0, sizeof(ataddr));
55 while (( c = getopt( ac, av, "p:A:m:" )) != EOF ) {
58 if (!atalk_aton(optarg, &ataddr)) {
59 fprintf(stderr, "Bad address.\n");
65 if ((charset_t)-1 == (chMac = add_charset(optarg)) ) {
66 fprintf(stderr, "Invalid Mac charset.\n");
72 port = atoi( optarg );
80 if ( ac - optind != 1 ) {
84 /* Convert the name */
85 if ((size_t)(-1) == convert_string_allocate(CH_UNIX, chMac,
86 av[optind], strlen(av[optind]), &convname))
87 convname = av[optind];
90 * Get the name. If Type or Obj aren't specified, error.
92 if ( nbp_name( convname, &Obj, &Type, &Zone ) || !Obj || !Type ) {
96 memset(&addr, 0, sizeof(addr));
97 memcpy(&addr.sat_addr, &ataddr, sizeof(addr.sat_addr));
98 if ((s = netddp_open(&addr, NULL)) < 0)
102 addr.sat_port = port;
105 if ( nbp_rgstr( &addr, Obj, Type, Zone ) < 0 ) {
106 perror( "nbp_rgstr" );
107 fprintf( stderr, "Can't register %s:%s@%s\n", Obj, Type,