From fcda57e90f6a28bc43c2a583c3fb3992af9a6b7d Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 13 Dec 2005 20:11:26 +0000 Subject: [PATCH] use macros instead of numbers... --- clients/tools/common.c | 2 +- clients/tools/ldapmodify.c | 4 ++-- libraries/libldap/add.c | 2 +- libraries/libldap/compare.c | 2 +- libraries/libldap/delete.c | 2 +- libraries/libldap/extended.c | 2 +- libraries/libldap/groupings.c | 18 +++++++++--------- libraries/libldap/kbind.c | 4 ++-- libraries/libldap/modify.c | 2 +- libraries/libldap/modrdn.c | 2 +- libraries/libldap/passwd.c | 2 +- libraries/libldap/sasl.c | 2 +- libraries/libldap/search.c | 6 +++--- libraries/libldap/whoami.c | 2 +- servers/slapd/back-ldap/bind.c | 2 +- servers/slapd/back-ldap/config.c | 2 +- servers/slapd/back-ldap/extended.c | 2 +- servers/slapd/back-ldap/search.c | 2 +- servers/slapd/back-meta/add.c | 2 +- servers/slapd/back-meta/bind.c | 4 ++-- servers/slapd/back-meta/compare.c | 2 +- servers/slapd/back-meta/delete.c | 2 +- servers/slapd/back-meta/modify.c | 2 +- servers/slapd/back-meta/modrdn.c | 2 +- servers/slapd/back-meta/search.c | 2 +- tests/progs/slapd-search.c | 4 +++- 26 files changed, 41 insertions(+), 39 deletions(-) diff --git a/clients/tools/common.c b/clients/tools/common.c index 4eab80167f..5608a23a71 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -1003,7 +1003,7 @@ tool_bind( LDAP *ld ) } } - if ( ldap_result( ld, msgid, 1, NULL, &result ) == -1 ) { + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ) == -1 ) { tool_perror( "ldap_result", -1, NULL, NULL, NULL, NULL ); exit( EXIT_FAILURE ); } diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 481ff2f9b8..a97a0d89f5 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -1163,9 +1163,9 @@ static int process_response( rc = ldap_result( ld, msgid, #ifdef LDAP_GROUP_TRANSACTION - txn ? 0 : 1, + txn ? LDAP_MSG_ONE : LDAP_MSG_ALL, #else - 1, + LDAP_MSG_ALL, #endif &tv, &res ); if ( tool_check_abandon( ld, msgid ) ) { diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index 88b849b359..e6930b67dd 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -198,7 +198,7 @@ ldap_add_ext_s( if ( rc != LDAP_SUCCESS ) return( rc ); - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); return( ldap_result2error( ld, res, 1 ) ); diff --git a/libraries/libldap/compare.c b/libraries/libldap/compare.c index 70249ad1b0..cc64917fa4 100644 --- a/libraries/libldap/compare.c +++ b/libraries/libldap/compare.c @@ -156,7 +156,7 @@ ldap_compare_ext_s( if ( rc != LDAP_SUCCESS ) return( rc ); - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); return( ldap_result2error( ld, res, 1 ) ); diff --git a/libraries/libldap/delete.c b/libraries/libldap/delete.c index 16e768cb53..72b5a41a23 100644 --- a/libraries/libldap/delete.c +++ b/libraries/libldap/delete.c @@ -123,7 +123,7 @@ ldap_delete_ext_s( if( rc != LDAP_SUCCESS ) return( ld->ld_errno ); - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); return( ldap_result2error( ld, res, 1 ) ); diff --git a/libraries/libldap/extended.c b/libraries/libldap/extended.c index 137dc69f04..75ba8dfce6 100644 --- a/libraries/libldap/extended.c +++ b/libraries/libldap/extended.c @@ -140,7 +140,7 @@ ldap_extended_operation_s( return( rc ); } - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) { + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) { return( ld->ld_errno ); } diff --git a/libraries/libldap/groupings.c b/libraries/libldap/groupings.c index fe768f17ac..d4495364a5 100644 --- a/libraries/libldap/groupings.c +++ b/libraries/libldap/groupings.c @@ -82,9 +82,9 @@ int ldap_grouping_create_s( struct berval **retgrpcookiep, struct berval **retgrpdatap ) { - int rc; - int msgid; - LDAPMessage *res; + int rc; + int msgid; + LDAPMessage *res; Debug( LDAP_DEBUG_TRACE, "ldap_grouping_create_s\n", 0, 0, 0 ); @@ -92,14 +92,14 @@ int ldap_grouping_create_s( assert( LDAP_VALID( ld ) ); assert( grpoid != NULL || *grpoid == '\0' ); - rc = ldap_grouping_create( ld, grpoid, grpdata, + rc = ldap_grouping_create( ld, grpoid, grpdata, sctrls, cctrls, &msgid ); - if ( rc != LDAP_SUCCESS ) { - return rc; + if ( rc != LDAP_SUCCESS ) { + return rc; } - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) { - return ld->ld_errno; + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) { + return ld->ld_errno; } if ( retgrpcookiep != NULL ) *retgrpcookiep = NULL; @@ -116,7 +116,7 @@ int ldap_grouping_create_s( return rc; } - return( ldap_result2error( ld, res, 1 ) ); + return( ldap_result2error( ld, res, 1 ) ); } int ldap_grouping_end( diff --git a/libraries/libldap/kbind.c b/libraries/libldap/kbind.c index 4f963cbd01..b8562f612f 100644 --- a/libraries/libldap/kbind.c +++ b/libraries/libldap/kbind.c @@ -126,7 +126,7 @@ ldap_kerberos_bind1_s( LDAP *ld, LDAP_CONST char *dn ) return( ld->ld_errno ); /* wait for a result */ - if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &res ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) 0, &res ) == -1 ) { return( ld->ld_errno ); /* ldap_result sets ld_errno */ } @@ -205,7 +205,7 @@ ldap_kerberos_bind2_s( LDAP *ld, LDAP_CONST char *dn ) return( ld->ld_errno ); /* wait for a result */ - if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &res ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) 0, &res ) == -1 ) { return( ld->ld_errno ); /* ldap_result sets ld_errno */ } diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index a03fd47057..fb938fc3b8 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -197,7 +197,7 @@ ldap_modify_ext_s( LDAP *ld, LDAP_CONST char *dn, if ( rc != LDAP_SUCCESS ) return( rc ); - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) return( ld->ld_errno ); return( ldap_result2error( ld, res, 1 ) ); diff --git a/libraries/libldap/modrdn.c b/libraries/libldap/modrdn.c index 0f46ec3945..246cede995 100644 --- a/libraries/libldap/modrdn.c +++ b/libraries/libldap/modrdn.c @@ -219,7 +219,7 @@ ldap_rename_s( return rc; } - rc = ldap_result( ld, msgid, 1, NULL, &res ); + rc = ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &res ); if( rc == -1 ) { return ld->ld_errno; diff --git a/libraries/libldap/passwd.c b/libraries/libldap/passwd.c index eef1510be5..49fe8bb24e 100644 --- a/libraries/libldap/passwd.c +++ b/libraries/libldap/passwd.c @@ -156,7 +156,7 @@ ldap_passwd_s( return rc; } - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) { + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) { return ld->ld_errno; } diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index e47302f33b..f1576faf8f 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -196,7 +196,7 @@ ldap_sasl_bind_s( } #endif - if ( ldap_result( ld, msgid, 1, NULL, &result ) == -1 ) { + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, NULL, &result ) == -1 ) { return( ld->ld_errno ); /* ldap_result sets ld_errno */ } diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 623c2fb317..60cac86f30 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -138,7 +138,7 @@ ldap_search_ext_s( return( rc ); } - rc = ldap_result( ld, msgid, 1, timeout, res ); + rc = ldap_result( ld, msgid, LDAP_MSG_ALL, timeout, res ); if( rc <= 0 ) { /* error(-1) or timeout(0) */ @@ -331,7 +331,7 @@ ldap_search_st( == -1 ) return( ld->ld_errno ); - if ( ldap_result( ld, msgid, 1, timeout, res ) == -1 ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, timeout, res ) == -1 ) return( ld->ld_errno ); if ( ld->ld_errno == LDAP_TIMEOUT ) { @@ -359,7 +359,7 @@ ldap_search_s( == -1 ) return( ld->ld_errno ); - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, res ) == -1 ) + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, res ) == -1 ) return( ld->ld_errno ); return( ldap_result2error( ld, *res, 0 ) ); diff --git a/libraries/libldap/whoami.c b/libraries/libldap/whoami.c index 498af5a180..79c8aa48e2 100644 --- a/libraries/libldap/whoami.c +++ b/libraries/libldap/whoami.c @@ -88,7 +88,7 @@ ldap_whoami_s( rc = ldap_whoami( ld, sctrls, cctrls, &msgid ); if ( rc != LDAP_SUCCESS ) return rc; - if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 ) { + if ( ldap_result( ld, msgid, LDAP_MSG_ALL, (struct timeval *) NULL, &res ) == -1 ) { return ld->ld_errno; } diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index c67eb60640..b9be36a408 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -851,7 +851,7 @@ ldap_back_op_result( retry:; /* if result parsing fails, note the failure reason */ - rc = ldap_result( lc->lc_ld, msgid, 1, &tv, &res ); + rc = ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, &tv, &res ); switch ( rc ) { case 0: if ( timeout ) { diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 07221bdfbd..4a22a48b80 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -1280,7 +1280,7 @@ ldap_back_exop_whoami( retry: rs->sr_err = ldap_whoami( lc->lc_ld, ctrls, NULL, &msgid ); if ( rs->sr_err == LDAP_SUCCESS ) { - if ( ldap_result( lc->lc_ld, msgid, 1, NULL, &res ) == -1 ) { + if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &res ) == -1 ) { ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err ); if ( rs->sr_err == LDAP_SERVER_DOWN && doretry ) { diff --git a/servers/slapd/back-ldap/extended.c b/servers/slapd/back-ldap/extended.c index dae58547f0..5c631ba4a1 100644 --- a/servers/slapd/back-ldap/extended.c +++ b/servers/slapd/back-ldap/extended.c @@ -122,7 +122,7 @@ retry: op->o_ctrls, NULL, &msgid ); if ( rc == LDAP_SUCCESS ) { - if ( ldap_result( lc->lc_ld, msgid, 1, NULL, &res ) == -1 ) { + if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &res ) == -1 ) { ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER, &rc ); ldap_back_freeconn( op, lc, 0 ); lc = NULL; diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 1a30eb6960..dde7795a85 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -258,7 +258,7 @@ retry: * but this is necessary for version matching, and for ACL processing. */ - for ( rc = 0; rc != -1; rc = ldap_result( lc->lc_ld, msgid, 0, &tv, &res ) ) + for ( rc = 0; rc != -1; rc = ldap_result( lc->lc_ld, msgid, LDAP_MSG_ONE, &tv, &res ) ) { /* check for abandon */ if ( op->o_abandon ) { diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index 84dc2b7f1c..c6c349ab15 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -186,7 +186,7 @@ retry:; rs->sr_err = LDAP_OTHER; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, - msgid, LDAP_MSG_ONE, tvp, &res ); + msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: send_ldap_result( op, rs ); diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 88c9a722f1..f2c2035fb0 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -343,7 +343,7 @@ rebind:; */ retry:; tv = mt->mt_bind_timeout; - switch ( ldap_result( msc->msc_ld, msgid, 0, &tv, &res ) ) { + switch ( ldap_result( msc->msc_ld, msgid, LDAP_MSG_ALL, &tv, &res ) ) { case 0: snprintf( buf, sizeof( buf ), "ldap_result=0 nretries=%d%s\n", @@ -499,7 +499,7 @@ rebind:; */ retry:; tv = mt->mt_bind_timeout; - switch ( ldap_result( msc->msc_ld, msgid, 0, &tv, &res ) ) { + switch ( ldap_result( msc->msc_ld, msgid, LDAP_MSG_ALL, &tv, &res ) ) { case 0: snprintf( buf, sizeof( buf ), "ldap_result=0 nretries=%d%s", diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index 65fdde05f0..b0d716c6fc 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -185,7 +185,7 @@ meta_back_compare( Operation *op, SlapReply *rs ) } lrc = ldap_result( msc->msc_ld, msgid[ i ], - 0, &tv, &res ); + LDAP_MSG_ALL, &tv, &res ); if ( lrc == 0 ) { assert( res == NULL ); diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index 42f77bf966..b810a99b6f 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -84,7 +84,7 @@ retry:; rs->sr_err = LDAP_OTHER; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, - msgid, LDAP_MSG_ONE, tvp, &res ); + msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: rs->sr_err = LDAP_OTHER; diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index 9701257022..30e48326b6 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -194,7 +194,7 @@ retry:; rs->sr_err = LDAP_OTHER; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, - msgid, LDAP_MSG_ONE, tvp, &res ); + msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: rc = -1; diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index 1c943b95d3..83efbb176c 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -125,7 +125,7 @@ retry:; rs->sr_err = LDAP_OTHER; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, - msgid, LDAP_MSG_ONE, tvp, &res ); + msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: break; diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index b64c92d935..a3d55ca3b7 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -389,7 +389,7 @@ meta_back_search( Operation *op, SlapReply *rs ) */ get_result:; rc = ldap_result( msc->msc_ld, candidates[ i ].sr_msgid, - 0, &tv, &res ); + LDAP_MSG_ONE, &tv, &res ); if ( rc == 0 ) { /* FIXME: res should not need to be freed */ diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index 0f3c1e63a0..7d80173499 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -181,6 +181,7 @@ retry:; rc = ldap_bind_s( ld, manager, passwd, LDAP_AUTH_SIMPLE ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_bind" ); + ldap_unbind_ext( ld, NULL, NULL ); switch ( rc ) { case LDAP_BUSY: case LDAP_UNAVAILABLE: @@ -205,6 +206,7 @@ retry:; filter, attrs, 0, &res ); if ( rc != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_search" ); + ldap_unbind_ext( ld, NULL, NULL ); if ( rc == LDAP_BUSY && do_retry > 0 ) { do_retry--; goto retry; @@ -219,5 +221,5 @@ retry:; fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc ); - ldap_unbind( ld ); + ldap_unbind_ext( ld, NULL, NULL ); } -- 2.39.5