Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b13c498c
Commit
b13c498c
authored
Apr 14, 2006
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Apr 14, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winspool: Add a test for GetPrinterDriver, make it pass under Wine.
parent
590f6fae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
18 deletions
+118
-18
info.c
dlls/winspool/info.c
+30
-18
info.c
dlls/winspool/tests/info.c
+88
-0
No files found.
dlls/winspool/info.c
View file @
b13c498c
...
...
@@ -575,7 +575,7 @@ void WINSPOOL_LoadSystemPrinters(void)
WCHAR
PrinterName
[
256
];
BOOL
done
=
FALSE
;
di3a
.
cVersion
=
0x400
;
di3a
.
cVersion
=
(
GetVersion
()
&
0x80000000
)
?
0
:
3
;
/* FIXME: add 1, 2 */
di3a
.
pName
=
"PS Driver"
;
di3a
.
pEnvironment
=
NULL
;
/* NULL means auto */
di3a
.
pDriverPath
=
"wineps16"
;
...
...
@@ -2589,7 +2589,13 @@ static BOOL WINSPOOL_GetStringFromReg(HKEY hkey, LPCWSTR ValueName, LPBYTE ptr,
*
needed
=
0
;
return
FALSE
;
}
/* add space for terminating '\0' */
sz
+=
unicode
?
sizeof
(
WCHAR
)
:
1
;
*
needed
=
sz
;
if
(
ptr
)
TRACE
(
"%s: %s
\n
"
,
debugstr_w
(
ValueName
),
unicode
?
debugstr_w
((
LPCWSTR
)
ptr
)
:
debugstr_a
((
LPCSTR
)
ptr
));
return
TRUE
;
}
...
...
@@ -3326,7 +3332,8 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
DWORD
cbBuf
,
/* size of string buffer */
LPDWORD
pcbNeeded
,
/* space needed for str. */
BOOL
unicode
)
/* type of strings */
{
DWORD
dw
,
size
,
tmp
,
type
;
{
DWORD
size
,
tmp
;
HKEY
hkeyDriver
;
LPBYTE
strPtr
=
pDriverStrings
;
...
...
@@ -3351,7 +3358,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
return
TRUE
;
}
else
{
if
(
ptr
)
((
PDRIVER_INFO_
3
W
)
ptr
)
->
pName
=
(
LPWSTR
)
strPtr
;
((
PDRIVER_INFO_
2
W
)
ptr
)
->
pName
=
(
LPWSTR
)
strPtr
;
strPtr
=
(
pDriverStrings
)
?
(
pDriverStrings
+
(
*
pcbNeeded
))
:
NULL
;
}
...
...
@@ -3361,12 +3368,8 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
return
FALSE
;
}
size
=
sizeof
(
dw
);
if
(
RegQueryValueExA
(
hkeyDriver
,
"Version"
,
0
,
&
type
,
(
PBYTE
)
&
dw
,
&
size
)
!=
ERROR_SUCCESS
)
WARN
(
"Can't get Version
\n
"
);
else
if
(
ptr
)
((
PDRIVER_INFO_3A
)
ptr
)
->
cVersion
=
dw
;
if
(
ptr
)
((
PDRIVER_INFO_2A
)
ptr
)
->
cVersion
=
(
GetVersion
()
&
0x80000000
)
?
0
:
3
;
/* FIXME: add 1, 2 */
if
(
!
pEnvironment
)
pEnvironment
=
(
LPWSTR
)
DefaultEnvironmentW
;
...
...
@@ -3383,7 +3386,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
WideCharToMultiByte
(
CP_ACP
,
0
,
pEnvironment
,
-
1
,
(
LPSTR
)
strPtr
,
size
,
NULL
,
NULL
);
if
(
ptr
)
((
PDRIVER_INFO_
3
W
)
ptr
)
->
pEnvironment
=
(
LPWSTR
)
strPtr
;
((
PDRIVER_INFO_
2
W
)
ptr
)
->
pEnvironment
=
(
LPWSTR
)
strPtr
;
strPtr
=
(
pDriverStrings
)
?
(
pDriverStrings
+
(
*
pcbNeeded
))
:
NULL
;
}
...
...
@@ -3394,7 +3397,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
DriverW
,
strPtr
,
size
,
&
tmp
,
unicode
);
if
(
ptr
)
((
PDRIVER_INFO_
3
W
)
ptr
)
->
pDriverPath
=
(
LPWSTR
)
strPtr
;
((
PDRIVER_INFO_
2
W
)
ptr
)
->
pDriverPath
=
(
LPWSTR
)
strPtr
;
strPtr
=
(
pDriverStrings
)
?
(
pDriverStrings
+
(
*
pcbNeeded
))
:
NULL
;
}
...
...
@@ -3405,7 +3408,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
Data_FileW
,
strPtr
,
size
,
&
tmp
,
unicode
);
if
(
ptr
)
((
PDRIVER_INFO_
3
W
)
ptr
)
->
pDataFile
=
(
LPWSTR
)
strPtr
;
((
PDRIVER_INFO_
2
W
)
ptr
)
->
pDataFile
=
(
LPWSTR
)
strPtr
;
strPtr
=
(
pDriverStrings
)
?
pDriverStrings
+
(
*
pcbNeeded
)
:
NULL
;
}
...
...
@@ -3416,7 +3419,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
Configuration_FileW
,
strPtr
,
size
,
&
tmp
,
unicode
);
if
(
ptr
)
((
PDRIVER_INFO_
3
W
)
ptr
)
->
pConfigFile
=
(
LPWSTR
)
strPtr
;
((
PDRIVER_INFO_
2
W
)
ptr
)
->
pConfigFile
=
(
LPWSTR
)
strPtr
;
strPtr
=
(
pDriverStrings
)
?
pDriverStrings
+
(
*
pcbNeeded
)
:
NULL
;
}
...
...
@@ -3426,7 +3429,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
return
TRUE
;
}
if
(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
Help_FileW
,
strPtr
,
0
,
&
size
,
if
(
Level
!=
5
&&
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
Help_FileW
,
strPtr
,
0
,
&
size
,
unicode
))
{
*
pcbNeeded
+=
size
;
if
(
*
pcbNeeded
<=
cbBuf
)
...
...
@@ -3437,7 +3440,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
strPtr
=
(
pDriverStrings
)
?
pDriverStrings
+
(
*
pcbNeeded
)
:
NULL
;
}
if
(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
Dependent_FilesW
,
strPtr
,
0
,
if
(
Level
!=
5
&&
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
Dependent_FilesW
,
strPtr
,
0
,
&
size
,
unicode
))
{
*
pcbNeeded
+=
size
;
if
(
*
pcbNeeded
<=
cbBuf
)
...
...
@@ -3448,7 +3451,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
strPtr
=
(
pDriverStrings
)
?
pDriverStrings
+
(
*
pcbNeeded
)
:
NULL
;
}
if
(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
MonitorW
,
strPtr
,
0
,
&
size
,
if
(
Level
!=
5
&&
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
MonitorW
,
strPtr
,
0
,
&
size
,
unicode
))
{
*
pcbNeeded
+=
size
;
if
(
*
pcbNeeded
<=
cbBuf
)
...
...
@@ -3459,7 +3462,7 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
strPtr
=
(
pDriverStrings
)
?
pDriverStrings
+
(
*
pcbNeeded
)
:
NULL
;
}
if
(
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
DatatypeW
,
strPtr
,
0
,
&
size
,
if
(
Level
!=
5
&&
WINSPOOL_GetStringFromReg
(
hkeyDriver
,
DatatypeW
,
strPtr
,
0
,
&
size
,
unicode
))
{
*
pcbNeeded
+=
size
;
if
(
*
pcbNeeded
<=
cbBuf
)
...
...
@@ -3498,7 +3501,7 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPWSTR pEnvironment,
SetLastError
(
ERROR_INVALID_HANDLE
);
return
FALSE
;
}
if
(
Level
<
1
||
Level
>
3
)
{
if
(
Level
<
1
||
Level
>
6
)
{
SetLastError
(
ERROR_INVALID_LEVEL
);
return
FALSE
;
}
...
...
@@ -3541,6 +3544,15 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPWSTR pEnvironment,
case
3
:
size
=
sizeof
(
DRIVER_INFO_3W
);
break
;
case
4
:
size
=
sizeof
(
DRIVER_INFO_4W
);
break
;
case
5
:
size
=
sizeof
(
DRIVER_INFO_5W
);
break
;
case
6
:
size
=
sizeof
(
DRIVER_INFO_6W
);
break
;
default:
ERR
(
"Invalid level
\n
"
);
return
FALSE
;
...
...
dlls/winspool/tests/info.c
View file @
b13c498c
/*
* Copyright (C) 2003, 2004 Stefan Leichter
* Copyright (C) 2005, 2006 Detlef Riekenberg
* Copyright (C) 2006 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -911,6 +912,92 @@ static void test_SetDefaultPrinter(void)
}
static
void
test_GetPrinterDriver
(
void
)
{
LPSTR
default_printer
;
HANDLE
hprn
;
BOOL
ret
;
BYTE
*
buf
;
INT
level
;
DWORD
needed
,
filled
;
default_printer
=
find_default_printer
();
if
(
!
default_printer
)
{
trace
(
"There is no default printer installed, skiping the test
\n
"
);
return
;
}
hprn
=
0
;
ret
=
OpenPrinter
(
default_printer
,
&
hprn
,
NULL
);
if
(
!
ret
)
{
trace
(
"There is no printers installed, skiping the test
\n
"
);
return
;
}
ok
(
hprn
!=
0
,
"wrong hprn %p
\n
"
,
hprn
);
for
(
level
=
-
1
;
level
<=
7
;
level
++
)
{
SetLastError
(
0xdeadbeef
);
needed
=
(
DWORD
)
-
1
;
ret
=
GetPrinterDriver
(
hprn
,
NULL
,
level
,
NULL
,
0
,
&
needed
);
ok
(
!
ret
,
"level %d: GetPrinterDriver should fail
\n
"
,
level
);
if
(
level
>=
1
&&
level
<=
6
)
{
ok
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
,
"wrong error %ld
\n
"
,
GetLastError
());
ok
(
needed
>
0
,
"not expected needed buffer size %ld
\n
"
,
needed
);
}
else
{
ok
(
GetLastError
()
==
ERROR_INVALID_LEVEL
,
"wrong error %ld
\n
"
,
GetLastError
());
ok
(
needed
==
(
DWORD
)
-
1
,
"not expected needed buffer size %ld
\n
"
,
needed
);
continue
;
}
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
needed
);
SetLastError
(
0xdeadbeef
);
filled
=
-
1
;
ret
=
GetPrinterDriver
(
hprn
,
NULL
,
level
,
buf
,
needed
,
&
filled
);
ok
(
ret
,
"level %d: GetPrinterDriver error %ld
\n
"
,
level
,
GetLastError
());
ok
(
needed
==
filled
,
"needed %ld != filled %ld
\n
"
,
needed
,
filled
);
if
(
level
==
2
)
{
DRIVER_INFO_2
*
di_2
=
(
DRIVER_INFO_2
*
)
buf
;
DWORD
calculated
=
sizeof
(
*
di_2
);
ok
(
di_2
->
cVersion
>=
0
&&
di_2
->
cVersion
<=
3
,
"di_2->cVersion = %ld
\n
"
,
di_2
->
cVersion
);
ok
(
di_2
->
pName
!=
NULL
,
"not expected NULL ptr
\n
"
);
ok
(
di_2
->
pEnvironment
!=
NULL
,
"not expected NULL ptr
\n
"
);
ok
(
di_2
->
pDriverPath
!=
NULL
,
"not expected NULL ptr
\n
"
);
ok
(
di_2
->
pDataFile
!=
NULL
,
"not expected NULL ptr
\n
"
);
ok
(
di_2
->
pConfigFile
!=
NULL
,
"not expected NULL ptr
\n
"
);
trace
(
"cVersion %ld
\n
"
,
di_2
->
cVersion
);
trace
(
"pName %s
\n
"
,
di_2
->
pName
);
calculated
+=
strlen
(
di_2
->
pName
)
+
1
;
trace
(
"pEnvironment %s
\n
"
,
di_2
->
pEnvironment
);
calculated
+=
strlen
(
di_2
->
pEnvironment
)
+
1
;
trace
(
"pDriverPath %s
\n
"
,
di_2
->
pDriverPath
);
calculated
+=
strlen
(
di_2
->
pDriverPath
)
+
1
;
trace
(
"pDataFile %s
\n
"
,
di_2
->
pDataFile
);
calculated
+=
strlen
(
di_2
->
pDataFile
)
+
1
;
trace
(
"pConfigFile %s
\n
"
,
di_2
->
pConfigFile
);
calculated
+=
strlen
(
di_2
->
pConfigFile
)
+
1
;
/* XP allocates memory for both ANSI and unicode names */
ok
(
filled
>=
calculated
,
"calculated %ld != filled %ld
\n
"
,
calculated
,
filled
);
}
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
}
SetLastError
(
0xdeadbeef
);
ret
=
ClosePrinter
(
hprn
);
ok
(
ret
,
"ClosePrinter error %ld
\n
"
,
GetLastError
());
}
START_TEST
(
info
)
{
...
...
@@ -925,5 +1012,6 @@ START_TEST(info)
test_GetDefaultPrinter
();
test_GetPrinterDriverDirectory
();
test_OpenPrinter
();
test_GetPrinterDriver
();
test_SetDefaultPrinter
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment