#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
+#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
fflush( stdout );
}
- if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
- perror( "ldap_open" );
+ if ( (ld = ldap_init( ldaphost, 0 )) == NULL ) {
+ perror( "ldap_init" );
return( NULL );
}
char **val;
char last;
+ ldbm_datum_init( data );
+
if ( verbose ) {
printf( "Generating new centroids for..." );
fflush( stdout );
/* for each value */
for ( j = 0; val[j] != NULL; j++ ) {
+
+ ldbm_datum_init( key );
+
/* normalize the value */
for ( s = val[j]; *s; s++ ) {
- if ( isascii( *s ) ) {
- *s = TOLOWER( *s );
- }
+ *s = TOLOWER( (unsigned char) *s );
last = *s;
}
if ( isascii( last ) && isdigit( last ) ) {
/* generate a word-based centroid */
} else {
- for ( w = strtok( val[j], WORD_BREAKS ); w != NULL;
- w = strtok( NULL, WORD_BREAKS ) ) {
+ char *lasts;
+ for ( w = ldap_pvt_strtok( val[j], WORD_BREAKS, &lasts );
+ w != NULL;
+ w = ldap_pvt_strtok( NULL, WORD_BREAKS, &lasts ) ) {
key.dptr = w;
key.dsize = strlen( key.dptr ) + 1;
(void) ldbm_store( ldbm[i], key, data, LDBM_INSERT );
fflush( stdout );
}
+ ldbm_datum_init( okey );
+ ldbm_datum_init( nkey );
+ ldbm_datum_init( olast );
+ ldbm_datum_init( nlast );
+ ldbm_datum_init( lastkey );
+ ldbm_datum_init( key );
+ ldbm_datum_init( data );
+
if ( (mods = (LDAPMod **) malloc( sizeof(LDAPMod *) * 4 )) == NULL ||
(mods[0] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
(mods[1] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
fflush( stdout );
}
+ ldbm_datum_init( key );
+ ldbm_datum_init( lastkey );
+
if ( (mods = (LDAPMod **) malloc( sizeof(LDAPMod *) * 3 )) == NULL ||
(mods[0] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
(mods[1] = (LDAPMod *) malloc( sizeof(LDAPMod) )) == NULL ||
free( ldapbase );
ldapbase = strdup( buf );
- if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
- perror( "ldap_open" );
+ if ( (ld = ldap_init( ldaphost, 0 )) == NULL ) {
+ perror( "ldap_init" );
return( NULL );
}
char *s
)
{
- int n;
-
if ( *a == NULL ) {
*a = (char **) malloc( (BUFSIZ + 1) * sizeof(char *) );
*cur = 0;