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