PageRenderTime 58ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/ndk-modules/ImageMagick-6.7.3-0/magick/nt-base.h

https://bitbucket.org/chyh1990/android-imagemagick
C Header | 426 lines | 363 code | 37 blank | 26 comment | 42 complexity | fc313d75438efd3c86094c470c650d10 MD5 | raw file
  1. /*
  2. Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization
  3. dedicated to making software imaging solutions freely available.
  4. You may not use this file except in compliance with the License.
  5. obtain a copy of the License at
  6. http://www.imagemagick.org/script/license.php
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. MagickCore Windows NT utility methods.
  13. */
  14. #ifndef _MAGICKCORE_NT_BASE_H
  15. #define _MAGICKCORE_NT_BASE_H
  16. #if defined(__cplusplus) || defined(c_plusplus)
  17. extern "C" {
  18. #endif
  19. #include "magick/delegate.h"
  20. #include "magick/delegate-private.h"
  21. #include "magick/exception.h"
  22. #define WIN32_LEAN_AND_MEAN
  23. #define VC_EXTRALEAN
  24. #define _CRT_SECURE_NO_DEPRECATE 1
  25. #include <windows.h>
  26. #include <wchar.h>
  27. #include <winuser.h>
  28. #include <wingdi.h>
  29. #include <io.h>
  30. #include <process.h>
  31. #include <errno.h>
  32. #if defined(_DEBUG) && !defined(__MINGW32__)
  33. #include <crtdbg.h>
  34. #endif
  35. #define PROT_READ 0x01
  36. #define PROT_WRITE 0x02
  37. #define MAP_SHARED 0x01
  38. #define MAP_PRIVATE 0x02
  39. #define MAP_ANONYMOUS 0x20
  40. #define F_OK 0
  41. #define R_OK 4
  42. #define W_OK 2
  43. #define RW_OK 6
  44. #define _SC_PAGESIZE 1
  45. #define _SC_PHYS_PAGES 2
  46. #define _SC_OPEN_MAX 3
  47. #if !defined(SSIZE_MAX)
  48. #define SSIZE_MAX 0x7fffffffL
  49. #endif
  50. /*
  51. _MSC_VER values:
  52. 1100 MSVC 5.0
  53. 1200 MSVC 6.0
  54. 1300 MSVC 7.0 Visual C++ .NET 2002
  55. 1310 Visual c++ .NET 2003
  56. 1400 Visual C++ 2005
  57. 1500 Visual C++ 2008
  58. */
  59. #if !defined(chsize)
  60. # if defined(__BORLANDC__)
  61. # define chsize(file,length) chsize(file,length)
  62. # else
  63. # define chsize(file,length) _chsize(file,length)
  64. # endif
  65. #endif
  66. #if !defined(access)
  67. #if defined(_VISUALC_) && (_MSC_VER >= 1400)
  68. # define access(path,mode) _access_s(path,mode)
  69. #endif
  70. #endif
  71. #if !defined(chdir)
  72. # define chdir _chdir
  73. #endif
  74. #if !defined(close)
  75. # define close _close
  76. #endif
  77. #if !defined(closedir)
  78. # define closedir(directory) NTCloseDirectory(directory)
  79. #endif
  80. #if !defined(fdopen)
  81. # define fdopen _fdopen
  82. #endif
  83. #if !defined(fileno)
  84. # define fileno _fileno
  85. #endif
  86. #if !defined(fseek) && !defined(__MINGW32__)
  87. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  88. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  89. # define fseek _fseeki64
  90. #endif
  91. #endif
  92. #if !defined(fstat) && !defined(__BORLANDC__)
  93. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  94. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  95. # define fstat _fstati64
  96. #else
  97. # define fstat _fstat
  98. #endif
  99. #endif
  100. #if !defined(fsync)
  101. # define fsync _commit
  102. #endif
  103. #if !defined(ftell) && !defined(__MINGW32__)
  104. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  105. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  106. # define ftell _ftelli64
  107. #endif
  108. #endif
  109. #if !defined(ftruncate)
  110. # define ftruncate(file,length) NTTruncateFile(file,length)
  111. #endif
  112. #if !defined(getcwd)
  113. # define getcwd _getcwd
  114. #endif
  115. #if !defined(getpid)
  116. # define getpid _getpid
  117. #endif
  118. #if !defined(hypot)
  119. # define hypot _hypot
  120. #endif
  121. #if !defined(inline)
  122. # define inline __inline
  123. #endif
  124. #if !defined(isatty)
  125. # define isatty _isatty
  126. #endif
  127. #if !defined(locale_t)
  128. #define locale_t _locale_t
  129. #endif
  130. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  131. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  132. # define lseek _lseeki64
  133. #else
  134. # define lseek _lseek
  135. #endif
  136. #if !defined(MAGICKCORE_LTDL_DELEGATE)
  137. #if !defined(lt_dlclose)
  138. # define lt_dlclose(handle) NTCloseLibrary(handle)
  139. #endif
  140. #if !defined(lt_dlerror)
  141. # define lt_dlerror() NTGetLibraryError()
  142. #endif
  143. #if !defined(lt_dlexit)
  144. # define lt_dlexit() NTExitLibrary()
  145. #endif
  146. #if !defined(lt_dlinit)
  147. # define lt_dlinit() NTInitializeLibrary()
  148. #endif
  149. #if !defined(lt_dlopen)
  150. # define lt_dlopen(filename) NTOpenLibrary(filename)
  151. #endif
  152. #if !defined(lt_dlsetsearchpath)
  153. # define lt_dlsetsearchpath(path) NTSetSearchPath(path)
  154. #endif
  155. #if !defined(lt_dlsym)
  156. # define lt_dlsym(handle,name) NTGetLibrarySymbol(handle,name)
  157. #endif
  158. #endif
  159. #if !defined(mkdir)
  160. # define mkdir _mkdir
  161. #endif
  162. #if !defined(mmap)
  163. # define mmap(address,length,protection,access,file,offset) \
  164. NTMapMemory(address,length,protection,access,file,offset)
  165. #endif
  166. #if !defined(msync)
  167. # define msync(address,length,flags) NTSyncMemory(address,length,flags)
  168. #endif
  169. #if !defined(munmap)
  170. # define munmap(address,length) NTUnmapMemory(address,length)
  171. #endif
  172. #if !defined(opendir)
  173. # define opendir(directory) NTOpenDirectory(directory)
  174. #endif
  175. #if !defined(open)
  176. # define open _open
  177. #endif
  178. #if !defined(pclose)
  179. # define pclose _pclose
  180. #endif
  181. #if !defined(popen)
  182. # define popen _popen
  183. #endif
  184. #if !defined(fprintf_l)
  185. #define fprintf_l _fprintf_s_l
  186. #endif
  187. #if !defined(read)
  188. # define read _read
  189. #endif
  190. #if !defined(readdir)
  191. # define readdir(directory) NTReadDirectory(directory)
  192. #endif
  193. #if !defined(seekdir)
  194. # define seekdir(directory,offset) NTSeekDirectory(directory,offset)
  195. #endif
  196. #if !defined(setmode)
  197. # define setmode _setmode
  198. #endif
  199. #if !defined(spawnvp)
  200. # define spawnvp _spawnvp
  201. #endif
  202. #if !defined(strtod_l)
  203. #define strtod_l _strtod_l
  204. #endif
  205. #if !defined(stat) && !defined(__BORLANDC__)
  206. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  207. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  208. # define stat _stati64
  209. #else
  210. # define stat _stat
  211. #endif
  212. #endif
  213. #if !defined(strcasecmp)
  214. # define strcasecmp _strcmpi
  215. #endif
  216. #if !defined(strncasecmp)
  217. # define strncasecmp _strnicmp
  218. #endif
  219. #if !defined(sysconf)
  220. # define sysconf(name) NTSystemConfiguration(name)
  221. #endif
  222. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  223. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  224. # define tell _telli64
  225. #else
  226. # define tell _tell
  227. #endif
  228. #if !defined(telldir)
  229. # define telldir(directory) NTTellDirectory(directory)
  230. #endif
  231. #if !defined(tempnam)
  232. # define tempnam _tempnam_s
  233. #endif
  234. #if !defined(vfprintf_l)
  235. #define vfprintf_l _vfprintf_l
  236. #endif
  237. #if !defined(vsnprintf)
  238. #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
  239. #define vsnprintf _vsnprintf
  240. #endif
  241. #endif
  242. #if !defined(vsnprintf_l)
  243. #define vsnprintf_l _vsnprintf_l
  244. #endif
  245. #if !defined(write)
  246. # define write _write
  247. #endif
  248. #if !defined(wstat) && !defined(__BORLANDC__)
  249. #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
  250. !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
  251. # define wstat _wstati64
  252. #else
  253. # define wstat _wstat
  254. #endif
  255. #endif
  256. #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
  257. # define SAFE_GLOBAL __declspec(thread)
  258. #else
  259. # define SAFE_GLOBAL
  260. #endif
  261. #if defined(__BORLANDC__)
  262. #undef _O_RANDOM
  263. #define _O_RANDOM 0
  264. #undef _O_SEQUENTIAL
  265. #define _O_SEQUENTIAL 0
  266. #undef _O_SHORT_LIVED
  267. #define _O_SHORT_LIVED 0
  268. #undef _O_TEMPORARY
  269. #define _O_TEMPORARY 0
  270. #endif
  271. #if !defined(XS_VERSION)
  272. struct dirent
  273. {
  274. char
  275. d_name[2048];
  276. int
  277. d_namlen;
  278. };
  279. typedef struct _DIR
  280. {
  281. HANDLE
  282. hSearch;
  283. WIN32_FIND_DATA
  284. Win32FindData;
  285. BOOL
  286. firsttime;
  287. struct dirent
  288. file_info;
  289. } DIR;
  290. typedef struct _NTMEMORYSTATUSEX
  291. {
  292. DWORD
  293. dwLength,
  294. dwMemoryLoad;
  295. DWORDLONG
  296. ullTotalPhys,
  297. ullAvailPhys,
  298. ullTotalPageFile,
  299. ullAvailPageFile,
  300. ullTotalVirtual,
  301. ullAvailVirtual,
  302. ullAvailExtendedVirtual;
  303. } NTMEMORYSTATUSEX;
  304. #if !defined(__MINGW32__)
  305. struct timezone
  306. {
  307. int
  308. tz_minuteswest,
  309. tz_dsttime;
  310. };
  311. #endif
  312. typedef UINT
  313. (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
  314. typedef UINT
  315. (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
  316. #endif
  317. #if defined(MAGICKCORE_BZLIB_DELEGATE)
  318. # if defined(_WIN32)
  319. # define BZ_IMPORT 1
  320. # endif
  321. #endif
  322. extern MagickExport char
  323. *NTGetLastError(void),
  324. **NTArgvToUTF8(const int argc,wchar_t **);
  325. extern MagickExport const GhostInfo
  326. *NTGhostscriptDLLVectors(void);
  327. #if !defined(MAGICKCORE_LTDL_DELEGATE)
  328. extern MagickExport const char
  329. *NTGetLibraryError(void);
  330. #endif
  331. #if !defined(XS_VERSION)
  332. extern MagickExport const char
  333. *NTGetLibraryError(void);
  334. extern MagickExport DIR
  335. *NTOpenDirectory(const char *);
  336. extern MagickExport double
  337. NTElapsedTime(void),
  338. NTUserTime(void);
  339. extern MagickExport int
  340. Exit(int),
  341. #if !defined(__MINGW32__)
  342. gettimeofday(struct timeval *,struct timezone *),
  343. #endif
  344. IsWindows95(),
  345. NTCloseDirectory(DIR *),
  346. NTCloseLibrary(void *),
  347. NTControlHandler(void),
  348. NTExitLibrary(void),
  349. NTTruncateFile(int,off_t),
  350. NTGhostscriptDLL(char *,int),
  351. NTGhostscriptEXE(char *,int),
  352. NTGhostscriptFonts(char *,int),
  353. NTGhostscriptLoadDLL(void),
  354. NTGhostscriptUnLoadDLL(void),
  355. NTInitializeLibrary(void),
  356. NTSetSearchPath(const char *),
  357. NTSyncMemory(void *,size_t,int),
  358. NTUnmapMemory(void *,size_t),
  359. NTSystemCommand(const char *);
  360. extern MagickExport ssize_t
  361. NTSystemConfiguration(int),
  362. NTTellDirectory(DIR *);
  363. extern MagickExport MagickBooleanType
  364. NTGatherRandomData(const size_t,unsigned char *),
  365. NTGetExecutionPath(char *,const size_t),
  366. NTGetModulePath(const char *,char *),
  367. NTReportEvent(const char *,const MagickBooleanType),
  368. NTReportException(const char *,const MagickBooleanType);
  369. extern MagickExport struct dirent
  370. *NTReadDirectory(DIR *);
  371. extern MagickExport unsigned char
  372. *NTRegistryKeyLookup(const char *),
  373. *NTResourceToBlob(const char *);
  374. extern MagickExport void
  375. NTErrorHandler(const ExceptionType,const char *,const char *),
  376. *NTGetLibrarySymbol(void *,const char *),
  377. *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
  378. *NTOpenLibrary(const char *),
  379. NTSeekDirectory(DIR *,ssize_t),
  380. NTWarningHandler(const ExceptionType,const char *,const char *);
  381. #endif /* !XS_VERSION */
  382. #if defined(__cplusplus) || defined(c_plusplus)
  383. }
  384. #endif /* !C++ */
  385. #endif /* !_MAGICKCORE_NT_BASE_H */