b8d3d8e8e8f35f62d16863e8227431d9024e089e
[reactos.git] / reactos / win32ss / gdi / gdi32 / objects / eng.c
1 /*
2 * reactos/lib/gdi32/misc/eng.c
3 *
4 * GDI32.DLL eng part
5 *
6 *
7 */
8
9 #include <precomp.h>
10
11 /*
12 * @implemented
13 */
14 VOID
15 WINAPI
16 EngAcquireSemaphore ( IN HSEMAPHORE hsem )
17 {
18 RtlEnterCriticalSection((PRTL_CRITICAL_SECTION)hsem);
19 }
20
21
22 /*
23 * @unimplemented
24 */
25 BOOL
26 copy_my_glyphset( FD_GLYPHSET *dst_glyphset , FD_GLYPHSET * src_glyphset, ULONG Size)
27 {
28 BOOL retValue = FALSE;
29
30 memcpy(src_glyphset, dst_glyphset, Size);
31 if (src_glyphset->cRuns == 0)
32 {
33 retValue = TRUE;
34 }
35
36 /* FIXME copy wrun */
37 return retValue;
38 }
39
40 /*
41 * @implemented
42 */
43 FD_GLYPHSET*
44 WINAPI
45 EngComputeGlyphSet(INT nCodePage,INT nFirstChar,INT cChars)
46 {
47 FD_GLYPHSET * ntfd_glyphset;
48 FD_GLYPHSET * myfd_glyphset = NULL;
49
50 ntfd_glyphset = NtGdiEngComputeGlyphSet(nCodePage,nFirstChar,cChars);
51
52 if (ntfd_glyphset)
53 {
54 if (ntfd_glyphset->cjThis)
55 {
56 myfd_glyphset = GlobalAlloc(0,ntfd_glyphset->cjThis);
57 if (myfd_glyphset)
58 {
59 if (copy_my_glyphset(myfd_glyphset,ntfd_glyphset,ntfd_glyphset->cjThis) == FALSE)
60 {
61 GlobalFree(myfd_glyphset);
62 myfd_glyphset = NULL;
63 }
64 }
65 }
66 }
67 return myfd_glyphset;
68 }
69
70 /*
71 * @implemented
72 */
73 HSEMAPHORE
74 WINAPI
75 EngCreateSemaphore ( VOID )
76 {
77 PRTL_CRITICAL_SECTION CritSect = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_CRITICAL_SECTION));
78 if (!CritSect)
79 {
80 return NULL;
81 }
82
83 RtlInitializeCriticalSection( CritSect );
84 return (HSEMAPHORE)CritSect;
85 }
86
87 /*
88 * @implemented
89 */
90 VOID
91 WINAPI
92 EngDeleteSemaphore ( IN HSEMAPHORE hsem )
93 {
94 if (hsem)
95 {
96 RtlDeleteCriticalSection( (PRTL_CRITICAL_SECTION) hsem );
97 RtlFreeHeap( GetProcessHeap(), 0, hsem );
98 }
99 }
100
101 /*
102 * @implemented
103 */
104 PVOID WINAPI
105 EngFindResource(HANDLE h,
106 int iName,
107 int iType,
108 PULONG pulSize)
109 {
110 HRSRC HRSrc;
111 DWORD Size = 0;
112 HGLOBAL Hg;
113 LPVOID Lock = NULL;
114
115 if ((HRSrc = FindResourceW( (HMODULE) h, MAKEINTRESOURCEW(iName), MAKEINTRESOURCEW(iType))))
116 {
117 if ((Size = SizeofResource( (HMODULE) h, HRSrc )))
118 {
119 if ((Hg = LoadResource( (HMODULE) h, HRSrc )))
120 {
121 Lock = LockResource( Hg );
122 }
123 }
124 }
125
126 *pulSize = Size;
127 return (PVOID) Lock;
128 }
129
130 /*
131 * @implemented
132 */
133 VOID WINAPI
134 EngFreeModule(HANDLE h)
135 {
136 FreeLibrary(h);
137 }
138
139 /*
140 * @implemented
141 */
142
143 VOID WINAPI
144 EngGetCurrentCodePage( OUT PUSHORT OemCodePage,
145 OUT PUSHORT AnsiCodePage)
146 {
147 *OemCodePage = GetOEMCP();
148 *AnsiCodePage = GetACP();
149 }
150
151
152 /*
153 * @implemented
154 */
155 LPWSTR WINAPI
156 EngGetDriverName(HDEV hdev)
157 {
158 // DHPDEV from NtGdiGetDhpdev must be from print driver.
159 PUMPDEV pPDev = (PUMPDEV)NtGdiGetDhpdev(hdev);
160
161 if (!pPDev) return NULL;
162
163 if (pPDev->Sig != PDEV_UMPD_ID)
164 {
165 pPDev = (PUMPDEV)pPDev->Sig;
166 }
167 return pPDev->pdi5Info->pDriverPath;
168 }
169
170 /*
171 * @implemented
172 */
173 LPWSTR WINAPI
174 EngGetPrinterDataFileName(HDEV hdev)
175 {
176 PUMPDEV pPDev = (PUMPDEV)NtGdiGetDhpdev(hdev);
177
178 if (!pPDev) return NULL;
179
180 if (pPDev->Sig != PDEV_UMPD_ID)
181 {
182 pPDev = (PUMPDEV)pPDev->Sig;
183 }
184 return pPDev->pdi5Info->pDataFile;
185 }
186
187 /*
188 * @implemented
189 */
190 HANDLE WINAPI
191 EngLoadModule(LPWSTR pwsz)
192 {
193 return LoadLibraryExW ( pwsz, NULL, LOAD_LIBRARY_AS_DATAFILE);
194 }
195
196 /*
197 * @implemented
198 */
199 INT WINAPI
200 EngMultiByteToWideChar(UINT CodePage,
201 LPWSTR WideCharString,
202 INT BytesInWideCharString,
203 LPSTR MultiByteString,
204 INT BytesInMultiByteString)
205 {
206 return MultiByteToWideChar(CodePage,0,MultiByteString,BytesInMultiByteString,WideCharString,BytesInWideCharString / sizeof(WCHAR));
207 }
208
209 /*
210 * @implemented
211 */
212 VOID WINAPI
213 EngQueryLocalTime(PENG_TIME_FIELDS etf)
214 {
215 SYSTEMTIME SystemTime;
216 GetLocalTime( &SystemTime );
217 etf->usYear = SystemTime.wYear;
218 etf->usMonth = SystemTime.wMonth;
219 etf->usWeekday = SystemTime.wDayOfWeek;
220 etf->usDay = SystemTime.wDay;
221 etf->usHour = SystemTime.wHour;
222 etf->usMinute = SystemTime.wMinute;
223 etf->usSecond = SystemTime.wSecond;
224 etf->usMilliseconds = SystemTime.wMilliseconds;
225 }
226
227 /*
228 * @implemented
229 */
230 VOID
231 WINAPI
232 EngReleaseSemaphore ( IN HSEMAPHORE hsem )
233 {
234 RtlLeaveCriticalSection( (PRTL_CRITICAL_SECTION) hsem);
235 }
236
237
238
239
240 /*
241 * @implemented
242 */
243 INT
244 WINAPI
245 EngWideCharToMultiByte( UINT CodePage,
246 LPWSTR WideCharString,
247 INT BytesInWideCharString,
248 LPSTR MultiByteString,
249 INT BytesInMultiByteString)
250 {
251 return WideCharToMultiByte(CodePage, 0, WideCharString, (BytesInWideCharString/sizeof(WCHAR)),
252 MultiByteString, BytesInMultiByteString, NULL, NULL);
253 }