sync master with lastest vba changes
[ooovba.git] / dmake / mac / tempnam.c
blob57a8994df963978dc746350899105e2331836387
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
13 -- WWW
14 -- http://dmake.wticorp.com/
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>/readme/license.txt.
23 -- LOG
24 -- Use cvs log to obtain detailed change logs.
28 #include "extern.h"
29 #include <StdIO.h>
30 #include <String.h>
35 * Try to open a temporary file in the given directory (if non-NULL)
36 * with the given prefix (if non-NULL).
38 * We ignore the directory argument.
40 PUBLIC char *
41 tempnam(char *pDir, char * pPrefix)
43 char *pName;
44 char *pFullName;
46 pName = tmpnam ((char *) NULL);
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);
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 */
61 strcat (pFullName, pName);
62 } /* if */
64 return (pFullName);
65 } /* PUBLIC char *tempnam () */