1 /* str2filter.c - parse an RFC 4515 string filter */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2013 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
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>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
33 #include <ac/socket.h>
39 str2filter_x( Operation *op, const char *str )
43 BerElementBuffer berbuf;
44 BerElement *ber = (BerElement *)&berbuf;
45 const char *text = NULL;
47 Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 );
49 if ( str == NULL || *str == '\0' ) {
53 ber_init2( ber, NULL, LBER_USE_DER );
54 if ( op->o_tmpmemctx ) {
55 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
58 rc = ldap_pvt_put_filter( ber, str );
65 rc = get_filter( op, ber, &f, &text );
74 str2filter( const char *str )
80 op.o_tmpmemctx = NULL;
81 op.o_tmpmfuncs = &ch_mfuncs;
83 return str2filter_x( &op, str );