ReactOS 0.4.16-dev-297-gc569aee
main.c File Reference
#include "precomp.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

ClosePrintProcessor

Closes a Print Processor Handle that has previously been opened through OpenPrintProcessor.

Parameters
hPrintProcessorThe return value of a previous successful OpenPrintProcessor call.
Returns
TRUE if the Print Processor Handle was successfully closed, FALSE otherwise. A more specific error code can be obtained through GetLastError.
BOOL WINAPI ClosePrintProcessor (HANDLE hPrintProcessor)
 
BOOL WINAPI ControlPrintProcessor (HANDLE hPrintProcessor, DWORD Command)
 
EnumPrintProcessorDatatypesW

Obtains an array of all datatypes supported by this Print Processor.

Parameters
pNameServer Name. Ignored here, because every caller of EnumPrintProcessorDatatypesW is interested in this Print Processor's information.
pPrintProcessorNamePrint Processor Name. Ignored here, because every caller of EnumPrintProcessorDatatypesW is interested in this Print Processor's information.
LevelThe level of the structure supplied through pDatatypes. This must be 1.
pDatatypesPointer to the buffer that receives an array of DATATYPES_INFO_1W structures. Can be NULL if you just want to know the required size of the buffer.
cbBufSize of the buffer you supplied for pDatatypes, in bytes.
pcbNeededPointer to a variable that receives the required size of the buffer for pDatatypes, in bytes. This parameter mustn't be NULL!
pcReturnedPointer to a variable that receives the number of elements of the DATATYPES_INFO_1W array. This parameter mustn't be NULL!
Returns
TRUE if we successfully copied the array into pDatatypes, FALSE otherwise. A more specific error code can be obtained through GetLastError.
BOOL WINAPI EnumPrintProcessorDatatypesW (PWSTR pName, PWSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 
DWORD WINAPI GetPrintProcessorCapabilities (PWSTR pValueName, DWORD dwAttributes, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
 
OpenPrintProcessor

Prepares this Print Processor for processing a document.

Parameters
pPrinterNameString in the format "\\COMPUTERNAME\Port:, Port" that is passed to OpenPrinterW for writing to the Print Monitor on the specified port.
pPrintProcessorOpenDataPointer to a PRINTPROCESSOROPENDATA structure containing details about the print job to be processed.
Returns
A Print Processor handle on success or NULL in case of a failure. This handle has to be passed to PrintDocumentOnPrintProcessor to do the actual processing. A more specific error code can be obtained through GetLastError.
HANDLE WINAPI OpenPrintProcessor (PWSTR pPrinterName, PPRINTPROCESSOROPENDATA pPrintProcessorOpenData)
 
PrintDocumentOnPrintProcessor

Prints a document on this Print Processor after a handle for the document has been opened through OpenPrintProcessor.

Parameters
hPrintProcessorThe return value of a previous successful OpenPrintProcessor call.
pDocumentNameString in the format "Printer, Job N" describing the spooled job that is to be processed.
Returns
TRUE if the document was successfully processed by this Print Processor, FALSE otherwise. A more specific error code can be obtained through GetLastError.
BOOL WINAPI PrintDocumentOnPrintProcessor (HANDLE hPrintProcessor, PWSTR pDocumentName)
 

Variables

static PCWSTR _pwszDatatypes []
 

Function Documentation

◆ ClosePrintProcessor()

BOOL WINAPI ClosePrintProcessor ( HANDLE  hPrintProcessor)

Definition at line 30 of file main.c.

31{
32 DWORD dwErrorCode;
33 PWINPRINT_HANDLE pHandle;
34
35 TRACE("ClosePrintProcessor(%p)\n", hPrintProcessor);
36
37 // Sanity checks
38 if (!hPrintProcessor)
39 {
40 dwErrorCode = ERROR_INVALID_HANDLE;
41 goto Cleanup;
42 }
43
44 pHandle = (PWINPRINT_HANDLE)hPrintProcessor;
45
46 // Free all structure fields for which memory has been allocated.
47 if (pHandle->pwszDatatype)
49
50 if (pHandle->pwszDocumentName)
52
53 if (pHandle->pwszOutputFile)
55
56 if (pHandle->pwszPrinterPort)
58
59 // Finally free the WINSPOOL_HANDLE structure itself.
60 DllFreeSplMem(pHandle);
61 dwErrorCode = ERROR_SUCCESS;
62
64 SetLastError(dwErrorCode);
65 return (dwErrorCode == ERROR_SUCCESS);
66}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TRACE(s)
Definition: solgame.cpp:4
PWSTR pwszOutputFile
Definition: precomp.h:32
PWSTR pwszPrinterPort
Definition: precomp.h:33
PWSTR pwszDocumentName
Definition: precomp.h:31
PWSTR pwszDatatype
Definition: precomp.h:30
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
BOOL WINAPI DllFreeSplStr(PWSTR pwszString)
Definition: memory.c:130
struct _WINPRINT_HANDLE * PWINPRINT_HANDLE

◆ ControlPrintProcessor()

BOOL WINAPI ControlPrintProcessor ( HANDLE  hPrintProcessor,
DWORD  Command 
)

Definition at line 69 of file main.c.

70{
71 TRACE("ControlPrintProcessor(%p, %lu)\n", hPrintProcessor, Command);
72
74 return FALSE;
75}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define FALSE
Definition: types.h:117
Definition: shell.h:41

◆ EnumPrintProcessorDatatypesW()

BOOL WINAPI EnumPrintProcessorDatatypesW ( PWSTR  pName,
PWSTR  pPrintProcessorName,
DWORD  Level,
PBYTE  pDatatypes,
DWORD  cbBuf,
PDWORD  pcbNeeded,
PDWORD  pcReturned 
)

Definition at line 111 of file main.c.

112{
113 DWORD cbDatatype;
114 DWORD dwDatatypeCount = 0;
115 DWORD dwOffsets[_countof(_pwszDatatypes)];
116 PCWSTR* pCurrentDatatype;
117 PDWORD pCurrentOffset = dwOffsets;
118
119 TRACE("EnumPrintProcessorDatatypesW(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);
120
121 // Sanity checks
122 if (Level != 1 || !pcbNeeded || !pcReturned)
123 return FALSE;
124
125 // Count the required buffer size and the number of datatypes.
126 *pcbNeeded = 0;
127 *pcReturned = 0;
128
129 for (pCurrentDatatype = _pwszDatatypes; *pCurrentDatatype; pCurrentDatatype++)
130 {
131 cbDatatype = (wcslen(*pCurrentDatatype) + 1) * sizeof(WCHAR);
132 *pcbNeeded += sizeof(DATATYPES_INFO_1W) + cbDatatype;
133
134 // Also calculate the offset in the output buffer of the pointer to this datatype string.
135 *pCurrentOffset = dwDatatypeCount * sizeof(DATATYPES_INFO_1W) + FIELD_OFFSET(DATATYPES_INFO_1W, pName);
136
137 dwDatatypeCount++;
138 pCurrentOffset++;
139 }
140
141 // Check if the supplied buffer is large enough.
142 if (cbBuf < *pcbNeeded)
143 {
145 return FALSE;
146 }
147
148 // Check if a buffer was supplied at all.
149 if (!pDatatypes)
150 {
152 return FALSE;
153 }
154
155 // Copy over all datatypes.
156 *pCurrentOffset = MAXDWORD;
157 PackStrings(_pwszDatatypes, pDatatypes, dwOffsets, &pDatatypes[*pcbNeeded]);
158
159 *pcReturned = dwDatatypeCount;
160 return TRUE;
161}
PBYTE WINAPI PackStrings(PCWSTR *pSource, PBYTE pDest, const DWORD *DestOffsets, PBYTE pEnd)
Definition: tools.c:39
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static LPSTR pName
Definition: security.c:75
#define MAXDWORD
DWORD * PDWORD
Definition: pedump.c:68
#define _countof(array)
Definition: sndvol32.h:70
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
static PCWSTR _pwszDatatypes[]
Definition: main.c:11
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
struct _DATATYPES_INFO_1W DATATYPES_INFO_1W
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ GetPrintProcessorCapabilities()

DWORD WINAPI GetPrintProcessorCapabilities ( PWSTR  pValueName,
DWORD  dwAttributes,
PBYTE  pData,
DWORD  nSize,
PDWORD  pcbNeeded 
)

Definition at line 165 of file main.c.

166{
167 TRACE("GetPrintProcessorCapabilities(%S, %lu, %p, %lu, %p)\n", pValueName, dwAttributes, pData, nSize, pcbNeeded);
168
170 return 0;
171}
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
DWORD dwAttributes
Definition: vdmdbg.h:34
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2109

◆ OpenPrintProcessor()

HANDLE WINAPI OpenPrintProcessor ( PWSTR  pPrinterName,
PPRINTPROCESSOROPENDATA  pPrintProcessorOpenData 
)

Definition at line 189 of file main.c.

190{
191 DWORD dwErrorCode;
192 HANDLE hReturnValue = NULL;
193 PWINPRINT_HANDLE pHandle = NULL;
194
195 TRACE("OpenPrintProcessor(%S, %p)\n", pPrinterName, pPrintProcessorOpenData);
196
197 // Sanity checks
198 // This time a datatype needs to be given. We can't fall back to a default here.
199 if (!pPrintProcessorOpenData || !pPrintProcessorOpenData->pDatatype || !*pPrintProcessorOpenData->pDatatype)
200 {
201 dwErrorCode = ERROR_INVALID_PARAMETER;
202 goto Cleanup;
203 }
204
205 // Create a new WINPRINT_HANDLE structure and fill the relevant fields.
206 pHandle = DllAllocSplMem(sizeof(WINPRINT_HANDLE));
207
208 // Check what datatype was given.
209 if (_wcsicmp(pPrintProcessorOpenData->pDatatype, L"RAW") == 0)
210 {
211 pHandle->Datatype = RAW;
212 }
213 else
214 {
215 dwErrorCode = ERROR_INVALID_DATATYPE;
216 goto Cleanup;
217 }
218
219 // Fill the relevant fields.
220 pHandle->dwJobID = pPrintProcessorOpenData->JobId;
221 pHandle->pwszDatatype = AllocSplStr(pPrintProcessorOpenData->pDatatype);
222 pHandle->pwszDocumentName = AllocSplStr(pPrintProcessorOpenData->pDocumentName);
223 pHandle->pwszOutputFile = AllocSplStr(pPrintProcessorOpenData->pOutputFile);
224 pHandle->pwszPrinterPort = AllocSplStr(pPrinterName);
225
226 // We were successful! Return the handle and don't let the cleanup routine free it.
227 dwErrorCode = ERROR_SUCCESS;
228 hReturnValue = pHandle;
229 pHandle = NULL;
230
231Cleanup:
232 if (pHandle)
233 DllFreeSplMem(pHandle);
234
235 SetLastError(dwErrorCode);
236 return hReturnValue;
237}
#define NULL
Definition: types.h:112
#define RAW(x)
Definition: genincdata.c:42
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
enum _WINPRINT_HANDLE::@5124 Datatype
DWORD dwJobID
Definition: precomp.h:29
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
PWSTR WINAPI AllocSplStr(PCWSTR pwszInput)
Definition: memory.c:56
#define ERROR_INVALID_DATATYPE
Definition: winerror.h:1111

◆ PrintDocumentOnPrintProcessor()

BOOL WINAPI PrintDocumentOnPrintProcessor ( HANDLE  hPrintProcessor,
PWSTR  pDocumentName 
)

Definition at line 255 of file main.c.

256{
257 DWORD dwErrorCode;
258 PWINPRINT_HANDLE pHandle;
259
260 TRACE("PrintDocumentOnPrintProcessor(%p, %S)\n", hPrintProcessor, pDocumentName);
261
262 // Sanity checks
263 if (!hPrintProcessor)
264 {
265 dwErrorCode = ERROR_INVALID_HANDLE;
266 goto Cleanup;
267 }
268
269 pHandle = (PWINPRINT_HANDLE)hPrintProcessor;
270
271 // Call the corresponding Print function for the datatype.
272 if (pHandle->Datatype == RAW)
273 dwErrorCode = PrintRawJob(pHandle, pDocumentName);
274
275Cleanup:
276 SetLastError(dwErrorCode);
277 return (dwErrorCode == ERROR_SUCCESS);
278}
DWORD PrintRawJob(PWINPRINT_HANDLE pHandle, PWSTR pwszPrinterAndJob)
Definition: raw.c:23

Variable Documentation

◆ _pwszDatatypes

PCWSTR _pwszDatatypes[]
static
Initial value:
= {
L"RAW",
0
}

Definition at line 11 of file main.c.

Referenced by EnumPrintProcessorDatatypesW().