]> git.sur5r.net Git - openldap/blob - libraries/liblutil/utils.c
8d5fe6b479c2976552bfb765e368117e6cd8dd13
[openldap] / libraries / liblutil / utils.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include <ac/stdlib.h>
10 #include <ac/string.h>
11 #ifdef HAVE_FCNTL_H
12 #include <fcntl.h>
13 #endif
14
15 #include <lber.h>
16 #include <lutil.h>
17 #include <ldap_defaults.h>
18
19 char* lutil_progname( const char* name, int argc, char *argv[] )
20 {
21         char *progname;
22
23         if(argc == 0) {
24                 return ber_strdup( name );
25         }
26
27         progname = strrchr ( argv[0], *LDAP_DIRSEP );
28         progname = ber_strdup( progname ? &progname[1] : argv[0] );
29
30         return progname;
31 }
32
33 #ifndef HAVE_MKSTEMP
34 int mkstemp( char * template )
35 {
36         return open ( mktemp ( template ), O_RDWR|O_CREAT|O_EXCL, 0600 );
37 }
38 #endif