Wine-Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 22 participants
- 84527 discussions
[PATCH v4 2/2] gdi32: Use a lazy-init lookup cache when converting RGB values to colour table indices.
by Huw Davies April 16, 2021
by Huw Davies April 16, 2021
April 16, 2021
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/gdi32/dibdrv/primitives.c | 57 ++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 13 deletions(-)
diff --git a/dlls/gdi32/dibdrv/primitives.c b/dlls/gdi32/dibdrv/primitives.c
index 31a9259e5f2..e4b18a6656d 100644
--- a/dlls/gdi32/dibdrv/primitives.c
+++ b/dlls/gdi32/dibdrv/primitives.c
@@ -3503,16 +3503,40 @@ static inline BOOL color_tables_match(const dib_info *d1, const dib_info *d2)
return !memcmp(d1->color_table, d2->color_table, (1 << d1->bit_count) * sizeof(d1->color_table[0]));
}
-static inline DWORD rgb_lookup_colortable(const dib_info *dst, BYTE r, BYTE g, BYTE b)
+/*
+ * To translate an RGB value into a colour table index Windows uses the 5 msbs of each component.
+ * We thus create a lookup table with 32^3 entries.
+ */
+struct rgb_lookup_colortable_ctx
+{
+ const dib_info *dib;
+ BYTE map[32 * 32 * 32];
+ BYTE valid[32 * 32 * 32 / 8];
+};
+
+static void rgb_lookup_colortable_init(const dib_info *dib, struct rgb_lookup_colortable_ctx *ctx)
{
- /* Windows reduces precision to 5 bits, probably in order to build some sort of lookup cache */
- return rgb_to_pixel_colortable( dst, (r & ~7) + 4, (g & ~7) + 4, (b & ~7) + 4 );
+ ctx->dib = dib;
+ memset(ctx->valid, 0, sizeof(ctx->valid));
+}
+
+static inline BYTE rgb_lookup_colortable(struct rgb_lookup_colortable_ctx *ctx, DWORD r, DWORD g, DWORD b)
+{
+ DWORD pos = ((r & 0xf8) >> 3) | ((g & 0xf8) << 2) | ((b & 0xf8) << 7);
+
+ if (!(ctx->valid[pos / 8] & pixel_masks_1[pos & 7]))
+ {
+ ctx->valid[pos / 8] |= pixel_masks_1[pos & 7];
+ ctx->map[pos] = rgb_to_pixel_colortable(ctx->dib, (r & 0xf8) | 4, (g & 0xf8) | 4, (b & 0xf8) | 4);
+ }
+ return ctx->map[pos];
}
static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rect, BOOL dither)
{
BYTE *dst_start = get_pixel_ptr_8(dst, 0, 0), *dst_pixel;
INT x, y, pad_size = ((dst->width + 3) & ~3) - (src_rect->right - src_rect->left);
+ struct rgb_lookup_colortable_ctx lookup_ctx;
DWORD src_val;
switch(src->bit_count)
@@ -3521,6 +3545,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
{
DWORD *src_start = get_pixel_ptr_32(src, src_rect->left, src_rect->top), *src_pixel;
+ rgb_lookup_colortable_init(dst, &lookup_ctx);
if(src->funcs == &funcs_8888)
{
for(y = src_rect->top; y < src_rect->bottom; y++)
@@ -3530,7 +3555,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst, src_val >> 16, src_val >> 8, src_val );
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx, src_val >> 16, src_val >> 8, src_val );
}
if(pad_size) memset(dst_pixel, 0, pad_size);
dst_start += dst->stride;
@@ -3546,7 +3571,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst,
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx,
src_val >> src->red_shift,
src_val >> src->green_shift,
src_val >> src->blue_shift );
@@ -3565,7 +3590,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst,
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx,
get_field(src_val, src->red_shift, src->red_len),
get_field(src_val, src->green_shift, src->green_len),
get_field(src_val, src->blue_shift, src->blue_len));
@@ -3582,13 +3607,14 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
{
BYTE *src_start = get_pixel_ptr_24(src, src_rect->left, src_rect->top), *src_pixel;
+ rgb_lookup_colortable_init(dst, &lookup_ctx);
for(y = src_rect->top; y < src_rect->bottom; y++)
{
dst_pixel = dst_start;
src_pixel = src_start;
for(x = src_rect->left; x < src_rect->right; x++, src_pixel += 3)
{
- *dst_pixel++ = rgb_lookup_colortable(dst, src_pixel[2], src_pixel[1], src_pixel[0] );
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx, src_pixel[2], src_pixel[1], src_pixel[0] );
}
if(pad_size) memset(dst_pixel, 0, pad_size);
dst_start += dst->stride;
@@ -3600,6 +3626,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
case 16:
{
WORD *src_start = get_pixel_ptr_16(src, src_rect->left, src_rect->top), *src_pixel;
+ rgb_lookup_colortable_init(dst, &lookup_ctx);
if(src->funcs == &funcs_555)
{
for(y = src_rect->top; y < src_rect->bottom; y++)
@@ -3609,7 +3636,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst,
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx,
((src_val >> 7) & 0xf8) | ((src_val >> 12) & 0x07),
((src_val >> 2) & 0xf8) | ((src_val >> 7) & 0x07),
((src_val << 3) & 0xf8) | ((src_val >> 2) & 0x07) );
@@ -3628,7 +3655,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst,
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx,
(((src_val >> src->red_shift) << 3) & 0xf8) |
(((src_val >> src->red_shift) >> 2) & 0x07),
(((src_val >> src->green_shift) << 3) & 0xf8) |
@@ -3650,7 +3677,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst,
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx,
(((src_val >> src->red_shift) << 3) & 0xf8) |
(((src_val >> src->red_shift) >> 2) & 0x07),
(((src_val >> src->green_shift) << 2) & 0xfc) |
@@ -3672,7 +3699,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
for(x = src_rect->left; x < src_rect->right; x++)
{
src_val = *src_pixel++;
- *dst_pixel++ = rgb_lookup_colortable(dst,
+ *dst_pixel++ = rgb_lookup_colortable(&lookup_ctx,
get_field(src_val, src->red_shift, src->red_len),
get_field(src_val, src->green_shift, src->green_len),
get_field(src_val, src->blue_shift, src->blue_len));
@@ -4802,8 +4829,10 @@ static void blend_rects_8(const dib_info *dst, int num, const RECT *rc,
const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
const RGBQUAD *color_table = get_dib_color_table( dst );
+ struct rgb_lookup_colortable_ctx lookup_ctx;
int i, x, y;
+ rgb_lookup_colortable_init( dst, &lookup_ctx );
for (i = 0; i < num; i++, rc++)
{
DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
@@ -4815,7 +4844,7 @@ static void blend_rects_8(const dib_info *dst, int num, const RECT *rc,
{
RGBQUAD rgb = color_table[dst_ptr[x]];
DWORD val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[x], blend );
- dst_ptr[x] = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
+ dst_ptr[x] = rgb_lookup_colortable( &lookup_ctx, val >> 16, val >> 8, val );
}
}
}
@@ -4825,8 +4854,10 @@ static void blend_rects_4(const dib_info *dst, int num, const RECT *rc,
const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
const RGBQUAD *color_table = get_dib_color_table( dst );
+ struct rgb_lookup_colortable_ctx lookup_ctx;
int i, j, x, y;
+ rgb_lookup_colortable_init( dst, &lookup_ctx );
for (i = 0; i < num; i++, rc++)
{
DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
@@ -4839,7 +4870,7 @@ static void blend_rects_4(const dib_info *dst, int num, const RECT *rc,
DWORD val = ((x & 1) ? dst_ptr[x / 2] : (dst_ptr[x / 2] >> 4)) & 0x0f;
RGBQUAD rgb = color_table[val];
val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[j], blend );
- val = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
+ val = rgb_lookup_colortable( &lookup_ctx, val >> 16, val >> 8, val );
if (x & 1)
dst_ptr[x / 2] = val | (dst_ptr[x / 2] & 0xf0);
else
--
2.23.0
1
0
[PATCH v4 1/2] gdi32: Move the loop through each clipped rectangle to the primitive blend funcs.
by Huw Davies April 16, 2021
by Huw Davies April 16, 2021
April 16, 2021
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
This is to prepare so we don't recalculate the lookup cache map for color
tables on every clipped rect (which is expensive).
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com>
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/gdi32/dibdrv/bitblt.c | 14 +-
dlls/gdi32/dibdrv/dibdrv.h | 4 +-
dlls/gdi32/dibdrv/primitives.c | 294 ++++++++++++++++++---------------
3 files changed, 171 insertions(+), 141 deletions(-)
diff --git a/dlls/gdi32/dibdrv/bitblt.c b/dlls/gdi32/dibdrv/bitblt.c
index 8f675354716..d2f59965b02 100644
--- a/dlls/gdi32/dibdrv/bitblt.c
+++ b/dlls/gdi32/dibdrv/bitblt.c
@@ -584,17 +584,15 @@ static void mask_rect( dib_info *dst, const RECT *dst_rect, const dib_info *src,
static DWORD blend_rect( dib_info *dst, const RECT *dst_rect, const dib_info *src, const RECT *src_rect,
HRGN clip, BLENDFUNCTION blend )
{
- POINT origin;
+ POINT offset;
struct clipped_rects clipped_rects;
- int i;
if (!get_clipped_rects( dst, dst_rect, clip, &clipped_rects )) return ERROR_SUCCESS;
- for (i = 0; i < clipped_rects.count; i++)
- {
- origin.x = src_rect->left + clipped_rects.rects[i].left - dst_rect->left;
- origin.y = src_rect->top + clipped_rects.rects[i].top - dst_rect->top;
- dst->funcs->blend_rect( dst, &clipped_rects.rects[i], src, &origin, blend );
- }
+
+ offset.x = src_rect->left - dst_rect->left;
+ offset.y = src_rect->top - dst_rect->top;
+ dst->funcs->blend_rects( dst, clipped_rects.count, clipped_rects.rects, src, &offset, blend );
+
free_clipped_rects( &clipped_rects );
return ERROR_SUCCESS;
}
diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index 88b4c62d023..d3a35b96c75 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -189,8 +189,8 @@ typedef struct primitive_funcs
const dib_info *brush, const rop_mask_bits *bits);
void (* copy_rect)(const dib_info *dst, const RECT *rc, const dib_info *src,
const POINT *origin, int rop2, int overlap);
- void (* blend_rect)(const dib_info *dst, const RECT *rc, const dib_info *src,
- const POINT *origin, BLENDFUNCTION blend);
+ void (* blend_rects)(const dib_info *dst, int num, const RECT *rc, const dib_info *src,
+ const POINT *offset, BLENDFUNCTION blend);
BOOL (* gradient_rect)(const dib_info *dib, const RECT *rc, const TRIVERTEX *v, int mode);
void (* mask_rect)(const dib_info *dst, const RECT *rc, const dib_info *src,
const POINT *origin, int rop2);
diff --git a/dlls/gdi32/dibdrv/primitives.c b/dlls/gdi32/dibdrv/primitives.c
index 01a1c7c1d83..31a9259e5f2 100644
--- a/dlls/gdi32/dibdrv/primitives.c
+++ b/dlls/gdi32/dibdrv/primitives.c
@@ -4651,199 +4651,231 @@ static inline DWORD blend_rgb( BYTE dst_r, BYTE dst_g, BYTE dst_b, DWORD src, BL
blend_color( dst_r, src >> 16, blend.SourceConstantAlpha ) << 16);
}
-static void blend_rect_8888(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_8888(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- DWORD *dst_ptr = get_pixel_ptr_32( dst, rc->left, rc->top );
- int x, y;
+ int i, x, y;
- if (blend.AlphaFormat & AC_SRC_ALPHA)
+ for (i = 0; i < num; i++, rc++)
{
- if (blend.SourceConstantAlpha == 255)
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
- for (x = 0; x < rc->right - rc->left; x++)
- dst_ptr[x] = blend_argb( dst_ptr[x], src_ptr[x] );
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ DWORD *dst_ptr = get_pixel_ptr_32( dst, rc->left, rc->top );
+
+ if (blend.AlphaFormat & AC_SRC_ALPHA)
+ {
+ if (blend.SourceConstantAlpha == 255)
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
+ for (x = 0; x < rc->right - rc->left; x++)
+ dst_ptr[x] = blend_argb( dst_ptr[x], src_ptr[x] );
+ else
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
+ for (x = 0; x < rc->right - rc->left; x++)
+ dst_ptr[x] = blend_argb_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
+ }
+ else if (src->compression == BI_RGB)
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
+ for (x = 0; x < rc->right - rc->left; x++)
+ dst_ptr[x] = blend_argb_constant_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
else
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
- for (x = 0; x < rc->right - rc->left; x++)
- dst_ptr[x] = blend_argb_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
- }
- else if (src->compression == BI_RGB)
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
- for (x = 0; x < rc->right - rc->left; x++)
- dst_ptr[x] = blend_argb_constant_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
- else
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
- for (x = 0; x < rc->right - rc->left; x++)
- dst_ptr[x] = blend_argb_no_src_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
+ for (x = 0; x < rc->right - rc->left; x++)
+ dst_ptr[x] = blend_argb_no_src_alpha( dst_ptr[x], src_ptr[x], blend.SourceConstantAlpha );
+ }
}
-static void blend_rect_32(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_32(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- DWORD *dst_ptr = get_pixel_ptr_32( dst, rc->left, rc->top );
- int x, y;
+ int i, x, y;
- if (dst->red_len == 8 && dst->green_len == 8 && dst->blue_len == 8)
+ for (i = 0; i < num; i++, rc++)
{
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ DWORD *dst_ptr = get_pixel_ptr_32( dst, rc->left, rc->top );
+
+ if (dst->red_len == 8 && dst->green_len == 8 && dst->blue_len == 8)
{
- for (x = 0; x < rc->right - rc->left; x++)
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
{
- DWORD val = blend_rgb( dst_ptr[x] >> dst->red_shift,
- dst_ptr[x] >> dst->green_shift,
- dst_ptr[x] >> dst->blue_shift,
- src_ptr[x], blend );
- dst_ptr[x] = ((( val & 0xff) << dst->blue_shift) |
- (((val >> 8) & 0xff) << dst->green_shift) |
- (((val >> 16) & 0xff) << dst->red_shift));
+ for (x = 0; x < rc->right - rc->left; x++)
+ {
+ DWORD val = blend_rgb( dst_ptr[x] >> dst->red_shift,
+ dst_ptr[x] >> dst->green_shift,
+ dst_ptr[x] >> dst->blue_shift,
+ src_ptr[x], blend );
+ dst_ptr[x] = ((( val & 0xff) << dst->blue_shift) |
+ (((val >> 8) & 0xff) << dst->green_shift) |
+ (((val >> 16) & 0xff) << dst->red_shift));
+ }
}
}
- }
- else
- {
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
+ else
{
- for (x = 0; x < rc->right - rc->left; x++)
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 4, src_ptr += src->stride / 4)
{
- DWORD val = blend_rgb( get_field( dst_ptr[x], dst->red_shift, dst->red_len ),
- get_field( dst_ptr[x], dst->green_shift, dst->green_len ),
- get_field( dst_ptr[x], dst->blue_shift, dst->blue_len ),
- src_ptr[x], blend );
- dst_ptr[x] = rgb_to_pixel_masks( dst, val >> 16, val >> 8, val );
+ for (x = 0; x < rc->right - rc->left; x++)
+ {
+ DWORD val = blend_rgb( get_field( dst_ptr[x], dst->red_shift, dst->red_len ),
+ get_field( dst_ptr[x], dst->green_shift, dst->green_len ),
+ get_field( dst_ptr[x], dst->blue_shift, dst->blue_len ),
+ src_ptr[x], blend );
+ dst_ptr[x] = rgb_to_pixel_masks( dst, val >> 16, val >> 8, val );
+ }
}
}
}
}
-static void blend_rect_24(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_24(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- BYTE *dst_ptr = get_pixel_ptr_24( dst, rc->left, rc->top );
- int x, y;
+ int i, x, y;
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
+ for (i = 0; i < num; i++, rc++)
{
- for (x = 0; x < rc->right - rc->left; x++)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ BYTE *dst_ptr = get_pixel_ptr_24( dst, rc->left, rc->top );
+
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
{
- DWORD val = blend_rgb( dst_ptr[x * 3 + 2], dst_ptr[x * 3 + 1], dst_ptr[x * 3],
- src_ptr[x], blend );
- dst_ptr[x * 3] = val;
- dst_ptr[x * 3 + 1] = val >> 8;
- dst_ptr[x * 3 + 2] = val >> 16;
+ for (x = 0; x < rc->right - rc->left; x++)
+ {
+ DWORD val = blend_rgb( dst_ptr[x * 3 + 2], dst_ptr[x * 3 + 1], dst_ptr[x * 3],
+ src_ptr[x], blend );
+ dst_ptr[x * 3] = val;
+ dst_ptr[x * 3 + 1] = val >> 8;
+ dst_ptr[x * 3 + 2] = val >> 16;
+ }
}
}
}
-static void blend_rect_555(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_555(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- WORD *dst_ptr = get_pixel_ptr_16( dst, rc->left, rc->top );
- int x, y;
+ int i, x, y;
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 2, src_ptr += src->stride / 4)
+ for (i = 0; i < num; i++, rc++)
{
- for (x = 0; x < rc->right - rc->left; x++)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ WORD *dst_ptr = get_pixel_ptr_16( dst, rc->left, rc->top );
+
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 2, src_ptr += src->stride / 4)
{
- DWORD val = blend_rgb( ((dst_ptr[x] >> 7) & 0xf8) | ((dst_ptr[x] >> 12) & 0x07),
- ((dst_ptr[x] >> 2) & 0xf8) | ((dst_ptr[x] >> 7) & 0x07),
- ((dst_ptr[x] << 3) & 0xf8) | ((dst_ptr[x] >> 2) & 0x07),
- src_ptr[x], blend );
- dst_ptr[x] = ((val >> 9) & 0x7c00) | ((val >> 6) & 0x03e0) | ((val >> 3) & 0x001f);
+ for (x = 0; x < rc->right - rc->left; x++)
+ {
+ DWORD val = blend_rgb( ((dst_ptr[x] >> 7) & 0xf8) | ((dst_ptr[x] >> 12) & 0x07),
+ ((dst_ptr[x] >> 2) & 0xf8) | ((dst_ptr[x] >> 7) & 0x07),
+ ((dst_ptr[x] << 3) & 0xf8) | ((dst_ptr[x] >> 2) & 0x07),
+ src_ptr[x], blend );
+ dst_ptr[x] = ((val >> 9) & 0x7c00) | ((val >> 6) & 0x03e0) | ((val >> 3) & 0x001f);
+ }
}
}
}
-static void blend_rect_16(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_16(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- WORD *dst_ptr = get_pixel_ptr_16( dst, rc->left, rc->top );
- int x, y;
+ int i, x, y;
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 2, src_ptr += src->stride / 4)
+ for (i = 0; i < num; i++, rc++)
{
- for (x = 0; x < rc->right - rc->left; x++)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ WORD *dst_ptr = get_pixel_ptr_16( dst, rc->left, rc->top );
+
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride / 2, src_ptr += src->stride / 4)
{
- DWORD val = blend_rgb( get_field( dst_ptr[x], dst->red_shift, dst->red_len ),
- get_field( dst_ptr[x], dst->green_shift, dst->green_len ),
- get_field( dst_ptr[x], dst->blue_shift, dst->blue_len ),
- src_ptr[x], blend );
- dst_ptr[x] = rgb_to_pixel_masks( dst, val >> 16, val >> 8, val );
+ for (x = 0; x < rc->right - rc->left; x++)
+ {
+ DWORD val = blend_rgb( get_field( dst_ptr[x], dst->red_shift, dst->red_len ),
+ get_field( dst_ptr[x], dst->green_shift, dst->green_len ),
+ get_field( dst_ptr[x], dst->blue_shift, dst->blue_len ),
+ src_ptr[x], blend );
+ dst_ptr[x] = rgb_to_pixel_masks( dst, val >> 16, val >> 8, val );
+ }
}
}
}
-static void blend_rect_8(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_8(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
const RGBQUAD *color_table = get_dib_color_table( dst );
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- BYTE *dst_ptr = get_pixel_ptr_8( dst, rc->left, rc->top );
- int x, y;
+ int i, x, y;
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
+ for (i = 0; i < num; i++, rc++)
{
- for (x = 0; x < rc->right - rc->left; x++)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ BYTE *dst_ptr = get_pixel_ptr_8( dst, rc->left, rc->top );
+
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
{
- RGBQUAD rgb = color_table[dst_ptr[x]];
- DWORD val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[x], blend );
- dst_ptr[x] = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
+ for (x = 0; x < rc->right - rc->left; x++)
+ {
+ RGBQUAD rgb = color_table[dst_ptr[x]];
+ DWORD val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[x], blend );
+ dst_ptr[x] = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
+ }
}
}
}
-static void blend_rect_4(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_4(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
const RGBQUAD *color_table = get_dib_color_table( dst );
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- BYTE *dst_ptr = get_pixel_ptr_4( dst, rc->left, rc->top );
- int i, x, y;
+ int i, j, x, y;
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
+ for (i = 0; i < num; i++, rc++)
{
- for (i = 0, x = (dst->rect.left + rc->left) & 1; i < rc->right - rc->left; i++, x++)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ BYTE *dst_ptr = get_pixel_ptr_4( dst, rc->left, rc->top );
+
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
{
- DWORD val = ((x & 1) ? dst_ptr[x / 2] : (dst_ptr[x / 2] >> 4)) & 0x0f;
- RGBQUAD rgb = color_table[val];
- val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[i], blend );
- val = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
- if (x & 1)
- dst_ptr[x / 2] = val | (dst_ptr[x / 2] & 0xf0);
- else
- dst_ptr[x / 2] = (val << 4) | (dst_ptr[x / 2] & 0x0f);
+ for (j = 0, x = (dst->rect.left + rc->left) & 1; j < rc->right - rc->left; j++, x++)
+ {
+ DWORD val = ((x & 1) ? dst_ptr[x / 2] : (dst_ptr[x / 2] >> 4)) & 0x0f;
+ RGBQUAD rgb = color_table[val];
+ val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[j], blend );
+ val = rgb_lookup_colortable( dst, val >> 16, val >> 8, val );
+ if (x & 1)
+ dst_ptr[x / 2] = val | (dst_ptr[x / 2] & 0xf0);
+ else
+ dst_ptr[x / 2] = (val << 4) | (dst_ptr[x / 2] & 0x0f);
+ }
}
}
}
-static void blend_rect_1(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_1(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
const RGBQUAD *color_table = get_dib_color_table( dst );
- DWORD *src_ptr = get_pixel_ptr_32( src, origin->x, origin->y );
- BYTE *dst_ptr = get_pixel_ptr_1( dst, rc->left, rc->top );
- int i, x, y;
+ int i, j, x, y;
- for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
+ for (i = 0; i < num; i++, rc++)
{
- for (i = 0, x = (dst->rect.left + rc->left) & 7; i < rc->right - rc->left; i++, x++)
+ DWORD *src_ptr = get_pixel_ptr_32( src, rc->left + offset->x, rc->top + offset->y );
+ BYTE *dst_ptr = get_pixel_ptr_1( dst, rc->left, rc->top );
+
+ for (y = rc->top; y < rc->bottom; y++, dst_ptr += dst->stride, src_ptr += src->stride / 4)
{
- DWORD val = (dst_ptr[x / 8] & pixel_masks_1[x % 8]) ? 1 : 0;
- RGBQUAD rgb = color_table[val];
- val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[i], blend );
- val = rgb_to_pixel_colortable(dst, val >> 16, val >> 8, val) ? 0xff : 0;
- dst_ptr[x / 8] = (dst_ptr[x / 8] & ~pixel_masks_1[x % 8]) | (val & pixel_masks_1[x % 8]);
+ for (j = 0, x = (dst->rect.left + rc->left) & 7; j < rc->right - rc->left; j++, x++)
+ {
+ DWORD val = (dst_ptr[x / 8] & pixel_masks_1[x % 8]) ? 1 : 0;
+ RGBQUAD rgb = color_table[val];
+ val = blend_rgb( rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue, src_ptr[j], blend );
+ val = rgb_to_pixel_colortable(dst, val >> 16, val >> 8, val) ? 0xff : 0;
+ dst_ptr[x / 8] = (dst_ptr[x / 8] & ~pixel_masks_1[x % 8]) | (val & pixel_masks_1[x % 8]);
+ }
}
}
}
-static void blend_rect_null(const dib_info *dst, const RECT *rc,
- const dib_info *src, const POINT *origin, BLENDFUNCTION blend)
+static void blend_rects_null(const dib_info *dst, int num, const RECT *rc,
+ const dib_info *src, const POINT *offset, BLENDFUNCTION blend)
{
}
@@ -7373,7 +7405,7 @@ const primitive_funcs funcs_8888 =
solid_line_32,
pattern_rects_32,
copy_rect_32,
- blend_rect_8888,
+ blend_rects_8888,
gradient_rect_8888,
mask_rect_32,
draw_glyph_8888,
@@ -7394,7 +7426,7 @@ const primitive_funcs funcs_32 =
solid_line_32,
pattern_rects_32,
copy_rect_32,
- blend_rect_32,
+ blend_rects_32,
gradient_rect_32,
mask_rect_32,
draw_glyph_32,
@@ -7415,7 +7447,7 @@ const primitive_funcs funcs_24 =
solid_line_24,
pattern_rects_24,
copy_rect_24,
- blend_rect_24,
+ blend_rects_24,
gradient_rect_24,
mask_rect_24,
draw_glyph_24,
@@ -7436,7 +7468,7 @@ const primitive_funcs funcs_555 =
solid_line_16,
pattern_rects_16,
copy_rect_16,
- blend_rect_555,
+ blend_rects_555,
gradient_rect_555,
mask_rect_16,
draw_glyph_555,
@@ -7457,7 +7489,7 @@ const primitive_funcs funcs_16 =
solid_line_16,
pattern_rects_16,
copy_rect_16,
- blend_rect_16,
+ blend_rects_16,
gradient_rect_16,
mask_rect_16,
draw_glyph_16,
@@ -7478,7 +7510,7 @@ const primitive_funcs funcs_8 =
solid_line_8,
pattern_rects_8,
copy_rect_8,
- blend_rect_8,
+ blend_rects_8,
gradient_rect_8,
mask_rect_8,
draw_glyph_8,
@@ -7499,7 +7531,7 @@ const primitive_funcs funcs_4 =
solid_line_4,
pattern_rects_4,
copy_rect_4,
- blend_rect_4,
+ blend_rects_4,
gradient_rect_4,
mask_rect_4,
draw_glyph_4,
@@ -7520,7 +7552,7 @@ const primitive_funcs funcs_1 =
solid_line_1,
pattern_rects_1,
copy_rect_1,
- blend_rect_1,
+ blend_rects_1,
gradient_rect_1,
mask_rect_null,
draw_glyph_1,
@@ -7541,7 +7573,7 @@ const primitive_funcs funcs_null =
solid_line_null,
pattern_rects_null,
copy_rect_null,
- blend_rect_null,
+ blend_rects_null,
gradient_rect_null,
mask_rect_null,
draw_glyph_null,
--
2.23.0
1
0
[PATCH 1/2] reg/tests: Only pass a newly created HKEY if it is used in later tests
by Hugh McMaster April 16, 2021
by Hugh McMaster April 16, 2021
April 16, 2021
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
---
programs/reg/tests/add.c | 13 +++++++++----
programs/reg/tests/delete.c | 8 +++-----
programs/reg/tests/export.c | 9 +++------
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c
index 8357e9ad0bc..e62caeade01 100644
--- a/programs/reg/tests/add.c
+++ b/programs/reg/tests/add.c
@@ -126,10 +126,16 @@ void verify_key_nonexist_(const char *file, unsigned line, HKEY key_base, const
void add_key_(const char *file, unsigned line, const HKEY hkey, const char *path, HKEY *subkey)
{
LONG err;
+ HKEY new_key;
err = RegCreateKeyExA(hkey, path, 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_READ|KEY_WRITE, NULL, subkey, NULL);
+ KEY_READ|KEY_WRITE, NULL, &new_key, NULL);
lok(err == ERROR_SUCCESS, "RegCreateKeyExA failed: %d\n", err);
+
+ if (subkey)
+ *subkey = new_key;
+ else
+ RegCloseKey(new_key);
}
void delete_key_(const char *file, unsigned line, const HKEY hkey, const char *path)
@@ -315,7 +321,7 @@ static void test_key_formats(void)
static void test_add(void)
{
- HKEY hkey, hsubkey;
+ HKEY hkey;
DWORD r, dword;
run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
@@ -324,8 +330,7 @@ static void test_add(void)
open_key(HKEY_CURRENT_USER, KEY_BASE, KEY_WRITE, &hkey);
/* Test whether overwriting a registry key modifies existing keys and values */
- add_key(hkey, "Subkey", &hsubkey);
- close_key(hsubkey);
+ add_key(hkey, "Subkey", NULL);
add_value(hkey, "Test1", REG_SZ, "Value1", 7);
dword = 0x123;
add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword));
diff --git a/programs/reg/tests/delete.c b/programs/reg/tests/delete.c
index 77d95d013c9..575c393d2b3 100644
--- a/programs/reg/tests/delete.c
+++ b/programs/reg/tests/delete.c
@@ -21,7 +21,7 @@
static void test_delete(void)
{
- HKEY hkey, hsubkey;
+ HKEY hkey;
DWORD r;
const DWORD deadbeef = 0xdeadbeef;
@@ -75,8 +75,7 @@ static void test_delete(void)
add_value(hkey, "bar", REG_DWORD, &deadbeef, sizeof(deadbeef));
add_value(hkey, NULL, REG_DWORD, &deadbeef, sizeof(deadbeef));
- add_key(hkey, "subkey", &hsubkey);
- close_key(hsubkey);
+ add_key(hkey, "subkey", NULL);
run_reg_exe("reg delete HKCU\\" KEY_BASE " /v bar /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -92,8 +91,7 @@ static void test_delete(void)
verify_key(hkey, "subkey");
/* Test forward and back slashes */
- add_key(hkey, "https://winehq.org", &hsubkey);
- close_key(hsubkey);
+ add_key(hkey, "https://winehq.org", NULL);
add_value(hkey, "count/up", REG_SZ, "one/two/three", 14);
add_value(hkey, "\\foo\\bar", REG_SZ, "", 1);
diff --git a/programs/reg/tests/export.c b/programs/reg/tests/export.c
index 4e5ac4c71d9..daf42f66e3e 100644
--- a/programs/reg/tests/export.c
+++ b/programs/reg/tests/export.c
@@ -291,10 +291,8 @@ static void test_export(void)
/* Test the export order of registry keys */
add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- add_key(hkey, "Subkey2", &subkey);
- close_key(subkey);
- add_key(hkey, "Subkey1", &subkey);
- close_key(subkey);
+ add_key(hkey, "Subkey2", NULL);
+ add_key(hkey, "Subkey1", NULL);
run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -405,8 +403,7 @@ static void test_export(void)
/* Test registry export with forward and back slashes */
add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- add_key(hkey, "https://winehq.org", &subkey);
- close_key(subkey);
+ add_key(hkey, "https://winehq.org", NULL);
add_value(hkey, "count/up", REG_SZ, "one/two/three", 14);
add_value(hkey, "\\foo\\bar", REG_SZ, "", 1);
close_key(hkey);
--
2.31.0
1
1
April 16, 2021
Signed-off-by: Jan Sikorski <jsikorski(a)codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 89 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index c499aa5f75b..f0da87bc0bd 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -17157,6 +17157,94 @@ static void test_shader_stage_input_output_matching(void)
release_test_context(&test_context);
}
+static void test_unbound_streams(void)
+{
+ struct d3d11_test_context test_context;
+ ID3D11DeviceContext *context;
+ ID3D11PixelShader *ps;
+ ID3D11Device *device;
+ HRESULT hr;
+
+ static const DWORD vs_code[] =
+ {
+#if 0
+ struct vs_ps
+ {
+ float4 position : SV_POSITION;
+ float4 color : COLOR0;
+ };
+
+ vs_ps vs_main(float4 position : POSITION, float4 color : COLOR0)
+ {
+ vs_ps result;
+ result.position = position;
+ result.color = color;
+ result.color.w = 1.0;
+ return result;
+ }
+#endif
+ 0x43425844, 0x4a9efaec, 0xe2c6cdf5, 0x15dd28a7, 0xae68e320, 0x00000001, 0x00000154, 0x00000003,
+ 0x0000002c, 0x0000007c, 0x000000d0, 0x4e475349, 0x00000048, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000041, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x0000070f, 0x49534f50, 0x4e4f4954, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, 0x00000000,
+ 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x505f5653,
+ 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x0000007c, 0x00010040, 0x0000001f,
+ 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x00101072, 0x00000001, 0x04000067, 0x001020f2,
+ 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, 0x00000000,
+ 0x00101e46, 0x00000000, 0x05000036, 0x00102072, 0x00000001, 0x00101246, 0x00000001, 0x05000036,
+ 0x00102082, 0x00000001, 0x00004001, 0x3f800000, 0x0100003e,
+ };
+
+ static const DWORD ps_code[] =
+ {
+#if 0
+ float4 ps_main(vs_ps input) : SV_TARGET
+ {
+ return input.color;
+ }
+#endif
+ 0x43425844, 0xe2087fa6, 0xa35fbd95, 0x8e585b3f, 0x67890f54, 0x00000001, 0x000000f4, 0x00000003,
+ 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038,
+ 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052,
+ 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054, 0x52444853, 0x00000038, 0x00000040,
+ 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
+ 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e,
+ };
+
+ static const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+
+ static const D3D11_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ };
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps);
+ ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
+
+ hr = ID3D11Device_CreateInputLayout(device, layout_desc, ARRAY_SIZE(layout_desc),
+ vs_code, sizeof(vs_code), &test_context.input_layout);
+ ok(SUCCEEDED(hr), "Failed to create input layout, hr %#x.\n", hr);
+
+ ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_quad_vs(&test_context, vs_code, sizeof(vs_code));
+ check_texture_color(test_context.backbuffer, 0xff000000, 1);
+
+ ID3D11PixelShader_Release(ps);
+ ID3D11InputLayout_Release(test_context.input_layout);
+ release_test_context(&test_context);
+}
+
static void test_shader_interstage_interface(void)
{
struct d3d11_test_context test_context;
@@ -32520,6 +32608,7 @@ START_TEST(d3d11)
queue_test(test_deferred_context_state);
queue_test(test_deferred_context_swap_state);
queue_test(test_deferred_context_rendering);
+ queue_test(test_unbound_streams);
run_queued_tests();
}
--
2.31.0
2
7
[PATCH 5/5] wldap32: Move support for page functions to the Unix library.
by Hans Leidekker April 16, 2021
by Hans Leidekker April 16, 2021
April 16, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/ber.c | 2 +-
dlls/wldap32/page.c | 281 +++++++++++----------------------
dlls/wldap32/winldap_private.h | 76 +++++++++
3 files changed, 169 insertions(+), 190 deletions(-)
diff --git a/dlls/wldap32/ber.c b/dlls/wldap32/ber.c
index ae5e9292e04..c6dca7153a2 100644
--- a/dlls/wldap32/ber.c
+++ b/dlls/wldap32/ber.c
@@ -413,7 +413,7 @@ int WINAPIV WLDAP32_ber_printf( WLDAP32_BerElement *ber, char *fmt, ... )
* berelement must have been allocated with ber_init. This function
* can be called multiple times to decode data.
*/
-int WINAPIV WLDAP32_ber_scanf( WLDAP32_BerElement *ber, char *fmt, ... )
+ULONG WINAPIV WLDAP32_ber_scanf( WLDAP32_BerElement *ber, char *fmt, ... )
{
__ms_va_list list;
int ret = 0;
diff --git a/dlls/wldap32/page.c b/dlls/wldap32/page.c
index 07f29be0d50..5364280f271 100644
--- a/dlls/wldap32/page.c
+++ b/dlls/wldap32/page.c
@@ -18,31 +18,20 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-#ifndef LDAP_MAXINT
-#define LDAP_MAXINT 2147483647
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "wine/heap.h"
+#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#ifdef HAVE_LDAP
-static struct berval null_cookieU = { 0, NULL };
+#define LDAP_MAXINT (2^31)
+
static struct WLDAP32_berval null_cookieW = { 0, NULL };
-#endif
/***********************************************************************
* ldap_create_page_controlA (WLDAP32.@)
@@ -50,84 +39,73 @@ static struct WLDAP32_berval null_cookieW = { 0, NULL };
* See ldap_create_page_controlW.
*/
ULONG CDECL ldap_create_page_controlA( WLDAP32_LDAP *ld, ULONG pagesize,
- struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlA *control )
+ struct WLDAP32_berval *cookie, UCHAR critical, LDAPControlA **control )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
LDAPControlW *controlW = NULL;
- TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie,
- critical, control );
+ TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, critical, control );
- if (!ld || !control || pagesize > LDAP_MAXINT)
- return WLDAP32_LDAP_PARAM_ERROR;
+ if (!ld || !control || pagesize > LDAP_MAXINT) return WLDAP32_LDAP_PARAM_ERROR;
ret = ldap_create_page_controlW( ld, pagesize, cookie, critical, &controlW );
- if (ret == LDAP_SUCCESS)
+ if (ret == WLDAP32_LDAP_SUCCESS)
{
*control = controlWtoA( controlW );
ldap_control_freeW( controlW );
}
-
-#endif
return ret;
}
-#ifdef HAVE_LDAP
-
/* create a page control by hand */
-static ULONG create_page_control( ULONG pagesize, struct berval *cookie,
- UCHAR critical, PLDAPControlW *control )
+static ULONG create_page_control( ULONG pagesize, struct WLDAP32_berval *cookie, UCHAR critical, LDAPControlW **control )
{
LDAPControlW *ctrl;
- BerElement *ber;
- ber_tag_t tag;
- struct berval *berval;
- INT ret, len;
+ WLDAP32_BerElement *ber;
+ struct WLDAP32_berval *berval, *vec[2];
+ int ret, len;
char *val;
- ber = ber_alloc_t( LBER_USE_DER );
- if (!ber) return WLDAP32_LDAP_NO_MEMORY;
+ if (!(ber = WLDAP32_ber_alloc_t( WLDAP32_LBER_USE_DER ))) return WLDAP32_LDAP_NO_MEMORY;
+ vec[1] = NULL;
if (cookie)
- tag = ber_printf( ber, "{iO}", (ber_int_t)pagesize, cookie );
+ vec[0] = cookie;
else
- tag = ber_printf( ber, "{iO}", (ber_int_t)pagesize, &null_cookieU );
+ vec[0] = &null_cookieW;
+ len = WLDAP32_ber_printf( ber, (char *)"{iV}", pagesize, vec );
- ret = ber_flatten( ber, &berval );
- ber_free( ber, 1 );
+ ret = WLDAP32_ber_flatten( ber, &berval );
+ WLDAP32_ber_free( ber, 1 );
- if (tag == LBER_ERROR)
- return WLDAP32_LDAP_ENCODING_ERROR;
-
- if (ret == -1)
- return WLDAP32_LDAP_NO_MEMORY;
+ if (len == WLDAP32_LBER_ERROR) return WLDAP32_LDAP_ENCODING_ERROR;
+ if (ret == -1) return WLDAP32_LDAP_NO_MEMORY;
/* copy the berval so it can be properly freed by the caller */
if (!(val = heap_alloc( berval->bv_len ))) return WLDAP32_LDAP_NO_MEMORY;
len = berval->bv_len;
memcpy( val, berval->bv_val, len );
- ber_bvfree( berval );
+ WLDAP32_ber_bvfree( berval );
- if (!(ctrl = heap_alloc( sizeof(LDAPControlW) )))
+ if (!(ctrl = heap_alloc( sizeof(*ctrl) )))
{
heap_free( val );
return WLDAP32_LDAP_NO_MEMORY;
}
-
- ctrl->ldctl_oid = strAtoW( LDAP_PAGED_RESULT_OID_STRING );
+ if (!(ctrl->ldctl_oid = strAtoW( LDAP_PAGED_RESULT_OID_STRING )))
+ {
+ heap_free( ctrl );
+ return WLDAP32_LDAP_NO_MEMORY;
+ }
ctrl->ldctl_value.bv_len = len;
ctrl->ldctl_value.bv_val = val;
- ctrl->ldctl_iscritical = critical;
+ ctrl->ldctl_iscritical = critical;
*control = ctrl;
-
return WLDAP32_LDAP_SUCCESS;
}
-#endif /* HAVE_LDAP */
-
/***********************************************************************
* ldap_create_page_controlW (WLDAP32.@)
*
@@ -146,31 +124,16 @@ static ULONG create_page_control( ULONG pagesize, struct berval *cookie,
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_create_page_controlW( WLDAP32_LDAP *ld, ULONG pagesize,
- struct WLDAP32_berval *cookie, UCHAR critical, PLDAPControlW *control )
+ULONG CDECL ldap_create_page_controlW( WLDAP32_LDAP *ld, ULONG pagesize, struct WLDAP32_berval *cookie,
+ UCHAR critical, LDAPControlW **control )
{
-#ifdef HAVE_LDAP
- struct berval *cookieU = NULL;
- ULONG ret;
+ TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, critical, control );
- TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie,
- critical, control );
-
- if (!ld || !control || pagesize > LDAP_MAXINT)
- return WLDAP32_LDAP_PARAM_ERROR;
-
- if (cookie && !(cookieU = bervalWtoU( cookie ))) return WLDAP32_LDAP_NO_MEMORY;
- ret = create_page_control( pagesize, cookieU, critical, control );
- heap_free( cookieU );
- return ret;
-
-#else
- return WLDAP32_LDAP_NOT_SUPPORTED;
-#endif
+ if (!ld || !control || pagesize > LDAP_MAXINT) return WLDAP32_LDAP_PARAM_ERROR;
+ return create_page_control( pagesize, cookie, critical, control );
}
-ULONG CDECL ldap_get_next_page( WLDAP32_LDAP *ld, PLDAPSearch search, ULONG pagesize,
- ULONG *message )
+ULONG CDECL ldap_get_next_page( WLDAP32_LDAP *ld, LDAPSearch *search, ULONG pagesize, ULONG *message )
{
FIXME( "(%p, %p, 0x%08x, %p)\n", ld, search, pagesize, message );
@@ -178,18 +141,16 @@ ULONG CDECL ldap_get_next_page( WLDAP32_LDAP *ld, PLDAPSearch search, ULONG page
return WLDAP32_LDAP_NOT_SUPPORTED;
}
-ULONG CDECL ldap_get_next_page_s( WLDAP32_LDAP *ld, PLDAPSearch search,
- struct l_timeval *timeout, ULONG pagesize, ULONG *count,
- WLDAP32_LDAPMessage **results )
+ULONG CDECL ldap_get_next_page_s( WLDAP32_LDAP *ld, LDAPSearch *search, struct l_timeval *timeout, ULONG pagesize,
+ ULONG *count, WLDAP32_LDAPMessage **results )
{
-#ifdef HAVE_LDAP
ULONG ret;
- TRACE( "(%p, %p, %p, %u, %p, %p)\n", ld, search, timeout,
- pagesize, count, results );
+ TRACE( "(%p, %p, %p, %u, %p, %p)\n", ld, search, timeout, pagesize, count, results );
+
if (!ld || !search || !count || !results) return ~0u;
- if (search->cookie && search->cookie->bv_len == 0)
+ if (search->cookie && !search->cookie->bv_len)
{
/* end of paged results */
*count = 0;
@@ -207,22 +168,16 @@ ULONG CDECL ldap_get_next_page_s( WLDAP32_LDAP *ld, PLDAPSearch search,
ret = ldap_create_page_controlW( ld, pagesize, search->cookie, 1, &search->serverctrls[0] );
if (ret != WLDAP32_LDAP_SUCCESS) return ret;
- ret = ldap_search_ext_sW( ld, search->dn, search->scope,
- search->filter, search->attrs, search->attrsonly,
+ ret = ldap_search_ext_sW( ld, search->dn, search->scope, search->filter, search->attrs, search->attrsonly,
search->serverctrls, search->clientctrls,
search->timeout.tv_sec ? &search->timeout : NULL, search->sizelimit, results );
if (ret != WLDAP32_LDAP_SUCCESS) return ret;
return ldap_get_paged_count( ld, search, count, *results );
-
-#endif
- return WLDAP32_LDAP_NOT_SUPPORTED;
}
-ULONG CDECL ldap_get_paged_count( WLDAP32_LDAP *ld, PLDAPSearch search,
- ULONG *count, WLDAP32_LDAPMessage *results )
+ULONG CDECL ldap_get_paged_count( WLDAP32_LDAP *ld, LDAPSearch *search, ULONG *count, WLDAP32_LDAPMessage *results )
{
-#ifdef HAVE_LDAP
ULONG ret;
LDAPControlW **server_ctrls = NULL;
@@ -249,99 +204,68 @@ ULONG CDECL ldap_get_paged_count( WLDAP32_LDAP *ld, PLDAPSearch search,
TRACE("new search->cookie: %s, count %u\n", debugstr_an(search->cookie->bv_val, search->cookie->bv_len), *count);
ldap_controls_freeW( server_ctrls );
-
return ret;
-
-#endif
- return WLDAP32_LDAP_NOT_SUPPORTED;
}
/***********************************************************************
* ldap_parse_page_controlA (WLDAP32.@)
*/
-ULONG CDECL ldap_parse_page_controlA( WLDAP32_LDAP *ld, PLDAPControlA *ctrls,
- ULONG *count, struct WLDAP32_berval **cookie )
+ULONG CDECL ldap_parse_page_controlA( WLDAP32_LDAP *ld, LDAPControlA **ctrls, ULONG *count,
+ struct WLDAP32_berval **cookie )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
LDAPControlW **ctrlsW = NULL;
TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie );
- if (!ld || !ctrls || !count || !cookie)
- return WLDAP32_LDAP_PARAM_ERROR;
-
- ctrlsW = controlarrayAtoW( ctrls );
- if (!ctrlsW) return WLDAP32_LDAP_NO_MEMORY;
+ if (!ld || !ctrls || !count || !cookie) return WLDAP32_LDAP_PARAM_ERROR;
+ if (!(ctrlsW = controlarrayAtoW( ctrls ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_parse_page_controlW( ld, ctrlsW, count, cookie );
controlarrayfreeW( ctrlsW );
-
-#endif
return ret;
}
/***********************************************************************
* ldap_parse_page_controlW (WLDAP32.@)
*/
-ULONG CDECL ldap_parse_page_controlW( WLDAP32_LDAP *ld, PLDAPControlW *ctrls,
- ULONG *count, struct WLDAP32_berval **cookie )
+ULONG CDECL ldap_parse_page_controlW( WLDAP32_LDAP *ld, LDAPControlW **ctrls, ULONG *count,
+ struct WLDAP32_berval **cookie )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
LDAPControlW *control = NULL;
- struct berval *cookieU = NULL, *valueU;
- BerElement *ber;
- ber_tag_t tag;
+ WLDAP32_BerElement *ber;
+ struct WLDAP32_berval *vec[2];
+ int tag;
ULONG i;
TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie );
- if (!ld || !ctrls || !count || !cookie)
- return WLDAP32_LDAP_PARAM_ERROR;
+ if (!ld || !ctrls || !count || !cookie) return WLDAP32_LDAP_PARAM_ERROR;
for (i = 0; ctrls[i]; i++)
{
if (!lstrcmpW( LDAP_PAGED_RESULT_OID_STRING_W, ctrls[i]->ldctl_oid ))
control = ctrls[i];
}
+ if (!control) return WLDAP32_LDAP_CONTROL_NOT_FOUND;
- if (!control)
- return WLDAP32_LDAP_CONTROL_NOT_FOUND;
-
- if (cookie && !(cookieU = bervalWtoU( *cookie )))
- return WLDAP32_LDAP_NO_MEMORY;
-
- if (!(valueU = bervalWtoU( &control->ldctl_value )))
- {
- heap_free( cookieU );
- return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (!(ber = WLDAP32_ber_init( &control->ldctl_value ))) return WLDAP32_LDAP_NO_MEMORY;
- ber = ber_init( valueU );
- heap_free( valueU );
- if (!ber)
- {
- heap_free( cookieU );
- return WLDAP32_LDAP_NO_MEMORY;
- }
-
- tag = ber_scanf( ber, "{iO}", count, &cookieU );
- if (tag == LBER_ERROR)
+ vec[0] = *cookie;
+ vec[1] = 0;
+ tag = WLDAP32_ber_scanf( ber, (char *)"{iV}", count, vec );
+ if (tag == WLDAP32_LBER_ERROR)
ret = WLDAP32_LDAP_DECODING_ERROR;
else
ret = WLDAP32_LDAP_SUCCESS;
- heap_free( cookieU );
- ber_free( ber, 1 );
-
-#endif
+ WLDAP32_ber_free( ber, 1 );
return ret;
}
-ULONG CDECL ldap_search_abandon_page( WLDAP32_LDAP *ld, PLDAPSearch search )
+ULONG CDECL ldap_search_abandon_page( WLDAP32_LDAP *ld, LDAPSearch *search )
{
-#ifdef HAVE_LDAP
LDAPControlW **ctrls;
TRACE( "(%p, %p)\n", ld, search );
@@ -357,91 +281,70 @@ ULONG CDECL ldap_search_abandon_page( WLDAP32_LDAP *ld, PLDAPSearch search )
while (*ctrls) controlfreeW( *ctrls++ );
heap_free( search->serverctrls );
controlarrayfreeW( search->clientctrls );
- if (search->cookie && search->cookie != &null_cookieW)
- heap_free( search->cookie );
+ if (search->cookie && search->cookie != &null_cookieW) heap_free( search->cookie );
heap_free( search );
return WLDAP32_LDAP_SUCCESS;
-
-#else
- return WLDAP32_LDAP_NOT_SUPPORTED;
-#endif
}
-PLDAPSearch CDECL ldap_search_init_pageA( WLDAP32_LDAP *ld, PCHAR dn, ULONG scope,
- PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyA *sortkeys )
+LDAPSearch * CDECL ldap_search_init_pageA( WLDAP32_LDAP *ld, char *dn, ULONG scope, char *filter, char **attrs,
+ ULONG attrsonly, LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG timelimit, ULONG sizelimit,
+ LDAPSortKeyA **sortkeys )
{
- FIXME( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(dn),
- scope, debugstr_a(filter), attrs, attrsonly );
+ FIXME( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_a(dn), scope,
+ debugstr_a(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, sortkeys );
return NULL;
}
-PLDAPSearch CDECL ldap_search_init_pageW( WLDAP32_LDAP *ld, PWCHAR dn, ULONG scope,
- PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyW *sortkeys )
+LDAPSearch * CDECL ldap_search_init_pageW( WLDAP32_LDAP *ld, WCHAR *dn, ULONG scope, WCHAR *filter, WCHAR **attrs,
+ ULONG attrsonly, LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG timelimit, ULONG sizelimit,
+ LDAPSortKeyW **sortkeys )
{
-#ifdef HAVE_LDAP
LDAPSearch *search;
DWORD i, len;
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
- ld, debugstr_w(dn), scope, debugstr_w(filter), attrs, attrsonly,
- serverctrls, clientctrls, timelimit, sizelimit, sortkeys );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_w(dn), scope,
+ debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, sortkeys );
- search = heap_alloc_zero( sizeof(*search) );
- if (!search)
+ if (!(search = heap_alloc_zero( sizeof(*search) )))
{
ld->ld_errno = WLDAP32_LDAP_NO_MEMORY;
return NULL;
}
- if (dn)
- {
- search->dn = strdupW( dn );
- if (!search->dn) goto fail;
- }
- if (filter)
- {
- search->filter = strdupW( filter );
- if (!search->filter) goto fail;
- }
- if (attrs)
- {
- search->attrs = strarraydupW( attrs );
- if (!search->attrs) goto fail;
- }
+ if (dn && !(search->dn = strdupW( dn ))) goto fail;
+ if (filter && !(search->filter = strdupW( filter ))) goto fail;
+ if (attrs && !(search->attrs = strarraydupW( attrs ))) goto fail;
len = serverctrls ? controlarraylenW( serverctrls ) : 0;
- search->serverctrls = heap_alloc( sizeof(LDAPControl *) * (len + 2) );
- if (!search->serverctrls) goto fail;
+ if (!(search->serverctrls = heap_alloc( sizeof(LDAPControlW *) * (len + 2) ))) goto fail;
search->serverctrls[0] = NULL; /* reserve 0 for page control */
for (i = 0; i < len; i++)
{
- search->serverctrls[i + 1] = controldupW( serverctrls[i] );
- if (!search->serverctrls[i + 1]) goto fail;
+ if (!(search->serverctrls[i + 1] = controldupW( serverctrls[i] )))
+ {
+ for (; i > 0; i--) controlfreeW( search->serverctrls[i] );
+ goto fail;
+ }
}
search->serverctrls[len + 1] = NULL;
- if (clientctrls)
+ if (clientctrls && !(search->clientctrls = controlarraydupW( clientctrls )))
{
- search->clientctrls = controlarraydupW( clientctrls );
- if (!search->clientctrls) goto fail;
+ for (i = 0; i < len; i++) controlfreeW( search->serverctrls[i] );
+ goto fail;
}
- search->scope = scope;
- search->attrsonly = attrsonly;
- search->timeout.tv_sec = timelimit;
+ search->scope = scope;
+ search->attrsonly = attrsonly;
+ search->timeout.tv_sec = timelimit;
search->timeout.tv_usec = 0;
- search->sizelimit = sizelimit;
- search->cookie = NULL;
-
+ search->sizelimit = sizelimit;
+ search->cookie = NULL;
return search;
fail:
ldap_search_abandon_page( ld, search );
ld->ld_errno = WLDAP32_LDAP_NO_MEMORY;
-
-#endif
return NULL;
}
diff --git a/dlls/wldap32/winldap_private.h b/dlls/wldap32/winldap_private.h
index 32ed3f5a266..e488db954c8 100644
--- a/dlls/wldap32/winldap_private.h
+++ b/dlls/wldap32/winldap_private.h
@@ -40,6 +40,8 @@
#define WLDAP32_LDAP_SCOPE_ONELEVEL 0x01
#define WLDAP32_LDAP_SCOPE_SUBTREE 0x02
+#define WLDAP32_LBER_USE_DER 0x01
+
typedef enum {
WLDAP32_LDAP_SUCCESS = 0x00,
WLDAP32_LDAP_UNWILLING_TO_PERFORM = 0x35,
@@ -312,6 +314,14 @@ typedef struct ldap_apifeature_infoW
int ldapaif_version;
} LDAPAPIFeatureInfoW;
+WLDAP32_BerElement * CDECL WLDAP32_ber_alloc_t(int);
+void CDECL WLDAP32_ber_bvfree(BERVAL *);
+int CDECL WLDAP32_ber_flatten(WLDAP32_BerElement *, BERVAL **);
+void CDECL WLDAP32_ber_free(WLDAP32_BerElement *, int);
+WLDAP32_BerElement * CDECL WLDAP32_ber_init(BERVAL *);
+int WINAPIV WLDAP32_ber_printf(WLDAP32_BerElement *, char *, ...);
+ULONG WINAPIV WLDAP32_ber_scanf(WLDAP32_BerElement *, char *, ...);
+
WLDAP32_LDAP * CDECL cldap_openA(PCHAR,ULONG);
WLDAP32_LDAP * CDECL cldap_openW(PWCHAR,ULONG);
ULONG CDECL WLDAP32_ldap_abandon(WLDAP32_LDAP*,ULONG);
@@ -614,6 +624,26 @@ static inline char **strarrayWtoU( WCHAR **strarray )
return strarrayU;
}
+static inline WCHAR **strarraydupW( WCHAR **strarray )
+{
+ WCHAR **strarrayW = NULL;
+ DWORD size;
+
+ if (strarray)
+ {
+ size = sizeof(WCHAR *) * (strarraylenW( strarray ) + 1);
+ if ((strarrayW = RtlAllocateHeap( GetProcessHeap(), 0, size )))
+ {
+ WCHAR **p = strarray;
+ WCHAR **q = strarrayW;
+
+ while (*p) *q++ = strdupW( *p++ );
+ *q = NULL;
+ }
+ }
+ return strarrayW;
+}
+
static inline char *strWtoA( const WCHAR *str )
{
char *ret = NULL;
@@ -1161,6 +1191,52 @@ static inline DWORD controlarraylenU( LDAPControlU **controlarray )
return p - controlarray;
}
+static inline LDAPControlW *controldupW( LDAPControlW *control )
+{
+ LDAPControlW *controlW;
+ DWORD len = control->ldctl_value.bv_len;
+ char *val = NULL;
+
+ if (control->ldctl_value.bv_val)
+ {
+ if (!(val = RtlAllocateHeap( GetProcessHeap(), 0, len ))) return NULL;
+ memcpy( val, control->ldctl_value.bv_val, len );
+ }
+
+ if (!(controlW = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(LDAPControlW) )))
+ {
+ RtlFreeHeap( GetProcessHeap(), 0, val );
+ return NULL;
+ }
+
+ controlW->ldctl_oid = strdupW( control->ldctl_oid );
+ controlW->ldctl_value.bv_len = len;
+ controlW->ldctl_value.bv_val = val;
+ controlW->ldctl_iscritical = control->ldctl_iscritical;
+
+ return controlW;
+}
+
+static inline LDAPControlW **controlarraydupW( LDAPControlW **controlarray )
+{
+ LDAPControlW **controlarrayW = NULL;
+ DWORD size;
+
+ if (controlarray)
+ {
+ size = sizeof(LDAPControlW *) * (controlarraylenW( controlarray ) + 1);
+ if ((controlarrayW = RtlAllocateHeap( GetProcessHeap(), 0, size )))
+ {
+ LDAPControlW **p = controlarray;
+ LDAPControlW **q = controlarrayW;
+
+ while (*p) *q++ = controldupW( *p++ );
+ *q = NULL;
+ }
+ }
+ return controlarrayW;
+}
+
static inline WCHAR *strUtoW( const char *str )
{
WCHAR *ret = NULL;
--
2.30.2
1
0
[PATCH 4/5] wldap32: Move support for option functions to the Unix library.
by Hans Leidekker April 16, 2021
by Hans Leidekker April 16, 2021
April 16, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/libldap.c | 20 ++++
dlls/wldap32/libldap.h | 23 +++++
dlls/wldap32/option.c | 170 ++++++++++++---------------------
dlls/wldap32/winldap_private.h | 7 ++
4 files changed, 112 insertions(+), 108 deletions(-)
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index e9353e2e3f4..662edb4d365 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -50,6 +50,8 @@ C_ASSERT( sizeof(LDAPModU) == sizeof(LDAPMod) );
C_ASSERT( sizeof(LDAPControlU) == sizeof(LDAPControl) );
C_ASSERT( sizeof(LDAPSortKeyU) == sizeof(LDAPSortKey) );
C_ASSERT( sizeof(LDAPVLVInfoU) == sizeof(LDAPVLVInfo) );
+C_ASSERT( sizeof(LDAPAPIInfoU) == sizeof(LDAPAPIInfo) );
+C_ASSERT( sizeof(LDAPAPIFeatureInfoU) == sizeof(LDAPAPIFeatureInfo) );
C_ASSERT( sizeof(struct timevalU) == sizeof(struct timeval) );
static LDAPMod *nullmods[] = { NULL };
@@ -346,6 +348,11 @@ int CDECL wrap_ldap_count_references( void *ld, void *chain )
return ldap_count_references( ld, chain );
}
+int CDECL wrap_ldap_count_values_len( struct bervalU **values )
+{
+ return ldap_count_values_len( (struct berval **)values );
+}
+
int CDECL wrap_ldap_create_sort_control( void *ld, LDAPSortKeyU **keylist, int critical, LDAPControlU **control )
{
return ldap_create_sort_control( ld, (LDAPSortKey **)keylist, critical, (LDAPControl **)control );
@@ -414,6 +421,16 @@ void * CDECL wrap_ldap_first_reference( void *ld, void *chain )
return ldap_first_reference( ld, chain );
}
+int CDECL wrap_ldap_get_option( void *ld, int option, void *value )
+{
+ return ldap_get_option( ld, option, value );
+}
+
+struct bervalU ** CDECL wrap_ldap_get_values_len( void *ld, void *entry, const char *attr )
+{
+ return (struct bervalU **)ldap_get_values_len( ld, entry, attr );
+}
+
int CDECL wrap_ldap_initialize( void **ld, const char *url )
{
return ldap_initialize( (LDAP **)ld, url );
@@ -583,6 +600,7 @@ static const struct ldap_funcs funcs =
wrap_ldap_control_free,
wrap_ldap_count_entries,
wrap_ldap_count_references,
+ wrap_ldap_count_values_len,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
@@ -592,6 +610,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_extended_operation,
wrap_ldap_extended_operation_s,
wrap_ldap_get_dn,
+ wrap_ldap_get_option,
+ wrap_ldap_get_values_len,
wrap_ldap_initialize,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index 1b0a2be4ba1..8745eac3abc 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -60,6 +60,23 @@ typedef struct
void *ldvlv_extradata;
} LDAPVLVInfoU;
+typedef struct
+{
+ int ldapai_info_version;
+ int ldapai_api_version;
+ int ldapai_protocol_version;
+ char **ldapai_extensions;
+ char *ldapai_vendor_name;
+ int ldapai_vendor_version;
+} LDAPAPIInfoU;
+
+typedef struct
+{
+ int ldapaif_info_version;
+ char *ldapaif_name;
+ int ldapaif_version;
+} LDAPAPIFeatureInfoU;
+
typedef struct timevalU
{
unsigned long tv_sec;
@@ -108,6 +125,7 @@ extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, str
extern void CDECL wrap_ldap_control_free(LDAPControlU *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_count_entries(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_count_references(void *, void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_count_values_len(struct bervalU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
@@ -119,6 +137,8 @@ extern int CDECL wrap_ldap_extended_operation(void *, const char *, struct berva
extern int CDECL wrap_ldap_extended_operation_s(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, char **, struct bervalU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_get_dn(void *, void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_get_option(void *, int, void *) DECLSPEC_HIDDEN;
+extern struct bervalU ** CDECL wrap_ldap_get_values_len(void *, void *, const char *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_initialize(void **, const char *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
@@ -181,6 +201,7 @@ struct ldap_funcs
void (CDECL *ldap_control_free)(LDAPControlU *);
int (CDECL *ldap_count_entries)(void *, void *);
int (CDECL *ldap_count_references)(void *, void *);
+ int (CDECL *ldap_count_values_len)(struct bervalU **);
int (CDECL *ldap_create_sort_control)(void *, LDAPSortKeyU **, int, LDAPControlU **);
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
@@ -192,6 +213,8 @@ struct ldap_funcs
int (CDECL *ldap_extended_operation_s)(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, char **, struct bervalU **);
char * (CDECL *ldap_get_dn)(void *, void *);
+ int (CDECL *ldap_get_option)(void *, int, void *);
+ struct bervalU ** (CDECL *ldap_get_values_len)(void *, void *, const char *);
int (CDECL *ldap_initialize)(void **, const char *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
diff --git a/dlls/wldap32/option.c b/dlls/wldap32/option.c
index 8398dff67e4..49eac7d2e94 100644
--- a/dlls/wldap32/option.c
+++ b/dlls/wldap32/option.c
@@ -18,25 +18,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#endif
/***********************************************************************
* ldap_get_optionA (WLDAP32.@)
@@ -45,8 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
*/
ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
@@ -62,14 +51,12 @@ ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
if (!featureA->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
featureW.ldapaif_info_version = featureA->ldapaif_info_version;
- featureW.ldapaif_name = strAtoW( featureA->ldapaif_name );
+ if (!(featureW.ldapaif_name = strAtoW( featureA->ldapaif_name ))) return WLDAP32_LDAP_NO_MEMORY;
featureW.ldapaif_version = 0;
- if (!featureW.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
-
ret = ldap_get_optionW( ld, option, &featureW );
- featureA->ldapaif_version = featureW.ldapaif_version;
+ if (ret == WLDAP32_LDAP_SUCCESS) featureA->ldapaif_version = featureW.ldapaif_version;
strfreeW( featureW.ldapaif_name );
return ret;
}
@@ -78,32 +65,27 @@ ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
LDAPAPIInfoW infoW;
LDAPAPIInfoA *infoA = value;
- memset( &infoW, 0, sizeof(LDAPAPIInfoW) );
+ memset( &infoW, 0, sizeof(infoW) );
infoW.ldapai_info_version = infoA->ldapai_info_version;
ret = ldap_get_optionW( ld, option, &infoW );
-
- infoA->ldapai_api_version = infoW.ldapai_api_version;
- infoA->ldapai_protocol_version = infoW.ldapai_protocol_version;
-
- if (infoW.ldapai_extensions)
- {
- infoA->ldapai_extensions = strarrayWtoA( infoW.ldapai_extensions );
- if (!infoA->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
- }
- if (infoW.ldapai_vendor_name)
+ if (ret == WLDAP32_LDAP_SUCCESS)
{
- infoA->ldapai_vendor_name = strWtoA( infoW.ldapai_vendor_name );
- if (!infoA->ldapai_vendor_name)
+ infoA->ldapai_api_version = infoW.ldapai_api_version;
+ infoA->ldapai_protocol_version = infoW.ldapai_protocol_version;
+
+ if (infoW.ldapai_extensions && !(infoA->ldapai_extensions = strarrayWtoA( infoW.ldapai_extensions )))
+ return WLDAP32_LDAP_NO_MEMORY;
+ if (infoW.ldapai_vendor_name && !(infoA->ldapai_vendor_name = strWtoA( infoW.ldapai_vendor_name )))
{
ldap_value_freeW( infoW.ldapai_extensions );
return WLDAP32_LDAP_NO_MEMORY;
}
- }
- infoA->ldapai_vendor_version = infoW.ldapai_vendor_version;
+ infoA->ldapai_vendor_version = infoW.ldapai_vendor_version;
- ldap_value_freeW( infoW.ldapai_extensions );
- ldap_memfreeW( infoW.ldapai_vendor_name );
+ ldap_value_freeW( infoW.ldapai_extensions );
+ ldap_memfreeW( infoW.ldapai_vendor_name );
+ }
return ret;
}
@@ -124,7 +106,7 @@ ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
case WLDAP32_LDAP_OPT_REBIND_FN:
case WLDAP32_LDAP_OPT_RESTART:
case WLDAP32_LDAP_OPT_THREAD_FN_PTRS:
- return LDAP_LOCAL_ERROR;
+ return WLDAP32_LDAP_LOCAL_ERROR;
case WLDAP32_LDAP_OPT_AREC_EXCLUSIVE:
case WLDAP32_LDAP_OPT_AUTO_RECONNECT:
@@ -163,9 +145,6 @@ ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
FIXME( "Unknown option: 0x%02x\n", option );
return WLDAP32_LDAP_LOCAL_ERROR;
}
-
-#endif
- return ret;
}
/***********************************************************************
@@ -184,8 +163,7 @@ ULONG CDECL ldap_get_optionA( WLDAP32_LDAP *ld, int option, void *value )
*/
ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
@@ -195,54 +173,47 @@ ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
{
case WLDAP32_LDAP_OPT_API_FEATURE_INFO:
{
- LDAPAPIFeatureInfo featureU;
+ LDAPAPIFeatureInfoU featureU;
LDAPAPIFeatureInfoW *featureW = value;
if (!featureW->ldapaif_name) return WLDAP32_LDAP_PARAM_ERROR;
featureU.ldapaif_info_version = featureW->ldapaif_info_version;
- featureU.ldapaif_name = strWtoU( featureW->ldapaif_name );
+ if (!(featureU.ldapaif_name = strWtoU( featureW->ldapaif_name ))) return WLDAP32_LDAP_NO_MEMORY;
featureU.ldapaif_version = 0;
- if (!featureU.ldapaif_name) return WLDAP32_LDAP_NO_MEMORY;
-
- ret = map_error( ldap_get_option( ld->ld, option, &featureU ));
+ ret = map_error( ldap_funcs->ldap_get_option( ld->ld, option, &featureU ) );
- featureW->ldapaif_version = featureU.ldapaif_version;
+ if (ret == WLDAP32_LDAP_SUCCESS) featureW->ldapaif_version = featureU.ldapaif_version;
strfreeU( featureU.ldapaif_name );
return ret;
}
case WLDAP32_LDAP_OPT_API_INFO:
{
- LDAPAPIInfo infoU;
+ LDAPAPIInfoU infoU;
LDAPAPIInfoW *infoW = value;
- memset( &infoU, 0, sizeof(LDAPAPIInfo) );
+ memset( &infoU, 0, sizeof(infoU) );
infoU.ldapai_info_version = infoW->ldapai_info_version;
- ret = map_error( ldap_get_option( ld->ld, option, &infoU ));
-
- infoW->ldapai_api_version = infoU.ldapai_api_version;
- infoW->ldapai_protocol_version = infoU.ldapai_protocol_version;
-
- if (infoU.ldapai_extensions)
- {
- infoW->ldapai_extensions = strarrayUtoW( infoU.ldapai_extensions );
- if (!infoW->ldapai_extensions) return WLDAP32_LDAP_NO_MEMORY;
- }
- if (infoU.ldapai_vendor_name)
+ ret = map_error( ldap_funcs->ldap_get_option( ld->ld, option, &infoU ) );
+ if (ret == WLDAP32_LDAP_SUCCESS)
{
- infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name );
- if (!infoW->ldapai_vendor_name)
+ infoW->ldapai_api_version = infoU.ldapai_api_version;
+ infoW->ldapai_protocol_version = infoU.ldapai_protocol_version;
+
+ if (infoU.ldapai_extensions && !(infoW->ldapai_extensions = strarrayUtoW( infoU.ldapai_extensions )))
+ return WLDAP32_LDAP_NO_MEMORY;
+ if (infoU.ldapai_vendor_name && !(infoW->ldapai_vendor_name = strUtoW( infoU.ldapai_vendor_name )))
{
- ldap_memvfree( (void **)infoU.ldapai_extensions );
+ ldap_funcs->ldap_memvfree( (void **)infoU.ldapai_extensions );
return WLDAP32_LDAP_NO_MEMORY;
}
- }
- infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
+ infoW->ldapai_vendor_version = infoU.ldapai_vendor_version;
- ldap_memvfree( (void **)infoU.ldapai_extensions );
- ldap_memfree( infoU.ldapai_vendor_name );
+ ldap_funcs->ldap_memvfree( (void **)infoU.ldapai_extensions );
+ ldap_funcs->ldap_memfree( infoU.ldapai_vendor_name );
+ }
return ret;
}
@@ -253,7 +224,7 @@ ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
case WLDAP32_LDAP_OPT_REFERRALS:
case WLDAP32_LDAP_OPT_SIZELIMIT:
case WLDAP32_LDAP_OPT_TIMELIMIT:
- return map_error( ldap_get_option( ld->ld, option, value ));
+ return map_error( ldap_funcs->ldap_get_option( ld->ld, option, value ));
case WLDAP32_LDAP_OPT_CACHE_ENABLE:
case WLDAP32_LDAP_OPT_CACHE_FN_PTRS:
@@ -302,9 +273,6 @@ ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
FIXME( "Unknown option: 0x%02x\n", option );
return WLDAP32_LDAP_LOCAL_ERROR;
}
-
-#endif
- return ret;
}
/***********************************************************************
@@ -314,8 +282,7 @@ ULONG CDECL ldap_get_optionW( WLDAP32_LDAP *ld, int option, void *value )
*/
ULONG CDECL ldap_set_optionA( WLDAP32_LDAP *ld, int option, void *value )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
@@ -326,10 +293,7 @@ ULONG CDECL ldap_set_optionA( WLDAP32_LDAP *ld, int option, void *value )
case WLDAP32_LDAP_OPT_SERVER_CONTROLS:
{
LDAPControlW **ctrlsW;
-
- ctrlsW = controlarrayAtoW( value );
- if (!ctrlsW) return WLDAP32_LDAP_NO_MEMORY;
-
+ if (!(ctrlsW = controlarrayAtoW( value ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_set_optionW( ld, option, ctrlsW );
controlarrayfreeW( ctrlsW );
return ret;
@@ -393,41 +357,37 @@ ULONG CDECL ldap_set_optionA( WLDAP32_LDAP *ld, int option, void *value )
FIXME( "Unknown option: 0x%02x\n", option );
return WLDAP32_LDAP_LOCAL_ERROR;
}
-
-#endif
- return ret;
}
-#ifdef HAVE_LDAP
-
static BOOL query_supported_server_ctrls( WLDAP32_LDAP *ld )
{
char *attrs[] = { (char *)"supportedControl", NULL };
- LDAPMessage *res, *entry;
+ void *res, *entry;
+ ULONG ret;
- if ( ld->ld_server_ctrls ) return TRUE;
+ if (ld->ld_server_ctrls) return TRUE;
- if (ldap_search_ext_s( ld->ld, (char *)"", LDAP_SCOPE_BASE, (char *)"(objectClass=*)", attrs, FALSE,
- NULL, NULL, NULL, 0, &res ) != LDAP_SUCCESS)
- return FALSE;
+ ret = map_error( ldap_funcs->ldap_search_ext_s( ld->ld, (char *)"", WLDAP32_LDAP_SCOPE_BASE,
+ (char *)"(objectClass=*)", attrs, FALSE, NULL, NULL, NULL, 0, &res ) );
+ if (ret != WLDAP32_LDAP_SUCCESS) return FALSE;
- entry = ldap_first_entry( ld->ld, res );
+ entry = ldap_funcs->ldap_first_entry( ld->ld, res );
if (entry)
{
ULONG count, i;
- ld->ld_server_ctrls = (struct bervalU **)ldap_get_values_len( ld->ld, entry, attrs[0] );
- count = ldap_count_values_len( (struct berval **)ld->ld_server_ctrls );
+ ld->ld_server_ctrls = ldap_funcs->ldap_get_values_len( ld->ld, entry, attrs[0] );
+ count = ldap_funcs->ldap_count_values_len( ld->ld_server_ctrls );
for (i = 0; i < count; i++)
TRACE("%u: %s\n", i, debugstr_an( ld->ld_server_ctrls[i]->bv_val, ld->ld_server_ctrls[i]->bv_len ));
}
- ldap_msgfree( res );
+ ldap_funcs->ldap_msgfree( res );
return ld->ld_server_ctrls != NULL;
}
-static BOOL is_supported_server_ctrls( WLDAP32_LDAP *ld, LDAPControl **ctrls )
+static BOOL is_supported_server_ctrls( WLDAP32_LDAP *ld, LDAPControlU **ctrls )
{
ULONG user_count, server_count, i, n, supported = 0;
@@ -435,7 +395,7 @@ static BOOL is_supported_server_ctrls( WLDAP32_LDAP *ld, LDAPControl **ctrls )
return TRUE; /* can't verify, let the server handle it on next query */
user_count = controlarraylenU( ctrls );
- server_count = ldap_count_values_len( (struct berval **)ld->ld_server_ctrls );
+ server_count = ldap_funcs->ldap_count_values_len( ld->ld_server_ctrls );
for (n = 0; n < user_count; n++)
{
@@ -453,7 +413,6 @@ static BOOL is_supported_server_ctrls( WLDAP32_LDAP *ld, LDAPControl **ctrls )
return supported == user_count;
}
-#endif
/***********************************************************************
* ldap_set_optionW (WLDAP32.@)
@@ -471,11 +430,10 @@ static BOOL is_supported_server_ctrls( WLDAP32_LDAP *ld, LDAPControl **ctrls )
*
* NOTES
* Set value to LDAP_OPT_ON or LDAP_OPT_OFF for on/off options.
- */
+ */
ULONG CDECL ldap_set_optionW( WLDAP32_LDAP *ld, int option, void *value )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
TRACE( "(%p, 0x%08x, %p)\n", ld, option, value );
@@ -485,26 +443,25 @@ ULONG CDECL ldap_set_optionW( WLDAP32_LDAP *ld, int option, void *value )
{
case WLDAP32_LDAP_OPT_SERVER_CONTROLS:
{
- LDAPControl **ctrlsU;
+ LDAPControlU **ctrlsU;
- ctrlsU = controlarrayWtoU( value );
- if (!ctrlsU) return WLDAP32_LDAP_NO_MEMORY;
+ if (!(ctrlsU = controlarrayWtoU( value ))) return WLDAP32_LDAP_NO_MEMORY;
if (!is_supported_server_ctrls( ld, ctrlsU ))
ret = WLDAP32_LDAP_PARAM_ERROR;
else
- ret = map_error( ldap_set_option( ld->ld, option, ctrlsU ));
+ ret = map_error( ldap_funcs->ldap_set_option( ld->ld, option, ctrlsU ) );
controlarrayfreeU( ctrlsU );
return ret;
}
case WLDAP32_LDAP_OPT_REFERRALS:
{
- void *openldap_referral = LDAP_OPT_ON;
- if (value == LDAP_OPT_OFF)
- openldap_referral = LDAP_OPT_OFF;
+ void *openldap_referral = WLDAP32_LDAP_OPT_ON;
+ if (value == WLDAP32_LDAP_OPT_OFF)
+ openldap_referral = WLDAP32_LDAP_OPT_OFF;
else
FIXME("upgrading referral value %p to LDAP_OPT_ON (OpenLDAP lacks sufficient granularity)\n", value);
- return map_error( ldap_set_option( ld->ld, option, openldap_referral ));
+ return map_error( ldap_funcs->ldap_set_option( ld->ld, option, openldap_referral ) );
break;
}
case WLDAP32_LDAP_OPT_DEREF:
@@ -513,7 +470,7 @@ ULONG CDECL ldap_set_optionW( WLDAP32_LDAP *ld, int option, void *value )
case WLDAP32_LDAP_OPT_PROTOCOL_VERSION:
case WLDAP32_LDAP_OPT_SIZELIMIT:
case WLDAP32_LDAP_OPT_TIMELIMIT:
- return map_error( ldap_set_option( ld->ld, option, value ));
+ return map_error( ldap_funcs->ldap_set_option( ld->ld, option, value ));
case WLDAP32_LDAP_OPT_CACHE_ENABLE:
case WLDAP32_LDAP_OPT_CACHE_FN_PTRS:
@@ -565,7 +522,4 @@ ULONG CDECL ldap_set_optionW( WLDAP32_LDAP *ld, int option, void *value )
FIXME( "Unknown option: 0x%02x\n", option );
return WLDAP32_LDAP_LOCAL_ERROR;
}
-
-#endif
- return ret;
}
diff --git a/dlls/wldap32/winldap_private.h b/dlls/wldap32/winldap_private.h
index 7ac7e5a3f41..32ed3f5a266 100644
--- a/dlls/wldap32/winldap_private.h
+++ b/dlls/wldap32/winldap_private.h
@@ -33,6 +33,13 @@
#define WLDAP32_LDAP_VERSION2 2
#define WLDAP32_LDAP_VERSION3 3
+#define WLDAP32_LDAP_OPT_ON ((void *)1)
+#define WLDAP32_LDAP_OPT_OFF ((void *)0)
+
+#define WLDAP32_LDAP_SCOPE_BASE 0x00
+#define WLDAP32_LDAP_SCOPE_ONELEVEL 0x01
+#define WLDAP32_LDAP_SCOPE_SUBTREE 0x02
+
typedef enum {
WLDAP32_LDAP_SUCCESS = 0x00,
WLDAP32_LDAP_UNWILLING_TO_PERFORM = 0x35,
--
2.30.2
1
0
[PATCH 3/5] wldap32: Move support for modrdn functions to the Unix library.
by Hans Leidekker April 16, 2021
by Hans Leidekker April 16, 2021
April 16, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/libldap.c | 16 ++++
dlls/wldap32/libldap.h | 7 ++
dlls/wldap32/modrdn.c | 199 ++++++++---------------------------------
3 files changed, 60 insertions(+), 162 deletions(-)
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index 333ecc741c2..e9353e2e3f4 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -470,6 +470,20 @@ int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matc
return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
}
+int CDECL wrap_ldap_rename( void *ld, const char *dn, const char *newrdn, const char *newparent, int delete,
+ LDAPControlU **clientctrls, LDAPControlU **serverctrls, ULONG *msg )
+{
+ return ldap_rename( ld, dn ? dn : "", newrdn, newparent, delete, (LDAPControl **)clientctrls,
+ (LDAPControl **)serverctrls, (int *)msg );
+}
+
+int CDECL wrap_ldap_rename_s( void *ld, const char *dn, const char *newrdn, const char *newparent, int delete,
+ LDAPControlU **clientctrls, LDAPControlU **serverctrls )
+{
+ return ldap_rename_s( ld, dn ? dn : "", newrdn, newparent, delete, (LDAPControl **)clientctrls,
+ (LDAPControl **)serverctrls );
+}
+
int CDECL wrap_ldap_result( void *ld, int msgid, int all, struct timevalU *timeout, void **result )
{
return ldap_result( ld, msgid, all, (struct timeval *)timeout, (LDAPMessage **)result );
@@ -591,6 +605,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_next_entry,
wrap_ldap_next_reference,
wrap_ldap_parse_result,
+ wrap_ldap_rename,
+ wrap_ldap_rename_s,
wrap_ldap_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index b99855e9d34..1b0a2be4ba1 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -135,6 +135,10 @@ extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_reference(void *, void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_parse_result(void *, void *, int *, char **, char **, char ***, LDAPControlU ***,
int) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_rename(void *, const char *, const char *, const char *, int, LDAPControlU **,
+ LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_rename_s(void *, const char *, const char *, const char *, int, LDAPControlU **,
+ LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_result(void *, int, int, struct timevalU *, void **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
@@ -201,6 +205,9 @@ struct ldap_funcs
void * (CDECL *ldap_next_entry)(void *, void *);
void * (CDECL *ldap_next_reference)(void *, void *);
int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
+ int (CDECL *ldap_rename)(void *, const char *, const char *, const char *, int, LDAPControlU **, LDAPControlU **,
+ ULONG *);
+ int (CDECL *ldap_rename_s)(void *, const char *, const char *, const char *, int, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_result)(void *, int, int, struct timevalU *, void **);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
diff --git a/dlls/wldap32/modrdn.c b/dlls/wldap32/modrdn.c
index c9e232140ca..c297c7e90b6 100644
--- a/dlls/wldap32/modrdn.c
+++ b/dlls/wldap32/modrdn.c
@@ -18,58 +18,38 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#endif
/***********************************************************************
* ldap_modrdnA (WLDAP32.@)
*
* See ldap_modrdnW.
*/
-ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
+ULONG CDECL ldap_modrdnA( WLDAP32_LDAP *ld, char *dn, char *newdn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(newdn) );
if (!ld || !newdn) return ~0u;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
-
- newdnW = strAtoW( newdn );
- if (!newdnW) goto exit;
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdnW( ld, dnW, newdnW );
exit:
strfreeW( dnW );
strfreeW( newdnW );
-
-#endif
return ret;
}
@@ -81,7 +61,7 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
- * newdn [I] New DN for the entry.
+ * newdn [I] New DN for the entry.
*
* RETURNS
* Success: Message ID of the modrdn operation.
@@ -92,40 +72,10 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
+ULONG CDECL ldap_modrdnW( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL, *newdnU = NULL;
- int msg;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(newdn) );
-
- if (!ld || !newdn) return ~0u;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
-
- newdnU = strWtoU( newdn );
- if (!newdnU) goto exit;
-
- ret = ldap_rename( ld->ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL, &msg );
-
- if (ret == LDAP_SUCCESS)
- ret = msg;
- else
- ret = ~0u;
-
-exit:
- strfreeU( dnU );
- strfreeU( newdnU );
-
-#endif
- return ret;
+ return ldap_modrdn2W( ld, dn, newdn, 1 );
}
/***********************************************************************
@@ -133,33 +83,23 @@ exit:
*
* See ldap_modrdn2W.
*/
-ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
+ULONG CDECL ldap_modrdn2A( WLDAP32_LDAP *ld, char *dn, char *newdn, int delete )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
if (!ld || !newdn) return ~0u;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
-
- newdnW = strAtoW( newdn );
- if (!newdnW) goto exit;
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdn2W( ld, dnW, newdnW, delete );
exit:
strfreeW( dnW );
strfreeW( newdnW );
-
-#endif
return ret;
}
@@ -171,7 +111,7 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
- * newdn [I] New DN for the entry.
+ * newdn [I] New DN for the entry.
* delete [I] Delete old DN?
*
* RETURNS
@@ -183,30 +123,21 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
+ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL, *newdnU = NULL;
- int msg;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ ULONG msg;
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
if (!ld || !newdn) return ~0u;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
-
- newdnU = strWtoU( newdn );
- if (!newdnU) goto exit;
+ if (dn && !(dnU = strWtoU( dn ))) goto exit;
+ if (!(newdnU = strWtoU( newdn ))) goto exit;
- ret = ldap_rename( ld->ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL, &msg );
-
- if (ret == LDAP_SUCCESS)
+ ret = ldap_funcs->ldap_rename( ld->ld, dnU, newdnU, NULL, delete, NULL, NULL, &msg );
+ if (ret == WLDAP32_LDAP_SUCCESS)
ret = msg;
else
ret = ~0u;
@@ -214,8 +145,6 @@ ULONG CDECL ldap_modrdn2W( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete
exit:
strfreeU( dnU );
strfreeU( newdnU );
-
-#endif
return ret;
}
@@ -224,33 +153,23 @@ exit:
*
* See ldap_modrdn2_sW.
*/
-ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn, INT delete )
+ULONG CDECL ldap_modrdn2_sA( WLDAP32_LDAP *ld, char *dn, char *newdn, int delete )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_a(dn), newdn, delete );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
-
- newdnW = strAtoW( newdn );
- if (!newdnW) goto exit;
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdn2_sW( ld, dnW, newdnW, delete );
exit:
strfreeW( dnW );
strfreeW( newdnW );
-
-#endif
return ret;
}
@@ -262,40 +181,30 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
- * newdn [I] New DN for the entry.
+ * newdn [I] New DN for the entry.
* delete [I] Delete old DN?
*
* RETURNS
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn, INT delete )
+ULONG CDECL ldap_modrdn2_sW( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn, int delete )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL, *newdnU = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p, 0x%02x)\n", ld, debugstr_w(dn), newdn, delete );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
-
- newdnU = strWtoU( newdn );
- if (!newdnU) goto exit;
+ if (dn && !(dnU = strWtoU( dn ))) goto exit;
+ if (!(newdnU = strWtoU( newdn ))) goto exit;
- ret = map_error( ldap_rename_s( ld->ld, dn ? dnU : "", newdnU, NULL, delete, NULL, NULL ));
+ ret = map_error( ldap_funcs->ldap_rename_s( ld->ld, dnU, newdnU, NULL, delete, NULL, NULL ));
exit:
strfreeU( dnU );
strfreeU( newdnU );
-
-#endif
return ret;
}
@@ -304,33 +213,23 @@ exit:
*
* See ldap_modrdn_sW.
*/
-ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newdn )
+ULONG CDECL ldap_modrdn_sA( WLDAP32_LDAP *ld, char *dn, char *newdn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL, *newdnW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), newdn );
if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
-
- newdnW = strAtoW( newdn );
- if (!newdnW) goto exit;
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (!(newdnW = strAtoW( newdn ))) goto exit;
ret = ldap_modrdn_sW( ld, dnW, newdnW );
exit:
strfreeW( dnW );
strfreeW( newdnW );
-
-#endif
return ret;
}
@@ -342,38 +241,14 @@ exit:
* PARAMS
* ld [I] Pointer to an LDAP context.
* dn [I] DN of the entry to change.
- * newdn [I] New DN for the entry.
+ * newdn [I] New DN for the entry.
*
* RETURNS
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newdn )
+ULONG CDECL ldap_modrdn_sW( WLDAP32_LDAP *ld, WCHAR *dn, WCHAR *newdn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL, *newdnU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), newdn );
-
- if (!ld || !newdn) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
-
- newdnU = strWtoU( newdn );
- if (!newdnU) goto exit;
-
- ret = map_error( ldap_rename_s( ld->ld, dn ? dnU : "", newdnU, NULL, 1, NULL, NULL ));
-
-exit:
- strfreeU( dnU );
- strfreeU( newdnU );
-
-#endif
- return ret;
+ return ldap_modrdn2_sW( ld, dn, newdn, 1 );
}
--
2.30.2
1
0
[PATCH 2/5] wldap32: Move support for modify functions to the Unix library.
by Hans Leidekker April 16, 2021
by Hans Leidekker April 16, 2021
April 16, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/libldap.c | 23 +++-
dlls/wldap32/libldap.h | 6 +
dlls/wldap32/modify.c | 275 +++++++++--------------------------------
3 files changed, 82 insertions(+), 222 deletions(-)
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index cf2c2b7e38c..333ecc741c2 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -52,7 +52,7 @@ C_ASSERT( sizeof(LDAPSortKeyU) == sizeof(LDAPSortKey) );
C_ASSERT( sizeof(LDAPVLVInfoU) == sizeof(LDAPVLVInfo) );
C_ASSERT( sizeof(struct timevalU) == sizeof(struct timeval) );
-static LDAPMod *nullattrs[] = { NULL };
+static LDAPMod *nullmods[] = { NULL };
static const struct ldap_callbacks *callbacks;
@@ -305,14 +305,14 @@ int CDECL wrap_ldap_add_ext( void *ld, const char *dn, LDAPModU **attrs, LDAPCon
LDAPControlU **clientctrls, ULONG *msg )
{
int dummy;
- return ldap_add_ext( ld, dn ? dn : "", attrs ? (LDAPMod **)attrs : nullattrs, (LDAPControl **)serverctrls,
+ return ldap_add_ext( ld, dn ? dn : "", attrs ? (LDAPMod **)attrs : nullmods, (LDAPControl **)serverctrls,
(LDAPControl **)clientctrls, msg ? (int *)msg : &dummy );
}
int CDECL wrap_ldap_add_ext_s( void *ld, const char *dn, LDAPModU **attrs, LDAPControlU **serverctrls,
LDAPControlU **clientctrls )
{
- return ldap_add_ext_s( ld, dn ? dn : "", attrs ? (LDAPMod **)attrs : nullattrs, (LDAPControl **)serverctrls,
+ return ldap_add_ext_s( ld, dn ? dn : "", attrs ? (LDAPMod **)attrs : nullmods, (LDAPControl **)serverctrls,
(LDAPControl **)clientctrls );
}
@@ -429,6 +429,21 @@ void CDECL wrap_ldap_memvfree( void **ptr )
ldap_memvfree( ptr );
}
+int CDECL wrap_ldap_modify_ext( void *ld, const char *dn, LDAPModU **mods, LDAPControlU **serverctrls,
+ LDAPControlU **clientctrls, ULONG *msg )
+{
+ int dummy;
+ return ldap_modify_ext( ld, dn ? dn : "", mods ? (LDAPMod **)mods : nullmods, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, msg ? (int *)msg : &dummy );
+}
+
+int CDECL wrap_ldap_modify_ext_s( void *ld, const char *dn, LDAPModU **mods, LDAPControlU **serverctrls,
+ LDAPControlU **clientctrls )
+{
+ return ldap_modify_ext_s( ld, dn ? dn : "", mods ? (LDAPMod **)mods : nullmods, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls );
+}
+
int CDECL wrap_ldap_msgfree( void *msg )
{
return ldap_msgfree( msg );
@@ -569,6 +584,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_first_reference,
wrap_ldap_memfree,
wrap_ldap_memvfree,
+ wrap_ldap_modify_ext,
+ wrap_ldap_modify_ext_s,
wrap_ldap_msgfree,
wrap_ldap_next_attribute,
wrap_ldap_next_entry,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index 9f26704d053..b99855e9d34 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -125,6 +125,10 @@ extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_reference(void *, void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memvfree(void **) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_modify_ext(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **,
+ ULONG *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_modify_ext_s(void *, const char *, LDAPModU **, LDAPControlU **,
+ LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_msgfree(void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_next_attribute(void *, void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_next_entry(void *, void *) DECLSPEC_HIDDEN;
@@ -190,6 +194,8 @@ struct ldap_funcs
void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
void (CDECL *ldap_memvfree)(void **);
+ int (CDECL *ldap_modify_ext)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **, ULONG *);
+ int (CDECL *ldap_modify_ext_s)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_msgfree)(void *);
char * (CDECL *ldap_next_attribute)(void *, void *, void *);
void * (CDECL *ldap_next_entry)(void *, void *);
diff --git a/dlls/wldap32/modify.c b/dlls/wldap32/modify.c
index 7269df9da9f..9655a0cf15e 100644
--- a/dlls/wldap32/modify.c
+++ b/dlls/wldap32/modify.c
@@ -18,62 +18,39 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-static LDAPMod *nullmods[] = { NULL };
-#endif
-
/***********************************************************************
* ldap_modifyA (WLDAP32.@)
*
* See ldap_modifyW.
*/
-ULONG CDECL ldap_modifyA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
+ULONG CDECL ldap_modifyA( WLDAP32_LDAP *ld, char *dn, LDAPModA **mods )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPModW **modsW = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
if (!ld) return ~0u;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
- if (mods) {
- modsW = modarrayAtoW( mods );
- if (!modsW) goto exit;
- }
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (mods && !(modsW = modarrayAtoW( mods ))) goto exit;
ret = ldap_modifyW( ld, dnW, modsW );
exit:
strfreeW( dnW );
modarrayfreeW( modsW );
-
-#endif
return ret;
}
@@ -97,43 +74,15 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_modifyW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
+ULONG CDECL ldap_modifyW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPModW **mods )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL;
- LDAPMod **modsU = NULL;
- int msg;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ ULONG ret, msg;
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
- if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (mods) {
- modsU = modarrayWtoU( mods );
- if (!modsU) goto exit;
- }
-
- ret = ldap_modify_ext( ld->ld, dn ? dnU : "", mods ? modsU : nullmods,
- NULL, NULL, &msg );
-
- if (ret == LDAP_SUCCESS)
- ret = msg;
- else
- ret = ~0u;
-
-exit:
- strfreeU( dnU );
- modarrayfreeU( modsU );
-
-#endif
- return ret;
+ ret = ldap_modify_extW( ld, dn, mods, NULL, NULL, &msg );
+ if (ret == WLDAP32_LDAP_SUCCESS) return msg;
+ return ~0u;
}
/***********************************************************************
@@ -141,38 +90,22 @@ exit:
*
* See ldap_modify_extW.
*/
-ULONG CDECL ldap_modify_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
- PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
+ULONG CDECL ldap_modify_extA( WLDAP32_LDAP *ld, char *dn, LDAPModA **mods,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPModW **modsW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
- serverctrls, clientctrls, message );
+ TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), mods, serverctrls, clientctrls, message );
if (!ld) return ~0u;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
- if (mods) {
- modsW = modarrayAtoW( mods );
- if (!modsW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (mods && !(modsW = modarrayAtoW( mods ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_modify_extW( ld, dnW, modsW, serverctrlsW, clientctrlsW, message );
@@ -181,8 +114,6 @@ exit:
modarrayfreeW( modsW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -209,50 +140,30 @@ exit:
* the operation. The serverctrls and clientctrls parameters are
* optional and should be set to NULL if not used.
*/
-ULONG CDECL ldap_modify_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
- PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
+ULONG CDECL ldap_modify_extW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPModW **mods,
+ LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL;
- LDAPMod **modsU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
- int dummy;
+ LDAPModU **modsU = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
- serverctrls, clientctrls, message );
+ TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), mods, serverctrls, clientctrls, message );
if (!ld) return ~0u;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (mods) {
- modsU = modarrayWtoU( mods );
- if (!modsU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- ret = map_error( ldap_modify_ext( ld->ld, dn ? dnU : "", mods ? modsU : nullmods, serverctrlsU,
- clientctrlsU, message ? (int *)message : &dummy ));
+ if (dn && !(dnU = strWtoU( dn ))) goto exit;
+ if (mods && !(modsU = modarrayWtoU( mods ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ ret = map_error( ldap_funcs->ldap_modify_ext( ld->ld, dnU, modsU, serverctrlsU, clientctrlsU, message ) );
exit:
strfreeU( dnU );
modarrayfreeU( modsU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -261,38 +172,22 @@ exit:
*
* See ldap_modify_ext_sW.
*/
-ULONG CDECL ldap_modify_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
- PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
+ULONG CDECL ldap_modify_ext_sA( WLDAP32_LDAP *ld, char *dn, LDAPModA **mods,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPModW **modsW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
- serverctrls, clientctrls );
+ TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), mods, serverctrls, clientctrls );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
- if (mods) {
- modsW = modarrayAtoW( mods );
- if (!modsW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (mods && !(modsW = modarrayAtoW( mods ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_modify_ext_sW( ld, dnW, modsW, serverctrlsW, clientctrlsW );
@@ -301,8 +196,6 @@ exit:
modarrayfreeW( modsW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -327,49 +220,30 @@ exit:
* The serverctrls and clientctrls parameters are optional and
* should be set to NULL if not used.
*/
-ULONG CDECL ldap_modify_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
- PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
+ULONG CDECL ldap_modify_ext_sW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPModW **mods,
+ LDAPControlW **serverctrls, LDAPControlW **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL;
- LDAPMod **modsU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
+ LDAPModU **modsU = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
- serverctrls, clientctrls );
+ TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), mods, serverctrls, clientctrls );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (mods) {
- modsU = modarrayWtoU( mods );
- if (!modsU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- ret = map_error( ldap_modify_ext_s( ld->ld, dn ? dnU : "", mods ? modsU : nullmods,
- serverctrlsU, clientctrlsU ));
+ if (dn && !(dnU = strWtoU( dn ))) goto exit;
+ if (mods && !(modsU = modarrayWtoU( mods ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ ret = map_error( ldap_funcs->ldap_modify_ext_s( ld->ld, dnU, modsU, serverctrlsU, clientctrlsU ) );
exit:
strfreeU( dnU );
modarrayfreeU( modsU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -378,35 +252,24 @@ exit:
*
* See ldap_modify_sW.
*/
-ULONG CDECL ldap_modify_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
+ULONG CDECL ldap_modify_sA( WLDAP32_LDAP *ld, char *dn, LDAPModA **mods )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPModW **modsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) goto exit;
- }
- if (mods) {
- modsW = modarrayAtoW( mods );
- if (!modsW) goto exit;
- }
+ if (dn && !(dnW = strAtoW( dn ))) goto exit;
+ if (mods && !(modsW = modarrayAtoW( mods ))) goto exit;
ret = ldap_modify_sW( ld, dnW, modsW );
exit:
strfreeW( dnW );
modarrayfreeW( modsW );
-
-#endif
return ret;
}
@@ -425,34 +288,8 @@ exit:
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_modify_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
+ULONG CDECL ldap_modify_sW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPModW **mods )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL;
- LDAPMod **modsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
-
- if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (mods) {
- modsU = modarrayWtoU( mods );
- if (!modsU) goto exit;
- }
-
- ret = map_error( ldap_modify_ext_s( ld->ld, dn ? dnU : "", mods ? modsU : nullmods, NULL, NULL ));
-
-exit:
- strfreeU( dnU );
- modarrayfreeU( modsU );
-
-#endif
- return ret;
+ return ldap_modify_ext_sW( ld, dn, mods, NULL, NULL );
}
--
2.30.2
1
0
[PATCH 1/5] wldap32: Move support for init functions to the Unix library.
by Hans Leidekker April 16, 2021
by Hans Leidekker April 16, 2021
April 16, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/init.c | 218 ++++++++-------------------------
dlls/wldap32/libldap.c | 18 +++
dlls/wldap32/libldap.h | 6 +
dlls/wldap32/winldap_private.h | 4 +
4 files changed, 78 insertions(+), 168 deletions(-)
diff --git a/dlls/wldap32/init.c b/dlls/wldap32/init.c
index 6586caa0ef5..d65554afb3c 100644
--- a/dlls/wldap32/init.c
+++ b/dlls/wldap32/init.c
@@ -18,25 +18,18 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
-#include <stdio.h>
#include <stdarg.h>
-#ifdef HAVE_LDAP_H
-#include <ldap.h>
-#endif
-
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "wine/heap.h"
+#include "winldap_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#ifdef HAVE_LDAP
/* Should eventually be determined by the algorithm documented on MSDN. */
static const WCHAR defaulthost[] = { 'l','o','c','a','l','h','o','s','t',0 };
@@ -200,55 +193,41 @@ static char *urlify_hostnames( const char *scheme, char *hostnames, ULONG port )
strarrayfreeU( strarray );
return url;
}
-#endif
-WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#ifdef HAVE_LDAP
static WLDAP32_LDAP *create_context( const char *url )
{
WLDAP32_LDAP *ld;
- int version = LDAP_VERSION3;
+ int version = WLDAP32_LDAP_VERSION3;
- ld = heap_alloc_zero( sizeof( *ld ));
- if (!ld) return NULL;
- if (ldap_initialize( (LDAP **)&ld->ld, url ) != LDAP_SUCCESS)
+ if (!(ld = heap_alloc_zero( sizeof( *ld )))) return NULL;
+ if (map_error( ldap_funcs->ldap_initialize( &ld->ld, url ) ) != WLDAP32_LDAP_SUCCESS)
{
heap_free( ld );
return NULL;
}
- ldap_set_option( ld->ld, LDAP_OPT_PROTOCOL_VERSION, &version );
+ ldap_funcs->ldap_set_option( ld->ld, WLDAP32_LDAP_OPT_PROTOCOL_VERSION, &version );
return ld;
}
-#endif
/***********************************************************************
* cldap_openA (WLDAP32.@)
*
* See cldap_openW.
*/
-WLDAP32_LDAP * CDECL cldap_openA( PCHAR hostname, ULONG portnumber )
+WLDAP32_LDAP * CDECL cldap_openA( char *hostname, ULONG portnumber )
{
-#ifdef HAVE_LDAP
- WLDAP32_LDAP *ld = NULL;
+ WLDAP32_LDAP *ld;
WCHAR *hostnameW = NULL;
TRACE( "(%s, %d)\n", debugstr_a(hostname), portnumber );
- if (hostname) {
- hostnameW = strAtoW( hostname );
- if (!hostnameW) goto exit;
- }
+ if (hostname && !(hostnameW = strAtoW( hostname ))) return NULL;
ld = cldap_openW( hostnameW, portnumber );
-exit:
strfreeW( hostnameW );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -272,25 +251,15 @@ exit:
* will take precedence over the port number supplied as a parameter
* to this function.
*/
-WLDAP32_LDAP * CDECL cldap_openW( PWCHAR hostname, ULONG portnumber )
+WLDAP32_LDAP * CDECL cldap_openW( WCHAR *hostname, ULONG portnumber )
{
-#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
- char *hostnameU = NULL, *url = NULL;
+ char *hostnameU, *url = NULL;
TRACE( "(%s, %d)\n", debugstr_w(hostname), portnumber );
- if (hostname) {
- hostnameU = strWtoU( hostname );
- if (!hostnameU) goto exit;
- }
- else {
- hostnameU = strWtoU( defaulthost );
- if (!hostnameU) goto exit;
- }
-
- url = urlify_hostnames( "cldap://", hostnameU, portnumber );
- if (!url) goto exit;
+ if (!(hostnameU = strWtoU( hostname ? hostname : defaulthost ))) return NULL;
+ if (!(url = urlify_hostnames( "cldap://", hostnameU, portnumber ))) goto exit;
ld = create_context( url );
@@ -298,10 +267,6 @@ exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -337,26 +302,17 @@ ULONG CDECL ldap_connect( WLDAP32_LDAP *ld, struct l_timeval *timeout )
*/
WLDAP32_LDAP * CDECL ldap_initA( const PCHAR hostname, ULONG portnumber )
{
-#ifdef HAVE_LDAP
- WLDAP32_LDAP *ld = NULL;
+ WLDAP32_LDAP *ld;
WCHAR *hostnameW = NULL;
TRACE( "(%s, %d)\n", debugstr_a(hostname), portnumber );
- if (hostname) {
- hostnameW = strAtoW( hostname );
- if (!hostnameW) goto exit;
- }
+ if (hostname && !(hostnameW = strAtoW( hostname ))) return NULL;
ld = ldap_initW( hostnameW, portnumber );
-exit:
strfreeW( hostnameW );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -383,23 +339,13 @@ exit:
*/
WLDAP32_LDAP * CDECL ldap_initW( const PWCHAR hostname, ULONG portnumber )
{
-#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
- char *hostnameU = NULL, *url = NULL;
+ char *hostnameU, *url = NULL;
TRACE( "(%s, %d)\n", debugstr_w(hostname), portnumber );
- if (hostname) {
- hostnameU = strWtoU( hostname );
- if (!hostnameU) goto exit;
- }
- else {
- hostnameU = strWtoU( defaulthost );
- if (!hostnameU) goto exit;
- }
-
- url = urlify_hostnames( "ldap://", hostnameU, portnumber );
- if (!url) goto exit;
+ if (!(hostnameU = strWtoU( hostname ? hostname : defaulthost ))) return NULL;
+ if (!(url = urlify_hostnames( "ldap://", hostnameU, portnumber ))) goto exit;
ld = create_context( url );
@@ -407,10 +353,6 @@ exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -418,28 +360,19 @@ exit:
*
* See ldap_openW.
*/
-WLDAP32_LDAP * CDECL ldap_openA( PCHAR hostname, ULONG portnumber )
+WLDAP32_LDAP * CDECL ldap_openA( char *hostname, ULONG portnumber )
{
-#ifdef HAVE_LDAP
- WLDAP32_LDAP *ld = NULL;
+ WLDAP32_LDAP *ld;
WCHAR *hostnameW = NULL;
TRACE( "(%s, %d)\n", debugstr_a(hostname), portnumber );
- if (hostname) {
- hostnameW = strAtoW( hostname );
- if (!hostnameW) goto exit;
- }
+ if (hostname && !(hostnameW = strAtoW( hostname ))) return NULL;
ld = ldap_openW( hostnameW, portnumber );
-exit:
strfreeW( hostnameW );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -463,25 +396,15 @@ exit:
* will take precedence over the port number supplied as a parameter
* to this function.
*/
-WLDAP32_LDAP * CDECL ldap_openW( PWCHAR hostname, ULONG portnumber )
+WLDAP32_LDAP * CDECL ldap_openW( WCHAR *hostname, ULONG portnumber )
{
-#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
- char *hostnameU = NULL, *url = NULL;
+ char *hostnameU, *url = NULL;
TRACE( "(%s, %d)\n", debugstr_w(hostname), portnumber );
- if (hostname) {
- hostnameU = strWtoU( hostname );
- if (!hostnameU) goto exit;
- }
- else {
- hostnameU = strWtoU( defaulthost );
- if (!hostnameU) goto exit;
- }
-
- url = urlify_hostnames( "ldap://", hostnameU, portnumber );
- if (!url) goto exit;
+ if (!(hostnameU = strWtoU( hostname ? hostname : defaulthost ))) return NULL;
+ if (!(url = urlify_hostnames( "ldap://", hostnameU, portnumber ))) goto exit;
ld = create_context( url );
@@ -489,10 +412,6 @@ exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -500,27 +419,19 @@ exit:
*
* See ldap_sslinitW.
*/
-WLDAP32_LDAP * CDECL ldap_sslinitA( PCHAR hostname, ULONG portnumber, int secure )
+WLDAP32_LDAP * CDECL ldap_sslinitA( char *hostname, ULONG portnumber, int secure )
{
-#ifdef HAVE_LDAP
WLDAP32_LDAP *ld;
WCHAR *hostnameW = NULL;
TRACE( "(%s, %d, 0x%08x)\n", debugstr_a(hostname), portnumber, secure );
- if (hostname) {
- hostnameW = strAtoW( hostname );
- if (!hostnameW) return NULL;
- }
+ if (hostname && !(hostnameW = strAtoW( hostname ))) return NULL;
ld = ldap_sslinitW( hostnameW, portnumber, secure );
strfreeW( hostnameW );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -546,22 +457,14 @@ WLDAP32_LDAP * CDECL ldap_sslinitA( PCHAR hostname, ULONG portnumber, int secure
* to this function. The connection will not be made until the first
* LDAP function that needs it is called.
*/
-WLDAP32_LDAP * CDECL ldap_sslinitW( PWCHAR hostname, ULONG portnumber, int secure )
+WLDAP32_LDAP * CDECL ldap_sslinitW( WCHAR *hostname, ULONG portnumber, int secure )
{
-#ifdef HAVE_LDAP
WLDAP32_LDAP *ld = NULL;
- char *hostnameU = NULL, *url = NULL;
+ char *hostnameU, *url = NULL;
TRACE( "(%s, %d, 0x%08x)\n", debugstr_w(hostname), portnumber, secure );
- if (hostname) {
- hostnameU = strWtoU( hostname );
- if (!hostnameU) goto exit;
- }
- else {
- hostnameU = strWtoU( defaulthost );
- if (!hostnameU) goto exit;
- }
+ if (!(hostnameU = strWtoU( hostname ? hostname : defaulthost ))) return NULL;
if (secure)
url = urlify_hostnames( "ldaps://", hostnameU, portnumber );
@@ -575,10 +478,6 @@ exit:
strfreeU( hostnameU );
strfreeU( url );
return ld;
-
-#else
- return NULL;
-#endif
}
/***********************************************************************
@@ -586,35 +485,24 @@ exit:
*
* See ldap_start_tls_sW.
*/
-ULONG CDECL ldap_start_tls_sA( WLDAP32_LDAP *ld, PULONG retval, WLDAP32_LDAPMessage **result,
- PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
+ULONG CDECL ldap_start_tls_sA( WLDAP32_LDAP *ld, ULONG *retval, WLDAP32_LDAPMessage **result,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
TRACE( "(%p, %p, %p, %p, %p)\n", ld, retval, result, serverctrls, clientctrls );
if (!ld) return ~0u;
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_start_tls_sW( ld, retval, result, serverctrlsW, clientctrlsW );
exit:
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -637,42 +525,36 @@ exit:
* NOTES
* LDAP function that needs it is called.
*/
-ULONG CDECL ldap_start_tls_sW( WLDAP32_LDAP *ld, PULONG retval, WLDAP32_LDAPMessage **result,
- PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
+ULONG CDECL ldap_start_tls_sW( WLDAP32_LDAP *ld, ULONG *retval, WLDAP32_LDAPMessage **result,
+ LDAPControlW **serverctrls, LDAPControlW **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
TRACE( "(%p, %p, %p, %p, %p)\n", ld, retval, result, serverctrls, clientctrls );
+ if (result)
+ {
+ FIXME( "result message not supported\n" );
+ *result = NULL;
+ }
if (!ld) return ~0u;
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
- ret = map_error( ldap_start_tls_s( ld->ld, serverctrlsU, clientctrlsU ));
+ ret = map_error( ldap_funcs->ldap_start_tls_s( ld->ld, serverctrlsU, clientctrlsU ) );
exit:
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
/***********************************************************************
* ldap_startup (WLDAP32.@)
*/
-ULONG CDECL ldap_startup( PLDAP_VERSION_INFO version, HANDLE *instance )
+ULONG CDECL ldap_startup( LDAP_VERSION_INFO *version, HANDLE *instance )
{
TRACE( "(%p, %p)\n", version, instance );
return WLDAP32_LDAP_SUCCESS;
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index de6974570f6..cf2c2b7e38c 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -414,6 +414,11 @@ void * CDECL wrap_ldap_first_reference( void *ld, void *chain )
return ldap_first_reference( ld, chain );
}
+int CDECL wrap_ldap_initialize( void **ld, const char *url )
+{
+ return ldap_initialize( (LDAP **)ld, url );
+}
+
void CDECL wrap_ldap_memfree( void *ptr )
{
return ldap_memfree( ptr );
@@ -502,6 +507,16 @@ int CDECL wrap_ldap_search_ext_s( void *ld, const char *base, int scope, const c
(LDAPMessage **)result );
}
+int CDECL wrap_ldap_set_option( void *ld, int option, const void *value )
+{
+ return ldap_set_option( ld, option, value );
+}
+
+int CDECL wrap_ldap_start_tls_s( void *ld, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
+{
+ return ldap_start_tls_s( ld, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
+}
+
int CDECL wrap_ldap_unbind_ext( void *ld, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
{
return ldap_unbind_ext( ld, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
@@ -548,6 +563,7 @@ static const struct ldap_funcs funcs =
wrap_ldap_extended_operation,
wrap_ldap_extended_operation_s,
wrap_ldap_get_dn,
+ wrap_ldap_initialize,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
wrap_ldap_first_reference,
@@ -564,6 +580,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_sasl_interactive_bind_s,
wrap_ldap_search_ext,
wrap_ldap_search_ext_s,
+ wrap_ldap_set_option,
+ wrap_ldap_start_tls_s,
wrap_ldap_unbind_ext,
wrap_ldap_unbind_ext_s,
wrap_ldap_value_free_len,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index f3fc5796fdc..9f26704d053 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -119,6 +119,7 @@ extern int CDECL wrap_ldap_extended_operation(void *, const char *, struct berva
extern int CDECL wrap_ldap_extended_operation_s(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, char **, struct bervalU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_get_dn(void *, void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_initialize(void **, const char *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_reference(void *, void *) DECLSPEC_HIDDEN;
@@ -141,6 +142,8 @@ extern int CDECL wrap_ldap_search_ext(void *, const char *, int, const char *, c
LDAPControlU **, struct timevalU *, int, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_search_ext_s(void *, const char *, int, const char *, char **, int, LDAPControlU **,
LDAPControlU **, struct timevalU *, int, void **) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_set_option(void *, int, const void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_start_tls_s(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_unbind_ext(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_unbind_ext_s(void *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_value_free_len(struct bervalU **) DECLSPEC_HIDDEN;
@@ -181,6 +184,7 @@ struct ldap_funcs
int (CDECL *ldap_extended_operation_s)(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, char **, struct bervalU **);
char * (CDECL *ldap_get_dn)(void *, void *);
+ int (CDECL *ldap_initialize)(void **, const char *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
void * (CDECL *ldap_first_reference)(void *, void *);
@@ -202,6 +206,8 @@ struct ldap_funcs
LDAPControlU **, struct timevalU *, int, ULONG *);
int (CDECL *ldap_search_ext_s)(void *, const char *, int, const char *, char **, int, LDAPControlU **,
LDAPControlU **, struct timevalU *, int, void **);
+ int (CDECL *ldap_set_option)(void *, int, const void *);
+ int (CDECL *ldap_start_tls_s)(void *, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_unbind_ext)(void *, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_unbind_ext_s)(void *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_value_free_len)(struct bervalU **);
diff --git a/dlls/wldap32/winldap_private.h b/dlls/wldap32/winldap_private.h
index 20fc676c7e2..7ac7e5a3f41 100644
--- a/dlls/wldap32/winldap_private.h
+++ b/dlls/wldap32/winldap_private.h
@@ -29,6 +29,10 @@
#define WLDAP32_LBER_ERROR (~0L)
+#define WLDAP32_LDAP_VERSION1 1
+#define WLDAP32_LDAP_VERSION2 2
+#define WLDAP32_LDAP_VERSION3 3
+
typedef enum {
WLDAP32_LDAP_SUCCESS = 0x00,
WLDAP32_LDAP_UNWILLING_TO_PERFORM = 0x35,
--
2.30.2
1
0
1
0