2000-06-05 06:59:38 +08:00
|
|
|
/* index.c - index utilities */
|
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/*
|
2002-01-05 05:17:25 +08:00
|
|
|
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
|
2000-06-05 06:59:38 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
slap_index2prefix( int indextype )
|
|
|
|
{
|
|
|
|
int prefix;
|
|
|
|
|
|
|
|
switch ( indextype ) {
|
|
|
|
case SLAP_INDEX_EQUALITY:
|
|
|
|
prefix = SLAP_INDEX_EQUALITY_PREFIX;
|
|
|
|
break;
|
|
|
|
case SLAP_INDEX_APPROX:
|
|
|
|
prefix = SLAP_INDEX_APPROX_PREFIX;
|
|
|
|
break;
|
|
|
|
case SLAP_INDEX_SUBSTR:
|
|
|
|
prefix = SLAP_INDEX_SUBSTR_PREFIX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
prefix = SLAP_INDEX_UNKNOWN_PREFIX;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return( prefix );
|
|
|
|
}
|
|
|
|
|
2000-08-23 05:26:25 +08:00
|
|
|
int slap_str2index( const char *str, slap_mask_t *idx )
|
2000-06-05 06:59:38 +08:00
|
|
|
{
|
|
|
|
if ( strcasecmp( str, "pres" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_PRESENT;
|
|
|
|
} else if ( strcasecmp( str, "eq" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_EQUALITY;
|
|
|
|
} else if ( strcasecmp( str, "approx" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_APPROX;
|
|
|
|
} else if ( strcasecmp( str, "subinitial" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_SUBSTR_INITIAL;
|
|
|
|
} else if ( strcasecmp( str, "subany" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_SUBSTR_ANY;
|
|
|
|
} else if ( strcasecmp( str, "subfinal" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_SUBSTR_FINAL;
|
|
|
|
} else if ( strcasecmp( str, "substr" ) == 0 ||
|
|
|
|
strcasecmp( str, "sub" ) == 0 )
|
|
|
|
{
|
|
|
|
*idx = SLAP_INDEX_SUBSTR_DEFAULT;
|
2001-12-05 08:06:03 +08:00
|
|
|
} else if ( strcasecmp( str, "nolang" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_NOLANG;
|
|
|
|
} else if ( strcasecmp( str, "nosubtypes" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_NOSUBTYPES;
|
2002-01-15 04:13:25 +08:00
|
|
|
} else if ( strcasecmp( str, "autosubtypes" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_AUTO_SUBTYPES;
|
2000-06-05 06:59:38 +08:00
|
|
|
} else {
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LDAP_SUCCESS;
|
|
|
|
}
|