2000-06-05 06:59:38 +08:00
|
|
|
/* index.c - index utilities */
|
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 09:17:14 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2005-01-02 04:49:32 +08:00
|
|
|
* Copyright 1998-2005 The OpenLDAP Foundation.
|
2003-11-27 09:17:14 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
2000-06-05 06:59:38 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2003-05-15 19:43:33 +08:00
|
|
|
#include <ac/string.h>
|
2000-06-05 06:59:38 +08:00
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
|
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;
|
2002-12-14 03:15:20 +08:00
|
|
|
} else if ( strcasecmp( str, "nolang" ) == 0 || /* backwards compat */
|
|
|
|
strcasecmp( str, "notags" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_NOTAGS;
|
2001-12-05 08:06:03 +08:00
|
|
|
} else if ( strcasecmp( str, "nosubtypes" ) == 0 ) {
|
|
|
|
*idx = SLAP_INDEX_NOSUBTYPES;
|
2000-06-05 06:59:38 +08:00
|
|
|
} else {
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LDAP_SUCCESS;
|
|
|
|
}
|