Move INDEX_ macros from back-ldbm.h to slap.h and prefix with SLAP_

Move AttrInfo from back-ldbm.h to attr.c
This commit is contained in:
Kurt Zeilenga 2000-01-28 20:38:00 +00:00
parent 17f1024ad5
commit cca2bdcb40
5 changed files with 45 additions and 46 deletions

View file

@ -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,

View file

@ -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 {

View file

@ -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 );
}

View file

@ -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:

View file

@ -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