/********************************************************************** * Copyright (c) Digital Equipment Corporation 1984, 1985, 1986. * * All Rights Reserved. * * Reference "/usr/src/COPYRIGHT" for applicable restrictions. * **********************************************************************/ /* SCCSID: @(#)tmpfile.c 3.0 4/22/86 */ /* (System 5) 1.3 */ /*LINTLIBRARY*/ /* * tmpfile - return a pointer to an update file that can be * used for scratch. The file will automatically * go away if the program using it terminates. */ #include <stdio.h> extern FILE *fopen(); extern int unlink(); extern char *tmpnam(); extern void perror(); FILE * tmpfile() { char tfname[L_tmpnam]; register FILE *p; (void) tmpnam(tfname); if((p = fopen(tfname, "w+")) == NULL) return NULL; else (void) unlink(tfname); return(p); }