]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/BsdSocketLib/res_comp.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / BsdSocketLib / res_comp.c
diff --git a/StdLib/BsdSocketLib/res_comp.c b/StdLib/BsdSocketLib/res_comp.c
deleted file mode 100644 (file)
index 7c327fa..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/** @file\r
-  Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-/*\r
- * Copyright (c) 1985, 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
- */\r
-\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
-\r
-/*\r
- * Portions Copyright (c) 1996 by Internet Software Consortium.\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.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS\r
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE\r
- * CONSORTIUM 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
-\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-static char sccsid[] = "@(#)res_comp.c  8.1 (Berkeley) 6/4/93";\r
-static char orig_rcsid[] = "From: Id: res_comp.c,v 8.11 1997/05/21 19:31:04 halley Exp $";\r
-static char rcsid[] = "$Id: res_comp.c,v 1.1.1.1 2003/11/19 01:51:35 kyu3 Exp $";\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#include <sys/types.h>\r
-#include <sys/param.h>\r
-#include <netinet/in.h>\r
-#include <arpa/nameser.h>\r
-#include <ctype.h>\r
-#include <resolv.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <unistd.h>\r
-\r
-#define BIND_4_COMPAT\r
-\r
-/*\r
- * Expand compressed domain name 'comp_dn' to full domain name.\r
- * 'msg' is a pointer to the begining of the message,\r
- * 'eomorig' points to the first location after the message,\r
- * 'exp_dn' is a pointer to a buffer of size 'length' for the result.\r
- * Return size of compressed name or -1 if there was an error.\r
- */\r
-int\r
-dn_expand(const u_char *msg, const u_char *eom, const u_char *src,\r
-      char *dst, int dstsiz)\r
-{\r
-    int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);\r
-\r
-    if (n > 0 && dst[0] == '.')\r
-        dst[0] = '\0';\r
-    return (n);\r
-}\r
-\r
-/*\r
- * Pack domain name 'exp_dn' in presentation form into 'comp_dn'.\r
- * Return the size of the compressed name or -1.\r
- * 'length' is the size of the array pointed to by 'comp_dn'.\r
- */\r
-int\r
-dn_comp(const char *src, u_char *dst, int dstsiz,\r
-    u_char **dnptrs, u_char **lastdnptr)\r
-{\r
-    return (ns_name_compress(src, dst, (size_t)dstsiz,\r
-                 (const u_char **)dnptrs,\r
-                 (const u_char **)lastdnptr));\r
-}\r
-\r
-/*\r
- * Skip over a compressed domain name. Return the size or -1.\r
- */\r
-int\r
-dn_skipname(const u_char *ptr, const u_char *eom) {\r
-    const u_char *saveptr = ptr;\r
-\r
-    if (ns_name_skip(&ptr, eom) == -1)\r
-        return (-1);\r
-    return ((int)(ptr - saveptr));\r
-}\r
-\r
-/*\r
- * Verify that a domain name uses an acceptable character set.\r
- */\r
-\r
-/*\r
- * Note the conspicuous absence of ctype macros in these definitions.  On\r
- * non-ASCII hosts, we can't depend on string literals or ctype macros to\r
- * tell us anything about network-format data.  The rest of the BIND system\r
- * is not careful about this, but for some reason, we're doing it right here.\r
- */\r
-#define PERIOD 0x2e\r
-#define hyphenchar(c) ((c) == 0x2d)\r
-#define bslashchar(c) ((c) == 0x5c)\r
-#define periodchar(c) ((c) == PERIOD)\r
-#define asterchar(c) ((c) == 0x2a)\r
-#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \\r
-           || ((c) >= 0x61 && (c) <= 0x7a))\r
-#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)\r
-\r
-#define borderchar(c) (alphachar(c) || digitchar(c))\r
-#define middlechar(c) (borderchar(c) || hyphenchar(c))\r
-#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)\r
-\r
-int\r
-res_hnok(\r
-    const char *dn\r
-    )\r
-{\r
-    int pch = PERIOD, ch = *dn++;\r
-\r
-    while (ch != '\0') {\r
-        int nch = *dn++;\r
-\r
-        if (periodchar(ch)) {\r
-            (void)NULL;\r
-        } else if (periodchar(pch)) {\r
-            if (!borderchar(ch))\r
-                return (0);\r
-        } else if (periodchar(nch) || nch == '\0') {\r
-            if (!borderchar(ch))\r
-                return (0);\r
-        } else {\r
-            if (!middlechar(ch))\r
-                return (0);\r
-        }\r
-        pch = ch;\r
-        ch = nch;\r
-    }\r
-    return (1);\r
-}\r
-\r
-/*\r
- * hostname-like (A, MX, WKS) owners can have "*" as their first label\r
- * but must otherwise be as a host name.\r
- */\r
-int\r
-res_ownok(\r
-    const char *dn\r
-    )\r
-{\r
-    if (asterchar(dn[0])) {\r
-        if (periodchar(dn[1]))\r
-            return (res_hnok(dn+2));\r
-        if (dn[1] == '\0')\r
-            return (1);\r
-    }\r
-    return (res_hnok(dn));\r
-}\r
-\r
-/*\r
- * SOA RNAMEs and RP RNAMEs can have any printable character in their first\r
- * label, but the rest of the name has to look like a host name.\r
- */\r
-int\r
-res_mailok(\r
-    const char *dn\r
-    )\r
-{\r
-    int ch, escaped = 0;\r
-\r
-    /* "." is a valid missing representation */\r
-    if (*dn == '\0')\r
-        return (1);\r
-\r
-    /* otherwise <label>.<hostname> */\r
-    while ((ch = *dn++) != '\0') {\r
-        if (!domainchar(ch))\r
-            return (0);\r
-        if (!escaped && periodchar(ch))\r
-            break;\r
-        if (escaped)\r
-            escaped = 0;\r
-        else if (bslashchar(ch))\r
-            escaped = 1;\r
-    }\r
-    if (periodchar(ch))\r
-        return (res_hnok(dn));\r
-    return (0);\r
-}\r
-\r
-/*\r
- * This function is quite liberal, since RFC 1034's character sets are only\r
- * recommendations.\r
- */\r
-int\r
-res_dnok(\r
-    const char *dn\r
-    )\r
-{\r
-    int ch;\r
-\r
-    while ((ch = *dn++) != '\0')\r
-        if (!domainchar(ch))\r
-            return (0);\r
-    return (1);\r
-}\r
-\r
-#ifdef BIND_4_COMPAT\r
-/*\r
- * This module must export the following externally-visible symbols:\r
- *    ___putlong\r
- *    ___putshort\r
- *    __getlong\r
- *    __getshort\r
- * Note that one _ comes from C and the others come from us.\r
- */\r
-void __putlong(u_int32_t src, u_char *dst) { ns_put32(src, dst); }\r
-void __putshort(u_int16_t src, u_char *dst) { ns_put16(src, dst); }\r
-u_int32_t _getlong(const u_char *src) { return (ns_get32(src)); }\r
-u_int16_t _getshort(const u_char *src) { return (ns_get16(src)); }\r
-#endif /*BIND_4_COMPAT*/\r