ReactOS 0.4.16-dev-329-g9223134
spoolfile.c File Reference
#include "precomp.h"
Include dependency graph for spoolfile.c:

Go to the source code of this file.

Functions

HANDLE WINAPI GetSpoolFileHandle (HANDLE hPrinter)
 
HANDLE WINAPI CommitSpoolData (HANDLE hPrinter, HANDLE hSpoolFile, DWORD cbCommit)
 
BOOL WINAPI CloseSpoolFileHandle (HANDLE hPrinter, HANDLE hSpoolFile)
 

Function Documentation

◆ CloseSpoolFileHandle()

BOOL WINAPI CloseSpoolFileHandle ( HANDLE  hPrinter,
HANDLE  hSpoolFile 
)

Definition at line 119 of file spoolfile.c.

120{
121 DWORD dwErrorCode;
122 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
123
124 FIXME("CloseSpoolFileHandle(%p, %p)\n", hPrinter,hSpoolFile);
125
126 if ( IntProtectHandle( hPrinter, FALSE ) )
127 {
128 return FALSE;
129 }
130 if ( pHandle->hSpoolFileHandle == hSpoolFile )
131 {
132 CloseHandle( pHandle->hSpoolFileHandle );
134
135 // Do the RPC call.
137 {
138 dwErrorCode = _RpcCloseSpoolFileHandle( &pHandle->hPrinter );
139 }
141 {
142 dwErrorCode = RpcExceptionCode();
143 ERR("_RpcloseSpoolFileHandle failed with exception code %lu!\n", dwErrorCode);
144 }
146 }
147 else
148 {
149 dwErrorCode = ERROR_INVALID_HANDLE;
150 }
151 IntUnprotectHandle(pHandle);
152 SetLastError(dwErrorCode);
153 return (dwErrorCode == ERROR_SUCCESS);
154}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD _RpcCloseSpoolFileHandle(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: spoolfile.c:104
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define RpcEndExcept
Definition: rpc.h:128
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExcept(expr)
Definition: rpc.h:127
#define RpcExceptionCode()
Definition: rpc.h:132
HANDLE hSpoolFileHandle
Definition: precomp.h:53
HANDLE hPrinter
Definition: precomp.h:50
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
BOOL WINAPI IntUnprotectHandle(HANDLE)
Definition: utils.c:171
LONG WINAPI IntProtectHandle(HANDLE, BOOL)
Definition: utils.c:107

◆ CommitSpoolData()

HANDLE WINAPI CommitSpoolData ( HANDLE  hPrinter,
HANDLE  hSpoolFile,
DWORD  cbCommit 
)

Definition at line 65 of file spoolfile.c.

66{
67 DWORD dwErrorCode, cpid;
68 WINSPOOL_FILE_INFO_CONTAINER FileInfoContainer;
70 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
72
73 FIXME("CommitSpoolData(%p, %p, %d)\n", hPrinter,hSpoolFile,cbCommit);
74
75 if ( IntProtectHandle( hPrinter, FALSE ) )
76 {
77 return hHandle;
78 }
79
80 if ( pHandle->hSpoolFileHandle == INVALID_HANDLE_VALUE || pHandle->hSpoolFileHandle != hSpoolFile )
81 {
82 dwErrorCode = ERROR_INVALID_HANDLE;
83 }
84 else
85 {
86 cpid = GetCurrentProcessId();
87
88 FileInfoContainer.Level = 1;
89 FileInfoContainer.FileInfo.pFileInfo1 = &wsplfi;
90
91 // Do the RPC call.
93 {
94 dwErrorCode = _RpcCommitSpoolData2( &pHandle->hPrinter, cpid, cbCommit, 1, &FileInfoContainer );
95 }
97 {
98 dwErrorCode = RpcExceptionCode();
99 ERR("_RpcCommitSpoolData failed with exception code %lu!\n", dwErrorCode);
100 }
102
103 if (dwErrorCode == ERROR_SUCCESS)
104 {
106 {
107 CloseHandle( pHandle->hSpoolFileHandle );
108 pHandle->hSpoolFileHandle = wsplfi.hSpoolFileHandle;
109 }
110 hHandle = pHandle->hSpoolFileHandle;
111 }
112 IntUnprotectHandle(pHandle);
113 }
114 SetLastError(dwErrorCode);
115 return hHandle;
116}
DWORD _RpcCommitSpoolData2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:77
WINSPOOL_HANDLE hSpoolFileHandle
Definition: winspool.idl:840
union _WINSPOOL_FILE_INFO_CONTAINER::@3448 FileInfo
WINSPOOL_FILE_INFO_1 * pFileInfo1
Definition: winspool.idl:852
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158

◆ GetSpoolFileHandle()

HANDLE WINAPI GetSpoolFileHandle ( HANDLE  hPrinter)

Definition at line 12 of file spoolfile.c.

13{
14 DWORD dwErrorCode, cpid;
15 WINSPOOL_FILE_INFO_CONTAINER FileInfoContainer;
17 PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
18 HANDLE hHandle = NULL;
19
20 FIXME("GetSpoolFileHandle(%p)\n", hPrinter);
21
22 if ( IntProtectHandle( hPrinter, FALSE ) )
23 {
24 dwErrorCode = ERROR_INVALID_HANDLE;
25 }
26 else
27 {
28 if ( pHandle->hSpoolFileHandle != INVALID_HANDLE_VALUE )
29 {
30 hHandle = pHandle->hSpoolFileHandle;
31 }
32 else
33 {
34 cpid = GetCurrentProcessId();
35
36 FileInfoContainer.Level = 1;
37 FileInfoContainer.FileInfo.pFileInfo1 = &wsplfi;
38
39 // Do the RPC call.
41 {
42 dwErrorCode = _RpcGetSpoolFileInfo2( &pHandle->hPrinter, cpid, 1, &FileInfoContainer );
43 }
45 {
46 dwErrorCode = RpcExceptionCode();
47 ERR("_RpcGetSpoolFileInfo failed with exception code %lu!\n", dwErrorCode);
48 }
50
51 if (dwErrorCode == ERROR_SUCCESS)
52 {
53 pHandle->hSpoolFileHandle = wsplfi.hSpoolFileHandle;
54 pHandle->dwOptions = wsplfi.dwOptions;
55 hHandle = pHandle->hSpoolFileHandle;
56 }
57 }
58 IntUnprotectHandle(pHandle);
59 }
60 SetLastError(dwErrorCode);
61 return hHandle;
62}
DWORD _RpcGetSpoolFileInfo2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:49
#define NULL
Definition: types.h:112
DWORD dwOptions
Definition: precomp.h:54