mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
3d61b63cc7
ADO's 95e. * inet/Makefile (routines): Removed inet_addr. * inet/inet_addr.c: Moved to resolv/ subdirectory. * resolv/Makefile (routines): Added inet_addr. * resolv/inet_addr.c: Incorporated from BIND 4.9.3-BETA24 release. * resolv/gethnamaddr.c: Likewise. * resolv/getnetbyaddr.c: Likewise. * resolv/getnetbyname.c: Likewise. * resolv/getnetent.c: Likewise. * resolv/getnetnamadr.c: Likewise. * resolv/herror.c: Likewise. * resolv/nsap_addr.c: Likewise. * resolv/res_comp.c: Likewise. * resolv/res_debug.c: Likewise. * resolv/res_init.c: Likewise. * resolv/res_mkquery.c: Likewise. * resolv/res_query.c: Likewise. * resolv/res_send.c: Likewise. * resolv/resolv.h: Likewise. * resolv/sethostent.c: Likewise. * resolv/arpa/nameser.h: Likewise. * inet/netdb.h: Incorporated from BIND 4.9.3-BETA24 release. [__GNU_LIBRARY__]: Include <rpc/netdb.h> instead of repeating its declarations (and doing so only #ifdef sun!). * posix/sys/types.h [__USE_BSD] (__BIT_TYPES_DEFINED__): New macro. [__USE_BSD] [__GNUC__] (int64_t, u_int64_t, register_t): New typedefs.
97 lines
1.6 KiB
C
97 lines
1.6 KiB
C
#if defined(LIBC_SCCS) && !defined(lint)
|
|
static char rcsid[] = "$Id$";
|
|
#endif /* LIBC_SCCS and not lint */
|
|
|
|
#include <sys/param.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/nameser.h>
|
|
#include <ctype.h>
|
|
#include <resolv.h>
|
|
|
|
#include "../conf/portability.h"
|
|
|
|
#if !defined(isxdigit) /* XXX - could be a function */
|
|
static int
|
|
isxdigit(c)
|
|
register int c;
|
|
{
|
|
return ((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'));
|
|
}
|
|
#endif
|
|
|
|
static char
|
|
xtob(c)
|
|
register int c;
|
|
{
|
|
return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
|
|
}
|
|
|
|
u_int
|
|
inet_nsap_addr(ascii, binary, maxlen)
|
|
const char *ascii;
|
|
u_char *binary;
|
|
int maxlen;
|
|
{
|
|
register u_char c, nib;
|
|
u_int len = 0;
|
|
|
|
while ((c = *ascii++) != '\0' && len < maxlen) {
|
|
if (c == '.' || c == '+' || c == '/')
|
|
continue;
|
|
if (!isascii(c))
|
|
return (0);
|
|
if (islower(c))
|
|
c = toupper(c);
|
|
if (isxdigit(c)) {
|
|
nib = xtob(c);
|
|
if (c = *ascii++) {
|
|
c = toupper(c);
|
|
if (isxdigit(c)) {
|
|
*binary++ = (nib << 4) | xtob(c);
|
|
len++;
|
|
} else
|
|
return (0);
|
|
}
|
|
else
|
|
return (0);
|
|
}
|
|
else
|
|
return (0);
|
|
}
|
|
return (len);
|
|
}
|
|
|
|
char *
|
|
inet_nsap_ntoa(binlen, binary, ascii)
|
|
int binlen;
|
|
register const u_char *binary;
|
|
register char *ascii;
|
|
{
|
|
register int nib;
|
|
int i;
|
|
static char tmpbuf[255*3];
|
|
char *start;
|
|
|
|
if (ascii)
|
|
start = ascii;
|
|
else {
|
|
ascii = tmpbuf;
|
|
start = tmpbuf;
|
|
}
|
|
|
|
if (binlen > 255)
|
|
binlen = 255;
|
|
|
|
for (i = 0; i < binlen; i++) {
|
|
nib = *binary >> 4;
|
|
*ascii++ = nib + (nib < 10 ? '0' : '7');
|
|
nib = *binary++ & 0x0f;
|
|
*ascii++ = nib + (nib < 10 ? '0' : '7');
|
|
if (((i % 2) == 0 && (i + 1) < binlen))
|
|
*ascii++ = '.';
|
|
}
|
|
*ascii = '\0';
|
|
return (start);
|
|
}
|