Module: wine
Branch: master
Commit: 842987cd12057cfe757a4a1df03945840b4cf8c9
URL: https://source.winehq.org/git/wine.git/?a=commit;h=842987cd12057cfe757a4a1d…
Author: Hans Leidekker <hans(a)codeweavers.com>
Date: Tue Apr 6 15:46:53 2021 +0200
wldap32/tests: Add ber_printf/scanf tests.
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/wldap32/tests/Makefile.in | 1 +
dlls/wldap32/tests/ber.c | 72 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+)
diff --git a/dlls/wldap32/tests/Makefile.in b/dlls/wldap32/tests/Makefile.in
index 6df015083e8..05fe5b9af6d 100644
--- a/dlls/wldap32/tests/Makefile.in
+++ b/dlls/wldap32/tests/Makefile.in
@@ -2,4 +2,5 @@ TESTDLL = wldap32.dll
IMPORTS = wldap32
C_SRCS = \
+ ber.c \
parse.c
diff --git a/dlls/wldap32/tests/ber.c b/dlls/wldap32/tests/ber.c
new file mode 100644
index 00000000000..56d54fa6f5a
--- /dev/null
+++ b/dlls/wldap32/tests/ber.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2021 Hans Leidekker for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winldap.h>
+#include <winber.h>
+
+#include "wine/test.h"
+
+static void test_ber_printf(void)
+{
+ int ret;
+ BerElement *ber;
+ struct berval *bv;
+
+ ber = ber_alloc_t( 0 );
+ todo_wine ok( ber == NULL, "ber_alloc_t succeeded\n" );
+
+ ber = ber_alloc_t( LBER_USE_DER );
+ ok( ber != NULL, "ber_alloc_t failed\n" );
+
+ ret = ber_printf( ber, (char *)"{i}", -1 );
+ todo_wine ok( !ret, "got %d\n", ret );
+
+ ret = ber_flatten( ber, &bv );
+ ok( !ret, "got %d\n", ret );
+ todo_wine ok( bv->bv_len == 12, "got %d\n", bv->bv_len );
+ if (bv->bv_len == 12) ok( !memcmp( bv->bv_val, "0\x84\x00\x00\x00\x06\x02\x04\xff\xff\xff\xff", 12 ), "got %s\n",
+ wine_dbgstr_an(bv->bv_val, 12) );
+ ber_bvfree( bv );
+ ber_free( ber, 1 );
+}
+
+static void test_ber_scanf(void)
+{
+ int ret;
+ BerElement *ber;
+ struct berval bv = { 12, (char *)"0\x84\x00\x00\x00\x06\x02\x04\xff\xff\xff\xff" };
+ int i;
+
+ ber = ber_init( &bv );
+ ok( ber != NULL, "ber_init failed\n" );
+
+ i = 0;
+ ret = ber_scanf( ber, (char *)"{i}", &i );
+ ok( !ret, "got %d\n", ret );
+ ok( i == -1, "got %d\n", i );
+ ber_free( ber, 1 );
+}
+
+START_TEST(ber)
+{
+ test_ber_printf();
+ test_ber_scanf();
+}
Module: wine
Branch: master
Commit: 3f25be74fc3a2c8e1cbe6cf980d0e31b617064a7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3f25be74fc3a2c8e1cbe6cf9…
Author: Hans Leidekker <hans(a)codeweavers.com>
Date: Tue Apr 6 15:46:51 2021 +0200
include: Add winber.h.
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
include/winber.h | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/include/winber.h b/include/winber.h
new file mode 100644
index 00000000000..40ab0f40ed8
--- /dev/null
+++ b/include/winber.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2021 Hans Leidekker for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_WINBER_H
+#define __WINE_WINBER_H
+
+#define LBER_ERROR (~0L)
+#define LBER_DEFAULT (~0L)
+
+typedef int ber_int_t;
+typedef unsigned int ber_tag_t;
+typedef unsigned int ber_len_t;
+
+BerElement * CDECL ber_alloc_t( int );
+void CDECL ber_bvfree( BERVAL * );
+int CDECL ber_flatten( BerElement *, BERVAL ** );
+void CDECL ber_free( BerElement *, int );
+BerElement * CDECL ber_init( BERVAL * );
+int WINAPIV ber_printf( BerElement *, char *, ... );
+ULONG WINAPIV ber_scanf( BerElement *, char *, ... );
+
+#endif /* __WINE_WINBER_H */