+
+
+DWORD WINAPI
+GetPrintProcessorCapabilities(PWSTR pValueName, DWORD dwAttributes, PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
+{
+ UNIMPLEMENTED;
+ return 0;
+}
+
+/**
+ * @name OpenPrintProcessor
+ *
+ * Prepares this Print Processor for processing a document.
+ *
+ * @param pPrinterName
+ * String in the format "\\COMPUTERNAME\Port:, Port" that is passed to OpenPrinterW for writing to the Print Monitor on the specified port.
+ *
+ * @param pPrintProcessorOpenData
+ * Pointer to a PRINTPROCESSOROPENDATA structure containing details about the print job to be processed.
+ *
+ * @return
+ * 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)
+{
+ DWORD dwErrorCode;
+ HANDLE hReturnValue = NULL;
+ PWINPRINT_HANDLE pHandle = NULL;
+
+ // Sanity checks
+ // This time a datatype needs to be given. We can't fall back to a default here.
+ if (!pPrintProcessorOpenData || !pPrintProcessorOpenData->pDatatype || !*pPrintProcessorOpenData->pDatatype)
+ {
+ dwErrorCode = ERROR_INVALID_PARAMETER;
+ goto Cleanup;
+ }
+
+ // Create a new WINPRINT_HANDLE structure. and fill the relevant fields.
+ pHandle = DllAllocSplMem(sizeof(WINPRINT_HANDLE));
+
+ // Check what datatype was given.
+ if (wcsicmp(pPrintProcessorOpenData->pDatatype, L"RAW") == 0)
+ {
+ pHandle->Datatype = RAW;
+ }
+ else
+ {
+ dwErrorCode = ERROR_INVALID_DATATYPE;
+ goto Cleanup;
+ }
+
+ // Fill the relevant fields.
+ pHandle->dwJobID = pPrintProcessorOpenData->JobId;
+ pHandle->pwszDatatype = AllocSplStr(pPrintProcessorOpenData->pDatatype);
+ pHandle->pwszDocumentName = AllocSplStr(pPrintProcessorOpenData->pDocumentName);
+ pHandle->pwszOutputFile = AllocSplStr(pPrintProcessorOpenData->pOutputFile);
+ pHandle->pwszPrinterPort = AllocSplStr(pPrintProcessorOpenData->pPrinterName);
+
+ // We were successful! Return the handle and don't let the cleanup routine free it.
+ dwErrorCode = ERROR_SUCCESS;
+ hReturnValue = pHandle;
+ pHandle = NULL;
+
+Cleanup:
+ if (pHandle)
+ DllFreeSplMem(pHandle);
+
+ SetLastError(dwErrorCode);
+ return hReturnValue;
+}
+
+/**
+ * @name PrintDocumentOnPrintProcessor
+ *
+ * Prints a document on this Print Processor after a handle for the document has been opened through OpenPrintProcessor.
+ *
+ * @param hPrintProcessor
+ * The return value of a previous successful OpenPrintProcessor call.
+ *
+ * @param pDocumentName
+ * String in the format "Printer, Job N" describing the spooled job that is to be processed.
+ *
+ * @return
+ * 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)
+{
+ DWORD dwErrorCode;
+ PWINPRINT_HANDLE pHandle;
+
+ // Sanity checks
+ if (!hPrintProcessor)
+ {
+ dwErrorCode = ERROR_INVALID_HANDLE;
+ goto Cleanup;
+ }
+
+ pHandle = (PWINPRINT_HANDLE)hPrintProcessor;
+
+ // Call the corresponding Print function for the datatype.
+ if (pHandle->Datatype == RAW)
+ dwErrorCode = PrintRawJob(pHandle, pDocumentName);
+
+Cleanup:
+ SetLastError(dwErrorCode);
+ return (dwErrorCode == ERROR_SUCCESS);
+}