openldap/libraries/liblutil/tempnam.c
Kurt Zeilenga 5f20cf1ed5 Modify ldapsearch(1) significantly. Now handles LDAPv3 search
references, extended results, and extended partial results.  LDIF
extended to support these new features and reported version 2.
-L now limits output to LDIFv1 for compatibility reasons.  No
-L is now LDIFv2.  Old alternative form is no longer supported.

Use LDAP_TMPDIR (in ldap_config.h) instead of hardcoded /tmp
Use LDAP_FILE_URI_PREFIX (in ldap_config.h) instead of hardcoded
	file://tmp/
2000-06-25 00:35:17 +00:00

47 lines
703 B
C

/* $OpenLDAP$ */
#include "portable.h"
#ifndef HAVE_TEMPNAM
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include "lutil.h"
char *
(tempnam)( const char *dir, const char *pfx )
{
char *s;
if ( dir == NULL ) {
dir = LDAP_TMPDIR;
}
/*
* allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
*/
if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) {
return( NULL );
}
strcpy( s, dir );
strcat( s, "/" );
if ( pfx != NULL ) {
strcat( s, pfx );
}
strcat( s, "XXXXXX" );
mktemp( s );
if ( *s == '\0' ) {
free( s );
s = NULL;
}
return( s );
}
#endif /* TEMPNAM */