From: Anantha Kesari H Y Date: Wed, 29 Jun 2005 12:16:25 +0000 (+0000) Subject: Netware LibC has mktemp implementation X-Git-Tag: php-5.1.0b3~264 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c49718f601e947305fbcd9663da13b2842ceea86;p=php Netware LibC has mktemp implementation --- 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 -#include -#include - - -/* 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; - } -} -