+/* $OpenLDAP$ */
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_DNS
#include <stdio.h>
-#include <stdlib.h>
+#include <ac/stdlib.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include "ldap-int.h"
-static char ** decode_answer LDAP_P(( unsigned char *answer, int len ));
+static char ** decode_answer LDAP_P(( unsigned char *answer, ber_len_t len ));
#define MAX_TO_SORT 32
* array.
*/
char **
-ldap_getdxbyname( char *domain )
+ldap_getdxbyname( const char *domain )
{
unsigned char buf[ PACKETSZ ];
char **dxs;
/*
* punt: return list conisting of the original domain name only
*/
- if (( dxs = (char **)malloc( 2 * sizeof( char * ))) == NULL ||
- ( dxs[ 0 ] = strdup( domain )) == NULL ) {
+ if (( dxs = (char **)LDAP_MALLOC( 2 * sizeof( char * ))) == NULL ||
+ ( dxs[ 0 ] = LDAP_STRDUP( domain )) == NULL ) {
if ( dxs != NULL ) {
- free( dxs );
+ LDAP_FREE( dxs );
}
dxs = NULL;
} else {
static char **
-decode_answer( unsigned char *answer, int len )
+decode_answer( unsigned char *answer, ber_len_t len )
{
HEADER *hp;
char buf[ 256 ], **dxs;
rr_len = _getshort( p );
p += INT16SZ;
if ( class == C_IN && type == T_TXT ) {
- int i, n, pref, txt_len;
+ int pref, txt_len;
char *q, *r;
q = (char *)p;
if ( *q >= 3 && strncasecmp( q + 1, "dx:", 3 ) == 0 ) {
txt_len = *q - 3;
r = q + 4;
- while ( isspace( *r )) {
+ while ( isspace( (unsigned char) *r )) {
++r;
--txt_len;
}
pref = 0;
- while ( isdigit( *r )) {
+ while ( isdigit( (unsigned char) *r )) {
pref *= 10;
pref += ( *r - '0' );
++r;
if ( dx_count < MAX_TO_SORT - 1 ) {
dx_pref[ dx_count ] = pref;
}
- while ( isspace( *r )) {
+ while ( isspace( (unsigned char) *r )) {
++r;
--txt_len;
}
- if ( dx_count == 0 ) {
- dxs = (char **)malloc( 2 * sizeof( char * ));
- } else {
- dxs = (char **)realloc( dxs,
+ dxs = (char **)LDAP_REALLOC( dxs,
( dx_count + 2 ) * sizeof( char * ));
- }
if ( dxs == NULL || ( dxs[ dx_count ] =
- (char *)calloc( 1, txt_len + 1 )) == NULL ) {
+ (char *)LDAP_CALLOC( 1, txt_len + 1 )) == NULL ) {
err = NO_RECOVERY;
continue;
}