/*
- * $Id: getzones.c,v 1.5 2001-07-31 19:49:02 srittau Exp $
+ * $Id: getzones.c,v 1.9 2009-10-14 01:38:28 didg Exp $
*/
#ifdef HAVE_CONFIG_H
#include <netatalk/at.h>
#include <atalk/atp.h>
#include <atalk/util.h>
+#include <atalk/unicode.h>
#include <atalk/zip.h>
-void print_zones(short n, char *buf);
+static void print_zones(short n, char *buf);
-void usage( s )
- char *s;
+static void usage( char *s)
{
fprintf( stderr, "usage:\t%s [-m | -l] [address]\n", s );
exit( 1 );
}
-int main( argc, argv )
- int argc;
- char *argv[];
+int main( int argc, char *argv[])
{
struct atp_handle *ah;
struct atp_block atpb;
}
-void print_zones( n, buf )
- short n; /* number of zones in this packet */
- char *buf; /* zone length/name pairs */
+/*
+ * n: number of zones in this packet
+ * buf: zone length/name pairs
+ */
+static void print_zones( short n, char *buf )
{
+ size_t zone_len;
+ char *zone;
+
for ( ; n--; buf += (*buf) + 1 ) {
- printf( "%.*s\n", *buf, buf+1 );
+
+ if ((size_t)(-1) == (zone_len = convert_string_allocate( CH_MAC,
+ CH_UNIX, buf+1, *buf, &zone)) ) {
+ zone_len = *buf;
+ if (( zone = strdup(buf+1)) == NULL ) {
+ perror( "strdup" );
+ exit( 1 );
+ }
+ }
+
+ printf( "%.*s\n", (int)zone_len, zone );
+
+ free(zone);
}
}