MagickCore  6.7.7
nt-base-private.h
Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
00003   dedicated to making software imaging solutions freely available.
00004 
00005   You may not use this file except in compliance with the License.
00006   obtain a copy of the License at
00007 
00008     http://www.imagemagick.org/script/license.php
00009 
00010   Unless required by applicable law or agreed to in writing, software
00011   distributed under the License is distributed on an "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013   See the License for the specific language governing permissions and
00014   limitations under the License.
00015 
00016   MagickCore Windows NT private methods.
00017 */
00018 #ifndef _MAGICKCORE_NT_BASE_PRIVATE_H
00019 #define _MAGICKCORE_NT_BASE_PRIVATE_H
00020 
00021 #if defined(__cplusplus) || defined(c_plusplus)
00022 extern "C" {
00023 #endif
00024 
00025 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
00026 
00027 #include "MagickCore/delegate.h"
00028 #include "MagickCore/delegate-private.h"
00029 #include "MagickCore/exception.h"
00030 #include "MagickCore/splay-tree.h"
00031 
00032 #define WIN32_LEAN_AND_MEAN
00033 #define VC_EXTRALEAN
00034 #define _CRT_SECURE_NO_DEPRECATE  1
00035 #include <windows.h>
00036 #include <wchar.h>
00037 #include <winuser.h>
00038 #include <wingdi.h>
00039 #include <io.h>
00040 #include <process.h>
00041 #include <errno.h>
00042 #if defined(_DEBUG) && !defined(__MINGW32__)
00043 #include <crtdbg.h>
00044 #endif
00045 
00046 #define PROT_READ  0x01
00047 #define PROT_WRITE  0x02
00048 #define MAP_SHARED  0x01
00049 #define MAP_PRIVATE  0x02
00050 #define MAP_ANONYMOUS  0x20
00051 #define F_OK 0
00052 #define R_OK 4
00053 #define W_OK 2
00054 #define RW_OK 6
00055 #define _SC_PAGESIZE 1
00056 #define _SC_PHYS_PAGES 2
00057 #define _SC_OPEN_MAX 3
00058 #if !defined(SSIZE_MAX)
00059 #define SSIZE_MAX  0x7fffffffL
00060 #endif
00061 
00062 /*
00063   _MSC_VER values:
00064     1100 MSVC 5.0
00065     1200 MSVC 6.0
00066     1300 MSVC 7.0 Visual C++ .NET 2002
00067     1310 Visual c++ .NET 2003
00068     1400 Visual C++ 2005
00069     1500 Visual C++ 2008
00070 */
00071 
00072 #if !defined(chsize)
00073 # if defined(__BORLANDC__)
00074 #   define chsize(file,length)  chsize(file,length)
00075 # else
00076 #   define chsize(file,length)  _chsize(file,length)
00077 # endif
00078 #endif
00079 
00080 #if !defined(access)
00081 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
00082 #  define access(path,mode)  _access_s(path,mode)
00083 #endif
00084 #endif
00085 #if !defined(chdir)
00086 #  define chdir  _chdir
00087 #endif
00088 #if !defined(close)
00089 #  define close  _close
00090 #endif
00091 #if !defined(closedir)
00092 #  define closedir(directory)  NTCloseDirectory(directory)
00093 #endif
00094 #if !defined(fdopen)
00095 #  define fdopen  _fdopen
00096 #endif
00097 #if !defined(fileno)
00098 #  define fileno  _fileno
00099 #endif
00100 #if !defined(fseek) && !defined(__MINGW32__)
00101 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00102   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00103 #  define fseek  _fseeki64
00104 #endif
00105 #endif
00106 #if !defined(fstat) && !defined(__BORLANDC__)
00107 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00108   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00109 #  define fstat  _fstati64
00110 #else
00111 #  define fstat  _fstat
00112 #endif
00113 #endif
00114 #if !defined(fsync)
00115 #  define fsync  _commit
00116 #endif
00117 #if !defined(ftell) && !defined(__MINGW32__)
00118 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00119   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00120 #  define ftell  _ftelli64
00121 #endif
00122 #endif
00123 #if !defined(ftruncate)
00124 #  define ftruncate(file,length)  NTTruncateFile(file,length)
00125 #endif
00126 #if !defined(getcwd)
00127 #  define getcwd  _getcwd
00128 #endif
00129 #if !defined(getpid)
00130 #  define getpid  _getpid
00131 #endif
00132 #if !defined(hypot)
00133 #  define hypot  _hypot
00134 #endif
00135 #if !defined(inline)
00136 #  define inline __inline
00137 #endif
00138 #if !defined(isatty)
00139 #  define isatty  _isatty
00140 #endif
00141 #if !defined(locale_t)
00142 #define locale_t _locale_t
00143 #endif
00144 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00145   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00146 #  define lseek  _lseeki64
00147 #else
00148 #  define lseek  _lseek
00149 #endif
00150 #if !defined(MAGICKCORE_LTDL_DELEGATE)
00151 #if !defined(lt_dlclose)
00152 #  define lt_dlclose(handle)  NTCloseLibrary(handle)
00153 #endif
00154 #if !defined(lt_dlerror)
00155 #  define lt_dlerror()  NTGetLibraryError()
00156 #endif
00157 #if !defined(lt_dlexit)
00158 #  define lt_dlexit()  NTExitLibrary()
00159 #endif
00160 #if !defined(lt_dlinit)
00161 #  define lt_dlinit()  NTInitializeLibrary()
00162 #endif
00163 #if !defined(lt_dlopen)
00164 #  define lt_dlopen(filename)  NTOpenLibrary(filename)
00165 #endif
00166 #if !defined(lt_dlsetsearchpath)
00167 #  define lt_dlsetsearchpath(path)  NTSetSearchPath(path)
00168 #endif
00169 #if !defined(lt_dlsym)
00170 #  define lt_dlsym(handle,name)  NTGetLibrarySymbol(handle,name)
00171 #endif
00172 #endif
00173 #if !defined(mkdir)
00174 #  define mkdir  _mkdir
00175 #endif
00176 #if !defined(mmap)
00177 #  define mmap(address,length,protection,access,file,offset) \
00178   NTMapMemory(address,length,protection,access,file,offset)
00179 #endif
00180 #if !defined(msync)
00181 #  define msync(address,length,flags)  NTSyncMemory(address,length,flags)
00182 #endif
00183 #if !defined(munmap)
00184 #  define munmap(address,length)  NTUnmapMemory(address,length)
00185 #endif
00186 #if !defined(opendir)
00187 #  define opendir(directory)  NTOpenDirectory(directory)
00188 #endif
00189 #if !defined(open)
00190 #  define open  _open
00191 #endif
00192 #if !defined(pclose)
00193 #  define pclose  _pclose
00194 #endif
00195 #if !defined(popen)
00196 #  define popen  _popen
00197 #endif
00198 #if !defined(fprintf_l)
00199 #define fprintf_l  _fprintf_s_l
00200 #endif
00201 #if !defined(read)
00202 #  define read  _read
00203 #endif
00204 #if !defined(readdir)
00205 #  define readdir(directory)  NTReadDirectory(directory)
00206 #endif
00207 #if !defined(seekdir)
00208 #  define seekdir(directory,offset)  NTSeekDirectory(directory,offset)
00209 #endif
00210 #if !defined(setmode)
00211 #  define setmode  _setmode
00212 #endif
00213 #if !defined(spawnvp)
00214 #  define spawnvp  _spawnvp
00215 #endif
00216 #if !defined(strtod_l)
00217 #define strtod_l  _strtod_l
00218 #endif
00219 #if !defined(stat) && !defined(__BORLANDC__)
00220 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00221   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00222 #  define stat  _stati64
00223 #else
00224 #  define stat  _stat
00225 #endif
00226 #endif
00227 #if !defined(strcasecmp)
00228 #  define strcasecmp  _strcmpi
00229 #endif
00230 #if !defined(strncasecmp)
00231 #  define strncasecmp  _strnicmp
00232 #endif
00233 #if !defined(sysconf)
00234 #  define sysconf(name)  NTSystemConfiguration(name)
00235 #endif
00236 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00237   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00238 #  define tell  _telli64
00239 #else
00240 #  define tell  _tell
00241 #endif
00242 #if !defined(telldir)
00243 #  define telldir(directory)  NTTellDirectory(directory)
00244 #endif
00245 #if !defined(tempnam)
00246 #  define tempnam  _tempnam_s
00247 #endif
00248 #if !defined(vfprintf_l)
00249 #define vfprintf_l  _vfprintf_l
00250 #endif
00251 #if !defined(vsnprintf)
00252 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
00253 #define vsnprintf _vsnprintf 
00254 #endif
00255 #endif
00256 #if !defined(vsnprintf_l)
00257 #define vsnprintf_l  _vsnprintf_l
00258 #endif
00259 #if !defined(write)
00260 #  define write  _write
00261 #endif
00262 #if !defined(wstat) && !defined(__BORLANDC__)
00263 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
00264   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
00265 #  define wstat  _wstati64
00266 #else
00267 #  define wstat  _wstat
00268 #endif
00269 #endif
00270 
00271 #if defined(_MT) && defined(MAGICKCORE_WINDOWS_SUPPORT)
00272 #  define SAFE_GLOBAL  __declspec(thread)
00273 #else
00274 #  define SAFE_GLOBAL
00275 #endif
00276 
00277 #if defined(__BORLANDC__)
00278 #undef _O_RANDOM
00279 #define _O_RANDOM 0
00280 #undef _O_SEQUENTIAL
00281 #define _O_SEQUENTIAL 0
00282 #undef _O_SHORT_LIVED
00283 #define _O_SHORT_LIVED 0
00284 #undef _O_TEMPORARY
00285 #define _O_TEMPORARY 0
00286 #endif
00287 
00288 #undef gettimeofday
00289 
00290 #if !defined(XS_VERSION)
00291 struct dirent
00292 {
00293   char
00294     d_name[2048];
00295 
00296   int
00297     d_namlen;
00298 };
00299 
00300 typedef struct _DIR
00301 {
00302   HANDLE
00303     hSearch;
00304 
00305   WIN32_FIND_DATA
00306     Win32FindData;
00307 
00308   BOOL
00309     firsttime;
00310 
00311   struct dirent
00312     file_info;
00313 } DIR;
00314 
00315 typedef struct _NTMEMORYSTATUSEX
00316 {
00317   DWORD
00318     dwLength,
00319     dwMemoryLoad;
00320 
00321   DWORDLONG
00322     ullTotalPhys,
00323     ullAvailPhys,
00324     ullTotalPageFile,
00325     ullAvailPageFile,
00326     ullTotalVirtual,
00327     ullAvailVirtual,
00328     ullAvailExtendedVirtual;
00329 } NTMEMORYSTATUSEX;
00330 
00331 #if !defined(__MINGW32__)
00332 struct timezone
00333 {
00334   int
00335     tz_minuteswest,
00336     tz_dsttime;
00337 };
00338 #endif
00339 
00340 typedef UINT
00341   (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
00342 
00343 typedef UINT
00344   (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
00345 
00346 #endif
00347 
00348 #if defined(MAGICKCORE_BZLIB_DELEGATE)
00349 #  if defined(_WIN32)
00350 #    define BZ_IMPORT 1
00351 #  endif
00352 #endif
00353 
00354 extern MagickPrivate char
00355   *NTGetLastError(void);
00356 
00357 #if !defined(MAGICKCORE_LTDL_DELEGATE)
00358 extern MagickPrivate const char
00359   *NTGetLibraryError(void);
00360 #endif
00361 
00362 #if !defined(XS_VERSION)
00363 extern MagickPrivate const char
00364   *NTGetLibraryError(void);
00365 
00366 extern MagickPrivate DIR
00367   *NTOpenDirectory(const char *);
00368 
00369 extern MagickPrivate double
00370   NTElapsedTime(void),
00371   NTUserTime(void);
00372 
00373 extern MagickPrivate int
00374   Exit(int),
00375 #if !defined(__MINGW32__)
00376   gettimeofday(struct timeval *,struct timezone *),
00377 #endif
00378   IsWindows95(void),
00379   NTCloseDirectory(DIR *),
00380   NTCloseLibrary(void *),
00381   NTControlHandler(void),
00382   NTExitLibrary(void),
00383   NTTruncateFile(int,off_t),
00384   NTGhostscriptDLL(char *,int),
00385   NTGhostscriptEXE(char *,int),
00386   NTGhostscriptFonts(char *,int),
00387   NTGhostscriptLoadDLL(void),
00388   NTInitializeLibrary(void),
00389   NTSetSearchPath(const char *),
00390   NTSyncMemory(void *,size_t,int),
00391   NTUnmapMemory(void *,size_t),
00392   NTSystemCommand(const char *);
00393 
00394 extern MagickPrivate ssize_t
00395   NTSystemConfiguration(int),
00396   NTTellDirectory(DIR *);
00397 
00398 extern MagickPrivate MagickBooleanType
00399   NTGatherRandomData(const size_t,unsigned char *),
00400   NTGetExecutionPath(char *,const size_t),
00401   NTGetModulePath(const char *,char *),
00402   NTReportEvent(const char *,const MagickBooleanType),
00403   NTReportException(const char *,const MagickBooleanType);
00404 
00405 extern MagickPrivate struct dirent
00406   *NTReadDirectory(DIR *);
00407 
00408 extern MagickPrivate unsigned char
00409   *NTRegistryKeyLookup(const char *),
00410   *NTResourceToBlob(const char *);
00411 
00412 extern MagickPrivate void
00413   *NTGetLibrarySymbol(void *,const char *),
00414   *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
00415   *NTOpenLibrary(const char *),
00416   NTSeekDirectory(DIR *,ssize_t);
00417 
00418 #endif /* !XS_VERSION */
00419 
00420 #endif /* MAGICKCORE_WINDOWS_SUPPORT */
00421 
00422 #if defined(__cplusplus) || defined(c_plusplus)
00423 }
00424 #endif /* !C++ */
00425 
00426 #endif /* !_MAGICKCORE_NT_BASE_H */