3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include <ac/string.h>
11 #include <ac/unistd.h>
21 #include <ldap_defaults.h>
27 char* lutil_progname( const char* name, int argc, char *argv[] )
38 for (i=0; i<argc; i++) __etoa(argv[i]);
42 progname = strrchr ( argv[0], *LDAP_DIRSEP );
43 progname = progname ? &progname[1] : argv[0];
48 size_t lutil_gentime( char *s, size_t max, const struct tm *tm )
52 /* We've been compiling in ASCII so far, but we want EBCDIC now since
53 * strftime only understands EBCDIC input.
55 #pragma convlit(suspend)
57 ret = strftime( s, max, "%Y%m%d%H%M%SZ", tm );
59 #pragma convlit(resume)
65 /* strcopy is like strcpy except it returns a pointer to the trailing NUL of
66 * the result string. This allows fast construction of catenated strings
67 * without the overhead of strlen/strcat.
78 while ((*a++ = *b++)) ;
82 /* strncopy is like strcpy except it returns a pointer to the trailing NUL of
83 * the result string. This allows fast construction of catenated strings
84 * without the overhead of strlen/strcat.
93 if (!a || !b || n == 0)
96 while ((*a++ = *b++) && n-- > 0) ;
101 int mkstemp( char * template )
104 return open ( mktemp ( template ), O_RDWR|O_CREAT|O_EXCL, 0600 );