Commit 388aca4b authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

winspool: Use the backend for GetPrintProcessorDirectory and update the tests.

parent 065599a4
......@@ -175,8 +175,6 @@ static const WCHAR Version3_RegPathW[] = {'\\','V','e','r','s','i','o','n','-','
static const WCHAR Version3_SubdirW[] = {'\\','3',0};
static const WCHAR spooldriversW[] = {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\',0};
static const WCHAR spoolprtprocsW[] = {'\\','s','p','o','o','l','\\','p','r','t','p','r','o','c','s','\\',0};
static const WCHAR backslashW[] = {'\\',0};
static const WCHAR Configuration_FileW[] = {'C','o','n','f','i','g','u','r','a','t',
'i','o','n',' ','F','i','l','e',0};
......@@ -2162,58 +2160,25 @@ BOOL WINAPI GetPrintProcessorDirectoryW(LPWSTR server, LPWSTR env,
DWORD level, LPBYTE Info,
DWORD cbBuf, LPDWORD pcbNeeded)
{
DWORD needed;
const printenv_t * env_t;
TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_w(server),
debugstr_w(env), level, Info, cbBuf, pcbNeeded);
if(server != NULL && server[0]) {
FIXME("server not supported: %s\n", debugstr_w(server));
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_w(server), debugstr_w(env), level,
Info, cbBuf, pcbNeeded);
env_t = validate_envW(env);
if(!env_t) return FALSE; /* environment invalid or unsupported */
if ((backend == NULL) && !load_backend()) return FALSE;
if(level != 1) {
WARN("(Level: %d) is ignored in win9x\n", level);
if (level != 1) {
/* (Level != 1) is ignored in win9x */
SetLastError(ERROR_INVALID_LEVEL);
return FALSE;
}
/* GetSystemDirectoryW returns number of WCHAR including the '\0' */
needed = GetSystemDirectoryW(NULL, 0);
/* add the Size for the Subdirectories */
needed += lstrlenW(spoolprtprocsW);
needed += lstrlenW(env_t->subdir);
needed *= sizeof(WCHAR); /* return-value is size in Bytes */
if(pcbNeeded) *pcbNeeded = needed;
TRACE ("required: 0x%x/%d\n", needed, needed);
if (needed > cbBuf) {
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
if(pcbNeeded == NULL) {
/* NT: RPC_X_NULL_REF_POINTER, 9x: ignored */
WARN("(pcbNeeded == NULL) is ignored in win9x\n");
SetLastError(RPC_X_NULL_REF_POINTER);
return FALSE;
}
if(Info == NULL) {
/* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
if (pcbNeeded == NULL) {
/* (pcbNeeded == NULL) is ignored in win9x */
SetLastError(RPC_X_NULL_REF_POINTER);
return FALSE;
}
GetSystemDirectoryW((LPWSTR) Info, cbBuf/sizeof(WCHAR));
/* add the Subdirectories */
lstrcatW((LPWSTR) Info, spoolprtprocsW);
lstrcatW((LPWSTR) Info, env_t->subdir);
TRACE(" => %s\n", debugstr_w((LPWSTR) Info));
return TRUE;
return backend->fpGetPrintProcessorDirectory(server, env, level, Info, cbBuf, pcbNeeded);
}
/*****************************************************************************
......
......@@ -50,7 +50,7 @@ static CHAR LocalPortA[] = "Local Port";
static CHAR portname_com1[] = "COM1:";
static CHAR portname_file[] = "FILE:";
static CHAR portname_lpt1[] = "LPT1:";
static CHAR server_does_not_exist[] = "\\does_not_exist";
static CHAR server_does_not_exist[] = "\\\\does_not_exist";
static CHAR version_dll[] = "version.dll";
static CHAR winetest[] = "winetest";
static CHAR xcv_localport[] = ",XcvMonitor Local Port";
......@@ -1628,41 +1628,49 @@ static void test_GetPrintProcessorDirectory(void)
pcbNeeded = 0;
SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
/* NT: ERROR_INVALID_USER_BUFFER, 9x: res != 0 */
ok( (!res && (GetLastError() == ERROR_INVALID_USER_BUFFER)) ||
broken(res),
"returned %d with %d (expected '0' with ERROR_INVALID_USER_BUFFER)\n",
res, GetLastError());
}
buffer[0] = '\0';
SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER),
"returned %d with %d (expected '!= 0' or '0' with "
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ||
broken(res),
"returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER)\n",
res, GetLastError());
buffer[0] = '\0';
SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER),
"returned %d with %d (expected '!= 0' or '0' with "
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ||
broken(res),
"returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER)\n",
res, GetLastError());
/* with a valid buffer, but level is invalid */
buffer[0] = '\0';
SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA(NULL, NULL, 0, buffer, cbBuf, &pcbNeeded);
/* Level is ignored in win9x*/
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
broken(res && buffer[0]),
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
buffer[0] = '\0';
SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
if (res && buffer[0])
{
/* Level is ignored in win9x*/
trace("invalid level (2) was ignored\n");
}
else
{
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
}
/* Level is ignored in win9x*/
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
broken(res && buffer[0]),
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError());
/* Empty environment is the same as the default environment */
buffer[0] = '\0';
......@@ -1703,9 +1711,11 @@ static void test_GetPrintProcessorDirectory(void)
buffer[0] = '\0';
SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA(server_does_not_exist, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
"returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
res, GetLastError());
/* NT: RPC_S_SERVER_UNAVAILABLE, 9x: ERROR_INVALID_PARAMETER */
ok( !res &&
(GetLastError() == RPC_S_SERVER_UNAVAILABLE || GetLastError() == ERROR_INVALID_PARAMETER),
"returned %d with %d (expected '0' with RPC_S_SERVER_UNAVAILABLE or "
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
HeapFree(GetProcessHeap(), 0, buffer);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment