]> git.sur5r.net Git - openldap/blob - servers/slapd/str2filter.c
Fixed minor compile errors
[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_x( Operation *op, const char *str )
28 {
29         int rc;
30         Filter  *f = NULL;
31         char berbuf[LBER_ELEMENT_SIZEOF];
32         BerElement *ber = (BerElement *)berbuf;
33         const char *text = NULL;
34
35 #ifdef NEW_LOGGING
36         LDAP_LOG( FILTER, ENTRY,  "str2filter: \"%s\"\n", str, 0, 0 );
37 #else
38         Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 );
39 #endif
40
41         if ( str == NULL || *str == '\0' ) {
42                 return NULL;
43         }
44
45         ber_init2( ber, NULL, LBER_USE_DER );
46         if ( op->o_tmpmemctx ) {
47                 ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
48         }
49
50         rc = ldap_pvt_put_filter( ber, str );
51         if( rc < 0 ) {
52                 goto done;
53         }
54
55         ber_reset( ber, 1 );
56
57         rc = get_filter( op, ber, &f, &text );
58
59 done:
60         ber_free_buf( ber );
61
62         return f;
63 }
64
65 Filter *
66 str2filter( const char *str )
67 {
68         Operation op = {0};
69
70         op.o_tmpmemctx = NULL;
71         op.o_tmpmfuncs = &ch_mfuncs;
72
73         return str2filter_x( &op, str );
74 }