ReactOS  0.4.15-dev-3175-g222acf5
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  }
145  RpcEndExcept;
146  }
147  else
148  {
149  dwErrorCode = ERROR_INVALID_HANDLE;
150  }
151  IntUnprotectHandle(pHandle);
152  SetLastError(dwErrorCode);
153  return (dwErrorCode == ERROR_SUCCESS);
154 }
#define RpcEndExcept
Definition: rpc.h:128
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
BOOL WINAPI IntUnprotectHandle(HANDLE)
Definition: utils.c:171
LONG WINAPI IntProtectHandle(HANDLE, BOOL)
Definition: utils.c:107
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExceptionCode()
Definition: rpc.h:132
HANDLE hSpoolFileHandle
Definition: precomp.h:53
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
DWORD _RpcCloseSpoolFileHandle(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: spoolfile.c:104
#define ERR(fmt,...)
Definition: debug.h:110
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

◆ 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;
69  WINSPOOL_FILE_INFO_1 wsplfi;
70  PSPOOLER_HANDLE pHandle = (PSPOOLER_HANDLE)hPrinter;
71  HANDLE hHandle = INVALID_HANDLE_VALUE;
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  }
101  RpcEndExcept;
102 
103  if (dwErrorCode == ERROR_SUCCESS)
104  {
105  if ( wsplfi.hSpoolFileHandle != INVALID_HANDLE_VALUE )
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 }
#define RpcEndExcept
Definition: rpc.h:128
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
WINSPOOL_HANDLE hSpoolFileHandle
Definition: winspool.idl:840
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
BOOL WINAPI IntUnprotectHandle(HANDLE)
Definition: utils.c:171
LONG WINAPI IntProtectHandle(HANDLE, BOOL)
Definition: utils.c:107
DWORD _RpcCommitSpoolData2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:77
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#define RpcTryExcept
Definition: rpc.h:126
#define RpcExceptionCode()
Definition: rpc.h:132
HANDLE hSpoolFileHandle
Definition: precomp.h:53
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
union _WINSPOOL_FILE_INFO_CONTAINER::@3359 FileInfo
#define ERR(fmt,...)
Definition: debug.h:110
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
WINSPOOL_FILE_INFO_1 * pFileInfo1
Definition: winspool.idl:852
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50

◆ 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;
16  WINSPOOL_FILE_INFO_1 wsplfi;
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 }
#define RpcEndExcept
Definition: rpc.h:128
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwOptions
Definition: precomp.h:54
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
WINSPOOL_HANDLE hSpoolFileHandle
Definition: winspool.idl:840
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
BOOL WINAPI IntUnprotectHandle(HANDLE)
Definition: utils.c:171
LONG WINAPI IntProtectHandle(HANDLE, BOOL)
Definition: utils.c:107
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
#define RpcTryExcept
Definition: rpc.h:126
DWORD _RpcGetSpoolFileInfo2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:49
#define RpcExceptionCode()
Definition: rpc.h:132
HANDLE hSpoolFileHandle
Definition: precomp.h:53
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
union _WINSPOOL_FILE_INFO_CONTAINER::@3359 FileInfo
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
struct _SPOOLER_HANDLE * PSPOOLER_HANDLE
WINSPOOL_FILE_INFO_1 * pFileInfo1
Definition: winspool.idl:852
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1158
#define RpcExcept(expr)
Definition: rpc.h:127
HANDLE hPrinter
Definition: precomp.h:50