1 /*
2  * PROJECT:     ReactOS Spooler API
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Precompiled Header for all source files
5  * COPYRIGHT:   Copyright 2015-2017 Colin Finck (colin@reactos.org)
6  */
7 
8 #ifndef _PRECOMP_H
9 #define _PRECOMP_H
10 
11 #define WIN32_NO_STATUS
12 #include <windef.h>
13 #include <winbase.h>
14 #include <winuser.h>
15 #include <wingdi.h>
16 #include <winreg.h>
17 #include <winspool.h>
18 #include <winspool_c.h>
19 #include <winsplp.h>
20 #include <winddiui.h>
21 #include <ndk/rtlfuncs.h>
22 #include <strsafe.h>
23 
24 #include <spoolss.h>
25 #include <marshalling/marshalling.h>
26 
27 #include "wspool.h"
28 
29 #include <wine/debug.h>
30 WINE_DEFAULT_DEBUG_CHANNEL(winspool);
31 
32 #define SPOOLER_HANDLE_SIG 'gg'
33 
34 // Structures
35 /*
36  * Describes a handle returned by AddPrinterW or OpenPrinterW.
37  */
38 typedef struct _SPOOLER_HANDLE
39 {
40     DWORD_PTR Sig;
41     BOOL bStartedDoc : 1;
42     BOOL bJob : 1;
43     BOOL bAnsi : 1;
44     BOOL bDocEvent : 1;
45     BOOL bTrayIcon : 1;
46     BOOL bNoColorProfile : 1;
47     BOOL bShared : 1;
48     BOOL bClosed : 1;
49     DWORD dwJobID;
50     HANDLE hPrinter;
51     HANDLE hSPLFile;
52     DWORD cCount;
53     HANDLE hSpoolFileHandle;
54     DWORD dwOptions;
55 }
56 SPOOLER_HANDLE, *PSPOOLER_HANDLE;
57 
58 // main.c
59 extern HANDLE hProcessHeap;
60 extern CRITICAL_SECTION rtlCritSec;
61 
62 // utils.c
63 DWORD UnicodeToAnsiInPlace(PWSTR pwszField);
64 DWORD UnicodeToAnsiZZInPlace(PWSTR pwszzField);
65 SECURITY_DESCRIPTOR * get_sd(SECURITY_DESCRIPTOR *sd, DWORD *size);
66 LONG WINAPI IntProtectHandle(HANDLE,BOOL);
67 BOOL WINAPI IntUnprotectHandle(HANDLE);
68 VOID UpdateTrayIcon(HANDLE hPrinter, DWORD JobId);
69 
70 // devmode.c
71 extern void RosConvertAnsiDevModeToUnicodeDevmode(PDEVMODEA pDevModeInput, PDEVMODEW *pDevModeOutput);
72 
73 extern void RosConvertUnicodeDevModeToAnsiDevmode(PDEVMODEW pDevModeInput, PDEVMODEA pDevModeOutput);
74 
75 //
76 // [MS-EMF] 2.2.27 UniversalFontId Object
77 //
78 typedef struct _UNIVERSAL_FONT_ID
79 {
80     ULONG CheckSum;
81     ULONG Index;
82 } UNIVERSAL_FONT_ID, *PUNIVERSAL_FONT_ID;
83 
84 BOOL WINAPI IsValidDevmodeNoSizeW(PDEVMODEW pDevmode);
85 
86 /* RtlCreateUnicodeStringFromAsciiz will return an empty string in the buffer
87    if passed a NULL string. This returns NULLs to the result.
88 */
AsciiToUnicode(UNICODE_STRING * usBufferPtr,LPCSTR src)89 static inline PWSTR AsciiToUnicode( UNICODE_STRING * usBufferPtr, LPCSTR src )
90 {
91     if ( (src) )
92     {
93         RtlCreateUnicodeStringFromAsciiz(usBufferPtr, src);
94         return usBufferPtr->Buffer;
95     }
96     usBufferPtr->Buffer = NULL; /* so that RtlFreeUnicodeString won't barf */
97     return NULL;
98 }
99 
100 #endif
101