]> git.sur5r.net Git - openldap/blob - servers/slapd/str2filter.c
Commit of the Proxy Cache contribution (ITS#2062)
[openldap] / servers / slapd / str2filter.c
1 /* str2filter.c - parse an rfc 1588 string filter */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 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 <ac/string.h>
13 #include <ac/ctype.h>
14 #include <ac/socket.h>
15
16 #include "slap.h"
17 #include <ldap_pvt.h>
18
19 #if 0 /* unused */
20 static char     *find_matching_paren( const char *s );
21 #endif /* unused */
22 static Filter   *str2list( const char *str, long unsigned int ftype);
23 static Filter   *str2simple( const char *str);
24 static int      str2subvals( const char *val, Filter *f);
25
26 Filter *
27 str2filter( const char *str )
28 {
29         int rc;
30         Filter  *f = NULL;
31         char berbuf[256];
32         BerElement *ber = (BerElement *)berbuf;
33         Connection conn;
34         const char *text = NULL;
35
36 #ifdef NEW_LOGGING
37         LDAP_LOG( FILTER, ENTRY,  "str2filter: \"%s\"\n", str, 0, 0 );
38 #else
39         Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 );
40 #endif
41
42         if ( str == NULL || *str == '\0' ) {
43                 return NULL;
44         }
45
46         ber_init2( ber, NULL, LBER_USE_DER );
47
48         rc = ldap_pvt_put_filter( ber, str );
49         if( rc < 0 ) {
50                 goto done;
51         }
52
53         ber_reset( ber, 1 );
54
55         conn.c_connid = 0;
56
57         rc = get_filter( &conn, ber, &f, &text );
58
59 done:
60         ber_free_buf( ber );
61
62         return f;
63 }