]> git.sur5r.net Git - openldap/blob - servers/slapd/index.c
Rework indexing code, removing "autolang" and making
[openldap] / servers / slapd / index.c
1 /* index.c - index utilities */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 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
15 slap_index2prefix( int indextype )
16 {
17         int     prefix;
18
19         switch ( indextype ) {
20         case SLAP_INDEX_EQUALITY:
21                 prefix = SLAP_INDEX_EQUALITY_PREFIX;
22                 break;
23         case SLAP_INDEX_APPROX:
24                 prefix = SLAP_INDEX_APPROX_PREFIX;
25                 break;
26         case SLAP_INDEX_SUBSTR:
27                 prefix = SLAP_INDEX_SUBSTR_PREFIX;
28                 break;
29         default:
30                 prefix = SLAP_INDEX_UNKNOWN_PREFIX;
31                 break;
32         }
33
34         return( prefix );
35 }
36
37 int slap_str2index( const char *str, slap_mask_t *idx )
38 {
39         if ( strcasecmp( str, "pres" ) == 0 ) {
40                 *idx = SLAP_INDEX_PRESENT;
41         } else if ( strcasecmp( str, "eq" ) == 0 ) {
42                 *idx = SLAP_INDEX_EQUALITY;
43         } else if ( strcasecmp( str, "approx" ) == 0 ) {
44                 *idx = SLAP_INDEX_APPROX;
45         } else if ( strcasecmp( str, "subinitial" ) == 0 ) {
46                 *idx = SLAP_INDEX_SUBSTR_INITIAL;
47         } else if ( strcasecmp( str, "subany" ) == 0 ) {
48                 *idx = SLAP_INDEX_SUBSTR_ANY;
49         } else if ( strcasecmp( str, "subfinal" ) == 0 ) {
50                 *idx = SLAP_INDEX_SUBSTR_FINAL;
51         } else if ( strcasecmp( str, "substr" ) == 0 ||
52                 strcasecmp( str, "sub" ) == 0 )
53         {
54                 *idx = SLAP_INDEX_SUBSTR_DEFAULT;
55         } else if ( strcasecmp( str, "nolang" ) == 0 ) {
56                 *idx = SLAP_INDEX_NOLANG;
57         } else if ( strcasecmp( str, "nosubtypes" ) == 0 ) {
58                 *idx = SLAP_INDEX_NOSUBTYPES;
59         } else if ( strcasecmp( str, "autosubtypes" ) == 0 ) {
60                 *idx = SLAP_INDEX_AUTO_SUBTYPES;
61         } else {
62                 return LDAP_OTHER;
63         }
64
65         return LDAP_SUCCESS;
66 }