From cca2bdcb409737ffb9fbf102d949114a161da45e Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 28 Jan 2000 20:38:00 +0000 Subject: [PATCH] Move INDEX_ macros from back-ldbm.h to slap.h and prefix with SLAP_ Move AttrInfo from back-ldbm.h to attr.c --- servers/slapd/back-ldbm/attr.c | 24 ++++++++++++++++-------- servers/slapd/back-ldbm/back-ldbm.h | 19 ------------------- servers/slapd/back-ldbm/filterindex.c | 12 ++++++------ servers/slapd/back-ldbm/index.c | 26 +++++++++++++------------- servers/slapd/slap.h | 10 ++++++++++ 5 files changed, 45 insertions(+), 46 deletions(-) diff --git a/servers/slapd/back-ldbm/attr.c b/servers/slapd/back-ldbm/attr.c index c8cd6b5cc7..107203f4bb 100644 --- a/servers/slapd/back-ldbm/attr.c +++ b/servers/slapd/back-ldbm/attr.c @@ -15,6 +15,13 @@ #include "slap.h" #include "back-ldbm.h" +/* for the cache of attribute information (which are indexed, etc.) */ +typedef struct ldbm_attrinfo { + char *ai_type; /* type name (cn, sn, ...) */ + int ai_indexmask; /* how the attr is indexed */ + int ai_syntaxmask; /* what kind of syntax */ +} AttrInfo; + static int ainfo_type_cmp( char *type, @@ -50,7 +57,7 @@ ainfo_dup( * if the duplicate definition is because we initialized the attr, * just add what came from the config file. otherwise, complain. */ - if ( a->ai_indexmask & INDEX_FROMINIT ) { + if ( a->ai_indexmask & SLAP_INDEX_FROMINIT ) { a->ai_indexmask |= b->ai_indexmask; return( 1 ); @@ -114,23 +121,24 @@ attr_index_config( a->ai_syntaxmask = attr_syntax( a->ai_type ); #endif if ( argc == 1 ) { - a->ai_indexmask = (INDEX_PRESENCE | INDEX_EQUALITY | - INDEX_APPROX | INDEX_SUB); + a->ai_indexmask = ( + SLAP_INDEX_PRESENCE | SLAP_INDEX_EQUALITY | + SLAP_INDEX_APPROX | SLAP_INDEX_SUB); } else { a->ai_indexmask = 0; for ( j = 0; indexes[j] != NULL; j++ ) { if ( strncasecmp( indexes[j], "pres", 4 ) == 0 ) { - a->ai_indexmask |= INDEX_PRESENCE; + a->ai_indexmask |= SLAP_INDEX_PRESENCE; } else if ( strncasecmp( indexes[j], "eq", 2 ) == 0 ) { - a->ai_indexmask |= INDEX_EQUALITY; + a->ai_indexmask |= SLAP_INDEX_EQUALITY; } else if ( strncasecmp( indexes[j], "approx", 6 ) == 0 ) { - a->ai_indexmask |= INDEX_APPROX; + a->ai_indexmask |= SLAP_INDEX_APPROX; } else if ( strncasecmp( indexes[j], "sub", 3 ) == 0 ) { - a->ai_indexmask |= INDEX_SUB; + a->ai_indexmask |= SLAP_INDEX_SUB; } else if ( strncasecmp( indexes[j], "none", 4 ) == 0 ) { if ( a->ai_indexmask != 0 ) { @@ -149,7 +157,7 @@ attr_index_config( } } if ( init ) { - a->ai_indexmask |= INDEX_FROMINIT; + a->ai_indexmask |= SLAP_INDEX_FROMINIT; } switch (avl_insert( &li->li_attrs, (caddr_t) a, diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 1c1154ec37..2692137d4c 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -108,25 +108,6 @@ typedef struct ldbm_dbcache { LDBM dbc_db; } DBCache; -/* for the cache of attribute information (which are indexed, etc.) */ -typedef struct ldbm_attrinfo { - char *ai_type; /* type name (cn, sn, ...) */ - int ai_indexmask; /* how the attr is indexed */ -#define INDEX_PRESENCE 0x0001 -#define INDEX_EQUALITY 0x0002 -#define INDEX_APPROX 0x0004 -#define INDEX_SUB 0x0008 -#define INDEX_UNKNOWN 0x0010 -#define INDEX_FROMINIT 0x1000 - int ai_syntaxmask; /* what kind of syntax */ -/* ...from slap.h... -#define SYNTAX_CIS 0x01 -#define SYNTAX_CES 0x02 -#define SYNTAX_BIN 0x04 - ... etc. ... -*/ -} AttrInfo; - #define MAXDBCACHE 16 struct ldbminfo { diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index c3c92a3954..55f73cc398 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -120,7 +120,7 @@ ava_candidates( switch ( type ) { case LDAP_FILTER_EQUALITY: - idl = index_read( be, ava->ava_type, INDEX_EQUALITY, + idl = index_read( be, ava->ava_type, SLAP_INDEX_EQUALITY, ava->ava_value.bv_val ); break; @@ -148,7 +148,7 @@ presence_candidates( Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 ); - idl = index_read( be, type, INDEX_PRESENCE, "*" ); + idl = index_read( be, type, SLAP_INDEX_PRESENCE, "*" ); Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %ld\n", idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 ); @@ -170,7 +170,7 @@ approx_candidates( for ( w = first_word( ava->ava_value.bv_val ); w != NULL; w = next_word( w ) ) { c = phonetic( w ); - if ( (tmp = index_read( be, ava->ava_type, INDEX_APPROX, c )) + if ( (tmp = index_read( be, ava->ava_type, SLAP_INDEX_APPROX, c )) == NULL ) { free( c ); idl_free( idl ); @@ -330,7 +330,7 @@ substring_comp_candidates( } buf[SUBLEN] = '\0'; - if ( (idl = index_read( be, type, INDEX_SUB, buf )) == NULL ) { + if ( (idl = index_read( be, type, SLAP_INDEX_SUB, buf )) == NULL ) { return( NULL ); } } else if ( prepost == '$' ) { @@ -341,7 +341,7 @@ substring_comp_candidates( buf[SUBLEN - 1] = '$'; buf[SUBLEN] = '\0'; - if ( (idl = index_read( be, type, INDEX_SUB, buf )) == NULL ) { + if ( (idl = index_read( be, type, SLAP_INDEX_SUB, buf )) == NULL ) { return( NULL ); } } @@ -352,7 +352,7 @@ substring_comp_candidates( } buf[SUBLEN] = '\0'; - if ( (tmp = index_read( be, type, INDEX_SUB, buf )) == NULL ) { + if ( (tmp = index_read( be, type, SLAP_INDEX_SUB, buf )) == NULL ) { idl_free( idl ); return( NULL ); } diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 0769a4bac8..055a2b407a 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -344,9 +344,9 @@ index_change_values( /* * presence index entry */ - if ( indexmask & INDEX_PRESENCE ) { + if ( indexmask & SLAP_INDEX_PRESENCE ) { - change_value( be, db, at_cn, INDEX_PRESENCE, + change_value( be, db, at_cn, SLAP_INDEX_PRESENCE, "*", id, idl_funct ); } @@ -383,9 +383,9 @@ index_change_values( /* * equality index entry */ - if ( indexmask & INDEX_EQUALITY ) { + if ( indexmask & SLAP_INDEX_EQUALITY ) { - change_value( be, db, at_cn, INDEX_EQUALITY, + change_value( be, db, at_cn, SLAP_INDEX_EQUALITY, val, id, idl_funct); } @@ -393,14 +393,14 @@ index_change_values( /* * approximate index entry */ - if ( indexmask & INDEX_APPROX ) { + if ( indexmask & SLAP_INDEX_APPROX ) { for ( w = first_word( val ); w != NULL; w = next_word( w ) ) { if ( (code = phonetic( w )) != NULL ) { change_value( be, db, at_cn, - INDEX_APPROX, + SLAP_INDEX_APPROX, code, id, idl_funct ); @@ -412,7 +412,7 @@ index_change_values( /* * substrings index entry */ - if ( indexmask & INDEX_SUB ) { + if ( indexmask & SLAP_INDEX_SUB ) { /* leading and trailing */ if ( len > SUBLEN - 2 ) { buf[0] = '^'; @@ -421,7 +421,7 @@ index_change_values( } buf[SUBLEN] = '\0'; - change_value( be, db, at_cn, INDEX_SUB, + change_value( be, db, at_cn, SLAP_INDEX_SUB, buf, id, idl_funct ); p = val + len - SUBLEN + 1; @@ -431,7 +431,7 @@ index_change_values( buf[SUBLEN - 1] = '$'; buf[SUBLEN] = '\0'; - change_value( be, db, at_cn, INDEX_SUB, + change_value( be, db, at_cn, SLAP_INDEX_SUB, buf, id, idl_funct ); } @@ -442,7 +442,7 @@ index_change_values( } buf[SUBLEN] = '\0'; - change_value( be, db, at_cn, INDEX_SUB, + change_value( be, db, at_cn, SLAP_INDEX_SUB, buf, id, idl_funct ); } } @@ -465,13 +465,13 @@ index2prefix( int indextype ) int prefix; switch ( indextype ) { - case INDEX_EQUALITY: + case SLAP_INDEX_EQUALITY: prefix = EQ_PREFIX; break; - case INDEX_APPROX: + case SLAP_INDEX_APPROX: prefix = APPROX_PREFIX; break; - case INDEX_SUB: + case SLAP_INDEX_SUB: prefix = SUB_PREFIX; break; default: diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a5815cd1f6..18faa0ea39 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -96,6 +96,16 @@ LDAP_BEGIN_DECL LIBSLAPD_F (int) slap_debug; +/* + * Index types + */ +#define SLAP_INDEX_PRESENCE 0x0001U +#define SLAP_INDEX_EQUALITY 0x0002U +#define SLAP_INDEX_APPROX 0x0004U +#define SLAP_INDEX_SUB 0x0008U +#define SLAP_INDEX_UNKNOWN 0x0010U +#define SLAP_INDEX_FROMINIT 0x8000U /* psuedo type */ + /* * represents schema information for a database -- 2.39.5