File:  [MW Coherent from dump] / coherent / d / lib / libc / gen / tmpnam.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:37 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * Standard I/O Library.
 * Create a unique name for a temporary file ala SYS V.
 */

#include <stdio.h>

#ifdef	GEMDOS
#define	FSPATHSEP	"\\"
#ifndef	P_tmpdir
#define	P_tmpdir	"\\tmp"
#endif
#endif
#ifdef	DOS
#define	FSPATHSEP	"\\"
#ifndef	P_tmpdir
#define	P_tmpdir	"\\tmp"
#endif
#endif
#ifndef	FSPATHSEP
#define	FSPATHSEP	"/"
#ifndef	P_tmpdir
#define	P_tmpdir	"/tmp"
#endif
#endif
#ifndef	L_tmpnam
#define	L_tmpnam	64
#endif
#define	TEMPLATE	"tXXXXXX"

char	*
tmpnam(s)
register char	*s;
{
	char *name;
	static	char namebuf[L_tmpnam];
	extern	char *mktemp(), *strcpy(), *strcat();

	for (;;) {
		if (s == NULL)
			s = namebuf;
		strcpy(s, P_tmpdir);
		strcat(s, FSPATHSEP);
		strcat(s, TEMPLATE);
		name = mktemp(s);
		if (access(name, 0) == -1)
			break;
	}
	return (s);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.