1 /* 2 * PROJECT: ReactOS Spooler Router 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: Functions related to Spool File 5 * COPYRIGHT: Copyright 1998-2022 ReactOS 6 */ 7 8 #include "precomp.h" 9 10 BOOL WINAPI 11 SplGetSpoolFileInfo( 12 HANDLE hPrinter, 13 HANDLE hProcessHandle, 14 DWORD Level, 15 PFILE_INFO_1 pFileInfo, 16 DWORD dwSize, 17 DWORD* dwNeeded ) 18 { 19 BOOL Ret; 20 HANDLE hHandle, hSourceProcessHandle; 21 PSPOOLSS_PRINTER_HANDLE pHandle = (PSPOOLSS_PRINTER_HANDLE)hPrinter; 22 23 // Sanity checks. 24 if (!pHandle) 25 { 26 SetLastError(ERROR_INVALID_PARAMETER); 27 return FALSE; 28 } 29 30 hSourceProcessHandle = GetCurrentProcess(); 31 32 // No Local? Ok, what ever... 33 34 Ret = pHandle->pPrintProvider->PrintProvider.fpGetSpoolFileInfo( pHandle->hPrinter, 35 NULL, 36 &hHandle, 37 hProcessHandle, 38 hSourceProcessHandle ); 39 if ( Ret ) 40 { 41 pFileInfo->hSpoolFileHandle = hHandle; 42 pFileInfo->bInheritHandle = TRUE; 43 pFileInfo->dwOptions = DUPLICATE_CLOSE_SOURCE; 44 } 45 46 return Ret; 47 } 48 49 BOOL WINAPI 50 SplCommitSpoolData( 51 HANDLE hPrinter, 52 HANDLE hProcessHandle, 53 DWORD cbCommit, 54 DWORD Level, 55 PFILE_INFO_1 pFileInfo, 56 DWORD dwSize, 57 DWORD* dwNeeded ) 58 { 59 PSPOOLSS_PRINTER_HANDLE pHandle = (PSPOOLSS_PRINTER_HANDLE)hPrinter; 60 61 // Sanity checks. 62 if (!pHandle) 63 { 64 SetLastError(ERROR_INVALID_PARAMETER); 65 return FALSE; 66 } 67 68 pFileInfo->hSpoolFileHandle = INVALID_HANDLE_VALUE; 69 pFileInfo->bInheritHandle = TRUE; 70 pFileInfo->dwOptions = DUPLICATE_CLOSE_SOURCE; 71 72 return pHandle->pPrintProvider->PrintProvider.fpCommitSpoolData( hPrinter, cbCommit ); 73 } 74 75 BOOL WINAPI 76 SplCloseSpoolFileHandle( HANDLE hPrinter ) 77 { 78 PSPOOLSS_PRINTER_HANDLE pHandle = (PSPOOLSS_PRINTER_HANDLE)hPrinter; 79 80 // Sanity checks. 81 if (!pHandle) 82 { 83 SetLastError(ERROR_INVALID_PARAMETER); 84 return FALSE; 85 } 86 87 return pHandle->pPrintProvider->PrintProvider.fpCloseSpoolFileHandle( pHandle->hPrinter ); 88 } 89