/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* Portions
#include <stdio.h>
#include <ac/time.h>
+#include <lutil.h>
+
size_t
lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod)
{
ltm = gmtime( &t );
n = snprintf( buf, len, "%4d%02d%02d%02d:%02d:%02dZ#0x%04x#%d#%04x",
- ltm->tm_year + 1900, ltm->tm_mon, ltm->tm_mday, ltm->tm_hour,
+ ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour,
ltm->tm_min, ltm->tm_sec, op, replica, mod );
- return ( n < len ) ? n : 0;
+ if( n < 0 ) return 0;
+ return ( (size_t) n < len ) ? n : 0;
}
#ifdef TEST
int
main(int argc, char **argv)
{
- char buf[256];
+ char buf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
if ( ! lutil_csnstr( buf, (size_t) 10, 0, 0 ) ) {
fprintf(stderr, "failed lutil_csnstr\n");