Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- 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
June 2018
- 68 participants
- 1149 messages
[PATCH 5/8] comctl32/taskdialog: Create main instruction without templates.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 90 ++++++++++++++++++++++++++------------
1 file changed, 62 insertions(+), 28 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index bd9e68b604..46a4ce1a1d 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -50,7 +50,6 @@ static const UINT DIALOG_BUTTON_WIDTH = 50;
static const UINT DIALOG_BUTTON_HEIGHT = 14;
static const UINT DIALOG_TIMER_MS = 200;
-static const UINT ID_MAIN_INSTRUCTION = 0xf000;
static const UINT ID_CONTENT = 0xf001;
static const UINT ID_TIMER = 1;
@@ -84,6 +83,8 @@ struct taskdialog_info
DWORD last_timer_tick;
HFONT font;
HFONT main_instruction_font;
+ /* Control handles */
+ HWND main_instruction;
/* Dialog metrics */
struct
{
@@ -114,24 +115,6 @@ static void template_write_data(char **ptr, const void *src, unsigned int size)
*ptr += size;
}
-static void taskdialog_set_main_instruction_font(struct taskdialog_info *dialog_info)
-{
- NONCLIENTMETRICSW ncm;
- HWND hwnd;
-
- hwnd = GetDlgItem(dialog_info->hwnd, ID_MAIN_INSTRUCTION);
- if(!hwnd) return;
-
- ncm.cbSize = sizeof(ncm);
- SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- /* 1.25 times the height */
- ncm.lfMessageFont.lfHeight = ncm.lfMessageFont.lfHeight * 5 / 4;
- ncm.lfMessageFont.lfWeight = FW_BOLD;
- dialog_info->main_instruction_font = CreateFontIndirectW(&ncm.lfMessageFont);
-
- SendMessageW(hwnd, WM_SETFONT, (WPARAM)dialog_info->main_instruction_font, TRUE);
-}
-
static unsigned int taskdialog_add_control(struct taskdialog_template_desc *desc, WORD id, const WCHAR *class,
HINSTANCE hInstance, const WCHAR *text, DWORD style)
{
@@ -184,11 +167,6 @@ static unsigned int taskdialog_add_static_label(struct taskdialog_template_desc
return size;
}
-static unsigned int taskdialog_add_main_instruction(struct taskdialog_template_desc *desc)
-{
- return taskdialog_add_static_label(desc, ID_MAIN_INSTRUCTION, desc->taskconfig->pszMainInstruction);
-}
-
static unsigned int taskdialog_add_content(struct taskdialog_template_desc *desc)
{
return taskdialog_add_static_label(desc, ID_CONTENT, desc->taskconfig->pszContent);
@@ -351,7 +329,6 @@ static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfi
desc.control_count = 0;
desc.default_button = NULL;
- size += taskdialog_add_main_instruction(&desc);
size += taskdialog_add_content(&desc);
size += taskdialog_add_buttons(&desc);
@@ -404,6 +381,30 @@ static void taskdialog_on_button_click(struct taskdialog_info *dialog_info, WORD
EndDialog(dialog_info->hwnd, command_id);
}
+static WCHAR *taskdialog_gettext(struct taskdialog_info *dialog_info, BOOL user_resource, const WCHAR *text)
+{
+ const WCHAR *textW = NULL;
+ INT length;
+ WCHAR *ret;
+
+ if (IS_INTRESOURCE(text))
+ {
+ if (!(length = LoadStringW(user_resource ? dialog_info->taskconfig->hInstance : COMCTL32_hModule,
+ (UINT_PTR)text, (WCHAR *)&textW, 0)))
+ return NULL;
+ }
+ else
+ {
+ textW = text;
+ length = strlenW(textW);
+ }
+
+ ret = Alloc((length + 1) * sizeof(WCHAR));
+ if (ret) memcpy(ret, textW, length * sizeof(WCHAR));
+
+ return ret;
+}
+
static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND hwnd, LONG max_width, SIZE *size)
{
DWORD style = DT_EXPANDTABS | DT_CALCRECT | DT_WORDBREAK;
@@ -429,6 +430,39 @@ static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND
ReleaseDC(hwnd, hdc);
}
+static HWND taskdialog_create_label(struct taskdialog_info *dialog_info, const WCHAR *text, HFONT font)
+{
+ WCHAR *textW;
+ HWND hwnd;
+
+ if (!text) return NULL;
+
+ textW = taskdialog_gettext(dialog_info, TRUE, text);
+ hwnd = CreateWindowW(WC_STATICW, textW, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, dialog_info->hwnd, NULL, 0, NULL);
+ if (textW) Free(textW);
+
+ SendMessageW(hwnd, WM_SETFONT, (WPARAM)font, 0);
+ return hwnd;
+}
+
+static void taskdialog_add_main_instruction(struct taskdialog_info *dialog_info)
+{
+ const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ NONCLIENTMETRICSW ncm;
+
+ if (!taskconfig->pszMainInstruction) return;
+
+ ncm.cbSize = sizeof(ncm);
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
+ /* 1.25 times the height */
+ ncm.lfMessageFont.lfHeight = ncm.lfMessageFont.lfHeight * 5 / 4;
+ ncm.lfMessageFont.lfWeight = FW_BOLD;
+ dialog_info->main_instruction_font = CreateFontIndirectW(&ncm.lfMessageFont);
+
+ dialog_info->main_instruction =
+ taskdialog_create_label(dialog_info, taskconfig->pszMainInstruction, dialog_info->main_instruction_font);
+}
+
static void taskdialog_label_layout(struct taskdialog_info *dialog_info, HWND hwnd, INT start_x, LONG dialog_width,
LONG *dialog_height)
{
@@ -471,8 +505,7 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info)
v_spacing = dialog_info->m.v_spacing;
/* Main instruction */
- hwnd = GetDlgItem(dialog_info->hwnd, ID_MAIN_INSTRUCTION);
- taskdialog_label_layout(dialog_info, hwnd, 0, dialog_width, &dialog_height);
+ taskdialog_label_layout(dialog_info, dialog_info->main_instruction, 0, dialog_width, &dialog_height);
/* Content */
hwnd = GetDlgItem(dialog_info->hwnd, ID_CONTENT);
@@ -624,7 +657,8 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
dialog_info->last_timer_tick = GetTickCount();
}
- taskdialog_set_main_instruction_font(dialog_info);
+ taskdialog_add_main_instruction(dialog_info);
+
taskdialog_layout(dialog_info);
}
--
2.17.1
June 12, 2018
[PATCH 4/8] comctl32/taskdialog: Support dynamic layout.
by Zhiyi Zhang
Support dynamic layout since some controls might change
their own layout after creation.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 418 +++++++++++++++++++++----------------
1 file changed, 237 insertions(+), 181 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 549c7f2bf9..bd9e68b604 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -66,21 +66,14 @@ struct taskdialog_button_desc
{
int id;
const WCHAR *text;
- unsigned int width;
- unsigned int line;
HINSTANCE hinst;
};
struct taskdialog_template_desc
{
const TASKDIALOGCONFIG *taskconfig;
- unsigned int dialog_height;
- unsigned int dialog_width;
struct list controls;
WORD control_count;
- LONG x_baseunit;
- LONG y_baseunit;
- HFONT font;
struct taskdialog_button_desc *default_button;
};
@@ -89,23 +82,30 @@ struct taskdialog_info
HWND hwnd;
const TASKDIALOGCONFIG *taskconfig;
DWORD last_timer_tick;
+ HFONT font;
HFONT main_instruction_font;
+ /* Dialog metrics */
+ struct
+ {
+ LONG x_baseunit;
+ LONG y_baseunit;
+ LONG h_spacing;
+ LONG v_spacing;
+ } m;
};
-static void pixels_to_dialogunits(const struct taskdialog_template_desc *desc, LONG *width, LONG *height)
+struct button_layout_info
{
- if (width)
- *width = MulDiv(*width, 4, desc->x_baseunit);
- if (height)
- *height = MulDiv(*height, 8, desc->y_baseunit);
-}
+ INT id;
+ HWND hwnd;
+ LONG width;
+ LONG line;
+};
-static void dialogunits_to_pixels(const struct taskdialog_template_desc *desc, LONG *width, LONG *height)
+static void taskdialog_du_to_px(struct taskdialog_info *dialog_info, LONG *width, LONG *height)
{
- if (width)
- *width = MulDiv(*width, desc->x_baseunit, 4);
- if (height)
- *height = MulDiv(*height, desc->y_baseunit, 8);
+ if (width) *width = MulDiv(*width, dialog_info->m.x_baseunit, 4);
+ if (height) *height = MulDiv(*height, dialog_info->m.y_baseunit, 8);
}
static void template_write_data(char **ptr, const void *src, unsigned int size)
@@ -132,49 +132,8 @@ static void taskdialog_set_main_instruction_font(struct taskdialog_info *dialog_
SendMessageW(hwnd, WM_SETFONT, (WPARAM)dialog_info->main_instruction_font, TRUE);
}
-/* used to calculate size for the controls */
-static void taskdialog_get_text_extent(const struct taskdialog_template_desc *desc, const WCHAR *text,
- BOOL user_resource, SIZE *sz)
-{
- RECT rect = { 0, 0, desc->dialog_width - DIALOG_SPACING * 2, 0}; /* padding left and right of the control */
- const WCHAR *textW = NULL;
- static const WCHAR nulW;
- unsigned int length;
- HFONT oldfont;
- HDC hdc;
-
- if (IS_INTRESOURCE(text))
- {
- if (!(length = LoadStringW(user_resource ? desc->taskconfig->hInstance : COMCTL32_hModule,
- (UINT_PTR)text, (WCHAR *)&textW, 0)))
- {
- WARN("Failed to load text\n");
- textW = &nulW;
- length = 0;
- }
- }
- else
- {
- textW = text;
- length = strlenW(textW);
- }
-
- hdc = GetDC(0);
- oldfont = SelectObject(hdc, desc->font);
-
- dialogunits_to_pixels(desc, &rect.right, NULL);
- DrawTextW(hdc, textW, length, &rect, DT_LEFT | DT_EXPANDTABS | DT_CALCRECT | DT_WORDBREAK);
- pixels_to_dialogunits(desc, &rect.right, &rect.bottom);
-
- SelectObject(hdc, oldfont);
- ReleaseDC(0, hdc);
-
- sz->cx = rect.right - rect.left;
- sz->cy = rect.bottom - rect.top;
-}
-
static unsigned int taskdialog_add_control(struct taskdialog_template_desc *desc, WORD id, const WCHAR *class,
- HINSTANCE hInstance, const WCHAR *text, DWORD style, short x, short y, short cx, short cy)
+ HINSTANCE hInstance, const WCHAR *text, DWORD style)
{
struct taskdialog_control *control = Alloc(sizeof(*control));
unsigned int size, class_size, text_size;
@@ -203,10 +162,6 @@ static unsigned int taskdialog_add_control(struct taskdialog_template_desc *desc
template->style = WS_VISIBLE | style;
template->dwExtendedStyle = 0;
- template->x = x;
- template->y = y;
- template->cx = cx;
- template->cy = cy;
template->id = id;
ptr = (char *)(template + 1);
template_write_data(&ptr, class, class_size);
@@ -221,17 +176,11 @@ static unsigned int taskdialog_add_control(struct taskdialog_template_desc *desc
static unsigned int taskdialog_add_static_label(struct taskdialog_template_desc *desc, WORD id, const WCHAR *str)
{
unsigned int size;
- SIZE sz;
if (!str)
return 0;
- taskdialog_get_text_extent(desc, str, TRUE, &sz);
-
- desc->dialog_height += DIALOG_SPACING;
- size = taskdialog_add_control(desc, id, WC_STATICW, desc->taskconfig->hInstance, str, 0, DIALOG_SPACING,
- desc->dialog_height, sz.cx, sz.cy);
- desc->dialog_height += sz.cy + DIALOG_SPACING;
+ size = taskdialog_add_control(desc, id, WC_STATICW, desc->taskconfig->hInstance, str, 0);
return size;
}
@@ -248,14 +197,8 @@ static unsigned int taskdialog_add_content(struct taskdialog_template_desc *desc
static void taskdialog_init_button(struct taskdialog_button_desc *button, struct taskdialog_template_desc *desc,
int id, const WCHAR *text, BOOL custom_button)
{
- SIZE sz;
-
- taskdialog_get_text_extent(desc, text, custom_button, &sz);
-
button->id = id;
button->text = text;
- button->width = max(DIALOG_BUTTON_WIDTH, sz.cx + DIALOG_SPACING * 2);
- button->line = 0;
button->hinst = custom_button ? desc->taskconfig->hInstance : COMCTL32_hModule;
if (id == desc->taskconfig->nDefaultButton)
@@ -290,8 +233,7 @@ static void taskdialog_init_common_buttons(struct taskdialog_template_desc *desc
static unsigned int taskdialog_add_buttons(struct taskdialog_template_desc *desc)
{
- unsigned int count = 0, buttons_size, i, line_count, size = 0;
- unsigned int location_x, *line_widths, alignment = ~0u;
+ unsigned int count = 0, buttons_size, i, size = 0;
const TASKDIALOGCONFIG *taskconfig = desc->taskconfig;
struct taskdialog_button_desc *buttons;
@@ -319,78 +261,13 @@ static unsigned int taskdialog_add_buttons(struct taskdialog_template_desc *desc
if (!desc->default_button)
desc->default_button = &buttons[0];
- /* For easy handling just allocate as many lines as buttons, the worst case. */
- line_widths = Alloc(count * sizeof(*line_widths));
-
- /* Separate buttons into lines */
- location_x = DIALOG_SPACING;
- for (i = 0, line_count = 0; i < count; i++)
- {
- if (location_x + buttons[i].width + DIALOG_SPACING > desc->dialog_width)
- {
- location_x = DIALOG_SPACING;
- line_count++;
- }
-
- buttons[i].line = line_count;
-
- location_x += buttons[i].width + DIALOG_SPACING;
- line_widths[line_count] += buttons[i].width + DIALOG_SPACING;
- }
- line_count++;
-
- /* Try to balance lines so they are about the same size */
- for (i = 1; i < line_count - 1; i++)
- {
- int diff_now = abs(line_widths[i] - line_widths[i - 1]);
- unsigned int j, last_button = 0;
- int diff_changed;
-
- for (j = 0; j < count; j++)
- if (buttons[j].line == i - 1)
- last_button = j;
-
- /* Difference in length of both lines if we wrapped the last button from the last line into this one */
- diff_changed = abs(2 * buttons[last_button].width + line_widths[i] - line_widths[i - 1]);
-
- if (diff_changed < diff_now)
- {
- buttons[last_button].line = i;
- line_widths[i] += buttons[last_button].width;
- line_widths[i - 1] -= buttons[last_button].width;
- }
- }
-
- /* Calculate left alignment so all lines are as far right as possible. */
- for (i = 0; i < line_count; i++)
- {
- int new_alignment = desc->dialog_width - line_widths[i];
- if (new_alignment < alignment)
- alignment = new_alignment;
- }
-
- /* Now that we got them all positioned, create all buttons */
- location_x = alignment;
+ /* create all buttons */
for (i = 0; i < count; i++)
{
DWORD style = &buttons[i] == desc->default_button ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON;
-
- if (i > 0 && buttons[i].line != buttons[i - 1].line) /* New line */
- {
- location_x = alignment;
- desc->dialog_height += DIALOG_BUTTON_HEIGHT + DIALOG_SPACING;
- }
-
- size += taskdialog_add_control(desc, buttons[i].id, WC_BUTTONW, buttons[i].hinst, buttons[i].text, style,
- location_x, desc->dialog_height, buttons[i].width, DIALOG_BUTTON_HEIGHT);
-
- location_x += buttons[i].width + DIALOG_SPACING;
+ size += taskdialog_add_control(desc, buttons[i].id, WC_BUTTONW, buttons[i].hinst, buttons[i].text, style);
}
- /* Add height for last row and spacing */
- desc->dialog_height += DIALOG_BUTTON_HEIGHT + DIALOG_SPACING;
-
- Free(line_widths);
Free(buttons);
return size;
@@ -408,25 +285,20 @@ static void taskdialog_clear_controls(struct list *controls)
}
}
-static unsigned int taskdialog_get_reference_rect(const struct taskdialog_template_desc *desc, RECT *ret)
+static unsigned int taskdialog_get_reference_rect(const TASKDIALOGCONFIG *taskconfig, RECT *ret)
{
- HMONITOR monitor = MonitorFromWindow(desc->taskconfig->hwndParent ? desc->taskconfig->hwndParent : GetActiveWindow(),
- MONITOR_DEFAULTTOPRIMARY);
+ HMONITOR monitor = MonitorFromWindow(taskconfig->hwndParent ? taskconfig->hwndParent : GetActiveWindow(),
+ MONITOR_DEFAULTTOPRIMARY);
MONITORINFO info;
info.cbSize = sizeof(info);
GetMonitorInfoW(monitor, &info);
- if (desc->taskconfig->dwFlags & TDF_POSITION_RELATIVE_TO_WINDOW && desc->taskconfig->hwndParent)
- GetWindowRect(desc->taskconfig->hwndParent, ret);
+ if (taskconfig->dwFlags & TDF_POSITION_RELATIVE_TO_WINDOW && taskconfig->hwndParent)
+ GetWindowRect(taskconfig->hwndParent, ret);
else
*ret = info.rcWork;
- pixels_to_dialogunits(desc, &ret->left, &ret->top);
- pixels_to_dialogunits(desc, &ret->right, &ret->bottom);
-
- pixels_to_dialogunits(desc, &info.rcWork.left, &info.rcWork.top);
- pixels_to_dialogunits(desc, &info.rcWork.right, &info.rcWork.bottom);
return info.rcWork.right - info.rcWork.left;
}
@@ -447,17 +319,14 @@ static WCHAR *taskdialog_get_exe_name(WCHAR *name, DWORD length)
static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfig)
{
struct taskdialog_control *control, *control2;
- unsigned int size, title_size, screen_width;
+ unsigned int size, title_size;
struct taskdialog_template_desc desc;
static const WORD fontsize = 0x7fff;
static const WCHAR emptyW[] = { 0 };
const WCHAR *titleW = NULL;
DLGTEMPLATE *template;
- NONCLIENTMETRICSW ncm;
WCHAR pathW[MAX_PATH];
- RECT ref_rect;
char *ptr;
- HDC hdc;
/* Window title */
if (!taskconfig->pszWindowTitle)
@@ -480,21 +349,6 @@ static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfi
list_init(&desc.controls);
desc.taskconfig = taskconfig;
desc.control_count = 0;
-
- ncm.cbSize = sizeof(ncm);
- SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
- desc.font = CreateFontIndirectW(&ncm.lfMessageFont);
-
- hdc = GetDC(0);
- SelectObject(hdc, desc.font);
- desc.x_baseunit = GdiGetCharDimensions(hdc, NULL, &desc.y_baseunit);
- ReleaseDC(0, hdc);
-
- screen_width = taskdialog_get_reference_rect(&desc, &ref_rect);
-
- desc.dialog_height = 0;
- desc.dialog_width = max(taskconfig->cxWidth, DIALOG_MIN_WIDTH);
- desc.dialog_width = min(desc.dialog_width, screen_width);
desc.default_button = NULL;
size += taskdialog_add_main_instruction(&desc);
@@ -505,7 +359,6 @@ static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfi
if (!template)
{
taskdialog_clear_controls(&desc.controls);
- DeleteObject(desc.font);
return NULL;
}
@@ -514,10 +367,6 @@ static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfi
if (!(taskconfig->dwFlags & TDF_NO_SET_FOREGROUND)) template->style |= DS_SETFOREGROUND;
if (taskconfig->dwFlags & TDF_RTL_LAYOUT) template->dwExtendedStyle = WS_EX_LAYOUTRTL | WS_EX_RIGHT | WS_EX_RTLREADING;
template->cdit = desc.control_count;
- template->x = (ref_rect.left + ref_rect.right + desc.dialog_width) / 2;
- template->y = (ref_rect.top + ref_rect.bottom + desc.dialog_height) / 2;
- template->cx = desc.dialog_width;
- template->cy = desc.dialog_height;
ptr = (char *)(template + 1);
ptr += 2; /* menu */
@@ -538,7 +387,6 @@ static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfi
Free(control);
}
- DeleteObject(desc.font);
return template;
}
@@ -556,13 +404,219 @@ static void taskdialog_on_button_click(struct taskdialog_info *dialog_info, WORD
EndDialog(dialog_info->hwnd, command_id);
}
+static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND hwnd, LONG max_width, SIZE *size)
+{
+ DWORD style = DT_EXPANDTABS | DT_CALCRECT | DT_WORDBREAK;
+ HFONT hfont, old_hfont;
+ HDC hdc;
+ RECT rect = {0};
+ WCHAR text[1024];
+ INT text_length;
+
+ if (dialog_info->taskconfig->dwFlags & TDF_RTL_LAYOUT)
+ style |= DT_RIGHT | DT_RTLREADING;
+ else
+ style |= DT_LEFT;
+
+ hfont = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
+ text_length = GetWindowTextW(hwnd, text, ARRAY_SIZE(text));
+ hdc = GetDC(hwnd);
+ old_hfont = SelectObject(hdc, hfont);
+ rect.right = max_width;
+ size->cy = DrawTextW(hdc, text, text_length, &rect, style);
+ size->cx = min(max_width, rect.right - rect.left);
+ if (old_hfont) SelectObject(hdc, old_hfont);
+ ReleaseDC(hwnd, hdc);
+}
+
+static void taskdialog_label_layout(struct taskdialog_info *dialog_info, HWND hwnd, INT start_x, LONG dialog_width,
+ LONG *dialog_height)
+{
+ LONG x, y, max_width;
+ SIZE size;
+
+ if (!hwnd) return;
+
+ x = start_x + dialog_info->m.h_spacing;
+ y = *dialog_height + dialog_info->m.v_spacing;
+ max_width = dialog_width - x - dialog_info->m.h_spacing;
+ taskdialog_get_label_size(dialog_info, hwnd, max_width, &size);
+ SetWindowPos(hwnd, 0, x, y, size.cx, size.cy, SWP_NOZORDER);
+ *dialog_height = y + size.cy;
+}
+
+static void taskdialog_layout(struct taskdialog_info *dialog_info)
+{
+ const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ DWORD flags = taskconfig->dwCommonButtons;
+ static BOOL first_time = TRUE;
+ HWND hwnd;
+ RECT ref_rect;
+ LONG screen_width, dialog_width, dialog_height = 0;
+ LONG h_spacing, v_spacing;
+ INT button_max_count, button_count = 0;
+ struct button_layout_info *button_layout_infos;
+ LONG button_min_width, button_height;
+ LONG *line_widths, line_count, align;
+ LONG x, y;
+ SIZE size;
+ INT i;
+
+ screen_width = taskdialog_get_reference_rect(dialog_info->taskconfig, &ref_rect);
+ dialog_width = max(taskconfig->cxWidth, DIALOG_MIN_WIDTH);
+ taskdialog_du_to_px(dialog_info, &dialog_width, 0);
+ dialog_width = min(dialog_width, screen_width);
+
+ h_spacing = dialog_info->m.h_spacing;
+ v_spacing = dialog_info->m.v_spacing;
+
+ /* Main instruction */
+ hwnd = GetDlgItem(dialog_info->hwnd, ID_MAIN_INSTRUCTION);
+ taskdialog_label_layout(dialog_info, hwnd, 0, dialog_width, &dialog_height);
+
+ /* Content */
+ hwnd = GetDlgItem(dialog_info->hwnd, ID_CONTENT);
+ taskdialog_label_layout(dialog_info, hwnd, 0, dialog_width, &dialog_height);
+
+ /* Common and custom buttons */
+ /* Allocate enough memory for the custom and the default buttons. Maximum 6 default buttons possible. */
+ button_max_count = 6;
+ /* Custom buttons */
+ if (taskconfig->cButtons && taskconfig->pButtons) button_max_count += taskconfig->cButtons;
+
+ button_layout_infos = Alloc(button_max_count * sizeof(*button_layout_infos));
+ line_widths = Alloc(button_max_count * sizeof(*line_widths));
+
+ if (taskconfig->cButtons && taskconfig->pButtons)
+ for (button_count = 0; button_count < taskconfig->cButtons; button_count++)
+ button_layout_infos[button_count].id = taskconfig->pButtons[button_count].nButtonID;
+
+ /* Ok button may be added if no button is specified in taskconfig */
+ if (GetDlgItem(dialog_info->hwnd, IDOK)) button_layout_infos[button_count++].id = IDOK;
+ if (flags & TDCBF_YES_BUTTON) button_layout_infos[button_count++].id = IDYES;
+ if (flags & TDCBF_NO_BUTTON) button_layout_infos[button_count++].id = IDNO;
+ if (flags & TDCBF_RETRY_BUTTON) button_layout_infos[button_count++].id = IDRETRY;
+ if (flags & TDCBF_CANCEL_BUTTON) button_layout_infos[button_count++].id = IDCANCEL;
+ if (flags & TDCBF_CLOSE_BUTTON) button_layout_infos[button_count++].id = IDCLOSE;
+
+ button_min_width = DIALOG_BUTTON_WIDTH;
+ button_height = DIALOG_BUTTON_HEIGHT;
+ taskdialog_du_to_px(dialog_info, &button_min_width, &button_height);
+ for (i = 0; i < button_count; i++)
+ {
+ button_layout_infos[i].hwnd = GetDlgItem(dialog_info->hwnd, button_layout_infos[i].id);
+ taskdialog_get_label_size(dialog_info, button_layout_infos[i].hwnd, dialog_width - h_spacing * 2, &size);
+ button_layout_infos[i].width = max(size.cx, button_min_width);
+ }
+
+ /* Separate buttons into lines */
+ x = h_spacing;
+ for (i = 0, line_count = 0; i < button_count; i++)
+ {
+ if (x + button_layout_infos[i].width + h_spacing >= dialog_width)
+ {
+ x = h_spacing;
+ line_count++;
+ }
+
+ button_layout_infos[i].line = line_count;
+
+ x += button_layout_infos[i].width + h_spacing;
+ line_widths[line_count] += button_layout_infos[i].width + h_spacing;
+ }
+ line_count++;
+
+ /* Try to balance lines so they are about the same size */
+ for (i = 1; i < line_count - 1; i++)
+ {
+ int diff_now = abs(line_widths[i] - line_widths[i - 1]);
+ unsigned int j, last_button = 0;
+ int diff_changed;
+
+ for (j = 0; j < button_count; j++)
+ if (button_layout_infos[j].line == i - 1) last_button = j;
+
+ /* Difference in length of both lines if we wrapped the last button from the last line into this one */
+ diff_changed = abs(2 * button_layout_infos[last_button].width + line_widths[i] - line_widths[i - 1]);
+
+ if (diff_changed < diff_now)
+ {
+ button_layout_infos[last_button].line = i;
+ line_widths[i] += button_layout_infos[last_button].width;
+ line_widths[i - 1] -= button_layout_infos[last_button].width;
+ }
+ }
+
+ /* Calculate left alignment so all lines are as far right as possible. */
+ align = dialog_width - h_spacing;
+ for (i = 0; i < line_count; i++)
+ {
+ int new_alignment = dialog_width - line_widths[i];
+ if (new_alignment < align) align = new_alignment;
+ }
+
+ /* Now that we got them all positioned, move all buttons */
+ x = align;
+ size.cy = button_height;
+ for (i = 0; i < button_count; i++)
+ {
+ /* New line */
+ if (i > 0 && button_layout_infos[i].line != button_layout_infos[i - 1].line)
+ {
+ x = align;
+ dialog_height += size.cy + v_spacing;
+ }
+
+ y = dialog_height + v_spacing;
+ size.cx = button_layout_infos[i].width;
+ SetWindowPos(button_layout_infos[i].hwnd, 0, x, y, size.cx, size.cy, SWP_NOZORDER);
+ x += button_layout_infos[i].width + h_spacing;
+ }
+
+ /* Add height for last row button and spacing */
+ dialog_height += size.cy + v_spacing;
+
+ Free(button_layout_infos);
+ Free(line_widths);
+
+ /* Add height for spacing, title height and frame height */
+ dialog_height += v_spacing;
+ dialog_height += GetSystemMetrics(SM_CYCAPTION);
+ dialog_height += GetSystemMetrics(SM_CXDLGFRAME);
+
+ if (first_time)
+ {
+ x = (ref_rect.left + ref_rect.right + dialog_width) / 2;
+ y = (ref_rect.top + ref_rect.bottom + dialog_height) / 2;
+ SetWindowPos(dialog_info->hwnd, 0, x, y, dialog_width, dialog_height, SWP_NOZORDER);
+ first_time = FALSE;
+ }
+ else
+ SetWindowPos(dialog_info->hwnd, 0, 0, 0, dialog_width, dialog_height, SWP_NOMOVE | SWP_NOZORDER);
+}
+
static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
{
const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ NONCLIENTMETRICSW ncm;
+ HDC hdc;
+
+ ncm.cbSize = sizeof(ncm);
+ SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
memset(dialog_info, 0, sizeof(*dialog_info));
dialog_info->taskconfig = taskconfig;
dialog_info->hwnd = hwnd;
+ dialog_info->font = CreateFontIndirectW(&ncm.lfMessageFont);
+
+ hdc = GetDC(dialog_info->hwnd);
+ SelectObject(hdc, dialog_info->font);
+ dialog_info->m.x_baseunit = GdiGetCharDimensions(hdc, NULL, &dialog_info->m.y_baseunit);
+ ReleaseDC(dialog_info->hwnd, hdc);
+
+ dialog_info->m.h_spacing = DIALOG_SPACING;
+ dialog_info->m.v_spacing = DIALOG_SPACING;
+ taskdialog_du_to_px(dialog_info, &dialog_info->m.h_spacing, &dialog_info->m.v_spacing);
if (taskconfig->dwFlags & TDF_CALLBACK_TIMER)
{
@@ -571,11 +625,13 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
}
taskdialog_set_main_instruction_font(dialog_info);
+ taskdialog_layout(dialog_info);
}
static void taskdialog_destroy(struct taskdialog_info *dialog_info)
{
if (dialog_info->taskconfig->dwFlags & TDF_CALLBACK_TIMER) KillTimer(dialog_info->hwnd, ID_TIMER);
+ if (dialog_info->font) DeleteObject(dialog_info->font);
if (dialog_info->main_instruction_font) DeleteObject(dialog_info->main_instruction_font);
}
--
2.17.1
June 12, 2018
[PATCH 3/8] comctl32/taskdialog: Add taskdialog_destroy().
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 7424467af1..549c7f2bf9 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -573,6 +573,12 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
taskdialog_set_main_instruction_font(dialog_info);
}
+static void taskdialog_destroy(struct taskdialog_info *dialog_info)
+{
+ if (dialog_info->taskconfig->dwFlags & TDF_CALLBACK_TIMER) KillTimer(dialog_info->hwnd, ID_TIMER);
+ if (dialog_info->main_instruction_font) DeleteObject(dialog_info->main_instruction_font);
+}
+
static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static const WCHAR taskdialog_info_propnameW[] = {'T','a','s','k','D','i','a','l','o','g','I','n','f','o',0};
@@ -618,10 +624,7 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case WM_DESTROY:
taskdialog_notify(dialog_info, TDN_DESTROYED, 0, 0);
RemovePropW(hwnd, taskdialog_info_propnameW);
- if (dialog_info->taskconfig->dwFlags & TDF_CALLBACK_TIMER)
- KillTimer(hwnd, ID_TIMER);
- if (dialog_info->main_instruction_font)
- DeleteObject(dialog_info->main_instruction_font);
+ taskdialog_destroy(dialog_info);
break;
default:
return FALSE;
--
2.17.1
June 12, 2018
[PATCH 2/8] comctl32/taskdialog: Remove unused parameter.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 56133ffb89..7424467af1 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -430,7 +430,7 @@ static unsigned int taskdialog_get_reference_rect(const struct taskdialog_templa
return info.rcWork.right - info.rcWork.left;
}
-static WCHAR *taskdialog_get_exe_name(const TASKDIALOGCONFIG *taskconfig, WCHAR *name, DWORD length)
+static WCHAR *taskdialog_get_exe_name(WCHAR *name, DWORD length)
{
DWORD len = GetModuleFileNameW(NULL, name, length);
if (len && len < length)
@@ -461,11 +461,11 @@ static DLGTEMPLATE *create_taskdialog_template(const TASKDIALOGCONFIG *taskconfi
/* Window title */
if (!taskconfig->pszWindowTitle)
- titleW = taskdialog_get_exe_name(taskconfig, pathW, ARRAY_SIZE(pathW));
+ titleW = taskdialog_get_exe_name(pathW, ARRAY_SIZE(pathW));
else if (IS_INTRESOURCE(taskconfig->pszWindowTitle))
{
if (!LoadStringW(taskconfig->hInstance, LOWORD(taskconfig->pszWindowTitle), (WCHAR *)&titleW, 0))
- titleW = taskdialog_get_exe_name(taskconfig, pathW, ARRAY_SIZE(pathW));
+ titleW = taskdialog_get_exe_name(pathW, ARRAY_SIZE(pathW));
}
else
titleW = taskconfig->pszWindowTitle;
--
2.17.1
June 12, 2018
[PATCH 1/8] comctl32/taskdialog: Zero out taskdialog_info at initialization.
by Zhiyi Zhang
Zero init taskdialog_info to avoid garbage values.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 346a079ab6..56133ffb89 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -560,6 +560,8 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
{
const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ memset(dialog_info, 0, sizeof(*dialog_info));
+ dialog_info->taskconfig = taskconfig;
dialog_info->hwnd = hwnd;
if (taskconfig->dwFlags & TDF_CALLBACK_TIMER)
--
2.17.1
June 12, 2018
[PATCH v2 2/2] msvcrt: Don't reimplement call_unwind_func().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/msvcrt/except_i386.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c
index 3f22f3e..5812d10 100644
--- a/dlls/msvcrt/except_i386.c
+++ b/dlls/msvcrt/except_i386.c
@@ -59,7 +59,7 @@ typedef struct __catchblock_info
UINT flags; /* flags (see below) */
const type_info *type_info; /* C++ type caught by this block */
int offset; /* stack offset to copy exception object to */
- void (*handler)(void);/* catch block handler code */
+ void * (*handler)(void);/* catch block handler code */
} catchblock_info;
#define TYPE_FLAG_CONST 1
#define TYPE_FLAG_VOLATILE 2
@@ -78,8 +78,8 @@ typedef struct __tryblock_info
/* info about the unwind handler for a given trylevel */
typedef struct __unwind_info
{
- int prev; /* prev trylevel unwind handler, to run after this one */
- void (*handler)(void);/* unwind handler */
+ int prev; /* prev trylevel unwind handler, to run after this one */
+ void * (*handler)(void);/* unwind handler */
} unwind_info;
/* descriptor of all try blocks of a given function */
@@ -137,22 +137,6 @@ DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame
const cxx_function_descr *descr,
EXCEPTION_REGISTRATION_RECORD* nested_frame, int nested_trylevel ) DECLSPEC_HIDDEN;
-/* call a function with a given ebp */
-static inline void *call_ebp_func( void *func, void *ebp )
-{
- void *ret;
- int dummy;
- __asm__ __volatile__ ("pushl %%ebx\n\t"
- "pushl %%ebp\n\t"
- "movl %4,%%ebp\n\t"
- "call *%%eax\n\t"
- "popl %%ebp\n\t"
- "popl %%ebx"
- : "=a" (ret), "=S" (dummy), "=D" (dummy)
- : "0" (func), "1" (ebp) : "ecx", "edx", "memory" );
- return ret;
-}
-
/* call a copy constructor */
extern void call_copy_ctor( void *func, void *this, void *src, int has_vbase );
@@ -326,7 +310,7 @@ static void copy_exception( void *object, cxx_exception_frame *frame,
/* unwind the local function up to a given trylevel */
static void cxx_local_unwind( cxx_exception_frame* frame, const cxx_function_descr *descr, int last_level)
{
- void (*handler)(void);
+ void * (*handler)(void);
int trylevel = frame->trylevel;
while (trylevel != last_level)
@@ -341,7 +325,7 @@ static void cxx_local_unwind( cxx_exception_frame* frame, const cxx_function_des
{
TRACE( "calling unwind handler %p trylevel %d last %d ebp %p\n",
handler, trylevel, last_level, &frame->ebp );
- call_ebp_func( handler, &frame->ebp );
+ call_handler( handler, &frame->ebp );
}
trylevel = descr->unwind_table[trylevel].prev;
}
@@ -478,7 +462,7 @@ static inline void call_catch_block( PEXCEPTION_RECORD rec, CONTEXT *context,
nested_frame.trylevel = nested_trylevel + 1;
__wine_push_frame( &nested_frame.frame );
- addr = call_ebp_func( catchblock->handler, &frame->ebp );
+ addr = call_handler( catchblock->handler, &frame->ebp );
__wine_pop_frame( &nested_frame.frame );
((DWORD*)frame)[-1] = save_esp;
--
2.7.4
June 11, 2018
[PATCH v2 1/2] msvcrt: Avoid using inline assembly in call_unwind_func().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
v2: rename to call_handler() and use void * as return type.
dlls/msvcrt/except_i386.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/dlls/msvcrt/except_i386.c b/dlls/msvcrt/except_i386.c
index 29540cd..3f22f3e 100644
--- a/dlls/msvcrt/except_i386.c
+++ b/dlls/msvcrt/except_i386.c
@@ -107,7 +107,7 @@ typedef struct _SCOPETABLE
{
int previousTryLevel;
int (*lpfnFilter)(PEXCEPTION_POINTERS);
- int (*lpfnHandler)(void);
+ void * (*lpfnHandler)(void);
} SCOPETABLE, *PSCOPETABLE;
typedef struct _MSVCRT_EXCEPTION_FRAME
@@ -198,24 +198,20 @@ __ASM_GLOBAL_FUNC( call_filter,
"popl %ebp\n\t"
"ret" );
-static inline int call_unwind_func( int (*func)(void), void *ebp )
-{
- int ret;
- __asm__ __volatile__ ("pushl %%ebp\n\t"
- "pushl %%ebx\n\t"
- "pushl %%esi\n\t"
- "pushl %%edi\n\t"
- "movl %2,%%ebp\n\t"
- "call *%0\n\t"
- "popl %%edi\n\t"
- "popl %%esi\n\t"
- "popl %%ebx\n\t"
- "popl %%ebp"
- : "=a" (ret)
- : "0" (func), "r" (ebp)
- : "ecx", "edx", "memory" );
- return ret;
-}
+extern void *call_handler( void * (*func)(void), void *ebp );
+
+__ASM_GLOBAL_FUNC( call_handler,
+ "pushl %ebp\n\t"
+ "pushl %ebx\n\t"
+ "pushl %esi\n\t"
+ "pushl %edi\n\t"
+ "movl 24(%esp), %ebp\n\t"
+ "call *20(%esp)\n\t"
+ "popl %edi\n\t"
+ "popl %esi\n\t"
+ "popl %ebx\n\t"
+ "popl %ebp\n\t"
+ "ret" );
static inline void dump_type( const cxx_type_info *type )
{
@@ -806,7 +802,7 @@ static void msvcrt_local_unwind2(MSVCRT_EXCEPTION_FRAME* frame, int trylevel, vo
{
TRACE( "__try block cleanup level %d handler %p ebp %p\n",
level, frame->scopetable[level].lpfnHandler, ebp );
- call_unwind_func( frame->scopetable[level].lpfnHandler, ebp );
+ call_handler( frame->scopetable[level].lpfnHandler, ebp );
}
}
__wine_pop_frame(®);
@@ -833,7 +829,7 @@ static void msvcrt_local_unwind4( ULONG *cookie, MSVCRT_EXCEPTION_FRAME* frame,
{
TRACE( "__try block cleanup level %d handler %p ebp %p\n",
level, scopetable->entries[level].lpfnHandler, ebp );
- call_unwind_func( scopetable->entries[level].lpfnHandler, ebp );
+ call_handler( scopetable->entries[level].lpfnHandler, ebp );
}
}
__wine_pop_frame(®);
--
2.7.4
June 11, 2018
[PATCH 7/7] wsdapi: Build types list when parsing Probe message.
by Owen Rudge
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/soap.c | 91
++++++++++++++++++++++++++++++++++++++++++-
dlls/wsdapi/tests/discovery.c | 2 +-
dlls/wsdapi/wsdapi_internal.h | 1 +
dlls/wsdapi/xml.c | 16 ++++++++
4 files changed, 108 insertions(+), 2 deletions(-)
June 11, 2018
[PATCH 6/7] wsdapi: Implement probe message parsing.
by Owen Rudge
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/soap.c | 40
+++++++++++++++++++++++++++++++++++++++-
dlls/wsdapi/tests/discovery.c | 4 ++--
2 files changed, 41 insertions(+), 3 deletions(-)
June 11, 2018
[PATCH 5/7] wsdapi: Return "any" headers in read_message.
by Owen Rudge
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/soap.c | 40
++++++++++++++++++++++++++++++++++++++++
dlls/wsdapi/tests/discovery.c | 2 +-
2 files changed, 41 insertions(+), 1 deletion(-)
June 11, 2018
[PATCH 4/7] wsdapi: Add initial support for reading messages; identify Probe message.
by Owen Rudge
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/soap.c | 388
+++++++++++++++++++++++++++++++++++++++++-
dlls/wsdapi/tests/discovery.c | 6 +-
2 files changed, 389 insertions(+), 5 deletions(-)
June 11, 2018
[PATCH 3/7] wsdapi: Add stub for Probe message parsing, prepare notification sink message.
by Owen Rudge
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/network.c | 60
++++++++++++++++++++++++++++++++++++++++++-
dlls/wsdapi/soap.c | 6 +++++
dlls/wsdapi/wsdapi_internal.h | 5 ++++
3 files changed, 70 insertions(+), 1 deletion(-)
June 11, 2018
[PATCH 2/7] wsdapi: Add critical section around notification sinks.
by Owen Rudge
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/discovery.c | 9 +++++++++
dlls/wsdapi/wsdapi_internal.h | 1 +
2 files changed, 10 insertions(+)
June 11, 2018
[PATCH 1/7] wsdapi: Add support for listening for UDP multicast broadcasts.
by Owen Rudge
v2: Returns HRESULT from functions where applicable, adds Probe message
body parsing to avoid leaving todo_wine statements in place.
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/network.c | 281
+++++++++++++++++++++++++++++++++++++++++-
dlls/wsdapi/wsdapi_internal.h | 4 +
2 files changed, 284 insertions(+), 1 deletion(-)
June 11, 2018
[PATCH] msxml3/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msxml3/tests/domdoc.c | 24 ++++++++++++------------
dlls/msxml3/tests/httpreq.c | 4 ++--
dlls/msxml3/tests/saxreader.c | 32 ++++++++++++++++----------------
dlls/msxml3/tests/schema.c | 2 +-
4 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 23c17ea978..d5f30fec62 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -102,7 +102,7 @@ static void get_class_support_data(struct msxmlsupported_data_t *table)
HRESULT hr;
int i;
- for (i = 0; i < sizeof(table->ifaces)/sizeof(table->ifaces[0]) && table->ifaces[i] != NULL; i++)
+ for (i = 0; i < ARRAY_SIZE(table->ifaces) && table->ifaces[i] != NULL; i++)
{
hr = CoCreateInstance(table->clsid, NULL, CLSCTX_INPROC_SERVER, table->ifaces[i], (void**)&unk);
if (hr == S_OK) IUnknown_Release(unk);
@@ -124,7 +124,7 @@ static BOOL is_clsid_supported(const GUID *clsid, REFIID riid)
{
int i;
- for (i = 0; i < sizeof(table->ifaces)/sizeof(table->ifaces[0]) && table->ifaces[i] != NULL; i++)
+ for (i = 0; i < ARRAY_SIZE(table->ifaces) && table->ifaces[i] != NULL; i++)
if (table->ifaces[i] == riid) return table->supported[i];
}
@@ -1238,7 +1238,7 @@ static int alloced_bstrs_count;
static BSTR _bstr_(const char *str)
{
- assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
+ assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs));
alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
return alloced_bstrs[alloced_bstrs_count++];
}
@@ -10834,13 +10834,13 @@ static void test_mxnamespacemanager_override(void)
&IID_IMXNamespaceManager, (void**)&nsmgr);
EXPECT_HR(hr, S_OK);
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 0, buffW, &len);
EXPECT_HR(hr, S_OK);
ok(!lstrcmpW(buffW, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW));
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 1, buffW, &len);
EXPECT_HR(hr, E_FAIL);
@@ -10859,7 +10859,7 @@ static void test_mxnamespacemanager_override(void)
hr = IMXNamespaceManager_declarePrefix(nsmgr, NULL, _bstr_("ns0 uri"));
EXPECT_HR(hr, S_OK);
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getURI(nsmgr, _bstr_(""), NULL, buffW, &len);
EXPECT_HR(hr, S_OK);
@@ -10868,19 +10868,19 @@ static void test_mxnamespacemanager_override(void)
hr = IMXNamespaceManager_declarePrefix(nsmgr, _bstr_("ns0"), _bstr_("ns0 uri"));
EXPECT_HR(hr, S_OK);
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 0, buffW, &len);
EXPECT_HR(hr, S_OK);
ok(!lstrcmpW(buffW, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW));
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 1, buffW, &len);
EXPECT_HR(hr, S_OK);
ok(!lstrcmpW(buffW, _bstr_("ns0")), "got prefix %s\n", wine_dbgstr_w(buffW));
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 2, buffW, &len);
EXPECT_HR(hr, S_OK);
@@ -10890,7 +10890,7 @@ static void test_mxnamespacemanager_override(void)
hr = IMXNamespaceManager_declarePrefix(nsmgr, _bstr_("ns1"), _bstr_("ns1 uri"));
EXPECT_HR(hr, S_OK);
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 1, buffW, &len);
EXPECT_HR(hr, S_OK);
@@ -10911,13 +10911,13 @@ static void test_mxnamespacemanager_override(void)
hr = IMXNamespaceManager_declarePrefix(nsmgr, NULL, _bstr_("ns0 uri override"));
EXPECT_HR(hr, S_FALSE);
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getURI(nsmgr, _bstr_(""), NULL, buffW, &len);
EXPECT_HR(hr, S_OK);
ok(!lstrcmpW(buffW, _bstr_("ns0 uri override")), "got uri %s\n", wine_dbgstr_w(buffW));
- len = sizeof(buffW)/sizeof(WCHAR);
+ len = ARRAY_SIZE(buffW);
buffW[0] = 0;
hr = IMXNamespaceManager_getDeclaredPrefix(nsmgr, 3, buffW, &len);
EXPECT_HR(hr, S_OK);
diff --git a/dlls/msxml3/tests/httpreq.c b/dlls/msxml3/tests/httpreq.c
index f20f18fb63..ae0a95a2f1 100644
--- a/dlls/msxml3/tests/httpreq.c
+++ b/dlls/msxml3/tests/httpreq.c
@@ -97,7 +97,7 @@ static int g_unexpectedcall, g_expectedcall;
static int strcmp_wa(const WCHAR *strw, const char *stra)
{
WCHAR buf[512];
- MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf);
}
@@ -117,7 +117,7 @@ static BSTR _bstr_(const char *str)
if(!str)
return NULL;
- assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
+ assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs));
alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
return alloced_bstrs[alloced_bstrs_count++];
}
diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c
index 3ed332edb6..eeef5b64c1 100644
--- a/dlls/msxml3/tests/saxreader.c
+++ b/dlls/msxml3/tests/saxreader.c
@@ -90,7 +90,7 @@ static int alloced_bstrs_count;
static BSTR _bstr_(const char *str)
{
- assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
+ assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs));
alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
return alloced_bstrs[alloced_bstrs_count++];
}
@@ -144,7 +144,7 @@ static void test_saxstr(const char *file, unsigned line, BSTR str, const char *e
/* exit earlier on length mismatch */
if (lenexp != len) return;
- MultiByteToWideChar(CP_ACP, 0, expected, -1, buf, sizeof(buf)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, expected, -1, buf, ARRAY_SIZE(buf));
cmp = memcmp(str, buf, lenexp*sizeof(WCHAR));
if (cmp && todo)
@@ -2952,7 +2952,7 @@ static void test_mxwriter_handlers(void)
EXPECT_REF(writer, 1);
- for (i = 0; i < sizeof(riids)/sizeof(REFIID); i++)
+ for (i = 0; i < ARRAY_SIZE(riids); i++)
{
IUnknown *handler;
IMXWriter *writer2;
@@ -3976,7 +3976,7 @@ static void test_mxwriter_characters(void)
hr = ISAXContentHandler_characters(content, chardataW, 0);
EXPECT_HR(hr, S_OK);
- hr = ISAXContentHandler_characters(content, chardataW, sizeof(chardataW)/sizeof(WCHAR) - 1);
+ hr = ISAXContentHandler_characters(content, chardataW, ARRAY_SIZE(chardataW) - 1);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
@@ -4166,7 +4166,7 @@ static void test_mxwriter_stream(void)
IStream *stream;
LARGE_INTEGER pos;
ULARGE_INTEGER pos2;
- DWORD test_count = sizeof(mxwriter_stream_tests)/sizeof(mxwriter_stream_tests[0]);
+ DWORD test_count = ARRAY_SIZE(mxwriter_stream_tests);
for(current_stream_test_index = 0; current_stream_test_index < test_count; ++current_stream_test_index) {
const mxwriter_stream_test *test = mxwriter_stream_tests+current_stream_test_index;
@@ -4640,7 +4640,7 @@ static void test_mxwriter_comment(void)
ok(!lstrcmpW(_bstr_("<!---->\r\n"), V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest)));
VariantClear(&dest);
- hr = ISAXLexicalHandler_comment(lexical, commentW, sizeof(commentW)/sizeof(WCHAR)-1);
+ hr = ISAXLexicalHandler_comment(lexical, commentW, ARRAY_SIZE(commentW) - 1);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
@@ -4865,16 +4865,16 @@ static void test_mxwriter_dtd(void)
hr = IVBSAXLexicalHandler_startDTD(vblexical, NULL, NULL, NULL);
EXPECT_HR(hr, E_POINTER);
- hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, pubW, sizeof(pubW)/sizeof(WCHAR), NULL, 0);
+ hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, pubW, ARRAY_SIZE(pubW), NULL, 0);
EXPECT_HR(hr, E_INVALIDARG);
- hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, NULL, 0, sysW, sizeof(sysW)/sizeof(WCHAR));
+ hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, NULL, 0, sysW, ARRAY_SIZE(sysW));
EXPECT_HR(hr, E_INVALIDARG);
- hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, pubW, sizeof(pubW)/sizeof(WCHAR), sysW, sizeof(sysW)/sizeof(WCHAR));
+ hr = ISAXLexicalHandler_startDTD(lexical, NULL, 0, pubW, ARRAY_SIZE(pubW), sysW, ARRAY_SIZE(sysW));
EXPECT_HR(hr, E_INVALIDARG);
- hr = ISAXLexicalHandler_startDTD(lexical, nameW, sizeof(nameW)/sizeof(WCHAR), NULL, 0, NULL, 0);
+ hr = ISAXLexicalHandler_startDTD(lexical, nameW, ARRAY_SIZE(nameW), NULL, 0, NULL, 0);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
@@ -4885,11 +4885,11 @@ static void test_mxwriter_dtd(void)
VariantClear(&dest);
/* system id is required if public is present */
- hr = ISAXLexicalHandler_startDTD(lexical, nameW, sizeof(nameW)/sizeof(WCHAR), pubW, sizeof(pubW)/sizeof(WCHAR), NULL, 0);
+ hr = ISAXLexicalHandler_startDTD(lexical, nameW, ARRAY_SIZE(nameW), pubW, ARRAY_SIZE(pubW), NULL, 0);
EXPECT_HR(hr, E_INVALIDARG);
- hr = ISAXLexicalHandler_startDTD(lexical, nameW, sizeof(nameW)/sizeof(WCHAR),
- pubW, sizeof(pubW)/sizeof(WCHAR), sysW, sizeof(sysW)/sizeof(WCHAR));
+ hr = ISAXLexicalHandler_startDTD(lexical, nameW, ARRAY_SIZE(nameW),
+ pubW, ARRAY_SIZE(pubW), sysW, ARRAY_SIZE(sysW));
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
@@ -4926,10 +4926,10 @@ static void test_mxwriter_dtd(void)
hr = IVBSAXDeclHandler_elementDecl(vbdecl, NULL, NULL);
EXPECT_HR(hr, E_POINTER);
- hr = ISAXDeclHandler_elementDecl(decl, nameW, sizeof(nameW)/sizeof(WCHAR), NULL, 0);
+ hr = ISAXDeclHandler_elementDecl(decl, nameW, ARRAY_SIZE(nameW), NULL, 0);
EXPECT_HR(hr, E_INVALIDARG);
- hr = ISAXDeclHandler_elementDecl(decl, nameW, sizeof(nameW)/sizeof(WCHAR), contentW, sizeof(contentW)/sizeof(WCHAR));
+ hr = ISAXDeclHandler_elementDecl(decl, nameW, ARRAY_SIZE(nameW), contentW, ARRAY_SIZE(contentW));
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
@@ -4944,7 +4944,7 @@ static void test_mxwriter_dtd(void)
hr = IMXWriter_put_output(writer, dest);
EXPECT_HR(hr, S_OK);
- hr = ISAXDeclHandler_elementDecl(decl, nameW, sizeof(nameW)/sizeof(WCHAR), contentW, 0);
+ hr = ISAXDeclHandler_elementDecl(decl, nameW, ARRAY_SIZE(nameW), contentW, 0);
EXPECT_HR(hr, S_OK);
V_VT(&dest) = VT_EMPTY;
diff --git a/dlls/msxml3/tests/schema.c b/dlls/msxml3/tests/schema.c
index 48d1c5bce4..9e5116f38f 100644
--- a/dlls/msxml3/tests/schema.c
+++ b/dlls/msxml3/tests/schema.c
@@ -452,7 +452,7 @@ static BSTR alloc_str_from_narrow(const char *str)
static BSTR _bstr_(const char *str)
{
- assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
+ assert(alloced_bstrs_count < ARRAY_SIZE(alloced_bstrs));
alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
return alloced_bstrs[alloced_bstrs_count++];
}
--
2.14.4
June 11, 2018
[PATCH] winhttp/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/winhttp/tests/notification.c | 20 ++++++++++----------
dlls/winhttp/tests/winhttp.c | 24 ++++++++++++------------
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c
index 2a647e3633..086f2e7935 100644
--- a/dlls/winhttp/tests/notification.c
+++ b/dlls/winhttp/tests/notification.c
@@ -187,7 +187,7 @@ static void test_connection_cache( void )
struct info info, *context = &info;
info.test = cache_test;
- info.count = sizeof(cache_test) / sizeof(cache_test[0]);
+ info.count = ARRAY_SIZE( cache_test );
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -427,7 +427,7 @@ static void test_redirect( void )
struct info info, *context = &info;
info.test = redirect_test;
- info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
+ info.count = ARRAY_SIZE( redirect_test );
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -508,7 +508,7 @@ static void test_async( void )
char buffer[1024];
info.test = async_test;
- info.count = sizeof(async_test) / sizeof(async_test[0]);
+ info.count = ARRAY_SIZE( async_test );
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@@ -779,12 +779,12 @@ static void open_async_request(int port, struct test_request *req, struct info *
if (reuse_connection)
{
info->test = reuse_socket_request_test;
- info->count = sizeof(reuse_socket_request_test) / sizeof(reuse_socket_request_test[0]);
+ info->count = ARRAY_SIZE( reuse_socket_request_test );
}
else
{
info->test = open_socket_request_test;
- info->count = sizeof(open_socket_request_test) / sizeof(open_socket_request_test[0]);
+ info->count = ARRAY_SIZE( open_socket_request_test );
}
req->session = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
@@ -830,7 +830,7 @@ static void server_send_reply(struct test_request *req, struct info *info, const
WaitForSingleObject( info->wait, INFINITE );
info->test = server_reply_test;
- info->count = sizeof(server_reply_test) / sizeof(server_reply_test[0]);
+ info->count = ARRAY_SIZE( server_reply_test );
info->index = 0;
setup_test( info, winhttp_send_request, __LINE__ );
ret = WinHttpReceiveResponse( req->request, NULL );
@@ -879,12 +879,12 @@ static void close_request(struct test_request *req, struct info *info, BOOL allo
if (allow_closing_connection)
{
info->test = close_allow_connection_close_request_test;
- info->count = sizeof(close_allow_connection_close_request_test)/sizeof(*close_allow_connection_close_request_test);
+ info->count = ARRAY_SIZE( close_allow_connection_close_request_test );
}
else
{
info->test = close_request_test;
- info->count = sizeof(close_request_test)/sizeof(*close_request_test);
+ info->count = ARRAY_SIZE( close_request_test );
}
info->index = 0;
setup_test( info, winhttp_close_handle, __LINE__ );
@@ -926,12 +926,12 @@ static void _read_request_data(struct test_request *req, struct info *info, cons
if (closing_connection)
{
info->test = read_allow_close_test;
- info->count = sizeof(read_allow_close_test)/sizeof(*read_allow_close_test);
+ info->count = ARRAY_SIZE( read_allow_close_test );
}
else
{
info->test = read_test;
- info->count = sizeof(read_test)/sizeof(*read_test);
+ info->count = ARRAY_SIZE( read_test );
}
info->index = 0;
diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c
index 4b4a84c5fc..46504e1b0c 100644
--- a/dlls/winhttp/tests/winhttp.c
+++ b/dlls/winhttp/tests/winhttp.c
@@ -2907,7 +2907,7 @@ static void test_not_modified(int port)
memcpy(today, ifmodifiedW, sizeof(ifmodifiedW));
GetSystemTime(&st);
- WinHttpTimeFromSystemTime(&st, &today[sizeof(ifmodifiedW)/sizeof(WCHAR)]);
+ WinHttpTimeFromSystemTime(&st, &today[ARRAY_SIZE(ifmodifiedW)]);
session = WinHttpOpen(test_useragent, WINHTTP_ACCESS_TYPE_NO_PROXY,
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
@@ -3277,13 +3277,13 @@ static void test_credentials(void)
req = WinHttpOpenRequest(con, NULL, NULL, NULL, NULL, NULL, 0);
ok(req != NULL, "failed to open a request %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_USERNAME, &buffer, &size);
ok(ret, "failed to query proxy username %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
ok(!size, "expected 0, got %u\n", size);
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_PASSWORD, &buffer, &size);
ok(ret, "failed to query proxy password %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3292,19 +3292,19 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_USERNAME, proxy_userW, lstrlenW(proxy_userW));
ok(ret, "failed to set username %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_USERNAME, &buffer, &size);
ok(ret, "failed to query proxy username %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, proxy_userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
ok(size == lstrlenW(proxy_userW) * sizeof(WCHAR), "unexpected result %u\n", size);
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
ok(ret, "failed to query username %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
ok(!size, "expected 0, got %u\n", size);
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
ok(ret, "failed to query password %u\n", GetLastError());
ok(!buffer[0], "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3313,7 +3313,7 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_PROXY_PASSWORD, proxy_passW, lstrlenW(proxy_passW));
ok(ret, "failed to set proxy password %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PROXY_PASSWORD, &buffer, &size);
ok(ret, "failed to query proxy password %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, proxy_passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3322,7 +3322,7 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_USERNAME, userW, lstrlenW(userW));
ok(ret, "failed to set username %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
ok(ret, "failed to query username %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, userW), "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3331,7 +3331,7 @@ static void test_credentials(void)
ret = WinHttpSetOption(req, WINHTTP_OPTION_PASSWORD, passW, lstrlenW(passW));
ok(ret, "failed to set password %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
ok(ret, "failed to query password %u\n", GetLastError());
ok(!winetest_strcmpW(buffer, passW), "unexpected result %s\n", wine_dbgstr_w(buffer));
@@ -3357,7 +3357,7 @@ static void test_credentials(void)
ret = WinHttpSetCredentials(req, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC, userW, passW, NULL);
ok(ret, "failed to set credentials %u\n", GetLastError());
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_USERNAME, &buffer, &size);
ok(ret, "failed to query username %u\n", GetLastError());
todo_wine {
@@ -3365,7 +3365,7 @@ static void test_credentials(void)
ok(!size, "expected 0, got %u\n", size);
}
- size = sizeof(buffer)/sizeof(WCHAR);
+ size = ARRAY_SIZE(buffer);
ret = WinHttpQueryOption(req, WINHTTP_OPTION_PASSWORD, &buffer, &size);
ok(ret, "failed to query password %u\n", GetLastError());
todo_wine {
@@ -3920,7 +3920,7 @@ static void test_IWinHttpRequest(int port)
ok( hr == S_OK, "got %08x\n", hr );
sprintf( buf, "http://localhost:%d/auth", port );
- MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, sizeof(bufW)/sizeof(bufW[0]) );
+ MultiByteToWideChar( CP_ACP, 0, buf, -1, bufW, ARRAY_SIZE( bufW ));
url = SysAllocString( bufW );
method = SysAllocString( method3W );
V_VT( &async ) = VT_BOOL;
--
2.14.4
June 11, 2018
Re: [PATCH 1/3] msvcrt: Add _crt_at_quick_exit stub
by Piotr Caban
On 06/11/18 23:02, Fabian Maurer wrote:
> Hi Piotr,
>
> > The func argument should probably use CDECL calling convention (not that
>
> > it really matters in case of no-arguments function).
>
> I did it like MSVCRT__crt_atexit did it, first pass the func like this
> and then cast to MSVCRT__onexit_t. Should I make it MSVCRT__onexit_t
> right away?
I think it's better to keep function header the same as in native. Could
you please also change MSVCRT__crt_atexit header while you're at it?
Thanks,
Piotr
June 11, 2018
Re: [PATCH 3/3] msvcrt: Implement quick_exit and _crt_at_quick_exit
by Piotr Caban
Hi,
On 06/05/18 22:42, Fabian Maurer wrote:
> Code taken from onexit logic and adapted-
Why don't you just call onexit functions instead of reimplementing it?
Note that you don't need to call MSVCRT__initialize_onexit_table when
quick_exit table is declared static.
Thanks,
Piotr
June 11, 2018
Re: [PATCH 2/3] msvcrt: Add quick_exit
by Piotr Caban
Hi,
On 06/05/18 22:42, Fabian Maurer wrote:
> +/*********************************************************************
> + * quick_exit (MSVCRT.@)
> + */
> +void CDECL MSVCRT_quick_exit(int exitcode)
> +{
> + FIXME("partial stub: (%d)\n", exitcode);
> + MSVCRT__exit(exitcode);
> +}
quick_exit function should not call exit. I'm attaching a test that
shows that atexit callbacks should not be called.
Thanks,
Piotr
June 11, 2018
Re: [PATCH 1/3] msvcrt: Add _crt_at_quick_exit stub
by Fabian Maurer
Hi Piotr,
> The func argument should probably use CDECL calling convention (not that
> it really matters in case of no-arguments function).
I did it like MSVCRT__crt_atexit did it, first pass the func like this and then cast to
MSVCRT__onexit_t. Should I make it MSVCRT__onexit_t right away?
> Also it's probably better to return -1 (error) in stub.
Sure can do, although it doesn't matter too much since I later replace it anyways.
Regards,
Fabian Maurer
June 11, 2018
Re: [PATCH 4/5] msvcrt: Avoid using inline assembly in call_unwind_func().
by Zebediah Figura
On 06/11/2018 11:48 AM, Piotr Caban wrote:
> Hi Zeb,
>
> On 06/05/18 00:23, Zebediah Figura wrote:
>> +extern int call_unwind_func( int (*func)(void), void *ebp );
>> +
>> +__ASM_GLOBAL_FUNC( call_unwind_func,
>> + "pushl %ebp\n\t"
>> + "pushl %ebx\n\t"
>> + "pushl %esi\n\t"
>> + "pushl %edi\n\t"
>> + "movl 24(%esp), %ebp\n\t"
>> + "call *20(%esp)\n\t"
>> + "popl %edi\n\t"
>> + "popl %esi\n\t"
>> + "popl %ebx\n\t"
>> + "popl %ebp\n\t"
>> + "ret" );
>
> How about renaming the function to call_handler and returning void* from
> it? It looks strange that in all places where return value is used we
> need to cast it to pointer.
>
> Thanks,
> Piotr
Thanks; I'll send an updated patch.
June 11, 2018
Re: [PATCH 1/3] msvcrt: Add _crt_at_quick_exit stub
by Piotr Caban
Hi Fabian,
On 06/05/18 22:42, Fabian Maurer wrote:
> +/*********************************************************************
> + * _crt_at_quick_exit (UCRTBASE.@)
> + */
> +int CDECL MSVCRT__crt_at_quick_exit(void (*func)(void))
> +{
> + FIXME("stub: (%p)\n", func);
> + return 0;
> +}
The func argument should probably use CDECL calling convention (not that
it really matters in case of no-arguments function). Also it's probably
better to return -1 (error) in stub.
Thanks,
Piotr
June 11, 2018
Re: [PATCH] vcomp/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
I already sent this patch in as 146709.
It is pending Sebastian's signed off.
bye
michael
On 06/11/2018 09:33 PM, André Hentschel wrote:
> Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
> ---
> dlls/vcomp/tests/vcomp.c | 56 ++++++++++++++++++++++++------------------------
> 1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/dlls/vcomp/tests/vcomp.c b/dlls/vcomp/tests/vcomp.c
> index 154744b..ea62909 100644
> --- a/dlls/vcomp/tests/vcomp.c
> +++ b/dlls/vcomp/tests/vcomp.c
> @@ -766,7 +766,7 @@ static void CDECL for_static_simple_cb(void)
> int thread_num = pomp_get_thread_num();
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned int my_begin, my_end, begin, end;
>
> @@ -966,7 +966,7 @@ static void CDECL for_static_cb(void)
> int thread_num = pomp_get_thread_num();
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> int my_begin, my_end, my_next, my_lastchunk;
> int begin, end, next, lastchunk;
> @@ -1614,25 +1614,25 @@ static void test_atomic_integer8(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> char val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> char val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> ok(val == tests2[i].expected, "test %d: expected val == %d, got %d\n", i, tests2[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests3); i++)
> {
> unsigned char val = tests3[i].v1;
> tests3[i].func(&val, tests3[i].v2);
> ok(val == tests3[i].expected, "test %d: expected val == %u, got %u\n", i, tests3[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests4); i++)
> {
> unsigned char val = tests4[i].v1;
> tests4[i].func(&val, tests4[i].v2);
> @@ -1707,25 +1707,25 @@ static void test_atomic_integer16(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> short val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> short val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> ok(val == tests2[i].expected, "test %d: expected val == %d, got %d\n", i, tests2[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests3); i++)
> {
> unsigned short val = tests3[i].v1;
> tests3[i].func(&val, tests3[i].v2);
> ok(val == tests3[i].expected, "test %d: expected val == %u, got %u\n", i, tests3[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests4); i++)
> {
> unsigned short val = tests4[i].v1;
> tests4[i].func(&val, tests4[i].v2);
> @@ -1777,13 +1777,13 @@ static void test_atomic_integer32(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> int val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: expected val == %d, got %d\n", i, tests1[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> unsigned int val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> @@ -1871,26 +1871,26 @@ static void test_atomic_integer64(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests1)/sizeof(tests1[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests1); i++)
> {
> LONG64 val = tests1[i].v1;
> tests1[i].func(&val, tests1[i].v2);
> ok(val == tests1[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests2)/sizeof(tests2[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests2); i++)
> {
> LONG64 val = tests2[i].v1;
> tests2[i].func(&val, tests2[i].v2);
> todo_wine_if(tests2[i].todo)
> ok(val == tests2[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests3)/sizeof(tests3[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests3); i++)
> {
> ULONG64 val = tests3[i].v1;
> tests3[i].func(&val, tests3[i].v2);
> ok(val == tests3[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests4)/sizeof(tests4[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests4); i++)
> {
> ULONG64 val = tests4[i].v1;
> tests4[i].func(&val, tests4[i].v2);
> @@ -1915,7 +1915,7 @@ static void test_atomic_float(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> float val = tests[i].v1;
> tests[i].func(&val, tests[i].v2);
> @@ -1940,7 +1940,7 @@ static void test_atomic_double(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> double val = tests[i].v1;
> tests[i].func(&val, tests[i].v2);
> @@ -1978,13 +1978,13 @@ static void test_reduction_integer8(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> char val = tests[i].v1;
> p_vcomp_reduction_i1(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: expected val == %d, got %d\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned char val = tests[i].v1;
> p_vcomp_reduction_u1(tests[i].flags, &val, tests[i].v2);
> @@ -2022,13 +2022,13 @@ static void test_reduction_integer16(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> short val = tests[i].v1;
> p_vcomp_reduction_i2(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: expected val == %d, got %d\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned short val = tests[i].v1;
> p_vcomp_reduction_u2(tests[i].flags, &val, tests[i].v2);
> @@ -2105,13 +2105,13 @@ static void test_reduction_integer32(void)
>
> pomp_set_num_threads(max_threads);
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> int val = tests[i].v1;
> p_vcomp_reduction_i4(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: expected val == %d, got %d\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> unsigned int val = tests[i].v1;
> p_vcomp_reduction_u4(tests[i].flags, &val, tests[i].v2);
> @@ -2148,13 +2148,13 @@ static void test_reduction_integer64(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> LONG64 val = tests[i].v1;
> p_vcomp_reduction_i8(tests[i].flags, &val, tests[i].v2);
> ok(val == tests[i].expected, "test %d: unexpectedly got %s\n", i, wine_dbgstr_longlong(val));
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> ULONG64 val = tests[i].v1;
> p_vcomp_reduction_u8(tests[i].flags, &val, tests[i].v2);
> @@ -2206,14 +2206,14 @@ static void test_reduction_float_double(void)
> };
> int i;
>
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> float val = tests[i].v1;
> p_vcomp_reduction_r4(tests[i].flags, &val, tests[i].v2);
> ok(tests[i].expected - 0.001 < val && val < tests[i].expected + 0.001,
> "test %d: expected val == %f, got %f\n", i, tests[i].expected, val);
> }
> - for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
> + for (i = 0; i < ARRAY_SIZE(tests); i++)
> {
> double val = tests[i].v1;
> p_vcomp_reduction_r8(tests[i].flags, &val, tests[i].v2);
>
June 11, 2018
Re: [PATCH] ws2_32/tests: Use the available ARRAY_SIZE() macro
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39073
Your paranoid android.
=== w7u (32 bit sock) ===
sock.c:10956: Test failed: got 0
sock.c:10957: Test failed: got 00000000
sock.c:10958: Test failed: got 0000
sock.c:10959: Test failed: got 00000000
sock.c:10960: Test failed: got 00000000
sock.c:10970: Test failed: got 0464,000002f4,00000002
=== w1064 (64 bit sock) ===
sock.c:8629: Test failed: bytesReturned isn't supposed to be 1
sock.c:8653: Test failed: GetOverlappedResult failed, error 0
June 11, 2018
[PATCH] ws2_32/tests: Use the available ARRAY_SIZE() macro
by André Hentschel
Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
---
dlls/ws2_32/tests/protocol.c | 4 +--
dlls/ws2_32/tests/sock.c | 58 +++++++++++++++++++++-----------------------
2 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index 9c6d80d..99bd137 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -113,7 +113,7 @@ static void test_WSAEnumProtocolsA(void)
ok( ret >= 2, "Expected at least 2 items, received %d\n", ret);
for (i = found = 0; i < ret; i++)
- for (j = 0; j < sizeof(ptest) / sizeof(ptest[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(ptest); j++)
if (buffer[i].iProtocol == ptest[j])
{
found |= 1 << j;
@@ -180,7 +180,7 @@ static void test_WSAEnumProtocolsW(void)
ok( ret >= 2, "Expected at least 2 items, received %d\n", ret);
for (i = found = 0; i < ret; i++)
- for (j = 0; j < sizeof(ptest) / sizeof(ptest[0]); j++)
+ for (j = 0; j < ARRAY_SIZE(ptest); j++)
if (buffer[i].iProtocol == ptest[j])
{
found |= 1 << j;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 6dd1491..b32d1c0 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1191,7 +1191,7 @@ static void test_WithWSAStartup(void)
ok(ptr != NULL, "gethostbyname() failed unexpectedly: %d\n", WSAGetLastError());
/* Alloc some sockets to check if they are destroyed on WSACleanup */
- for (socks = 0; socks < sizeof(pairs) / sizeof(pairs[0]); socks++)
+ for (socks = 0; socks < ARRAY_SIZE(pairs); socks++)
{
WSAPROTOCOL_INFOA info;
if (tcp_socketpair(&pairs[socks].src, &pairs[socks].dst)) break;
@@ -1471,7 +1471,7 @@ static void test_set_getsockopt(void)
todo_wine ok( value == 4096, "expected 4096, got %u\n", value );
/* SO_LINGER */
- for( i = 0; i < sizeof(linger_testvals)/sizeof(LINGER);i++) {
+ for( i = 0; i < ARRAY_SIZE(linger_testvals);i++) {
size = sizeof(lingval);
lingval = linger_testvals[i];
err = setsockopt(s, SOL_SOCKET, SO_LINGER, (char *) &lingval, size);
@@ -1630,7 +1630,7 @@ todo_wine
closesocket(s);
/* test SO_PROTOCOL_INFO structure returned for different protocols */
- for (i = 0; i < sizeof(prottest) / sizeof(prottest[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(prottest); i++)
{
int k;
@@ -2083,7 +2083,7 @@ static void test_ip_pktinfo(void)
/* Note: hdr.Control.len is set below */
hdr.dwFlags = 0;
- for (i=0;i<sizeof(addresses)/sizeof(UINT32);i++)
+ for (i=0;i<ARRAY_SIZE(addresses);i++)
{
s1addr.sin_addr.s_addr = addresses[i];
@@ -2689,7 +2689,7 @@ static void test_WSASocket(void)
/* when no socket type is specified the first entry from WSAEnumProtocols
* that matches the protocol is returned */
- for (i = 0; i < sizeof(autoprotocols) / sizeof(autoprotocols[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(autoprotocols); i++)
{
sock = WSASocketA(0, 0, autoprotocols[i], NULL, 0, 0);
ok(sock != INVALID_SOCKET, "Failed to create socket for protocol %d, received %d\n",
@@ -3010,7 +3010,7 @@ static void test_WSAEnumNetworkEvents(void)
/* This test follows the steps from bugs 10204 and 24946 */
for (l = 0; l < 2; l++)
{
- for (i = 0; i < sizeof(sock_type) / sizeof(sock_type[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(sock_type); i++)
{
if (i == 2)
ok(!tcp_socketpair(&s, &s2), "Test[%d]: creating socket pair failed\n", i);
@@ -3280,7 +3280,7 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address, expect1 ), "Expected different address string\n" );
- ok( len == sizeof( expect1 )/sizeof( WCHAR ), "Got size %d\n", len);
+ ok( len == ARRAY_SIZE(expect1), "Got size %d\n", len);
len = sizeof(address);
@@ -3314,7 +3314,7 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address, expect4 ), "Expected different address string\n" );
- ok( len == sizeof( expect4 )/sizeof( WCHAR ), "Got %d\n", len);
+ ok( len == ARRAY_SIZE(expect4), "Got %d\n", len);
/*check to see it IPv6 is available */
v6 = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
@@ -3325,7 +3325,7 @@ static void test_WSAAddressToStringW(void)
}
/* Test a short IPv6 address */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0x0000;
@@ -3335,10 +3335,10 @@ static void test_WSAAddressToStringW(void)
ret = WSAAddressToStringW( (SOCKADDR*)&sockaddr6, sizeof(sockaddr6), NULL, address6, &len );
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_1 ), "Wrong string returned\n" );
- ok( len == sizeof(expect6_1)/sizeof(WCHAR), "Got %d\n", len);
+ ok( len == ARRAY_SIZE(expect6_1), "Got %d\n", len);
/* Test a longer IPv6 address */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0x0000;
@@ -3349,10 +3349,10 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_2 ), "Wrong string returned\n" );
- ok( len == sizeof(expect6_2)/sizeof(WCHAR), "Got %d\n", len);
+ ok( len == ARRAY_SIZE(expect6_2), "Got %d\n", len);
/* Test IPv6 address and port number */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0xfa81;
@@ -3363,10 +3363,10 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_3 ),
"Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3), wine_dbgstr_w(address6) );
- ok( len == sizeof(expect6_3)/sizeof(WCHAR), "Got %d\n", len );
+ ok( len == ARRAY_SIZE(expect6_3), "Got %d\n", len );
/* Test IPv6 address, port number and scope_id */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0xfa81;
@@ -3377,10 +3377,10 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_3_2 ),
"Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_2), wine_dbgstr_w(address6) );
- ok( len == sizeof(expect6_3_2)/sizeof(WCHAR), "Got %d\n", len );
+ ok( len == ARRAY_SIZE(expect6_3_2), "Got %d\n", len );
/* Test IPv6 address and scope_id */
- len = sizeof(address6)/sizeof(WCHAR);
+ len = ARRAY_SIZE(address6);
sockaddr6.sin6_family = AF_INET6;
sockaddr6.sin6_port = 0x0000;
@@ -3391,7 +3391,7 @@ static void test_WSAAddressToStringW(void)
ok( !ret, "WSAAddressToStringW() failed unexpectedly: %d\n", WSAGetLastError() );
ok( !lstrcmpW( address6, expect6_3_3 ),
"Expected: %s, got: %s\n", wine_dbgstr_w(expect6_3_3), wine_dbgstr_w(address6) );
- ok( len == sizeof(expect6_3_3)/sizeof(WCHAR), "Got %d\n", len );
+ ok( len == ARRAY_SIZE(expect6_3_3), "Got %d\n", len );
end:
if (v6 != INVALID_SOCKET)
@@ -5112,7 +5112,7 @@ static void test_inet_pton(void)
return;
}
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
WSASetLastError(0xdeadbeef);
ret = pInetPtonA(tests[i].family, tests[i].printable, buffer);
@@ -5137,11 +5137,10 @@ static void test_inet_pton(void)
i, tests[i].collapsed, ptr);
}
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
if (tests[i].printable)
- MultiByteToWideChar(CP_ACP, 0, tests[i].printable, -1, printableW,
- sizeof(printableW) / sizeof(printableW[0]));
+ MultiByteToWideChar(CP_ACP, 0, tests[i].printable, -1, printableW, ARRAY_SIZE(printableW));
WSASetLastError(0xdeadbeef);
ret = pInetPtonW(tests[i].family, tests[i].printable ? printableW : NULL, buffer);
ok(ret == tests[i].ret, "Test [%d]: Expected %d, got %d\n", i, tests[i].ret, ret);
@@ -5157,13 +5156,12 @@ static void test_inet_pton(void)
/* Test the result from Pton with Ntop */
printableW[0] = 0xdead;
- ptrW = pInetNtopW(tests[i].family, buffer, printableW, sizeof(printableW) / sizeof(printableW[0]));
+ ptrW = pInetNtopW(tests[i].family, buffer, printableW, ARRAY_SIZE(printableW));
ok (ptrW != NULL, "Test [%d]: Failed with NULL\n", i);
ok (ptrW == printableW, "Test [%d]: Pointers differ (%p != %p)\n", i, ptrW, printableW);
if (!ptrW) continue;
- MultiByteToWideChar(CP_ACP, 0, tests[i].collapsed, -1, collapsedW,
- sizeof(collapsedW) / sizeof(collapsedW[0]));
+ MultiByteToWideChar(CP_ACP, 0, tests[i].collapsed, -1, collapsedW, ARRAY_SIZE(collapsedW));
ok (lstrcmpW(ptrW, collapsedW) == 0, "Test [%d]: Expected '%s', got '%s'\n",
i, tests[i].collapsed, wine_dbgstr_w(ptrW));
}
@@ -5189,7 +5187,7 @@ static void test_ioctlsocket(void)
return;
}
- for(i = 0; i < sizeof(cmds)/sizeof(cmds[0]); i++)
+ for(i = 0; i < ARRAY_SIZE(cmds); i++)
{
/* broken apps like defcon pass the argp value directly instead of a pointer to it */
ret = ioctlsocket(sock, cmds[i], (u_long *)1);
@@ -7345,7 +7343,7 @@ static void test_GetAddrInfoW(void)
int i, ret;
ADDRINFOW *result, *result2, *p, hint;
WCHAR name[256];
- DWORD size = sizeof(name)/sizeof(WCHAR);
+ DWORD size = ARRAY_SIZE(name);
/* te su to.winehq.org written in katakana */
static const WCHAR idn_domain[] =
{0x30C6,0x30B9,0x30C8,'.','w','i','n','e','h','q','.','o','r','g',0};
@@ -7483,7 +7481,7 @@ static void test_GetAddrInfoW(void)
ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n", WSAGetLastError());
ok(result == NULL, "got %p\n", result);
- for (i = 0;i < (sizeof(hinttests) / sizeof(hinttests[0]));i++)
+ for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
{
hint.ai_family = hinttests[i].family;
hint.ai_socktype = hinttests[i].socktype;
@@ -7939,7 +7937,7 @@ static void test_getaddrinfo(void)
hint.ai_flags = 0;
- for (i = 0;i < (sizeof(hinttests) / sizeof(hinttests[0]));i++)
+ for (i = 0;i < (ARRAY_SIZE(hinttests));i++)
{
hint.ai_family = hinttests[i].family;
hint.ai_socktype = hinttests[i].socktype;
@@ -11504,7 +11502,7 @@ START_TEST( sock )
test_ip_pktinfo();
test_extendedSocketOptions();
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
trace ( " **** STARTING TEST %d ****\n", i );
do_test ( &tests[i] );
--
2.7.4
June 11, 2018