+/* ftest.c -- OpenLDAP Filter API Test */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2013 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
*/
-/* OpenLDAP Filter API Test */
#include "portable.h"
#include <ldap.h>
#include "ldap_pvt.h"
+#include "lber_pvt.h"
#include "ldif.h"
#include "lutil.h"
{
fprintf( stderr, "usage:\n"
" ftest [-d n] filter\n"
- " filter - RFC 2254 string representation of an "
+ " filter - RFC 4515 string representation of an "
"LDAP search filter\n" );
return EXIT_FAILURE;
}
static int filter2ber( char *filter )
{
int rc;
- struct berval *bv = NULL;
+ struct berval bv = BER_BVNULL;
BerElement *ber;
printf( "Filter: %s\n", filter );
return EXIT_FAILURE;
}
- rc = ber_flatten( ber, &bv );
+ rc = ber_flatten2( ber, &bv, 0 );
if( rc < 0 ) {
- perror( "ber_flatten" );
+ perror( "ber_flatten2" );
return EXIT_FAILURE;
}
- printf( "BER encoding (len=%ld):\n", (long) bv->bv_len );
- ber_bprint( bv->bv_val, bv->bv_len );
+ printf( "BER encoding (len=%ld):\n", (long) bv.bv_len );
+ ber_bprint( bv.bv_val, bv.bv_len );
- ber_free( ber, 0 );
- ber_bvfree( bv );
+ ber_free( ber, 1 );
return EXIT_SUCCESS;
}