Files
Digital-Research-Source-Code/CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/clib/mktemp.c
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

41 lines
1.1 KiB
C

/***********************************************************************
*
* m k t e m p F u n c t i o n
* -----------------------------
* Copyright 1982 by Digital Research Inc. All rights reserved.
*
* "mktemp" assumes it is called with a string ending in 6 X's.
* It will replace the last 6 chars with the process id
* and a letter (different on each invocation).
* REALLY "mktemp" replaces everything after the 1st x...
* this is a feature...
* Note that the process id does not change under CP/M,
* therefore the name itself will not be very unique...
*
* Calling sequence:
* string = mktemp(string)
* Where:
*
* string -> null terminated string with 6 x's
*
*************************************************************************/
#include "portab.h"
MLOCAL BYTE _mktchar = { 'A' };
BYTE * mktemp(template) /* CLEAR FUNCTION ***********/
REG BYTE *template;
{
REG BYTE *ss;
for( ss=template; *ss != 'x' && *ss != 'X'; ss++)
if(*ss == NULL)
return(template); /* resign */
if( _mktchar < 'A' || _mktchar >'Z' )
_mktchar = 'A';
sprintf(ss,"X%04.4d%c",getpid(),_mktchar);
_mktchar++;
return(template);
}