From 8754c8f2a3ecde86613fdf024ebd830af1eade20 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 28 Nov 2002 04:38:41 +0000 Subject: [PATCH] #unifdef paged results, remove lint --- clients/tools/ldapsearch.c | 42 ++++++--------------------------- clients/tools/ldapwhoami.c | 2 -- servers/slapd/back-bdb/init.c | 12 +++------- servers/slapd/back-bdb/search.c | 23 +----------------- servers/slapd/config.c | 5 +--- servers/slapd/controls.c | 12 ---------- servers/slapd/init.c | 9 ------- servers/slapd/limits.c | 2 -- servers/slapd/slap.h | 6 +---- 9 files changed, 13 insertions(+), 100 deletions(-) diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 0c0c06b4eb..5ad8b5610e 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -56,9 +56,7 @@ usage( const char *s ) " -b basedn base dn for search\n" " -E [!][=] search controls (! indicates criticality)\n" " [!]mv= (matched values filter)\n" -#ifdef LDAP_CONTROL_PAGEDRESULTS " [!]pr= (paged results)\n" -#endif #ifdef LDAP_CONTROL_SUBENTRIES " [!]subentries[=true|false] (subentries)\n" #endif @@ -175,7 +173,6 @@ static int use_tls = 0; static char *sortattr = NULL; static int verbose, not, includeufn, vals2tmp, ldif; -#ifdef LDAP_CONTROL_PAGEDRESULTS static int pagedResults = 0; static ber_int_t pageSize = 0; static ber_int_t entriesLeft = 0; @@ -191,7 +188,6 @@ static int parse_page_control( LDAP *ld, LDAPMessage *result, struct berval *cookie ); -#endif /* LDAP_CONTROL_PAGEDRESULTS */ static void urlize(char *url) @@ -215,28 +211,22 @@ main( int argc, char **argv ) int referrals, timelimit, sizelimit, debug; int authmethod, version, want_bindpw; LDAP *ld = NULL; - int subentries, valuesReturnFilter; BerElement *ber = NULL; + char *control = NULL, *cvalue; + int subentries, valuesReturnFilter; struct berval *sebvalp = NULL, *vrbvalp = NULL; char *vrFilter = NULL; - char *control = NULL, *cvalue; char *pw_file = NULL; char *authzid = NULL; -#ifdef LDAP_CONTROL_PAGEDRESULTS struct berval *prbvalp = NULL; - int num = 0; -#endif /* LDAP_CONTROL_PAGEDRESULTS */ - infile = NULL; debug = verbose = not = vals2tmp = referrals = subentries = valuesReturnFilter = attrsonly = manageDSAit = noop = ldif = want_bindpw = 0; -#ifdef LDAP_CONTROL_PAGEDRESULTS npagedresponses = npagedentries = npagedreferences = npagedextended = npagedpartial = 0; -#endif /* LDAP_CONTROL_PAGEDRESULTS */ prog = lutil_progname( "ldapsearch", argc, argv ); @@ -335,9 +325,8 @@ main( int argc, char **argv ) version = LDAP_VERSION3; break; -#ifdef LDAP_CONTROL_PAGEDRESULTS } else if ( strcasecmp( control, "pr" ) == 0 ) { - int tmp; + int num, tmp; /* PagedResults control */ if ( pagedResults != 0 ) { fprintf( stderr, "PagedResultsControl previously specified" ); @@ -353,7 +342,6 @@ main( int argc, char **argv ) pageSize = (ber_int_t) tmp; pagedResults = 1 + crit; break; -#endif /* LDAP_CONTROL_PAGEDRESULTS */ #ifdef LDAP_CONTROL_SUBENTRIES } else if ( strcasecmp( control, "subentries" ) == 0 ) { @@ -1024,12 +1012,9 @@ main( int argc, char **argv ) } } -#ifdef LDAP_CONTROL_PAGEDRESULTS getNextPage: - if ( manageDSAit || noop || subentries || valuesReturnFilter || pageSize ) -#else - if ( manageDSAit || noop || subentries || valuesReturnFilter ) -#endif + if ( manageDSAit || noop || subentries + || valuesReturnFilter || pageSize ) { int err; int i=0; @@ -1123,7 +1108,6 @@ getNextPage: ctrls[++i] = NULL; } -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pagedResults ) { if (( ber = ber_alloc_t(LBER_USE_DER)) == NULL ) { return EXIT_FAILURE; @@ -1144,7 +1128,6 @@ getNextPage: ctrls[i] = &c[i]; ctrls[++i] = NULL; } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls ); @@ -1158,9 +1141,7 @@ getNextPage: ber_bvfree( sebvalp ); ber_bvfree( vrbvalp ); -#ifdef LDAP_CONTROL_PAGEDRESULTS ber_bvfree( prbvalp ); -#endif /* LDAP_CONTROL_PAGEDRESULTS */ } if ( verbose ) { @@ -1252,7 +1233,6 @@ getNextPage: } } -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( ( pageSize != 0 ) && ( morePagedResults != 0 ) ) { char buf[6]; int i, moreEntries, tmpSize; @@ -1277,7 +1257,7 @@ getNextPage: buf[i] = '\0'; if ( i > 0 && isdigit( buf[0] ) ) { - num = sscanf( buf, "%d", &tmpSize ); + int num = sscanf( buf, "%d", &tmpSize ); if ( num != 1 ) { fprintf( stderr, "Invalid value for PagedResultsControl, %s.\n", buf); return EXIT_FAILURE; @@ -1288,7 +1268,6 @@ getNextPage: goto getNextPage; } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ ldap_unbind( ld ); return( rc ); @@ -1403,11 +1382,9 @@ static int dosearch( case LDAP_RES_SEARCH_RESULT: rc = print_result( ld, msg, 1 ); -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pageSize != 0 ) { rc = parse_page_control( ld, msg, &cookie ); } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ goto done; } } @@ -1421,7 +1398,6 @@ static int dosearch( } done: -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pageSize != 0 ) { npagedresponses = npagedresponses + nresponses; npagedentries = npagedentries + nentries; @@ -1435,9 +1411,7 @@ done: if( npartial ) printf( "# numPartial: %d\n", npagedpartial ); if( nreferences ) printf( "# numReferences: %d\n", npagedreferences ); } - } else -#endif /* LDAP_CONTROL_PAGEDRESULTS */ - if ( ldif < 2 ) { + } else if ( ldif < 2 ) { printf( "\n# numResponses: %d\n", nresponses ); if( nentries ) printf( "# numEntries: %d\n", nentries ); if( nextended ) printf( "# numExtended: %d\n", nextended ); @@ -1939,7 +1913,6 @@ write_ldif( int type, char *name, char *value, ber_len_t vallen ) } -#ifdef LDAP_CONTROL_PAGEDRESULTS static int parse_page_control( LDAP *ld, @@ -2003,4 +1976,3 @@ parse_page_control( return err; } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ diff --git a/clients/tools/ldapwhoami.c b/clients/tools/ldapwhoami.c index 8d16eee744..37289e6235 100644 --- a/clients/tools/ldapwhoami.c +++ b/clients/tools/ldapwhoami.c @@ -100,8 +100,6 @@ main( int argc, char *argv[] ) char *control, *cvalue; int crit; - int id; - LDAPMessage *res; char *matcheddn = NULL, *text = NULL, **refs = NULL; char *retoid = NULL; struct berval *retdata = NULL; diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index d4a183302c..245d165250 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -495,21 +495,15 @@ bdb_initialize( { static char *controls[] = { LDAP_CONTROL_MANAGEDSAIT, -#ifdef LDAP_CONTROL_SUBENTRIES - LDAP_CONTROL_SUBENTRIES, -#endif -#ifdef LDAP_CONTROL_NOOP LDAP_CONTROL_NOOP, -#endif -#ifdef LDAP_CONTROL_VALUESRETURNFILTER + LDAP_CONTROL_PAGEDRESULTS, LDAP_CONTROL_VALUESRETURNFILTER, +#ifdef LDAP_CONTROL_SUBENTRIES + LDAP_CONTROL_SUBENTRIES, #endif #ifdef LDAP_CLIENT_UPDATE LDAP_CONTROL_CLIENT_UPDATE, #endif -#ifdef LDAP_CONTROL_PAGEDRESULTS - LDAP_CONTROL_PAGEDRESULTS, -#endif /* LDAP_CONTROL_PAGEDRESULTS */ NULL }; diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 7964b98ee4..0a653a9f51 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -26,14 +26,12 @@ static int search_candidates( int scope, int deref, ID *ids ); -#ifdef LDAP_CONTROL_PAGEDRESULTS static void send_pagerequest_response( Connection *conn, Operation *op, ID lastid, int nentries, int tentries ); -#endif /* LDAP_CONTROL_PAGEDRESULTS */ int bdb_search( @@ -63,11 +61,9 @@ bdb_search( struct berval realbase = { 0, NULL }; int nentries = 0; int manageDSAit; -#ifdef LDAP_CONTROL_PAGEDRESULTS int pagedresults; int tentries = 0; ID lastid = NOID; -#endif /* LDAP_CONTROL_PAGEDRESULTS */ #ifdef LDAP_CLIENT_UPDATE Filter lcupf, csnfnot, csnfeq, csnfand, csnfge; @@ -100,10 +96,7 @@ bdb_search( manageDSAit = get_manageDSAit( op ); - -#ifdef LDAP_CONTROL_PAGEDRESULTS pagedresults = get_pagedresults( op ); -#endif /* LDAP_CONTROL_PAGEDRESULTS */ rc = LOCK_ID (bdb->bi_dbenv, &locker ); switch(rc) { @@ -283,15 +276,11 @@ dn2entry_retry: /* if no limit is required, use soft limit */ if ( slimit <= 0 ) { -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pagedresults && limit->lms_s_pr != 0 ) { slimit = limit->lms_s_pr; } else { -#endif /* LDAP_CONTROL_PAGEDRESULTS */ slimit = limit->lms_s_soft; -#ifdef LDAP_CONTROL_PAGEDRESULTS } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ /* if requested limit higher than hard limit, abort */ } else if ( slimit > limit->lms_s_hard ) { @@ -367,13 +356,10 @@ dn2entry_retry: } } -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( isroot || !limit->lms_s_pr_hide ) { tentries = BDB_IDL_N(candidates); } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ -#ifdef LDAP_CONTROL_PAGEDRESULTS if ( pagedresults ) { if ( op->o_pagedresults_state.ps_cookie == 0 ) { id = 0; @@ -405,7 +391,6 @@ dn2entry_retry: } goto loop_begin; } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ #ifdef LDAP_CLIENT_UPDATE if ( op->o_clientupdate_type & SLAP_LCUP_SYNC ) { @@ -441,10 +426,7 @@ dn2entry_retry: int scopeok = 0; -#ifdef LDAP_CONTROL_PAGEDRESULTS loop_begin: -#endif /* LDAP_CONTROL_PAGEDRESULTS */ - /* check for abandon */ if ( op->o_abandon ) { rc = 0; @@ -647,7 +629,7 @@ id2entry_retry: v2refs, NULL, nentries ); goto done; } -#ifdef LDAP_CONTROL_PAGEDRESULTS + if ( pagedresults ) { if ( nentries >= op->o_pagedresults_size ) { send_pagerequest_response( conn, op, lastid, nentries, tentries ); @@ -655,7 +637,6 @@ id2entry_retry: } lastid = id; } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ if (e) { int result; @@ -1106,7 +1087,6 @@ static int search_candidates( return rc; } -#ifdef LDAP_CONTROL_PAGEDRESULTS static void send_pagerequest_response( Connection *conn, @@ -1167,5 +1147,4 @@ done: ch_free( ctrls[0]->ldctl_value.bv_val ); } } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ diff --git a/servers/slapd/config.c b/servers/slapd/config.c index bd777a81c4..f6225eeff2 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -30,12 +30,9 @@ struct slap_limits_set deflimit = { SLAPD_DEFAULT_SIZELIMIT, /* backward compatible limits */ 0, - -1 /* no limit on unchecked size */ -#ifdef LDAP_CONTROL_PAGEDRESULTS - , + -1, /* no limit on unchecked size */ 0, /* page limit */ 0 /* hide number of entries left */ -#endif /* LDAP_CONTROL_PAGEDRESULTS */ }; AccessControl *global_acl = NULL; diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index 81ec835089..1021d267d9 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -71,21 +71,15 @@ static struct slap_control { SLAP_CTRL_SEARCH, NULL, parseSubentries }, #endif -#ifdef LDAP_CONTROL_NOOP { LDAP_CONTROL_NOOP, SLAP_CTRL_ACCESS, NULL, parseNoOp }, -#endif -#ifdef LDAP_CONTROL_PAGEDRESULTS { LDAP_CONTROL_PAGEDRESULTS, SLAP_CTRL_SEARCH, NULL, parsePagedResults }, -#endif /* LDAP_CONTROL_PAGEDRESULTS */ -#ifdef LDAP_CONTROL_VALUESRETURNFILTER { LDAP_CONTROL_VALUESRETURNFILTER, SLAP_CTRL_SEARCH, NULL, parseValuesReturnFilter }, -#endif #ifdef LDAP_CLIENT_UPDATE { LDAP_CONTROL_CLIENT_UPDATE, SLAP_CTRL_SEARCH, NULL, @@ -445,7 +439,6 @@ static int parseSubentries ( } #endif -#ifdef LDAP_CONTROL_NOOP static int parseNoOp ( Connection *conn, Operation *op, @@ -468,9 +461,7 @@ static int parseNoOp ( return LDAP_SUCCESS; } -#endif -#ifdef LDAP_CONTROL_PAGEDRESULTS static int parsePagedResults ( Connection *conn, Operation *op, @@ -551,9 +542,7 @@ static int parsePagedResults ( return LDAP_SUCCESS; } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ -#ifdef LDAP_CONTROL_VALUESRETURNFILTER int parseValuesReturnFilter ( Connection *conn, Operation *op, @@ -609,7 +598,6 @@ int parseValuesReturnFilter ( return LDAP_SUCCESS; } -#endif #ifdef LDAP_CLIENT_UPDATE static int parseClientUpdate ( diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 90f66152ea..94530f9437 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -79,17 +79,13 @@ char *slap_known_controls[] = { LDAP_CONTROL_REFERRALS, #endif /* LDAP_CONTROL_REFERRALS */ -#ifdef LDAP_CONTROL_MANAGEDSAIT LDAP_CONTROL_MANAGEDSAIT, -#endif /* LDAP_CONTROL_MANAGEDSAIT */ #ifdef LDAP_CONTROL_SUBENTRIES LDAP_CONTROL_SUBENTRIES, #endif /* LDAP_CONTROL_SUBENTRIES */ -#ifdef LDAP_CONTROL_NOOP LDAP_CONTROL_NOOP, -#endif /* LDAP_CONTROL_NOOP */ #ifdef LDAP_CONTROL_DUPENT_REQUEST LDAP_CONTROL_DUPENT_REQUEST, @@ -103,9 +99,7 @@ char *slap_known_controls[] = { LDAP_CONTROL_DUPENT_ENTRY, #endif /* LDAP_CONTROL_DUPENT_ENTRY */ -#ifdef LDAP_CONTROL_PAGEDRESULTS LDAP_CONTROL_PAGEDRESULTS, -#endif /* LDAP_CONTROL_PAGEDRESULTS */ #ifdef LDAP_CONTROL_SORTREQUEST LDAP_CONTROL_SORTREQUEST, @@ -123,10 +117,7 @@ char *slap_known_controls[] = { LDAP_CONTROL_VLVRESPONSE, #endif /* LDAP_CONTROL_VLVRESPONSE */ -#ifdef LDAP_CONTROL_VALUESRETURNFILTER LDAP_CONTROL_VALUESRETURNFILTER, -#endif /* LDAP_CONTROL_VALUESRETURNFILTER */ - NULL }; diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 6c74b449b7..51f5673046 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -563,7 +563,6 @@ parse_limit( } } -#ifdef LDAP_CONTROL_PAGEDRESULTS } else if ( strncasecmp( arg, "pr", sizeof( "pr" ) - 1 ) == 0 ) { arg += sizeof( "pr" ) - 1; if ( arg[0] != '=' ) { @@ -581,7 +580,6 @@ parse_limit( return( 1 ); } } -#endif /* LDAP_CONTROL_PAGEDRESULTS */ } else { return( 1 ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index e81a0289fd..7e33a378ad 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1154,10 +1154,8 @@ struct slap_limits_set { int lms_s_soft; int lms_s_hard; int lms_s_unchecked; -#ifdef LDAP_CONTROL_PAGEDRESULTS int lms_s_pr; int lms_s_pr_hide; -#endif /* LDAP_CONTROL_PAGEDRESULTS */ }; struct slap_limits { @@ -1685,9 +1683,7 @@ typedef struct slap_op { #define get_manageDSAit(op) ((int)(op)->o_managedsait) #define get_subentries(op) ((int)(op)->o_subentries) #define get_subentries_visibility(op) ((int)(op)->o_subentries_visibility) -#ifdef LDAP_CONTROL_PAGEDRESULTS -#define get_pagedresults(op) ((int)(op)->o_pagedresults) -#endif /* LDAP_CONTROL_PAGEDRESULTS */ +#define get_pagedresults(op) ((int)(op)->o_pagedresults) /* -- 2.39.5