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','-',' ...@@ -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 Version3_SubdirW[] = {'\\','3',0};
static const WCHAR spooldriversW[] = {'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s','\\',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 backslashW[] = {'\\',0};
static const WCHAR Configuration_FileW[] = {'C','o','n','f','i','g','u','r','a','t', static const WCHAR Configuration_FileW[] = {'C','o','n','f','i','g','u','r','a','t',
'i','o','n',' ','F','i','l','e',0}; 'i','o','n',' ','F','i','l','e',0};
...@@ -2162,58 +2160,25 @@ BOOL WINAPI GetPrintProcessorDirectoryW(LPWSTR server, LPWSTR env, ...@@ -2162,58 +2160,25 @@ BOOL WINAPI GetPrintProcessorDirectoryW(LPWSTR server, LPWSTR env,
DWORD level, LPBYTE Info, DWORD level, LPBYTE Info,
DWORD cbBuf, LPDWORD pcbNeeded) 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]) { TRACE("(%s, %s, %d, %p, %d, %p)\n", debugstr_w(server), debugstr_w(env), level,
FIXME("server not supported: %s\n", debugstr_w(server)); Info, cbBuf, pcbNeeded);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
env_t = validate_envW(env); if ((backend == NULL) && !load_backend()) return FALSE;
if(!env_t) return FALSE; /* environment invalid or unsupported */
if(level != 1) { if (level != 1) {
WARN("(Level: %d) is ignored in win9x\n", level); /* (Level != 1) is ignored in win9x */
SetLastError(ERROR_INVALID_LEVEL); SetLastError(ERROR_INVALID_LEVEL);
return FALSE; return FALSE;
} }
/* GetSystemDirectoryW returns number of WCHAR including the '\0' */ if (pcbNeeded == NULL) {
needed = GetSystemDirectoryW(NULL, 0); /* (pcbNeeded == NULL) is ignored in win9x */
/* 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 */
SetLastError(RPC_X_NULL_REF_POINTER); SetLastError(RPC_X_NULL_REF_POINTER);
return FALSE; return FALSE;
} }
GetSystemDirectoryW((LPWSTR) Info, cbBuf/sizeof(WCHAR)); return backend->fpGetPrintProcessorDirectory(server, env, level, Info, cbBuf, pcbNeeded);
/* add the Subdirectories */
lstrcatW((LPWSTR) Info, spoolprtprocsW);
lstrcatW((LPWSTR) Info, env_t->subdir);
TRACE(" => %s\n", debugstr_w((LPWSTR) Info));
return TRUE;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -50,7 +50,7 @@ static CHAR LocalPortA[] = "Local Port"; ...@@ -50,7 +50,7 @@ static CHAR LocalPortA[] = "Local Port";
static CHAR portname_com1[] = "COM1:"; static CHAR portname_com1[] = "COM1:";
static CHAR portname_file[] = "FILE:"; static CHAR portname_file[] = "FILE:";
static CHAR portname_lpt1[] = "LPT1:"; 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 version_dll[] = "version.dll";
static CHAR winetest[] = "winetest"; static CHAR winetest[] = "winetest";
static CHAR xcv_localport[] = ",XcvMonitor Local Port"; static CHAR xcv_localport[] = ",XcvMonitor Local Port";
...@@ -1628,41 +1628,49 @@ static void test_GetPrintProcessorDirectory(void) ...@@ -1628,41 +1628,49 @@ static void test_GetPrintProcessorDirectory(void)
pcbNeeded = 0; pcbNeeded = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded); 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'; buffer[0] = '\0';
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL); res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */ /* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER), ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ||
"returned %d with %d (expected '!= 0' or '0' with " broken(res),
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError()); "returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER)\n",
res, GetLastError());
buffer[0] = '\0'; buffer[0] = '\0';
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL); res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */ /* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER), ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ||
"returned %d with %d (expected '!= 0' or '0' with " broken(res),
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError()); "returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER)\n",
res, GetLastError());
/* with a valid buffer, but level is invalid */ /* with a valid buffer, but level is invalid */
buffer[0] = '\0'; buffer[0] = '\0';
SetLastError(0xdeadbeef); 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); res = GetPrintProcessorDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
if (res && buffer[0])
{
/* Level is ignored in win9x*/ /* Level is ignored in win9x*/
trace("invalid level (2) was ignored\n"); ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
} broken(res && buffer[0]),
else
{
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n", "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
res, GetLastError()); res, GetLastError());
}
/* Empty environment is the same as the default environment */ /* Empty environment is the same as the default environment */
buffer[0] = '\0'; buffer[0] = '\0';
...@@ -1703,9 +1711,11 @@ static void test_GetPrintProcessorDirectory(void) ...@@ -1703,9 +1711,11 @@ static void test_GetPrintProcessorDirectory(void)
buffer[0] = '\0'; buffer[0] = '\0';
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = GetPrintProcessorDirectoryA(server_does_not_exist, NULL, 1, buffer, cbBuf*2, &pcbNeeded); res = GetPrintProcessorDirectoryA(server_does_not_exist, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER), /* NT: RPC_S_SERVER_UNAVAILABLE, 9x: ERROR_INVALID_PARAMETER */
"returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n", ok( !res &&
res, GetLastError()); (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); 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