ReactOS 0.4.16-dev-199-g898cc56
printerdrivers.c File Reference
#include "precomp.h"
Include dependency graph for printerdrivers.c:

Go to the source code of this file.

Functions

BOOL WINAPI AddPrinterDriverExW (PWSTR pName, DWORD Level, PBYTE pDriverInfo, DWORD dwFileCopyFlags)
 
BOOL WINAPI AddPrinterDriverW (PWSTR pName, DWORD Level, PBYTE pDriverInfo)
 
BOOL WINAPI DeletePrinterDriverExW (PWSTR pName, PWSTR pEnvironment, PWSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)
 
BOOL WINAPI DeletePrinterDriverW (PWSTR pName, PWSTR pEnvironment, PWSTR pDriverName)
 
BOOL WINAPI EnumPrinterDriversW (PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
BOOL WINAPI GetPrinterDriverW (HANDLE hPrinter, PWSTR pEnvironment, DWORD Level, PBYTE pDriverInfo, DWORD cbBuf, PDWORD pcbNeeded)
 
BOOL WINAPI GetPrinterDriverExW (HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, PDWORD pdwServerMajorVersion, PDWORD pdwServerMinorVersion)
 
BOOL WINAPI GetPrinterDriverDirectoryW (PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pDriverDirectory, DWORD cbBuf, PDWORD pcbNeeded)
 

Function Documentation

◆ AddPrinterDriverExW()

BOOL WINAPI AddPrinterDriverExW ( PWSTR  pName,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  dwFileCopyFlags 
)

Definition at line 11 of file printerdrivers.c.

12{
13 BOOL bReturnValue;
16 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
17
18 // Loop through all Print Providers.
20 {
22
23 bReturnValue = pPrintProvider->PrintProvider.fpAddPrinterDriverEx(pName, Level, pDriverInfo, dwFileCopyFlags);
24
25 if (bReturnValue == ROUTER_SUCCESS)
26 {
27 dwErrorCode = ERROR_SUCCESS;
28 goto Cleanup;
29 }
30 else if (bReturnValue == ROUTER_STOP_ROUTING)
31 {
32 ERR("A Print Provider returned ROUTER_STOP_ROUTING for Printer \"%S\"!\n", pName);
33 dwErrorCode = GetLastError();
34 goto Cleanup;
35 }
36 }
37
39 // ERROR_INVALID_NAME by the Print Provider is translated to ERROR_INVALID_PRINTER_NAME here, but not in other APIs as far as I know.
40 if (dwErrorCode == ERROR_INVALID_NAME)
41 dwErrorCode = ERROR_INVALID_PRINTER_NAME;
42
43 SetLastError(dwErrorCode);
44 return (dwErrorCode == ERROR_SUCCESS);
45}
#define ERR(fmt,...)
Definition: precomp.h:57
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_NAME
Definition: compat.h:103
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
static LPSTR pName
Definition: security.c:75
#define ROUTER_STOP_ROUTING
Definition: winsplp.h:42
#define ROUTER_SUCCESS
Definition: winsplp.h:41
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PRINTPROVIDOR PrintProvider
Definition: precomp.h:36
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
LIST_ENTRY PrintProviderList
Definition: main.c:12
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INVALID_PRINTER_NAME
Definition: winerror.h:1108
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56

Referenced by _RpcAddPrinterDriverEx(), AddPrinterDriverExA(), and AddPrinterDriverW().

◆ AddPrinterDriverW()

BOOL WINAPI AddPrinterDriverW ( PWSTR  pName,
DWORD  Level,
PBYTE  pDriverInfo 
)

Definition at line 48 of file printerdrivers.c.

49{
50 TRACE("AddPrinterDriverW(%S, %lu, %p)\n", pName, Level, pDriverInfo);
52}
BOOL WINAPI AddPrinterDriverExW(PWSTR pName, DWORD Level, PBYTE pDriverInfo, DWORD dwFileCopyFlags)
#define TRACE(s)
Definition: solgame.cpp:4
#define APD_COPY_NEW_FILES
Definition: winspool.h:606

Referenced by _RpcAddPrinterDriver().

◆ DeletePrinterDriverExW()

BOOL WINAPI DeletePrinterDriverExW ( PWSTR  pName,
PWSTR  pEnvironment,
PWSTR  pDriverName,
DWORD  dwDeleteFlag,
DWORD  dwVersionFlag 
)

Definition at line 55 of file printerdrivers.c.

56{
57 BOOL bReturnValue;
60 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
61
62 // Loop through all Print Providers.
64 {
66
67 bReturnValue = pPrintProvider->PrintProvider.fpDeletePrinterDriverEx(pName, pEnvironment, pDriverName, dwDeleteFlag, dwVersionFlag);
68
69 if (bReturnValue == ROUTER_SUCCESS)
70 {
71 dwErrorCode = ERROR_SUCCESS;
72 goto Cleanup;
73 }
74 else if (bReturnValue == ROUTER_STOP_ROUTING)
75 {
76 ERR("A Print Provider returned ROUTER_STOP_ROUTING for Printer \"%S\"!\n", pName);
77 dwErrorCode = GetLastError();
78 goto Cleanup;
79 }
80 }
81
83 // ERROR_INVALID_NAME by the Print Provider is translated to ERROR_INVALID_PRINTER_NAME here, but not in other APIs as far as I know.
84 if (dwErrorCode == ERROR_INVALID_NAME)
85 dwErrorCode = ERROR_INVALID_PRINTER_NAME;
86
87 SetLastError(dwErrorCode);
88 return (dwErrorCode == ERROR_SUCCESS);
89}

Referenced by _RpcDeletePrinterDriverEx(), DeletePrinterDriverExA(), and DeletePrinterDriverW().

◆ DeletePrinterDriverW()

BOOL WINAPI DeletePrinterDriverW ( PWSTR  pName,
PWSTR  pEnvironment,
PWSTR  pDriverName 
)

Definition at line 92 of file printerdrivers.c.

93{
94 TRACE("DeletePrinterDriverW(%S, %S, %S)\n", pName, pEnvironment, pDriverName);
95 return DeletePrinterDriverExW(pName, pEnvironment, pDriverName, 0, 0);
96}
BOOL WINAPI DeletePrinterDriverExW(PWSTR pName, PWSTR pEnvironment, PWSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionFlag)

Referenced by _RpcDeletePrinterDriver().

◆ EnumPrinterDriversW()

BOOL WINAPI EnumPrinterDriversW ( PWSTR  pName,
PWSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 99 of file printerdrivers.c.

100{
101 DWORD cbCallBuffer;
102 DWORD cbNeeded;
103 DWORD dwErrorCode = MAXDWORD;
104 DWORD dwReturned;
105 PBYTE pCallBuffer;
106 BOOL Ret = FALSE;
107 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
109
110 // Begin counting.
111 *pcbNeeded = 0;
112 *pcReturned = 0;
113
114 if ( cbBuf && !pDriverInfo )
115 {
116 dwErrorCode = ERROR_INVALID_USER_BUFFER;
117 goto Cleanup;
118 }
119
120 // At the beginning, we have the full buffer available.
121 cbCallBuffer = cbBuf;
122 pCallBuffer = pDriverInfo;
123
124 // Loop through all Print Providers.
126 {
128
129 // Call the EnumPrinters function of this Print Provider.
130 cbNeeded = 0;
131 dwReturned = 0;
132
133 Ret = pPrintProvider->PrintProvider.fpEnumPrinterDrivers( pName, pEnvironment, Level, pCallBuffer, cbCallBuffer, &cbNeeded, &dwReturned);
134
135 if ( !Ret )
136 {
137 dwErrorCode = GetLastError();
138 }
139
140 // Add the returned counts to the total values.
141 *pcbNeeded += cbNeeded;
142 *pcReturned += dwReturned;
143
144 // Reduce the available buffer size for the next call without risking an underflow.
145 if (cbNeeded < cbCallBuffer)
146 cbCallBuffer -= cbNeeded;
147 else
148 cbCallBuffer = 0;
149
150 // Advance the buffer if the caller provided it.
151 if (pCallBuffer)
152 pCallBuffer += cbNeeded;
153
154 // dwErrorCode shall not be overwritten if a previous EnumPrinters call already succeeded.
155 if (dwErrorCode != ERROR_SUCCESS)
156 dwErrorCode = GetLastError();
157 }
158
159Cleanup:
160 SetLastError(dwErrorCode);
161 return (dwErrorCode == ERROR_SUCCESS);
162}
#define FALSE
Definition: types.h:117
#define MAXDWORD
BYTE * PBYTE
Definition: pedump.c:66
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091

Referenced by _RpcEnumPrinterDrivers(), and EnumPrinterDriversA().

◆ GetPrinterDriverDirectoryW()

BOOL WINAPI GetPrinterDriverDirectoryW ( PWSTR  pName,
PWSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverDirectory,
DWORD  cbBuf,
PDWORD  pcbNeeded 
)

Definition at line 214 of file printerdrivers.c.

215{
216 BOOL bReturnValue;
217 DWORD dwErrorCode = ERROR_INVALID_PRINTER_NAME;
219 PSPOOLSS_PRINT_PROVIDER pPrintProvider;
220
221 if ( cbBuf && !pDriverDirectory )
222 {
224 return FALSE;
225 }
226
227 // Loop through all Print Providers.
229 {
231
232 bReturnValue = pPrintProvider->PrintProvider.fpGetPrinterDriverDirectory(pName, pEnvironment, Level, pDriverDirectory, cbBuf, pcbNeeded);
233
234 if (bReturnValue == ROUTER_SUCCESS)
235 {
236 dwErrorCode = ERROR_SUCCESS;
237 goto Cleanup;
238 }
239 else if (bReturnValue == ROUTER_STOP_ROUTING)
240 {
241 ERR("A Print Provider returned ROUTER_STOP_ROUTING for Printer \"%S\"!\n", pName);
242 dwErrorCode = GetLastError();
243 goto Cleanup;
244 }
245 }
246
247Cleanup:
248 // ERROR_INVALID_NAME by the Print Provider is translated to ERROR_INVALID_PRINTER_NAME here, but not in other APIs as far as I know.
249 if (dwErrorCode == ERROR_INVALID_NAME)
250 dwErrorCode = ERROR_INVALID_PRINTER_NAME;
251
252 SetLastError(dwErrorCode);
253 return (dwErrorCode == ERROR_SUCCESS);
254}

Referenced by _RpcGetPrinterDriverDirectory(), and GetPrinterDriverDirectoryA().

◆ GetPrinterDriverExW()

BOOL WINAPI GetPrinterDriverExW ( HANDLE  hPrinter,
LPWSTR  pEnvironment,
DWORD  Level,
LPBYTE  pDriverInfo,
DWORD  cbBuf,
LPDWORD  pcbNeeded,
DWORD  dwClientMajorVersion,
DWORD  dwClientMinorVersion,
PDWORD  pdwServerMajorVersion,
PDWORD  pdwServerMinorVersion 
)

Definition at line 181 of file printerdrivers.c.

192{
194
195 FIXME("GetPrinterDriverExW(%p, %lu, %lu, %p, %lu, %p, %lu, %lu, %p, %p)\n", hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded, dwClientMajorVersion, dwClientMinorVersion, pdwServerMajorVersion, pdwServerMinorVersion);
196
197 // Sanity checks.
198 if (!pHandle)
199 {
201 return FALSE;
202 }
203
204 if ( cbBuf && !pDriverInfo )
205 {
207 return FALSE;
208 }
209
210 return pHandle->pPrintProvider->PrintProvider.fpGetPrinterDriverEx(pHandle->hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded, dwClientMajorVersion, dwClientMinorVersion, pdwServerMajorVersion, pdwServerMinorVersion);
211}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PSPOOLSS_PRINT_PROVIDER pPrintProvider
Definition: precomp.h:46
struct _SPOOLSS_PRINTER_HANDLE * PSPOOLSS_PRINTER_HANDLE

Referenced by _RpcGetPrinterDriver2(), and YGetPrinterDriver2().

◆ GetPrinterDriverW()

BOOL WINAPI GetPrinterDriverW ( HANDLE  hPrinter,
PWSTR  pEnvironment,
DWORD  Level,
PBYTE  pDriverInfo,
DWORD  cbBuf,
PDWORD  pcbNeeded 
)

Definition at line 165 of file printerdrivers.c.

166{
168
169 // Sanity checks.
170 if (!pHandle)
171 {
173 return FALSE;
174 }
175
176 return pHandle->pPrintProvider->PrintProvider.fpGetPrinterDriver(pHandle->hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded);
177}

Referenced by _RpcGetPrinterDriver(), and GetPrinterDriverA().