]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/BsdSocketLib/gethostbyht.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / BsdSocketLib / gethostbyht.c
diff --git a/StdLib/BsdSocketLib/gethostbyht.c b/StdLib/BsdSocketLib/gethostbyht.c
deleted file mode 100644 (file)
index ac31f8c..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*-\r
- * Copyright (c) 1985, 1988, 1993\r
- *     The Regents of the University of California.  All rights reserved.\r
- *\r
- * Portions copyright (c) 1999, 2000\r
- * Intel Corporation.\r
- * All rights reserved.\r
- * \r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * \r
- * 1. Redistributions of source code must retain the above copyright\r
- *    notice, this list of conditions and the following disclaimer.\r
- * \r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the\r
- *    documentation and/or other materials provided with the distribution.\r
- * \r
- * 3. All advertising materials mentioning features or use of this software\r
- *    must display the following acknowledgement:\r
- * \r
- *    This product includes software developed by the University of\r
- *    California, Berkeley, Intel Corporation, and its contributors.\r
- * \r
- * 4. Neither the name of University, Intel Corporation, or their respective\r
- *    contributors may be used to endorse or promote products derived from\r
- *    this software without specific prior written permission.\r
- * \r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION AND\r
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS,\r
- * INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.\r
- *\r
- * Permission to use, copy, modify, and distribute this software for any\r
- * purpose with or without fee is hereby granted, provided that the above\r
- * copyright notice and this permission notice appear in all copies, and that\r
- * the name of Digital Equipment Corporation not be used in advertising or\r
- * publicity pertaining to distribution of the document or software without\r
- * specific, written prior permission.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL\r
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT\r
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\r
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR\r
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\r
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
- * SOFTWARE.\r
- * -\r
- * --Copyright--\r
- */\r
-\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-static char sccsid[] = "@(#)gethostnamadr.c    8.1 (Berkeley) 6/4/93";\r
-static char rcsid[] = "$Id: gethostbyht.c,v 1.1.1.1 2003/11/19 01:51:27 kyu3 Exp $";\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#include <sys/param.h>\r
-#include <sys/socket.h>\r
-#include <netinet/in.h>\r
-#include <arpa/inet.h>\r
-#include <netdb.h>\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-#include <errno.h>\r
-#include <string.h>\r
-#include <arpa/nameser.h>      /* XXX */\r
-#include <resolv.h>            /* XXX */\r
-#include "Socklib_internals.h"\r
-\r
-#define        MAXALIASES      35\r
-\r
-static struct hostent host;\r
-static char *host_aliases[MAXALIASES];\r
-static char hostbuf[BUFSIZ+1];\r
-static FILE *hostf = NULL;\r
-static u_char host_addr[16];   /* IPv4 or IPv6 */\r
-static char *h_addr_ptrs[2];\r
-static int stayopen = 0;\r
-\r
-void\r
-_sethosthtent(int f)\r
-{\r
-       if (!hostf)\r
-               hostf = fopen(_PATH_HOSTS, "r" );\r
-       else\r
-               rewind(hostf);\r
-       stayopen = f;\r
-}\r
-\r
-void\r
-_endhosthtent()\r
-{\r
-       if (hostf && !stayopen) {\r
-               (void) fclose(hostf);\r
-               hostf = NULL;\r
-       }\r
-}\r
-\r
-struct hostent *\r
-gethostent()\r
-{\r
-       char *p;\r
-       register char *cp, **q;\r
-       int af, len;\r
-\r
-       if (!hostf && ( NULL == (hostf = fopen(_PATH_HOSTS, "r" )))) {\r
-               h_errno = NETDB_INTERNAL;\r
-               return (NULL);\r
-       }\r
- again:\r
-       if ( NULL == (p = fgets(hostbuf, sizeof hostbuf, hostf))) {\r
-               h_errno = HOST_NOT_FOUND;\r
-               return (NULL);\r
-       }\r
-       if (*p == '#')\r
-               goto again;\r
-       if ( NULL == (cp = strpbrk(p, "#\n")))\r
-               goto again;\r
-       *cp = '\0';\r
-       if ( NULL == (cp = strpbrk(p, " \t")))\r
-               goto again;\r
-       *cp++ = '\0';\r
-       if (inet_pton(AF_INET6, p, host_addr) > 0) {\r
-               af = AF_INET6;\r
-               len = IN6ADDRSZ;\r
-       } else if (inet_pton(AF_INET, p, host_addr) > 0) {\r
-               if (_res.options & RES_USE_INET6) {\r
-                       _map_v4v6_address((char*)host_addr, (char*)host_addr);\r
-                       af = AF_INET6;\r
-                       len = IN6ADDRSZ;\r
-               } else {\r
-                       af = AF_INET;\r
-                       len = INADDRSZ;\r
-               }\r
-       } else {\r
-               goto again;\r
-       }\r
-       h_addr_ptrs[0] = (char *)host_addr;\r
-       h_addr_ptrs[1] = NULL;\r
-       host.h_addr_list = h_addr_ptrs;\r
-       host.h_length = len;\r
-       host.h_addrtype = af;\r
-       while (*cp == ' ' || *cp == '\t')\r
-               cp++;\r
-       host.h_name = cp;\r
-       q = host.h_aliases = host_aliases;\r
-       if ((cp = strpbrk(cp, " \t\r")) != NULL)\r
-               *cp++ = '\0';\r
-       while (cp && *cp) {\r
-               if (*cp == ' ' || *cp == '\t') {\r
-                       cp++;\r
-                       continue;\r
-               }\r
-               if (q < &host_aliases[MAXALIASES - 1])\r
-                       *q++ = cp;\r
-               if ((cp = strpbrk(cp, " \t\r")) != NULL)\r
-                       *cp++ = '\0';\r
-       }\r
-       *q = NULL;\r
-       h_errno = NETDB_SUCCESS;\r
-       return (&host);\r
-}\r
-\r
-struct hostent *\r
-_gethostbyhtname(const char *name, int af)\r
-{\r
-       register struct hostent *p;\r
-       register char **cp;\r
-       \r
-       sethostent(0);\r
-       while ((p = gethostent()) != NULL) {\r
-               if (p->h_addrtype != af)\r
-                       continue;\r
-               if (strcasecmp(p->h_name, name) == 0)\r
-                       break;\r
-               for (cp = p->h_aliases; *cp != 0; cp++)\r
-                       if (strcasecmp(*cp, name) == 0)\r
-                               goto found;\r
-       }\r
-found:\r
-       endhostent();\r
-       return (p);\r
-}\r
-\r
-struct hostent *\r
-_gethostbyhtaddr(const char *addr, int len, int af)\r
-{\r
-       register struct hostent *p;\r
-\r
-       sethostent(0);\r
-       while ((p = gethostent()) != NULL)\r
-               if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len))\r
-                       break;\r
-       endhostent();\r
-       return (p);\r
-}\r