From 218f012ba9c18cf5be4a715e18b81e638575b9e3 Mon Sep 17 00:00:00 2001 From: roland Date: Thu, 28 Jul 1994 21:52:58 +0000 Subject: [PATCH] Incorporated from BIND-4.9.3-BETA9. --- inet/netdb.h | 33 +++++++++---------- resolv/herror.c | 17 ++++++---- resolv/nsap_addr.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 23 deletions(-) create mode 100644 resolv/nsap_addr.c diff --git a/inet/netdb.h b/inet/netdb.h index 98490fc5da..e39081c359 100644 --- a/inet/netdb.h +++ b/inet/netdb.h @@ -1,13 +1,8 @@ /* - * @(#)netdb.h 5.15 (Berkeley) 4/3/91 - * $Id$ - */ - -/* - * ++Copyright++ 1980, 1983, 1988 + * ++Copyright++ 1980, 1983, 1988, 1993 * - - * Copyright (c) 1980, 1983, 1988 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1980, 1983, 1988, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -58,14 +53,17 @@ * --Copyright-- */ +/* + * @(#)netdb.h 8.1 (Berkeley) 6/2/93 + * $Id$ + */ + #ifndef _NETDB_H_ #define _NETDB_H_ #include #if (!defined(BSD)) || (BSD < 199306) # include -#else -# include #endif #include @@ -91,13 +89,13 @@ struct hostent { /* * Assumption here is that a network number - * fits in 32 bits -- probably a poor one. + * fits in an unsigned long -- probably a poor one. */ struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ - u_int32_t n_net; /* network # */ + unsigned long n_net; /* network # */ }; struct servent { @@ -132,8 +130,12 @@ void endservent __P((void)); struct hostent *gethostbyaddr __P((const char *, int, int)); struct hostent *gethostbyname __P((const char *)); struct hostent *gethostent __P((void)); -struct netent *getnetbyaddr __P((int32_t, int)); /* u_int32_t? */ +struct netent *getnetbyaddr __P((long, int)); /* u_long? */ +#ifdef sun +struct netent *getnetbyname __P((char *)); +#else struct netent *getnetbyname __P((const char *)); +#endif struct netent *getnetent __P((void)); struct protoent *getprotobyname __P((const char *)); struct protoent *getprotobynumber __P((int)); @@ -142,7 +144,7 @@ struct servent *getservbyname __P((const char *, const char *)); struct servent *getservbyport __P((int, const char *)); struct servent *getservent __P((void)); void herror __P((const char *)); -char * hstrerror __P((int)); +char *hstrerror __P((int)); void sethostent __P((int)); /* void sethostfile __P((const char *)); */ void setnetent __P((int)); @@ -150,7 +152,4 @@ void setprotoent __P((int)); void setservent __P((int)); __END_DECLS -/* Get `struct rpcent' and the definition for reading /etc/rpc. */ -#include - #endif /* !_NETDB_H_ */ diff --git a/resolv/herror.c b/resolv/herror.c index 236824e9ac..759ff7b65e 100644 --- a/resolv/herror.c +++ b/resolv/herror.c @@ -1,8 +1,8 @@ /* - * ++Copyright++ 1987 + * ++Copyright++ 1987, 1993 * - - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -54,14 +54,19 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)herror.c 6.6 (Berkeley) 2/24/91"; +static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; static char rcsid[] = "$Id$"; #endif /* LIBC_SCCS and not lint */ -#include +#include #include #include -#include "../conf/portability.h" +#if defined(BSD) && (BSD >= 199103) +# include +# include +#else +# include "../conf/portability.h" +#endif char *h_errlist[] = { "Error 0", diff --git a/resolv/nsap_addr.c b/resolv/nsap_addr.c new file mode 100644 index 0000000000..ea1850132a --- /dev/null +++ b/resolv/nsap_addr.c @@ -0,0 +1,97 @@ +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$Id$"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include + +#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_char *start = binary; + 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); +} -- 2.11.0