From bf5fc54473f2143586e43aada98ae8f5dab7570b Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 28 Dec 2001 03:39:05 +0000 Subject: [PATCH] Add ftest (filter test) to the mix, needs work. Misc cleanup of other tests. Add *.dsp files for tests --- libraries/libldap/dntest.c | 2 +- libraries/libldap/dntest.dsp | 143 +++++++++++++++++++++++++++++++++++ libraries/libldap/ftest.c | 112 +++++++++++++++++++++++++++ libraries/libldap/ftest.dsp | 143 +++++++++++++++++++++++++++++++++++ libraries/libldap/ldap-int.h | 7 +- libraries/libldap/search.c | 8 +- libraries/libldap/test.c | 2 +- 7 files changed, 408 insertions(+), 9 deletions(-) create mode 100644 libraries/libldap/dntest.dsp create mode 100644 libraries/libldap/ftest.c create mode 100644 libraries/libldap/ftest.dsp diff --git a/libraries/libldap/dntest.c b/libraries/libldap/dntest.c index ffbc28b4cc..0f92a5dc1c 100644 --- a/libraries/libldap/dntest.c +++ b/libraries/libldap/dntest.c @@ -4,7 +4,7 @@ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* - * OpenLDAP API Test + * OpenLDAP DN API Test * Written by: Pierangelo Masarati * * This program is designed to test the ldap_str2dn/ldap_dn2str diff --git a/libraries/libldap/dntest.dsp b/libraries/libldap/dntest.dsp new file mode 100644 index 0000000000..9b2c8f462f --- /dev/null +++ b/libraries/libldap/dntest.dsp @@ -0,0 +1,143 @@ +# Microsoft Developer Studio Project File - Name="dntest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=dntest - Win32 Single Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "dntest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "dntest.mak" CFG="dntest - Win32 Single Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "dntest - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "dntest - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "dntest - Win32 Single Release" (based on\ + "Win32 (x86) Console Application") +!MESSAGE "dntest - Win32 Single Debug" (based on\ + "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "dntest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\Release" +# PROP Intermediate_Dir "..\..\Release\dntest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\Release" + +!ELSEIF "$(CFG)" == "dntest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "dntest___" +# PROP BASE Intermediate_Dir "dntest___" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\Debug" +# PROP Intermediate_Dir "..\..\Debug\dntest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug" + +!ELSEIF "$(CFG)" == "dntest - Win32 Single Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "dntest___" +# PROP BASE Intermediate_Dir "dntest___" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\SRelease" +# PROP Intermediate_Dir "..\..\SRelease\dntest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 oldap32.lib olber32.lib olutil32.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\Release" +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\SRelease" + +!ELSEIF "$(CFG)" == "dntest - Win32 Single Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "dntest__0" +# PROP BASE Intermediate_Dir "dntest__0" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\SDebug" +# PROP Intermediate_Dir "..\..\SDebug\dntest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 oldap32.lib olber32.lib olutil32.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\Debug" +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\SDebug" + +!ENDIF + +# Begin Target + +# Name "dntest - Win32 Release" +# Name "dntest - Win32 Debug" +# Name "dntest - Win32 Single Release" +# Name "dntest - Win32 Single Debug" +# Begin Source File + +SOURCE=.\dntest.c +# End Source File +# End Target +# End Project diff --git a/libraries/libldap/ftest.c b/libraries/libldap/ftest.c new file mode 100644 index 0000000000..69c2a4f6fc --- /dev/null +++ b/libraries/libldap/ftest.c @@ -0,0 +1,112 @@ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* OpenLDAP Filter API Test */ + +#include "portable.h" + +#include +#include +#include + +#include + +#include + +#include "ldap-int.h" + +#include "ldif.h" +#include "lutil.h" +#include "lutil_ldap.h" +#include "ldap_defaults.h" + +static int filter2ber( const char *filter ); + +int usage() +{ + fprintf( stderr, "usage:\n" + " ftest [filter]" ); + return EXIT_FAILURE; +} + +int +main( int argc, char *argv[] ) +{ + int i, debug=0, ber=0; + char *filter=NULL; + + while( (i = getopt( argc, argv, "Aa:Ss:" + "bd:" )) != EOF ) + { + switch ( i ) { + case 'b': + ber++; + break; + case 'd': + debug = atoi( optarg ); + break; + default: + fprintf( stderr, "ftest: unrecognized option -%c\n", + optopt ); + return usage(); + } + } + + if ( debug ) { + if ( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug ) + != LBER_OPT_SUCCESS ) + { + fprintf( stderr, "Could not set LBER_OPT_DEBUG_LEVEL %d\n", + debug ); + } + if ( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug ) + != LDAP_OPT_SUCCESS ) + { + fprintf( stderr, "Could not set LDAP_OPT_DEBUG_LEVEL %d\n", + debug ); + } + } + + if( argc - optind > 1 ) { + return usage(); + } else if ( argc - optind == 1 ) { + if( ber ) { + fprintf( stderr, "ftest: parameter %s unexpected\n", + argv[optind] ); + return usage(); + } + return filter2ber( argv[optind] ); + } + + return EXIT_FAILURE; +} + +static int filter2ber( const char *filter ) +{ + int rc; + BerElement *ber = ber_alloc_t( LBER_USE_DER ); + struct berval *bv = NULL; + + if( ber == NULL ) { + perror( "ber_alloc_t" ); + return EXIT_FAILURE; + } + + rc = ldap_int_put_filter( ber, (char *) filter ); + + ber_dump( ber, 0 ); + + rc = ber_flatten( ber, &bv ); + + if( rc < 0 ) { + perror( "ber_flatten" ); + return EXIT_FAILURE; + } + + ber_free( ber, 1 ); + ber_bvfree( bv ); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/libraries/libldap/ftest.dsp b/libraries/libldap/ftest.dsp new file mode 100644 index 0000000000..6978494559 --- /dev/null +++ b/libraries/libldap/ftest.dsp @@ -0,0 +1,143 @@ +# Microsoft Developer Studio Project File - Name="ftest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=ftest - Win32 Single Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ftest.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ftest.mak" CFG="ltest - Win32 Single Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "ftest - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "ftest - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE "ftest - Win32 Single Release" (based on\ + "Win32 (x86) Console Application") +!MESSAGE "ftest - Win32 Single Debug" (based on\ + "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "ftest - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\Release" +# PROP Intermediate_Dir "..\..\Release\ftest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\Release" + +!ELSEIF "$(CFG)" == "ftest - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "ftest___" +# PROP BASE Intermediate_Dir "ftest___" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\Debug" +# PROP Intermediate_Dir "..\..\Debug\ftest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug" + +!ELSEIF "$(CFG)" == "ftest - Win32 Single Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ftest___" +# PROP BASE Intermediate_Dir "ftest___" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "..\..\SRelease" +# PROP Intermediate_Dir "..\..\SRelease\ftest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 oldap32.lib olber32.lib olutil32.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\Release" +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\SRelease" + +!ELSEIF "$(CFG)" == "ftest - Win32 Single Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "ftest__0" +# PROP BASE Intermediate_Dir "ftest__0" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "..\..\SDebug" +# PROP Intermediate_Dir "..\..\SDebug\ftest" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 oldap32.lib olber32.lib olutil32.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\Debug" +# ADD LINK32 libsasl.lib hs_regex.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\SDebug" + +!ENDIF + +# Begin Target + +# Name "ftest - Win32 Release" +# Name "ftest - Win32 Debug" +# Name "ftest - Win32 Single Release" +# Name "ftest - Win32 Single Debug" +# Begin Source File + +SOURCE=.\ftest.c +# End Source File +# End Target +# End Project diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index fc70d9daa8..d042c1b292 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -495,10 +495,9 @@ LDAP_F (BerElement *) ldap_build_search_req LDAP_P(( ber_int_t timelimit, ber_int_t sizelimit )); -/* - * in string.c - */ - /* see */ +LDAP_F( int ) ldap_int_put_filter LDAP_P(( + BerElement *ber, + char *str )); /* * in unbind.c diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 61273a0cde..c4a223dfe3 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -40,10 +40,12 @@ static char *put_complex_filter LDAP_P(( ber_tag_t tag, int not )); -static int put_filter LDAP_P(( +int ldap_int_put_filter LDAP_P(( BerElement *ber, char *str )); +#define put_filter(b,s) ldap_int_put_filter((b),(s)) + static int put_simple_filter LDAP_P(( BerElement *ber, char *str )); @@ -553,8 +555,8 @@ put_complex_filter( BerElement *ber, char *str, ber_tag_t tag, int not ) return( next ); } -static int -put_filter( BerElement *ber, char *str ) +int +ldap_int_put_filter( BerElement *ber, char *str ) { char *next; int parens, balance, escape; diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 4034243262..68b9cfdcf1 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -726,7 +726,7 @@ main( int argc, char **argv ) case '?': /* help */ printf( "Commands: [ad]d [ab]andon [b]ind\n" ); - printf( " [B]ind async [c]ompare [l]URL search\n" ); + printf( " [B]ind async [c]ompare\n" ); printf( " [modi]fy [modr]dn [rem]ove\n" ); printf( " [res]ult [s]earch [q]uit/unbind\n\n" ); printf( " [d]ebug [e]nable cache set ms[g]id\n" ); -- 2.39.5