#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,
* 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 );
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 ) {
}
}
if ( init ) {
- a->ai_indexmask |= INDEX_FROMINIT;
+ a->ai_indexmask |= SLAP_INDEX_FROMINIT;
}
switch (avl_insert( &li->li_attrs, (caddr_t) a,
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 {
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;
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 );
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 );
}
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 == '$' ) {
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 );
}
}
}
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 );
}
/*
* 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 );
}
/*
* 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);
}
/*
* 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 );
/*
* substrings index entry
*/
- if ( indexmask & INDEX_SUB ) {
+ if ( indexmask & SLAP_INDEX_SUB ) {
/* leading and trailing */
if ( len > SUBLEN - 2 ) {
buf[0] = '^';
}
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;
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 );
}
}
buf[SUBLEN] = '\0';
- change_value( be, db, at_cn, INDEX_SUB,
+ change_value( be, db, at_cn, SLAP_INDEX_SUB,
buf, id, idl_funct );
}
}
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:
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