# nt-base.h

Go to the documentation of this file.

    00001 /*
    00002   Copyright 1999-2008 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 utility methods.
    00017 */
    00018 #ifndef _MAGICKCORE_NT_BASE_H
    00019 #define _MAGICKCORE_NT_BASE_H
    00020
    00021 #if defined(__cplusplus) || defined(c_plusplus)
    00022 extern "C" {
    00023 #endif
    00024
    00025 #include "magick/delegate.h"
    00026 #include "magick/exception.h"
    00027
    00028 #define WIN32_LEAN_AND_MEAN
    00029 #define VC_EXTRALEAN
    00030 #define _CRT_SECURE_NO_DEPRECATE  1
    00031 #include <windows.h>
    00032 #include <wchar.h>
    00033 #include <winuser.h>
    00034 #include <wingdi.h>
    00035 #include <io.h>
    00036 #include <process.h>
    00037 #include <errno.h>
    00038 #if defined(_DEBUG) && !defined(__MINGW32__)
    00039 #include <crtdbg.h>
    00040 #endif
    00041
    00042 #define PROT_READ  0x01
    00043 #define PROT_WRITE  0x02
    00044 #define MAP_SHARED  0x01
    00045 #define MAP_PRIVATE  0x02
    00046 #define MAP_ANONYMOUS  0x20
    00047 #define F_OK 0
    00048 #define R_OK 4
    00049 #define W_OK 2
    00050 #define RW_OK 6
    00051 #define _SC_PAGESIZE 1
    00052 #define _SC_PHYS_PAGES 2
    00053 #define _SC_OPEN_MAX 3
    00054 #if !defined(SSIZE_MAX)
    00055 #define SSIZE_MAX  0x7fffffffL
    00056 #endif
    00057
    00058 #if !defined(chsize)
    00059 # if defined(__BORLANDC__)
    00060 #   define chsize(file,length)  chsize(file,length)
    00061 # else
    00062 #   define chsize(file,length)  _chsize(file,length)
    00063 # endif
    00064 #endif
    00065
    00066 #if !defined(access)
    00067 #  define access(path,mode)  _access(path,mode)
    00068 #endif
    00069 #if !defined(chdir)
    00070 #  define chdir  _chdir
    00071 #endif
    00072 #if !defined(close)
    00073 #  define close  _close
    00074 #endif
    00075 #if !defined(closedir)
    00076 #  define closedir(directory)  NTCloseDirectory(directory)
    00077 #endif
    00078 #if !defined(fdopen)
    00079 #  define fdopen  _fdopen
    00080 #endif
    00081 #if !defined(fileno)
    00082 #  define fileno  _fileno
    00083 #endif
    00084 #if !defined(ftruncate)
    00085 #  define ftruncate(file,length)  NTTruncateFile(file,length)
    00086 #endif
    00087 #if !defined(getcwd)
    00088 #  define getcwd  _getcwd
    00089 #endif
    00090 #if !defined(getpid)
    00091 #  define getpid  _getpid
    00092 #endif
    00093 #if !defined(hypot)
    00094 #  define hypot  _hypot
    00095 #endif
    00096 #if !defined(isatty)
    00097 #  define isatty _isatty
    00098 #endif
    00099 #if !defined(MAGICKCORE_LTDL_DELEGATE)
    00100 #if !defined(lt_dlclose)
    00101 #  define lt_dlclose(handle)  NTCloseLibrary(handle)
    00102 #endif
    00103 #if !defined(lt_dlerror)
    00104 #  define lt_dlerror()  NTGetLibraryError()
    00105 #endif
    00106 #if !defined(lt_dlexit)
    00107 #  define lt_dlexit()  NTExitLibrary()
    00108 #endif
    00109 #if !defined(lt_dlinit)
    00110 #  define lt_dlinit()  NTInitializeLibrary()
    00111 #endif
    00112 #if !defined(lt_dlopen)
    00113 #  define lt_dlopen(filename)  NTOpenLibrary(filename)
    00114 #endif
    00115 #if !defined(lt_dlsetsearchpath)
    00116 #  define lt_dlsetsearchpath(path)  NTSetSearchPath(path)
    00117 #endif
    00118 #if !defined(lt_dlsym)
    00119 #  define lt_dlsym(handle,name)  NTGetLibrarySymbol(handle,name)
    00120 #endif
    00121 #endif
    00122 #if !defined(mmap)
    00123 #  define mmap(address,length,protection,access,file,offset) \
    00124   NTMapMemory(address,length,protection,access,file,offset)
    00125 #endif
    00126 #if !defined(msync)
    00127 #  define msync(address,length,flags)  NTSyncMemory(address,length,flags)
    00128 #endif
    00129 #if !defined(munmap)
    00130 #  define munmap(address,length)  NTUnmapMemory(address,length)
    00131 #endif
    00132 #if !defined(opendir)
    00133 #  define opendir(directory)  NTOpenDirectory(directory)
    00134 #endif
    00135 #if !defined(open)
    00136 #  define open  _open
    00137 #endif
    00138 #if !defined(pclose)
    00139 #  define pclose  _pclose
    00140 #endif
    00141 #if !defined(popen)
    00142 #  define popen  _popen
    00143 #endif
    00144 #if !defined(read)
    00145 #  define read  _read
    00146 #endif
    00147 #if !defined(readdir)
    00148 #  define readdir(directory)  NTReadDirectory(directory)
    00149 #endif
    00150 #if !defined(seekdir)
    00151 #  define seekdir(directory,offset)  NTSeekDirectory(directory,offset)
    00152 #endif
    00153 #if !defined(setmode)
    00154 #  define setmode  _setmode
    00155 #endif
    00156 #if !defined(strcasecmp)
    00157 #  define strcasecmp  _strcmpi
    00158 #endif
    00159 #if !defined(strncasecmp)
    00160 #  define strncasecmp  _strnicmp
    00161 #endif
    00162 #if !defined(sysconf)
    00163 #  define sysconf(name)  NTSystemConfiguration(name)
    00164 #endif
    00165 #if !defined(telldir)
    00166 #  define telldir(directory)  NTTellDirectory(directory)
    00167 #endif
    00168 #if !defined(tempnam)
    00169 #  define tempnam  _tempnam
    00170 #endif
    00171 #if !defined(vsnprintf)
    00172 #  define vsnprintf  _vsnprintf
    00173 #endif
    00174 #if !defined(write)
    00175 #  define write  _write
    00176 #endif
    00177
    00178 #if defined(_MT) && defined(__WINDOWS__)
    00179 #  define SAFE_GLOBAL  __declspec(thread)
    00180 #else
    00181 #  define SAFE_GLOBAL
    00182 #endif
    00183
    00184 #if defined(__BORLANDC__)
    00185 #undef _O_RANDOM
    00186 #define _O_RANDOM 0
    00187 #undef _O_SEQUENTIAL
    00188 #define _O_SEQUENTIAL 0
    00189 #undef _O_SHORT_LIVED
    00190 #define _O_SHORT_LIVED 0
    00191 #undef _O_TEMPORARY
    00192 #define _O_TEMPORARY 0
    00193 #endif
    00194
    00195 #if !defined(XS_VERSION)
    00196 struct dirent
    00197 {
    00198   char
    00199     d_name[2048];
    00200
    00201   int
    00202     d_namlen;
    00203 };
    00204
    00205 typedef struct _DIR
    00206 {
    00207   HANDLE
    00208     hSearch;
    00209
    00210   WIN32_FIND_DATA
    00211     Win32FindData;
    00212
    00213   BOOL
    00214     firsttime;
    00215
    00216   struct dirent
    00217     file_info;
    00218 } DIR;
    00219
    00220 typedef struct _NTMEMORYSTATUSEX
    00221 {
    00222   DWORD
    00223     dwLength,
    00224     dwMemoryLoad;
    00225
    00226   DWORDLONG
    00227     ullTotalPhys,
    00228     ullAvailPhys,
    00229     ullTotalPageFile,
    00230     ullAvailPageFile,
    00231     ullTotalVirtual,
    00232     ullAvailVirtual,
    00233     ullAvailExtendedVirtual;
    00234 } NTMEMORYSTATUSEX;
    00235
    00236 typedef UINT
    00237   (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
    00238
    00239 typedef UINT
    00240   (CALLBACK *LPFNDLLFUNC2)(NTMEMORYSTATUSEX *);
    00241
    00242 #endif
    00243
    00244 #if !defined(ssize_t) && !defined(__MINGW32__)
    00245 typedef long ssize_t;
    00246 #endif
    00247
    00248 extern MagickExport char
    00249   *NTGetLastError(void);
    00250
    00251 extern MagickExport const GhostscriptVectors
    00252   *NTGhostscriptDLLVectors(void);
    00253
    00254 #if !defined(MAGICKCORE_LTDL_DELEGATE)
    00255 extern MagickExport const char
    00256   *NTGetLibraryError(void);
    00257 #endif
    00258
    00259 #if !defined(XS_VERSION)
    00260 extern MagickExport char
    00261   *NTRegistryKeyLookup(const char *);
    00262
    00263 extern MagickExport const char
    00264   *NTGetLibraryError(void);
    00265
    00266 extern MagickExport DIR
    00267   *NTOpenDirectory(const char *);
    00268
    00269 extern MagickExport double
    00270   NTElapsedTime(void),
    00271   NTUserTime(void);
    00272
    00273 extern MagickExport int
    00274   Exit(int),
    00275   IsWindows95(),
    00276   NTCloseDirectory(DIR *),
    00277   NTCloseLibrary(void *),
    00278   NTControlHandler(void),
    00279   NTExitLibrary(void),
    00280   NTTruncateFile(int,off_t),
    00281   NTGhostscriptDLL(char *,int),
    00282   NTGhostscriptEXE(char *,int),
    00283   NTGhostscriptFonts(char *,int),
    00284   NTGhostscriptLoadDLL(void),
    00285   NTGhostscriptUnLoadDLL(void),
    00286   NTInitializeLibrary(void),
    00287   NTSetSearchPath(const char *),
    00288   NTSyncMemory(void *,size_t,int),
    00289   NTUnmapMemory(void *,size_t),
    00290   NTSystemCommand(const char *);
    00291
    00292 extern MagickExport long
    00293   NTSystemConfiguration(int),
    00294   NTTellDirectory(DIR *);
    00295
    00296 extern MagickExport MagickBooleanType
    00297   NTGetExecutionPath(char *,const size_t),
    00298   NTGetModulePath(const char *,char *),
    00299   NTReportEvent(const char *,const MagickBooleanType),
    00300   NTReportException(const char *,const MagickBooleanType);
    00301
    00302 extern MagickExport struct dirent
    00303   *NTReadDirectory(DIR *);
    00304
    00305 extern MagickExport unsigned char
    00306   *NTResourceToBlob(const char *);
    00307
    00308 extern MagickExport void
    00309   NTErrorHandler(const ExceptionType,const char *,const char *),
    00310   *NTGetLibrarySymbol(void *,const char *),
    00311   *NTMapMemory(char *,size_t,int,int,int,MagickOffsetType),
    00312   *NTOpenLibrary(const char *),
    00313   NTSeekDirectory(DIR *,long),
    00314   NTWarningHandler(const ExceptionType,const char *,const char *);
    00315
    00316 #endif /* !XS_VERSION */
    00317
    00318 #if defined(__cplusplus) || defined(c_plusplus)
    00319 }
    00320 #endif /* !C++ */
    00321
    00322 #endif /* !_MAGICKCORE_NT_BASE_H */