% December 1996 %
% %
% %
-% Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
+% 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. You may %
Include declarations.
*/
#include "magick/studio.h"
-#if defined(__WINDOWS__)
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
#include "magick/client.h"
#include "magick/log.h"
#include "magick/magick.h"
*lt_slsearchpath = (char *) NULL;
#endif
-static GhostscriptVectors
- gs_vectors;
+static GhostInfo
+ ghost_info;
static void
- *gs_dll_handle = (void *) NULL;
+ *ghost_handle = (void *) NULL;
\f
/*
External declarations.
*/
-#if !defined(__WINDOWS__)
+#if !defined(MAGICKCORE_WINDOWS_SUPPORT)
extern "C" BOOL WINAPI
DllMain(HINSTANCE handle,DWORD reason,LPVOID lpvReserved);
#endif
return(0);
}
\f
+#if !defined(__MINGW32__)
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% g e t t i m e o f d a y %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% The gettimeofday() method get the time of day.
+%
+% The format of the gettimeofday method is:
+%
+% int gettimeofday(struct timeval *time_value,struct timezone *time_zone)
+%
+% A description of each parameter follows:
+%
+% o time_value: the time value.
+%
+% o time_zone: the time zone.
+%
+*/
+MagickExport int gettimeofday (struct timeval *time_value,
+ struct timezone *time_zone)
+{
+#define EpochFiletime MagickLLConstant(116444736000000000)
+
+ static int
+ is_tz_set;
+
+ if (time_value != (struct timeval *) NULL)
+ {
+ FILETIME
+ file_time;
+
+ __int64
+ time;
+
+ LARGE_INTEGER
+ date_time;
+
+ GetSystemTimeAsFileTime(&file_time);
+ date_time.LowPart=file_time.dwLowDateTime;
+ date_time.HighPart=file_time.dwHighDateTime;
+ time=date_time.QuadPart;
+ time-=EpochFiletime;
+ time/=10;
+ time_value->tv_sec=(long) (time / 1000000);
+ time_value->tv_usec=(long) (time % 1000000);
+ }
+ if (time_zone != (struct timezone *) NULL)
+ {
+ if (is_tz_set == 0)
+ {
+ _tzset();
+ is_tz_set++;
+ }
+ time_zone->tz_minuteswest=_timezone/60;
+ time_zone->tz_dsttime=_daylight;
+ }
+ return(0);
+}
+#endif
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
static BOOL ControlHandler(DWORD type)
{
- AsynchronousDestroyMagickResources();
+ (void) type;
+ AsynchronousResourceComponentTerminus();
return(FALSE);
}
%
% The format of the NTErrorHandler method is:
%
-% void NTErrorHandler(const ExceptionType error,const char *reason,
+% void NTErrorHandler(const ExceptionType severity,const char *reason,
% const char *description)
%
% A description of each parameter follows:
%
-% o error: Specifies the numeric error category.
+% o severity: Specifies the numeric error category.
%
% o reason: Specifies the reason to display before terminating the
% program.
% o description: Specifies any description to the reason.
%
*/
-MagickExport void NTErrorHandler(const ExceptionType error,const char *reason,
- const char *description)
+MagickExport void NTErrorHandler(const ExceptionType severity,
+ const char *reason,const char *description)
{
char
buffer[3*MaxTextExtent],
*message;
+ (void) severity;
if (reason == (char *) NULL)
{
MagickCoreTerminus();
status=CryptReleaseContext(handle,0);
if (status == 0)
return(MagickFalse);
+#else
+ (void) random;
+ (void) length;
#endif
return(MagickTrue);
}
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% NTGhostscriptDLL() obtains the path to the latest Ghostscript DLL. The
-% method returns MagickFalse if a value is not obtained.
+% NTGhostscriptDLL() returns the path to the most recent Ghostscript version
+% DLL. The method returns TRUE on success otherwise FALSE.
%
% The format of the NTGhostscriptDLL method is:
%
-% int NTGhostscriptDLL(char *path, int length)
+% int NTGhostscriptDLL(char *path,int length)
%
% A description of each parameter follows:
%
-% o path: Pointer to buffer in which to return result.
+% o path: return the Ghostscript DLL path here.
%
-% o length: Length of buffer
+% o length: the buffer length.
%
*/
-#define GS_PRODUCT_AFPL "AFPL Ghostscript"
-#define GS_PRODUCT_ALADDIN "Aladdin Ghostscript"
-#define GS_PRODUCT_GNU "GNU Ghostscript"
-#define GS_PRODUCT_GPL "GPL Ghostscript"
-#define GS_MINIMUM_VERSION 550
-
-/*
- Get Ghostscript versions for given product.
- Store results starting at pver + 1 + offset.
- Returns total number of versions in pver.
-*/
-static int NTGhostscriptProductVersions(int *pver,int offset,
- const char *gs_productfamily)
+static int NTGetRegistryValue(HKEY root,const char *key,const char *name,
+ char *value,int *length)
{
- HKEY
- hkey,
- hkeyroot;
+ BYTE
+ byte,
+ *p;
DWORD
- cbData;
+ extent,
+ type;
- char
- key[MaxTextExtent],
- *p;
+ HKEY
+ hkey;
- int
- n = 0,
- ver;
+ LONG
+ status;
- (void) FormatMagickString(key,MaxTextExtent,"Software\\%s",gs_productfamily);
- hkeyroot = HKEY_LOCAL_MACHINE;
- if (RegOpenKeyExA(hkeyroot,key,0,KEY_READ,&hkey) == ERROR_SUCCESS)
+ /*
+ Get a registry value: key = root\\key, named value = name.
+ */
+ if (RegOpenKeyExA(root,key,0,KEY_READ,&hkey) != ERROR_SUCCESS)
+ return(1); /* no match */
+ p=(BYTE *) value;
+ type=REG_SZ;
+ extent=(*length);
+ if (p == (BYTE *) NULL)
+ p=(&byte); /* ERROR_MORE_DATA only if value is NULL */
+ status=RegQueryValueExA(hkey,(char *) name,0,&type,p,&extent);
+ RegCloseKey(hkey);
+ if (status == ERROR_SUCCESS)
{
- /*
- Now enumerate the keys.
- */
- cbData = sizeof(key) / sizeof(char);
- while (RegEnumKeyA(hkey,n,key,cbData) == ERROR_SUCCESS)
- {
- n++;
- ver = 0;
- p = key;
- while (*p && (*p!='.')) {
- ver = (ver * 10) + (*p - '0')*100;
- p++;
- }
- if (*p == '.')
- p++;
- if (*p)
- {
- ver+=10*(*p-'0');
- p++;
- }
- if (*p)
- ver+=(*p - '0');
- if ((n+offset) < pver[0])
- pver[n+offset]=ver;
- }
- RegCloseKey(hkey);
+ *length=extent;
+ return(0); /* return the match */
+ }
+ if (status == ERROR_MORE_DATA)
+ {
+ *length=extent;
+ return(-1); /* buffer not large enough */
}
- return(n+offset);
+ return(1); /* not found */
}
-/* Query registry to find which versions of Ghostscript are installed.
- * Return version numbers in an integer array.
- * On entry, the first element in the array must be the array size
- * in elements.
- * If all is well, TRUE is returned.
- * On exit, the first element is set to the number of Ghostscript
- * versions installed, and subsequent elements to the version
- * numbers of Ghostscript.
- * e.g. on entry {5, 0, 0, 0, 0}, on exit {3, 550, 600, 596, 0}
- * Returned version numbers may not be sorted.
- *
- * If Ghostscript is not installed at all, return FALSE
- * and set pver[0] to 0.
- * If the array is not large enough, return FALSE
- * and set pver[0] to the number of Ghostscript versions installed.
- */
-
-static int NTGhostscriptEnumerateVersions(int *pver)
+static int NTLocateGhostscript(const char **product_family,int *major_version,
+ int *minor_version)
{
int
- n;
-
- assert(pver != (int *) NULL);
- n=NTGhostscriptProductVersions(pver,0,GS_PRODUCT_AFPL);
- n=NTGhostscriptProductVersions(pver,n,GS_PRODUCT_ALADDIN);
- n=NTGhostscriptProductVersions(pver,n,GS_PRODUCT_GNU);
- n=NTGhostscriptProductVersions(pver,n,GS_PRODUCT_GPL);
- if (n >= pver[0])
- {
- pver[0]=n;
- return(FALSE); /* too small */
- }
- if (n == 0)
+ i;
+
+ MagickBooleanType
+ status;
+
+ static const char
+ *products[4] =
{
- pver[0] = 0;
- return(FALSE); /* not installed */
- }
- pver[0]=n;
- return(TRUE);
-}
+ "GPL Ghostscript",
+ "GNU Ghostscript",
+ "AFPL Ghostscript",
+ "Aladdin Ghostscript"
+ };
-/*
- Get a named registry value.
- Key = hkeyroot\\key, named value = name.
- name, ptr, plen and return values are the same as in gp_getenv();
-*/
-static int NTGetRegistryValue(HKEY hkeyroot,const char *key,const char *name,
- char *ptr,int *plen)
-{
- HKEY
- hkey;
+ /*
+ Find the most recent version of Ghostscript.
+ */
+ status=FALSE;
+ *product_family=NULL;
+ *major_version=5;
+ *minor_version=49; /* min version of Ghostscript is 5.50 */
+ for (i=0; i < (long) (sizeof(products)/sizeof(products[0])); i++)
+ {
+ char
+ key[MaxTextExtent];
- DWORD
- cbData,
- keytype;
+ HKEY
+ hkey,
+ root;
- BYTE
- b,
- *bptr = (BYTE *)ptr;
+ REGSAM
+ mode;
- LONG
- rc;
+ (void) FormatMagickString(key,MaxTextExtent,"SOFTWARE\\%s",products[i]);
+ root=HKEY_LOCAL_MACHINE;
+ mode=KEY_READ;
+#if defined(KEY_WOW64_32KEY)
+ mode|=KEY_WOW64_32KEY;
+#endif
+ if (RegOpenKeyExA(root,key,0,mode,&hkey) == ERROR_SUCCESS)
+ {
+ DWORD
+ extent;
- if (RegOpenKeyExA(hkeyroot,key,0,KEY_READ,&hkey) == ERROR_SUCCESS)
- {
- keytype = REG_SZ;
- cbData = *plen;
- if (bptr == (BYTE *)NULL)
- bptr=(&b); /* Registry API won't return ERROR_MORE_DATA */
- /* if ptr is NULL */
- rc=RegQueryValueExA(hkey,(char *) name,0,&keytype,bptr,&cbData);
- RegCloseKey(hkey);
- if (rc == ERROR_SUCCESS)
+ int
+ j;
+
+ /*
+ Now enumerate the keys.
+ */
+ extent=sizeof(key)/sizeof(char);
+ for (j=0; RegEnumKeyA(hkey,j,key,extent) == ERROR_SUCCESS; j++)
{
- *plen = cbData;
- return 0; /* found environment variable and copied it */
- } else if (rc == ERROR_MORE_DATA) {
- /* buffer wasn't large enough */
- *plen = cbData;
- return -1;
- }
+ int
+ major,
+ minor;
+
+ major=0;
+ minor=0;
+ if (sscanf(key,"%d.%d",&major,&minor) != 2)
+ continue;
+ if ((major > *major_version) || ((major == *major_version) &&
+ (minor > *minor_version)))
+ {
+ *product_family=products[i];
+ *major_version=major;
+ *minor_version=minor;
+ status=TRUE;
+ }
+ }
+ (void) RegCloseKey(hkey);
+ }
+ }
+ if (status == FALSE)
+ {
+ i=0;
+ *major_version=0;
+ *minor_version=0;
}
- return(1); /* not found */
+ (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),"Ghostscript (%s) "
+ "version %d.%02d",*product_family,*major_version,*minor_version);
+ return(status);
}
-static int NTGhostscriptGetProductString(int gs_revision,const char *name,
- char *ptr,int len,const char *gs_productfamily)
+static int NTGhostscriptGetString(const char *name,char *value,
+ const size_t length)
{
- /* If using Win32, look in the registry for a value with
- * the given name. The registry value will be under the key
- * HKEY_CURRENT_USER\Software\AFPL Ghostscript\N.NN
- * or if that fails under the key
- * HKEY_LOCAL_MACHINE\Software\AFPL Ghostscript\N.NN
- * where "AFPL Ghostscript" is actually gs_productfamily
- * and N.NN is obtained from gs_revision.
- */
-
char
- dotversion[MaxTextExtent],
key[MaxTextExtent];
int
- code,
- length;
+ i,
+ extent;
- DWORD version = GetVersion();
+ static const char
+ *product_family = (const char *) NULL;
- if (((HIWORD(version) & 0x8000) != 0) && ((HIWORD(version) & 0x4000) == 0))
- {
- /* Win32s */
- return FALSE;
- }
- (void) FormatMagickString(dotversion,MaxTextExtent,"%d.%02d",(int)
- (gs_revision/100),(int) (gs_revision % 100));
- (void) FormatMagickString(key,MaxTextExtent,"Software\\%s\\%s",
- gs_productfamily,dotversion);
- length = len;
- code = NTGetRegistryValue(HKEY_CURRENT_USER, key, name, ptr, &length);
- if ( code == 0 )
- return TRUE; /* found it */
- length = len;
- code = NTGetRegistryValue(HKEY_LOCAL_MACHINE, key, name, ptr, &length);
- if ( code == 0 )
- return TRUE; /* found it */
- return FALSE;
-}
+ static int
+ major_version=0,
+ minor_version=0;
-static int NTGhostscriptGetString(int gs_revision,const char *name,char *ptr,
- int len)
-{
- if (NTGhostscriptGetProductString(gs_revision,name,ptr,len,GS_PRODUCT_AFPL))
- return(TRUE);
- if (NTGhostscriptGetProductString(gs_revision,name,ptr,len,GS_PRODUCT_ALADDIN))
- return(TRUE);
- if (NTGhostscriptGetProductString(gs_revision,name,ptr,len,GS_PRODUCT_GNU))
- return(TRUE);
- if (NTGhostscriptGetProductString(gs_revision,name,ptr,len,GS_PRODUCT_GPL))
- return(TRUE);
- return(FALSE);
-}
+ struct
+ {
+ const HKEY
+ hkey;
-static int NTGetLatestGhostscript( void )
-{
- int
- count,
- i,
- version,
- *ver;
-
- DWORD version = GetVersion();
- if ( ((HIWORD(version) & 0x8000)!=0) && ((HIWORD(version) & 0x4000)==0) )
- return FALSE; /* win32s */
-
- count = 1;
- NTGhostscriptEnumerateVersions(&count);
- if (count < 1)
- return FALSE;
- ver=(int *) AcquireQuantumMemory(count+1UL,sizeof(*ver));
- if (ver == (int *)NULL)
+ const char
+ *name;
+ }
+ hkeys[2] =
+ {
+ { HKEY_CURRENT_USER, "HKEY_CURRENT_USER" },
+ { HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE" }
+ };
+
+ /*
+ Get a string from the installed Ghostscript.
+ */
+ *value='\0';
+ if (product_family == NULL)
+ (void) NTLocateGhostscript(&product_family,&major_version,&minor_version);
+ if (product_family == NULL)
return(FALSE);
- ver[0]=count+1;
- if (!NTGhostscriptEnumerateVersions(ver))
- {
- ver=(int *) RelinquishMagickMemory(ver);
- return FALSE;
- }
- version = 0;
- for (i=1; i<=ver[0]; i++) {
- if (ver[i] > version)
- version = ver[i];
+ (void) FormatMagickString(key,MaxTextExtent,"SOFTWARE\\%s\\%d.%02d",
+ product_family,major_version,minor_version);
+ for (i=0; i < (long) (sizeof(hkeys)/sizeof(hkeys[0])); i++)
+ {
+ extent=(int) length;
+ if (NTGetRegistryValue(hkeys[i].hkey,key,name,value,&extent) == 0)
+ {
+ (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+ "registry: \"%s\\%s\\%s\"=\"%s\"",hkeys[i].name,key,name,value);
+ return(TRUE);
+ }
+ (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+ "registry: \"%s\\%s\\%s\" (failed)",hkeys[i].name,key,name);
}
- ver=(int *) RelinquishMagickMemory(ver);
- return(version);
+ return(FALSE);
}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% %
-% %
-% %
-% N T G h o s t s c r i p t D L L %
-% %
-% %
-% %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% NTGhostscriptDLL() obtains the path to the latest Ghostscript DLL. The
-% method returns MagickFalse if a value is not obtained.
-%
-% The format of the NTGhostscriptDLL method is:
-%
-% int NTGhostscriptDLL( char *path, int length)
-%
-% A description of each parameter follows:
-%
-% o path: Pointer to path buffer to update
-%
-% o length: Allocation size of path buffer.
-%
-*/
-MagickExport int NTGhostscriptDLL(char *path, int length)
+MagickExport int NTGhostscriptDLL(char *path,int length)
{
- int
- version;
-
- char
- buf[256];
+ static char
+ dll[MaxTextExtent] = { "" };
*path='\0';
- version = NTGetLatestGhostscript();
- if ((version == FALSE) || (version < GS_MINIMUM_VERSION))
- return FALSE;
-
- if (!NTGhostscriptGetString(version, "GS_DLL", buf, sizeof(buf)))
- return FALSE;
-
- (void) CopyMagickString(path,buf,length+1);
+ if ((*dll == '\0') &&
+ (NTGhostscriptGetString("GS_DLL",dll,sizeof(dll)) == FALSE))
+ return(FALSE);
+ (void) CopyMagickString(path,dll,length);
return(TRUE);
}
\f
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% NTGhostscriptDLLVectors() returns a GhostscriptVectors structure containing
+% NTGhostscriptDLLVectors() returns a GhostInfo structure that includes
% function vectors to invoke Ghostscript DLL functions. A null pointer is
-% returned if there is an error with loading the DLL or retrieving the
+% returned if there is an error when loading the DLL or retrieving the
% function vectors.
%
% The format of the NTGhostscriptDLLVectors method is:
%
-% const GhostscriptVectors *NTGhostscriptDLLVectors(void)
+% const GhostInfo *NTGhostscriptDLLVectors(void)
%
*/
-MagickExport const GhostscriptVectors *NTGhostscriptDLLVectors( void )
+MagickExport const GhostInfo *NTGhostscriptDLLVectors(void)
{
- if (NTGhostscriptLoadDLL())
- return(&gs_vectors);
- return((GhostscriptVectors*) NULL);
+ if (NTGhostscriptLoadDLL() == FALSE)
+ return((GhostInfo *) NULL);
+ return(&ghost_info);
}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% NTGhostscriptEXE() obtains the path to the latest Ghostscript executable.
-% The method returns MagickFalse if a value is not obtained.
+% The method returns FALSE if a full path value is not obtained and returns
+% a default path of gswin32c.exe.
%
% The format of the NTGhostscriptEXE method is:
%
-% int NTGhostscriptEXE(char *path, int length)
+% int NTGhostscriptEXE(char *path,int length)
%
% A description of each parameter follows:
%
-% o path: pointer to buffer in which to return result.
+% o path: return the Ghostscript executable path here.
%
% o length: length of buffer.
%
*/
MagickExport int NTGhostscriptEXE(char *path,int length)
{
- char
- buffer[MaxTexytExtent],
+ register char
*p;
- int
- version;
+ static char
+ program[MaxTextExtent] = { "" };
(void) CopyMagickString(path,"gswin32c.exe",length);
- version=NTGetLatestGhostscript();
- if ((version == FALSE) || (version < GS_MINIMUM_VERSION))
- return(FALSE);
- if (NTGhostscriptGetString(version,"GS_DLL",buffer,sizeof(buffer)) == 0)
+ if ((*program == '\0') &&
+ (NTGhostscriptGetString("GS_DLL",program,sizeof(program)) == FALSE))
return(FALSE);
- p=strrchr(buffer, '\\');
- if (p == (char *) NULL)
- return(FALSE);
- p++;
- *p='\0';
- (void) CopyMagickString(p,path,sizeof(buffer)-strlen(buffer));
- (void) CopyMagickString(path,buffer,length);
+ p=strrchr(program,'\\');
+ if (p != (char *) NULL)
+ {
+ p++;
+ *p='\0';
+ (void) ConcatenateMagickString(program,"gswin32c.exe",sizeof(program));
+ }
+ (void) CopyMagickString(path,program,length);
return(TRUE);
}
\f
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% NTGhostscriptFonts() gets the path to the Ghostscript fonts. The method
-% returns MagickFalse if an error occurs otherwise MagickTrue.
+% NTGhostscriptFonts() obtains the path to the Ghostscript fonts. The method
+% returns FALSE if it cannot determine the font path.
%
% The format of the NTGhostscriptFonts method is:
%
-% int NTGhostscriptFonts(char *path,int length)
+% int NTGhostscriptFonts(char *path, int length)
%
% A description of each parameter follows:
%
-% o path: Pointer to buffer in which to return result.
+% o path: return the font path here.
%
-% o length: Length of buffer.
+% o length: length of the path buffer.
%
*/
MagickExport int NTGhostscriptFonts(char *path,int length)
buffer[MaxTextExtent],
filename[MaxTextExtent];
- int
- version;
-
register char
*p,
*q;
*path='\0';
- version=NTGetLatestGhostscript();
- if ((version == FALSE) || (version < GS_MINIMUM_VERSION))
- return(FALSE);
- if (!NTGhostscriptGetString(version,"GS_LIB",buffer,MaxTextExtent))
+ if (NTGhostscriptGetString("GS_LIB",buffer,MaxTextExtent) == FALSE)
return(FALSE);
for (p=buffer-1; p != (char *) NULL; p=strchr(p+1,DirectoryListSeparator))
{
q=strchr(path,DirectoryListSeparator);
if (q != (char *) NULL)
*q='\0';
- FormatMagickString(filename,MaxTextExtent,"%s%sfonts.dir",path,
+ (void) FormatMagickString(filename,MaxTextExtent,"%s%sfonts.dir",path,
DirectorySeparator);
if (IsPathAccessible(filename) != MagickFalse)
return(TRUE);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% NTGhostscriptLoadDLL() attempts to load the Ghostscript DLL and returns
-% MagickTrue if it succeeds.
+% TRUE if it succeeds.
%
% The format of the NTGhostscriptLoadDLL method is:
%
MagickExport int NTGhostscriptLoadDLL(void)
{
char
- module_path[MaxTextExtent];
+ path[MaxTextExtent];
- if (gs_dll_handle != (void *) NULL)
- return(MagickTrue);
- if (NTGhostscriptDLL(module_path,sizeof(module_path)) == MagickFalse)
- return(MagickFalse);
- gs_dll_handle=NTOpenLibrary(module_path);
- if (gs_dll_handle == (void *) NULL)
- return(MagickFalse);
- (void) ResetMagickMemory((void *) &gs_vectors,0,sizeof(GhostscriptVectors));
- gs_vectors.exit=(int (MagickDLLCall *)
- (gs_main_instance *)) NTGetLibrarySymbol(gs_dll_handle,"gsapi_exit");
- gs_vectors.init_with_args=(int (MagickDLLCall *)
- (gs_main_instance *,int,char **))
- (NTGetLibrarySymbol(gs_dll_handle,"gsapi_init_with_args"));
- gs_vectors.new_instance=(int (MagickDLLCall *) (gs_main_instance **,void *))
- (NTGetLibrarySymbol(gs_dll_handle,"gsapi_new_instance"));
- gs_vectors.run_string=(int (MagickDLLCall *)
- (gs_main_instance *,const char *,int,int *))
- (NTGetLibrarySymbol(gs_dll_handle,"gsapi_run_string"));
- gs_vectors.delete_instance=(void (MagickDLLCall *)(gs_main_instance *))
- (NTGetLibrarySymbol(gs_dll_handle,"gsapi_delete_instance"));
- if ((gs_vectors.exit == NULL) ||
- (gs_vectors.init_with_args == NULL) ||
- (gs_vectors.new_instance == NULL) ||
- (gs_vectors.run_string == NULL) ||
- (gs_vectors.delete_instance == NULL))
- return(MagickFalse);
- return(MagickTrue);
+ if (ghost_handle != (void *) NULL)
+ return(TRUE);
+ if (NTGhostscriptDLL(path,sizeof(path)) == FALSE)
+ return(FALSE);
+ ghost_handle=lt_dlopen(path);
+ if (ghost_handle == (void *) NULL)
+ return(FALSE);
+ (void) ResetMagickMemory((void *) &ghost_info,0,sizeof(GhostInfo));
+ ghost_info.exit=(int (MagickDLLCall *)(gs_main_instance*))
+ lt_dlsym(ghost_handle,"gsapi_exit");
+ ghost_info.init_with_args=(int (MagickDLLCall *)(gs_main_instance *,int,
+ char **)) (lt_dlsym(ghost_handle,"gsapi_init_with_args"));
+ ghost_info.new_instance=(int (MagickDLLCall *)(gs_main_instance **,void *)) (
+ lt_dlsym(ghost_handle,"gsapi_new_instance"));
+ ghost_info.run_string=(int (MagickDLLCall *)(gs_main_instance *,const char *,
+ int,int *)) (lt_dlsym(ghost_handle,"gsapi_run_string"));
+ ghost_info.delete_instance=(void (MagickDLLCall *) (gs_main_instance *)) (
+ lt_dlsym(ghost_handle,"gsapi_delete_instance"));
+ if ((ghost_info.exit == NULL) || (ghost_info.init_with_args == NULL) ||
+ (ghost_info.new_instance == NULL) || (ghost_info.run_string == NULL) ||
+ (ghost_info.delete_instance == NULL))
+ return(FALSE);
+ return(TRUE);
}
\f
/*
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% NTGhostscriptUnLoadDLL() unloads the Ghostscript DLL if it is loaded.
+% NTGhostscriptUnLoadDLL() unloads the Ghostscript DLL and returns TRUE if
+% it succeeds.
%
% The format of the NTGhostscriptUnLoadDLL method is:
%
*/
MagickExport int NTGhostscriptUnLoadDLL(void)
{
- if (gs_dll_handle == (void *) NULL)
- return(MagickFalse);
- NTCloseLibrary(gs_dll_handle);
- gs_dll_handle=(void *) NULL;
- (void) ResetMagickMemory((void *) &gs_vectors,0,sizeof(GhostscriptVectors));
- return(MagickTrue);
+ int
+ status;
+
+ if (ghost_handle == (void *) NULL)
+ return(FALSE);
+ status=lt_dlclose(ghost_handle);
+ ghost_handle=(void *) NULL;
+ (void) ResetMagickMemory((void *) &ghost_info,0,sizeof(GhostInfo));
+ return(status);
}
\f
/*
void
*map;
+ (void) address;
access_mode=0;
file_handle=INVALID_HANDLE_VALUE;
low_length=(DWORD) (length & 0xFFFFFFFFUL);
MaxTextExtent);
if (length >= MaxTextExtent)
return((DIR *) NULL);
- entry=(DIR *) AcquireMagickMemory(sizeof(DIR));
+ entry=(DIR *) AcquireAlignedMemory(1,sizeof(DIR));
if (entry != (DIR *) NULL)
{
entry->firsttime=TRUE;
*/
MagickExport void NTSeekDirectory(DIR *entry,long position)
{
+ (void) position;
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(entry != (DIR *) NULL);
}
*/
MagickExport int NTSyncMemory(void *address,size_t length,int flags)
{
+ (void) flags;
if (FlushViewOfFile(address,length) == MagickFalse)
return(-1);
return(0);
%
% The format of the NTSystemCommand method is:
%
-% int NTSystemCommand(const char *command)
+% int NTSystemCommand(MagickFalse,const char *command)
%
% A description of each parameter follows:
%
*/
MagickExport int NTUnmapMemory(void *map,size_t length)
{
+ (void) length;
if (UnmapViewOfFile(map) == 0)
return(-1);
return(0);
%
% The format of the NTWarningHandler method is:
%
-% void NTWarningHandler(const ExceptionType warning,const char *reason,
+% void NTWarningHandler(const ExceptionType severity,const char *reason,
% const char *description)
%
% A description of each parameter follows:
%
-% o warning: Specifies the numeric warning category.
+% o severity: Specifies the numeric warning category.
%
% o reason: Specifies the reason to display before terminating the
% program.
% o description: Specifies any description to the reason.
%
*/
-MagickExport void NTWarningHandler(const ExceptionType warning,
+MagickExport void NTWarningHandler(const ExceptionType severity,
const char *reason,const char *description)
{
char
buffer[2*MaxTextExtent];
+ (void) severity;
if (reason == (char *) NULL)
return;
if (description == (char *) NULL)