X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Ftest.c;h=793bed66c6d69a6df4d82e43049f22bf864c5d98;hb=bcf8f7eeb788faa25efe0ea78e66e83e9d9b4d73;hp=b6aab5924d0ecb59a3d82a21308426cddf6cef07;hpb=cb68aab469680082fb5794dd55df8fb22b5ae95b;p=openldap diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index b6aab5924d..793bed66c6 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -1,5 +1,6 @@ +/* $OpenLDAP$ */ /* - * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ @@ -113,7 +114,7 @@ static int file_read( char *path, struct berval *bv ) { FILE *fp; - long rlen; + ber_slen_t rlen; int eof; if (( fp = fopen( path, "r" )) == NULL ) { @@ -145,7 +146,7 @@ file_read( char *path, struct berval *bv ) eof = feof( fp ); fclose( fp ); - if ( (unsigned long) rlen != bv->bv_len ) { + if ( (ber_len_t) rlen != bv->bv_len ) { perror( path ); free( bv->bv_val ); return( -1 ); @@ -234,7 +235,7 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, static char dn[256], passwd[256]; if ( !freeit ) { -#ifdef HAVE_KERBEROS +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND getline( dn, sizeof(dn), stdin, "re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " ); if (( *authmethodp = atoi( dn )) == 3 ) { @@ -242,9 +243,9 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp, } else { *authmethodp |= 0x80; } -#else /* HAVE_KERBEROS */ +#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ *authmethodp = LDAP_AUTH_SIMPLE; -#endif /* HAVE_KERBEROS */ +#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ getline( dn, sizeof(dn), stdin, "re-bind dn? " ); strcat( dn, dnsuffix ); @@ -301,7 +302,7 @@ main( int argc, char **argv ) ldap_debug = atoi( optarg ); #ifdef LBER_DEBUG if ( ldap_debug & LDAP_DEBUG_PACKETS ) { - lber_debug = ldap_debug; + ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug ); } #endif #else @@ -343,7 +344,7 @@ main( int argc, char **argv ) if ( errflg || optind < argc - 1 ) { fprintf( stderr, usage, argv[ 0 ] ); - exit( 1 ); + exit( EXIT_FAILURE ); } printf( "%s( %s, %d )\n", @@ -360,14 +361,14 @@ main( int argc, char **argv ) if ( ld == NULL ) { perror( cldapflg ? "cldap_open" : "ldap_init" ); - exit(1); + exit( EXIT_FAILURE ); } if ( copyfname != NULL ) { if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT, 0600 )) == -1 ) { perror( copyfname ); - exit ( 1 ); + exit ( EXIT_FAILURE ); } ld->ld_sb.sb_options = copyoptions; } @@ -412,13 +413,13 @@ main( int argc, char **argv ) break; case 'b': /* asynch bind */ -#ifdef HAVE_KERBEROS +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND getline( line, sizeof(line), stdin, "method (0->simple, 1->krbv41, 2->krbv42)? " ); method = atoi( line ) | 0x80; -#else /* HAVE_KERBEROS */ +#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ method = LDAP_AUTH_SIMPLE; -#endif /* HAVE_KERBEROS */ +#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ getline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); @@ -438,7 +439,7 @@ main( int argc, char **argv ) break; case 'B': /* synch bind */ -#ifdef HAVE_KERBEROS +#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND getline( line, sizeof(line), stdin, "method 0->simple 1->krbv41 2->krbv42 3->krb? " ); method = atoi( line ); @@ -446,9 +447,9 @@ main( int argc, char **argv ) method = LDAP_AUTH_KRBV4; else method = method | 0x80; -#else /* HAVE_KERBEROS */ +#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ method = LDAP_AUTH_SIMPLE; -#endif /* HAVE_KERBEROS */ +#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */ getline( dn, sizeof(dn), stdin, "dn? " ); strcat( dn, dnsuffix ); @@ -486,7 +487,7 @@ main( int argc, char **argv ) ldap_debug = atoi( line ); #ifdef LBER_DEBUG if ( ldap_debug & LDAP_DEBUG_PACKETS ) { - lber_debug = ldap_debug; + ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ldap_debug ); } #endif #else @@ -549,7 +550,7 @@ main( int argc, char **argv ) if ( !cldapflg ) { ldap_unbind( ld ); } - exit( 0 ); + exit( EXIT_SUCCESS ); break; case 'r': /* result or remove */ @@ -575,7 +576,7 @@ main( int argc, char **argv ) printf( "\nresult: msgtype %d msgid %d\n", msgtype, res->lm_msgid ); handle_result( ld, res ); - res = NULLMSG; + res = NULL; break; case 'm': /* remove */ @@ -618,7 +619,7 @@ main( int argc, char **argv ) printf( "\nresult: msgid %d\n", res->lm_msgid ); handle_result( ld, res ); - res = NULLMSG; + res = NULL; } #endif /* LDAP_CONNECTIONLESS */ } else { @@ -663,7 +664,7 @@ main( int argc, char **argv ) else { printf( "\nresult: err %d\n", id ); handle_result( ld, res ); - res = NULLMSG; + res = NULL; } free_list( types ); break; @@ -889,7 +890,8 @@ handle_result( LDAP *ld, LDAPMessage *lm ) break; default: - printf( "Unknown result type 0x%x\n", lm->lm_msgtype ); + printf( "Unknown result type 0x%lx\n", + (unsigned long) lm->lm_msgtype ); print_ldap_result( ld, lm, "unknown" ); } } @@ -912,7 +914,7 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) { LDAPMessage *e; - for ( e = ldap_first_entry( ld, res ); e != NULLMSG; + for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) ) { BerElement *ber = NULL; @@ -945,7 +947,7 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) int j, nonascii; nonascii = 0; - for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ ) + for ( j = 0; (ber_len_t) j < vals[i]->bv_len; j++ ) if ( !isascii( vals[i]->bv_val[j] ) ) { nonascii = 1; break; @@ -954,7 +956,7 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) if ( nonascii ) { printf( "\t\t\tlength (%ld) (not ascii)\n", vals[i]->bv_len ); #ifdef BPRINT_NONASCII - lber_bprint( vals[i]->bv_val, + ber_bprint( vals[i]->bv_val, vals[i]->bv_len ); #endif /* BPRINT_NONASCII */ continue; @@ -972,6 +974,6 @@ print_search_entry( LDAP *ld, LDAPMessage *res ) } if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT - || res->lm_chain != NULLMSG ) + || res->lm_chain != NULL ) print_ldap_result( ld, res, "search" ); }