]> git.sur5r.net Git - openldap/blob - servers/slapd/index.c
Add validation.
[openldap] / servers / slapd / index.c
1 /* index.c - index utilities */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include "slap.h"
13
14 int slap_str2index( const char *str, slap_mask_t *idx )
15 {
16         if ( strcasecmp( str, "pres" ) == 0 ) {
17                 *idx = SLAP_INDEX_PRESENT;
18         } else if ( strcasecmp( str, "eq" ) == 0 ) {
19                 *idx = SLAP_INDEX_EQUALITY;
20         } else if ( strcasecmp( str, "approx" ) == 0 ) {
21                 *idx = SLAP_INDEX_APPROX;
22         } else if ( strcasecmp( str, "subinitial" ) == 0 ) {
23                 *idx = SLAP_INDEX_SUBSTR_INITIAL;
24         } else if ( strcasecmp( str, "subany" ) == 0 ) {
25                 *idx = SLAP_INDEX_SUBSTR_ANY;
26         } else if ( strcasecmp( str, "subfinal" ) == 0 ) {
27                 *idx = SLAP_INDEX_SUBSTR_FINAL;
28         } else if ( strcasecmp( str, "substr" ) == 0 ||
29                 strcasecmp( str, "sub" ) == 0 )
30         {
31                 *idx = SLAP_INDEX_SUBSTR_DEFAULT;
32         } else if ( strcasecmp( str, "nolang" ) == 0 ) {
33                 *idx = SLAP_INDEX_NOLANG;
34         } else if ( strcasecmp( str, "nosubtypes" ) == 0 ) {
35                 *idx = SLAP_INDEX_NOSUBTYPES;
36         } else {
37                 return LDAP_OTHER;
38         }
39
40         return LDAP_SUCCESS;
41 }