]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Stdio/gettemp.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / LibC / Stdio / gettemp.c
diff --git a/StdLib/LibC/Stdio/gettemp.c b/StdLib/LibC/Stdio/gettemp.c
deleted file mode 100644 (file)
index 0773340..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/** @file\r
-  Internal function to generate temporary file name for tmpnam.\r
-\r
-  Copyright (c) 2010 - 2011, 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 that 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
-  Copyright (c) 1987, 1993\r
-   The Regents of the University of California.  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
-    1. Redistributions of source code must retain the above copyright\r
-       notice, this list of conditions and the following disclaimer.\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
-    3. Neither the name of the University nor the names of its contributors\r
-       may be used to endorse or promote products derived from this software\r
-       without specific prior written permission.\r
-\r
-  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
-  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
-  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
-  ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
-  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
-  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
-  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
-  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
-  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
-  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
-  SUCH DAMAGE.\r
-\r
-  mktemp.c  8.1 (Berkeley) 6/4/93\r
-  NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp\r
-**/\r
-#include  <LibConfig.h>\r
-\r
-#if HAVE_NBTOOL_CONFIG_H\r
-#include "nbtool_config.h"\r
-#endif\r
-\r
-#if !defined(HAVE_NBTOOL_CONFIG_H) || !defined(HAVE_MKSTEMP) || !defined(HAVE_MKDTEMP)\r
-\r
-#include <sys/EfiCdefs.h>\r
-\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-\r
-#include <assert.h>\r
-#include <ctype.h>\r
-#include <errno.h>\r
-#include <fcntl.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include  <unistd.h>\r
-\r
-#if HAVE_NBTOOL_CONFIG_H\r
-#define GETTEMP   gettemp\r
-#else\r
-#include "reentrant.h"\r
-#include "local.h"\r
-#define GETTEMP   __gettemp\r
-#endif\r
-\r
-int\r
-GETTEMP(\r
-  char *path,\r
-  int *doopen,\r
-  int domkdir\r
-  )\r
-{\r
-  char *start, *trv;\r
-  struct stat sbuf;\r
-\r
-  /* To guarantee multiple calls generate unique names even if\r
-     the file is not created. 676 different possibilities with 7\r
-     or more X's, 26 with 6 or less. */\r
-  static char xtra[] = "aa";\r
-  int xcnt = 0;\r
-\r
-  _DIAGASSERT(path != NULL);\r
-  /* doopen may be NULL */\r
-\r
-  /* Move to end of path and count trailing X's. */\r
-  for (trv = path; *trv; ++trv) {\r
-    if (*trv == 'X') {\r
-      xcnt++;\r
-    }\r
-    else {\r
-      xcnt = 0;\r
-    }\r
-  }\r
-\r
-  /* Use at least one from xtra.  Use 2 if more than 6 X's. */\r
-  if (*(trv - 1) == 'X')\r
-    *--trv = xtra[0];\r
-  if (xcnt > 6 && *(trv - 1) == 'X')\r
-    *--trv = xtra[1];\r
-\r
-  /* Set remaining X's to 0's. */\r
-  while (*--trv == 'X') {\r
-    *trv = '0';\r
-  }\r
-\r
-  /* update xtra for next call. */\r
-  if (xtra[0] != 'z')\r
-    xtra[0]++;\r
-  else {\r
-    xtra[0] = 'a';\r
-    if (xtra[1] != 'z')\r
-      xtra[1]++;\r
-    else\r
-      xtra[1] = 'a';\r
-  }\r
-\r
-  /*\r
-   * check the target directory; if you have six X's and it\r
-   * doesn't exist this runs for a *very* long time.\r
-   */\r
-  for (start = trv + 1;; --trv) {\r
-    if (trv <= path)\r
-      break;\r
-    if (*trv == '/') {\r
-      *trv = '\0';\r
-      if (stat(path, &sbuf))\r
-        return (0);\r
-      if (!S_ISDIR(sbuf.st_mode)) {\r
-        errno = ENOTDIR;\r
-        return (0);\r
-      }\r
-      *trv = '/';\r
-      break;\r
-    }\r
-  }\r
-\r
-  for (;;) {\r
-    if (doopen) {\r
-      if ((*doopen =\r
-          open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)\r
-        return (1);\r
-      if (errno != EEXIST)\r
-        return (0);\r
-    } else if (domkdir) {\r
-      if (mkdir(path, 0700) >= 0)\r
-        return (1);\r
-      if (errno != EEXIST)\r
-        return (0);\r
-    } else if (lstat(path, &sbuf))\r
-      return (errno == ENOENT ? 1 : 0);\r
-\r
-    /* tricky little algorithm for backward compatibility */\r
-    for (trv = start;;) {\r
-      if (!*trv)\r
-        return (0);\r
-      if (*trv == 'z') {\r
-        *trv++ = 'a';\r
-      }\r
-      else {\r
-        if (isdigit((unsigned char)*trv))\r
-          *trv = 'a';\r
-        else\r
-          ++*trv;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  /*NOTREACHED*/\r
-}\r
-\r
-#endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP || !HAVE_MKDTEMP */\r