]> git.sur5r.net Git - openldap/blob - servers/slapd/index.c
SLAPI updates (blind commit)
[openldap] / servers / slapd / index.c
1 /* index.c - index utilities */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2004 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20 #include <ac/string.h>
21
22 #include "slap.h"
23
24 int slap_str2index( const char *str, slap_mask_t *idx )
25 {
26         if ( strcasecmp( str, "pres" ) == 0 ) {
27                 *idx = SLAP_INDEX_PRESENT;
28         } else if ( strcasecmp( str, "eq" ) == 0 ) {
29                 *idx = SLAP_INDEX_EQUALITY;
30         } else if ( strcasecmp( str, "approx" ) == 0 ) {
31                 *idx = SLAP_INDEX_APPROX;
32         } else if ( strcasecmp( str, "subinitial" ) == 0 ) {
33                 *idx = SLAP_INDEX_SUBSTR_INITIAL;
34         } else if ( strcasecmp( str, "subany" ) == 0 ) {
35                 *idx = SLAP_INDEX_SUBSTR_ANY;
36         } else if ( strcasecmp( str, "subfinal" ) == 0 ) {
37                 *idx = SLAP_INDEX_SUBSTR_FINAL;
38         } else if ( strcasecmp( str, "substr" ) == 0 ||
39                 strcasecmp( str, "sub" ) == 0 )
40         {
41                 *idx = SLAP_INDEX_SUBSTR_DEFAULT;
42         } else if ( strcasecmp( str, "nolang" ) == 0 || /* backwards compat */
43                     strcasecmp( str, "notags" ) == 0 ) {
44                 *idx = SLAP_INDEX_NOTAGS;
45         } else if ( strcasecmp( str, "nosubtypes" ) == 0 ) {
46                 *idx = SLAP_INDEX_NOSUBTYPES;
47         } else {
48                 return LDAP_OTHER;
49         }
50
51         return LDAP_SUCCESS;
52 }