From 0b5691f12264a6342ade8a026b5ab3355d9d651c Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 15 May 2003 01:18:45 +0000 Subject: [PATCH] cleanup previous commit; update header --- include/lutil.h | 4 +++- libraries/liblutil/utils.c | 16 +++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/lutil.h b/include/lutil.h index 4cba4df7e2..f0930e09c2 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -149,8 +149,10 @@ struct tm; /* use this macro to statically allocate buffer for lutil_gentime */ #define LDAP_LUTIL_GENTIME_BUFSIZE 22 +#define lutil_gentime(s,m,t) lutil_localtime((s),(m),(t),0) LDAP_LUTIL_F( size_t ) -lutil_gentime LDAP_P(( char *s, size_t max, const struct tm *tm )); +lutil_localtime LDAP_P(( char *s, size_t smax, const struct tm *tm, + long delta )); #ifndef HAVE_MKSTEMP LDAP_LUTIL_F( int ) diff --git a/libraries/liblutil/utils.c b/libraries/liblutil/utils.c index d12bac851c..ee0c25cd25 100644 --- a/libraries/liblutil/utils.c +++ b/libraries/liblutil/utils.c @@ -46,9 +46,9 @@ char* lutil_progname( const char* name, int argc, char *argv[] ) return progname; } +#if 0 size_t lutil_gentime( char *s, size_t smax, const struct tm *tm ) { -#if 0 size_t ret; #ifdef HAVE_EBCDIC /* We've been compiling in ASCII so far, but we want EBCDIC now since @@ -62,18 +62,16 @@ size_t lutil_gentime( char *s, size_t smax, const struct tm *tm ) __etoa( s ); #endif return ret; -#else - return lutil_localtime( s, smax, tm, 0 ); -#endif } +#endif size_t lutil_localtime( char *s, size_t smax, const struct tm *tm, long delta ) { size_t ret; char *p; - if ( smax < 20 ) { - return -1; + if ( smax < 16 ) { /* YYYYmmddHHMMSSZ */ + return 0; } #ifdef HAVE_EBCDIC @@ -83,12 +81,12 @@ size_t lutil_localtime( char *s, size_t smax, const struct tm *tm, long delta ) #pragma convlit(suspend) #endif ret = strftime( s, smax, "%Y%m%d%H%M%SZ", tm ); - if ( ret == 0 ) { + if ( delta == 0 || ret == 0 ) { return ret; } - if ( delta == 0 ) { - return ret; + if ( smax < 20 ) { /* YYYYmmddHHMMSS+HHMM */ + return 0; } p = s + 14; -- 2.39.5