2 * reactos/lib/gdi32/misc/eng.c
16 EngAcquireSemaphore ( IN HSEMAPHORE hsem
)
18 RtlEnterCriticalSection((PRTL_CRITICAL_SECTION
)hsem
);
26 copy_my_glyphset( FD_GLYPHSET
*dst_glyphset
, FD_GLYPHSET
* src_glyphset
, ULONG Size
)
28 BOOL retValue
= FALSE
;
30 memcpy(src_glyphset
, dst_glyphset
, Size
);
31 if (src_glyphset
->cRuns
== 0)
45 EngComputeGlyphSet(INT nCodePage
,INT nFirstChar
,INT cChars
)
47 FD_GLYPHSET
* ntfd_glyphset
;
48 FD_GLYPHSET
* myfd_glyphset
= NULL
;
50 ntfd_glyphset
= NtGdiEngComputeGlyphSet(nCodePage
,nFirstChar
,cChars
);
54 if (ntfd_glyphset
->cjThis
)
56 myfd_glyphset
= GlobalAlloc(0,ntfd_glyphset
->cjThis
);
59 if (copy_my_glyphset(myfd_glyphset
,ntfd_glyphset
,ntfd_glyphset
->cjThis
) == FALSE
)
61 GlobalFree(myfd_glyphset
);
75 EngCreateSemaphore ( VOID
)
77 PRTL_CRITICAL_SECTION CritSect
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_CRITICAL_SECTION
));
83 RtlInitializeCriticalSection( CritSect
);
84 return (HSEMAPHORE
)CritSect
;
92 EngDeleteSemaphore ( IN HSEMAPHORE hsem
)
96 RtlDeleteCriticalSection( (PRTL_CRITICAL_SECTION
) hsem
);
97 RtlFreeHeap( GetProcessHeap(), 0, hsem
);
105 EngFindResource(HANDLE h
,
115 if ((HRSrc
= FindResourceW( (HMODULE
) h
, MAKEINTRESOURCEW(iName
), MAKEINTRESOURCEW(iType
))))
117 if ((Size
= SizeofResource( (HMODULE
) h
, HRSrc
)))
119 if ((Hg
= LoadResource( (HMODULE
) h
, HRSrc
)))
121 Lock
= LockResource( Hg
);
134 EngFreeModule(HANDLE h
)
144 EngGetCurrentCodePage( OUT PUSHORT OemCodePage
,
145 OUT PUSHORT AnsiCodePage
)
147 *OemCodePage
= GetOEMCP();
148 *AnsiCodePage
= GetACP();
156 EngGetDriverName(HDEV hdev
)
158 // DHPDEV from NtGdiGetDhpdev must be from print driver.
159 PUMPDEV pPDev
= (PUMPDEV
)NtGdiGetDhpdev(hdev
);
161 if (!pPDev
) return NULL
;
163 if (pPDev
->Sig
!= PDEV_UMPD_ID
)
165 pPDev
= (PUMPDEV
)pPDev
->Sig
;
167 return pPDev
->pdi5Info
->pDriverPath
;
174 EngGetPrinterDataFileName(HDEV hdev
)
176 PUMPDEV pPDev
= (PUMPDEV
)NtGdiGetDhpdev(hdev
);
178 if (!pPDev
) return NULL
;
180 if (pPDev
->Sig
!= PDEV_UMPD_ID
)
182 pPDev
= (PUMPDEV
)pPDev
->Sig
;
184 return pPDev
->pdi5Info
->pDataFile
;
191 EngLoadModule(LPWSTR pwsz
)
193 return LoadLibraryExW ( pwsz
, NULL
, LOAD_LIBRARY_AS_DATAFILE
);
200 EngMultiByteToWideChar(UINT CodePage
,
201 LPWSTR WideCharString
,
202 INT BytesInWideCharString
,
203 LPSTR MultiByteString
,
204 INT BytesInMultiByteString
)
206 return MultiByteToWideChar(CodePage
,0,MultiByteString
,BytesInMultiByteString
,WideCharString
,BytesInWideCharString
/ sizeof(WCHAR
));
213 EngQueryLocalTime(PENG_TIME_FIELDS etf
)
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
;
232 EngReleaseSemaphore ( IN HSEMAPHORE hsem
)
234 RtlLeaveCriticalSection( (PRTL_CRITICAL_SECTION
) hsem
);
245 EngWideCharToMultiByte( UINT CodePage
,
246 LPWSTR WideCharString
,
247 INT BytesInWideCharString
,
248 LPSTR MultiByteString
,
249 INT BytesInMultiByteString
)
251 return WideCharToMultiByte(CodePage
, 0, WideCharString
, (BytesInWideCharString
/sizeof(WCHAR
)),
252 MultiByteString
, BytesInMultiByteString
, NULL
, NULL
);