diff options
author | SVN Migration <svn@php.net> | 2003-02-27 17:43:39 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2003-02-27 17:43:39 +0000 |
commit | 078bcec0997ad0e07b720c43cc9e6d0e046a75ab (patch) | |
tree | 36cb0f6be2ef078fe3374de8c087b93ecf82f812 /netware/mktemp.c | |
parent | fd61f69077f6156ca71dde60ecfd9ed9765a02db (diff) | |
download | php-git-PHP-5.tar.gz |
This commit was manufactured by cvs2svn to create branch 'PHP_5'.PHP-5
Diffstat (limited to 'netware/mktemp.c')
-rw-r--r-- | netware/mktemp.c | 87 |
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; - } -} - |