#include <sys/un.h>
#include <netinet/in.h>
-#if !defined(__minix)
#include <netatalk/at.h>
#include <net/if_dl.h>
-#endif /* !defined(__minix) */
#include <stdio.h>
#include <string.h>
#include <util.h>
#include <netdb.h>
-#if !defined(__minix)
static int
debug_at(char *str, size_t len, const struct sockaddr_at *sat)
{
s[0x0], s[0x1], s[0x2], s[0x3], s[0x4], s[0x5],
s[0x6], s[0x7], s[0x8], s[0x9], s[0xa], s[0xb]);
}
-#endif /* !defined(__minix) */
int
sockaddr_snprintf(char * const sbuf, const size_t len, const char * const fmt,
const struct sockaddr * const sa)
{
const void *a = NULL;
-#if !defined(__minix)
char abuf[1024], nbuf[1024], *addr = NULL, *w = NULL;
-#else
- char abuf[1024], nbuf[1024], *addr = NULL;
-#endif /* !defined(__minix) */
char Abuf[1024], pbuf[32], *name = NULL, *port = NULL;
char *ebuf = &sbuf[len - 1], *buf = sbuf;
const char *ptr, *s;
int p = -1;
-#if !defined(__minix)
const struct sockaddr_at *sat = NULL;
-#endif /* !defined(__minix) */
const struct sockaddr_in *sin4 = NULL;
-#if !defined(__minix)
const struct sockaddr_in6 *sin6 = NULL;
const struct sockaddr_un *sun = NULL;
const struct sockaddr_dl *sdl = NULL;
-#endif /* !defined(__minix) */
int na = 1;
#define ADDC(c) do { if (buf < ebuf) *buf++ = c; else buf++; } \
switch (sa->sa_family) {
case AF_UNSPEC:
goto done;
-#if !defined(__minix)
case AF_APPLETALK:
sat = ((const struct sockaddr_at *)(const void *)sa);
p = ntohs(sat->sat_port);
sun = ((const struct sockaddr_un *)(const void *)sa);
(void)strlcpy(addr = abuf, sun->sun_path, sizeof(abuf));
break;
-#endif /* !defined(__minix) */
case AF_INET:
sin4 = ((const struct sockaddr_in *)(const void *)sa);
p = ntohs(sin4->sin_port);
a = &sin4->sin_addr;
break;
-#if !defined(__minix)
case AF_INET6:
sin6 = ((const struct sockaddr_in6 *)(const void *)sa);
p = ntohs(sin6->sin6_port);
addr = w;
}
break;
-#endif /* !defined(__minix) */
default:
errno = EAFNOSUPPORT;
return -1;
if (addr == abuf)
name = addr;
-#if !defined(__minix)
if (a && getnameinfo(sa, (socklen_t)sa->sa_len, addr = abuf,
-#else
- if (a && getnameinfo(sa, (socklen_t)len, addr = abuf,
-#endif /* !defined(__minix) */
(unsigned int)sizeof(abuf), NULL, 0,
NI_NUMERICHOST|NI_NUMERICSERV) != 0)
return -1;
ADDS(nbuf);
break;
case 'l':
-#if !defined(__minix)
(void)snprintf(nbuf, sizeof(nbuf), "%d", sa->sa_len);
-#else
- (void)snprintf(nbuf, sizeof(nbuf), "%zu", len);
-#endif /* !defined(__minix) */
ADDS(nbuf);
break;
case 'A':
else if (!a)
ADDNA();
else {
-#if !defined(__minix)
getnameinfo(sa, (socklen_t)sa->sa_len,
-#else
- getnameinfo(sa, (socklen_t)len,
-#endif /* !defined(__minix) */
name = Abuf,
(unsigned int)sizeof(nbuf), NULL, 0, 0);
ADDS(name);
else if (p == -1)
ADDNA();
else {
-#if !defined(__minix)
getnameinfo(sa, (socklen_t)sa->sa_len, NULL, 0,
-#else
- getnameinfo(sa, (socklen_t)len, NULL, 0,
-#endif /* !defined(__minix) */
port = pbuf,
(unsigned int)sizeof(pbuf), 0);
ADDS(port);
}
break;
-#if !defined(__minix)
case 'I':
if (sdl && addr != abuf) {
ADDS(abuf);
}
ADDS(nbuf);
break;
-#endif /* !defined(__minix) */
default:
ADDC('%');
if (na == 0)