From 6602f61c23c77a46ee99df4900718a5470a577af Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Mon, 28 May 2007 10:45:57 +0000 Subject: [PATCH] wfix + ffix --- man3/getnameinfo.3 | 47 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/man3/getnameinfo.3 b/man3/getnameinfo.3 index e6707c3fb..1f52e7128 100644 --- a/man3/getnameinfo.3 +++ b/man3/getnameinfo.3 @@ -181,52 +181,53 @@ In order to assist the programmer in choosing reasonable sizes for the supplied buffers, .I defines the constants -.RS +.in +0.5i .nf + # define NI_MAXHOST 1025 -.br # define NI_MAXSERV 32 .fi -.RE +.in +.PP The former is the constant MAXDNAME in recent versions of BIND's .I header file. The latter is a guess based on the services listed in the current Assigned Numbers RFC. .SH EXAMPLE -The following code tries to get the numeric hostname and service name, for -a given socket address. +The following code tries to get the numeric hostname and service name, +for a given socket address. Note that there is no hardcoded reference to a particular address family. -.RS +.in +0.5i .nf - struct sockaddr *sa; /* input */ - char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; +struct sockaddr *sa; /* input */ +char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; - if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, - sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) - printf("host=%s, serv=%s\en", hbuf, sbuf); +if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf, + sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) + printf("host=%s, serv=%s\en", hbuf, sbuf); .fi -.RE +.in The following version checks if the socket address has a reverse address mapping. -.RS -.fi - struct sockaddr *sa; /* input */ - char hbuf[NI_MAXHOST]; +.in +0.5i +.nf +struct sockaddr *sa; /* input */ +char hbuf[NI_MAXHOST]; - if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), - NULL, 0, NI_NAMEREQD)) - printf("could not resolve hostname"); - else - printf("host=%s\en", hbuf); +if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), + NULL, 0, NI_NAMEREQD)) + printf("could not resolve hostname"); +else + printf("host=%s\en", hbuf); .fi -.RE +.in .PP -An example program use +An example program using .BR getnameinfo () can be found in .BR getaddrinfo (3).