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