]> git.sur5r.net Git - openldap/blob - servers/slapd/tempnam.c
SLAPD and tools compile and link!
[openldap] / servers / slapd / tempnam.c
1 #include "portable.h"
2
3 #ifndef HAVE_TEMPNAME
4
5 #include <ac/string.h>
6
7 char *tempnam( char *dir, char *pfx )
8 {
9     char        *s;
10
11     if ( dir == NULL ) {
12         dir = "/tmp";
13     }
14
15 /*
16  * allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
17  */
18     if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) {
19         return( NULL );
20     }
21
22     strcpy( s, dir );
23     strcat( s, "/" );
24     if ( pfx != NULL ) {
25         strcat( s, pfx );
26     }
27     strcat( s, "XXXXXX" );
28     mktemp( s );
29
30     if ( *s == '\0' ) {
31         free( s );
32         s = NULL;
33     }
34
35     return( s );
36 }
37
38 #endif /* nextstep */