ns_addr(3) — Subroutines
NAME
ns_addr, ns_ntoa, ns_ntoa_r − Xerox NS address conversion routines
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <sys/types.h>
#include <netns/ns.h> struct ns_addr ns_addr(
char ∗cp);
char ∗ns_ntoa(
struct ns_addr ns);
int ns_ntoa_r(
struct ns_addr ns,
char ∗buf,
int buf_len);
PARAMETERS
cpPoints to a character string representing an XNS address.
nsSpecifies an XNS address.
bufPoints to the buffer that will contain the returned ASCII strings.
buf_lenSpecifies the size of the buffer buf. This must be at least 40 characters.
DESCRIPTION
The ns_addr() function interprets character strings representing Xerox NS addresses, and returns binary information suitable for use in functions. The ns_ntoa() function takes XNS addresses and returns ASCII strings representing the address in a notation in common use in the Xerox development environment:
<network number>.<host number>.<port number>
Trailing zero fields are suppressed, and each number is printed in hexadecimal, in a format suitable for input to the ns_addr() function. Any fields lacking superdecimal digits will have a trailing H appended.
Unfortunately, no universal standard exists for representing XNS addresses. An effort has been made to ensure that the ns_addr() function be compatible with most formats in common use.
The ns_addr() function first separates an address into one to three fields using a . (dot), a : (colon), or a # (number sign) single delimiter. Each field is then examined for byte separators (colon or period). If there are byte separators, each subfield separated is taken to be a small hexadecimal number, and the entire component is taken as a network-byte-ordered quantity to be zero extended in the high-network-order bytes.
Next, the field is inspected for dashes. If there are dashes, the field is assumed to be a number in decimal notation with dashes separating the millenia. Next, the field is assumed to be a number. It is interpreted as hexadecimal if there is a leading 0x (as in C), a trailing H (as in Mesa), or if there are any superdecimal digits present. It is interpreted as octal if there is a leading 0 (zero) and there are no superoctal digits. Otherwise, it is converted as a decimal number.
The ns_ntoa_r() function is a reentrant version of ns_ntoa(). Upon successful completion, the converted string is in the buffer pointed at by buf.
RETURN VALUES
The ns_ntoa_r() function returns a value of 0 (zero) for success or a value of -1 for failure.
ERRORS
If any of the following conditions occurs, ns_ntoa_r() sets errno to the corresponding value:
[EINVAL]The buffer pointed to by buf is invalid, or buf_len is less than 40 characters.
RELATED INFORMATION
Files: hosts(4), networks(4).