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
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48486
Signed-off-by: Gijs Vermeulen <gijsvrm(a)gmail.com>
---
v2: merge patches and simplify by calculating len in WCMD_keyword_ws_found() (Thanks Hugh)
Superseeds 203619 & 203620
programs/cmd/builtins.c | 48 +++++++++++++++++++----------------------
programs/cmd/wcmd.h | 2 +-
programs/cmd/wcmdmain.c | 45 +++++++++++++++-----------------------
3 files changed, 40 insertions(+), 55 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 0fb40d94e49..502694ffc46 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1533,8 +1533,6 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
BOOL processThese = executecmds;
while (*cmdList) {
- static const WCHAR ifElse[] = {'e','l','s','e'};
-
/* execute all appropriate commands */
curPosition = *cmdList;
@@ -1566,13 +1564,13 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
/* End of the command - does 'ELSE ' follow as the next command? */
} else {
- if (isIF && WCMD_keyword_ws_found(ifElse, ARRAY_SIZE(ifElse), (*cmdList)->command)) {
+ if (isIF && WCMD_keyword_ws_found(L"else", (*cmdList)->command)) {
/* Swap between if and else processing */
processThese = !executecmds;
/* Process the ELSE part */
if (processThese) {
- const int keyw_len = ARRAY_SIZE(ifElse) + 1;
+ const int keyw_len = lstrlenW(L"else") + 1;
WCHAR *cmd = ((*cmdList)->command) + keyw_len;
/* Skip leading whitespace between condition and the command */
@@ -1599,8 +1597,7 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
the same bracket depth as the IF, then the IF statement is over. This is required
to handle nested ifs properly */
} else if (isIF && (*cmdList)->bracketDepth == myDepth) {
- static const WCHAR doW[] = {'d','o'};
- if (WCMD_keyword_ws_found(doW, ARRAY_SIZE(doW), (*cmdList)->command)) {
+ if (WCMD_keyword_ws_found(L"do", (*cmdList)->command)) {
WINE_TRACE("Still inside FOR-loop, not an end of IF statement\n");
*cmdList = (*cmdList)->nextcommand;
} else {
@@ -1642,11 +1639,11 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
WCHAR *pos = options;
int len = lstrlenW(pos);
- static const WCHAR eolW[] = {'e','o','l','='};
- static const WCHAR skipW[] = {'s','k','i','p','='};
- static const WCHAR tokensW[] = {'t','o','k','e','n','s','='};
- static const WCHAR delimsW[] = {'d','e','l','i','m','s','='};
- static const WCHAR usebackqW[] = {'u','s','e','b','a','c','k','q'};
+ const int eol_len = lstrlenW(L"eol=");
+ const int skip_len = lstrlenW(L"skip=");
+ const int tokens_len = lstrlenW(L"tokens=");
+ const int delims_len = lstrlenW(L"delims=");
+ const int usebackq_len = lstrlenW(L"usebackq");
/* Initialize to defaults */
lstrcpyW(delims, L" \t");
@@ -1668,35 +1665,35 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
/* Save End of line character (Ignore line if first token (based on delims) starts with it) */
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- pos, ARRAY_SIZE(eolW), eolW, ARRAY_SIZE(eolW)) == CSTR_EQUAL) {
- *eol = *(pos + ARRAY_SIZE(eolW));
- pos = pos + ARRAY_SIZE(eolW) + 1;
+ pos, eol_len, L"eol=", eol_len) == CSTR_EQUAL) {
+ *eol = *(pos + eol_len);
+ pos = pos + eol_len + 1;
WINE_TRACE("Found eol as %c(%x)\n", *eol, *eol);
/* Save number of lines to skip (Can be in base 10, hex (0x...) or octal (0xx) */
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- pos, ARRAY_SIZE(skipW), skipW, ARRAY_SIZE(skipW)) == CSTR_EQUAL) {
+ pos, skip_len, L"skip=", skip_len) == CSTR_EQUAL) {
WCHAR *nextchar = NULL;
- pos = pos + ARRAY_SIZE(skipW);
+ pos = pos + skip_len;
*skip = wcstoul(pos, &nextchar, 0);
WINE_TRACE("Found skip as %d lines\n", *skip);
pos = nextchar;
/* Save if usebackq semantics are in effect */
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, pos,
- ARRAY_SIZE(usebackqW), usebackqW, ARRAY_SIZE(usebackqW)) == CSTR_EQUAL) {
+ usebackq_len, L"usebackq", usebackq_len) == CSTR_EQUAL) {
*usebackq = TRUE;
- pos = pos + ARRAY_SIZE(usebackqW);
+ pos = pos + usebackq_len;
WINE_TRACE("Found usebackq\n");
/* Save the supplied delims. Slightly odd as space can be a delimiter but only
if you finish the optionsroot string with delims= otherwise the space is
just a token delimiter! */
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- pos, ARRAY_SIZE(delimsW), delimsW, ARRAY_SIZE(delimsW)) == CSTR_EQUAL) {
+ pos, delims_len, L"delims=", delims_len) == CSTR_EQUAL) {
int i=0;
- pos = pos + ARRAY_SIZE(delimsW);
+ pos = pos + delims_len;
while (*pos && *pos != ' ') {
delims[i++] = *pos;
pos++;
@@ -1707,10 +1704,10 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
/* Save the tokens being requested */
} else if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- pos, ARRAY_SIZE(tokensW), tokensW, ARRAY_SIZE(tokensW)) == CSTR_EQUAL) {
+ pos, tokens_len, L"tokens=", tokens_len) == CSTR_EQUAL) {
int i=0;
- pos = pos + ARRAY_SIZE(tokensW);
+ pos = pos + tokens_len;
while (*pos && *pos != ' ') {
tokens[i++] = *pos;
pos++;
@@ -2109,8 +2106,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
WIN32_FIND_DATAW fd;
HANDLE hff;
int i;
- static const WCHAR inW[] = {'i','n'};
- static const WCHAR doW[] = {'d','o'};
+ const int in_len = lstrlenW(L"in");
CMD_LIST *setStart, *thisSet, *cmdStart, *cmdEnd;
WCHAR variable[4];
int varidx = -1;
@@ -2210,7 +2206,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
thisArg = WCMD_parameter(p, parameterNo++, NULL, FALSE, FALSE);
if (!thisArg
|| !(CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
- thisArg, ARRAY_SIZE(inW), inW, ARRAY_SIZE(inW)) == CSTR_EQUAL)) {
+ thisArg, in_len, L"in", in_len) == CSTR_EQUAL)) {
WCMD_output_stderr (WCMD_LoadMessage(WCMD_SYNTAXERR));
return;
}
@@ -2235,7 +2231,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
/* Syntax error if missing close bracket, or nothing following it
and once we have the complete set, we expect a DO */
WINE_TRACE("Looking for 'do ' in %p\n", *cmdList);
- if ((*cmdList == NULL) || !WCMD_keyword_ws_found(doW, ARRAY_SIZE(doW), (*cmdList)->command)) {
+ if ((*cmdList == NULL) || !WCMD_keyword_ws_found(L"do", (*cmdList)->command)) {
WCMD_output_stderr (WCMD_LoadMessage(WCMD_SYNTAXERR));
return;
}
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 468a29102d7..a02395ca123 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -110,7 +110,7 @@ WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **start, BOOL raw, BOOL wholecmdli
WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, BOOL raw,
BOOL wholecmdline, const WCHAR *delims);
WCHAR *WCMD_skip_leading_spaces (WCHAR *string);
-BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr);
+BOOL WCMD_keyword_ws_found(const WCHAR *keyword, const WCHAR *ptr);
void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute);
WCHAR *WCMD_strip_quotes(WCHAR *cmd);
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index dd7d14e50e5..acf8f63b1f1 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -473,7 +473,8 @@ WCHAR *WCMD_skip_leading_spaces (WCHAR *string) {
* Checks if the string located at ptr matches a keyword (of length len)
* followed by a whitespace character (space or tab)
*/
-BOOL WCMD_keyword_ws_found(const WCHAR *keyword, int len, const WCHAR *ptr) {
+BOOL WCMD_keyword_ws_found(const WCHAR *keyword, const WCHAR *ptr) {
+ const int len = lstrlenW(keyword);
return (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
ptr, len, keyword, len) == CSTR_EQUAL)
&& ((*(ptr + len) == ' ') || (*(ptr + len) == '\t'));
@@ -1813,11 +1814,6 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
CMD_LIST *lastEntry = NULL;
CMD_DELIMITERS prevDelim = CMD_NONE;
static WCHAR *extraSpace = NULL; /* Deliberately never freed */
- static const WCHAR remCmd[] = {'r','e','m'};
- static const WCHAR forCmd[] = {'f','o','r'};
- static const WCHAR ifCmd[] = {'i','f'};
- static const WCHAR ifElse[] = {'e','l','s','e'};
- static const WCHAR setCmd[] = {'s','e','t'};
BOOL inOneLine = FALSE;
BOOL inFor = FALSE;
BOOL inIn = FALSE;
@@ -1870,10 +1866,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Show prompt before batch line IF echo is on and in batch program */
if (context && echo_mode && *curPos && (*curPos != '@')) {
- static const WCHAR echoDot[] = {'e','c','h','o','.'};
- static const WCHAR echoCol[] = {'e','c','h','o',':'};
- static const WCHAR echoSlash[] = {'e','c','h','o','/'};
- const DWORD len = ARRAY_SIZE(echoDot);
+ const DWORD len = lstrlenW(L"echo.");
DWORD curr_size = lstrlenW(curPos);
DWORD min_len = (curr_size < len ? curr_size : len);
WCMD_show_prompt(TRUE);
@@ -1881,11 +1874,11 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* I don't know why Windows puts a space here but it does */
/* Except for lines starting with 'echo.', 'echo:' or 'echo/'. Ask MS why */
if (CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
- curPos, min_len, echoDot, len) != CSTR_EQUAL
+ curPos, min_len, L"echo.", len) != CSTR_EQUAL
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
- curPos, min_len, echoCol, len) != CSTR_EQUAL
+ curPos, min_len, L"echo:", len) != CSTR_EQUAL
&& CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
- curPos, min_len, echoSlash, len) != CSTR_EQUAL)
+ curPos, min_len, L"echo/", len) != CSTR_EQUAL)
{
WCMD_output_asis(L" ");
}
@@ -1921,13 +1914,11 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Certain commands need special handling */
if (curStringLen == 0 && curCopyTo == curString) {
- static const WCHAR forDO[] = {'d','o'};
-
/* If command starts with 'rem ' or identifies a label, ignore any &&, ( etc. */
- if (WCMD_keyword_ws_found(remCmd, ARRAY_SIZE(remCmd), curPos) || *curPos == ':') {
+ if (WCMD_keyword_ws_found(L"rem", curPos) || *curPos == ':') {
inOneLine = TRUE;
- } else if (WCMD_keyword_ws_found(forCmd, ARRAY_SIZE(forCmd), curPos)) {
+ } else if (WCMD_keyword_ws_found(L"for", curPos)) {
inFor = TRUE;
/* If command starts with 'if ' or 'else ', handle ('s mid line. We should ensure this
@@ -1935,14 +1926,14 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
should suffice for now.
To be able to handle ('s in the condition part take as much as evaluate_if_condition
would take and skip parsing it here. */
- } else if (WCMD_keyword_ws_found(ifCmd, ARRAY_SIZE(ifCmd), curPos)) {
+ } else if (WCMD_keyword_ws_found(L"if", curPos)) {
int negate; /* Negate condition */
int test; /* Condition evaluation result */
WCHAR *p, *command;
inIf = TRUE;
- p = curPos+(ARRAY_SIZE(ifCmd));
+ p = curPos+(lstrlenW(L"if"));
while (*p == ' ' || *p == '\t')
p++;
WCMD_parse (p, quals, param1, param2);
@@ -1960,11 +1951,11 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
curPos+=if_condition_len;
}
- if (WCMD_keyword_ws_found(setCmd, ARRAY_SIZE(setCmd), curPos))
+ if (WCMD_keyword_ws_found(L"set", curPos))
ignoreBracket = TRUE;
- } else if (WCMD_keyword_ws_found(ifElse, ARRAY_SIZE(ifElse), curPos)) {
- const int keyw_len = ARRAY_SIZE(ifElse) + 1;
+ } else if (WCMD_keyword_ws_found(L"else", curPos)) {
+ const int keyw_len = lstrlenW(L"else") + 1;
inElse = TRUE;
lastWasElse = TRUE;
onlyWhiteSpace = TRUE;
@@ -1985,8 +1976,8 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* In a for loop, the DO command will follow a close bracket followed by
whitespace, followed by DO, ie closeBracket inserts a NULL entry, curLen
is then 0, and all whitespace is skipped */
- } else if (inFor && WCMD_keyword_ws_found(forDO, ARRAY_SIZE(forDO), curPos)) {
- const int keyw_len = ARRAY_SIZE(forDO) + 1;
+ } else if (inFor && WCMD_keyword_ws_found(L"do", curPos)) {
+ const int keyw_len = lstrlenW(L"do") + 1;
WINE_TRACE("Found 'DO '\n");
lastWasDo = TRUE;
onlyWhiteSpace = TRUE;
@@ -1999,12 +1990,10 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Special handling for the 'FOR' command */
if (inFor && lastWasWhiteSpace) {
- static const WCHAR forIN[] = {'i','n'};
-
WINE_TRACE("Found 'FOR ', comparing next parm: '%s'\n", wine_dbgstr_w(curPos));
- if (WCMD_keyword_ws_found(forIN, ARRAY_SIZE(forIN), curPos)) {
- const int keyw_len = ARRAY_SIZE(forIN) + 1;
+ if (WCMD_keyword_ws_found(L"in", curPos)) {
+ const int keyw_len = lstrlenW(L"in") + 1;
WINE_TRACE("Found 'IN '\n");
lastWasIn = TRUE;
onlyWhiteSpace = TRUE;
--
2.31.1
1
0
[PATCH] reg/tests: Refactor 'add' tests into registry types, keys and syntax checks
by Hugh McMaster April 15, 2021
by Hugh McMaster April 15, 2021
April 15, 2021
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
---
programs/reg/tests/add.c | 253 ++++++++++++++++++++++++++-------------
1 file changed, 167 insertions(+), 86 deletions(-)
diff --git a/programs/reg/tests/add.c b/programs/reg/tests/add.c
index 30e5fe55667..8357e9ad0bc 100644
--- a/programs/reg/tests/add.c
+++ b/programs/reg/tests/add.c
@@ -204,12 +204,9 @@ void delete_value_(const char *file, unsigned line, const HKEY hkey, const char
/* Unit tests */
-static void test_add(void)
+static void test_command_syntax(void)
{
- HKEY hkey, hsubkey;
- LONG err;
- DWORD r, dword, type, size;
- char buffer[22];
+ DWORD r;
delete_tree(HKEY_CURRENT_USER, KEY_BASE);
verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE);
@@ -226,19 +223,56 @@ static void test_add(void)
run_reg_exe("reg add -H", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ /* Duplicate switches */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v Test /f", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f /t REG_SZ", &r);
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
+ "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f /d 456", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /f /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
- open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ /* No /v argument */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ /* Test invalid switches */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
/* Test empty type */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
+}
+
+static void test_key_formats(void)
+{
+ HKEY hkey;
+ DWORD r;
+ LONG err;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- /* Test input key formats */
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
verify_key_nonexist(hkey, "keytest0");
@@ -257,13 +291,19 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_key(hkey, "keytest3");
- delete_key(hkey, "keytest3");
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest4 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_key(hkey, "keytest4");
- delete_key(hkey, "keytest4");
+ run_reg_exe("reg add HKCU\\" KEY_BASE "\\https://winehq.org /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ verify_key(hkey, "https://winehq.org");
+
+ close_key(hkey);
+ delete_tree(HKEY_CURRENT_USER, KEY_BASE);
+
+ /* Test validity of trailing backslash after system key */
run_reg_exe("reg add HKCU\\ /v Value1 /t REG_SZ /d foo /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
todo_wine verify_reg_nonexist(HKEY_CURRENT_USER, "Value1");
@@ -271,8 +311,44 @@ static void test_add(void)
run_reg_exe("reg add HKEY_CURRENT_USER\\ /v Value2 /t REG_SZ /d bar /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
todo_wine verify_reg_nonexist(HKEY_CURRENT_USER, "Value2");
+}
+
+static void test_add(void)
+{
+ HKEY hkey, hsubkey;
+ DWORD r, dword;
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ 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_value(hkey, "Test1", REG_SZ, "Value1", 7);
+ dword = 0x123;
+ add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword));
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+
+ verify_key(HKEY_CURRENT_USER, KEY_BASE);
+ verify_key(hkey, "Subkey");
+ verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
+ verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0);
+
+ close_key(hkey);
+ delete_tree(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_none(void)
+{
+ HKEY hkey;
+ DWORD r;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- /* REG_NONE */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
@@ -285,7 +361,17 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_NONE, "\0", 2, 0);
- /* REG_SZ */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_sz(void)
+{
+ HKEY hkey;
+ DWORD r;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %d, expected 0\n", r);
@@ -340,7 +426,26 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, "\\0", REG_SZ, "Value", 6, 0);
- /* REG_EXPAND_SZ */
+ /* Test support for forward and back slashes in value names */
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v count/up /d one/two/three /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ verify_reg(hkey, "count/up", REG_SZ, "one/two/three", 14, 0);
+
+ run_reg_exe("reg add HKCU\\" KEY_BASE " /v \\foo\\bar /f", &r);
+ ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ verify_reg(hkey, "\\foo\\bar", REG_SZ, "", 1, 0);
+
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_expand_sz(void)
+{
+ HKEY hkey;
+ DWORD r;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
@@ -365,7 +470,19 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_EXPAND_SZ, "", 1, 0);
- /* REG_BINARY */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_binary(void)
+{
+ HKEY hkey;
+ DWORD r, dword, type, size;
+ char buffer[22];
+ LONG err;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, "bin0", REG_BINARY, buffer, 0, 0);
@@ -389,7 +506,7 @@ static void test_add(void)
/* Remaining nibble prefixed */
buffer[0] = 0x0d; buffer[1] = 0xea; buffer[2] = 0xdb;
buffer[3] = 0xee; buffer[4] = 0xf0; buffer[5] = 0xdd;
- /* Remaining nibble suffixed on winXP */
+ /* Remaining nibble suffixed on WinXP */
buffer[6] = 0xde; buffer[7] = 0xad; buffer[8] = 0xbe;
buffer[9] = 0xef; buffer[10] = 0x0d; buffer[11] = 0xd0;
size = 6;
@@ -411,7 +528,18 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_BINARY, buffer, 0, 0);
- /* REG_DWORD */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_dword(void)
+{
+ HKEY hkey;
+ DWORD r, dword, type, size;
+ LONG err;
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /f /d 12345678", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
"got exit code %d, expected 0\n", r);
@@ -510,7 +638,18 @@ static void test_add(void)
run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /t REG_DWORD_BIG_ENDIAN /f", &r);
ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u, expected 1\n", r);
- /* REG_MULTI_SZ */
+ close_key(hkey);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
+}
+
+static void test_reg_multi_sz(void)
+{
+ HKEY hkey;
+ DWORD r;
+ char buffer[22];
+
+ add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
+
run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
memcpy(buffer, "three\0little\0strings\0", 22);
@@ -596,74 +735,8 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %u, expected 0\n", r);
verify_reg(hkey, NULL, REG_MULTI_SZ, buffer, 1, 0);
- /* Test forward and back slashes */
- run_reg_exe("reg add HKCU\\" KEY_BASE "\\https://winehq.org /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_key(hkey, "https://winehq.org");
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v count/up /d one/two/three /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "count/up", REG_SZ, "one/two/three", 14, 0);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v \\foo\\bar /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- verify_reg(hkey, "\\foo\\bar", REG_SZ, "", 1, 0);
-
close_key(hkey);
- delete_tree(HKEY_CURRENT_USER, KEY_BASE);
-
- /* Test duplicate switches */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /t REG_DWORD /d 0x1 /v Test /f", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f /t REG_SZ", &r);
- ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
- "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f /d 456", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- /* Multiple /v* switches */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v Wine /ve", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- /* No /v argument */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /d Test /f /v", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
-
- /* Test invalid switches */
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid1 /a", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid2 /ae", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid3 /", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /v invalid4 -", &r);
- ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
-
- /* Test whether overwriting a registry key modifies existing keys and values */
- add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey);
- add_key(hkey, "Subkey", &hsubkey);
- close_key(hsubkey);
- add_value(hkey, "Test1", REG_SZ, "Value1", 7);
- dword = 0x123;
- add_value(hkey, "Test2", REG_DWORD, &dword, sizeof(dword));
-
- run_reg_exe("reg add HKCU\\" KEY_BASE " /f", &r);
- ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
-
- verify_key(HKEY_CURRENT_USER, KEY_BASE);
- verify_key(hkey, "Subkey");
- verify_reg(hkey, "Test1", REG_SZ, "Value1", 7, 0);
- verify_reg(hkey, "Test2", REG_DWORD, &dword, sizeof(dword), 0);
-
- delete_tree(HKEY_CURRENT_USER, KEY_BASE);
+ delete_key(HKEY_CURRENT_USER, KEY_BASE);
}
START_TEST(add)
@@ -675,5 +748,13 @@ START_TEST(add)
return;
}
+ test_command_syntax();
+ test_key_formats();
test_add();
+ test_reg_none();
+ test_reg_sz();
+ test_reg_expand_sz();
+ test_reg_binary();
+ test_reg_dword();
+ test_reg_multi_sz();
}
--
2.31.0
1
0
April 15, 2021
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/dwrite/tests/font.c | 58 ++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 14 deletions(-)
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 54e279ea11e..9f814504a44 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -8445,31 +8445,46 @@ static void test_HasKerningPairs(void)
ok(ref == 0, "factory not released, %u\n", ref);
}
+static float get_scaled_metric(const DWRITE_GLYPH_RUN *run, float metric, const DWRITE_FONT_METRICS *m)
+{
+ return run->fontEmSize * metric / m->designUnitsPerEm;
+}
+
static void get_expected_glyph_origins(D2D1_POINT_2F baseline_origin, const DWRITE_GLYPH_RUN *run,
D2D1_POINT_2F *origins)
{
+ DWRITE_GLYPH_METRICS glyph_metrics[2];
+ DWRITE_FONT_METRICS metrics;
unsigned int i;
+ HRESULT hr;
+
+ IDWriteFontFace_GetMetrics(run->fontFace, &metrics);
+
+ hr = IDWriteFontFace_GetDesignGlyphMetrics(run->fontFace, run->glyphIndices, run->glyphCount, glyph_metrics,
+ run->isSideways);
+ ok(hr == S_OK, "Failed to get glyph metrics, hr %#x.\n", hr);
if (run->bidiLevel & 1)
{
- DWRITE_GLYPH_METRICS glyph_metrics[2];
- DWRITE_FONT_METRICS metrics;
float advance;
- HRESULT hr;
-
- hr = IDWriteFontFace_GetDesignGlyphMetrics(run->fontFace, run->glyphIndices, run->glyphCount, glyph_metrics, FALSE);
- ok(hr == S_OK, "Failed to get glyph metrics, hr %#x.\n", hr);
-
- IDWriteFontFace_GetMetrics(run->fontFace, &metrics);
- advance = run->fontEmSize * glyph_metrics[0].advanceWidth / metrics.designUnitsPerEm;
+ advance = get_scaled_metric(run, run->isSideways ? glyph_metrics[0].advanceHeight :
+ glyph_metrics[0].advanceWidth, &metrics);
baseline_origin.x -= advance;
for (i = 0; i < run->glyphCount; ++i)
{
- origins[i].x = baseline_origin.x - run->glyphOffsets[i].advanceOffset;
- origins[i].y = baseline_origin.y - run->glyphOffsets[i].ascenderOffset;
+ origins[i] = baseline_origin;
+
+ if (run->isSideways)
+ {
+ origins[i].x += get_scaled_metric(run, glyph_metrics[i].verticalOriginY, &metrics);
+ origins[i].y += metrics.designUnitsPerEm / (4.0f * run->fontEmSize);
+ }
+
+ origins[i].x -= run->glyphOffsets[i].advanceOffset;
+ origins[i].y -= run->glyphOffsets[i].ascenderOffset;
baseline_origin.x -= run->glyphAdvances[i];
}
@@ -8478,8 +8493,16 @@ static void get_expected_glyph_origins(D2D1_POINT_2F baseline_origin, const DWRI
{
for (i = 0; i < run->glyphCount; ++i)
{
- origins[i].x = baseline_origin.x + run->glyphOffsets[i].advanceOffset;
- origins[i].y = baseline_origin.y - run->glyphOffsets[i].ascenderOffset;
+ origins[i] = baseline_origin;
+
+ if (run->isSideways)
+ {
+ origins[i].x += get_scaled_metric(run, glyph_metrics[i].verticalOriginY, &metrics);
+ origins[i].y += metrics.designUnitsPerEm / (4.0f * run->fontEmSize);
+ }
+
+ origins[i].x += run->glyphOffsets[i].advanceOffset;
+ origins[i].y -= run->glyphOffsets[i].ascenderOffset;
baseline_origin.x += run->glyphAdvances[i];
}
@@ -8494,12 +8517,18 @@ static void test_ComputeGlyphOrigins(void)
float advances[2];
DWRITE_GLYPH_OFFSET offsets[2];
unsigned int bidi_level;
+ unsigned int sideways;
}
origins_tests[] =
{
{ { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } } },
{ { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } } },
{ { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 1 },
+
+ { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 0, 1 },
+ { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } }, 0, 1 },
+ { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0 } }, 1, 1 },
+ { { 123.0f, 321.0f }, { 10.0f, 20.0f }, { { 0.3f, 0.5f }, { -0.1f, 0.9f } }, 1, 1 },
};
IDWriteFactory4 *factory;
DWRITE_GLYPH_RUN run;
@@ -8529,7 +8558,7 @@ static void test_ComputeGlyphOrigins(void)
run.glyphIndices = glyphs;
run.glyphAdvances = origins_tests[i].advances;
run.glyphOffsets = origins_tests[i].offsets;
- run.isSideways = FALSE;
+ run.isSideways = !!origins_tests[i].sideways;
run.bidiLevel = origins_tests[i].bidi_level;
get_expected_glyph_origins(origins_tests[i].baseline_origin, &run, expected_origins);
@@ -8539,6 +8568,7 @@ static void test_ComputeGlyphOrigins(void)
ok(hr == S_OK, "%u: failed to compute glyph origins, hr %#x.\n", i, hr);
for (j = 0; j < run.glyphCount; ++j)
{
+ todo_wine_if(run.isSideways)
ok(!memcmp(&origins[j], &expected_origins[j], sizeof(origins[j])),
"%u: unexpected origin[%u] (%f, %f) - (%f, %f).\n", i, j, origins[j].x, origins[j].y,
expected_origins[j].x, expected_origins[j].y);
--
2.30.2
2
1
[PATCH 1/2] reg/tests: Compare output of some 'query' recursion tests
by Hugh McMaster April 15, 2021
by Hugh McMaster April 15, 2021
April 15, 2021
Recursively querying a registry key for a given value name produces an extra
line specifying the number of matches found.
This line is locale-specific, so we only exclude it from the comparison
on a test-by-test basis.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
---
programs/reg/tests/query.c | 51 ++++++++++++++++++++++++++++++--------
1 file changed, 40 insertions(+), 11 deletions(-)
diff --git a/programs/reg/tests/query.c b/programs/reg/tests/query.c
index af0cc3848a4..93f30e3fc94 100644
--- a/programs/reg/tests/query.c
+++ b/programs/reg/tests/query.c
@@ -84,12 +84,23 @@ static BOOL read_reg_output_(const char *file, unsigned line, const char *cmd,
return bret;
}
-#define compare_query(b,e,todo) compare_query_(__FILE__,__LINE__,b,e,todo)
+#define compare_query(b,e,c,todo) compare_query_(__FILE__,__LINE__,b,e,c,todo)
static void compare_query_(const char *file, unsigned line, const BYTE *buf,
- const char *expected, DWORD todo)
+ const char *expected, BOOL cmp_len, DWORD todo)
{
- todo_wine_if (todo & TODO_REG_COMPARE)
- lok(!strcmp((char *)buf, expected), "query output does not match expected output\n");
+ const char *str = (const char *)buf;
+ const char *err = "query output does not match expected output\n";
+
+ if (!cmp_len)
+ {
+ todo_wine_if (todo & TODO_REG_COMPARE)
+ lok(!strcmp(str, expected), err);
+ }
+ else
+ {
+ todo_wine_if (todo & TODO_REG_COMPARE)
+ lok(!strncmp(str, expected, strlen(expected)), err);
+ }
}
/* Unit tests */
@@ -121,6 +132,22 @@ static void test_query(void)
"HKEY_CURRENT_USER\\" KEY_BASE "\\subkey\r\n"
" Test4 REG_DWORD 0xabc\r\n\r\n";
+ const char *test6 = "\r\n"
+ "HKEY_CURRENT_USER\\" KEY_BASE "\r\n"
+ " Test1 REG_SZ Hello, World\r\n"
+ " Test2 REG_DWORD 0x123\r\n"
+ " Wine REG_SZ First instance\r\n\r\n"
+ "HKEY_CURRENT_USER\\" KEY_BASE "\\subkey\r\n"
+ " Test3 REG_SZ Some string data\r\n"
+ " Test4 REG_DWORD 0xabc\r\n"
+ " Wine REG_SZ Second instance\r\n\r\n";
+
+ const char *test7 = "\r\n"
+ "HKEY_CURRENT_USER\\" KEY_BASE "\r\n"
+ " Wine REG_SZ First instance\r\n\r\n"
+ "HKEY_CURRENT_USER\\" KEY_BASE "\\subkey\r\n"
+ " Wine REG_SZ Second instance\r\n\r\n";
+
DWORD r, dword = 0x123;
HKEY key, subkey;
BYTE buf[512];
@@ -162,7 +189,7 @@ static void test_query(void)
read_reg_output("reg query HKCU\\" KEY_BASE, buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- compare_query(buf, test1, 0);
+ compare_query(buf, test1, FALSE, 0);
run_reg_exe("reg query HKCU\\" KEY_BASE " /ve", &r);
ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
@@ -170,7 +197,7 @@ static void test_query(void)
read_reg_output("reg query HKCU\\" KEY_BASE " /v Test1", buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- compare_query(buf, test2, 0);
+ compare_query(buf, test2, FALSE, 0);
run_reg_exe("reg query HKCU\\" KEY_BASE " /v Test2", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
@@ -182,7 +209,7 @@ static void test_query(void)
read_reg_output("reg query HKCU\\" KEY_BASE, buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- compare_query(buf, test3, TODO_REG_COMPARE);
+ compare_query(buf, test3, FALSE, TODO_REG_COMPARE);
add_value(subkey, "Test3", REG_SZ, "Some string data", 16);
dword = 0xabc;
@@ -190,24 +217,26 @@ static void test_query(void)
read_reg_output("reg query HKCU\\" KEY_BASE "\\subkey", buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- compare_query(buf, test4, 0);
+ compare_query(buf, test4, FALSE, 0);
run_reg_exe("reg query HKCU\\" KEY_BASE "\\subkey /v Test3", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
read_reg_output("reg query HKCU\\" KEY_BASE "\\subkey /v Test4", buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
- compare_query(buf, test5, 0);
+ compare_query(buf, test5, FALSE, 0);
add_value(subkey, "Wine", REG_SZ, "Second instance", 16);
/* Test recursion */
- run_reg_exe("reg query HKCU\\" KEY_BASE " /s", &r);
+ read_reg_output("reg query HKCU\\" KEY_BASE " /s", buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
+ compare_query(buf, test6, FALSE, 0);
- run_reg_exe("reg query HKCU\\" KEY_BASE " /v Wine /s", &r);
+ read_reg_output("reg query HKCU\\" KEY_BASE " /v Wine /s", buf, sizeof(buf), &r);
ok(r == REG_EXIT_SUCCESS || r == REG_EXIT_FAILURE /* WinXP */,
"got exit code %d, expected 0\n", r);
+ compare_query(buf, test7, TRUE, 0);
add_value(key, NULL, REG_SZ, "Empty", 6);
add_value(subkey, NULL, REG_SZ, "Empty", 6);
--
2.31.0
1
1
[PATCH 5/5] wldap32: Move support for extended functions to the Unix library.
by Hans Leidekker April 15, 2021
by Hans Leidekker April 15, 2021
April 15, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/extended.c | 175 ++++++++++++++--------------------------
dlls/wldap32/libldap.c | 17 ++++
dlls/wldap32/libldap.h | 8 ++
3 files changed, 84 insertions(+), 116 deletions(-)
diff --git a/dlls/wldap32/extended.c b/dlls/wldap32/extended.c
index 4600109182f..e09d90fdc60 100644
--- a/dlls/wldap32/extended.c
+++ b/dlls/wldap32/extended.c
@@ -18,21 +18,13 @@
* 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"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
@@ -66,33 +58,20 @@ ULONG CDECL ldap_close_extended_op( WLDAP32_LDAP *ld, ULONG msgid )
*
* See ldap_extended_operationW.
*/
-ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
- PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
+ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, char *oid, struct WLDAP32_berval *data,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *oidW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
- clientctrls, message );
+ TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, message );
if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
- if (oid) {
- oidW = strAtoW( oid );
- if (!oidW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (oid && !(oidW = strAtoW( oid ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
@@ -100,8 +79,6 @@ exit:
strfreeW( oidW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -130,43 +107,30 @@ exit:
* are optional and should be set to NULL if not used. Call
* ldap_close_extended_op to close the operation.
*/
-ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
- PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
+ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, WCHAR *oid, struct WLDAP32_berval *data,
+ LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *oidU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
+ struct bervalU *dataU = NULL;
- TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
- clientctrls, message );
+ TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, message );
if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
- if (oid) {
- oidU = strWtoU( oid );
- if (!oidU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
+ if (oid && !(oidU = strWtoU( oid ))) goto exit;
+ if (data && !(dataU = bervalWtoU( data ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
- ret = map_error( ldap_extended_operation( ld->ld, oid ? oidU : "", (struct berval *)data,
- serverctrlsU, clientctrlsU, (int *)message ));
+ ret = map_error( ldap_funcs->ldap_extended_operation( ld->ld, oidU, dataU, serverctrlsU, clientctrlsU, message ) );
exit:
strfreeU( oidU );
+ bvfreeU( dataU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -175,41 +139,27 @@ exit:
*
* See ldap_extended_operation_sW.
*/
-ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
- PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PCHAR *retoid,
- struct WLDAP32_berval **retdata )
+ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, char *oid, struct WLDAP32_berval *data,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls, char **retoid, struct WLDAP32_berval **retdata )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *oidW = NULL, *retoidW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
- clientctrls, retoid, retdata );
+ TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, retoid, retdata );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (oid) {
- oidW = strAtoW( oid );
- if (!oidW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
-
- ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW,
- &retoidW, retdata );
+ if (oid && !(oidW = strAtoW( oid ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
- if (retoid && retoidW) {
- *retoid = strWtoA( retoidW );
- if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
+ ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW, &retoidW, retdata );
+ if (retoid && retoidW)
+ {
+ char *str = strWtoA( retoidW );
+ if (str) *retoid = str;
+ else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_memfreeW( retoidW );
}
@@ -217,8 +167,6 @@ exit:
strfreeW( oidW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -246,49 +194,44 @@ exit:
* and retdata parameters are also optional. Set to NULL if not
* used. Free retoid and retdata after use with ldap_memfree.
*/
-ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
- PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PWCHAR *retoid,
- struct WLDAP32_berval **retdata )
+ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, WCHAR *oid, struct WLDAP32_berval *data,
+ LDAPControlW **serverctrls, LDAPControlW **clientctrls, WCHAR **retoid, struct WLDAP32_berval **retdata )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *oidU = NULL, *retoidU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
+ struct bervalU *retdataU, *dataU = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
- clientctrls, retoid, retdata );
+ TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, retoid, retdata );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (oid) {
- oidU = strWtoU( oid );
- if (!oidU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
+ if (oid && !(oidU = strWtoU( oid ))) goto exit;
+ if (data && !(dataU = bervalWtoU( data ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ ret = map_error( ldap_funcs->ldap_extended_operation_s( ld->ld, oidU, dataU, serverctrlsU, clientctrlsU,
+ &retoidU, &retdataU ) );
+ if (retoid && retoidU)
+ {
+ WCHAR *str = strUtoW( retoidU );
+ if (str) *retoid = str;
+ else ret = WLDAP32_LDAP_NO_MEMORY;
+ ldap_funcs->ldap_memfree( retoidU );
}
-
- ret = map_error( ldap_extended_operation_s( ld->ld, oid ? oidU : "", (struct berval *)data, serverctrlsU,
- clientctrlsU, &retoidU, (struct berval **)retdata ));
-
- if (retoid && retoidU) {
- *retoid = strUtoW( retoidU );
- if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
- ldap_memfree( retoidU );
+ if (retdata && retdataU)
+ {
+ struct WLDAP32_berval *bv = bervalUtoW( retdataU );
+ if (bv) *retdata = bv;
+ else ret = WLDAP32_LDAP_NO_MEMORY;
+ ldap_funcs->ber_bvfree( retdataU );
}
exit:
strfreeU( oidU );
+ bvfreeU( dataU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index c07a898e47c..de6974570f6 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -379,6 +379,21 @@ char ** CDECL wrap_ldap_explode_dn( const char *dn, int notypes )
return ldap_explode_dn( dn, notypes );
}
+int CDECL wrap_ldap_extended_operation( void *ld, const char *oid, struct bervalU *data, LDAPControlU **serverctrls,
+ LDAPControlU **clientctrls, ULONG *msg )
+{
+ int dummy;
+ return ldap_extended_operation( ld, oid ? oid : "", (struct berval *)data, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, msg ? (int *)msg : &dummy );
+}
+
+int CDECL wrap_ldap_extended_operation_s( void *ld, const char *oid, struct bervalU *data, LDAPControlU **serverctrls,
+ LDAPControlU **clientctrls, char **retoid, struct bervalU **retdata )
+{
+ return ldap_extended_operation_s( ld, oid ? oid : "", (struct berval *)data, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, retoid, (struct berval **)retdata );
+}
+
char * CDECL wrap_ldap_get_dn( void *ld, void *entry )
{
return ldap_get_dn( ld, entry );
@@ -530,6 +545,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_delete_ext_s,
wrap_ldap_dn2ufn,
wrap_ldap_explode_dn,
+ wrap_ldap_extended_operation,
+ wrap_ldap_extended_operation_s,
wrap_ldap_get_dn,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index b339ad752bc..f3fc5796fdc 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -114,6 +114,10 @@ extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDA
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_dn2ufn(const char *) DECLSPEC_HIDDEN;
extern char ** CDECL wrap_ldap_explode_dn(const char *, int) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_extended_operation(void *, const char *, struct bervalU *, LDAPControlU **,
+ LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
+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 char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
@@ -172,6 +176,10 @@ struct ldap_funcs
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
char * (CDECL *ldap_dn2ufn)(const char *);
char ** (CDECL *ldap_explode_dn)(const char *, int);
+ int (CDECL *ldap_extended_operation)(void *, const char *, struct bervalU *, LDAPControlU **,
+ LDAPControlU **, ULONG *);
+ int (CDECL *ldap_extended_operation_s)(void *, const char *, struct bervalU *, LDAPControlU **,
+ LDAPControlU **, char **, struct bervalU **);
char * (CDECL *ldap_get_dn)(void *, void *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
--
2.30.2
1
0
[PATCH 4/5] wldap32: Move support for dn functions to the Unix library.
by Hans Leidekker April 15, 2021
by Hans Leidekker April 15, 2021
April 15, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/dn.c | 127 ++++++++++++++---------------------------
dlls/wldap32/libldap.c | 24 ++++++++
dlls/wldap32/libldap.h | 8 +++
3 files changed, 75 insertions(+), 84 deletions(-)
diff --git a/dlls/wldap32/dn.c b/dlls/wldap32/dn.c
index b35a5dfe1ac..61d421ee233 100644
--- a/dlls/wldap32/dn.c
+++ b/dlls/wldap32/dn.c
@@ -18,49 +18,35 @@
* 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_dn2ufnA (WLDAP32.@)
*
* See ldap_dn2ufnW.
*/
-PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
+char * CDECL ldap_dn2ufnA( char *dn )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ char *ret;
WCHAR *dnW, *retW;
TRACE( "(%s)\n", debugstr_a(dn) );
- dnW = strAtoW( dn );
- if (!dnW) return NULL;
+ if (!(dnW = strAtoW( dn ))) return NULL;
retW = ldap_dn2ufnW( dnW );
ret = strWtoA( retW );
strfreeW( dnW );
ldap_memfreeW( retW );
-
-#endif
return ret;
}
@@ -73,30 +59,26 @@ PCHAR CDECL ldap_dn2ufnA( PCHAR dn )
* dn [I] DN to convert.
*
* RETURNS
- * Success: Pointer to a string containing the user-friendly name.
+ * Success: Pointer to a string containing the user-friendly name.
* Failure: NULL
*
* NOTES
* Free the string with ldap_memfree.
*/
-PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
+WCHAR * CDECL ldap_dn2ufnW( WCHAR *dn )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR *ret;
char *dnU, *retU;
TRACE( "(%s)\n", debugstr_w(dn) );
- dnU = strWtoU( dn );
- if (!dnU) return NULL;
+ if (!(dnU = strWtoU( dn ))) return NULL;
- retU = ldap_dn2ufn( dnU );
+ retU = ldap_funcs->ldap_dn2ufn( dnU );
ret = strUtoW( retU );
strfreeU( dnU );
- ldap_memfree( retU );
-
-#endif
+ ldap_funcs->ldap_memfree( retU );
return ret;
}
@@ -105,24 +87,20 @@ PWCHAR CDECL ldap_dn2ufnW( PWCHAR dn )
*
* See ldap_explode_dnW.
*/
-PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
+char ** CDECL ldap_explode_dnA( char *dn, ULONG notypes )
{
- PCHAR *ret = NULL;
-#ifdef HAVE_LDAP
+ char **ret;
WCHAR *dnW, **retW;
TRACE( "(%s, 0x%08x)\n", debugstr_a(dn), notypes );
- dnW = strAtoW( dn );
- if (!dnW) return NULL;
+ if (!(dnW = strAtoW( dn ))) return NULL;
retW = ldap_explode_dnW( dnW, notypes );
ret = strarrayWtoA( retW );
strfreeW( dnW );
ldap_value_freeW( retW );
-
-#endif
return ret;
}
@@ -137,30 +115,26 @@ PCHAR * CDECL ldap_explode_dnA( PCHAR dn, ULONG notypes )
*
* RETURNS
* Success: Pointer to a NULL-terminated array that contains the DN
- * components.
+ * components.
* Failure: NULL
*
* NOTES
* Free the string array with ldap_value_free.
*/
-PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
+WCHAR ** CDECL ldap_explode_dnW( WCHAR *dn, ULONG notypes )
{
- PWCHAR *ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR **ret;
char *dnU, **retU;
TRACE( "(%s, 0x%08x)\n", debugstr_w(dn), notypes );
- dnU = strWtoU( dn );
- if (!dnU) return NULL;
+ if (!(dnU = strWtoU( dn ))) return NULL;
- retU = ldap_explode_dn( dnU, notypes );
+ retU = ldap_funcs->ldap_explode_dn( dnU, notypes );
ret = strarrayUtoW( retU );
strfreeU( dnU );
- ldap_memvfree( (void **)retU );
-
-#endif
+ ldap_funcs->ldap_memvfree( (void **)retU );
return ret;
}
@@ -169,11 +143,10 @@ PWCHAR * CDECL ldap_explode_dnW( PWCHAR dn, ULONG notypes )
*
* See ldap_get_dnW.
*/
-PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
+char * CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
- PWCHAR retW;
+ char *ret;
+ WCHAR *retW;
TRACE( "(%p, %p)\n", ld, entry );
@@ -183,8 +156,6 @@ PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
ret = strWtoA( retW );
ldap_memfreeW( retW );
-
-#endif
return ret;
}
@@ -204,22 +175,19 @@ PCHAR CDECL ldap_get_dnA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
* NOTES
* Free the string with ldap_memfree.
*/
-PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
+WCHAR * CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR *ret;
char *retU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
- retU = ldap_get_dn( ld->ld, entry->Request );
+ retU = ldap_funcs->ldap_get_dn( ld->ld, entry->Request );
ret = strUtoW( retU );
- ldap_memfree( retU );
-
-#endif
+ ldap_funcs->ldap_memfree( retU );
return ret;
}
@@ -228,34 +196,28 @@ PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
*
* See ldap_ufn2dnW.
*/
-ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
+ULONG CDECL ldap_ufn2dnA( char *ufn, char **dn )
{
- ULONG ret = WLDAP32_LDAP_SUCCESS;
-#ifdef HAVE_LDAP
- PWCHAR ufnW = NULL, dnW = NULL;
+ ULONG ret;
+ WCHAR *ufnW = NULL, *dnW = NULL;
TRACE( "(%s, %p)\n", debugstr_a(ufn), dn );
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
-
- if (ufn) {
- ufnW = strAtoW( ufn );
- if (!ufnW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (ufn && !(ufnW = strAtoW( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_ufn2dnW( ufnW, &dnW );
-
- if (dnW) {
- *dn = strWtoA( dnW );
- if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
+ if (dnW)
+ {
+ char *str;
+ if (!(str = strWtoA( dnW ))) ret = WLDAP32_LDAP_NO_MEMORY;
+ else *dn = str;
}
strfreeW( ufnW );
ldap_memfreeW( dnW );
-
-#endif
return ret;
}
@@ -266,7 +228,7 @@ ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
*
* PARAMS
* ufn [I] User-friendly name to convert.
- * dn [O] Receives a pointer to a string containing the DN.
+ * dn [O] Receives a pointer to a string containing the DN.
*
* RETURNS
* Success: LDAP_SUCCESS
@@ -275,10 +237,9 @@ ULONG CDECL ldap_ufn2dnA( PCHAR ufn, PCHAR *dn )
* NOTES
* Free the string with ldap_memfree.
*/
-ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
+ULONG CDECL ldap_ufn2dnW( WCHAR *ufn, WCHAR **dn )
{
ULONG ret = WLDAP32_LDAP_SUCCESS;
-#ifdef HAVE_LDAP
char *ufnU = NULL;
TRACE( "(%s, %p)\n", debugstr_w(ufn), dn );
@@ -286,18 +247,16 @@ ULONG CDECL ldap_ufn2dnW( PWCHAR ufn, PWCHAR *dn )
if (!dn) return WLDAP32_LDAP_PARAM_ERROR;
*dn = NULL;
-
- if (ufn) {
- ufnU = strWtoU( ufn );
- if (!ufnU) return WLDAP32_LDAP_NO_MEMORY;
+ if (ufn)
+ {
+ WCHAR *str;
+ if (!(ufnU = strWtoU( ufn ))) return WLDAP32_LDAP_NO_MEMORY;
/* FIXME: do more than just a copy */
- *dn = strUtoW( ufnU );
- if (!*dn) ret = WLDAP32_LDAP_NO_MEMORY;
+ if (!(str = strUtoW( ufnU ))) ret = WLDAP32_LDAP_NO_MEMORY;
+ else *dn = str;
}
strfreeU( ufnU );
-
-#endif
return ret;
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index bc1a161127a..c07a898e47c 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -369,6 +369,21 @@ int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serve
return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
+char * CDECL wrap_ldap_dn2ufn( const char *dn )
+{
+ return ldap_dn2ufn( dn );
+}
+
+char ** CDECL wrap_ldap_explode_dn( const char *dn, int notypes )
+{
+ return ldap_explode_dn( dn, notypes );
+}
+
+char * CDECL wrap_ldap_get_dn( void *ld, void *entry )
+{
+ return ldap_get_dn( ld, entry );
+}
+
char * CDECL wrap_ldap_first_attribute( void *ld, void *entry, void **ber )
{
return ldap_first_attribute( ld, entry, (BerElement **)ber );
@@ -389,6 +404,11 @@ void CDECL wrap_ldap_memfree( void *ptr )
return ldap_memfree( ptr );
}
+void CDECL wrap_ldap_memvfree( void **ptr )
+{
+ ldap_memvfree( ptr );
+}
+
int CDECL wrap_ldap_msgfree( void *msg )
{
return ldap_msgfree( msg );
@@ -508,10 +528,14 @@ static const struct ldap_funcs funcs =
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
+ wrap_ldap_dn2ufn,
+ wrap_ldap_explode_dn,
+ wrap_ldap_get_dn,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
wrap_ldap_first_reference,
wrap_ldap_memfree,
+ wrap_ldap_memvfree,
wrap_ldap_msgfree,
wrap_ldap_next_attribute,
wrap_ldap_next_entry,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index f307eaf4327..b339ad752bc 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -112,10 +112,14 @@ extern int CDECL wrap_ldap_create_sort_control(void *, LDAPSortKeyU **, int, LDA
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;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
+extern char * CDECL wrap_ldap_dn2ufn(const char *) DECLSPEC_HIDDEN;
+extern char ** CDECL wrap_ldap_explode_dn(const char *, int) DECLSPEC_HIDDEN;
+extern char * CDECL wrap_ldap_get_dn(void *, void *) 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;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
+extern void CDECL wrap_ldap_memvfree(void **) 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;
@@ -166,10 +170,14 @@ struct ldap_funcs
int (CDECL *ldap_create_vlv_control)(void *, LDAPVLVInfoU *, LDAPControlU **);
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
+ char * (CDECL *ldap_dn2ufn)(const char *);
+ char ** (CDECL *ldap_explode_dn)(const char *, int);
+ char * (CDECL *ldap_get_dn)(void *, void *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
+ void (CDECL *ldap_memvfree)(void **);
int (CDECL *ldap_msgfree)(void *);
char * (CDECL *ldap_next_attribute)(void *, void *, void *);
void * (CDECL *ldap_next_entry)(void *, void *);
--
2.30.2
1
0
[PATCH 3/5] wldap32: Move support for search functions to the Unix library.
by Hans Leidekker April 15, 2021
by Hans Leidekker April 15, 2021
April 15, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/dn.c | 2 +-
dlls/wldap32/error.c | 2 +-
dlls/wldap32/libldap.c | 98 ++++++++-
dlls/wldap32/libldap.h | 36 ++++
dlls/wldap32/misc.c | 250 +++++++++++-----------
dlls/wldap32/parse.c | 10 +-
dlls/wldap32/search.c | 458 +++++++++++------------------------------
dlls/wldap32/value.c | 4 +-
8 files changed, 379 insertions(+), 481 deletions(-)
diff --git a/dlls/wldap32/dn.c b/dlls/wldap32/dn.c
index 6d1a9711016..b35a5dfe1ac 100644
--- a/dlls/wldap32/dn.c
+++ b/dlls/wldap32/dn.c
@@ -214,7 +214,7 @@ PWCHAR CDECL ldap_get_dnW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
if (!ld || !entry) return NULL;
- retU = ldap_get_dn( ld->ld, entry );
+ retU = ldap_get_dn( ld->ld, entry->Request );
ret = strUtoW( retU );
ldap_memfree( retU );
diff --git a/dlls/wldap32/error.c b/dlls/wldap32/error.c
index c1b678788f0..a56adc11c02 100644
--- a/dlls/wldap32/error.c
+++ b/dlls/wldap32/error.c
@@ -152,7 +152,7 @@ ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *re
if (!ld || !res) return ~0u;
- ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free ) );
+ ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res->Request, &error, NULL, NULL, NULL, NULL, free ) );
if (ret == WLDAP32_LDAP_SUCCESS)
ret = error;
else
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index 11a3707f200..bc1a161127a 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -26,6 +26,7 @@
#ifdef HAVE_LDAP
#include <stdarg.h>
+#include <sys/time.h>
#ifdef HAVE_LDAP_H
# include <ldap.h>
#endif
@@ -49,6 +50,7 @@ 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(struct timevalU) == sizeof(struct timeval) );
static LDAPMod *nullattrs[] = { NULL };
@@ -294,6 +296,11 @@ int WINAPIV wrap_ber_scanf( void *ber, char *fmt, ... )
return ret;
}
+int CDECL wrap_ldap_abandon_ext( void *ld, int msgid, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
+{
+ return ldap_abandon_ext( ld, msgid, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
+}
+
int CDECL wrap_ldap_add_ext( void *ld, const char *dn, LDAPModU **attrs, LDAPControlU **serverctrls,
LDAPControlU **clientctrls, ULONG *msg )
{
@@ -309,11 +316,6 @@ int CDECL wrap_ldap_add_ext_s( void *ld, const char *dn, LDAPModU **attrs, LDAPC
(LDAPControl **)clientctrls );
}
-void CDECL wrap_ldap_control_free( LDAPControlU *control )
-{
- ldap_control_free( (LDAPControl *)control );
-}
-
int CDECL wrap_ldap_compare_ext( void *ld, const char *dn, const char *attrs, struct bervalU *value,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, ULONG *msg )
{
@@ -329,6 +331,21 @@ int CDECL wrap_ldap_compare_ext_s( void *ld, const char *dn, const char *attrs,
(LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
+void CDECL wrap_ldap_control_free( LDAPControlU *control )
+{
+ ldap_control_free( (LDAPControl *)control );
+}
+
+int CDECL wrap_ldap_count_entries( void *ld, void *chain )
+{
+ return ldap_count_entries( ld, chain );
+}
+
+int CDECL wrap_ldap_count_references( void *ld, void *chain )
+{
+ return ldap_count_references( ld, chain );
+}
+
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 );
@@ -352,17 +369,57 @@ int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serve
return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
}
+char * CDECL wrap_ldap_first_attribute( void *ld, void *entry, void **ber )
+{
+ return ldap_first_attribute( ld, entry, (BerElement **)ber );
+}
+
+void * CDECL wrap_ldap_first_entry( void *ld, void *chain )
+{
+ return ldap_first_entry( ld, chain );
+}
+
+void * CDECL wrap_ldap_first_reference( void *ld, void *chain )
+{
+ return ldap_first_reference( ld, chain );
+}
+
void CDECL wrap_ldap_memfree( void *ptr )
{
return ldap_memfree( ptr );
}
+int CDECL wrap_ldap_msgfree( void *msg )
+{
+ return ldap_msgfree( msg );
+}
+
+char * CDECL wrap_ldap_next_attribute( void *ld, void *entry, void *ber )
+{
+ return ldap_next_attribute( ld, entry, ber );
+}
+
+void * CDECL wrap_ldap_next_entry( void *ld, void *entry )
+{
+ return ldap_next_entry( ld, entry );
+}
+
+void * CDECL wrap_ldap_next_reference( void *ld, void *entry )
+{
+ return ldap_next_reference( ld, entry );
+}
+
int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matcheddn, char **errmsg,
char ***referrals, LDAPControlU ***serverctrls, int free )
{
return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
}
+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 );
+}
+
int CDECL wrap_ldap_sasl_bind( void *ld, const char *dn, const char *mech, struct bervalU *cred,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, int *msgid )
{
@@ -393,6 +450,23 @@ int CDECL wrap_ldap_sasl_interactive_bind_s( void *ld, const char *dn, const cha
wrap_sasl_interact, defaults );
}
+int CDECL wrap_ldap_search_ext( void *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly,
+ LDAPControlU **serverctrls, LDAPControlU **clientctrls, struct timevalU *timeout,
+ int sizelimit, ULONG *msg )
+{
+ return ldap_search_ext( ld, base, scope, filter, attrs, attrsonly, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, (struct timeval *)timeout, sizelimit, (int *)msg );
+}
+
+int CDECL wrap_ldap_search_ext_s( void *ld, const char *base, int scope, const char *filter, char **attrs,
+ int attrsonly, LDAPControlU **serverctrls, LDAPControlU **clientctrls,
+ struct timevalU *timeout, int sizelimit, void **result )
+{
+ return ldap_search_ext_s( ld, base, scope, filter, attrs, attrsonly, (LDAPControl **)serverctrls,
+ (LDAPControl **)clientctrls, (struct timeval *)timeout, sizelimit,
+ (LDAPMessage **)result );
+}
+
int CDECL wrap_ldap_unbind_ext( void *ld, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
{
return ldap_unbind_ext( ld, (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
@@ -422,20 +496,33 @@ static const struct ldap_funcs funcs =
wrap_ber_skip_tag,
wrap_ber_printf,
wrap_ber_scanf,
+ wrap_ldap_abandon_ext,
wrap_ldap_add_ext,
wrap_ldap_add_ext_s,
wrap_ldap_compare_ext,
wrap_ldap_compare_ext_s,
wrap_ldap_control_free,
+ wrap_ldap_count_entries,
+ wrap_ldap_count_references,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
+ wrap_ldap_first_attribute,
+ wrap_ldap_first_entry,
+ wrap_ldap_first_reference,
wrap_ldap_memfree,
+ wrap_ldap_msgfree,
+ wrap_ldap_next_attribute,
+ wrap_ldap_next_entry,
+ wrap_ldap_next_reference,
wrap_ldap_parse_result,
+ wrap_ldap_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
wrap_ldap_sasl_interactive_bind_s,
+ wrap_ldap_search_ext,
+ wrap_ldap_search_ext_s,
wrap_ldap_unbind_ext,
wrap_ldap_unbind_ext_s,
wrap_ldap_value_free_len,
@@ -448,5 +535,4 @@ NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *p
*(const struct ldap_funcs **)ptr_out = &funcs;
return STATUS_SUCCESS;
}
-
#endif /* HAVE_LDAP */
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index 5ebc5bacd54..f307eaf4327 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -60,6 +60,12 @@ typedef struct
void *ldvlv_extradata;
} LDAPVLVInfoU;
+typedef struct timevalU
+{
+ unsigned long tv_sec;
+ unsigned long tv_usec;
+} LDAP_TIMEVALU;
+
#ifndef SASL_CB_LIST_END
#define SASL_CB_LIST_END 0
#define SASL_CB_USER 0x4001
@@ -90,6 +96,7 @@ extern unsigned int CDECL wrap_ber_skip_tag(void *, unsigned int *) DECLSPEC_HID
extern int WINAPIV wrap_ber_printf(void *, char *, ...) DECLSPEC_HIDDEN;
extern int WINAPIV wrap_ber_scanf(void *, char *, ...) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_abandon_ext(void *, int, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_add_ext(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **,
ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_add_ext_s(void *, const char *, LDAPModU **, LDAPControlU **,
@@ -99,19 +106,33 @@ extern int CDECL wrap_ldap_compare_ext(void *, const char *, const char *, struc
extern int CDECL wrap_ldap_compare_ext_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **) DECLSPEC_HIDDEN;
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_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;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) 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;
extern void CDECL wrap_ldap_memfree(void *) 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;
+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_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;
extern int CDECL wrap_ldap_sasl_bind_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, struct bervalU **) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_interactive_bind_s(void *, const char *, const char *, LDAPControlU **,
LDAPControlU **, unsigned int, void *) DECLSPEC_HIDDEN;
+extern int CDECL wrap_ldap_search_ext(void *, const char *, int, const char *, char **, int, LDAPControlU **,
+ 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_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;
@@ -131,6 +152,7 @@ struct ldap_funcs
int (WINAPIV *ber_printf)(void *, char *, ...);
int (WINAPIV *ber_scanf)(void *, char *, ...);
+ int (CDECL *ldap_abandon_ext)(void *, int, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_add_ext)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_add_ext_s)(void *, const char *, LDAPModU **, LDAPControlU **, LDAPControlU **);
int (CDECL *ldap_compare_ext)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
@@ -138,18 +160,32 @@ struct ldap_funcs
int (CDECL *ldap_compare_ext_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **);
void (CDECL *ldap_control_free)(LDAPControlU *);
+ int (CDECL *ldap_count_entries)(void *, void *);
+ int (CDECL *ldap_count_references)(void *, void *);
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 *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
+ char * (CDECL *ldap_first_attribute)(void *, void *, void **);
+ void * (CDECL *ldap_first_entry)(void *, void *);
+ void * (CDECL *ldap_first_reference)(void *, void *);
void (CDECL *ldap_memfree)(void *);
+ int (CDECL *ldap_msgfree)(void *);
+ char * (CDECL *ldap_next_attribute)(void *, void *, void *);
+ 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_result)(void *, int, int, struct timevalU *, void **);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
int (CDECL *ldap_sasl_bind_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, struct bervalU **);
int (CDECL *ldap_sasl_interactive_bind_s)(void *, const char *, const char *, LDAPControlU **, LDAPControlU **,
unsigned int, void *);
+ int (CDECL *ldap_search_ext)(void *, const char *, int, const char *, char **, int, LDAPControlU **,
+ 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_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/misc.c b/dlls/wldap32/misc.c
index dd1a1ef3f12..234b84d42f9 100644
--- a/dlls/wldap32/misc.c
+++ b/dlls/wldap32/misc.c
@@ -18,22 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#include <stdarg.h>
-#include <stdio.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 "wine/heap.h"
+#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
@@ -52,16 +44,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
*/
ULONG CDECL WLDAP32_ldap_abandon( WLDAP32_LDAP *ld, ULONG msgid )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
-
TRACE( "(%p, 0x%08x)\n", ld, msgid );
if (!ld) return ~0u;
- ret = map_error( ldap_abandon_ext( ld->ld, msgid, NULL, NULL ));
-
-#endif
- return ret;
+ return map_error( ldap_funcs->ldap_abandon_ext( ld->ld, msgid, NULL, NULL ) );
}
/***********************************************************************
@@ -69,7 +55,7 @@ ULONG CDECL WLDAP32_ldap_abandon( WLDAP32_LDAP *ld, ULONG msgid )
*
* See ldap_check_filterW.
*/
-ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
+ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, char *filter )
{
ULONG ret;
WCHAR *filterW = NULL;
@@ -77,11 +63,7 @@ ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
TRACE( "(%p, %s)\n", ld, debugstr_a(filter) );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (filter && !(filterW = strAtoW( filter ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_check_filterW( ld, filterW );
@@ -102,7 +84,7 @@ ULONG CDECL ldap_check_filterA( WLDAP32_LDAP *ld, PCHAR filter )
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_check_filterW( WLDAP32_LDAP *ld, PWCHAR filter )
+ULONG CDECL ldap_check_filterW( WLDAP32_LDAP *ld, WCHAR *filter )
{
TRACE( "(%p, %s)\n", ld, debugstr_w(filter) );
@@ -155,16 +137,10 @@ WLDAP32_LDAP * CDECL ldap_conn_from_msg( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *
*/
ULONG CDECL WLDAP32_ldap_count_entries( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
-
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return ~0u;
- ret = ldap_count_entries( ld->ld, res );
-
-#endif
- return ret;
+ return ldap_funcs->ldap_count_entries( ld->ld, res->Request );
}
/***********************************************************************
@@ -182,16 +158,10 @@ ULONG CDECL WLDAP32_ldap_count_entries( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *r
*/
ULONG CDECL WLDAP32_ldap_count_references( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP_COUNT_REFERENCES
-
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return 0;
- ret = ldap_count_references( ld->ld, res );
-
-#endif
- return ret;
+ return ldap_funcs->ldap_count_references( ld->ld, res->Request );
}
static ULONG get_escape_size( PCHAR src, ULONG srclen )
@@ -213,7 +183,7 @@ static ULONG get_escape_size( PCHAR src, ULONG srclen )
return size + 1;
}
-static void escape_filter_element( PCHAR src, ULONG srclen, PCHAR dst )
+static void escape_filter_element( char *src, ULONG srclen, char *dst )
{
ULONG i;
static const char fmt[] = "\\%02X";
@@ -236,22 +206,17 @@ static void escape_filter_element( PCHAR src, ULONG srclen, PCHAR dst )
*
* See ldap_escape_filter_elementW.
*/
-ULONG CDECL ldap_escape_filter_elementA( PCHAR src, ULONG srclen, PCHAR dst, ULONG dstlen )
+ULONG CDECL ldap_escape_filter_elementA( char *src, ULONG srclen, char *dst, ULONG dstlen )
{
- ULONG len;
+ ULONG len = get_escape_size( src, srclen );
TRACE( "(%p, 0x%08x, %p, 0x%08x)\n", src, srclen, dst, dstlen );
- len = get_escape_size( src, srclen );
if (!dst) return len;
+ if (!src || dstlen < len) return WLDAP32_LDAP_PARAM_ERROR;
- if (!src || dstlen < len)
- return WLDAP32_LDAP_PARAM_ERROR;
- else
- {
- escape_filter_element( src, srclen, dst );
- return WLDAP32_LDAP_SUCCESS;
- }
+ escape_filter_element( src, srclen, dst );
+ return WLDAP32_LDAP_SUCCESS;
}
/***********************************************************************
@@ -269,13 +234,12 @@ ULONG CDECL ldap_escape_filter_elementA( PCHAR src, ULONG srclen, PCHAR dst, ULO
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_escape_filter_elementW( PCHAR src, ULONG srclen, PWCHAR dst, ULONG dstlen )
+ULONG CDECL ldap_escape_filter_elementW( char *src, ULONG srclen, WCHAR *dst, ULONG dstlen )
{
- ULONG len;
+ ULONG len = get_escape_size( src, srclen );
TRACE( "(%p, 0x%08x, %p, 0x%08x)\n", src, srclen, dst, dstlen );
- len = get_escape_size( src, srclen );
if (!dst) return len;
/* no matter what you throw at it, this is what native returns */
@@ -287,29 +251,29 @@ ULONG CDECL ldap_escape_filter_elementW( PCHAR src, ULONG srclen, PWCHAR dst, UL
*
* See ldap_first_attributeW.
*/
-PCHAR CDECL ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement** ptr )
+char * CDECL ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement **ber )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ char *ret = NULL;
WCHAR *retW;
- TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
+ TRACE( "(%p, %p, %p)\n", ld, entry, ber );
if (!ld || !entry) return NULL;
- retW = ldap_first_attributeW( ld, entry, ptr );
- ret = strWtoA( retW );
- ldap_memfreeW( retW );
+ retW = ldap_first_attributeW( ld, entry->Request, ber );
+ if (retW)
+ {
+ ret = strWtoA( retW );
+ ldap_memfreeW( retW );
+ }
-#endif
return ret;
}
/***********************************************************************
* ldap_first_attributeW (WLDAP32.@)
*
- * Get the first attribute for a given entry.
+ * Get the first attribute for a given entry.
*
* PARAMS
* ld [I] Pointer to an LDAP context.
@@ -323,29 +287,26 @@ PCHAR CDECL ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
* NOTES
* Use ldap_memfree to free the returned string.
*/
-PWCHAR CDECL ldap_first_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement** ptr )
+WCHAR * CDECL ldap_first_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement **ptr )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
- BerElement *berU;
+ WCHAR *ret = NULL;
+ WLDAP32_BerElement *ber;
char *retU;
+ void *berU;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry) return NULL;
- retU = ldap_first_attribute( ld->ld, entry, &berU );
- if (retU)
+ retU = ldap_funcs->ldap_first_attribute( ld->ld, entry->Request, &berU );
+ if (retU && (ber = heap_alloc( sizeof(*ber) )))
{
- WLDAP32_BerElement *ber = heap_alloc( sizeof(*ber) );
ber->opaque = (char *)berU;
*ptr = ber;
ret = strUtoW( retU );
- ldap_memfree( retU );
}
-#endif
+ ldap_funcs->ldap_memfree( retU );
return ret;
}
@@ -363,20 +324,24 @@ PWCHAR CDECL ldap_first_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry
* Failure: NULL
*
* NOTES
- * The returned entry will be freed when the message is freed.
+ * The returned entry will be freed when the message is freed.
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_entry( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
-#ifdef HAVE_LDAP
+ void *msgU;
TRACE( "(%p, %p)\n", ld, res );
if (!ld || !res) return NULL;
- return ldap_first_entry( ld->ld, res );
-#else
+ msgU = ldap_funcs->ldap_first_entry( ld->ld, res->Request );
+ if (msgU)
+ {
+ assert( msgU == res->Request );
+ return res;
+ }
+
return NULL;
-#endif
}
/***********************************************************************
@@ -394,16 +359,20 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_entry( WLDAP32_LDAP *ld, WLDAP32_
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_reference( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res )
{
-#ifdef HAVE_LDAP_FIRST_REFERENCE
+ void *msgU;
TRACE( "(%p, %p)\n", ld, res );
if (!ld) return NULL;
- return ldap_first_reference( ld->ld, res );
-#else
+ msgU = ldap_funcs->ldap_first_reference( ld->ld, res->Request );
+ if (msgU)
+ {
+ assert( msgU == res->Request );
+ return res;
+ }
+
return NULL;
-#endif
}
/***********************************************************************
@@ -411,7 +380,7 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_first_reference( WLDAP32_LDAP *ld, WLDA
*
* See ldap_memfreeW.
*/
-void CDECL ldap_memfreeA( PCHAR block )
+void CDECL ldap_memfreeA( char *block )
{
TRACE( "(%p)\n", block );
strfreeA( block );
@@ -425,7 +394,7 @@ void CDECL ldap_memfreeA( PCHAR block )
* PARAMS
* block [I] Pointer to memory block to be freed.
*/
-void CDECL ldap_memfreeW( PWCHAR block )
+void CDECL ldap_memfreeW( WCHAR *block )
{
TRACE( "(%p)\n", block );
strfreeW( block );
@@ -441,14 +410,21 @@ void CDECL ldap_memfreeW( PWCHAR block )
*/
ULONG CDECL WLDAP32_ldap_msgfree( WLDAP32_LDAPMessage *res )
{
- ULONG ret = WLDAP32_LDAP_SUCCESS;
-#ifdef HAVE_LDAP
+ WLDAP32_LDAPMessage *entry, *list = res;
TRACE( "(%p)\n", res );
- ldap_msgfree( res );
-#endif
- return ret;
+ if (!res) return WLDAP32_LDAP_SUCCESS;
+
+ ldap_funcs->ldap_msgfree( res->Request );
+ while (list)
+ {
+ entry = list;
+ list = entry->lm_next;
+ heap_free( entry );
+ }
+
+ return WLDAP32_LDAP_SUCCESS;
}
/***********************************************************************
@@ -456,22 +432,22 @@ ULONG CDECL WLDAP32_ldap_msgfree( WLDAP32_LDAPMessage *res )
*
* See ldap_next_attributeW.
*/
-PCHAR CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement *ptr )
+char * CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement *ptr )
{
- PCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ char *ret = NULL;
WCHAR *retW;
TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
if (!ld || !entry || !ptr) return NULL;
- retW = ldap_next_attributeW( ld, entry, ptr );
- ret = strWtoA( retW );
- ldap_memfreeW( retW );
+ retW = ldap_next_attributeW( ld, entry->Request, ptr );
+ if (retW)
+ {
+ ret = strWtoA( retW );
+ ldap_memfreeW( retW );
+ }
-#endif
return ret;
}
@@ -493,25 +469,22 @@ PCHAR CDECL ldap_next_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
* Free the returned string after each iteration with ldap_memfree.
* When done iterating and when ptr != NULL, call ber_free( ptr, 0 ).
*/
-PWCHAR CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
- WLDAP32_BerElement *ber )
+WCHAR * CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, WLDAP32_BerElement *ptr )
{
- PWCHAR ret = NULL;
-#ifdef HAVE_LDAP
+ WCHAR *ret = NULL;
char *retU;
- TRACE( "(%p, %p, %p)\n", ld, entry, ber );
+ TRACE( "(%p, %p, %p)\n", ld, entry, ptr );
- if (!ld || !entry) return NULL;
+ if (!ld || !entry || !ptr) return NULL;
- retU = ldap_next_attribute( ld->ld, entry, (BerElement *)ber->opaque );
+ retU = ldap_funcs->ldap_next_attribute( ld->ld, entry->Request, ptr->opaque );
if (retU)
{
ret = strUtoW( retU );
- ldap_memfree( retU );
+ ldap_funcs->ldap_memfree( retU );
}
-#endif
return ret;
}
@@ -533,16 +506,23 @@ PWCHAR CDECL ldap_next_attributeW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_entry( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
-#ifdef HAVE_LDAP
+ WLDAP32_LDAPMessage *msg = NULL;
+ void *msgU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
- return ldap_next_entry( ld->ld, entry );
-#else
- return NULL;
-#endif
+ if (entry->lm_next) return entry->lm_next;
+
+ msgU = ldap_funcs->ldap_next_entry( ld->ld, entry->Request );
+ if (msgU && (msg = heap_alloc_zero( sizeof(*msg) )))
+ {
+ msg->Request = msgU;
+ entry->lm_next = msg;
+ }
+
+ return msg;
}
/***********************************************************************
@@ -563,16 +543,23 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_entry( WLDAP32_LDAP *ld, WLDAP32_L
*/
WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_reference( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry )
{
-#ifdef HAVE_LDAP_NEXT_REFERENCE
+ WLDAP32_LDAPMessage *msg = NULL;
+ void *msgU;
TRACE( "(%p, %p)\n", ld, entry );
if (!ld || !entry) return NULL;
- return ldap_next_reference( ld->ld, entry );
-#else
- return NULL;
-#endif
+ if (entry->lm_next) return entry->lm_next;
+
+ msgU = ldap_funcs->ldap_next_reference( ld->ld, entry->Request );
+ if (msgU && (msg = heap_alloc_zero( sizeof(*msg) )))
+ {
+ msg->Request = msgU;
+ entry->lm_next = msg;
+ }
+
+ return msg;
}
/***********************************************************************
@@ -611,18 +598,31 @@ WLDAP32_LDAPMessage * CDECL WLDAP32_ldap_next_reference( WLDAP32_LDAP *ld, WLDAP
* to immediately return any available results. Free returned results
* with ldap_msgfree.
*/
-ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
- struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
+ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all, struct l_timeval *timeout,
+ WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ WLDAP32_LDAPMessage *msg;
+ struct timevalU timeval;
+ void *msgU = NULL;
+ ULONG ret;
TRACE( "(%p, 0x%08x, 0x%08x, %p, %p)\n", ld, msgid, all, timeout, res );
if (!ld || !res || msgid == ~0u) return ~0u;
- ret = ldap_result( ld->ld, msgid, all, (struct timeval *)timeout, res );
-#endif
+ if (timeout)
+ {
+ timeval.tv_sec = timeout->tv_sec;
+ timeval.tv_usec = timeout->tv_usec;
+ }
+
+ ret = ldap_funcs->ldap_result( ld->ld, msgid, all, timeout ? &timeval : NULL, &msgU );
+ if (msgU && (msg = heap_alloc_zero( sizeof(*msg) )))
+ {
+ msg->Request = msgU;
+ *res = msg;
+ }
+
return ret;
}
@@ -635,7 +635,7 @@ ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
* src [I] Wide character string to convert.
* srclen [I] Size of string to convert, in characters.
* dst [O] Pointer to a buffer that receives the converted string.
- * dstlen [I] Size of the destination buffer in characters.
+ * dstlen [I] Size of the destination buffer in characters.
*
* RETURNS
* The number of characters written into the destination buffer.
@@ -643,7 +643,7 @@ ULONG CDECL WLDAP32_ldap_result( WLDAP32_LDAP *ld, ULONG msgid, ULONG all,
* NOTES
* Set dstlen to zero to ask for the required buffer size.
*/
-int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
+int CDECL LdapUnicodeToUTF8( const WCHAR *src, int srclen, char *dst, int dstlen )
{
return WideCharToMultiByte( CP_UTF8, 0, src, srclen, dst, dstlen, NULL, NULL );
}
@@ -657,7 +657,7 @@ int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
* src [I] UTF8 string to convert.
* srclen [I] Size of string to convert, in characters.
* dst [O] Pointer to a buffer that receives the converted string.
- * dstlen [I] Size of the destination buffer in characters.
+ * dstlen [I] Size of the destination buffer in characters.
*
* RETURNS
* The number of characters written into the destination buffer.
@@ -665,7 +665,7 @@ int CDECL LdapUnicodeToUTF8( LPCWSTR src, int srclen, LPSTR dst, int dstlen )
* NOTES
* Set dstlen to zero to ask for the required buffer size.
*/
-int CDECL LdapUTF8ToUnicode( LPCSTR src, int srclen, LPWSTR dst, int dstlen )
+int CDECL LdapUTF8ToUnicode( const char *src, int srclen, WCHAR *dst, int dstlen )
{
return MultiByteToWideChar( CP_UTF8, 0, src, srclen, dst, dstlen );
}
diff --git a/dlls/wldap32/parse.c b/dlls/wldap32/parse.c
index 6bde8542bec..bbaa7b1f842 100644
--- a/dlls/wldap32/parse.c
+++ b/dlls/wldap32/parse.c
@@ -99,7 +99,7 @@ ULONG CDECL ldap_parse_extended_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (!result) return WLDAP32_LDAP_NO_RESULTS_RETURNED;
- ret = map_error( ldap_parse_extended_result( ld->ld, result, &oidU, (struct berval **)data, free ) );
+ ret = map_error( ldap_parse_extended_result( ld->ld, result->Request, &oidU, (struct berval **)data, free ) );
if (oid) {
*oid = strUtoW( oidU );
@@ -153,18 +153,18 @@ ULONG CDECL ldap_parse_referenceA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *messag
* NOTES
* Free the referrals with ldap_value_free.
*/
-ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *message,
+ULONG CDECL ldap_parse_referenceW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
PWCHAR **referrals )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP_PARSE_REFERENCE
char **referralsU = NULL;
- TRACE( "(%p, %p, %p)\n", ld, message, referrals );
+ TRACE( "(%p, %p, %p)\n", ld, result, referrals );
if (!ld) return ~0u;
- ret = map_error( ldap_parse_reference( ld->ld, message, &referralsU, NULL, 0 ));
+ ret = map_error( ldap_parse_reference( ld->ld, result->Request, &referralsU, NULL, 0 ));
*referrals = strarrayUtoW( referralsU );
ldap_memfree( referralsU );
@@ -249,7 +249,7 @@ ULONG CDECL ldap_parse_resultW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *result,
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- ret = map_error( ldap_parse_result( ld->ld, result, (int *)retcode, &matchedU, &errorU,
+ ret = map_error( ldap_parse_result( ld->ld, result->Request, (int *)retcode, &matchedU, &errorU,
&referralsU, &serverctrlsU, free ));
if (matched) *matched = strUtoW( matchedU );
diff --git a/dlls/wldap32/search.c b/dlls/wldap32/search.c
index 88ecb541c92..b4bf204f817 100644
--- a/dlls/wldap32/search.c
+++ b/dlls/wldap32/search.c
@@ -18,57 +18,34 @@
* 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 "wine/heap.h"
+#include "winldap_private.h"
-#ifdef HAVE_LDAP
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
-#endif
/***********************************************************************
* ldap_searchA (WLDAP32.@)
*
* See ldap_searchW.
*/
-ULONG CDECL ldap_searchA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
- PCHAR attrs[], ULONG attrsonly )
+ULONG CDECL ldap_searchA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs, ULONG attrsonly )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(base),
- scope, debugstr_a(filter), attrs, attrsonly );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly );
if (!ld) return ~0u;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
ret = ldap_searchW( ld, baseW, scope, filterW, attrsW, attrsonly );
@@ -76,8 +53,6 @@ exit:
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
-
-#endif
return ret;
}
@@ -104,49 +79,14 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_searchW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
- PWCHAR attrs[], ULONG attrsonly )
+ULONG CDECL ldap_searchW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs, ULONG attrsonly )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
- int msg;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(base),
- scope, debugstr_w(filter), attrs, attrsonly );
-
- if (!ld) return ~0u;
+ ULONG ret, msg;
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly );
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
-
- ret = ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- NULL, NULL, NULL, 0, &msg );
-
- if (ret == LDAP_SUCCESS)
- ret = msg;
- else
- ret = ~0u;
-
-exit:
- strfreeU( baseU );
- strfreeU( filterU );
- strarrayfreeU( attrsU );
-
-#endif
- return ret;
+ ret = ldap_search_extW( ld, base, scope, filter, attrs, attrsonly, NULL, NULL, 0, 0, &msg );
+ if (ret == WLDAP32_LDAP_SUCCESS) return msg;
+ return ~0u;
}
/***********************************************************************
@@ -154,47 +94,26 @@ exit:
*
* See ldap_search_extW.
*/
-ULONG CDECL ldap_search_extA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
- PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
+ULONG CDECL ldap_search_extA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs, ULONG attrsonly,
+ LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
- ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
- serverctrls, clientctrls, timelimit, sizelimit, message );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_a(base), scope,
+ debugstr_a(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter)
- {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
- ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly,
- serverctrlsW, clientctrlsW, timelimit, sizelimit, message );
+ ret = ldap_search_extW( ld, baseW, scope, filterW, attrsW, attrsonly, serverctrlsW, clientctrlsW, timelimit,
+ sizelimit, message );
exit:
strfreeW( baseW );
@@ -202,8 +121,6 @@ exit:
strarrayfreeW( attrsW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -235,63 +152,38 @@ exit:
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_search_extW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
- PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, ULONG *message )
+ULONG CDECL ldap_search_extW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs,
+ ULONG attrsonly, LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG timelimit, ULONG sizelimit,
+ ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
- struct timeval tv, *tvp = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
+ struct timevalU timevalU;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n",
- ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
- serverctrls, clientctrls, timelimit, sizelimit, message );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", ld, debugstr_w(base), scope,
+ debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timelimit, sizelimit, message );
if (!ld) return ~0u;
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- if (timelimit)
- {
- tv.tv_sec = timelimit;
- tv.tv_usec = 0;
- tvp = &tv;
- }
+ if (base && !(baseU = strWtoU( base ))) goto exit;
+ if (filter && !(filterU = strWtoU( filter ))) goto exit;
+ if (attrs && !(attrsU = strarrayWtoU( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
- ret = map_error( ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- serverctrlsU, clientctrlsU, tvp, sizelimit, (int *)message ));
+ timevalU.tv_sec = timelimit;
+ timevalU.tv_usec = 0;
+ ret = map_error( ldap_funcs->ldap_search_ext( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
+ serverctrlsU, clientctrlsU, timelimit ? &timevalU : NULL, sizelimit,
+ message ) );
exit:
strfreeU( baseU );
strfreeU( filterU );
strarrayfreeU( attrsU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -300,46 +192,27 @@ exit:
*
* See ldap_search_ext_sW.
*/
-ULONG CDECL ldap_search_ext_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope,
- PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_ext_sA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs,
+ ULONG attrsonly, LDAPControlA **serverctrls, LDAPControlA **clientctrls, struct l_timeval *timeout,
+ ULONG sizelimit, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n",
- ld, debugstr_a(base), scope, debugstr_a(filter), attrs, attrsonly,
- serverctrls, clientctrls, timeout, sizelimit, res );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n", ld, debugstr_a(base), scope,
+ debugstr_a(filter), attrs, attrsonly, serverctrls, clientctrls, timeout, sizelimit, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
- if (serverctrls) {
- serverctrlsW = controlarrayAtoW( serverctrls );
- if (!serverctrlsW) goto exit;
- }
- if (clientctrls) {
- clientctrlsW = controlarrayAtoW( clientctrls );
- if (!clientctrlsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
- ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly,
- serverctrlsW, clientctrlsW, timeout, sizelimit, res );
+ ret = ldap_search_ext_sW( ld, baseW, scope, filterW, attrsW, attrsonly, serverctrlsW, clientctrlsW, timeout,
+ sizelimit, res );
exit:
strfreeW( baseW );
@@ -347,8 +220,6 @@ exit:
strarrayfreeW( attrsW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -378,47 +249,49 @@ exit:
* NOTES
* Call ldap_msgfree to free the results.
*/
-ULONG CDECL ldap_search_ext_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope,
- PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, struct l_timeval* timeout, ULONG sizelimit, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_ext_sW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs,
+ ULONG attrsonly, LDAPControlW **serverctrls, LDAPControlW **clientctrls, struct l_timeval *timeout,
+ ULONG sizelimit, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
+ struct timevalU timevalU;
+ void *msgU = NULL;
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n",
- ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly,
- serverctrls, clientctrls, timeout, sizelimit, res );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, %p, 0x%08x, %p)\n", ld, debugstr_w(base), scope,
+ debugstr_w(filter), attrs, attrsonly, serverctrls, clientctrls, timeout, sizelimit, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
+ if (base && !(baseU = strWtoU( base ))) goto exit;
+ if (filter && !(filterU = strWtoU( filter ))) goto exit;
+ if (attrs && !(attrsU = strarrayWtoU( attrs ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ if (timeout)
+ {
+ timevalU.tv_sec = timeout->tv_sec;
+ timevalU.tv_usec = timeout->tv_usec;
}
- ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- serverctrlsU, clientctrlsU, (struct timeval *)timeout,
- sizelimit, res ));
+ ret = map_error( ldap_funcs->ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly, serverctrlsU,
+ clientctrlsU, timeout ? &timevalU : NULL, sizelimit, &msgU ) );
+ if (msgU)
+ {
+ WLDAP32_LDAPMessage *msg = heap_alloc_zero( sizeof(*msg) );
+ if (msg)
+ {
+ msg->Request = msgU;
+ *res = msg;
+ }
+ else
+ {
+ ldap_funcs->ldap_msgfree( msgU );
+ ret = WLDAP32_LDAP_NO_MEMORY;
+ }
+ }
exit:
strfreeU( baseU );
@@ -426,8 +299,6 @@ exit:
strarrayfreeU( attrsU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -436,32 +307,20 @@ exit:
*
* See ldap_search_sW.
*/
-ULONG CDECL ldap_search_sA( WLDAP32_LDAP *ld, PCHAR base, ULONG scope, PCHAR filter,
- PCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_sA( WLDAP32_LDAP *ld, char *base, ULONG scope, char *filter, char **attrs, ULONG attrsonly,
+ WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_a(base),
- scope, debugstr_a(filter), attrs, attrsonly, res );
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_a(base), scope, debugstr_a(filter), attrs,
+ attrsonly, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
ret = ldap_search_sW( ld, baseW, scope, filterW, attrsW, attrsonly, res );
@@ -469,8 +328,6 @@ exit:
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
-
-#endif
return ret;
}
@@ -496,43 +353,12 @@ exit:
* NOTES
* Call ldap_msgfree to free the results.
*/
-ULONG CDECL ldap_search_sW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter,
- PWCHAR attrs[], ULONG attrsonly, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_sW( WLDAP32_LDAP *ld, WCHAR *base, ULONG scope, WCHAR *filter, WCHAR **attrs, ULONG attrsonly,
+ WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_w(base),
- scope, debugstr_w(filter), attrs, attrsonly, res );
-
- if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
-
- ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- NULL, NULL, NULL, 0, res ));
-
-exit:
- strfreeU( baseU );
- strfreeU( filterU );
- strarrayfreeU( attrsU );
-
-#endif
- return ret;
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs,
+ attrsonly, res );
+ return ldap_search_ext_sW( ld, base, scope, filter, attrs, attrsonly, NULL, NULL, NULL, 0, res );
}
/***********************************************************************
@@ -540,44 +366,27 @@ exit:
*
* See ldap_search_stW.
*/
-ULONG CDECL ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope,
- const PCHAR filter, PCHAR attrs[], ULONG attrsonly,
- struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_stA( WLDAP32_LDAP *ld, const PCHAR base, ULONG scope, const PCHAR filter, char **attrs,
+ ULONG attrsonly, struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *baseW = NULL, *filterW = NULL, **attrsW = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld,
- debugstr_a(base), scope, debugstr_a(filter), attrs,
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld, debugstr_a(base), scope, debugstr_a(filter), attrs,
attrsonly, timeout, res );
if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
- if (base) {
- baseW = strAtoW( base );
- if (!baseW) goto exit;
- }
- if (filter) {
- filterW = strAtoW( filter );
- if (!filterW) goto exit;
- }
- if (attrs) {
- attrsW = strarrayAtoW( attrs );
- if (!attrsW) goto exit;
- }
+ if (base && !(baseW = strAtoW( base ))) goto exit;
+ if (filter && !(filterW = strAtoW( filter ))) goto exit;
+ if (attrs && !(attrsW = strarrayAtoW( attrs ))) goto exit;
- ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly,
- timeout, res );
+ ret = ldap_search_stW( ld, baseW, scope, filterW, attrsW, attrsonly, timeout, res );
exit:
strfreeW( baseW );
strfreeW( filterW );
strarrayfreeW( attrsW );
-
-#endif
return ret;
}
@@ -604,43 +413,10 @@ exit:
* NOTES
* Call ldap_msgfree to free the results.
*/
-ULONG CDECL ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope,
- const PWCHAR filter, PWCHAR attrs[], ULONG attrsonly,
- struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
+ULONG CDECL ldap_search_stW( WLDAP32_LDAP *ld, const PWCHAR base, ULONG scope, const PWCHAR filter, WCHAR **attrs,
+ ULONG attrsonly, struct l_timeval *timeout, WLDAP32_LDAPMessage **res )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *baseU = NULL, *filterU = NULL, **attrsU = NULL;
-
- ret = WLDAP32_LDAP_NO_MEMORY;
-
- TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld,
- debugstr_w(base), scope, debugstr_w(filter), attrs,
+ TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p)\n", ld, debugstr_w(base), scope, debugstr_w(filter), attrs,
attrsonly, timeout, res );
-
- if (!ld || !res) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (base) {
- baseU = strWtoU( base );
- if (!baseU) goto exit;
- }
- if (filter) {
- filterU = strWtoU( filter );
- if (!filterU) goto exit;
- }
- if (attrs) {
- attrsU = strarrayWtoU( attrs );
- if (!attrsU) goto exit;
- }
-
- ret = map_error( ldap_search_ext_s( ld->ld, baseU, scope, filterU, attrsU, attrsonly,
- NULL, NULL, (struct timeval *)timeout, 0, res ));
-
-exit:
- strfreeU( baseU );
- strfreeU( filterU );
- strarrayfreeU( attrsU );
-
-#endif
- return ret;
+ return ldap_search_ext_sW( ld, base, scope, filter, attrs, attrsonly, NULL, NULL, timeout, 0, res );
}
diff --git a/dlls/wldap32/value.c b/dlls/wldap32/value.c
index ff13289b309..a7d7d44244f 100644
--- a/dlls/wldap32/value.c
+++ b/dlls/wldap32/value.c
@@ -228,7 +228,7 @@ PWCHAR * CDECL ldap_get_valuesW( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, P
attrU = strWtoU( attr );
if (!attrU) return NULL;
- bv = ldap_get_values_len( ld->ld, entry, attrU );
+ bv = ldap_get_values_len( ld->ld, entry->Request, attrU );
if (bv)
{
retU = bv2str_array( bv );
@@ -305,7 +305,7 @@ struct WLDAP32_berval ** CDECL ldap_get_values_lenW( WLDAP32_LDAP *ld,
attrU = strWtoU( attr );
if (!attrU) return NULL;
- ret = ldap_get_values_len( ld->ld, message, attrU );
+ ret = ldap_get_values_len( ld->ld, message->Request, attrU );
strfreeU( attrU );
return (struct WLDAP32_berval **)ret;
--
2.30.2
1
0
[PATCH 2/5] wldap32: Move support for error functions to the Unix library.
by Hans Leidekker April 15, 2021
by Hans Leidekker April 15, 2021
April 15, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/error.c | 64 ++++++++++++++++++------------------------
dlls/wldap32/libldap.c | 7 +++++
dlls/wldap32/libldap.h | 3 ++
3 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/dlls/wldap32/error.c b/dlls/wldap32/error.c
index 11ecaf8763b..c1b678788f0 100644
--- a/dlls/wldap32/error.c
+++ b/dlls/wldap32/error.c
@@ -18,47 +18,41 @@
* 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 "winuser.h"
#include "winnls.h"
-#include "winldap_private.h"
-#include "wldap32.h"
#include "wine/debug.h"
+#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
+extern HINSTANCE hwldap32 DECLSPEC_HIDDEN;
+
ULONG map_error( int error )
{
switch (error)
{
-#ifdef HAVE_LDAP_H
- case LDAP_SERVER_DOWN: return WLDAP32_LDAP_SERVER_DOWN;
- case LDAP_LOCAL_ERROR: return WLDAP32_LDAP_LOCAL_ERROR;
- case LDAP_DECODING_ERROR: return WLDAP32_LDAP_DECODING_ERROR;
- case LDAP_TIMEOUT: return WLDAP32_LDAP_TIMEOUT;
- case LDAP_AUTH_UNKNOWN: return WLDAP32_LDAP_AUTH_UNKNOWN;
- case LDAP_FILTER_ERROR: return WLDAP32_LDAP_FILTER_ERROR;
- case LDAP_USER_CANCELLED: return WLDAP32_LDAP_USER_CANCELLED;
- case LDAP_PARAM_ERROR: return WLDAP32_LDAP_PARAM_ERROR;
- case LDAP_NO_MEMORY: return WLDAP32_LDAP_NO_MEMORY;
- case LDAP_CONNECT_ERROR: return WLDAP32_LDAP_CONNECT_ERROR;
- case LDAP_NOT_SUPPORTED: return WLDAP32_LDAP_NOT_SUPPORTED;
- case LDAP_CONTROL_NOT_FOUND: return WLDAP32_LDAP_CONTROL_NOT_FOUND;
- case LDAP_NO_RESULTS_RETURNED: return WLDAP32_LDAP_NO_RESULTS_RETURNED;
- case LDAP_MORE_RESULTS_TO_RETURN: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN;
- case LDAP_CLIENT_LOOP: return WLDAP32_LDAP_CLIENT_LOOP;
- case LDAP_REFERRAL_LIMIT_EXCEEDED: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED;
-#endif
+ case 0: return WLDAP32_LDAP_SUCCESS;
+ case -1: return WLDAP32_LDAP_SERVER_DOWN;
+ case -2: return WLDAP32_LDAP_LOCAL_ERROR;
+ case -3: return WLDAP32_LDAP_ENCODING_ERROR;
+ case -4: return WLDAP32_LDAP_DECODING_ERROR;
+ case -5: return WLDAP32_LDAP_TIMEOUT;
+ case -6: return WLDAP32_LDAP_AUTH_UNKNOWN;
+ case -7: return WLDAP32_LDAP_FILTER_ERROR;
+ case -8: return WLDAP32_LDAP_USER_CANCELLED;
+ case -9: return WLDAP32_LDAP_PARAM_ERROR;
+ case -10: return WLDAP32_LDAP_NO_MEMORY;
+ case -11: return WLDAP32_LDAP_CONNECT_ERROR;
+ case -12: return WLDAP32_LDAP_NOT_SUPPORTED;
+ case -13: return WLDAP32_LDAP_CONTROL_NOT_FOUND;
+ case -14: return WLDAP32_LDAP_NO_RESULTS_RETURNED;
+ case -15: return WLDAP32_LDAP_MORE_RESULTS_TO_RETURN;
+ case -16: return WLDAP32_LDAP_CLIENT_LOOP;
+ case -17: return WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED;
default: return error;
}
}
@@ -68,7 +62,7 @@ ULONG map_error( int error )
*
* See ldap_err2stringW.
*/
-PCHAR CDECL ldap_err2stringA( ULONG err )
+char * CDECL ldap_err2stringA( ULONG err )
{
static char buf[256] = "";
@@ -98,7 +92,7 @@ PCHAR CDECL ldap_err2stringA( ULONG err )
* The returned string is statically allocated, you must not
* free this string.
*/
-PWCHAR CDECL ldap_err2stringW( ULONG err )
+WCHAR * CDECL ldap_err2stringW( ULONG err )
{
static WCHAR buf[256] = { 0 };
@@ -151,22 +145,19 @@ void CDECL WLDAP32_ldap_perror( WLDAP32_LDAP *ld, const PCHAR msg )
*/
ULONG CDECL WLDAP32_ldap_result2error( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res, ULONG free )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
int error;
TRACE( "(%p, %p, 0x%08x)\n", ld, res, free );
if (!ld || !res) return ~0u;
- ret = ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free );
-
- if (ret == LDAP_SUCCESS)
+ ret = map_error( ldap_funcs->ldap_parse_result( ld->ld, res, &error, NULL, NULL, NULL, NULL, free ) );
+ if (ret == WLDAP32_LDAP_SUCCESS)
ret = error;
else
ret = ~0u;
-#endif
return ret;
}
@@ -303,7 +294,6 @@ ULONG CDECL LdapMapErrorToWin32( ULONG err )
{
TRACE( "(0x%08x)\n", err );
- if (err >= ARRAY_SIZE( WLDAP32_errormap ))
- return ERROR_DS_GENERIC_ERROR;
+ if (err >= ARRAY_SIZE( WLDAP32_errormap )) return ERROR_DS_GENERIC_ERROR;
return WLDAP32_errormap[err];
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index be2e540721b..11a3707f200 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -357,6 +357,12 @@ void CDECL wrap_ldap_memfree( void *ptr )
return ldap_memfree( ptr );
}
+int CDECL wrap_ldap_parse_result( void *ld, void *res, int *errcode, char **matcheddn, char **errmsg,
+ char ***referrals, LDAPControlU ***serverctrls, int free )
+{
+ return ldap_parse_result( ld, res, errcode, matcheddn, errmsg, referrals, (LDAPControl ***)serverctrls, free );
+}
+
int CDECL wrap_ldap_sasl_bind( void *ld, const char *dn, const char *mech, struct bervalU *cred,
LDAPControlU **serverctrls, LDAPControlU **clientctrls, int *msgid )
{
@@ -426,6 +432,7 @@ static const struct ldap_funcs funcs =
wrap_ldap_delete_ext,
wrap_ldap_delete_ext_s,
wrap_ldap_memfree,
+ wrap_ldap_parse_result,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
wrap_ldap_sasl_interactive_bind_s,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index dde7d3eba17..5ebc5bacd54 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -104,6 +104,8 @@ extern int CDECL wrap_ldap_create_vlv_control(void *, LDAPVLVInfoU *, LDAPContro
extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(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_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind_s(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
@@ -141,6 +143,7 @@ struct ldap_funcs
int (CDECL *ldap_delete_ext)(void *, const char *, LDAPControlU **, LDAPControlU **, ULONG *);
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_memfree)(void *);
+ int (CDECL *ldap_parse_result)(void *, void *, int *, char **, char **, char ***, LDAPControlU ***, int);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
int (CDECL *ldap_sasl_bind_s)(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
--
2.30.2
1
0
[PATCH 1/5] wldap32: Move support for delete functions to the Unix library.
by Hans Leidekker April 15, 2021
by Hans Leidekker April 15, 2021
April 15, 2021
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wldap32/delete.c | 214 ++++++++++-------------------------------
dlls/wldap32/libldap.c | 15 +++
dlls/wldap32/libldap.h | 4 +
3 files changed, 68 insertions(+), 165 deletions(-)
diff --git a/dlls/wldap32/delete.c b/dlls/wldap32/delete.c
index 95d636e4874..9f2b107f62c 100644
--- a/dlls/wldap32/delete.c
+++ b/dlls/wldap32/delete.c
@@ -18,50 +18,33 @@
* 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_deleteA (WLDAP32.@)
*
* See ldap_deleteW.
*/
-ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
+ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, char *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
WCHAR *dnW = NULL;
TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
if (!ld) return ~0u;
-
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (dn && !(dnW = strAtoW( dn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_deleteW( ld, dnW );
strfreeW( dnW );
-
-#endif
return ret;
}
@@ -83,33 +66,15 @@ ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
* the operation. Cancel the operation by calling ldap_abandon
* with the message ID.
*/
-ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
+ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, WCHAR *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL;
- int msg;
+ ULONG ret, msg;
TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
- if (!ld) return ~0u;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
- }
-
- ret = ldap_delete_ext( ld->ld, dn ? dnU : "", NULL, NULL, &msg );
-
- if (ret == LDAP_SUCCESS)
- ret = msg;
- else
- ret = ~0u;
-
- strfreeU( dnU );
-
-#endif
- return ret;
+ ret = ldap_delete_extW( ld, dn, NULL, NULL, &msg );
+ if (ret == WLDAP32_LDAP_SUCCESS) return msg;
+ return ~0u;
}
/***********************************************************************
@@ -117,33 +82,20 @@ ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
*
* See ldap_delete_extW.
*/
-ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls, ULONG *message )
+ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, char *dn, LDAPControlA **serverctrls,
+ LDAPControlA **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
- clientctrls, message );
-
- ret = WLDAP32_LDAP_NO_MEMORY;
+ TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) 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 (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
@@ -151,8 +103,6 @@ exit:
strfreeW( dnW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -177,44 +127,27 @@ exit:
* the operation. The serverctrls and clientctrls parameters are
* optional and should be set to NULL if not used.
*/
-ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls, ULONG *message )
+ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls,
+ LDAPControlW **clientctrls, ULONG *message )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
- int dummy;
-
- TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
- clientctrls, message );
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
- ret = WLDAP32_LDAP_NO_MEMORY;
+ TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- ret = map_error( ldap_delete_ext( ld->ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
- message ? (int *)message : &dummy ));
+ if (dn && !(dnU = strWtoU( dn ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ ret = map_error( ldap_funcs->ldap_delete_ext( ld->ld, dnU, serverctrlsU, clientctrlsU, message ) );
exit:
strfreeU( dnU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
@@ -223,31 +156,20 @@ exit:
*
* See ldap_delete_ext_sW.
*/
-ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
- PLDAPControlA *clientctrls )
+ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, char *dn, LDAPControlA **serverctrls,
+ LDAPControlA **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *dnW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
- TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
- clientctrls );
+ TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) 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 (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
@@ -255,8 +177,6 @@ exit:
strfreeW( dnW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
-
-#endif
return ret;
}
@@ -279,67 +199,47 @@ exit:
* The serverctrls and clientctrls parameters are optional and
* should be set to NULL if not used.
*/
-ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
- PLDAPControlW *clientctrls )
+ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls,
+ LDAPControlW **clientctrls )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *dnU = NULL;
- LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
+ LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
- TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
- clientctrls );
+ TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) goto exit;
- }
- if (serverctrls) {
- serverctrlsU = controlarrayWtoU( serverctrls );
- if (!serverctrlsU) goto exit;
- }
- if (clientctrls) {
- clientctrlsU = controlarrayWtoU( clientctrls );
- if (!clientctrlsU) goto exit;
- }
-
- ret = map_error( ldap_delete_ext_s( ld->ld, dn ? dnU : "", serverctrlsU, clientctrlsU ));
+ if (dn && !(dnU = strWtoU( dn ))) goto exit;
+ if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
+ if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
+
+ ret = map_error( ldap_funcs->ldap_delete_ext_s( ld->ld, dnU, serverctrlsU, clientctrlsU ) );
exit:
strfreeU( dnU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
-
-#endif
return ret;
}
-
+
/***********************************************************************
* ldap_delete_sA (WLDAP32.@)
*
* See ldap_delete_sW.
*/
-ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
+ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, char *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
+ ULONG ret;
WCHAR *dnW = NULL;
TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnW = strAtoW( dn );
- if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
- }
+ if (dn && !(dnW = strAtoW( dn ))) return WLDAP32_LDAP_NO_MEMORY;
ret = ldap_delete_sW( ld, dnW );
strfreeW( dnW );
-
-#endif
return ret;
}
@@ -356,24 +256,8 @@ ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
* Success: LDAP_SUCCESS
* Failure: An LDAP error code.
*/
-ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
+ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, WCHAR *dn )
{
- ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
-#ifdef HAVE_LDAP
- char *dnU = NULL;
-
TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
-
- if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
-
- if (dn) {
- dnU = strWtoU( dn );
- if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
- }
-
- ret = map_error( ldap_delete_ext_s( ld->ld, dn ? dnU : "", NULL, NULL ));
- strfreeU( dnU );
-
-#endif
- return ret;
+ return ldap_delete_ext_sW( ld, dn, NULL, NULL );
}
diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c
index 34cd3e98746..be2e540721b 100644
--- a/dlls/wldap32/libldap.c
+++ b/dlls/wldap32/libldap.c
@@ -339,6 +339,19 @@ int CDECL wrap_ldap_create_vlv_control( void *ld, LDAPVLVInfoU *info, LDAPContro
return ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, (LDAPControl **)control );
}
+int CDECL wrap_ldap_delete_ext( void *ld, const char *dn, LDAPControlU **serverctrls, LDAPControlU **clientctrls,
+ ULONG *msg )
+{
+ int dummy;
+ return ldap_delete_ext( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls,
+ msg ? (int *)msg : &dummy );
+}
+
+int CDECL wrap_ldap_delete_ext_s( void *ld, const char *dn, LDAPControlU **serverctrls, LDAPControlU **clientctrls )
+{
+ return ldap_delete_ext_s( ld, dn ? dn : "", (LDAPControl **)serverctrls, (LDAPControl **)clientctrls );
+}
+
void CDECL wrap_ldap_memfree( void *ptr )
{
return ldap_memfree( ptr );
@@ -410,6 +423,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_control_free,
wrap_ldap_create_sort_control,
wrap_ldap_create_vlv_control,
+ wrap_ldap_delete_ext,
+ wrap_ldap_delete_ext_s,
wrap_ldap_memfree,
wrap_ldap_sasl_bind,
wrap_ldap_sasl_bind_s,
diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h
index c582e9f923d..dde7d3eba17 100644
--- a/dlls/wldap32/libldap.h
+++ b/dlls/wldap32/libldap.h
@@ -101,6 +101,8 @@ 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_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;
+extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern void CDECL wrap_ldap_memfree(void *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_sasl_bind(void *, const char *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, int *) DECLSPEC_HIDDEN;
@@ -136,6 +138,8 @@ struct ldap_funcs
void (CDECL *ldap_control_free)(LDAPControlU *);
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 *);
+ int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
void (CDECL *ldap_memfree)(void *);
int (CDECL *ldap_sasl_bind)(void *, const char *, const char *, struct bervalU *, LDAPControlU **, LDAPControlU **,
int *);
--
2.30.2
1
0
[PATCH v2] xmllite: Avoid out of bounds access in readerinput_get_utf8_convlen().
by Paul Gofman April 15, 2021
by Paul Gofman April 15, 2021
April 15, 2021
And consequently in readerinput_shrinkraw().
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
v2:
- move the 'written' check to readerinput_growraw();
- add readerinput_growraw() failure check in readerinput_shrinkraw().
dlls/xmllite/reader.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index 13d841eb94d..a5a75c29887 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -844,6 +844,8 @@ static HRESULT readerinput_growraw(xmlreaderinput *readerinput)
readerinput->pending = hr == E_PENDING;
if (FAILED(hr)) return hr;
buffer->written += read;
+ if (!buffer->written)
+ return MX_E_INPUTEND;
return hr;
}
@@ -929,6 +931,8 @@ static int readerinput_get_utf8_convlen(xmlreaderinput *readerinput)
encoded_buffer *buffer = &readerinput->buffer->encoded;
int len = buffer->written;
+ assert(len);
+
/* complete single byte char */
if (!(buffer->data[len-1] & 0x80)) return len;
@@ -966,6 +970,7 @@ static void readerinput_shrinkraw(xmlreaderinput *readerinput, int len)
if (len == -1)
len = readerinput_get_convlen(readerinput);
+ assert(len >= 0);
memmove(buffer->data, buffer->data + buffer->cur + (buffer->written - len), len);
/* everything below cur is lost too */
buffer->written -= len + buffer->cur;
@@ -1068,7 +1073,9 @@ static HRESULT reader_more(xmlreader *reader)
WCHAR *ptr;
/* get some raw data from stream first */
- hr = readerinput_growraw(readerinput);
+ if (FAILED(hr = readerinput_growraw(readerinput)))
+ return hr;
+
len = readerinput_get_convlen(readerinput);
prev_len = dest->written / sizeof(WCHAR);
--
2.30.2
2
1