home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 3
/
hamradioversion3.0examsandprograms1992.iso
/
packet
/
n17jsrc
/
mkname.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-31
|
2KB
|
69 lines
/* routines to override the standard Borland library routines */
/* PA0GRI , N1BEE , aparent origin PE1CHL */
/* Compile into _TEXT segment with -zC_TEXT */
#include <stdio.h>
#include <string.h>
#include <io.h>
#include "global.h"
#ifdef __TURBOC__
char *getnenv __ARGS((char *name)); /* In pc.c */
#ifdef __BORLANDC__
char far * near pascal __MKNAME __ARGS((char far *tmpname,unsigned int tmpnum));
#else
char *pascal __MKNAME __ARGS((char *tmpname,unsigned int tmpnum));
#endif
unsigned int _tmpnum = 0;
/* low-level routines used by tmpnam, fixed to use TMP environment variable */
#ifdef __BORLANDC__
char far * near pascal __MKNAME (tmpname,tmpnum) /* Turbo C++ acc. n1bee */
char far *tmpname;
#else
char *pascal __MKNAME (tmpname,tmpnum) /* The "standard compiler" */
char *tmpname;
#endif
unsigned int tmpnum;
{
char *tmpdir,*p;
static char staticname[80];
if (tmpname == NULL)
tmpname = staticname;
p = tmpdir = getnenv("TMP"); /* get tempdir name */
if (p[0] != '\0')
p += strlen(p) - 1; /* point to last character */
sprintf(tmpname,"%s%sTMP%u.$$$",tmpdir,
((*p != '/' && *p != '\\')? "/":""),tmpnum);
return tmpname;
}
/* new tmpnam function. calls above routine to generate the name, but */
/* is otherwise the same as the tmpnam() in the library. */
char *tmpnam (name)
char *name;
{
do
{
if (_tmpnum == 0xffff)
_tmpnum = 2;
else
++_tmpnum;
name = __MKNAME(name,_tmpnum);
}
while (access(name,0) != -1);
return name;
}
#endif