openldap/libraries/liblutil/utils.c

47 lines
827 B
C
Raw Normal View History

/* $OpenLDAP$ */
/*
2002-01-05 05:17:25 +08:00
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/unistd.h>
2001-12-18 12:52:55 +08:00
#ifdef HAVE_IO_H
#include <io.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <lber.h>
#include <lutil.h>
#include <ldap_defaults.h>
char* lutil_progname( const char* name, int argc, char *argv[] )
{
char *progname;
if(argc == 0) {
2000-06-07 14:33:59 +08:00
return ber_strdup( name );
}
progname = strrchr ( argv[0], *LDAP_DIRSEP );
2000-06-07 14:33:59 +08:00
progname = ber_strdup( progname ? &progname[1] : argv[0] );
return progname;
}
2001-06-15 12:16:55 +08:00
#ifndef HAVE_MKSTEMP
int mkstemp( char * template )
{
#ifdef HAVE_MKTEMP
return open ( mktemp ( template ), O_RDWR|O_CREAT|O_EXCL, 0600 );
#else
2001-12-18 10:55:38 +08:00
return -1;
#endif
2001-06-15 12:16:55 +08:00
}
2001-10-11 12:01:45 +08:00
#endif