summaryrefslogtreecommitdiff
path: root/netware
diff options
context:
space:
mode:
authorAnantha Kesari H Y <hyanantha@php.net>2005-06-29 12:16:25 +0000
committerAnantha Kesari H Y <hyanantha@php.net>2005-06-29 12:16:25 +0000
commitc49718f601e947305fbcd9663da13b2842ceea86 (patch)
tree9bcde17614b49502e30c4617d8c97abbe3ee9a96 /netware
parentc8442648aaaff67b670817a29da49cc33fafa606 (diff)
downloadphp-git-c49718f601e947305fbcd9663da13b2842ceea86.tar.gz
Netware LibC has mktemp implementation
Diffstat (limited to 'netware')
-rw-r--r--netware/mktemp.c87
1 files changed, 0 insertions, 87 deletions
diff --git a/netware/mktemp.c b/netware/mktemp.c
deleted file mode 100644
index b6d8e92593..0000000000
--- a/netware/mktemp.c
+++ /dev/null
@@ -1,87 +0,0 @@
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-
-/* Based on standard ANSI C mktemp() for NetWare */
-char* mktemp(char* templateStr)
-{
- char* pXs = NULL;
- char numBuf[50] = {'\0'};
- int count = 0;
- char* pPid = NULL;
-
- char termChar = '\0';
- char letter = 'a';
- char letter1 = 'a';
-
- if (templateStr && (pXs = strstr(templateStr, "XXXXXX")))
- {
- /* Generate temp name */
- termChar = pXs[6];
- ltoa(NXThreadGetId(), numBuf, 16);
- numBuf[strlen(numBuf)-1] = '\0';
-
- /*
- Beware! thread IDs are 8 hex digits on NW 4.11 and only the
- lower digits seem to change, whereas on NW 5 they are in the
- range of < 1000 hex or 3 hex digits in length. So the following
- logic ensures we use the least significant portion of the number.\
- */
- if (strlen(numBuf) > 5)
- pPid = &numBuf[strlen(numBuf)-5];
- else
- pPid = numBuf;
-
- /*
- Temporary files, as the name suggests, are temporarily used and then
- cleaned up after usage. In the case of complex scripts, new temp files
- may be created before the old ones are deleted. So, we need to have
- a provision to create many temp files. It is found that provision for
- 26 files may not be enough in such cases. Hence the logic below.
-
- The logic below allows 26 files (like, pla00015.tmp through plz00015.tmp)
- plus 6x26=676 (like, plaa0015.tmp through plzz0015.tmp)
- */
- letter = 'a';
- do
- {
- sprintf(pXs, (char *)"%c%05.5s", letter, pPid);
- pXs[6] = termChar;
-
- if (access(templateStr, 0) != 0)
- return templateStr; /* File does not exist */
-
- letter++;
- } while (letter <= 'z');
-
- letter1 = 'a';
- do
- {
- letter = 'a';
-
- do
- {
- sprintf(pXs, (char *)"%c%c%04.5s", letter1, letter, pPid);
- pXs[6] = termChar;
-
- if (access(templateStr, 0) != 0)
- return templateStr; /* File does not exist */
-
- letter++;
- } while (letter <= 'z');
-
- letter1++;
- } while (letter1 <= 'z');
-
- errno = ENOENT;
- return NULL;
- }
- else
- {
- errno = EINVAL;
- return NULL;
- }
-}
-