]> git.sur5r.net Git - openldap/blob - libraries/liblutil/utils.c
bd502ba0c046591146d8469c1c71e6b108afaf77
[openldap] / libraries / liblutil / utils.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 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 #include <ac/unistd.h>
12 #ifdef HAVE_IO_H
13 #include <io.h>
14 #endif
15 #ifdef HAVE_FCNTL_H
16 #include <fcntl.h>
17 #endif
18
19 #include <lber.h>
20 #include <lutil.h>
21 #include <ldap_defaults.h>
22
23 char* lutil_progname( const char* name, int argc, char *argv[] )
24 {
25         char *progname;
26
27         if(argc == 0) {
28                 return ber_strdup( name );
29         }
30
31         progname = strrchr ( argv[0], *LDAP_DIRSEP );
32         progname = ber_strdup( progname ? &progname[1] : argv[0] );
33
34         return progname;
35 }
36
37 #ifndef HAVE_MKSTEMP
38 int mkstemp( char * template )
39 {
40 #ifdef HAVE_MKTEMP
41         return open ( mktemp ( template ), O_RDWR|O_CREAT|O_EXCL, 0600 );
42 #else
43         return -1;
44 #endif
45 }
46 #endif