#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
-extern char *strdup (const char *);
#include <lber.h>
#include <ldap.h>
{
int idx;
char **rdns;
- BerElement *cookie;
register LDAPMessage *ep;
register char *ap;
printf(" Done clearing entry\n");
#endif
for (ep = ldap_first_entry(ld, s); ep != NULL; ep = ldap_next_entry(ld, ep)) {
+ BerElement *cookie = NULL;
#ifdef DEBUG
if (debug & D_PARSE)
printf(" Determining DN and name\n");
}
add_value(&(Entry.attrs[idx]), ep, ap);
}
+
+ if( cookie != NULL ) {
+ ber_free( cookie, 0 );
+ }
}
#ifdef DEBUG
if (debug & D_PARSE)
putchar('\n');
for (k = lead; k > 0; k--)
putchar(' ');
- while (isspace(*(cp + 1)))
+ while (isspace((unsigned char) cp[1]))
cp++;
}
else
printf(" Clearing entry \"%s\"\n", Entry.name);
#endif
if (Entry.DN != NULL)
- Free(Entry.DN);
+ ldap_memfree(Entry.DN);
if (Entry.name != NULL)
Free(Entry.name);
Entry.may_join = FALSE;
register int i;
char c, *cp, *url;
- for (cp = s; !isspace(*cp) && (*cp != '\0'); cp++)
+ for (cp = s; !isspace((unsigned char)*cp) && (*cp != '\0'); cp++)
;
c = *cp;
*cp = '\0';
url = strdup(s);
*cp = c;
if (*cp != '\0') {
- for (cp++; isspace(*cp); cp++)
+ for (cp++; isspace((unsigned char)*cp); cp++)
;
}
else
}
-#define GET2BYTENUM( p ) (( *p - '0' ) * 10 + ( *(p+1) - '0' ))
+#define GET2BYTENUM( p ) (( *(p) - '0' ) * 10 + ( *((p)+1) - '0' ))
static char *
time2text( char *ldtimestr, int dateonly )
struct tm t;
char *p, *timestr, zone, *fmterr = "badly formatted time";
time_t gmttime;
+ int ndigits;
- memset( (char *)&t, 0, sizeof( struct tm ));
- if ( strlen( ldtimestr ) < 13 ) {
- return( fmterr );
+ if (strlen( ldtimestr ) < 12 ) {
+ return( fmterr );
+ }
+
+ for ( ndigits=0; isdigit((unsigned char) ldtimestr[ndigits]); ndigits++) {
+ ; /* EMPTY */
}
- for ( p = ldtimestr; p - ldtimestr < 12; ++p ) {
- if ( !isdigit( *p )) {
+ if ( ndigits != 12 && ndigits != 14) {
return( fmterr );
}
- }
+
+ memset( (char *)&t, 0, sizeof( struct tm ));
p = ldtimestr;
+
+ if( ndigits == 14) {
+ /* came with a century */
+ /* POSIX says tm_year should be year - 1900 */
+ t.tm_year = 100 * GET2BYTENUM( p ) - 1900;
+ p += 2;
+ }
t.tm_year = GET2BYTENUM( p ); p += 2;
+
t.tm_mon = GET2BYTENUM( p ) - 1; p += 2;
t.tm_mday = GET2BYTENUM( p ); p += 2;
t.tm_hour = GET2BYTENUM( p ); p += 2;
timestr[ strlen( timestr ) - 1 ] = zone; /* replace trailing newline */
if ( dateonly ) {
- strcpy( timestr + 11, timestr + 20 );
+ SAFEMEMCPY( timestr + 11, timestr + 20, strlen( timestr + 20 ) + 1 );
}
- Free ( ldtimestr );
return( strdup( timestr ) );
}
#define dysize(y) \
(((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
-#define YEAR(y) ((y) >= 100 ? (y) : (y) + 1900)
+/*
+ * Y2K YEAR
+ */
+ /* per STDC & POSIX tm_year *should* be offset by 1900 */
+#define YEAR_POSIX(y) ((y) + 1900)
+
+ /*
+ * year is < 1900, year is offset by 1900
+ */
+#define YEAR_CAREFUL(y) ((y) < 1900 ? (y) + 1900 : (y))
+
+#define YEAR(y) YEAR_CAREFUL(y)
+
/* \f */