ngspice/src/misc/mktemp.c

43 lines
660 B
C
Raw Normal View History

2000-04-27 22:03:57 +02:00
/**********
Copyright 1990 Regents of the University of California. All rights reserved.
**********/
/*
* A more portable version of the standard "mktemp( )" function
*
* FIXME: remove smktemp() and adjust all callers to use tmpfile(3).
*/
#include "ngspice/ngspice.h"
2000-04-27 22:03:57 +02:00
#include "mktemp.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
2001-02-11 01:47:21 +01:00
2000-04-27 22:03:57 +02:00
#ifndef TEMPFORMAT
#define TEMPFORMAT "temp%s%d"
#endif
char *
smktemp(char *id)
{
char rbuf[513];
char *nbuf;
int num;
num = getpid( );
if (!id)
id = "sp";
sprintf(rbuf, TEMPFORMAT, id, num);
nbuf = TMALLOC(char, strlen(rbuf) + 1);
2000-04-27 22:03:57 +02:00
strcpy(nbuf, rbuf);
return nbuf;
}