/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
LDAP *ld, struct sockaddr *sap ));
static int cldap_result LDAP_P((
LDAP *ld, int msgid, LDAPMessage **res,
LDAP *ld, struct sockaddr *sap ));
static int cldap_result LDAP_P((
LDAP *ld, int msgid, LDAPMessage **res,
static int cldap_parsemsg LDAP_P((
LDAP *ld, int msgid, BerElement *ber,
static int cldap_parsemsg LDAP_P((
LDAP *ld, int msgid, BerElement *ber,
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
ld->ld_cldapaddrs = NULL;
if (ber_pvt_sb_set_io( &(ld->ld_sb), &ber_pvt_sb_io_udp, NULL )<0) {
ld->ld_cldapaddrs = NULL;
if (ber_pvt_sb_set_io( &(ld->ld_sb), &ber_pvt_sb_io_udp, NULL )<0) {
for ( ; host != NULL; host = p ) {
if (( p = strchr( host, ' ' )) != NULL ) {
for (*p++ = '\0'; *p == ' '; p++) {
for ( ; host != NULL; host = p ) {
if (( p = strchr( host, ' ' )) != NULL ) {
for (*p++ = '\0'; *p == ' '; p++) {
(char *)hp->h_addr_list[ i ],
sizeof(sock.sin_addr.s_addr));
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
(char *)hp->h_addr_list[ i ],
sizeof(sock.sin_addr.s_addr));
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
} else {
sock.sin_addr.s_addr = address;
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
} else {
sock.sin_addr.s_addr = address;
if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
if ( ld->ld_cldapaddrs == NULL
|| ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
) {
if ( ld->ld_cldapaddrs == NULL
|| ( ld->ld_defconn = ldap_new_connection( ld, NULL, 1,0,0 )) == NULL
) {
-cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
- int attrsonly, LDAPMessage **res, char *logdn )
+cldap_search_s( LDAP *ld,
+ LDAP_CONST char *base,
+ int scope,
+ LDAP_CONST char *filter,
+ char **attrs,
+ int attrsonly,
+ LDAPMessage **res,
+ char *logdn )
- if ( ld->ld_cldapnaddr == 0 ) {
- addrs = (struct sockaddr **)malloc( sizeof(struct sockaddr *));
- } else {
- addrs = (struct sockaddr **)realloc( ld->ld_cldapaddrs,
+ addrs = (struct sockaddr **)LDAP_REALLOC( ld->ld_cldapaddrs,
static int
cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
static int
cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
logdn = NULL;
if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
logdn = NULL;
if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
ret = LDAP_DECODING_ERROR;
Debug( LDAP_DEBUG_TRACE,
"cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
ret, 0, 0 );
} else if ( id != msgid ) {
ret = LDAP_DECODING_ERROR;
Debug( LDAP_DEBUG_TRACE,
"cldap_result: ber_scanf returned LBER_ERROR (%d)\n",
ret, 0, 0 );
} else if ( id != msgid ) {
}
}
ret = cldap_parsemsg( ld, msgid, &ber, res, base );
}
}
ret = cldap_parsemsg( ld, msgid, &ber, res, base );
Debug( LDAP_DEBUG_TRACE,
"cldap_result got result (%d)\n", ret, 0, 0 );
}
if ( logdn != NULL ) {
Debug( LDAP_DEBUG_TRACE,
"cldap_result got result (%d)\n", ret, 0, 0 );
}
if ( logdn != NULL ) {
static int
cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
static int
cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
char *dn, *p, *cookie;
LDAPMessage *chain, *prev, *ldm;
struct berval *bv;
rc = LDAP_DECODING_ERROR; /* pessimistic */
char *dn, *p, *cookie;
LDAPMessage *chain, *prev, *ldm;
struct berval *bv;
rc = LDAP_DECODING_ERROR; /* pessimistic */
baselen = ( base == NULL ) ? 0 : strlen( base );
bv = NULL;
for ( tag = ber_first_element( ber, &len, &cookie );
tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
tag = ber_next_element( ber, &len, cookie )) {
baselen = ( base == NULL ) ? 0 : strlen( base );
bv = NULL;
for ( tag = ber_first_element( ber, &len, &cookie );
tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
tag = ber_next_element( ber, &len, cookie )) {
- if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val,
- bv->bv_len ) == -1 ) {
+ if ( ber_printf( ldm->lm_ber, "tO", tag, bv ) == -1 ) {
- if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) {
+ if ( ber_scanf( ber, "{aO" /*}*/, &dn, &bv ) == LBER_ERROR ) {
break; /* return w/error */
}
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
break; /* return w/error */
}
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg entry %s\n", dn, 0, 0 );
break; /* return w/error */
}
strcpy( p, dn );
strcpy( p + slen - 1, base );
break; /* return w/error */
}
strcpy( p, dn );
strcpy( p + slen - 1, base );
- fprintf( stderr, "cldap_parsemsg add message id %d type %d:\n",
- ldm->lm_msgid, ldm->lm_msgtype );
+ fprintf( stderr, "cldap_parsemsg add message id %ld type %ld:\n",
+ (long) ldm->lm_msgid, (long) ldm->lm_msgtype );
ber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 );
}
#endif /* LDAP_DEBUG */
ber_log_dump( LDAP_DEBUG_BER, ldap_debug, ldm->lm_ber, 1 );
}
#endif /* LDAP_DEBUG */