1 /* RCS $Id: tempnam.c,v 1.1.1.1 2000-09-22 15:33:27 hr Exp $ 2 -- 3 -- SYNOPSIS 4 -- Fake tempnam function for the mac 5 -- 6 -- DESCRIPTION 7 -- Get a temporary file name. 8 -- 9 -- AUTHOR 10 -- Dennis Vadura, dvadura@dmake.wticorp.com 11 -- 12 -- 13 -- WWW 14 -- http://dmake.wticorp.com/ 15 -- 16 -- COPYRIGHT 17 -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved. 18 -- 19 -- This program is NOT free software; you can redistribute it and/or 20 -- modify it under the terms of the Software License Agreement Provided 21 -- in the file <distribution-root>/COPYING. 22 -- 23 -- LOG 24 -- Use cvs log to obtain detailed change logs. 25 */ 26 27 28 #include "extern.h" 29 #include <StdIO.h> 30 #include <String.h> 31 32 33 34 /* 35 * Try to open a temporary file in the given directory (if non-NULL) 36 * with the given prefix (if non-NULL). 37 * 38 * We ignore the directory argument. 39 */ 40 PUBLIC char * tempnam(char * pDir,char * pPrefix)41tempnam(char *pDir, char * pPrefix) 42 { 43 char *pName; 44 char *pFullName; 45 46 pName = tmpnam ((char *) NULL); 47 48 /* Assume that if the name returned by tmpnam is not being used, 49 the name with the prefix is also not being used. */ 50 pFullName = MALLOC (((pPrefix != NULL) ? strlen (pPrefix) : 0) + 51 strlen (pName) + 1, char); 52 53 /* Copy in the name if we successfully allocated space for it. */ 54 if (pFullName != NULL) { 55 if (pPrefix != NULL) { 56 strcpy (pFullName, pPrefix); 57 } else { 58 *pFullName = '\0'; 59 } /* if ... else */ 60 61 strcat (pFullName, pName); 62 } /* if */ 63 64 return (pFullName); 65 } /* PUBLIC char *tempnam () */ 66