Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
0987ae04
Commit
0987ae04
authored
Feb 12, 2003
by
Duane Clark
Committed by
Alexandre Julliard
Feb 12, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Winspool expects NULLs to be preserved in ascii to unicode
conversions.
parent
39f73a22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
41 deletions
+69
-41
info.c
dlls/winspool/info.c
+69
-41
No files found.
dlls/winspool/info.c
View file @
0987ae04
...
...
@@ -104,6 +104,21 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPWSTR pEnvironment,
DWORD
Level
,
LPBYTE
pDriverInfo
,
DWORD
cbBuf
,
LPDWORD
pcbNeeded
,
BOOL
unicode
);
/* RtlCreateUnicodeStringFromAsciiz will return an empty string in the buffer
if passed a NULL string. This returns NULLs to the result.
*/
static
inline
PWSTR
asciitounicode
(
UNICODE_STRING
*
usBufferPtr
,
LPCSTR
src
)
{
if
(
(
src
)
)
{
RtlCreateUnicodeStringFromAsciiz
(
usBufferPtr
,
src
);
return
usBufferPtr
->
Buffer
;
}
usBufferPtr
->
Buffer
=
NULL
;
/* so that RtlFreeUnicodeString won't barf */
return
NULL
;
}
static
void
WINSPOOL_SetDefaultPrinter
(
const
char
*
devname
,
const
char
*
name
,
BOOL
force
)
{
char
qbuf
[
200
];
...
...
@@ -157,9 +172,30 @@ CUPS_LoadPrinters(void) {
nrofdests
=
pcupsGetPrinters
(
&
printers
);
for
(
i
=
0
;
i
<
nrofdests
;
i
++
)
{
const
char
*
ppd
=
pcupsGetPPD
(
printers
[
i
])
;
const
char
*
ppd
;
char
*
port
,
*
devline
;
WCHAR
*
pNameW
;
HKEY
hkeyPrinters
,
hkeyPrinter
;
/* First check that the printer doesn't exist already */
pNameW
=
HEAP_strdupAtoW
(
GetProcessHeap
(),
0
,
printers
[
i
]);
if
(
RegCreateKeyA
(
HKEY_LOCAL_MACHINE
,
Printers
,
&
hkeyPrinters
)
==
ERROR_SUCCESS
)
{
if
(
RegOpenKeyW
(
hkeyPrinters
,
pNameW
,
&
hkeyPrinter
)
==
ERROR_SUCCESS
)
{
/* We know this printer already */
RegCloseKey
(
hkeyPrinter
);
RegCloseKey
(
hkeyPrinters
);
HeapFree
(
GetProcessHeap
(),
0
,
pNameW
);
TRACE
(
"Printer %s already known. Skipping detection
\n
"
,
printers
[
i
]);
continue
;
}
RegCloseKey
(
hkeyPrinters
);
}
HeapFree
(
GetProcessHeap
(),
0
,
pNameW
);
/* OK, we haven't seen this one yet. Request PPD for it */
ppd
=
pcupsGetPPD
(
printers
[
i
]);
if
(
!
ppd
)
{
WARN
(
"No ppd file for %s.
\n
"
,
printers
[
i
]);
/* If this was going to be the default printer,
...
...
@@ -554,29 +590,18 @@ static LPPRINTER_INFO_2W PRINTER_INFO_2AtoW(HANDLE heap, LPPRINTER_INFO_2A piA)
piW
=
HeapAlloc
(
heap
,
0
,
sizeof
(
*
piW
));
memcpy
(
piW
,
piA
,
sizeof
(
*
piW
));
/* copy everything first */
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pServerName
);
piW
->
pServerName
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pPrinterName
);
piW
->
pPrinterName
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pShareName
);
piW
->
pShareName
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pPortName
);
piW
->
pPortName
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pDriverName
);
piW
->
pDriverName
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pComment
);
piW
->
pComment
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pLocation
);
piW
->
pLocation
=
usBuffer
.
Buffer
;
piW
->
pServerName
=
asciitounicode
(
&
usBuffer
,
piA
->
pServerName
);
piW
->
pPrinterName
=
asciitounicode
(
&
usBuffer
,
piA
->
pPrinterName
);
piW
->
pShareName
=
asciitounicode
(
&
usBuffer
,
piA
->
pShareName
);
piW
->
pPortName
=
asciitounicode
(
&
usBuffer
,
piA
->
pPortName
);
piW
->
pDriverName
=
asciitounicode
(
&
usBuffer
,
piA
->
pDriverName
);
piW
->
pComment
=
asciitounicode
(
&
usBuffer
,
piA
->
pComment
);
piW
->
pLocation
=
asciitounicode
(
&
usBuffer
,
piA
->
pLocation
);
piW
->
pDevMode
=
DEVMODEdupAtoW
(
heap
,
piA
->
pDevMode
);
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pSepFile
);
piW
->
pSepFile
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pPrintProcessor
);
piW
->
pPrintProcessor
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pDatatype
);
piW
->
pDatatype
=
usBuffer
.
Buffer
;
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
piA
->
pParameters
);
piW
->
pParameters
=
usBuffer
.
Buffer
;
piW
->
pSepFile
=
asciitounicode
(
&
usBuffer
,
piA
->
pSepFile
);
piW
->
pPrintProcessor
=
asciitounicode
(
&
usBuffer
,
piA
->
pPrintProcessor
);
piW
->
pDatatype
=
asciitounicode
(
&
usBuffer
,
piA
->
pDatatype
);
piW
->
pParameters
=
asciitounicode
(
&
usBuffer
,
piA
->
pParameters
);
return
piW
;
}
...
...
@@ -777,19 +802,19 @@ BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter,
UNICODE_STRING
lpPrinterNameW
;
UNICODE_STRING
usBuffer
;
PRINTER_DEFAULTSW
DefaultW
,
*
pDefaultW
=
NULL
;
PWSTR
pwstrPrinterNameW
;
BOOL
ret
;
RtlCreateUnicodeStringFromAsciiz
(
&
lpPrinterNameW
,
lpPrinterName
);
pwstrPrinterNameW
=
asciitounicode
(
&
lpPrinterNameW
,
lpPrinterName
);
if
(
pDefault
)
{
RtlCreateUnicodeStringFromAsciiz
(
&
usBuffer
,
pDefault
->
pDatatype
);
DefaultW
.
pDatatype
=
usBuffer
.
Buffer
;
DefaultW
.
pDatatype
=
asciitounicode
(
&
usBuffer
,
pDefault
->
pDatatype
);
DefaultW
.
pDevMode
=
DEVMODEdupAtoW
(
GetProcessHeap
(),
pDefault
->
pDevMode
);
DefaultW
.
DesiredAccess
=
pDefault
->
DesiredAccess
;
pDefaultW
=
&
DefaultW
;
}
ret
=
OpenPrinterW
(
lpPrinterNameW
.
Buffer
,
phPrinter
,
pDefaultW
);
ret
=
OpenPrinterW
(
pwstrPrinterNameW
,
phPrinter
,
pDefaultW
);
if
(
pDefault
)
{
RtlFreeUnicodeString
(
&
usBuffer
);
HeapFree
(
GetProcessHeap
(),
0
,
DefaultW
.
pDevMode
);
...
...
@@ -1183,6 +1208,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
HANDLE
WINAPI
AddPrinterA
(
LPSTR
pName
,
DWORD
Level
,
LPBYTE
pPrinter
)
{
UNICODE_STRING
pNameW
;
PWSTR
pwstrNameW
;
PRINTER_INFO_2W
*
piW
;
PRINTER_INFO_2A
*
piA
=
(
PRINTER_INFO_2A
*
)
pPrinter
;
HANDLE
ret
;
...
...
@@ -1193,10 +1219,10 @@ HANDLE WINAPI AddPrinterA(LPSTR pName, DWORD Level, LPBYTE pPrinter)
SetLastError
(
ERROR_INVALID_LEVEL
);
return
0
;
}
RtlCreateUnicodeStringFromAsciiz
(
&
pNameW
,
pName
);
pwstrNameW
=
asciitounicode
(
&
pNameW
,
pName
);
piW
=
PRINTER_INFO_2AtoW
(
GetProcessHeap
(),
piA
);
ret
=
AddPrinterW
(
p
NameW
.
Buffer
,
Level
,
(
LPBYTE
)
piW
);
ret
=
AddPrinterW
(
p
wstrNameW
,
Level
,
(
LPBYTE
)
piW
);
FREE_PRINTER_INFO_2W
(
GetProcessHeap
(),
piW
);
RtlFreeUnicodeString
(
&
pNameW
);
...
...
@@ -2166,8 +2192,11 @@ BOOL WINAPI EnumPrintersA(DWORD dwType, LPSTR lpszName,
{
BOOL
ret
;
UNICODE_STRING
lpszNameW
;
PWSTR
pwstrNameW
;
RtlCreateUnicodeStringFromAsciiz
(
&
lpszNameW
,
lpszName
);
ret
=
WINSPOOL_EnumPrinters
(
dwType
,
lpszNameW
.
Buffer
,
dwLevel
,
lpbPrinters
,
cbBuf
,
pwstrNameW
=
asciitounicode
(
&
lpszNameW
,
lpszName
);
ret
=
WINSPOOL_EnumPrinters
(
dwType
,
pwstrNameW
,
dwLevel
,
lpbPrinters
,
cbBuf
,
lpdwNeeded
,
lpdwReturned
,
FALSE
);
RtlFreeUnicodeString
(
&
lpszNameW
);
return
ret
;
...
...
@@ -2440,8 +2469,10 @@ BOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment,
{
BOOL
ret
;
UNICODE_STRING
pEnvW
;
RtlCreateUnicodeStringFromAsciiz
(
&
pEnvW
,
pEnvironment
);
ret
=
WINSPOOL_GetPrinterDriver
(
hPrinter
,
pEnvW
.
Buffer
,
Level
,
pDriverInfo
,
PWSTR
pwstrEnvW
;
pwstrEnvW
=
asciitounicode
(
&
pEnvW
,
pEnvironment
);
ret
=
WINSPOOL_GetPrinterDriver
(
hPrinter
,
pwstrEnvW
,
Level
,
pDriverInfo
,
cbBuf
,
pcbNeeded
,
FALSE
);
RtlFreeUnicodeString
(
&
pEnvW
);
return
ret
;
...
...
@@ -2816,19 +2847,16 @@ BOOL WINAPI EnumPrinterDriversA(LPSTR pName, LPSTR pEnvironment, DWORD Level,
LPDWORD
pcbNeeded
,
LPDWORD
pcReturned
)
{
BOOL
ret
;
UNICODE_STRING
pNameW
,
pEnvironmentW
;
PWSTR
pwstrNameW
,
pwstrEnvironmentW
;
if
(
pName
)
RtlCreateUnicodeStringFromAsciiz
(
&
pNameW
,
pName
);
if
(
pEnvironment
)
RtlCreateUnicodeStringFromAsciiz
(
&
pEnvironmentW
,
pEnvironment
);
pwstrNameW
=
asciitounicode
(
&
pNameW
,
pName
);
pwstrEnvironmentW
=
asciitounicode
(
&
pEnvironmentW
,
pEnvironment
);
ret
=
WINSPOOL_EnumPrinterDrivers
(
p
NameW
.
Buffer
,
pEnvironmentW
.
Buffer
,
ret
=
WINSPOOL_EnumPrinterDrivers
(
p
wstrNameW
,
pwstrEnvironmentW
,
Level
,
pDriverInfo
,
cbBuf
,
pcbNeeded
,
pcReturned
,
FALSE
);
if
(
pName
)
RtlFreeUnicodeString
(
&
pNameW
);
if
(
pEnvironment
)
RtlFreeUnicodeString
(
&
pEnvironmentW
);
RtlFreeUnicodeString
(
&
pNameW
);
RtlFreeUnicodeString
(
&
pEnvironmentW
);
return
ret
;
}
...
...
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