http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=28359
diff --git a/MagickCore/Make.com b/MagickCore/Make.com
new file mode 100755
index 0000000..411a67f
--- /dev/null
+++ b/MagickCore/Make.com
@@ -0,0 +1,189 @@
+$!
+$! Make ImageMagick image utilities for VMS.
+$!
+$ define/nolog MAGICKCORE [-.magickcore]
+$ define/nolog MAGICKWAND [-.magickwand]
+$ copy version.h_vms version.h
+$ copy config.h_vms magick-baseconfig.h
+$ copy xwdfile.h_vms xwdfile.h
+$
+$if (f$trnlnm("X11") .eqs. "") then define/nolog X11 decw$include:
+$compile_options="/nodebug/optimize"
+$if (f$search("sys$system:decc$compiler.exe") .nes. "") 
+$then     ! VAX with DEC C
+$  compile_options="/decc/nodebug/optimize/warning=(disable=rightshiftovr)"
+$else     ! VAX with VAX C
+$define/nolog lnk$library sys$library:vaxcrtl
+$define/nolog sys sys$share
+$endif
+$if (f$getsyi("HW_MODEL") .gt. 1023)
+$then     ! Alpha with DEC C
+$  define/nolog sys decc$library_include
+$  compile_options="/nodebug/optimize/prefix=all/warning=disable=(rightshiftovr,ptrmismatch,cvtdiftypes,SIZFUNVOIDTYP)/name=(as_is,short)/float=ieee
+$endif
+$
+$write sys$output "Making MagickCore..."
+$call Make accelerate.c
+$call Make animate.c
+$call Make annotate.c
+$call Make artifact.c
+$call Make attribute.c
+$call Make blob.c
+$call Make cache.c
+$call Make cache-view.c
+$call Make channel.c
+$call Make cipher.c
+$call Make client.c
+$call Make coder.c
+$call Make color.c
+$call Make colormap.c
+$call Make colorspace.c
+$call Make compare.c
+$call Make composite.c
+$call Make compress.c
+$call Make configure.c
+$call Make constitute.c
+$call Make decorate.c
+$call Make delegate.c
+$call Make deprecate.c
+$call Make display.c
+$call Make distort.c
+$call Make distribute-cache.c
+$call Make draw.c
+$call Make effect.c
+$call Make enhance.c
+$call Make exception.c
+$call Make feature.c
+$call Make fourier.c
+$call Make fx.c
+$call Make gem.c
+$call Make geometry.c
+$call Make hashmap.c
+$call Make histogram.c
+$call Make identify.c
+$call Make image.c
+$call Make image-view.c
+$call Make layer.c
+$call Make list.c
+$call Make locale.c
+$call Make log.c
+$call Make magic.c
+$call Make magick.c
+$call Make matrix.c
+$call Make memory.c
+$call Make mime.c
+$call Make module.c
+$call Make monitor.c
+$call Make montage.c
+$call Make morphology.c
+$call Make option.c
+$call Make paint.c
+$call Make pixel.c
+$call Make policy.c
+$call Make prepress.c
+$call Make property.c
+$call Make PreRvIcccm.c
+$call Make profile.c
+$call Make quantize.c
+$call Make quantum.c
+$call Make quantum-export.c
+$call Make quantum-import.c
+$call Make random.c
+$call Make registry.c
+$call Make resample.c
+$call Make resize.c
+$call Make resource.c
+$call Make segment.c
+$call Make semaphore.c
+$call Make shear.c
+$call Make signature.c
+$call Make splay-tree.c
+$call Make static.c
+$call Make statistic.c
+$call Make stream.c
+$call Make string.c
+$call Make thread.c
+$call Make timer.c
+$call Make token.c
+$call Make transform.c
+$call Make threshold.c
+$call Make type.c
+$call Make utility.c
+$call Make version.c
+$call Make vision.c
+$call Make vms.c
+$call Make widget.c
+$call Make xml-tree.c
+$call Make xwindow.c
+$ set default [-.filters]
+$ call Make analyze.c
+$ set default [-.magickwand]
+$ call Make drawing-wand.c
+$ call Make pixel-wand.c
+$ call Make wand-view.c
+$ call Make conjure.c
+$ call Make convert.c
+$ call Make import.c
+$ call Make mogrify.c
+$ copy animate.c animate-wand.c
+$ call make animate-wand.c
+$ copy compare.c compare-wand.c
+$ call make compare-wand.c
+$ copy composite.c composite-wand.c
+$ call make composite-wand.c
+$ copy display.c display-wand.c
+$ call make display-wand.c
+$ copy identify.c identify-wand.c
+$ call make identify-wand.c
+$ copy montage.c montage-wand.c
+$ call make montage-wand.c
+$ call Make magick-wand.c
+$ call Make wand.c
+$ call Make magick-image.c
+$ set default [-.magickcore]
+$ deass magickcore
+$ deass magickwand
+$library/create libMagick.olb -
+  accelerate, animate, annotate, artifact, attribute, blob, cache, cache-view, -
+  channel, cipher, client, coder, color, colormap, colorspace, compare, -
+  composite, compress, configure, constitute, decorate, delegate, deprecate, -
+  display, distort, draw, effect, enhance, exception, feature, fourier, fx, -
+  gem, geometry, hashmap, histogram, identify, image, image-view, layer, list, -
+  locale, log, magic, magick, matrix, memory, mime, module, monitor, montage, -
+  morphology, option, paint, pixel, PreRvIcccm, profile, quantize, quantum, -
+  quantum-export, quantum-import,random, registry, resample, resize, resource, -
+  segment, semaphore, shear, signature, splay-tree, static, stream, string, -
+  thread, timer, token, transform, threshold, type, utility, version, vms, -
+  widget, xwindow, statistic, policy, prepress, property, xml-tree, -
+   distribute-cache, vision,-
+	[-.filters]analyze,[-.magickwand]drawing-wand, pixel-wand, wand-view, conjure, -
+  convert,import, mogrify, animate-wand, compare-wand, composite-wand, -
+  display-wand,identify-wand,montage-wand,magick-wand,wand,magick-image
+$exit
+$
+$Make: subroutine
+$!
+$! Primitive MMS hack for DCL.
+$!
+$if (p1 .eqs. "") then exit
+$source_file=f$search(f$parse(p1,".c"))
+$if (source_file .nes. "")
+$then
+$  object_file=f$parse(source_file,,,"name")+".obj"
+$  object_file=f$search( object_file )
+$  if (object_file .nes. "")
+$  then
+$    object_time=f$file_attribute(object_file,"cdt")
+$    source_time=f$file_attribute(source_file,"cdt")
+$    if (f$cvtime(object_time) .lts. f$cvtime(source_time)) then -
+$      object_file=""
+$  endif
+$  if (object_file .eqs. "")
+$  then
+$    write sys$output "Compiling ",p1
+$    cc'compile_options'/include_directory=([-],[-.magickcore],[-.jpeg],[-.png], -
+       [-.tiff],[-.ttf],[-.zlib]) 'source_file'  
+$  endif
+$endif
+$exit
+$endsubroutine
diff --git a/MagickCore/blob.c b/MagickCore/blob.c
old mode 100644
new mode 100755
index a95c22d..1833486
--- a/MagickCore/blob.c
+++ b/MagickCore/blob.c
@@ -40,6 +40,10 @@
 /*
   Include declarations.
 */
+#ifdef __VMS
+#include  <types.h>
+#include  <mman.h>
+#endif
 #include "MagickCore/studio.h"
 #include "MagickCore/blob.h"
 #include "MagickCore/blob-private.h"
diff --git a/MagickCore/config.h_vms b/MagickCore/config.h_vms
new file mode 100755
index 0000000..c955800
--- /dev/null
+++ b/MagickCore/config.h_vms
@@ -0,0 +1,289 @@
+/* magick/config.h.in.  Generated automatically from configure.in by autoheader.  */
+
+/* Define if you don't have vprintf but do have _doprnt.  */
+#undef MAGICKCORE_HAVE_DOPRNT
+
+/* Define if you have a working `mmap' system call.  */
+#define MAGICKCORE_HAVE_MMAP 1
+
+/* Define if you have the vprintf function.  */
+#define MAGICKCORE_HAVE_VPRINTF 1
+
+/* Define as __inline if that's what the C compiler calls it.  */
+#define MAGICKCORE_inline __inline
+
+/* Define as the return type of signal handlers (int or void).  */
+#define MAGICKCORE_RETSIGTYPE void
+
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly.  */
+#undef MAGICKCORE_STAT_MACROS_BROKEN
+
+/* Define if you have the ANSI C header files.  */
+#define MAGICKCORE_STDC_HEADERS 1
+
+/* Define if you can safely include both <sys/time.h> and <time.h>.  */
+#define MAGICKCORE_TIME_WITH_SYS_TIME 1
+
+/* Define if your processor stores words with the most significant
+   byte first (like Motorola and SPARC, unlike Intel and VAX).  */
+#undef MAGICKCORE_WORDS_BIGENDIAN
+
+/* Define if the X Window System is missing or not being used.  */
+#undef MAGICKCORE_X_DISPLAY_MISSING
+
+/* The number of bytes in a int.  */
+#define MAGICKCORE_SIZEOF_INT 4
+
+/* The number of bytes in a long long.  */
+#define MAGICKCORE_SIZEOF_UNSIGNED_LONG_LONG 8
+
+/* Define if you have the getcwd function.  */
+#define MAGICKCORE_HAVE_GETCWD 1
+
+/* Define if you have the getexecname function.  */
+#undef MAGICKCORE_HAVE_GETEXECNAME
+
+/* Define if you have the getpagesize function.  */
+#define MAGICKCORE_HAVE_GETPAGESIZE 1
+
+/* Define if you have the gettimeofday function.  */
+#define MAGICKCORE_HAVE_GETTIMEOFDAY 1
+
+/* Define if you have the mkdir function.  */
+#define MAGICKCORE_HAVE_MKDIR 1
+
+/* Define if you have the poll function.  */
+#undef MAGICKCORE_HAVE_POLL
+
+/* Define if you have the select function.  */
+#undef MAGICKCORE_HAVE_SELECT
+
+/* Define if you have the snprintf function.  */
+#undef MAGICKCORE_HAVE_SNPRINTF
+
+/* Define if you have the strchr function.  */
+#define MAGICKCORE_HAVE_STRCHR 1
+
+/* Define if you have the strerror function.  */
+#define MAGICKCORE_HAVE_STRERROR 1
+
+/* Define if you have the strtol function.  */
+#define MAGICKCORE_HAVE_STRTOL 1
+
+/* Define if you have the sysconf function.  */
+#define MAGICKCORE_HAVE_SYSCONF 1
+
+/* Define if you have the tempnam function.  */
+#define MAGICKCORE_HAVE_TEMPNAM 1
+
+/* Define if you have the vsnprintf function.  */
+#undef MAGICKCORE_HAVE_VSNPRINTF
+
+/* Define if you have the <dirent.h> header file.  */
+#define MAGICKCORE_HAVE_DIRENT_H 1
+
+/* Define if you have the <errno.h> header file.  */
+#define MAGICKCORE_HAVE_ERRNO_H 1
+
+/* Define if you have the <fcntl.h> header file.  */
+#define MAGICKCORE_HAVE_FCNTL_H 1
+
+/* Define if you have the <ft2build.h> header file.  */
+#define MAGICKCORE_HAVE_FT2BUILD_H 1
+
+/* Define if you have the <freetype/freetype.h> header file.  */
+#define MAGICKCORE_HAVE_FREETYPE_FREETYPE_H 1
+
+/* Define if you have the <hdf.h> header file.  */
+#define MAGICKCORE_HAVE_HDF_H 1
+
+/* Define if you have the <hdf/hdf.h> header file.  */
+#undef MAGICKCORE_HAVE_HDF_HDF_H
+
+/* Define if you have the <libxml/xml-error.h> header file.  */
+#undef MAGICKCORE_HAVE_LIBXML_XML_ERROR_H
+
+/* Define if you have the <libxml/xmlerror.h> header file.  */
+#undef MAGICKCORE_HAVE_LIBXML_XMLERROR_H
+
+/* Define if you have the <jp2conf.h> header file.  */
+#undef MAGICKCORE_HAVE_JP2CONF_H
+
+/* Define if you have the <malloc.h> header file.  */
+#undef MAGICKCORE_HAVE_MALLOC_H
+
+/* Define if you have the <math.h> header file.  */
+#define MAGICKCORE_HAVE_MATH_H 1
+
+/* Define if you have the <memory.h> header file.  */
+#define MAGICKCORE_HAVE_MEMORY_H 1
+
+/* Define if you have the <ndir.h> header file.  */
+#undef MAGICKCORE_HAVE_NDIR_H
+
+/* Define if you have the <pwd.h> header file.  */
+#define MAGICKCORE_HAVE_PWD_H 1
+
+/* Define if you have the <stdarg.h> header file.  */
+#define MAGICKCORE_HAVE_STDARG_H 1
+
+/* Define if you have the <stdint.h> header file.  */
+#undef MAGICKCORE_HAVE_STDINT_H
+
+/* Define if you have the <string.h> header file.  */
+#define MAGICKCORE_HAVE_STRING_H 1
+
+/* Define if you have the <sys/dir.h> header file.  */
+#undef MAGICKCORE_HAVE_SYS_DIR_H
+
+/* Define if you have the <sys/ndir.h> header file.  */
+#undef MAGICKCORE_HAVE_SYS_NDIR_H
+
+/* Define if you have the <sys/select.h> header file.  */
+#define MAGICKCORE_HAVE_SYS_SELECT_H 1
+
+/* Define if you have the <sys/stat.h> header file.  */
+#define MAGICKCORE_HAVE_SYS_STAT_H 1
+
+/* Define if you have the <sys/time.h> header file.  */
+#define MAGICKCORE_HAVE_SYS_TIME_H 1
+
+/* Define if you have the <sys/types.h> header file.  */
+#define MAGICKCORE_HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <tiffconf.h> header file.  */
+#define MAGICKCORE_HAVE_TIFFCONF_H 1
+
+/* Define if you have the <unistd.h> header file.  */
+#define MAGICKCORE_HAVE_UNISTD_H 1
+
+/* Define if you have the <varargs.h> header file.  */
+#undef MAGICKCORE_HAVE_VARARGS_H
+
+/* Define if using libltdl to create dynamically loadable modules */
+#undef MAGICKCORE_LTDL_DELEGATE
+
+/* Location of coder modules */
+#undef MAGICKCORE_MagickModulesPath
+
+/* Number of bits in a pixel Quantum (8 or 16) */
+#define MAGICKCORE_QUANTUM_DEPTH 16
+
+/* Pixel cache threshold (default 2047MB) */
+#undef MAGICKCORE_PixelCacheThreshold
+
+/* Define to specify default TrueType font path. */
+#undef MAGICKCORE_TT_FONT_PATH
+
+/* Location of X11 configure files */
+#undef MAGICKCORE_X11ConfigurePath
+
+/* Define if you have Posix thread methods. */
+#undef MAGICKCORE_HasPTHREADS
+
+/* Define if you have zlib compression library */
+#define MAGICKCORE_ZLIB_DELEGATE 1
+
+/* Define if you have the bzip2 library */
+#define MAGICKCORE_BZLIB_DELEGATE 1
+
+/* Define if you have X11 library */
+#define MAGICKCORE_X11_DELEGATE 1
+
+/* X11 server supports shared memory extension */
+#undef MAGICKCORE_HAVE_SHARED_MEMORY
+
+/* X11 server supports shape extension */
+#undef MAGICKCORE_HAVE_SHAPE
+
+/* Define if you have Display Postscript */
+#undef MAGICKCORE_DPS_DELEGATE
+
+/* Define if you have FlashPIX library */
+#undef MAGICKCORE_FPX_DELEGATE
+
+/* Define if you have LCMS library */
+#undef MAGICKCORE_LCMS_DELEGATE
+
+/* Define if you have PNG library */
+#define MAGICKCORE_PNG_DELEGATE 1
+
+/* Define if you have JPEG library */
+#define MAGICKCORE_JPEG_DELEGATE 1
+
+/* Define if you have JPEG version 2 Jasper library */
+#define MAGICKCORE_JP2_DELEGATE 1
+/* #define MAGICKCORE_LIBOPENJP2_DELEGATE 1 */
+
+/* Define if you have Ghostscript library */
+#undef MAGICKCORE_GS_DELEGATE
+
+/* Define if you have FreeType (TrueType font) library */
+#define MAGICKCORE_FREETYPE_DELEGATE 1
+
+/* Define if you have TIFF library */
+#define MAGICKCORE_TIFF_DELEGATE 1
+
+/* Define if you have HDF4 library */
+#define MAGICKCORE_HDF_DELEGATE 1
+
+/* Define if you have JBIG library */
+#define MAGICKCORE_JBIG_DELEGATE 1
+
+/* Define if you have XML library */
+#undef MAGICKCORE_XML_DELEGATE
+
+/* Define if you have WMF library */
+#undef MAGICKCORE_WMF_DELEGATE
+
+/* Define if you have sys_errlist in libc */
+#undef MAGICKCORE_HAVE_SYS_ERRLIST
+
+/* Define directory where ImageMagick/delegates.xml lives. */
+#undef MAGICKCORE_MagickConfigurePath
+
+/* define MAGICKCORE_if bool is a built-in type */
+#define MAGICKCORE_HAVE_BOOL 1
+
+/* define MAGICKCORE_if the compiler supports const_cast<> */
+#undef MAGICKCORE_HAVE_CONST_CAST
+
+/* define MAGICKCORE_if the compiler supports default template parameters */
+#undef MAGICKCORE_HAVE_DEFAULT_TEMPLATE_PARAMETERS
+
+/* define MAGICKCORE_if the compiler supports exceptions */
+#undef MAGICKCORE_HAVE_EXCEPTIONS
+
+/* define MAGICKCORE_if the compiler implements namespaces */
+#undef MAGICKCORE_HAVE_NAMESPACES
+
+/* define MAGICKCORE_if the compiler supports the explicit keyword */
+#undef MAGICKCORE_HAVE_EXPLICIT
+
+/* define MAGICKCORE_if the compiler supports ISO C++ standard library */
+#define MAGICKCORE_HAVE_STD 1
+
+/* define MAGICKCORE_if the compiler supports Standard Template Library */
+#define MAGICKCORE_HAVE_STL 1
+
+/* define MAGICKCORE_if the compiler supports the mutable keyword */
+#undef MAGICKCORE_HAVE_MUTABLE
+
+/* define MAGICKCORE_if the compiler accepts the new for scoping rules */
+#undef MAGICKCORE_HAVE_NEW_FOR_SCOPING
+
+/* define MAGICKCORE_if the compiler supports static_cast<> */
+#undef MAGICKCORE_HAVE_STATIC_CAST
+
+/* define MAGICKCORE_if the compiler supports basic templates */
+#undef MAGICKCORE_HAVE_TEMPLATES
+
+#define MAGICKCORE_LIBRARY_RELATIVE_PATH "/"
+
+#define MAGICKCORE_HAVE_MKSTEMP 1
+
+#define round nint
+
+#define MAGICKCORE_CIPHER_SUPPORT 1
+
+#define MAGICKCORE_HDRI_ENABLE 1
diff --git a/MagickCore/configure.c b/MagickCore/configure.c
old mode 100644
new mode 100755
index 99ac01b..a6f5568
--- a/MagickCore/configure.c
+++ b/MagickCore/configure.c
@@ -830,7 +830,7 @@
     home=GetEnvironmentValue("MAGICK_HOME");
     if (home != (char *) NULL)
       {
-#if !defined(MAGICKCORE_POSIX_SUPPORT)
+#if !defined(MAGICKCORE_POSIX_SUPPORT) || defined( __VMS )
         (void) FormatLocaleString(path,MagickPathExtent,"%s%s",home,
           DirectorySeparator);
         (void) AppendValueToLinkedList(paths,ConstantString(path));
@@ -850,7 +850,7 @@
     }
   if (*GetClientPath() != '\0')
     {
-#if !defined(MAGICKCORE_POSIX_SUPPORT)
+#if !defined(MAGICKCORE_POSIX_SUPPORT) || defined( __VMS )
       (void) FormatLocaleString(path,MagickPathExtent,"%s%s",GetClientPath(),
         DirectorySeparator);
       (void) AppendValueToLinkedList(paths,ConstantString(path));
diff --git a/MagickCore/distribute-cache.c b/MagickCore/distribute-cache.c
index d206206..b4c1d67 100644
--- a/MagickCore/distribute-cache.c
+++ b/MagickCore/distribute-cache.c
@@ -1,1534 +1,1545 @@
-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%    DDDD    IIIII   SSSSS  TTTTT  RRRR   IIIII  BBBB   U   U  TTTTT  EEEEE   %

-%    D   D     I     SS       T    R   R    I    B   B  U   U    T    E       %

-%    D   D     I      SSS     T    RRRR     I    BBBB   U   U    T    EEE     %

-%    D   D     I        SS    T    R R      I    B   B  U   U    T    E       %

-%    DDDDA   IIIII   SSSSS    T    R  R   IIIII  BBBB    UUU     T    EEEEE   %

-%                                                                             %

-%                      CCCC   AAA    CCCC  H   H  EEEEE                       %

-%                     C      A   A  C      H   H  E                           %

-%                     C      AAAAA  C      HHHHH  EEE                         %

-%                     C      A   A  C      H   H  E                           %

-%                      CCCC  A   A   CCCC  H   H  EEEEE                       %

-%                                                                             %

-%                                                                             %

-%                 MagickCore Distributed Pixel Cache Methods                  %

-%                                                                             %

-%                              Software Design                                %

-%                                   Cristy                                    %

-%                                January 2013                                 %

-%                                                                             %

-%                                                                             %

-%  Copyright 1999-2015 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  %

-%  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.                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-% A distributed pixel cache is an extension of the traditional pixel cache

-% available on a single host.  The distributed pixel cache may span multiple

-% servers so that it can grow in size and transactional capacity to support

-% very large images.  Start up the pixel cache server on one or more machines.

-% When you read or operate on an image and the local pixel cache resources are

-% exhausted, ImageMagick contacts one or more of these remote pixel servers to

-% store or retrieve pixels.

-%

-*/

-

-/*

-  Include declarations.

-*/

-#include "MagickCore/studio.h"

-#include "MagickCore/cache.h"

-#include "MagickCore/cache-private.h"

-#include "MagickCore/distribute-cache.h"

-#include "MagickCore/distribute-cache-private.h"

-#include "MagickCore/exception.h"

-#include "MagickCore/exception-private.h"

-#include "MagickCore/geometry.h"

-#include "MagickCore/image.h"

-#include "MagickCore/image-private.h"

-#include "MagickCore/list.h"

-#include "MagickCore/locale_.h"

-#include "MagickCore/memory_.h"

-#include "MagickCore/nt-base-private.h"

-#include "MagickCore/pixel.h"

-#include "MagickCore/policy.h"

-#include "MagickCore/random_.h"

-#include "MagickCore/registry.h"

-#include "MagickCore/splay-tree.h"

-#include "MagickCore/string_.h"

-#include "MagickCore/string-private.h"

-#include "MagickCore/version.h"

-#include "MagickCore/version-private.h"

-#undef MAGICKCORE_HAVE_DISTRIBUTE_CACHE

-#if defined(MAGICKCORE_HAVE_SOCKET) && defined(MAGICKCORE_THREAD_SUPPORT)

-#include <netinet/in.h>

-#include <netdb.h>

-#include <sys/socket.h>

-#include <arpa/inet.h>

-#define CHAR_TYPE_CAST

-#define CLOSE_SOCKET(socket) (void) close(socket)

-#define HANDLER_RETURN_TYPE void *

-#define HANDLER_RETURN_VALUE (void *) NULL

-#define SOCKET_TYPE int

-#define LENGTH_TYPE size_t

-#define MAGICKCORE_HAVE_DISTRIBUTE_CACHE

-#elif defined(MAGICKCORE_WINDOWS_SUPPORT)

-#define CHAR_TYPE_CAST (char *)

-#define CLOSE_SOCKET(socket) (void) closesocket(socket)

-#define HANDLER_RETURN_TYPE DWORD WINAPI

-#define HANDLER_RETURN_VALUE 0

-#define SOCKET_TYPE SOCKET

-#define LENGTH_TYPE int

-#define MAGICKCORE_HAVE_DISTRIBUTE_CACHE

-#else

-#define CLOSE_SOCKET(socket) 

-#define HANDLER_RETURN_TYPE  void *

-#define HANDLER_RETURN_VALUE  (void *) NULL

-#define SOCKET_TYPE  int

-#define LENGTH_TYPE size_t

-#undef send

-#undef recv

-#define send(file,buffer,length,flags)  0

-#define recv(file,buffer,length,flags)  0

-#endif

-

-/*

-  Define declarations.

-*/

-#define DPCHostname  "127.0.0.1"

-#define DPCPendingConnections  10

-#define DPCPort  6668

-#define DPCSessionKeyLength  8

-#ifndef MSG_NOSIGNAL

-#  define MSG_NOSIGNAL 0

-#endif

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   A c q u i r e D i s t r i b u t e C a c h e I n f o                       %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  AcquireDistributeCacheInfo() allocates the DistributeCacheInfo structure.

-%

-%  The format of the AcquireDistributeCacheInfo method is:

-%

-%      DistributeCacheInfo *AcquireDistributeCacheInfo(ExceptionInfo *exception)

-%

-%  A description of each parameter follows:

-%

-%    o exception: return any errors or warnings in this structure.

-%

-*/

-

-static inline MagickOffsetType dpc_read(int file,const MagickSizeType length,

-  unsigned char *restrict message)

-{

-  register MagickOffsetType

-    i;

-

-  ssize_t

-    count;

-

-#if !defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)

-  magick_unreferenced(file);

-  magick_unreferenced(message);

-#endif

-

-  count=0;

-  for (i=0; i < (MagickOffsetType) length; i+=count)

-  {

-    count=recv(file,CHAR_TYPE_CAST message+i,(LENGTH_TYPE) MagickMin(length-i,

-      (MagickSizeType) SSIZE_MAX),0);

-    if (count <= 0)

-      {

-        count=0;

-        if (errno != EINTR)

-          break;

-      }

-  }

-  return(i);

-}

-

-static int ConnectPixelCacheServer(const char *hostname,const int port,

-  size_t *session_key,ExceptionInfo *exception)

-{

-#if defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)

-  char

-    service[MagickPathExtent];

-

-  const char

-    *shared_secret;

-

-  int

-    status;

-

-  SOCKET_TYPE

-    client_socket;

-

-  ssize_t

-    count;

-

-  struct addrinfo

-    hint,

-    *result;

-

-  unsigned char

-    secret[MagickPathExtent];

-

-  /*

-    Connect to distributed pixel cache and get session key.

-  */

-  *session_key=0;

-  shared_secret=GetPolicyValue("shared-secret");

-  if (shared_secret == (const char *) NULL)

-    {

-      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,

-        "DistributedPixelCache","'%s'","shared secret expected");

-      return(-1);

-    }

-#if defined(MAGICKCORE_WINDOWS_SUPPORT)

-  NTInitializeWinsock(MagickTrue);

-#endif

-  (void) ResetMagickMemory(&hint,0,sizeof(hint));

-  hint.ai_family=AF_INET;

-  hint.ai_socktype=SOCK_STREAM;

-  hint.ai_flags=AI_PASSIVE;

-  (void) FormatLocaleString(service,MagickPathExtent,"%d",port);

-  status=getaddrinfo(hostname,service,&hint,&result);

-  if (status != 0)

-    {

-      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,

-        "DistributedPixelCache","'%s'",hostname);

-      return(-1);

-    }

-  client_socket=socket(result->ai_family,result->ai_socktype,

-    result->ai_protocol);

-  if (client_socket == -1)

-    {

-      freeaddrinfo(result);

-      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,

-        "DistributedPixelCache","'%s'",hostname);

-      return(-1);

-    }

-  status=connect(client_socket,result->ai_addr,(socklen_t) result->ai_addrlen);

-  if (status == -1)

-    {

-      CLOSE_SOCKET(client_socket);

-      freeaddrinfo(result);

-      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,

-        "DistributedPixelCache","'%s'",hostname);

-      return(-1);

-    }

-  count=recv(client_socket,CHAR_TYPE_CAST secret,MagickPathExtent,0);

-  if (count != -1)

-    {

-      StringInfo

-        *nonce;

-

-      nonce=AcquireStringInfo(count);

-      (void) memcpy(GetStringInfoDatum(nonce),secret,(size_t) count);

-      *session_key=GetMagickSignature(nonce);

-      nonce=DestroyStringInfo(nonce);

-    }

-  if (*session_key == 0)

-    {

-      CLOSE_SOCKET(client_socket);

-      client_socket=(SOCKET_TYPE) (-1);

-    }

-  freeaddrinfo(result);

-  return(client_socket);

-#else

-  (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,

-    "DelegateLibrarySupportNotBuiltIn","distributed pixel cache");

-  return(MagickFalse);

-#endif

-}

-

-static char *GetHostname(int *port,ExceptionInfo *exception)

-{

-  char

-    *host,

-    *hosts,

-    **hostlist;

-

-  int

-    argc;

-

-  register ssize_t

-    i;

-

-  static size_t

-    id = 0;

-

-  /*

-    Parse host list (e.g. 192.168.100.1:6668,192.168.100.2:6668).

-  */

-  hosts=(char *) GetImageRegistry(StringRegistryType,"cache:hosts",exception);

-  if (hosts == (char *) NULL)

-    {

-      *port=DPCPort;

-      return(AcquireString(DPCHostname));

-    }

-  (void) SubstituteString(&hosts,","," ");

-  hostlist=StringToArgv(hosts,&argc);

-  hosts=DestroyString(hosts);

-  if (hostlist == (char **) NULL)

-    {

-      *port=DPCPort;

-      return(AcquireString(DPCHostname));

-    }

-  hosts=AcquireString(hostlist[(id++ % (argc-1))+1]);

-  for (i=0; i < (ssize_t) argc; i++)

-    hostlist[i]=DestroyString(hostlist[i]);

-  hostlist=(char **) RelinquishMagickMemory(hostlist);

-  (void) SubstituteString(&hosts,":"," ");

-  hostlist=StringToArgv(hosts,&argc);

-  if (hostlist == (char **) NULL)

-    {

-      *port=DPCPort;

-      return(AcquireString(DPCHostname));

-    }

-  host=AcquireString(hostlist[1]);

-  if (hostlist[2] == (char *) NULL)

-    *port=DPCPort;

-  else

-    *port=StringToLong(hostlist[2]);

-  for (i=0; i < (ssize_t) argc; i++)

-    hostlist[i]=DestroyString(hostlist[i]);

-  hostlist=(char **) RelinquishMagickMemory(hostlist);

-  return(host);

-}

-

-MagickPrivate DistributeCacheInfo *AcquireDistributeCacheInfo(

-  ExceptionInfo *exception)

-{

-  char

-    *hostname;

-

-  DistributeCacheInfo

-    *server_info;

-

-  size_t

-    session_key;

-

-  /*

-    Connect to the distributed pixel cache server.

-  */

-  server_info=(DistributeCacheInfo *) AcquireMagickMemory(sizeof(*server_info));

-  if (server_info == (DistributeCacheInfo *) NULL)

-    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");

-  (void) ResetMagickMemory(server_info,0,sizeof(*server_info));

-  server_info->signature=MagickCoreSignature;

-  server_info->port=0;

-  hostname=GetHostname(&server_info->port,exception);

-  session_key=0;

-  server_info->file=ConnectPixelCacheServer(hostname,server_info->port,

-    &session_key,exception);

-  if (server_info->file == -1)

-    server_info=DestroyDistributeCacheInfo(server_info);

-  else

-    {

-      server_info->session_key=session_key;

-      (void) CopyMagickString(server_info->hostname,hostname,MagickPathExtent);

-      server_info->debug=IsEventLogging();

-    }

-  hostname=DestroyString(hostname);

-  return(server_info);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   D e s t r o y D i s t r i b u t e C a c h e I n f o                       %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  DestroyDistributeCacheInfo() deallocates memory associated with an

-%  DistributeCacheInfo structure.

-%

-%  The format of the DestroyDistributeCacheInfo method is:

-%

-%      DistributeCacheInfo *DestroyDistributeCacheInfo(

-%        DistributeCacheInfo *server_info)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-*/

-MagickPrivate DistributeCacheInfo *DestroyDistributeCacheInfo(

-  DistributeCacheInfo *server_info)

-{

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  if (server_info->file > 0)

-    CLOSE_SOCKET(server_info->file);

-  server_info->signature=(~MagickCoreSignature);

-  server_info=(DistributeCacheInfo *) RelinquishMagickMemory(server_info);

-  return(server_info);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   D i s t r i b u t e P i x e l C a c h e S e r v e r                       %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  DistributePixelCacheServer() waits on the specified port for commands to

-%  create, read, update, or destroy a pixel cache.

-%

-%  The format of the DistributePixelCacheServer() method is:

-%

-%      void DistributePixelCacheServer(const int port)

-%

-%  A description of each parameter follows:

-%

-%    o port: connect the distributed pixel cache at this port.

-%

-%    o exception: return any errors or warnings in this structure.

-%

-*/

-

-static MagickBooleanType DestroyDistributeCache(SplayTreeInfo *registry,

-  const size_t session_key)

-{

-  /*

-    Destroy distributed pixel cache.

-  */

-  return(DeleteNodeFromSplayTree(registry,(const void *) session_key));

-}

-

-static inline MagickOffsetType dpc_send(int file,const MagickSizeType length,

-  const unsigned char *restrict message)

-{

-  MagickOffsetType

-    count;

-

-  register MagickOffsetType

-    i;

-

-#if !defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)

-  magick_unreferenced(file);

-  magick_unreferenced(message);

-#endif

-

-  /*

-    Ensure a complete message is sent.

-  */

-  count=0;

-  for (i=0; i < (MagickOffsetType) length; i+=count)

-  {

-    count=(MagickOffsetType) send(file,CHAR_TYPE_CAST message+i,(LENGTH_TYPE)

-      MagickMin(length-i,(MagickSizeType) SSIZE_MAX),MSG_NOSIGNAL);

-    if (count <= 0)

-      {

-        count=0;

-        if (errno != EINTR)

-          break;

-      }

-  }

-  return(i);

-}

-

-static MagickBooleanType OpenDistributeCache(SplayTreeInfo *registry,int file,

-  const size_t session_key,ExceptionInfo *exception)

-{

-  Image

-    *image;

-

-  MagickBooleanType

-    status;

-

-  MagickOffsetType

-    count;

-

-  MagickSizeType

-    length;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Open distributed pixel cache.

-  */

-  image=AcquireImage((ImageInfo *) NULL,exception);

-  if (image == (Image *) NULL)

-    return(MagickFalse);

-  length=sizeof(image->storage_class)+sizeof(image->colorspace)+

-    sizeof(image->alpha_trait)+sizeof(image->read_mask)+

-    sizeof(image->write_mask)+sizeof(image->columns)+sizeof(image->rows)+

-    sizeof(image->number_channels)+MaxPixelChannels*sizeof(*image->channel_map)+

-    sizeof(image->metacontent_extent);

-  count=dpc_read(file,length,message);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  /*

-    Deserialize the image attributes.

-  */

-  p=message;

-  (void) memcpy(&image->storage_class,p,sizeof(image->storage_class));

-  p+=sizeof(image->storage_class);

-  (void) memcpy(&image->colorspace,p,sizeof(image->colorspace));

-  p+=sizeof(image->colorspace);

-  (void) memcpy(&image->alpha_trait,p,sizeof(image->alpha_trait));

-  p+=sizeof(image->alpha_trait);

-  (void) memcpy(&image->read_mask,p,sizeof(image->read_mask));

-  p+=sizeof(image->read_mask);

-  (void) memcpy(&image->write_mask,p,sizeof(image->write_mask));

-  p+=sizeof(image->write_mask);

-  (void) memcpy(&image->columns,p,sizeof(image->columns));

-  p+=sizeof(image->columns);

-  (void) memcpy(&image->rows,p,sizeof(image->rows));

-  p+=sizeof(image->rows);

-  (void) memcpy(&image->number_channels,p,sizeof(image->number_channels));

-  p+=sizeof(image->number_channels);

-  (void) memcpy(image->channel_map,p,MaxPixelChannels*

-    sizeof(*image->channel_map));

-  p+=MaxPixelChannels*sizeof(*image->channel_map);

-  (void) memcpy(&image->metacontent_extent,p,sizeof(image->metacontent_extent));

-  p+=sizeof(image->metacontent_extent);

-  if (SyncImagePixelCache(image,exception) == MagickFalse)

-    return(MagickFalse);

-  status=AddValueToSplayTree(registry,(const void *) session_key,image);

-  return(status);

-}

-

-static MagickBooleanType ReadDistributeCacheMetacontent(SplayTreeInfo *registry,

-  int file,const size_t session_key,ExceptionInfo *exception)

-{

-  const unsigned char

-    *metacontent;

-

-  Image

-    *image;

-

-  MagickOffsetType

-    count;

-

-  MagickSizeType

-    length;

-

-  RectangleInfo

-    region;

-

-  register const Quantum

-    *p;

-

-  register unsigned char

-    *q;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Read distributed pixel cache metacontent.

-  */

-  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);

-  if (image == (Image *) NULL)

-    return(MagickFalse);

-  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+

-    sizeof(region.y)+sizeof(length);

-  count=dpc_read(file,length,message);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  q=message;

-  (void) memcpy(&region.width,q,sizeof(region.width));

-  q+=sizeof(region.width);

-  (void) memcpy(&region.height,q,sizeof(region.height));

-  q+=sizeof(region.height);

-  (void) memcpy(&region.x,q,sizeof(region.x));

-  q+=sizeof(region.x);

-  (void) memcpy(&region.y,q,sizeof(region.y));

-  q+=sizeof(region.y);

-  (void) memcpy(&length,q,sizeof(length));

-  q+=sizeof(length);

-  p=GetVirtualPixels(image,region.x,region.y,region.width,region.height,

-    exception);

-  if (p == (const Quantum *) NULL)

-    return(MagickFalse);

-  metacontent=(const unsigned char *) GetVirtualMetacontent(image);

-  count=dpc_send(file,length,metacontent);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  return(MagickTrue);

-}

-

-static MagickBooleanType ReadDistributeCachePixels(SplayTreeInfo *registry,

-  int file,const size_t session_key,ExceptionInfo *exception)

-{

-  Image

-    *image;

-

-  MagickOffsetType

-    count;

-

-  MagickSizeType

-    length;

-

-  RectangleInfo

-    region;

-

-  register const Quantum

-    *p;

-

-  register unsigned char

-    *q;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Read distributed pixel cache pixels.

-  */

-  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);

-  if (image == (Image *) NULL)

-    return(MagickFalse);

-  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+

-    sizeof(region.y)+sizeof(length);

-  count=dpc_read(file,length,message);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  q=message;

-  (void) memcpy(&region.width,q,sizeof(region.width));

-  q+=sizeof(region.width);

-  (void) memcpy(&region.height,q,sizeof(region.height));

-  q+=sizeof(region.height);

-  (void) memcpy(&region.x,q,sizeof(region.x));

-  q+=sizeof(region.x);

-  (void) memcpy(&region.y,q,sizeof(region.y));

-  q+=sizeof(region.y);

-  (void) memcpy(&length,q,sizeof(length));

-  q+=sizeof(length);

-  p=GetVirtualPixels(image,region.x,region.y,region.width,region.height,

-    exception);

-  if (p == (const Quantum *) NULL)

-    return(MagickFalse);

-  count=dpc_send(file,length,(unsigned char *) p);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  return(MagickTrue);

-}

-

-static void *RelinquishImageRegistry(void *image)

-{

-  return((void *) DestroyImageList((Image *) image));

-}

-

-static MagickBooleanType WriteDistributeCacheMetacontent(

-  SplayTreeInfo *registry,int file,const size_t session_key,

-  ExceptionInfo *exception)

-{

-  Image

-    *image;

-

-  MagickOffsetType

-    count;

-

-  MagickSizeType

-    length;

-

-  RectangleInfo

-    region;

-

-  register Quantum

-    *q;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent],

-    *metacontent;

-

-  /*

-    Write distributed pixel cache metacontent.

-  */

-  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);

-  if (image == (Image *) NULL)

-    return(MagickFalse);

-  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+

-    sizeof(region.y)+sizeof(length);

-  count=dpc_read(file,length,message);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  p=message;

-  (void) memcpy(&region.width,p,sizeof(region.width));

-  p+=sizeof(region.width);

-  (void) memcpy(&region.height,p,sizeof(region.height));

-  p+=sizeof(region.height);

-  (void) memcpy(&region.x,p,sizeof(region.x));

-  p+=sizeof(region.x);

-  (void) memcpy(&region.y,p,sizeof(region.y));

-  p+=sizeof(region.y);

-  (void) memcpy(&length,p,sizeof(length));

-  p+=sizeof(length);

-  q=GetAuthenticPixels(image,region.x,region.y,region.width,region.height,

-    exception);

-  if (q == (Quantum *) NULL)

-    return(MagickFalse);

-  metacontent=(unsigned char *) GetAuthenticMetacontent(image);

-  count=dpc_read(file,length,metacontent);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  return(SyncAuthenticPixels(image,exception));

-}

-

-static MagickBooleanType WriteDistributeCachePixels(SplayTreeInfo *registry,

-  int file,const size_t session_key,ExceptionInfo *exception)

-{

-  Image

-    *image;

-

-  MagickOffsetType

-    count;

-

-  MagickSizeType

-    length;

-

-  RectangleInfo

-    region;

-

-  register Quantum

-    *q;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Write distributed pixel cache pixels.

-  */

-  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);

-  if (image == (Image *) NULL)

-    return(MagickFalse);

-  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+

-    sizeof(region.y)+sizeof(length);

-  count=dpc_read(file,length,message);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  p=message;

-  (void) memcpy(&region.width,p,sizeof(region.width));

-  p+=sizeof(region.width);

-  (void) memcpy(&region.height,p,sizeof(region.height));

-  p+=sizeof(region.height);

-  (void) memcpy(&region.x,p,sizeof(region.x));

-  p+=sizeof(region.x);

-  (void) memcpy(&region.y,p,sizeof(region.y));

-  p+=sizeof(region.y);

-  (void) memcpy(&length,p,sizeof(length));

-  p+=sizeof(length);

-  q=GetAuthenticPixels(image,region.x,region.y,region.width,region.height,

-    exception);

-  if (q == (Quantum *) NULL)

-    return(MagickFalse);

-  count=dpc_read(file,length,(unsigned char *) q);

-  if (count != (MagickOffsetType) length)

-    return(MagickFalse);

-  return(SyncAuthenticPixels(image,exception));

-}

-

-static HANDLER_RETURN_TYPE DistributePixelCacheClient(void *socket)

-{

-  const char

-    *shared_secret;

-

-  ExceptionInfo

-    *exception;

-

-  MagickBooleanType

-    status;

-

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  RandomInfo

-    *random_info;

-

-  size_t

-    key,

-    session_key;

-

-  SOCKET_TYPE

-    client_socket;

-

-  SplayTreeInfo

-    *registry;

-

-  StringInfo

-    *secret;

-

-  unsigned char

-    command,

-    session[2*MagickPathExtent];

-

-  /*

-    Distributed pixel cache client.

-  */

-  shared_secret=GetPolicyValue("shared-secret");

-  if (shared_secret == (const char *) NULL)

-    ThrowFatalException(CacheFatalError,"shared secret expected");

-  p=session;

-  (void) CopyMagickString((char *) p,shared_secret,MagickPathExtent);

-  p+=strlen(shared_secret);

-  random_info=AcquireRandomInfo();

-  secret=GetRandomKey(random_info,DPCSessionKeyLength);

-  (void) memcpy(p,GetStringInfoDatum(secret),DPCSessionKeyLength);

-  session_key=GetMagickSignature(secret);

-  random_info=DestroyRandomInfo(random_info);

-  exception=AcquireExceptionInfo();

-  registry=NewSplayTree((int (*)(const void *,const void *)) NULL,

-    (void *(*)(void *)) NULL,RelinquishImageRegistry);

-  client_socket=(*(SOCKET_TYPE *) socket);

-  count=dpc_send(client_socket,DPCSessionKeyLength,GetStringInfoDatum(secret));

-  secret=DestroyStringInfo(secret);

-  for ( ; ; )

-  {

-    count=dpc_read(client_socket,1,(unsigned char *) &command);

-    if (count <= 0)

-      break;

-    count=dpc_read(client_socket,sizeof(key),(unsigned char *) &key);

-    if ((count != (MagickOffsetType) sizeof(key)) || (key != session_key))

-      break;

-    status=MagickFalse;

-    switch (command)

-    {

-      case 'o':

-      {

-        status=OpenDistributeCache(registry,client_socket,session_key,

-          exception);

-        count=dpc_send(client_socket,sizeof(status),(unsigned char *) &status);

-        break;

-      }

-      case 'r':

-      {

-        status=ReadDistributeCachePixels(registry,client_socket,session_key,

-          exception);

-        break;

-      }

-      case 'R':

-      {

-        status=ReadDistributeCacheMetacontent(registry,client_socket,

-          session_key,exception);

-        break;

-      }

-      case 'w':

-      {

-        status=WriteDistributeCachePixels(registry,client_socket,session_key,

-          exception);

-        break;

-      }

-      case 'W':

-      {

-        status=WriteDistributeCacheMetacontent(registry,client_socket,

-          session_key,exception);

-        break;

-      }

-      case 'd':

-      {

-        status=DestroyDistributeCache(registry,session_key);

-        break;

-      }

-      default:

-        break;

-    }

-    if (status == MagickFalse)

-      break;

-    if (command == 'd')

-      break;

-  }

-  count=dpc_send(client_socket,sizeof(status),(unsigned char *) &status);

-  CLOSE_SOCKET(client_socket);

-  exception=DestroyExceptionInfo(exception);

-  registry=DestroySplayTree(registry);

-  return(HANDLER_RETURN_VALUE);

-}

-

-MagickExport void DistributePixelCacheServer(const int port,

-  ExceptionInfo *exception)

-{

-#if defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)

-  char

-    service[MagickPathExtent];

-

-  int

-    status;

-

-#if defined(MAGICKCORE_THREAD_SUPPORT)

-  pthread_attr_t

-    attributes;

-

-  pthread_t

-    threads;

-#elif defined(MAGICKCORE_WINDOWS_SUPPORT)

-  DWORD

-    threadID;

-#else

-  Not implemented!

-#endif

-

-  register struct addrinfo

-    *p;

-

-  SOCKET_TYPE

-    server_socket;

-

-  struct addrinfo

-    hint,

-    *result;

-

-  struct sockaddr_in

-    address;

-

-  /*

-    Launch distributed pixel cache server.

-  */

-  assert(exception != (ExceptionInfo *) NULL);

-  assert(exception->signature == MagickCoreSignature);

-#if defined(MAGICKCORE_WINDOWS_SUPPORT)

-  NTInitializeWinsock(MagickFalse);

-#endif

-  (void) ResetMagickMemory(&hint,0,sizeof(hint));

-  hint.ai_family=AF_INET;

-  hint.ai_socktype=SOCK_STREAM;

-  hint.ai_flags=AI_PASSIVE;

-  (void) FormatLocaleString(service,MagickPathExtent,"%d",port);

-  status=getaddrinfo((const char *) NULL,service,&hint,&result);

-  if (status != 0)

-    ThrowFatalException(CacheFatalError,"UnableToListen");

-  server_socket=(SOCKET_TYPE) 0;

-  for (p=result; p != (struct addrinfo *) NULL; p=p->ai_next)

-  {

-    int

-      one;

-

-    server_socket=socket(p->ai_family,p->ai_socktype,p->ai_protocol);

-    if (server_socket == -1)

-      continue;

-    one=1;

-    status=setsockopt(server_socket,SOL_SOCKET,SO_REUSEADDR,

-      CHAR_TYPE_CAST &one,(socklen_t) sizeof(one));

-    if (status == -1)

-      {

-        CLOSE_SOCKET(server_socket);

-        continue;

-      }

-    status=bind(server_socket,p->ai_addr,(socklen_t) p->ai_addrlen);

-    if (status == -1)

-      {

-        CLOSE_SOCKET(server_socket);

-        continue;

-      }

-    break;

-  }

-  if (p == (struct addrinfo *) NULL)

-    ThrowFatalException(CacheFatalError,"UnableToBind");

-  freeaddrinfo(result);

-  status=listen(server_socket,DPCPendingConnections);

-  if (status != 0)

-    ThrowFatalException(CacheFatalError,"UnableToListen");

-#if defined(MAGICKCORE_THREAD_SUPPORT)

-  pthread_attr_init(&attributes);

-#endif

-  for ( ; ; )

-  {

-    SOCKET_TYPE

-      client_socket;

-

-    socklen_t

-      length;

-

-    length=(socklen_t) sizeof(address);

-    client_socket=accept(server_socket,(struct sockaddr *) &address,&length);

-    if (client_socket == -1)

-      ThrowFatalException(CacheFatalError,"UnableToEstablishConnection");

-#if defined(MAGICKCORE_THREAD_SUPPORT)

-    status=pthread_create(&threads,&attributes,DistributePixelCacheClient,

-      (void *) &client_socket);

-    if (status == -1)

-      ThrowFatalException(CacheFatalError,"UnableToCreateClientThread");

-#elif defined(MAGICKCORE_WINDOWS_SUPPORT)

-    if (CreateThread(0,0,DistributePixelCacheClient,(void*) &client_socket,0,

-        &threadID) == (HANDLE) NULL)

-      ThrowFatalException(CacheFatalError,"UnableToCreateClientThread");

-#else

-    Not implemented!

-#endif

-  }

-#else

-  magick_unreferenced(port);

-  magick_unreferenced(exception);

-  ThrowFatalException(MissingDelegateError,"DelegateLibrarySupportNotBuiltIn");

-#endif

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   G e t D i s t r i b u t e C a c h e F i l e                               %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  GetDistributeCacheFile() returns the file associated with this

-%  DistributeCacheInfo structure.

-%

-%  The format of the GetDistributeCacheFile method is:

-%

-%      int GetDistributeCacheFile(const DistributeCacheInfo *server_info)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-*/

-MagickPrivate int GetDistributeCacheFile(const DistributeCacheInfo *server_info)

-{

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  return(server_info->file);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   G e t D i s t r i b u t e C a c h e H o s t n a m e                       %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  GetDistributeCacheHostname() returns the hostname associated with this

-%  DistributeCacheInfo structure.

-%

-%  The format of the GetDistributeCacheHostname method is:

-%

-%      const char *GetDistributeCacheHostname(

-%        const DistributeCacheInfo *server_info)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-*/

-MagickPrivate const char *GetDistributeCacheHostname(

-  const DistributeCacheInfo *server_info)

-{

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  return(server_info->hostname);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   G e t D i s t r i b u t e C a c h e P o r t                               %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  GetDistributeCachePort() returns the port associated with this

-%  DistributeCacheInfo structure.

-%

-%  The format of the GetDistributeCachePort method is:

-%

-%      int GetDistributeCachePort(const DistributeCacheInfo *server_info)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-*/

-MagickPrivate int GetDistributeCachePort(const DistributeCacheInfo *server_info)

-{

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  return(server_info->port);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   O p e n D i s t r i b u t e P i x e l C a c h e                           %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  OpenDistributePixelCache() opens a pixel cache on a remote server.

-%

-%  The format of the OpenDistributePixelCache method is:

-%

-%      MagickBooleanType *OpenDistributePixelCache(

-%        DistributeCacheInfo *server_info,Image *image)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-%    o image: the image.

-%

-*/

-MagickPrivate MagickBooleanType OpenDistributePixelCache(

-  DistributeCacheInfo *server_info,Image *image)

-{

-  MagickBooleanType

-    status;

-

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Open distributed pixel cache.

-  */

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  assert(image != (Image *) NULL);

-  assert(image->signature == MagickCoreSignature);

-  p=message;

-  *p++='o';  /* open */

-  /*

-    Serialize image attributes (see ValidatePixelCacheMorphology()).

-  */

-  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));

-  p+=sizeof(server_info->session_key);

-  (void) memcpy(p,&image->storage_class,sizeof(image->storage_class));

-  p+=sizeof(image->storage_class);

-  (void) memcpy(p,&image->colorspace,sizeof(image->colorspace));

-  p+=sizeof(image->colorspace);

-  (void) memcpy(p,&image->alpha_trait,sizeof(image->alpha_trait));

-  p+=sizeof(image->alpha_trait);

-  (void) memcpy(p,&image->read_mask,sizeof(image->read_mask));

-  p+=sizeof(image->read_mask);

-  (void) memcpy(p,&image->write_mask,sizeof(image->write_mask));

-  p+=sizeof(image->write_mask);

-  (void) memcpy(p,&image->columns,sizeof(image->columns));

-  p+=sizeof(image->columns);

-  (void) memcpy(p,&image->rows,sizeof(image->rows));

-  p+=sizeof(image->rows);

-  (void) memcpy(p,&image->number_channels,sizeof(image->number_channels));

-  p+=sizeof(image->number_channels);

-  (void) memcpy(p,image->channel_map,MaxPixelChannels*

-    sizeof(*image->channel_map));

-  p+=MaxPixelChannels*sizeof(*image->channel_map);

-  (void) memcpy(p,&image->metacontent_extent,sizeof(image->metacontent_extent));

-  p+=sizeof(image->metacontent_extent);

-  count=dpc_send(server_info->file,p-message,message);

-  if (count != (MagickOffsetType) (p-message))

-    return(MagickFalse);

-  status=MagickFalse;

-  count=dpc_read(server_info->file,sizeof(status),(unsigned char *) &status);

-  if (count != (MagickOffsetType) sizeof(status))

-    return(MagickFalse);

-  return(status);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   R e a d D i s t r i b u t e P i x e l C a c h e M e t a c o n t e n t     %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  ReadDistributePixelCacheMetacontents() reads metacontent from the specified

-%  region of the distributed pixel cache.

-%

-%  The format of the ReadDistributePixelCacheMetacontents method is:

-%

-%      MagickOffsetType ReadDistributePixelCacheMetacontents(

-%        DistributeCacheInfo *server_info,const RectangleInfo *region,

-%        const MagickSizeType length,unsigned char *metacontent)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-%    o image: the image.

-%

-%    o region: read the metacontent from this region of the image.

-%

-%    o length: the length in bytes of the metacontent.

-%

-%    o metacontent: read these metacontent from the pixel cache.

-%

-*/

-MagickPrivate MagickOffsetType ReadDistributePixelCacheMetacontent(

-  DistributeCacheInfo *server_info,const RectangleInfo *region,

-  const MagickSizeType length,unsigned char *metacontent)

-{

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Read distributed pixel cache metacontent.

-  */

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  assert(region != (RectangleInfo *) NULL);

-  assert(metacontent != (unsigned char *) NULL);

-  if (length > (MagickSizeType) SSIZE_MAX)

-    return(-1);

-  p=message;

-  *p++='R';

-  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));

-  p+=sizeof(server_info->session_key);

-  (void) memcpy(p,&region->width,sizeof(region->width));

-  p+=sizeof(region->width);

-  (void) memcpy(p,&region->height,sizeof(region->height));

-  p+=sizeof(region->height);

-  (void) memcpy(p,&region->x,sizeof(region->x));

-  p+=sizeof(region->x);

-  (void) memcpy(p,&region->y,sizeof(region->y));

-  p+=sizeof(region->y);

-  (void) memcpy(p,&length,sizeof(length));

-  p+=sizeof(length);

-  count=dpc_send(server_info->file,p-message,message);

-  if (count != (MagickOffsetType) (p-message))

-    return(-1);

-  return(dpc_read(server_info->file,length,metacontent));

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   R e a d D i s t r i b u t e P i x e l C a c h e P i x e l s               %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  ReadDistributePixelCachePixels() reads pixels from the specified region of

-%  the distributed pixel cache.

-%

-%  The format of the ReadDistributePixelCachePixels method is:

-%

-%      MagickOffsetType ReadDistributePixelCachePixels(

-%        DistributeCacheInfo *server_info,const RectangleInfo *region,

-%        const MagickSizeType length,unsigned char *restrict pixels)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-%    o image: the image.

-%

-%    o region: read the pixels from this region of the image.

-%

-%    o length: the length in bytes of the pixels.

-%

-%    o pixels: read these pixels from the pixel cache.

-%

-*/

-MagickPrivate MagickOffsetType ReadDistributePixelCachePixels(

-  DistributeCacheInfo *server_info,const RectangleInfo *region,

-  const MagickSizeType length,unsigned char *restrict pixels)

-{

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Read distributed pixel cache pixels.

-  */

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  assert(region != (RectangleInfo *) NULL);

-  assert(pixels != (unsigned char *) NULL);

-  if (length > (MagickSizeType) SSIZE_MAX)

-    return(-1);

-  p=message;

-  *p++='r';

-  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));

-  p+=sizeof(server_info->session_key);

-  (void) memcpy(p,&region->width,sizeof(region->width));

-  p+=sizeof(region->width);

-  (void) memcpy(p,&region->height,sizeof(region->height));

-  p+=sizeof(region->height);

-  (void) memcpy(p,&region->x,sizeof(region->x));

-  p+=sizeof(region->x);

-  (void) memcpy(p,&region->y,sizeof(region->y));

-  p+=sizeof(region->y);

-  (void) memcpy(p,&length,sizeof(length));

-  p+=sizeof(length);

-  count=dpc_send(server_info->file,p-message,message);

-  if (count != (MagickOffsetType) (p-message))

-    return(-1);

-  return(dpc_read(server_info->file,length,pixels));

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   R e l i n q u i s h D i s t r i b u t e P i x e l C a c h e               %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  RelinquishDistributePixelCache() frees resources acquired with

-%  OpenDistributePixelCache().

-%

-%  The format of the RelinquishDistributePixelCache method is:

-%

-%      MagickBooleanType RelinquishDistributePixelCache(

-%        DistributeCacheInfo *server_info)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-*/

-MagickPrivate MagickBooleanType RelinquishDistributePixelCache(

-  DistributeCacheInfo *server_info)

-{

-  MagickBooleanType

-    status;

-

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Delete distributed pixel cache.

-  */

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  p=message;

-  *p++='d';

-  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));

-  p+=sizeof(server_info->session_key);

-  count=dpc_send(server_info->file,p-message,message);

-  if (count != (MagickOffsetType) (p-message))

-    return(MagickFalse);

-  count=dpc_read(server_info->file,sizeof(status),(unsigned char *) &status);

-  if (count != (MagickOffsetType) sizeof(status))

-    return(MagickFalse);

-  return(status);

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   W r i t e D i s t r i b u t e P i x e l C a c h e M e t a c o n t e n t   %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  WriteDistributePixelCacheMetacontents() writes image metacontent to the

-%  specified region of the distributed pixel cache.

-%

-%  The format of the WriteDistributePixelCacheMetacontents method is:

-%

-%      MagickOffsetType WriteDistributePixelCacheMetacontents(

-%        DistributeCacheInfo *server_info,const RectangleInfo *region,

-%        const MagickSizeType length,const unsigned char *metacontent)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-%    o image: the image.

-%

-%    o region: write the metacontent to this region of the image.

-%

-%    o length: the length in bytes of the metacontent.

-%

-%    o metacontent: write these metacontent to the pixel cache.

-%

-*/

-MagickPrivate MagickOffsetType WriteDistributePixelCacheMetacontent(

-  DistributeCacheInfo *server_info,const RectangleInfo *region,

-  const MagickSizeType length,const unsigned char *metacontent)

-{

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Write distributed pixel cache metacontent.

-  */

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  assert(region != (RectangleInfo *) NULL);

-  assert(metacontent != (unsigned char *) NULL);

-  if (length > (MagickSizeType) SSIZE_MAX)

-    return(-1);

-  p=message;

-  *p++='W';

-  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));

-  p+=sizeof(server_info->session_key);

-  (void) memcpy(p,&region->width,sizeof(region->width));

-  p+=sizeof(region->width);

-  (void) memcpy(p,&region->height,sizeof(region->height));

-  p+=sizeof(region->height);

-  (void) memcpy(p,&region->x,sizeof(region->x));

-  p+=sizeof(region->x);

-  (void) memcpy(p,&region->y,sizeof(region->y));

-  p+=sizeof(region->y);

-  (void) memcpy(p,&length,sizeof(length));

-  p+=sizeof(length);

-  count=dpc_send(server_info->file,p-message,message);

-  if (count != (MagickOffsetType) (p-message))

-    return(-1);

-  return(dpc_send(server_info->file,length,metacontent));

-}

-

-/*

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%                                                                             %

-%                                                                             %

-%                                                                             %

-+   W r i t e D i s t r i b u t e P i x e l C a c h e P i x e l s             %

-%                                                                             %

-%                                                                             %

-%                                                                             %

-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-%

-%  WriteDistributePixelCachePixels() writes image pixels to the specified

-%  region of the distributed pixel cache.

-%

-%  The format of the WriteDistributePixelCachePixels method is:

-%

-%      MagickBooleanType WriteDistributePixelCachePixels(

-%        DistributeCacheInfo *server_info,const RectangleInfo *region,

-%        const MagickSizeType length,const unsigned char *restrict pixels)

-%

-%  A description of each parameter follows:

-%

-%    o server_info: the distributed cache info.

-%

-%    o image: the image.

-%

-%    o region: write the pixels to this region of the image.

-%

-%    o length: the length in bytes of the pixels.

-%

-%    o pixels: write these pixels to the pixel cache.

-%

-*/

-MagickPrivate MagickOffsetType WriteDistributePixelCachePixels(

-  DistributeCacheInfo *server_info,const RectangleInfo *region,

-  const MagickSizeType length,const unsigned char *restrict pixels)

-{

-  MagickOffsetType

-    count;

-

-  register unsigned char

-    *p;

-

-  unsigned char

-    message[MagickPathExtent];

-

-  /*

-    Write distributed pixel cache pixels.

-  */

-  assert(server_info != (DistributeCacheInfo *) NULL);

-  assert(server_info->signature == MagickCoreSignature);

-  assert(region != (RectangleInfo *) NULL);

-  assert(pixels != (const unsigned char *) NULL);

-  if (length > (MagickSizeType) SSIZE_MAX)

-    return(-1);

-  p=message;

-  *p++='w';

-  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));

-  p+=sizeof(server_info->session_key);

-  (void) memcpy(p,&region->width,sizeof(region->width));

-  p+=sizeof(region->width);

-  (void) memcpy(p,&region->height,sizeof(region->height));

-  p+=sizeof(region->height);

-  (void) memcpy(p,&region->x,sizeof(region->x));

-  p+=sizeof(region->x);

-  (void) memcpy(p,&region->y,sizeof(region->y));

-  p+=sizeof(region->y);

-  (void) memcpy(p,&length,sizeof(length));

-  p+=sizeof(length);

-  count=dpc_send(server_info->file,p-message,message);

-  if (count != (MagickOffsetType) (p-message))

-    return(-1);

-  return(dpc_send(server_info->file,length,pixels));

-}

+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%    DDDD    IIIII   SSSSS  TTTTT  RRRR   IIIII  BBBB   U   U  TTTTT  EEEEE   %
+%    D   D     I     SS       T    R   R    I    B   B  U   U    T    E       %
+%    D   D     I      SSS     T    RRRR     I    BBBB   U   U    T    EEE     %
+%    D   D     I        SS    T    R R      I    B   B  U   U    T    E       %
+%    DDDDA   IIIII   SSSSS    T    R  R   IIIII  BBBB    UUU     T    EEEEE   %
+%                                                                             %
+%                      CCCC   AAA    CCCC  H   H  EEEEE                       %
+%                     C      A   A  C      H   H  E                           %
+%                     C      AAAAA  C      HHHHH  EEE                         %
+%                     C      A   A  C      H   H  E                           %
+%                      CCCC  A   A   CCCC  H   H  EEEEE                       %
+%                                                                             %
+%                                                                             %
+%                 MagickCore Distributed Pixel Cache Methods                  %
+%                                                                             %
+%                              Software Design                                %
+%                                   Cristy                                    %
+%                                January 2013                                 %
+%                                                                             %
+%                                                                             %
+%  Copyright 1999-2015 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  %
+%  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.                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% A distributed pixel cache is an extension of the traditional pixel cache
+% available on a single host.  The distributed pixel cache may span multiple
+% servers so that it can grow in size and transactional capacity to support
+% very large images.  Start up the pixel cache server on one or more machines.
+% When you read or operate on an image and the local pixel cache resources are
+% exhausted, ImageMagick contacts one or more of these remote pixel servers to
+% store or retrieve pixels.
+%
+*/
+
+/*
+  Include declarations.
+*/
+#include "MagickCore/studio.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/cache-private.h"
+#include "MagickCore/distribute-cache.h"
+#include "MagickCore/distribute-cache-private.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/geometry.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/locale_.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/nt-base-private.h"
+#include "MagickCore/pixel.h"
+#include "MagickCore/policy.h"
+#include "MagickCore/random_.h"
+#include "MagickCore/registry.h"
+#include "MagickCore/splay-tree.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/string-private.h"
+#include "MagickCore/version.h"
+#include "MagickCore/version-private.h"
+#undef MAGICKCORE_HAVE_DISTRIBUTE_CACHE
+#if defined(MAGICKCORE_HAVE_SOCKET) && defined(MAGICKCORE_THREAD_SUPPORT)
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#define CHAR_TYPE_CAST
+#define CLOSE_SOCKET(socket) (void) close(socket)
+#define HANDLER_RETURN_TYPE void *
+#define HANDLER_RETURN_VALUE (void *) NULL
+#define SOCKET_TYPE int
+#define LENGTH_TYPE size_t
+#define MAGICKCORE_HAVE_DISTRIBUTE_CACHE
+#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
+#define CHAR_TYPE_CAST (char *)
+#define CLOSE_SOCKET(socket) (void) closesocket(socket)
+#define HANDLER_RETURN_TYPE DWORD WINAPI
+#define HANDLER_RETURN_VALUE 0
+#define SOCKET_TYPE SOCKET
+#define LENGTH_TYPE int
+#define MAGICKCORE_HAVE_DISTRIBUTE_CACHE
+#else
+#ifdef __VMS
+#define CLOSE_SOCKET(socket) (void) close(socket)
+#else
+#define CLOSE_SOCKET(socket) 
+#endif
+#define HANDLER_RETURN_TYPE  void *
+#define HANDLER_RETURN_VALUE  (void *) NULL
+#define SOCKET_TYPE  int
+#undef send
+#undef recv
+#define send(file,buffer,length,flags)  0
+#define recv(file,buffer,length,flags)  0
+#endif
+
+/*
+  Define declarations.
+*/
+#define DPCHostname  "127.0.0.1"
+#define DPCPendingConnections  10
+#define DPCPort  6668
+#define DPCSessionKeyLength  8
+#ifndef MSG_NOSIGNAL
+#  define MSG_NOSIGNAL 0
+#endif
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   A c q u i r e D i s t r i b u t e C a c h e I n f o                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  AcquireDistributeCacheInfo() allocates the DistributeCacheInfo structure.
+%
+%  The format of the AcquireDistributeCacheInfo method is:
+%
+%      DistributeCacheInfo *AcquireDistributeCacheInfo(ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+
+static inline MagickOffsetType dpc_read(int file,const MagickSizeType length,
+  unsigned char *restrict message)
+{
+  register MagickOffsetType
+    i;
+
+  ssize_t
+    count;
+
+#if !defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)
+  magick_unreferenced(file);
+  magick_unreferenced(message);
+#endif
+
+  count=0;
+  for (i=0; i < (MagickOffsetType) length; i+=count)
+  {
+    count=recv(file,CHAR_TYPE_CAST message+i,(LENGTH_TYPE) MagickMin(length-i,
+      (MagickSizeType) SSIZE_MAX),0);
+    if (count <= 0)
+      {
+        count=0;
+        if (errno != EINTR)
+          break;
+      }
+  }
+  return(i);
+}
+
+static int ConnectPixelCacheServer(const char *hostname,const int port,
+  size_t *session_key,ExceptionInfo *exception)
+{
+#if defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)
+  char
+    service[MagickPathExtent];
+
+  const char
+    *shared_secret;
+
+  int
+    status;
+
+  SOCKET_TYPE
+    client_socket;
+
+  ssize_t
+    count;
+
+  struct addrinfo
+    hint,
+    *result;
+
+  unsigned char
+    secret[MagickPathExtent];
+
+  /*
+    Connect to distributed pixel cache and get session key.
+  */
+  *session_key=0;
+  shared_secret=GetPolicyValue("shared-secret");
+  if (shared_secret == (const char *) NULL)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s'","shared secret expected");
+      return(-1);
+    }
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+  NTInitializeWinsock(MagickTrue);
+#endif
+  (void) ResetMagickMemory(&hint,0,sizeof(hint));
+  hint.ai_family=AF_INET;
+  hint.ai_socktype=SOCK_STREAM;
+  hint.ai_flags=AI_PASSIVE;
+  (void) FormatLocaleString(service,MagickPathExtent,"%d",port);
+  status=getaddrinfo(hostname,service,&hint,&result);
+  if (status != 0)
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s'",hostname);
+      return(-1);
+    }
+  client_socket=socket(result->ai_family,result->ai_socktype,
+    result->ai_protocol);
+  if (client_socket == -1)
+    {
+      freeaddrinfo(result);
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s'",hostname);
+      return(-1);
+    }
+  status=connect(client_socket,result->ai_addr,(socklen_t) result->ai_addrlen);
+  if (status == -1)
+    {
+      CLOSE_SOCKET(client_socket);
+      freeaddrinfo(result);
+      (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
+        "DistributedPixelCache","'%s'",hostname);
+      return(-1);
+    }
+  count=recv(client_socket,CHAR_TYPE_CAST secret,MagickPathExtent,0);
+  if (count != -1)
+    {
+      StringInfo
+        *nonce;
+
+      nonce=AcquireStringInfo(count);
+      (void) memcpy(GetStringInfoDatum(nonce),secret,(size_t) count);
+      *session_key=GetMagickSignature(nonce);
+      nonce=DestroyStringInfo(nonce);
+    }
+  if (*session_key == 0)
+    {
+      CLOSE_SOCKET(client_socket);
+      client_socket=(SOCKET_TYPE) (-1);
+    }
+  freeaddrinfo(result);
+  return(client_socket);
+#else
+  (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
+    "DelegateLibrarySupportNotBuiltIn","distributed pixel cache");
+  return(MagickFalse);
+#endif
+}
+
+static char *GetHostname(int *port,ExceptionInfo *exception)
+{
+  char
+    *host,
+    *hosts,
+    **hostlist;
+
+  int
+    argc;
+
+  register ssize_t
+    i;
+
+  static size_t
+    id = 0;
+
+  /*
+    Parse host list (e.g. 192.168.100.1:6668,192.168.100.2:6668).
+  */
+  hosts=(char *) GetImageRegistry(StringRegistryType,"cache:hosts",exception);
+  if (hosts == (char *) NULL)
+    {
+      *port=DPCPort;
+      return(AcquireString(DPCHostname));
+    }
+  (void) SubstituteString(&hosts,","," ");
+  hostlist=StringToArgv(hosts,&argc);
+  hosts=DestroyString(hosts);
+  if (hostlist == (char **) NULL)
+    {
+      *port=DPCPort;
+      return(AcquireString(DPCHostname));
+    }
+  hosts=AcquireString(hostlist[(id++ % (argc-1))+1]);
+  for (i=0; i < (ssize_t) argc; i++)
+    hostlist[i]=DestroyString(hostlist[i]);
+  hostlist=(char **) RelinquishMagickMemory(hostlist);
+  (void) SubstituteString(&hosts,":"," ");
+  hostlist=StringToArgv(hosts,&argc);
+  if (hostlist == (char **) NULL)
+    {
+      *port=DPCPort;
+      return(AcquireString(DPCHostname));
+    }
+  host=AcquireString(hostlist[1]);
+  if (hostlist[2] == (char *) NULL)
+    *port=DPCPort;
+  else
+    *port=StringToLong(hostlist[2]);
+  for (i=0; i < (ssize_t) argc; i++)
+    hostlist[i]=DestroyString(hostlist[i]);
+  hostlist=(char **) RelinquishMagickMemory(hostlist);
+  return(host);
+}
+
+MagickPrivate DistributeCacheInfo *AcquireDistributeCacheInfo(
+  ExceptionInfo *exception)
+{
+  char
+    *hostname;
+
+  DistributeCacheInfo
+    *server_info;
+
+  size_t
+    session_key;
+
+  /*
+    Connect to the distributed pixel cache server.
+  */
+  server_info=(DistributeCacheInfo *) AcquireMagickMemory(sizeof(*server_info));
+  if (server_info == (DistributeCacheInfo *) NULL)
+    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
+  (void) ResetMagickMemory(server_info,0,sizeof(*server_info));
+  server_info->signature=MagickCoreSignature;
+  server_info->port=0;
+  hostname=GetHostname(&server_info->port,exception);
+  session_key=0;
+  server_info->file=ConnectPixelCacheServer(hostname,server_info->port,
+    &session_key,exception);
+  if (server_info->file == -1)
+    server_info=DestroyDistributeCacheInfo(server_info);
+  else
+    {
+      server_info->session_key=session_key;
+      (void) CopyMagickString(server_info->hostname,hostname,MagickPathExtent);
+      server_info->debug=IsEventLogging();
+    }
+  hostname=DestroyString(hostname);
+  return(server_info);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   D e s t r o y D i s t r i b u t e C a c h e I n f o                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DestroyDistributeCacheInfo() deallocates memory associated with an
+%  DistributeCacheInfo structure.
+%
+%  The format of the DestroyDistributeCacheInfo method is:
+%
+%      DistributeCacheInfo *DestroyDistributeCacheInfo(
+%        DistributeCacheInfo *server_info)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+*/
+MagickPrivate DistributeCacheInfo *DestroyDistributeCacheInfo(
+  DistributeCacheInfo *server_info)
+{
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  if (server_info->file > 0)
+    CLOSE_SOCKET(server_info->file);
+  server_info->signature=(~MagickCoreSignature);
+  server_info=(DistributeCacheInfo *) RelinquishMagickMemory(server_info);
+  return(server_info);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   D i s t r i b u t e P i x e l C a c h e S e r v e r                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DistributePixelCacheServer() waits on the specified port for commands to
+%  create, read, update, or destroy a pixel cache.
+%
+%  The format of the DistributePixelCacheServer() method is:
+%
+%      void DistributePixelCacheServer(const int port)
+%
+%  A description of each parameter follows:
+%
+%    o port: connect the distributed pixel cache at this port.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+
+static MagickBooleanType DestroyDistributeCache(SplayTreeInfo *registry,
+  const size_t session_key)
+{
+  /*
+    Destroy distributed pixel cache.
+  */
+  return(DeleteNodeFromSplayTree(registry,(const void *) session_key));
+}
+
+static inline MagickOffsetType dpc_send(int file,const MagickSizeType length,
+  const unsigned char *restrict message)
+{
+  MagickOffsetType
+    count;
+
+  register MagickOffsetType
+    i;
+
+#if !defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)
+  magick_unreferenced(file);
+  magick_unreferenced(message);
+#endif
+
+  /*
+    Ensure a complete message is sent.
+  */
+  count=0;
+  for (i=0; i < (MagickOffsetType) length; i+=count)
+  {
+    count=(MagickOffsetType) send(file,CHAR_TYPE_CAST message+i,(LENGTH_TYPE)
+      MagickMin(length-i,(MagickSizeType) SSIZE_MAX),MSG_NOSIGNAL);
+    if (count <= 0)
+      {
+        count=0;
+        if (errno != EINTR)
+          break;
+      }
+  }
+  return(i);
+}
+
+static MagickBooleanType OpenDistributeCache(SplayTreeInfo *registry,int file,
+  const size_t session_key,ExceptionInfo *exception)
+{
+  Image
+    *image;
+
+  MagickBooleanType
+    status;
+
+  MagickOffsetType
+    count;
+
+  MagickSizeType
+    length;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Open distributed pixel cache.
+  */
+  image=AcquireImage((ImageInfo *) NULL,exception);
+  if (image == (Image *) NULL)
+    return(MagickFalse);
+  length=sizeof(image->storage_class)+sizeof(image->colorspace)+
+    sizeof(image->alpha_trait)+sizeof(image->read_mask)+
+    sizeof(image->write_mask)+sizeof(image->columns)+sizeof(image->rows)+
+    sizeof(image->number_channels)+MaxPixelChannels*sizeof(*image->channel_map)+
+    sizeof(image->metacontent_extent);
+  count=dpc_read(file,length,message);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  /*
+    Deserialize the image attributes.
+  */
+  p=message;
+  (void) memcpy(&image->storage_class,p,sizeof(image->storage_class));
+  p+=sizeof(image->storage_class);
+  (void) memcpy(&image->colorspace,p,sizeof(image->colorspace));
+  p+=sizeof(image->colorspace);
+  (void) memcpy(&image->alpha_trait,p,sizeof(image->alpha_trait));
+  p+=sizeof(image->alpha_trait);
+  (void) memcpy(&image->read_mask,p,sizeof(image->read_mask));
+  p+=sizeof(image->read_mask);
+  (void) memcpy(&image->write_mask,p,sizeof(image->write_mask));
+  p+=sizeof(image->write_mask);
+  (void) memcpy(&image->columns,p,sizeof(image->columns));
+  p+=sizeof(image->columns);
+  (void) memcpy(&image->rows,p,sizeof(image->rows));
+  p+=sizeof(image->rows);
+  (void) memcpy(&image->number_channels,p,sizeof(image->number_channels));
+  p+=sizeof(image->number_channels);
+  (void) memcpy(image->channel_map,p,MaxPixelChannels*
+    sizeof(*image->channel_map));
+  p+=MaxPixelChannels*sizeof(*image->channel_map);
+  (void) memcpy(&image->metacontent_extent,p,sizeof(image->metacontent_extent));
+  p+=sizeof(image->metacontent_extent);
+  if (SyncImagePixelCache(image,exception) == MagickFalse)
+    return(MagickFalse);
+  status=AddValueToSplayTree(registry,(const void *) session_key,image);
+  return(status);
+}
+
+static MagickBooleanType ReadDistributeCacheMetacontent(SplayTreeInfo *registry,
+  int file,const size_t session_key,ExceptionInfo *exception)
+{
+  const unsigned char
+    *metacontent;
+
+  Image
+    *image;
+
+  MagickOffsetType
+    count;
+
+  MagickSizeType
+    length;
+
+  RectangleInfo
+    region;
+
+  register const Quantum
+    *p;
+
+  register unsigned char
+    *q;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Read distributed pixel cache metacontent.
+  */
+  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);
+  if (image == (Image *) NULL)
+    return(MagickFalse);
+  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+
+    sizeof(region.y)+sizeof(length);
+  count=dpc_read(file,length,message);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  q=message;
+  (void) memcpy(&region.width,q,sizeof(region.width));
+  q+=sizeof(region.width);
+  (void) memcpy(&region.height,q,sizeof(region.height));
+  q+=sizeof(region.height);
+  (void) memcpy(&region.x,q,sizeof(region.x));
+  q+=sizeof(region.x);
+  (void) memcpy(&region.y,q,sizeof(region.y));
+  q+=sizeof(region.y);
+  (void) memcpy(&length,q,sizeof(length));
+  q+=sizeof(length);
+  p=GetVirtualPixels(image,region.x,region.y,region.width,region.height,
+    exception);
+  if (p == (const Quantum *) NULL)
+    return(MagickFalse);
+  metacontent=(const unsigned char *) GetVirtualMetacontent(image);
+  count=dpc_send(file,length,metacontent);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  return(MagickTrue);
+}
+
+static MagickBooleanType ReadDistributeCachePixels(SplayTreeInfo *registry,
+  int file,const size_t session_key,ExceptionInfo *exception)
+{
+  Image
+    *image;
+
+  MagickOffsetType
+    count;
+
+  MagickSizeType
+    length;
+
+  RectangleInfo
+    region;
+
+  register const Quantum
+    *p;
+
+  register unsigned char
+    *q;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Read distributed pixel cache pixels.
+  */
+  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);
+  if (image == (Image *) NULL)
+    return(MagickFalse);
+  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+
+    sizeof(region.y)+sizeof(length);
+  count=dpc_read(file,length,message);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  q=message;
+  (void) memcpy(&region.width,q,sizeof(region.width));
+  q+=sizeof(region.width);
+  (void) memcpy(&region.height,q,sizeof(region.height));
+  q+=sizeof(region.height);
+  (void) memcpy(&region.x,q,sizeof(region.x));
+  q+=sizeof(region.x);
+  (void) memcpy(&region.y,q,sizeof(region.y));
+  q+=sizeof(region.y);
+  (void) memcpy(&length,q,sizeof(length));
+  q+=sizeof(length);
+  p=GetVirtualPixels(image,region.x,region.y,region.width,region.height,
+    exception);
+  if (p == (const Quantum *) NULL)
+    return(MagickFalse);
+  count=dpc_send(file,length,(unsigned char *) p);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  return(MagickTrue);
+}
+
+static void *RelinquishImageRegistry(void *image)
+{
+  return((void *) DestroyImageList((Image *) image));
+}
+
+static MagickBooleanType WriteDistributeCacheMetacontent(
+  SplayTreeInfo *registry,int file,const size_t session_key,
+  ExceptionInfo *exception)
+{
+  Image
+    *image;
+
+  MagickOffsetType
+    count;
+
+  MagickSizeType
+    length;
+
+  RectangleInfo
+    region;
+
+  register Quantum
+    *q;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent],
+    *metacontent;
+
+  /*
+    Write distributed pixel cache metacontent.
+  */
+  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);
+  if (image == (Image *) NULL)
+    return(MagickFalse);
+  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+
+    sizeof(region.y)+sizeof(length);
+  count=dpc_read(file,length,message);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  p=message;
+  (void) memcpy(&region.width,p,sizeof(region.width));
+  p+=sizeof(region.width);
+  (void) memcpy(&region.height,p,sizeof(region.height));
+  p+=sizeof(region.height);
+  (void) memcpy(&region.x,p,sizeof(region.x));
+  p+=sizeof(region.x);
+  (void) memcpy(&region.y,p,sizeof(region.y));
+  p+=sizeof(region.y);
+  (void) memcpy(&length,p,sizeof(length));
+  p+=sizeof(length);
+  q=GetAuthenticPixels(image,region.x,region.y,region.width,region.height,
+    exception);
+  if (q == (Quantum *) NULL)
+    return(MagickFalse);
+  metacontent=(unsigned char *) GetAuthenticMetacontent(image);
+  count=dpc_read(file,length,metacontent);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  return(SyncAuthenticPixels(image,exception));
+}
+
+static MagickBooleanType WriteDistributeCachePixels(SplayTreeInfo *registry,
+  int file,const size_t session_key,ExceptionInfo *exception)
+{
+  Image
+    *image;
+
+  MagickOffsetType
+    count;
+
+  MagickSizeType
+    length;
+
+  RectangleInfo
+    region;
+
+  register Quantum
+    *q;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Write distributed pixel cache pixels.
+  */
+  image=(Image *) GetValueFromSplayTree(registry,(const void *) session_key);
+  if (image == (Image *) NULL)
+    return(MagickFalse);
+  length=sizeof(region.width)+sizeof(region.height)+sizeof(region.x)+
+    sizeof(region.y)+sizeof(length);
+  count=dpc_read(file,length,message);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  p=message;
+  (void) memcpy(&region.width,p,sizeof(region.width));
+  p+=sizeof(region.width);
+  (void) memcpy(&region.height,p,sizeof(region.height));
+  p+=sizeof(region.height);
+  (void) memcpy(&region.x,p,sizeof(region.x));
+  p+=sizeof(region.x);
+  (void) memcpy(&region.y,p,sizeof(region.y));
+  p+=sizeof(region.y);
+  (void) memcpy(&length,p,sizeof(length));
+  p+=sizeof(length);
+  q=GetAuthenticPixels(image,region.x,region.y,region.width,region.height,
+    exception);
+  if (q == (Quantum *) NULL)
+    return(MagickFalse);
+  count=dpc_read(file,length,(unsigned char *) q);
+  if (count != (MagickOffsetType) length)
+    return(MagickFalse);
+  return(SyncAuthenticPixels(image,exception));
+}
+
+static HANDLER_RETURN_TYPE DistributePixelCacheClient(void *socket)
+{
+  const char
+    *shared_secret;
+
+  ExceptionInfo
+    *exception;
+
+  MagickBooleanType
+    status;
+
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  RandomInfo
+    *random_info;
+
+  size_t
+    key,
+    session_key;
+
+  SOCKET_TYPE
+    client_socket;
+
+  SplayTreeInfo
+    *registry;
+
+  StringInfo
+    *secret;
+
+  unsigned char
+    command,
+    session[2*MagickPathExtent];
+
+  /*
+    Distributed pixel cache client.
+  */
+  shared_secret=GetPolicyValue("shared-secret");
+  if (shared_secret == (const char *) NULL)
+    ThrowFatalException(CacheFatalError,"shared secret expected");
+  p=session;
+  (void) CopyMagickString((char *) p,shared_secret,MagickPathExtent);
+  p+=strlen(shared_secret);
+  random_info=AcquireRandomInfo();
+  secret=GetRandomKey(random_info,DPCSessionKeyLength);
+  (void) memcpy(p,GetStringInfoDatum(secret),DPCSessionKeyLength);
+  session_key=GetMagickSignature(secret);
+  random_info=DestroyRandomInfo(random_info);
+  exception=AcquireExceptionInfo();
+  registry=NewSplayTree((int (*)(const void *,const void *)) NULL,
+    (void *(*)(void *)) NULL,RelinquishImageRegistry);
+  client_socket=(*(SOCKET_TYPE *) socket);
+  count=dpc_send(client_socket,DPCSessionKeyLength,GetStringInfoDatum(secret));
+  secret=DestroyStringInfo(secret);
+  for ( ; ; )
+  {
+    count=dpc_read(client_socket,1,(unsigned char *) &command);
+    if (count <= 0)
+      break;
+    count=dpc_read(client_socket,sizeof(key),(unsigned char *) &key);
+    if ((count != (MagickOffsetType) sizeof(key)) || (key != session_key))
+      break;
+    status=MagickFalse;
+    switch (command)
+    {
+      case 'o':
+      {
+        status=OpenDistributeCache(registry,client_socket,session_key,
+          exception);
+        count=dpc_send(client_socket,sizeof(status),(unsigned char *) &status);
+        break;
+      }
+      case 'r':
+      {
+        status=ReadDistributeCachePixels(registry,client_socket,session_key,
+          exception);
+        break;
+      }
+      case 'R':
+      {
+        status=ReadDistributeCacheMetacontent(registry,client_socket,
+          session_key,exception);
+        break;
+      }
+      case 'w':
+      {
+        status=WriteDistributeCachePixels(registry,client_socket,session_key,
+          exception);
+        break;
+      }
+      case 'W':
+      {
+        status=WriteDistributeCacheMetacontent(registry,client_socket,
+          session_key,exception);
+        break;
+      }
+      case 'd':
+      {
+        status=DestroyDistributeCache(registry,session_key);
+        break;
+      }
+      default:
+        break;
+    }
+    if (status == MagickFalse)
+      break;
+    if (command == 'd')
+      break;
+  }
+  count=dpc_send(client_socket,sizeof(status),(unsigned char *) &status);
+  CLOSE_SOCKET(client_socket);
+  exception=DestroyExceptionInfo(exception);
+  registry=DestroySplayTree(registry);
+  return(HANDLER_RETURN_VALUE);
+}
+
+MagickExport void DistributePixelCacheServer(const int port,
+  ExceptionInfo *exception)
+{
+#if defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)
+  char
+    service[MagickPathExtent];
+
+  int
+    status;
+
+#if defined(MAGICKCORE_THREAD_SUPPORT)
+  pthread_attr_t
+    attributes;
+
+  pthread_t
+    threads;
+#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
+  DWORD
+    threadID;
+#else
+  Not implemented!
+#endif
+
+  register struct addrinfo
+    *p;
+
+  SOCKET_TYPE
+    server_socket;
+
+  struct addrinfo
+    hint,
+    *result;
+
+  struct sockaddr_in
+    address;
+
+  /*
+    Launch distributed pixel cache server.
+  */
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickCoreSignature);
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+  NTInitializeWinsock(MagickFalse);
+#endif
+  (void) ResetMagickMemory(&hint,0,sizeof(hint));
+  hint.ai_family=AF_INET;
+  hint.ai_socktype=SOCK_STREAM;
+  hint.ai_flags=AI_PASSIVE;
+  (void) FormatLocaleString(service,MagickPathExtent,"%d",port);
+  status=getaddrinfo((const char *) NULL,service,&hint,&result);
+  if (status != 0)
+    ThrowFatalException(CacheFatalError,"UnableToListen");
+  server_socket=(SOCKET_TYPE) 0;
+  for (p=result; p != (struct addrinfo *) NULL; p=p->ai_next)
+  {
+    int
+      one;
+
+    server_socket=socket(p->ai_family,p->ai_socktype,p->ai_protocol);
+    if (server_socket == -1)
+      continue;
+    one=1;
+    status=setsockopt(server_socket,SOL_SOCKET,SO_REUSEADDR,
+      CHAR_TYPE_CAST &one,(socklen_t) sizeof(one));
+    if (status == -1)
+      {
+        CLOSE_SOCKET(server_socket);
+        continue;
+      }
+    status=bind(server_socket,p->ai_addr,(socklen_t) p->ai_addrlen);
+    if (status == -1)
+      {
+        CLOSE_SOCKET(server_socket);
+        continue;
+      }
+    break;
+  }
+  if (p == (struct addrinfo *) NULL)
+    ThrowFatalException(CacheFatalError,"UnableToBind");
+  freeaddrinfo(result);
+  status=listen(server_socket,DPCPendingConnections);
+  if (status != 0)
+    ThrowFatalException(CacheFatalError,"UnableToListen");
+#if defined(MAGICKCORE_THREAD_SUPPORT)
+  pthread_attr_init(&attributes);
+#endif
+  for ( ; ; )
+  {
+    SOCKET_TYPE
+      client_socket;
+
+    socklen_t
+      length;
+
+    length=(socklen_t) sizeof(address);
+    client_socket=accept(server_socket,(struct sockaddr *) &address,&length);
+    if (client_socket == -1)
+      ThrowFatalException(CacheFatalError,"UnableToEstablishConnection");
+#if defined(MAGICKCORE_THREAD_SUPPORT)
+    status=pthread_create(&threads,&attributes,DistributePixelCacheClient,
+      (void *) &client_socket);
+    if (status == -1)
+      ThrowFatalException(CacheFatalError,"UnableToCreateClientThread");
+#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
+    if (CreateThread(0,0,DistributePixelCacheClient,(void*) &client_socket,0,
+        &threadID) == (HANDLE) NULL)
+      ThrowFatalException(CacheFatalError,"UnableToCreateClientThread");
+#else
+    Not implemented!
+#endif
+  }
+#else
+  magick_unreferenced(port);
+  magick_unreferenced(exception);
+  ThrowFatalException(MissingDelegateError,"DelegateLibrarySupportNotBuiltIn");
+#endif
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   G e t D i s t r i b u t e C a c h e F i l e                               %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetDistributeCacheFile() returns the file associated with this
+%  DistributeCacheInfo structure.
+%
+%  The format of the GetDistributeCacheFile method is:
+%
+%      int GetDistributeCacheFile(const DistributeCacheInfo *server_info)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+*/
+MagickPrivate int GetDistributeCacheFile(const DistributeCacheInfo *server_info)
+{
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  return(server_info->file);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   G e t D i s t r i b u t e C a c h e H o s t n a m e                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetDistributeCacheHostname() returns the hostname associated with this
+%  DistributeCacheInfo structure.
+%
+%  The format of the GetDistributeCacheHostname method is:
+%
+%      const char *GetDistributeCacheHostname(
+%        const DistributeCacheInfo *server_info)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+*/
+MagickPrivate const char *GetDistributeCacheHostname(
+  const DistributeCacheInfo *server_info)
+{
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  return(server_info->hostname);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   G e t D i s t r i b u t e C a c h e P o r t                               %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetDistributeCachePort() returns the port associated with this
+%  DistributeCacheInfo structure.
+%
+%  The format of the GetDistributeCachePort method is:
+%
+%      int GetDistributeCachePort(const DistributeCacheInfo *server_info)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+*/
+MagickPrivate int GetDistributeCachePort(const DistributeCacheInfo *server_info)
+{
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  return(server_info->port);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   O p e n D i s t r i b u t e P i x e l C a c h e                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  OpenDistributePixelCache() opens a pixel cache on a remote server.
+%
+%  The format of the OpenDistributePixelCache method is:
+%
+%      MagickBooleanType *OpenDistributePixelCache(
+%        DistributeCacheInfo *server_info,Image *image)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+%    o image: the image.
+%
+*/
+MagickPrivate MagickBooleanType OpenDistributePixelCache(
+  DistributeCacheInfo *server_info,Image *image)
+{
+  MagickBooleanType
+#ifdef __VMS
+     status=MagickTrue;
+#else
+    status;
+#endif
+
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Open distributed pixel cache.
+  */
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickCoreSignature);
+  p=message;
+  *p++='o';  /* open */
+  /*
+    Serialize image attributes (see ValidatePixelCacheMorphology()).
+  */
+  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));
+  p+=sizeof(server_info->session_key);
+  (void) memcpy(p,&image->storage_class,sizeof(image->storage_class));
+  p+=sizeof(image->storage_class);
+  (void) memcpy(p,&image->colorspace,sizeof(image->colorspace));
+  p+=sizeof(image->colorspace);
+  (void) memcpy(p,&image->alpha_trait,sizeof(image->alpha_trait));
+  p+=sizeof(image->alpha_trait);
+  (void) memcpy(p,&image->read_mask,sizeof(image->read_mask));
+  p+=sizeof(image->read_mask);
+  (void) memcpy(p,&image->write_mask,sizeof(image->write_mask));
+  p+=sizeof(image->write_mask);
+  (void) memcpy(p,&image->columns,sizeof(image->columns));
+  p+=sizeof(image->columns);
+  (void) memcpy(p,&image->rows,sizeof(image->rows));
+  p+=sizeof(image->rows);
+  (void) memcpy(p,&image->number_channels,sizeof(image->number_channels));
+  p+=sizeof(image->number_channels);
+  (void) memcpy(p,image->channel_map,MaxPixelChannels*
+    sizeof(*image->channel_map));
+  p+=MaxPixelChannels*sizeof(*image->channel_map);
+  (void) memcpy(p,&image->metacontent_extent,sizeof(image->metacontent_extent));
+  p+=sizeof(image->metacontent_extent);
+  count=dpc_send(server_info->file,p-message,message);
+  if (count != (MagickOffsetType) (p-message))
+    return(MagickFalse);
+  status=MagickFalse;
+  count=dpc_read(server_info->file,sizeof(status),(unsigned char *) &status);
+  if (count != (MagickOffsetType) sizeof(status))
+    return(MagickFalse);
+  return(status);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   R e a d D i s t r i b u t e P i x e l C a c h e M e t a c o n t e n t     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ReadDistributePixelCacheMetacontents() reads metacontent from the specified
+%  region of the distributed pixel cache.
+%
+%  The format of the ReadDistributePixelCacheMetacontents method is:
+%
+%      MagickOffsetType ReadDistributePixelCacheMetacontents(
+%        DistributeCacheInfo *server_info,const RectangleInfo *region,
+%        const MagickSizeType length,unsigned char *metacontent)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+%    o image: the image.
+%
+%    o region: read the metacontent from this region of the image.
+%
+%    o length: the length in bytes of the metacontent.
+%
+%    o metacontent: read these metacontent from the pixel cache.
+%
+*/
+MagickPrivate MagickOffsetType ReadDistributePixelCacheMetacontent(
+  DistributeCacheInfo *server_info,const RectangleInfo *region,
+  const MagickSizeType length,unsigned char *metacontent)
+{
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Read distributed pixel cache metacontent.
+  */
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  assert(region != (RectangleInfo *) NULL);
+  assert(metacontent != (unsigned char *) NULL);
+  if (length > (MagickSizeType) SSIZE_MAX)
+    return(-1);
+  p=message;
+  *p++='R';
+  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));
+  p+=sizeof(server_info->session_key);
+  (void) memcpy(p,&region->width,sizeof(region->width));
+  p+=sizeof(region->width);
+  (void) memcpy(p,&region->height,sizeof(region->height));
+  p+=sizeof(region->height);
+  (void) memcpy(p,&region->x,sizeof(region->x));
+  p+=sizeof(region->x);
+  (void) memcpy(p,&region->y,sizeof(region->y));
+  p+=sizeof(region->y);
+  (void) memcpy(p,&length,sizeof(length));
+  p+=sizeof(length);
+  count=dpc_send(server_info->file,p-message,message);
+  if (count != (MagickOffsetType) (p-message))
+    return(-1);
+  return(dpc_read(server_info->file,length,metacontent));
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   R e a d D i s t r i b u t e P i x e l C a c h e P i x e l s               %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ReadDistributePixelCachePixels() reads pixels from the specified region of
+%  the distributed pixel cache.
+%
+%  The format of the ReadDistributePixelCachePixels method is:
+%
+%      MagickOffsetType ReadDistributePixelCachePixels(
+%        DistributeCacheInfo *server_info,const RectangleInfo *region,
+%        const MagickSizeType length,unsigned char *restrict pixels)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+%    o image: the image.
+%
+%    o region: read the pixels from this region of the image.
+%
+%    o length: the length in bytes of the pixels.
+%
+%    o pixels: read these pixels from the pixel cache.
+%
+*/
+MagickPrivate MagickOffsetType ReadDistributePixelCachePixels(
+  DistributeCacheInfo *server_info,const RectangleInfo *region,
+  const MagickSizeType length,unsigned char *restrict pixels)
+{
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Read distributed pixel cache pixels.
+  */
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  assert(region != (RectangleInfo *) NULL);
+  assert(pixels != (unsigned char *) NULL);
+  if (length > (MagickSizeType) SSIZE_MAX)
+    return(-1);
+  p=message;
+  *p++='r';
+  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));
+  p+=sizeof(server_info->session_key);
+  (void) memcpy(p,&region->width,sizeof(region->width));
+  p+=sizeof(region->width);
+  (void) memcpy(p,&region->height,sizeof(region->height));
+  p+=sizeof(region->height);
+  (void) memcpy(p,&region->x,sizeof(region->x));
+  p+=sizeof(region->x);
+  (void) memcpy(p,&region->y,sizeof(region->y));
+  p+=sizeof(region->y);
+  (void) memcpy(p,&length,sizeof(length));
+  p+=sizeof(length);
+  count=dpc_send(server_info->file,p-message,message);
+  if (count != (MagickOffsetType) (p-message))
+    return(-1);
+  return(dpc_read(server_info->file,length,pixels));
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   R e l i n q u i s h D i s t r i b u t e P i x e l C a c h e               %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  RelinquishDistributePixelCache() frees resources acquired with
+%  OpenDistributePixelCache().
+%
+%  The format of the RelinquishDistributePixelCache method is:
+%
+%      MagickBooleanType RelinquishDistributePixelCache(
+%        DistributeCacheInfo *server_info)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+*/
+MagickPrivate MagickBooleanType RelinquishDistributePixelCache(
+  DistributeCacheInfo *server_info)
+{
+  MagickBooleanType
+#ifdef __VMS
+     status = MagickTrue;
+#else
+    status;
+#endif
+
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Delete distributed pixel cache.
+  */
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  p=message;
+  *p++='d';
+  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));
+  p+=sizeof(server_info->session_key);
+  count=dpc_send(server_info->file,p-message,message);
+  if (count != (MagickOffsetType) (p-message))
+    return(MagickFalse);
+  count=dpc_read(server_info->file,sizeof(status),(unsigned char *) &status);
+  if (count != (MagickOffsetType) sizeof(status))
+    return(MagickFalse);
+  return(status);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   W r i t e D i s t r i b u t e P i x e l C a c h e M e t a c o n t e n t   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  WriteDistributePixelCacheMetacontents() writes image metacontent to the
+%  specified region of the distributed pixel cache.
+%
+%  The format of the WriteDistributePixelCacheMetacontents method is:
+%
+%      MagickOffsetType WriteDistributePixelCacheMetacontents(
+%        DistributeCacheInfo *server_info,const RectangleInfo *region,
+%        const MagickSizeType length,const unsigned char *metacontent)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+%    o image: the image.
+%
+%    o region: write the metacontent to this region of the image.
+%
+%    o length: the length in bytes of the metacontent.
+%
+%    o metacontent: write these metacontent to the pixel cache.
+%
+*/
+MagickPrivate MagickOffsetType WriteDistributePixelCacheMetacontent(
+  DistributeCacheInfo *server_info,const RectangleInfo *region,
+  const MagickSizeType length,const unsigned char *metacontent)
+{
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Write distributed pixel cache metacontent.
+  */
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  assert(region != (RectangleInfo *) NULL);
+  assert(metacontent != (unsigned char *) NULL);
+  if (length > (MagickSizeType) SSIZE_MAX)
+    return(-1);
+  p=message;
+  *p++='W';
+  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));
+  p+=sizeof(server_info->session_key);
+  (void) memcpy(p,&region->width,sizeof(region->width));
+  p+=sizeof(region->width);
+  (void) memcpy(p,&region->height,sizeof(region->height));
+  p+=sizeof(region->height);
+  (void) memcpy(p,&region->x,sizeof(region->x));
+  p+=sizeof(region->x);
+  (void) memcpy(p,&region->y,sizeof(region->y));
+  p+=sizeof(region->y);
+  (void) memcpy(p,&length,sizeof(length));
+  p+=sizeof(length);
+  count=dpc_send(server_info->file,p-message,message);
+  if (count != (MagickOffsetType) (p-message))
+    return(-1);
+  return(dpc_send(server_info->file,length,metacontent));
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   W r i t e D i s t r i b u t e P i x e l C a c h e P i x e l s             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  WriteDistributePixelCachePixels() writes image pixels to the specified
+%  region of the distributed pixel cache.
+%
+%  The format of the WriteDistributePixelCachePixels method is:
+%
+%      MagickBooleanType WriteDistributePixelCachePixels(
+%        DistributeCacheInfo *server_info,const RectangleInfo *region,
+%        const MagickSizeType length,const unsigned char *restrict pixels)
+%
+%  A description of each parameter follows:
+%
+%    o server_info: the distributed cache info.
+%
+%    o image: the image.
+%
+%    o region: write the pixels to this region of the image.
+%
+%    o length: the length in bytes of the pixels.
+%
+%    o pixels: write these pixels to the pixel cache.
+%
+*/
+MagickPrivate MagickOffsetType WriteDistributePixelCachePixels(
+  DistributeCacheInfo *server_info,const RectangleInfo *region,
+  const MagickSizeType length,const unsigned char *restrict pixels)
+{
+  MagickOffsetType
+    count;
+
+  register unsigned char
+    *p;
+
+  unsigned char
+    message[MagickPathExtent];
+
+  /*
+    Write distributed pixel cache pixels.
+  */
+  assert(server_info != (DistributeCacheInfo *) NULL);
+  assert(server_info->signature == MagickCoreSignature);
+  assert(region != (RectangleInfo *) NULL);
+  assert(pixels != (const unsigned char *) NULL);
+  if (length > (MagickSizeType) SSIZE_MAX)
+    return(-1);
+  p=message;
+  *p++='w';
+  (void) memcpy(p,&server_info->session_key,sizeof(server_info->session_key));
+  p+=sizeof(server_info->session_key);
+  (void) memcpy(p,&region->width,sizeof(region->width));
+  p+=sizeof(region->width);
+  (void) memcpy(p,&region->height,sizeof(region->height));
+  p+=sizeof(region->height);
+  (void) memcpy(p,&region->x,sizeof(region->x));
+  p+=sizeof(region->x);
+  (void) memcpy(p,&region->y,sizeof(region->y));
+  p+=sizeof(region->y);
+  (void) memcpy(p,&length,sizeof(length));
+  p+=sizeof(length);
+  count=dpc_send(server_info->file,p-message,message);
+  if (count != (MagickOffsetType) (p-message))
+    return(-1);
+  return(dpc_send(server_info->file,length,pixels));
+}
diff --git a/MagickCore/image.h b/MagickCore/image.h
index 91f275c..1db80e4 100644
--- a/MagickCore/image.h
+++ b/MagickCore/image.h
@@ -314,6 +314,9 @@
   ProfileInfo
     *generic_profile;
 
+  long
+    tietz_offset;
+
   void
     *properties,       /* general settings, to save with image */
     *artifacts;        /* general operational/coder settings, not saved */
diff --git a/MagickCore/string.c b/MagickCore/string.c
old mode 100644
new mode 100755
index b82fa84..ab19463
--- a/MagickCore/string.c
+++ b/MagickCore/string.c
@@ -60,6 +60,9 @@
 /*
   static declarations.
 */
+#ifdef __VMS
+#define asciimap AsciiMap
+#endif
 #if !defined(MAGICKCORE_HAVE_STRCASECMP) || !defined(MAGICKCORE_HAVE_STRNCASECMP)
 static const unsigned char
   AsciiMap[] =
diff --git a/MagickCore/studio.h b/MagickCore/studio.h
old mode 100644
new mode 100755
index 17535ca..8c8462b
--- a/MagickCore/studio.h
+++ b/MagickCore/studio.h
@@ -32,8 +32,8 @@
 
 #if !defined(_MAGICKCORE_CONFIG_H)
 # define _MAGICKCORE_CONFIG_H
-# include "MagickCore/magick-config.h"
-#if defined(MAGICKCORE__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
+#include "MagickCore/magick-config.h"
+# if defined(MAGICKCORE__FILE_OFFSET_BITS) && !defined(_FILE_OFFSET_BITS)
 # define _FILE_OFFSET_BITS MAGICKCORE__FILE_OFFSET_BITS
 #endif
 #if defined(_magickcore_const) && !defined(const)
@@ -234,6 +234,9 @@
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
 # include "MagickCore/nt-base.h"
 #endif
+#ifdef __VMS
+# include "MagickCore/vms.h"
+#endif
 
 #undef HAVE_CONFIG_H
 #undef gamma
@@ -244,7 +247,7 @@
 /*
   Review these platform specific definitions.
 */
-#if defined(MAGICKCORE_POSIX_SUPPORT) && !defined(__OS2__)
+#if defined(MAGICKCORE_POSIX_SUPPORT) &&  !( defined(__OS2__) || defined( vms ) )
 # define DirectorySeparator  "/"
 # define DirectoryListSeparator  ':'
 # define EditorOptions  " -title \"Edit Image Comment\" -e vi"
@@ -255,6 +258,21 @@
 # define ReadCommandlLine(argc,argv)
 # define SetNotifyHandlers
 #else
+# ifdef __VMS
+#  define X11_APPLICATION_PATH  "decw$system_defaults:"
+#  define DirectorySeparator  ""
+#  define DirectoryListSeparator  ';'
+#  define EditorOptions  ""
+#  define Exit  exit
+#  define IsBasenameSeparator(c) \
+  (((c) == ']') || ((c) == ':') || ((c) == '/') ? MagickTrue : MagickFalse)
+#  define MAGICKCORE_LIBRARY_PATH  "sys$login:"
+#  define MAGICKCORE_SHARE_PATH  "sys$login:"
+#  define X11_PREFERENCES_PATH  "decw$user_defaults:"
+#  define ProcessPendingEvents(text)
+#  define ReadCommandlLine(argc,argv)
+#  define SetNotifyHandlers
+# endif
 # if defined(__OS2__)
 #   define DirectorySeparator  "\\"
 #   define DirectoryListSeparator  ';'
diff --git a/MagickCore/version.h_vms b/MagickCore/version.h_vms
new file mode 100755
index 0000000..c7075b7
--- /dev/null
+++ b/MagickCore/version.h_vms
Binary files differ
diff --git a/MagickCore/vms.c b/MagickCore/vms.c
new file mode 100755
index 0000000..9b76d5f
--- /dev/null
+++ b/MagickCore/vms.c
@@ -0,0 +1,271 @@
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%                            V   V  M   M  SSSSS                              %
+%                            V   V  MM MM  SS                                 %
+%                            V   V  M M M   SSS                               %
+%                             V V   M   M     SS                              %
+%                              V    M   M  SSSSS                              %
+%                                                                             %
+%                                                                             %
+%                         MagickCore VMS Utility Methods                      %
+%                                                                             %
+%                               Software Design                               %
+%                                    Cristy                                   %
+%                                October 1994                                 %
+%                                                                             %
+%                                                                             %
+%  Copyright 1999-2015 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  %
+%  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.                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  The directory methods are strongly based on similar methods written
+%  by Rich Salz.
+%
+*/
+
+#if defined(vms)
+/*
+  Include declarations.
+*/
+#include "MagickCore/studio.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/vms.h"
+
+#if !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000))
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   c l o s e d i r                                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  closedir() closes the named directory stream and frees the DIR structure.
+%
+%  The format of the closedir method is:
+%
+%
+%  A description of each parameter follows:
+%
+%    o entry: Specifies a pointer to a DIR structure.
+%
+%
+*/
+void closedir(DIR *directory)
+{
+  if (image->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
+  assert(directory != (DIR *) NULL);
+  directory->pattern=DestroyString(directory->pattern);
+  directory=DestroyString(directory);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   o p e n d i r                                                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  opendir() opens the directory named by filename and associates a directory
+%  stream with it.
+%
+%  The format of the opendir method is:
+%
+%      opendir(entry)
+%
+%  A description of each parameter follows:
+%
+%    o entry: Specifies a pointer to a DIR structure.
+%
+%
+*/
+DIR *opendir(char *name)
+{
+  DIR
+    *directory;
+
+  /*
+    Allocate memory for handle and the pattern.
+  */
+  directory=(DIR *) AcquireMagickMemory(sizeof(DIR));
+  if (directory == (DIR *) NULL)
+    {
+      errno=ENOMEM;
+      return((DIR *) NULL);
+    }
+  if (strcmp(".",name) == 0)
+    name="";
+  directory->pattern=(char *) AcquireQuantumMemory(strlen(name)+sizeof("*.*")+
+    1UL,sizeof(*directory->pattern));
+  if (directory->pattern == (char *) NULL)
+    {
+      directory=DestroyString(directory);
+      errno=ENOMEM;
+      return(NULL);
+    }
+  /*
+    Initialize descriptor.
+  */
+  (void) FormatLocaleString(directory->pattern,MagickPathExtent,"%s*.*",name);
+  directory->context=0;
+  directory->pat.dsc$a_pointer=directory->pattern;
+  directory->pat.dsc$w_length=strlen(directory->pattern);
+  directory->pat.dsc$b_dtype=DSC$K_DTYPE_T;
+  directory->pat.dsc$b_class=DSC$K_CLASS_S;
+  return(directory);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   r e a d d i r                                                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  readdir() returns a pointer to a structure representing the directory entry
+%  at the current position in the directory stream to which entry refers.
+%
+%  The format of the readdir
+%
+%      readdir(entry)
+%
+%  A description of each parameter follows:
+%
+%    o entry: Specifies a pointer to a DIR structure.
+%
+%
+*/
+struct dirent *readdir(DIR *directory)
+{
+  char
+    buffer[sizeof(directory->entry.d_name)];
+
+  int
+    status;
+
+  register char
+    *p;
+
+  register int
+    i;
+
+  struct dsc$descriptor_s
+    result;
+
+  /*
+    Initialize the result descriptor.
+  */
+  result.dsc$a_pointer=buffer;
+  result.dsc$w_length=sizeof(buffer)-2;
+  result.dsc$b_dtype=DSC$K_DTYPE_T;
+  result.dsc$b_class=DSC$K_CLASS_S;
+  status=lib$find_file(&directory->pat,&result,&directory->context);
+  if ((status == RMS$_NMF) || (directory->context == 0L))
+    return((struct dirent *) NULL);
+  /*
+    Lowercase all filenames.
+  */
+  buffer[sizeof(buffer)-1]='\0';
+  for (p=buffer; *p; p++)
+    if (isupper((int) ((unsigned char) *p)))
+      *p=tolower(*p);
+  /*
+    Skip any directory component and just copy the name.
+  */
+  p=buffer;
+  while (isspace((int) ((unsigned char) *p)) == 0)
+    p++;
+  *p='\0';
+  p=strchr(buffer,']');
+  if (p)
+    (void) CopyMagickString(directory->entry.d_name,p+1,MagickPathExtent);
+  else
+    (void) CopyMagickString(directory->entry.d_name,buffer,MagickPathExtent);
+  directory->entry.d_namlen=strlen(directory->entry.d_name);
+  return(&directory->entry);
+}
+#endif /* !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) */
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   I s M a g i c k C o n f l i c t                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  VMSIsMagickConflict() returns true if the image format conflicts with a
+%  logical drive (.e.g. SYS$SCRATCH:).
+%
+%  Contributed by Forrest Cahoon (forrest@wiredaemons.com)
+%
+%  The format of the VMSIsMagickConflict method is:
+%
+%      MagickBooleanType VMSIsMagickConflict(const char *magick)
+%
+%  A description of each parameter follows:
+%
+%    o magick: Specifies the image format.
+%
+%
+*/
+MagickExport MagickBooleanType VMSIsMagickConflict(const char *magick)
+{
+  ile3
+    item_list[2];
+
+  int
+    device_class,
+    status;
+
+  struct dsc$descriptor_s
+    device;
+
+  assert(magick != (char *) NULL);
+  device.dsc$w_length=strlen(magick);
+  device.dsc$a_pointer=(char *) magick;
+  device.dsc$b_class=DSC$K_CLASS_S;
+  device.dsc$b_dtype=DSC$K_DTYPE_T;
+  item_list[0].ile3$w_length=sizeof(device_class);
+  item_list[0].ile3$w_code=DVI$_DEVCLASS;
+  item_list[0].ile3$ps_bufaddr=&device_class;
+  item_list[0].ile3$ps_retlen_addr=NULL;
+  (void) ResetMagickMemory(&item_list[1],0,sizeof(item_list[1]));
+  status=sys$getdviw(0,0,&device,&item_list,0,0,0,0);
+  if ((status == SS$_NONLOCAL) ||
+      ((status & 0x01) && (device_class & (DC$_DISK | DC$_TAPE))))
+    return(MagickTrue);
+  return(MagickFalse);
+}
+#endif /* defined(vms) */
diff --git a/MagickCore/vms.h b/MagickCore/vms.h
new file mode 100755
index 0000000..7a5534e
--- /dev/null
+++ b/MagickCore/vms.h
@@ -0,0 +1,985 @@
+/*
+  Copyright 1999-2015 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 VMS compatibility methods.
+*/
+#ifndef _MAGICKCORE_VMS_H
+#define _MAGICKCORE_VMS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+#if defined(__DECC) || defined(__DECCXX)
+#  include <lib$routines.h>
+#  include <starlet.h>
+#endif
+
+#include <errno.h>
+#include <descrip.h>
+#include <rmsdef.h>
+#include <ctype.h>
+#include <dvidef.h>
+#include <dcdef.h>
+#include <ssdef.h>
+
+#define DtSaverGetWindows DTSAVERGETWINDOWS
+#define XAddHosts XADDHOSTS
+#define XAllocClassHint XALLOCCLASSHINT
+#define XAllocColor XALLOCCOLOR
+#define XAllocColorCells XALLOCCOLORCELLS
+#define XAllocIconSize XALLOCICONSIZE
+#define XAllocNamedColor XALLOCNAMEDCOLOR
+#define XAllocSizeHints XALLOCSIZEHINTS
+#define XAllocStandardColormap XALLOCSTANDARDCOLORMAP
+#define XAllocWMHints XALLOCWMHINTS
+#define XAllowEvents XALLOWEVENTS
+#define XAutoRepeatOff XAUTOREPEATOFF
+#define XAutoRepeatOn XAUTOREPEATON
+#define XBaseFontNameListOfFontSet XBASEFONTNAMELISTOFFONTSET
+#define XBell XBELL
+#define XBitmapPad XBITMAPPAD
+#define XBlackPixel XBLACKPIXEL
+#define XBlackPixelOfScreen XBLACKPIXELOFSCREEN
+#define XChangeActivePointerGrab XCHANGEACTIVEPOINTERGRAB
+#define XChangeGC XCHANGEGC
+#define XChangeKeyboardControl XCHANGEKEYBOARDCONTROL
+#define XChangeProperty XCHANGEPROPERTY
+#define XChangeWindowAttributes XCHANGEWINDOWATTRIBUTES
+#define XCheckIfEvent XCHECKIFEVENT
+#define XCheckMaskEvent XCHECKMASKEVENT
+#define XCheckTypedWindowEvent XCHECKTYPEDWINDOWEVENT
+#define XCheckWindowEvent XCHECKWINDOWEVENT
+#define XClearArea XCLEARAREA
+#define XClearWindow XCLEARWINDOW
+#define XClipBox XCLIPBOX
+#define XCloseDisplay XCLOSEDISPLAY
+#define XCloseIM XCLOSEIM
+#define XConfigureWindow XCONFIGUREWINDOW
+#define XConvertSelection XCONVERTSELECTION
+#define XCopyArea XCOPYAREA
+#define XCopyColormapAndFree XCOPYCOLORMAPANDFREE
+#define XCopyGC XCOPYGC
+#define XCopyPlane XCOPYPLANE
+#define XCreateBitmapFromData XCREATEBITMAPFROMDATA
+#define XCreateColormap XCREATECOLORMAP
+#define XCreateFontCursor XCREATEFONTCURSOR
+#define XCreateFontSet XCREATEFONTSET
+#define XCreateGC XCREATEGC
+#define XCreateIC XCREATEIC
+#define XCreateImage XCREATEIMAGE
+#define XCreatePixmap XCREATEPIXMAP
+#define XCreatePixmapCursor XCREATEPIXMAPCURSOR
+#define XCreatePixmapFromBitmapData XCREATEPIXMAPFROMBITMAPDATA
+#define XCreateRegion XCREATEREGION
+#define XCreateSimpleWindow XCREATESIMPLEWINDOW
+#define XCreateWindow XCREATEWINDOW
+#define XDefaultColormap XDEFAULTCOLORMAP
+#define XDefaultColormapOfScreen XDEFAULTCOLORMAPOFSCREEN
+#define XDefaultDepth XDEFAULTDEPTH
+#define XDefaultGC XDEFAULTGC
+#define XDefaultRootWindow XDEFAULTROOTWINDOW
+#define XDefaultScreen XDEFAULTSCREEN
+#define XDefaultScreenOfDisplay XDEFAULTSCREENOFDISPLAY
+#define XDefaultVisual XDEFAULTVISUAL
+#define XDefineCursor XDEFINECURSOR
+#define XDeleteProperty XDELETEPROPERTY
+#define XDestroyIC XDESTROYIC
+#define XDestroyRegion XDESTROYREGION
+#define XDestroySubwindows XDESTROYSUBWINDOWS
+#define XDestroyWindow XDESTROYWINDOW
+#define XDisableAccessControl XDISABLEACCESSCONTROL
+#define XDisplayCells XDISPLAYCELLS
+#define XDisplayHeight XDISPLAYHEIGHT
+#define XDisplayName XDISPLAYNAME
+#define XDisplayOfScreen XDISPLAYOFSCREEN
+#define XDisplayWidth XDISPLAYWIDTH
+#define XDrawArc XDRAWARC
+#define XDrawArcs XDRAWARCS
+#define XDrawImageString XDRAWIMAGESTRING
+#define XDrawImageString16 XDRAWIMAGESTRING16
+#define XDrawLine XDRAWLINE
+#define XDrawLines XDRAWLINES
+#define XDrawPoint XDRAWPOINT
+#define XDrawPoints XDRAWPOINTS
+#define XDrawRectangle XDRAWRECTANGLE
+#define XDrawRectangles XDRAWRECTANGLES
+#define XDrawSegments XDRAWSEGMENTS
+#define XDrawString XDRAWSTRING
+#define XDrawString16 XDRAWSTRING16
+#define XDrawText XDRAWTEXT
+#define XEmptyRegion XEMPTYREGION
+#define XEnableAccessControl XENABLEACCESSCONTROL
+#define XEqualRegion XEQUALREGION
+#define XEventsQueued XEVENTSQUEUED
+#define XExtentsOfFontSet XEXTENTSOFFONTSET
+#define XFetchName XFETCHNAME
+#define XFillArc XFILLARC
+#define XFillArcs XFILLARCS
+#define XFillPolygon XFILLPOLYGON
+#define XFillRectangle XFILLRECTANGLE
+#define XFillRectangles XFILLRECTANGLES
+#define XFilterEvent XFILTEREVENT
+#define XFlush XFLUSH
+#define XFontsOfFontSet XFONTSOFFONTSET
+#define XForceScreenSaver XFORCESCREENSAVER
+#define XFree XFREE
+#define XFreeColormap XFREECOLORMAP
+#define XFreeColors XFREECOLORS
+#define XFreeCursor XFREECURSOR
+#define XFreeDeviceList XFREEDEVICELIST
+#define XFreeDeviceState XFREEDEVICESTATE
+#define XFreeFont XFREEFONT
+#define XFreeFontInfo XFREEFONTINFO
+#define XFreeFontNames XFREEFONTNAMES
+#define XFreeFontSet XFREEFONTSET
+#define XFreeGC XFREEGC
+#define XFreeModifiermap XFREEMODIFIERMAP
+#define XFreePixmap XFREEPIXMAP
+#define XFreeStringList XFREESTRINGLIST
+#define XGetAtomName XGETATOMNAME
+#define XGetCommand XGETCOMMAND
+#define XGetDefault XGETDEFAULT
+#define XGetErrorDatabaseText XGETERRORDATABASETEXT
+#define XGetErrorText XGETERRORTEXT
+#define XGetExtensionVersion XGETEXTENSIONVERSION
+#define XGetFontProperty XGETFONTPROPERTY
+#define XGetGCValues XGETGCVALUES
+#define XGetGeometry XGETGEOMETRY
+#define XGetICValues XGETICVALUES
+#define XGetIMValues XGETIMVALUES
+#define XGetIconName XGETICONNAME
+#define XGetIconSizes XGETICONSIZES
+#define XGetImage XGETIMAGE
+#define XGetKeyboardControl XGETKEYBOARDCONTROL
+#define XGetModifierMapping XGETMODIFIERMAPPING
+#define XGetMotionEvents XGETMOTIONEVENTS
+#define XGetNormalHints XGETNORMALHINTS
+#define XGetRGBColormaps XGETRGBCOLORMAPS
+#define XGetScreenSaver XGETSCREENSAVER
+#define XGetSelectionOwner XGETSELECTIONOWNER
+#define XGetSubImage XGETSUBIMAGE
+#define XGetVisualInfo XGETVISUALINFO
+#define XGetWMColormapWindows XGETWMCOLORMAPWINDOWS
+#define XGetWMHints XGETWMHINTS
+#define XGetWMName XGETWMNAME
+#define XGetWMNormalHints XGETWMNORMALHINTS
+#define XGetWindowAttributes XGETWINDOWATTRIBUTES
+#define XGetWindowProperty XGETWINDOWPROPERTY
+#define XGrabButton XGRABBUTTON
+#define XGrabKeyboard XGRABKEYBOARD
+#define XGrabPointer XGRABPOINTER
+#define XGrabServer XGRABSERVER
+#define XHeightOfScreen XHEIGHTOFSCREEN
+#define XIconifyWindow XICONIFYWINDOW
+#define XIfEvent XIFEVENT
+#define XInstallColormap XINSTALLCOLORMAP
+#define XInternAtom XINTERNATOM
+#define XIntersectRegion XINTERSECTREGION
+#define XKeycodeToKeysym XKEYCODETOKEYSYM
+#define XKeysymToKeycode XKEYSYMTOKEYCODE
+#define XKeysymToString XKEYSYMTOSTRING
+#define XKillClient XKILLCLIENT
+#define XListFonts XLISTFONTS
+#define XListFontsWithInfo XLISTFONTSWITHINFO
+#define XListHosts XLISTHOSTS
+#define XListInputDevices XLISTINPUTDEVICES
+#define XListInstalledColormaps XLISTINSTALLEDCOLORMAPS
+#define XListPixmapFormats XLISTPIXMAPFORMATS
+#define XListProperties XLISTPROPERTIES
+#define XLoadFont XLOADFONT
+#define XLoadQueryFont XLOADQUERYFONT
+#define XLookupColor XLOOKUPCOLOR
+#define XLookupKeysym XLOOKUPKEYSYM
+#define XLookupString XLOOKUPSTRING
+#define XLowerWindow XLOWERWINDOW
+#define XMapRaised XMAPRAISED
+#define XMapSubwindows XMAPSUBWINDOWS
+#define XMapWindow XMAPWINDOW
+#define XMatchVisualInfo XMATCHVISUALINFO
+#define XMaxRequestSize XMAXREQUESTSIZE
+#define XMoveResizeWindow XMOVERESIZEWINDOW
+#define XMoveWindow XMOVEWINDOW
+#define XNextEvent XNEXTEVENT
+#define XOffsetRegion XOFFSETREGION
+#define XOpenDevice XOPENDEVICE
+#define XOpenDisplay XOPENDISPLAY
+#define XOpenIM XOPENIM
+#define XParseColor XPARSECOLOR
+#define XParseGeometry XPARSEGEOMETRY
+#define XPeekEvent XPEEKEVENT
+#define XPeekIfEvent XPEEKIFEVENT
+#define XPending XPENDING
+#define XPointInRegion XPOINTINREGION
+#define XPolygonRegion XPOLYGONREGION
+#define XPutBackEvent XPUTBACKEVENT
+#define XPutImage XPUTIMAGE
+#define XQueryColor XQUERYCOLOR
+#define XQueryColors XQUERYCOLORS
+#define XQueryDeviceState XQUERYDEVICESTATE
+#define XQueryExtension XQUERYEXTENSION
+#define XQueryFont XQUERYFONT
+#define XQueryKeymap XQUERYKEYMAP
+#define XQueryPointer XQUERYPOINTER
+#define XQueryTree XQUERYTREE
+#define XRaiseWindow XRAISEWINDOW
+#define XReadBitmapFile XREADBITMAPFILE
+#define XRecolorCursor XRECOLORCURSOR
+#define XReconfigureWMWindow XRECONFIGUREWMWINDOW
+#define XRectInRegion XRECTINREGION
+#define XRefreshKeyboardMapping XREFRESHKEYBOARDMAPPING
+#define XRemoveHosts XREMOVEHOSTS
+#define XReparentWindow XREPARENTWINDOW
+#define XResetScreenSaver XRESETSCREENSAVER
+#define XResizeWindow XRESIZEWINDOW
+#define XResourceManagerString XRESOURCEMANAGERSTRING
+#define XRestackWindows XRESTACKWINDOWS
+#define XRootWindow XROOTWINDOW
+#define XRootWindowOfScreen XROOTWINDOWOFSCREEN
+#define XScreenNumberOfScreen XSCREENNUMBEROFSCREEN
+#define XScreenOfDisplay XSCREENOFDISPLAY
+#define XSelectAsyncEvent XSELECTASYNCEVENT
+#define XSelectAsyncInput XSELECTASYNCINPUT
+#define XSelectExtensionEvent XSELECTEXTENSIONEVENT
+#define XSelectInput XSELECTINPUT
+#define XSendEvent XSENDEVENT
+#define XServerVendor XSERVERVENDOR
+#define XSetBackground XSETBACKGROUND
+#define XSetClassHint XSETCLASSHINT
+#define XSetClipMask XSETCLIPMASK
+#define XSetClipOrigin XSETCLIPORIGIN
+#define XSetClipRectangles XSETCLIPRECTANGLES
+#define XSetCloseDownMode XSETCLOSEDOWNMODE
+#define XSetCommand XSETCOMMAND
+#define XSetDashes XSETDASHES
+#define XSetErrorHandler XSETERRORHANDLER
+#define XSetFillRule XSETFILLRULE
+#define XSetFillStyle XSETFILLSTYLE
+#define XSetFont XSETFONT
+#define XSetForeground XSETFOREGROUND
+#define XSetFunction XSETFUNCTION
+#define XSetGraphicsExposures XSETGRAPHICSEXPOSURES
+#define XSetICFocus XSETICFOCUS
+#define XSetICValues XSETICVALUES
+#define XSetIOErrorHandler XSETIOERRORHANDLER
+#define XSetIconName XSETICONNAME
+#define XSetInputFocus XSETINPUTFOCUS
+#define XSetLineAttributes XSETLINEATTRIBUTES
+#define XSetLocaleModifiers XSETLOCALEMODIFIERS
+#define XSetNormalHints XSETNORMALHINTS
+#define XSetPlaneMask XSETPLANEMASK
+#define XSetRegion XSETREGION
+#define XSetScreenSaver XSETSCREENSAVER
+#define XSetSelectionOwner XSETSELECTIONOWNER
+#define XSetStandardProperties XSETSTANDARDPROPERTIES
+#define XSetState XSETSTATE
+#define XSetStipple XSETSTIPPLE
+#define XSetSubwindowMode XSETSUBWINDOWMODE
+#define XSetTSOrigin XSETTSORIGIN
+#define XSetTile XSETTILE
+#define XSetTransientForHint XSETTRANSIENTFORHINT
+#define XSetWMColormapWindows XSETWMCOLORMAPWINDOWS
+#define XSetWMHints XSETWMHINTS
+#define XSetWMIconName XSETWMICONNAME
+#define XSetWMName XSETWMNAME
+#define XSetWMNormalHints XSETWMNORMALHINTS
+#define XSetWMProperties XSETWMPROPERTIES
+#define XSetWMProtocols XSETWMPROTOCOLS
+#define XSetWindowBackground XSETWINDOWBACKGROUND
+#define XSetWindowBackgroundPixmap XSETWINDOWBACKGROUNDPIXMAP
+#define XSetWindowColormap XSETWINDOWCOLORMAP
+#define XShapeCombineMask XSHAPECOMBINEMASK
+#define XShapeCombineRectangles XSHAPECOMBINERECTANGLES
+#define XShapeGetRectangles XSHAPEGETRECTANGLES
+#define XShrinkRegion XSHRINKREGION
+#define XStoreBytes XSTOREBYTES
+#define XStoreColor XSTORECOLOR
+#define XStoreColors XSTORECOLORS
+#define XStoreName XSTORENAME
+#define XStringListToTextProperty XSTRINGLISTTOTEXTPROPERTY
+#define XStringToKeysym XSTRINGTOKEYSYM
+#define XSubtractRegion XSUBTRACTREGION
+#define XSupportsLocale XSUPPORTSLOCALE
+#define XSync XSYNC
+#define XSynchronize XSYNCHRONIZE
+#define XTextExtents XTEXTEXTENTS
+#define XTextExtents16 XTEXTEXTENTS16
+#define XTextWidth XTEXTWIDTH
+#define XTextWidth16 XTEXTWIDTH16
+#define XTranslateCoordinates XTRANSLATECOORDINATES
+#define XUndefineCursor XUNDEFINECURSOR
+#define XUngrabButton XUNGRABBUTTON
+#define XUngrabKeyboard XUNGRABKEYBOARD
+#define XUngrabPointer XUNGRABPOINTER
+#define XUngrabServer XUNGRABSERVER
+#define XUninstallColormap XUNINSTALLCOLORMAP
+#define XUnionRectWithRegion XUNIONRECTWITHREGION
+#define XUnionRegion XUNIONREGION
+#define XUnmapWindow XUNMAPWINDOW
+#define XUnsetICFocus XUNSETICFOCUS
+#define XVaCreateNestedList XVACREATENESTEDLIST
+#define XVisualIDFromVisual XVISUALIDFROMVISUAL
+#define XWMGeometry XWMGEOMETRY
+#define XWarpPointer XWARPPOINTER
+#define XWhitePixel XWHITEPIXEL
+#define XWidthOfScreen XWIDTHOFSCREEN
+#define XWindowEvent XWINDOWEVENT
+#define XWithdrawWindow XWITHDRAWWINDOW
+#define XXorRegion XXORREGION
+#define XmActivateProtocol XMACTIVATEPROTOCOL
+#define XmAddProtocolCallback XMADDPROTOCOLCALLBACK
+#define XmAddProtocols XMADDPROTOCOLS
+#define XmChangeColor XMCHANGECOLOR
+#define XmClipboardCopy XMCLIPBOARDCOPY
+#define XmClipboardEndCopy XMCLIPBOARDENDCOPY
+#define XmClipboardInquireLength XMCLIPBOARDINQUIRELENGTH
+#define XmClipboardLock XMCLIPBOARDLOCK
+#define XmClipboardRetrieve XMCLIPBOARDRETRIEVE
+#define XmClipboardStartCopy XMCLIPBOARDSTARTCOPY
+#define XmClipboardUnlock XMCLIPBOARDUNLOCK
+#define XmCreateArrowButton XMCREATEARROWBUTTON
+#define XmCreateArrowButtonGadget XMCREATEARROWBUTTONGADGET
+#define XmCreateBulletinBoardDialog XMCREATEBULLETINBOARDDIALOG
+#define XmCreateCascadeButton XMCREATECASCADEBUTTON
+#define XmCreateCascadeButtonGadget XMCREATECASCADEBUTTONGADGET
+#define XmCreateDialogShell XMCREATEDIALOGSHELL
+#define XmCreateDragIcon XMCREATEDRAGICON
+#define XmCreateDrawingArea XMCREATEDRAWINGAREA
+#define XmCreateDrawnButton XMCREATEDRAWNBUTTON
+#define XmCreateErrorDialog XMCREATEERRORDIALOG
+#define XmCreateFileSelectionBox XMCREATEFILESELECTIONBOX
+#define XmCreateFileSelectionDialog XMCREATEFILESELECTIONDIALOG
+#define XmCreateForm XMCREATEFORM
+#define XmCreateFormDialog XMCREATEFORMDIALOG
+#define XmCreateFrame XMCREATEFRAME
+#define XmCreateInformationDialog XMCREATEINFORMATIONDIALOG
+#define XmCreateLabel XMCREATELABEL
+#define XmCreateLabelGadget XMCREATELABELGADGET
+#define XmCreateMainWindow XMCREATEMAINWINDOW
+#define XmCreateMenuBar XMCREATEMENUBAR
+#define XmCreateMessageBox XMCREATEMESSAGEBOX
+#define XmCreateMessageDialog XMCREATEMESSAGEDIALOG
+#define XmCreateOptionMenu XMCREATEOPTIONMENU
+#define XmCreatePanedWindow XMCREATEPANEDWINDOW
+#define XmCreatePopupMenu XMCREATEPOPUPMENU
+#define XmCreatePromptDialog XMCREATEPROMPTDIALOG
+#define XmCreatePulldownMenu XMCREATEPULLDOWNMENU
+#define XmCreatePushButton XMCREATEPUSHBUTTON
+#define XmCreatePushButtonGadget XMCREATEPUSHBUTTONGADGET
+#define XmCreateQuestionDialog XMCREATEQUESTIONDIALOG
+#define XmCreateRadioBox XMCREATERADIOBOX
+#define XmCreateRowColumn XMCREATEROWCOLUMN
+#define XmCreateScale XMCREATESCALE
+#define XmCreateScrollBar XMCREATESCROLLBAR
+#define XmCreateScrolledList XMCREATESCROLLEDLIST
+#define XmCreateScrolledText XMCREATESCROLLEDTEXT
+#define XmCreateScrolledWindow XMCREATESCROLLEDWINDOW
+#define XmCreateSelectionDialog XMCREATESELECTIONDIALOG
+#define XmCreateSeparator XMCREATESEPARATOR
+#define XmCreateSeparatorGadget XMCREATESEPARATORGADGET
+#define XmCreateTemplateDialog XMCREATETEMPLATEDIALOG
+#define XmCreateText XMCREATETEXT
+#define XmCreateTextField XMCREATETEXTFIELD
+#define XmCreateToggleButton XMCREATETOGGLEBUTTON
+#define XmCreateToggleButtonGadget XMCREATETOGGLEBUTTONGADGET
+#define XmCreateWarningDialog XMCREATEWARNINGDIALOG
+#define XmCvtCTToXmString XMCVTCTTOXMSTRING
+#define XmDestroyPixmap XMDESTROYPIXMAP
+#define XmDragStart XMDRAGSTART
+#define XmDropSiteRegister XMDROPSITEREGISTER
+#define XmDropSiteUnregister XMDROPSITEUNREGISTER
+#define XmDropSiteUpdate XMDROPSITEUPDATE
+#define XmDropTransferStart XMDROPTRANSFERSTART
+#define XmFileSelectionBoxGetChild XMFILESELECTIONBOXGETCHILD
+#define XmFileSelectionDoSearch XMFILESELECTIONDOSEARCH
+#define XmFontListAppendEntry XMFONTLISTAPPENDENTRY
+#define XmFontListCopy XMFONTLISTCOPY
+#define XmFontListCreate XMFONTLISTCREATE
+#define XmFontListEntryCreate XMFONTLISTENTRYCREATE
+#define XmFontListEntryFree XMFONTLISTENTRYFREE
+#define XmFontListEntryGetFont XMFONTLISTENTRYGETFONT
+#define XmFontListEntryGetTag XMFONTLISTENTRYGETTAG
+#define XmFontListEntryLoad XMFONTLISTENTRYLOAD
+#define XmFontListFree XMFONTLISTFREE
+#define XmFontListFreeFontContext XMFONTLISTFREEFONTCONTEXT
+#define XmFontListGetNextFont XMFONTLISTGETNEXTFONT
+#define XmFontListInitFontContext XMFONTLISTINITFONTCONTEXT
+#define XmFontListNextEntry XMFONTLISTNEXTENTRY
+#define XmGetColors XMGETCOLORS
+#define XmGetFocusWidget XMGETFOCUSWIDGET
+#define XmGetMenuCursor XMGETMENUCURSOR
+#define XmGetPixmap XMGETPIXMAP
+#define XmGetPixmapByDepth XMGETPIXMAPBYDEPTH
+#define XmGetTearOffControl XMGETTEAROFFCONTROL
+#define XmGetXmDisplay XMGETXMDISPLAY
+#define XmImMbLookupString XMIMMBLOOKUPSTRING
+#define XmImRegister XMIMREGISTER
+#define XmImSetFocusValues XMIMSETFOCUSVALUES
+#define XmImSetValues XMIMSETVALUES
+#define XmImUnregister XMIMUNREGISTER
+#define XmImUnsetFocus XMIMUNSETFOCUS
+#define XmInstallImage XMINSTALLIMAGE
+#define XmInternAtom XMINTERNATOM
+#define XmIsMotifWMRunning XMISMOTIFWMRUNNING
+#define XmListAddItem XMLISTADDITEM
+#define XmListAddItemUnselected XMLISTADDITEMUNSELECTED
+#define XmListAddItems XMLISTADDITEMS
+#define XmListAddItemsUnselected XMLISTADDITEMSUNSELECTED
+#define XmListDeleteAllItems XMLISTDELETEALLITEMS
+#define XmListDeleteItem XMLISTDELETEITEM
+#define XmListDeleteItemsPos XMLISTDELETEITEMSPOS
+#define XmListDeletePos XMLISTDELETEPOS
+#define XmListDeselectAllItems XMLISTDESELECTALLITEMS
+#define XmListDeselectPos XMLISTDESELECTPOS
+#define XmListGetKbdItemPos XMLISTGETKBDITEMPOS
+#define XmListGetMatchPos XMLISTGETMATCHPOS
+#define XmListGetSelectedPos XMLISTGETSELECTEDPOS
+#define XmListItemExists XMLISTITEMEXISTS
+#define XmListItemPos XMLISTITEMPOS
+#define XmListPosSelected XMLISTPOSSELECTED
+#define XmListReplaceItems XMLISTREPLACEITEMS
+#define XmListReplaceItemsPos XMLISTREPLACEITEMSPOS
+#define XmListSelectItem XMLISTSELECTITEM
+#define XmListSelectPos XMLISTSELECTPOS
+#define XmListSetBottomPos XMLISTSETBOTTOMPOS
+#define XmListSetItem XMLISTSETITEM
+#define XmListSetKbdItemPos XMLISTSETKBDITEMPOS
+#define XmListSetPos XMLISTSETPOS
+#define XmMainWindowSetAreas XMMAINWINDOWSETAREAS
+#define XmMenuPosition XMMENUPOSITION
+#define XmMessageBoxGetChild XMMESSAGEBOXGETCHILD
+#define XmOptionButtonGadget XMOPTIONBUTTONGADGET
+#define XmOptionLabelGadget XMOPTIONLABELGADGET
+#define XmProcessTraversal XMPROCESSTRAVERSAL
+#define XmQmotif XMQMOTIF
+#define XmRemoveProtocolCallback XMREMOVEPROTOCOLCALLBACK
+#define XmRemoveProtocols XMREMOVEPROTOCOLS
+#define XmRemoveTabGroup XMREMOVETABGROUP
+#define XmRepTypeGetId XMREPTYPEGETID
+#define XmRepTypeGetRecord XMREPTYPEGETRECORD
+#define XmRepTypeRegister XMREPTYPEREGISTER
+#define XmRepTypeValidValue XMREPTYPEVALIDVALUE
+#define XmScrollBarSetValues XMSCROLLBARSETVALUES
+#define XmScrolledWindowSetAreas XMSCROLLEDWINDOWSETAREAS
+#define XmSelectionBoxGetChild XMSELECTIONBOXGETCHILD
+#define XmSetColorCalculation XMSETCOLORCALCULATION
+#define XmStringByteCompare XMSTRINGBYTECOMPARE
+#define XmStringCompare XMSTRINGCOMPARE
+#define XmStringConcat XMSTRINGCONCAT
+#define XmStringCopy XMSTRINGCOPY
+#define XmStringCreate XMSTRINGCREATE
+#define XmStringCreateLocalized XMSTRINGCREATELOCALIZED
+#define XmStringCreateLtoR XMSTRINGCREATELTOR
+#define XmStringCreateSimple XMSTRINGCREATESIMPLE
+#define XmStringDraw XMSTRINGDRAW
+#define XmStringDrawUnderline XMSTRINGDRAWUNDERLINE
+#define XmStringExtent XMSTRINGEXTENT
+#define XmStringFree XMSTRINGFREE
+#define XmStringFreeContext XMSTRINGFREECONTEXT
+#define XmStringGetLtoR XMSTRINGGETLTOR
+#define XmStringGetNextComponent XMSTRINGGETNEXTCOMPONENT
+#define XmStringGetNextSegment XMSTRINGGETNEXTSEGMENT
+#define XmStringInitContext XMSTRINGINITCONTEXT
+#define XmStringLength XMSTRINGLENGTH
+#define XmStringLtoRCreate XMSTRINGLTORCREATE
+#define XmStringNConcat XMSTRINGNCONCAT
+#define XmStringSegmentCreate XMSTRINGSEGMENTCREATE
+#define XmStringWidth XMSTRINGWIDTH
+#define XmTextClearSelection XMTEXTCLEARSELECTION
+#define XmTextCopy XMTEXTCOPY
+#define XmTextCut XMTEXTCUT
+#define XmTextFieldClearSelection XMTEXTFIELDCLEARSELECTION
+#define XmTextFieldCopy XMTEXTFIELDCOPY
+#define XmTextFieldCut XMTEXTFIELDCUT
+#define XmTextFieldGetEditable XMTEXTFIELDGETEDITABLE
+#define XmTextFieldGetInsertionPosition XMTEXTFIELDGETINSERTIONPOSITION
+#define XmTextFieldGetLastPosition XMTEXTFIELDGETLASTPOSITION
+#define XmTextFieldGetMaxLength XMTEXTFIELDGETMAXLENGTH
+#define XmTextFieldGetSelection XMTEXTFIELDGETSELECTION
+#define XmTextFieldGetSelectionPosition XMTEXTFIELDGETSELECTIONPOSITION
+#define XmTextFieldGetString XMTEXTFIELDGETSTRING
+#define XmTextFieldInsert XMTEXTFIELDINSERT
+#define XmTextFieldPaste XMTEXTFIELDPASTE
+#define XmTextFieldRemove XMTEXTFIELDREMOVE
+#define XmTextFieldReplace XMTEXTFIELDREPLACE
+#define XmTextFieldSetAddMode XMTEXTFIELDSETADDMODE
+#define XmTextFieldSetHighlight XMTEXTFIELDSETHIGHLIGHT
+#define XmTextFieldSetInsertionPosition XMTEXTFIELDSETINSERTIONPOSITION
+#define XmTextFieldSetMaxLength XMTEXTFIELDSETMAXLENGTH
+#define XmTextFieldSetSelection XMTEXTFIELDSETSELECTION
+#define XmTextFieldSetString XMTEXTFIELDSETSTRING
+#define XmTextFieldShowPosition XMTEXTFIELDSHOWPOSITION
+#define XmTextGetCursorPosition XMTEXTGETCURSORPOSITION
+#define XmTextGetEditable XMTEXTGETEDITABLE
+#define XmTextGetInsertionPosition XMTEXTGETINSERTIONPOSITION
+#define XmTextGetLastPosition XMTEXTGETLASTPOSITION
+#define XmTextGetMaxLength XMTEXTGETMAXLENGTH
+#define XmTextGetSelection XMTEXTGETSELECTION
+#define XmTextGetSelectionPosition XMTEXTGETSELECTIONPOSITION
+#define XmTextGetString XMTEXTGETSTRING
+#define XmTextInsert XMTEXTINSERT
+#define XmTextPaste XMTEXTPASTE
+#define XmTextPosToXY XMTEXTPOSTOXY
+#define XmTextRemove XMTEXTREMOVE
+#define XmTextReplace XMTEXTREPLACE
+#define XmTextSetCursorPosition XMTEXTSETCURSORPOSITION
+#define XmTextSetEditable XMTEXTSETEDITABLE
+#define XmTextSetHighlight XMTEXTSETHIGHLIGHT
+#define XmTextSetInsertionPosition XMTEXTSETINSERTIONPOSITION
+#define XmTextSetSelection XMTEXTSETSELECTION
+#define XmTextSetString XMTEXTSETSTRING
+#define XmTextShowPosition XMTEXTSHOWPOSITION
+#define XmToggleButtonGadgetGetState XMTOGGLEBUTTONGADGETGETSTATE
+#define XmToggleButtonGadgetSetState XMTOGGLEBUTTONGADGETSETSTATE
+#define XmToggleButtonGetState XMTOGGLEBUTTONGETSTATE
+#define XmToggleButtonSetState XMTOGGLEBUTTONSETSTATE
+#define XmUninstallImage XMUNINSTALLIMAGE
+#define XmUpdateDisplay XMUPDATEDISPLAY
+#define XmVaCreateSimpleRadioBox XMVACREATESIMPLERADIOBOX
+#define XmbDrawString XMBDRAWSTRING
+#define XmbLookupString XMBLOOKUPSTRING
+#define XmbResetIC XMBRESETIC
+#define XmbSetWMProperties XMBSETWMPROPERTIES
+#define XmbTextEscapement XMBTEXTESCAPEMENT
+#define XmbTextExtents XMBTEXTEXTENTS
+#define XmbTextListToTextProperty XMBTEXTLISTTOTEXTPROPERTY
+#define XmbTextPropertyToTextList XMBTEXTPROPERTYTOTEXTLIST
+#define XmuClientWindow XMUCLIENTWINDOW
+#define XmuCvtStringToBitmap XMUCVTSTRINGTOBITMAP
+#define XmuLookupStandardColormap XMULOOKUPSTANDARDCOLORMAP
+#define XmuPrintDefaultErrorMessage XMUPRINTDEFAULTERRORMESSAGE
+#define XrmCombineDatabase XRMCOMBINEDATABASE
+#define XrmCombineFileDatabase XRMCOMBINEFILEDATABASE
+#define XrmDestroyDatabase XRMDESTROYDATABASE
+#define XrmGetDatabase XRMGETDATABASE
+#define XrmGetFileDatabase XRMGETFILEDATABASE
+#define XrmGetResource XRMGETRESOURCE
+#define XrmGetStringDatabase XRMGETSTRINGDATABASE
+#define XrmInitialize XRMINITIALIZE
+#define XrmMergeDatabases XRMMERGEDATABASES
+#define XrmParseCommand XRMPARSECOMMAND
+#define XrmPutFileDatabase XRMPUTFILEDATABASE
+#define XrmPutLineResource XRMPUTLINERESOURCE
+#define XrmPutStringResource XRMPUTSTRINGRESOURCE
+#define XrmQPutStringResource XRMQPUTSTRINGRESOURCE
+#define XrmQuarkToString XRMQUARKTOSTRING
+#define XrmStringToBindingQuarkList XRMSTRINGTOBINDINGQUARKLIST
+#define XrmStringToQuark XRMSTRINGTOQUARK
+#define XrmStringToQuark XRMSTRINGTOQUARK
+#define XtAddCallback XTADDCALLBACK
+#define XtAddCallbacks XTADDCALLBACKS
+#define XtAddConverter XTADDCONVERTER
+#define XtAddEventHandler XTADDEVENTHANDLER
+#define XtAddExposureToRegion XTADDEXPOSURETOREGION
+#define XtAddGrab XTADDGRAB
+#define XtAllocateGC XTALLOCATEGC
+#define XtAppAddActions XTAPPADDACTIONS
+#define XtAppAddInput XTAPPADDINPUT
+#define XtAppAddTimeOut XTAPPADDTIMEOUT
+#define XtAppAddWorkProc XTAPPADDWORKPROC
+#define XtAppCreateShell XTAPPCREATESHELL
+#define XtAppInitialize XTAPPINITIALIZE
+#define XtAppMainLoop XTAPPMAINLOOP
+#define XtAppNextEvent XTAPPNEXTEVENT
+#define XtAppPeekEvent XTAPPPEEKEVENT
+#define XtAppPending XTAPPPENDING
+#define XtAppProcessEvent XTAPPPROCESSEVENT
+#define XtAppSetErrorHandler XTAPPSETERRORHANDLER
+#define XtAppSetFallbackResources XTAPPSETFALLBACKRESOURCES
+#define XtAppSetWarningHandler XTAPPSETWARNINGHANDLER
+#define XtAppSetWarningMsgHandler XTAPPSETWARNINGMSGHANDLER
+#define XtAppWarning XTAPPWARNING
+#define XtCallActionProc XTCALLACTIONPROC
+#define XtCallCallbackList XTCALLCALLBACKLIST
+#define XtCallCallbacks XTCALLCALLBACKS
+#define XtCloseDisplay XTCLOSEDISPLAY
+#define XtConfigureWidget XTCONFIGUREWIDGET
+#define XtConvertAndStore XTCONVERTANDSTORE
+#define XtCreateApplicationContext XTCREATEAPPLICATIONCONTEXT
+#define XtCreateManagedWidget XTCREATEMANAGEDWIDGET
+#define XtCreatePopupShell XTCREATEPOPUPSHELL
+#define XtCreateWidget XTCREATEWIDGET
+#define XtDatabase XTDATABASE
+#define XtDestroyApplicationContext XTDESTROYAPPLICATIONCONTEXT
+#define XtDestroyWidget XTDESTROYWIDGET
+#define XtDisownSelection XTDISOWNSELECTION
+#define XtDispatchEvent XTDISPATCHEVENT
+#define XtDisplay XTDISPLAY
+#define XtDisplayOfObject XTDISPLAYOFOBJECT
+#define XtDisplayStringConvWarning XTDISPLAYSTRINGCONVWARNING
+#define XtDisplayToApplicationContext XTDISPLAYTOAPPLICATIONCONTEXT
+#define XtError XTERROR
+#define XtFree XTFREE
+#define XtGetActionKeysym XTGETACTIONKEYSYM
+#define XtGetActionList XTGETACTIONLIST
+#define XtGetApplicationNameAndClass XTGETAPPLICATIONNAMEANDCLASS
+#define XtGetApplicationResources XTGETAPPLICATIONRESOURCES
+#define XtGetGC XTGETGC
+#define XtGetMultiClickTime XTGETMULTICLICKTIME
+#define XtGetSelectionValue XTGETSELECTIONVALUE
+#define XtGetSelectionValues XTGETSELECTIONVALUES
+#define XtGetSubresources XTGETSUBRESOURCES
+#define XtGetValues XTGETVALUES
+#define XtGrabButton XTGRABBUTTON
+#define XtGrabKeyboard XTGRABKEYBOARD
+#define XtGrabPointer XTGRABPOINTER
+#define XtHasCallbacks XTHASCALLBACKS
+#define XtInitialize XTINITIALIZE
+#define XtInitializeWidgetClass XTINITIALIZEWIDGETCLASS
+#define XtInsertEventHandler XTINSERTEVENTHANDLER
+#define XtIsManaged XTISMANAGED
+#define XtIsObject XTISOBJECT
+#define XtIsRealized XTISREALIZED
+#define XtIsSensitive XTISSENSITIVE
+#define XtIsSubclass XTISSUBCLASS
+#define XtLastTimestampProcessed XTLASTTIMESTAMPPROCESSED
+#define XtMainLoop XTMAINLOOP
+#define XtMakeGeometryRequest XTMAKEGEOMETRYREQUEST
+#define XtMakeResizeRequest XTMAKERESIZEREQUEST
+#define XtMalloc XTMALLOC
+#define XtManageChild XTMANAGECHILD
+#define XtManageChildren XTMANAGECHILDREN
+#define XtMergeArgLists XTMERGEARGLISTS
+#define XtMoveWidget XTMOVEWIDGET
+#define XtName XTNAME
+#define XtNameToWidget XTNAMETOWIDGET
+#define XtOpenDisplay XTOPENDISPLAY
+#define XtOverrideTranslations XTOVERRIDETRANSLATIONS
+#define XtOwnSelection XTOWNSELECTION
+#define XtParseTranslationTable XTPARSETRANSLATIONTABLE
+#define XtPopdown XTPOPDOWN
+#define XtPopup XTPOPUP
+#define XtQueryGeometry XTQUERYGEOMETRY
+#define XtRealizeWidget XTREALIZEWIDGET
+#define XtRealloc XTREALLOC
+#define XtRegisterDrawable _XTREGISTERWINDOW
+#define XtReleaseGC XTRELEASEGC
+#define XtRemoveAllCallbacks XTREMOVEALLCALLBACKS
+#define XtRemoveCallback XTREMOVECALLBACK
+#define XtRemoveEventHandler XTREMOVEEVENTHANDLER
+#define XtRemoveGrab XTREMOVEGRAB
+#define XtRemoveInput XTREMOVEINPUT
+#define XtRemoveTimeOut XTREMOVETIMEOUT
+#define XtRemoveWorkProc XTREMOVEWORKPROC
+#define XtResizeWidget XTRESIZEWIDGET
+#define XtResolvePathname XTRESOLVEPATHNAME
+#define XtScreen XTSCREEN
+#define XtSetKeyboardFocus XTSETKEYBOARDFOCUS
+#define XtSetMappedWhenManaged XTSETMAPPEDWHENMANAGED
+#define XtSetSensitive XTSETSENSITIVE
+#define XtSetTypeConverter XTSETTYPECONVERTER
+#define XtSetValues XTSETVALUES
+#define XtShellStrings XTSHELLSTRINGS
+#define XtStrings XTSTRINGS
+#define XtToolkitInitialize XTTOOLKITINITIALIZE
+#define XtTranslateCoords XTTRANSLATECOORDS
+#define XtTranslateKeycode XTTRANSLATEKEYCODE
+#define XtUngrabButton XTUNGRABBUTTON
+#define XtUngrabKeyboard XTUNGRABKEYBOARD
+#define XtUngrabPointer XTUNGRABPOINTER
+#define XtUnmanageChild XTUNMANAGECHILD
+#define XtUnmanageChildren XTUNMANAGECHILDREN
+#define XtUnrealizeWidget XTUNREALIZEWIDGET
+#define XtUnregisterDrawable _XTUNREGISTERWINDOW
+#define XtVaCreateManagedWidget XTVACREATEMANAGEDWIDGET
+#define XtVaCreatePopupShell XTVACREATEPOPUPSHELL
+#define XtVaCreateWidget XTVACREATEWIDGET
+#define XtVaGetValues XTVAGETVALUES
+#define XtVaSetValues XTVASETVALUES
+#define XtWarning XTWARNING
+#define XtWidgetToApplicationContext XTWIDGETTOAPPLICATIONCONTEXT
+#define XtWindow XTWINDOW
+#define XtWindowOfObject XTWINDOWOFOBJECT
+#define XtWindowToWidget XTWINDOWTOWIDGET
+#define XwcDrawString XWCDRAWSTRING
+#define XwcFreeStringList XWCFREESTRINGLIST
+#define XwcTextEscapement XWCTEXTESCAPEMENT
+#define XwcTextExtents XWCTEXTEXTENTS
+#define XwcTextListToTextProperty XWCTEXTLISTTOTEXTPROPERTY
+#define XwcTextPropertyToTextList XWCTEXTPROPERTYTOTEXTLIST
+#define _XRegisterFilterByType _XREGISTERFILTERBYTYPE
+#define _XUnregisterFilter _XUNREGISTERFILTER
+#define _XmBottomShadowColorDefault _XMBOTTOMSHADOWCOLORDEFAULT
+#define _XmClearBorder _XMCLEARBORDER
+#define _XmConfigureObject _XMCONFIGUREOBJECT
+#define _XmDestroyParentCallback _XMDESTROYPARENTCALLBACK
+#define _XmDrawArrow _XMDRAWARROW
+#define _XmDrawShadows _XMDRAWSHADOWS
+#define _XmFontListGetDefaultFont _XMFONTLISTGETDEFAULTFONT
+#define _XmFromHorizontalPixels _XMFROMHORIZONTALPIXELS
+#define _XmFromVerticalPixels _XMFROMVERTICALPIXELS
+#define _XmGetClassExtensionPtr _XMGETCLASSEXTENSIONPTR
+#define _XmGetDefaultFontList _XMGETDEFAULTFONTLIST
+#define _XmGetTextualDragIcon _XMGETTEXTUALDRAGICON
+#define _XmGetWidgetExtData _XMGETWIDGETEXTDATA
+#define _XmGrabKeyboard _XMGRABKEYBOARD
+#define _XmGrabPointer _XMGRABPOINTER
+#define _XmInheritClass _XMINHERITCLASS
+#define _XmInputInGadget _XMINPUTINGADGET
+#define _XmMakeGeometryRequest _XMMAKEGEOMETRYREQUEST
+#define _XmMenuPopDown _XMMENUPOPDOWN
+#define _XmMoveObject _XMMOVEOBJECT
+#define _XmNavigChangeManaged _XMNAVIGCHANGEMANAGED
+#define _XmOSBuildFileList _XMOSBUILDFILELIST
+#define _XmOSFileCompare _XMOSFILECOMPARE
+#define _XmOSFindPatternPart _XMOSFINDPATTERNPART
+#define _XmOSQualifyFileSpec _XMOSQUALIFYFILESPEC
+#define _XmPostPopupMenu _XMPOSTPOPUPMENU
+#define _XmPrimitiveEnter _XMPRIMITIVEENTER
+#define _XmPrimitiveLeave _XMPRIMITIVELEAVE
+#define _XmRedisplayGadgets _XMREDISPLAYGADGETS
+#define _XmShellIsExclusive _XMSHELLISEXCLUSIVE
+#define _XmStringDraw _XMSTRINGDRAW
+#define _XmStringGetTextConcat _XMSTRINGGETTEXTCONCAT
+#define _XmStrings _XMSTRINGS
+#define _XmToHorizontalPixels _XMTOHORIZONTALPIXELS
+#define _XmToVerticalPixels _XMTOVERTICALPIXELS
+#define _XmTopShadowColorDefault _XMTOPSHADOWCOLORDEFAULT
+#define _Xm_fastPtr _XM_FASTPTR
+#define _XtCheckSubclassFlag _XTCHECKSUBCLASSFLAG
+#define _XtInherit _XTINHERIT
+#define _XtInheritTranslations _XTINHERITTRANSLATIONS
+#define applicationShellWidgetClass APPLICATIONSHELLWIDGETCLASS
+#define compositeWidgetClass COMPOSITEWIDGETCLASS
+#define lib$ediv LIB$EDIV
+#define lib$find_file LIB$FIND_FILE
+#define lib$find_file_end LIB$FIND_FILE_END
+#define lib$set_symbol LIB$SET_SYMBOL
+#define lib$sfree1_dd LIB$SFREE1_DD
+#define lib$spawn LIB$SPAWN
+#define lib$subx LIB$SUBX
+#define lib$wait LIB$WAIT
+#define overrideShellWidgetClass OVERRIDESHELLWIDGETCLASS
+#define pthread_attr_create PTHREAD_ATTR_CREATE
+#define pthread_attr_delete PTHREAD_ATTR_DELETE
+#define pthread_attr_destroy PTHREAD_ATTR_DESTROY
+#define pthread_attr_getdetach_np PTHREAD_ATTR_GETDETACH_NP
+#define pthread_attr_getguardsize_np PTHREAD_ATTR_GETGUARDSIZE_NP
+#define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED
+#define pthread_attr_getprio PTHREAD_ATTR_GETPRIO
+#define pthread_attr_getsched PTHREAD_ATTR_GETSCHED
+#define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM
+#define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY
+#define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE
+#define pthread_attr_init PTHREAD_ATTR_INIT
+#define pthread_attr_setdetach_np PTHREAD_ATTR_SETDETACH_NP
+#define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE
+#define pthread_attr_setguardsize_np PTHREAD_ATTR_SETGUARDSIZE_NP
+#define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED
+#define pthread_attr_setprio PTHREAD_ATTR_SETPRIO
+#define pthread_attr_setsched PTHREAD_ATTR_SETSCHED
+#define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM
+#define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY
+#define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE
+#define pthread_cancel PTHREAD_CANCEL
+#define pthread_cancel_e PTHREAD_CANCEL_E
+#define pthread_cond_broadcast PTHREAD_COND_BROADCAST
+#define pthread_cond_destroy PTHREAD_COND_DESTROY
+#define pthread_cond_init PTHREAD_COND_INIT
+#define pthread_cond_sig_preempt_int_np PTHREAD_COND_SIG_PREEMPT_INT_NP
+#define pthread_cond_signal PTHREAD_COND_SIGNAL
+#define pthread_cond_signal_int_np PTHREAD_COND_SIGNAL_INT_NP
+#define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT
+#define pthread_cond_wait PTHREAD_COND_WAIT
+#define pthread_condattr_create PTHREAD_CONDATTR_CREATE
+#define pthread_condattr_delete PTHREAD_CONDATTR_DELETE
+#define pthread_condattr_init PTHREAD_CONDATTR_INIT
+#define pthread_create PTHREAD_CREATE
+#define pthread_delay_np PTHREAD_DELAY_NP
+#define pthread_detach PTHREAD_DETACH
+#define pthread_equal PTHREAD_EQUAL
+#define pthread_exc_fetch_fp_np PTHREAD_EXC_FETCH_FP_NP
+#define pthread_exc_handler_np PTHREAD_EXC_HANDLER_NP
+#define pthread_exc_pop_ctx_np PTHREAD_EXC_POP_CTX_NP
+#define pthread_exc_push_ctx_np PTHREAD_EXC_PUSH_CTX_NP
+#define pthread_exc_savecontext_np PTHREAD_EXC_SAVECONTEXT_NP
+#define pthread_exit PTHREAD_EXIT
+#define pthread_get_expiration_np PTHREAD_GET_EXPIRATION_NP
+#define pthread_getprio PTHREAD_GETPRIO
+#define pthread_getschedparam PTHREAD_GETSCHEDPARAM
+#define pthread_getscheduler PTHREAD_GETSCHEDULER
+#define pthread_getspecific PTHREAD_GETSPECIFIC
+#define pthread_getunique_np PTHREAD_GETUNIQUE_NP
+#define pthread_join PTHREAD_JOIN
+#define pthread_join32 PTHREAD_JOIN32
+#define pthread_key_create PTHREAD_KEY_CREATE
+#define pthread_key_delete PTHREAD_KEY_DELETE
+#define pthread_keycreate PTHREAD_KEYCREATE
+#define pthread_kill PTHREAD_KILL
+#define pthread_lock_global_np PTHREAD_LOCK_GLOBAL_NP
+#define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY
+#define pthread_mutex_init PTHREAD_MUTEX_INIT
+#define pthread_mutex_lock PTHREAD_MUTEX_LOCK
+#define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK
+#define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK
+#define pthread_mutexattr_create PTHREAD_MUTEXATTR_CREATE
+#define pthread_mutexattr_delete PTHREAD_MUTEXATTR_DELETE
+#define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY
+#define pthread_mutexattr_getkind_np PTHREAD_MUTEXATTR_GETKIND_NP
+#define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT
+#define pthread_mutexattr_setkind_np PTHREAD_MUTEXATTR_SETKIND_NP
+#define pthread_mutexattr_settype_np PTHREAD_MUTEXATTR_SETTYPE_NP
+#define pthread_once PTHREAD_ONCE
+#define pthread_resume_np PTHREAD_RESUME_NP
+#define pthread_self PTHREAD_SELF
+#define pthread_setasynccancel PTHREAD_SETASYNCCANCEL
+#define pthread_setcancel PTHREAD_SETCANCEL
+#define pthread_setcancelstate PTHREAD_SETCANCELSTATE
+#define pthread_setprio PTHREAD_SETPRIO
+#define pthread_setschedparam PTHREAD_SETSCHEDPARAM
+#define pthread_setscheduler PTHREAD_SETSCHEDULER
+#define pthread_setspecific PTHREAD_SETSPECIFIC
+#define pthread_suspend_np PTHREAD_SUSPEND_NP
+#define pthread_testcancel PTHREAD_TESTCANCEL
+#define pthread_unlock_global_np PTHREAD_UNLOCK_GLOBAL_NP
+#define pthread_yield PTHREAD_YIELD
+#define pthread_yield_np PTHREAD_YIELD_NP
+#define pthread_exc_raise_np PTHREAD_EXC_RAISE_NP
+#define pthread_setcanceltype PTHREAD_SETCANCELTYPE
+#define shellWidgetClass SHELLWIDGETCLASS
+#define sys$assign SYS$ASSIGN
+#define sys$bintim SYS$BINTIM
+#define sys$crembx SYS$CREMBX
+#define sys$dassgn SYS$DASSGN
+#define sys$dclexh SYS$DCLEXH
+#define sys$getdviw SYS$GETDVIW
+#define sys$getsyiw SYS$GETSYIW
+#define sys$gettim SYS$GETTIM
+#define sys$qio SYS$QIO
+#define sys$qiow SYS$QIOW
+#define sys$setef SYS$SETEF
+#define sys$synch SYS$SYNCH
+#define topLevelShellClassRec TOPLEVELSHELLCLASSREC
+#define topLevelShellWidgetClass TOPLEVELSHELLWIDGETCLASS
+#define transientShellWidgetClass TRANSIENTSHELLWIDGETCLASS
+#define vendorShellClassRec VENDORSHELLCLASSREC
+#define vendorShellWidgetClass VENDORSHELLWIDGETCLASS
+#define wmShellWidgetClass WMSHELLWIDGETCLASS
+#define xmArrowButtonWidgetClass XMARROWBUTTONWIDGETCLASS
+#define xmBulletinBoardWidgetClass XMBULLETINBOARDWIDGETCLASS
+#define xmCascadeButtonClassRec XMCASCADEBUTTONCLASSREC
+#define xmCascadeButtonGadgetClass XMCASCADEBUTTONGADGETCLASS
+#define xmCascadeButtonWidgetClass XMCASCADEBUTTONWIDGETCLASS
+#define xmDialogShellWidgetClass XMDIALOGSHELLWIDGETCLASS
+#define xmDrawingAreaWidgetClass XMDRAWINGAREAWIDGETCLASS
+#define xmDrawnButtonWidgetClass XMDRAWNBUTTONWIDGETCLASS
+#define xmFileSelectionBoxWidgetClass XMFILESELECTIONBOXWIDGETCLASS
+#define xmFormWidgetClass XMFORMWIDGETCLASS
+#define xmFrameWidgetClass XMFRAMEWIDGETCLASS
+#define xmGadgetClass XMGADGETCLASS
+#define xmLabelGadgetClass XMLABELGADGETCLASS
+#define xmLabelWidgetClass XMLABELWIDGETCLASS
+#define xmListWidgetClass XMLISTWIDGETCLASS
+#define xmMainWindowWidgetClass XMMAINWINDOWWIDGETCLASS
+#define xmManagerClassRec XMMANAGERCLASSREC
+#define xmManagerWidgetClass XMMANAGERWIDGETCLASS
+#define xmMenuShellWidgetClass XMMENUSHELLWIDGETCLASS
+#define xmMessageBoxWidgetClass XMMESSAGEBOXWIDGETCLASS
+#define xmPrimitiveClassRec XMPRIMITIVECLASSREC
+#define xmPrimitiveWidgetClass XMPRIMITIVEWIDGETCLASS
+#define xmPushButtonClassRec XMPUSHBUTTONCLASSREC
+#define xmPushButtonGadgetClass XMPUSHBUTTONGADGETCLASS
+#define xmPushButtonWidgetClass XMPUSHBUTTONWIDGETCLASS
+#define xmRowColumnWidgetClass XMROWCOLUMNWIDGETCLASS
+#define xmSashWidgetClass XMSASHWIDGETCLASS
+#define xmScaleWidgetClass XMSCALEWIDGETCLASS
+#define xmScrollBarWidgetClass XMSCROLLBARWIDGETCLASS
+#define xmScrolledWindowClassRec XMSCROLLEDWINDOWCLASSREC
+#define xmScrolledWindowWidgetClass XMSCROLLEDWINDOWWIDGETCLASS
+#define xmSeparatorGadgetClass XMSEPARATORGADGETCLASS
+#define xmSeparatorWidgetClass XMSEPARATORWIDGETCLASS
+#define xmTextFieldWidgetClass XMTEXTFIELDWIDGETCLASS
+#define xmTextWidgetClass XMTEXTWIDGETCLASS
+#define xmToggleButtonGadgetClass XMTOGGLEBUTTONGADGETCLASS
+#define xmToggleButtonWidgetClass XMTOGGLEBUTTONWIDGETCLASS
+#define XInitImage XINITIMAGE
+#define _XInitImageFuncPtrs _XINITIMAGEFUNCPTRS
+#define XtParent XTPARENT
+#define XConnectionNumber XCONNECTIONNUMBER
+#define XDrawText16 XDRAWTEXT16
+#define XFindContext XFINDCONTEXT
+#define XGetInputFocus XGETINPUTFOCUS
+#define XSaveContext XSAVECONTEXT
+#define XUniqueContext XUNIQUECONTEXT
+#define XChangePointerControl XCHANGEPOINTERCONTROL
+#pragma __member_alignment __save
+typedef struct _ile3
+{
+#pragma __nomember_alignment
+  unsigned short int
+    ile3$w_length,
+    ile3$w_code;
+
+  void
+    *ile3$ps_bufaddr;
+
+  unsigned short int
+    *ile3$ps_retlen_addr;
+} ile3;
+#pragma __member_alignment __restore
+
+
+#if defined(__VMS_VER) && (__VMS_VER >= 70000000)
+#include <dirent.h>
+#else
+
+/*
+  Typedef declarations.
+*/
+struct dirent
+{
+  char
+    d_name[255];
+
+  int
+    d_namlen;
+};
+
+typedef struct _dirdesc
+{
+  long
+    context;
+
+  char
+    *pattern;
+
+  struct dirent
+    entry;
+
+  struct dsc$descriptor_s
+    pat;
+} DIR;
+
+extern DIR
+  *opendir(char *);
+
+extern struct dirent
+  *readdir(DIR *);
+
+extern void
+  closedir(DIR *);
+#endif
+
+extern MagickExport MagickBooleanType
+  VMSIsMagickConflict(const char *);
+
+extern void
+  XtFree(char *);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif
diff --git a/MagickWand/method-attribute.h b/MagickWand/method-attribute.h
old mode 100644
new mode 100755
index fe3ab93..ebaee5f
--- a/MagickWand/method-attribute.h
+++ b/MagickWand/method-attribute.h
@@ -103,6 +103,10 @@
 #  define wand_aligned(x)  __attribute__((aligned(x)))
 #  define wand_attribute  __attribute__
 #  define wand_unused(x)  wand_unused_ ## x __attribute__((unused))
+#elif defined( __VMS )
+#  define wand_aligned(x)  /* nothing */
+#  define wand_attribute(x)  /* nothing */
+#  define wand_unused(x) x
 #else
 #  define wand_aligned(x)  __declspec(align(x))
 #  define wand_attribute(x)  /* nothing */
diff --git a/Magickshr.opt b/Magickshr.opt
index ee260a9..0195a31 100644
--- a/Magickshr.opt
+++ b/Magickshr.opt
@@ -1,18 +1,14 @@
-IDENTIFICATION="Magick V6.5"
-GSMATCH=LEQUAL,6,5
+IDENTIFICATION="Magick V7.3"
+GSMATCH=LEQUAL,7,3
 case_sensitive=YES
 symbol_vector=(AcquireImageInfo=PROCEDURE)
-symbol_vector=(AcquireMemory=PROCEDURE)
 symbol_vector=(AddNoiseImage=PROCEDURE)
-symbol_vector=(AllocateImage=PROCEDURE)
-symbol_vector=(AllocateString=PROCEDURE)
 symbol_vector=(AnnotateImage=PROCEDURE)
 symbol_vector=(AppendImageFormat=PROCEDURE)
 symbol_vector=(AppendImages=PROCEDURE)
 symbol_vector=(Ascii85Encode=PROCEDURE)
 symbol_vector=(Ascii85Flush=PROCEDURE)
 symbol_vector=(Ascii85Initialize=PROCEDURE)
-symbol_vector=(AverageImages=PROCEDURE)
 symbol_vector=(BlobToImage=PROCEDURE)
 symbol_vector=(BlurImage=PROCEDURE)
 symbol_vector=(BorderImage=PROCEDURE)
@@ -24,17 +20,13 @@
 symbol_vector=(CloneString=PROCEDURE)
 symbol_vector=(CloseBlob=PROCEDURE)
 symbol_vector=(CoalesceImages=PROCEDURE)
-symbol_vector=(ColorFloodfillImage=PROCEDURE)
 symbol_vector=(CompositeImage=PROCEDURE)
 symbol_vector=(ContrastImage=PROCEDURE)
 symbol_vector=(CropImage=PROCEDURE)
 symbol_vector=(CycleColormapImage=PROCEDURE)
-symbol_vector=(DeconstructImages=PROCEDURE)
-symbol_vector=(DescribeImage=PROCEDURE)
 symbol_vector=(DespeckleImage=PROCEDURE)
 symbol_vector=(DestroyImage=PROCEDURE)
 symbol_vector=(DestroyImageInfo=PROCEDURE)
-symbol_vector=(DestroyImages=PROCEDURE)
 symbol_vector=(DestroyMontageInfo=PROCEDURE)
 symbol_vector=(DrawImage=PROCEDURE)
 symbol_vector=(EdgeImage=PROCEDURE)
@@ -46,14 +38,10 @@
 symbol_vector=(ExpandFilenames=PROCEDURE)
 symbol_vector=(FlipImage=PROCEDURE)
 symbol_vector=(FlopImage=PROCEDURE)
-symbol_vector=(FormatMagickString=PROCEDURE)
 symbol_vector=(FrameImage=PROCEDURE)
 symbol_vector=(GammaImage=PROCEDURE)
 symbol_vector=(GetBlobInfo=PROCEDURE)
-symbol_vector=(GetExceptionInfo=PROCEDURE)
 symbol_vector=(GetImageInfo=PROCEDURE)
-symbol_vector=(GetImagePixels=PROCEDURE)
-symbol_vector=(GetOnePixel=PROCEDURE)
 symbol_vector=(GetMontageInfo=PROCEDURE)
 symbol_vector=(GetQuantizeInfo=PROCEDURE)
 symbol_vector=(GlobExpression=PROCEDURE)
@@ -62,8 +50,6 @@
 symbol_vector=(ImageToBlob=PROCEDURE)
 symbol_vector=(ImplodeImage=PROCEDURE)
 symbol_vector=(IsGeometry=PROCEDURE)
-symbol_vector=(IsGrayImage=PROCEDURE)
-symbol_vector=(LiberateMemory=PROCEDURE)
 symbol_vector=(ListDelegateInfo=PROCEDURE)
 symbol_vector=(ListFiles=PROCEDURE)
 symbol_vector=(ListMagickInfo=PROCEDURE)
@@ -73,46 +59,33 @@
 symbol_vector=(MagickError=PROCEDURE)
 symbol_vector=(MagickWarning=PROCEDURE)
 symbol_vector=(MagnifyImage=PROCEDURE)
-symbol_vector=(MapImage=PROCEDURE)
-symbol_vector=(MapImages=PROCEDURE)
-symbol_vector=(MatteFloodfillImage=PROCEDURE)
 symbol_vector=(MinifyImage=PROCEDURE)
 symbol_vector=(ModulateImage=PROCEDURE)
 symbol_vector=(MogrifyImage=PROCEDURE)
 symbol_vector=(MogrifyImages=PROCEDURE)
 symbol_vector=(MontageImages=PROCEDURE)
 symbol_vector=(MorphImages=PROCEDURE)
-symbol_vector=(MosaicImages=PROCEDURE)
 symbol_vector=(MultilineCensus=PROCEDURE)
 symbol_vector=(NegateImage=PROCEDURE)
 symbol_vector=(NormalizeImage=PROCEDURE)
 symbol_vector=(OilPaintImage=PROCEDURE)
-symbol_vector=(OpaqueImage=PROCEDURE)
 symbol_vector=(OpenBlob=PROCEDURE)
 symbol_vector=(PackbitsEncodeImage=PROCEDURE)
-symbol_vector=(ParseImageGeometry=PROCEDURE)
 symbol_vector=(PingImage=PROCEDURE)
-symbol_vector=(PostscriptGeometry=PROCEDURE)
-symbol_vector=(QuantizationError=PROCEDURE)
 symbol_vector=(QuantizeImage=PROCEDURE)
 symbol_vector=(QuantizeImages=PROCEDURE)
-symbol_vector=(QueryColorDatabase=PROCEDURE)
 symbol_vector=(RaiseImage=PROCEDURE)
 symbol_vector=(ReadBlob=PROCEDURE)
 symbol_vector=(ReadImage=PROCEDURE)
-symbol_vector=(ReduceNoiseImage=PROCEDURE)
-symbol_vector=(RGBTransformImage=PROCEDURE)
 symbol_vector=(RollImage=PROCEDURE)
 symbol_vector=(RotateImage=PROCEDURE)
 symbol_vector=(SampleImage=PROCEDURE)
 symbol_vector=(ScaleImage=PROCEDURE)
 symbol_vector=(SeekBlob=PROCEDURE)
 symbol_vector=(SegmentImage=PROCEDURE)
-symbol_vector=(SetCacheThreshold=PROCEDURE)
 symbol_vector=(SetClientName=PROCEDURE)
 symbol_vector=(SetErrorHandler=PROCEDURE)
 symbol_vector=(SetImageInfo=PROCEDURE)
-symbol_vector=(SetMonitorHandler=PROCEDURE)
 symbol_vector=(SetWarningHandler=PROCEDURE)
 symbol_vector=(ShadeImage=PROCEDURE)
 symbol_vector=(SharpenImage=PROCEDURE)
@@ -124,17 +97,12 @@
 symbol_vector=(SteganoImage=PROCEDURE)
 symbol_vector=(StereoImage=PROCEDURE)
 symbol_vector=(StringToList=PROCEDURE)
-symbol_vector=(Strip=PROCEDURE)
+symbol_vector=(StripString=PROCEDURE)
 symbol_vector=(SwirlImage=PROCEDURE)
 symbol_vector=(SyncImage=PROCEDURE)
-symbol_vector=(SyncImagePixels=PROCEDURE)
 symbol_vector=(TellBlob=PROCEDURE)
-symbol_vector=(TemporaryFilename=PROCEDURE)
 symbol_vector=(TextureImage=PROCEDURE)
 symbol_vector=(TransformImage=PROCEDURE)
-symbol_vector=(TransformRGBImage=PROCEDURE)
-symbol_vector=(TranslateText=PROCEDURE)
-symbol_vector=(TransparentImage=PROCEDURE)
 symbol_vector=(WriteBlob=PROCEDURE)
 symbol_vector=(WriteImage=PROCEDURE)
 symbol_vector=(XAnnotateImage=PROCEDURE)
@@ -182,7 +150,6 @@
 symbol_vector=(XMenuWidget=PROCEDURE)
 symbol_vector=(XNoticeWidget=PROCEDURE)
 symbol_vector=(XPreferencesWidget=PROCEDURE)
-symbol_vector=(XQueryColorDatabase=PROCEDURE)
 symbol_vector=(XQueryPosition=PROCEDURE)
 symbol_vector=(XRefreshWindow=PROCEDURE)
 symbol_vector=(XRemoteCommand=PROCEDURE)
@@ -193,31 +160,18 @@
 symbol_vector=(XWindowByID=PROCEDURE)
 symbol_vector=(XWindowByName=PROCEDURE)
 symbol_vector=(XWindowByProperty=PROCEDURE)
-symbol_vector=(ZoomImage=PROCEDURE)
-symbol_vector=(AllocateImageColormap=PROCEDURE)
-symbol_vector=(GetIndexes=PROCEDURE)
 symbol_vector=(GetNumberColors=PROCEDURE)
-symbol_vector=(GetImageException=PROCEDURE)
 symbol_vector=(ThrowException=PROCEDURE)
 symbol_vector=(GetMagickVersion=PROCEDURE)
 symbol_vector=(GetExecutionPath=PROCEDURE)
-symbol_vector=(FlattenImages=PROCEDURE)
-symbol_vector=(GetImageAttribute=PROCEDURE)
 symbol_vector=(ListColorInfo=PROCEDURE)
 symbol_vector=(ListMagicInfo=PROCEDURE)
-symbol_vector=(DestroyMagick=PROCEDURE)
-symbol_vector=(InitializeMagick=PROCEDURE)
 symbol_vector=(ListTypeInfo=PROCEDURE)
-symbol_vector=(SetImageClipMask=PROCEDURE)
-symbol_vector=(StringToDouble=PROCEDURE)
 symbol_vector=(SetImageType=PROCEDURE)
-symbol_vector=(SetImageOpacity=PROCEDURE)
 symbol_vector=(DestroyImageList=PROCEDURE)
 symbol_vector=(GetPageGeometry=PROCEDURE)
 symbol_vector=(WriteImages=PROCEDURE)
-symbol_vector=(PushImageList=PROCEDURE)
 symbol_vector=(GetGeometry=PROCEDURE)
-symbol_vector=(GetImageGeometry=PROCEDURE)
 symbol_vector=(CatchException=PROCEDURE)
 symbol_vector=(MagickFatalError=PROCEDURE)
 symbol_vector=(DestroyExceptionInfo=PROCEDURE)
@@ -237,7 +191,6 @@
 symbol_vector=(ImportImageCommand=PROCEDURE)
 symbol_vector=(AnimateImageCommand=PROCEDURE)
 symbol_vector=(RelinquishMagickMemory=PROCEDURE)
-symbol_vector=(CompareImageCommand=PROCEDURE)
 symbol_vector=(DestroyString=PROCEDURE)
 symbol_vector=(AcquireExceptionInfo=PROCEDURE)
 symbol_vector=(MagickCoreGenesis=PROCEDURE)
@@ -248,4 +201,12 @@
 symbol_vector=(AcquireTimerInfo=PROCEDURE)
 symbol_vector=(DestroyTimerInfo=PROCEDURE)
 symbol_vector=(MagickCommandGenesis=PROCEDURE)
+symbol_vector=(CompareImagesCommand=PROCEDURE)
+symbol_vector=(GetAuthenticPixels=PROCEDURE)
+symbol_vector=(GetVirtualPixels=PROCEDURE)
+symbol_vector=(AcquireImage=PROCEDURE)
+symbol_vector=(AcquireImageColormap=PROCEDURE)
+symbol_vector=(SyncAuthenticPixels=PROCEDURE)
+symbol_vector=(GetImageOption=PROCEDURE)
+symbol_vector=(IsStringTrue=PROCEDURE)
 sys$share:decw$xlibshr.exe/share
diff --git a/Make.com b/Make.com
new file mode 100755
index 0000000..6a74f9f
--- /dev/null
+++ b/Make.com
@@ -0,0 +1,265 @@
+$!
+$! Make ImageMagick X image utilities for VMS.
+$!
+$ on error then continue
+$ deass magick
+$ on error then continue
+$ deass magickcore
+$ on error then continue
+$ deass pango
+$ set noon
+$
+$ option := 'p1'
+$ if option .eqs. "CLEAN"
+$ then
+$    deletee/log [.magickcore]libMagick.olb;*
+$    deletee/log [.coders]libCoders.olb;*
+$    exit
+$ endif
+$ if option .eqs. "REALCLEAN"
+$ then
+$    deletee/log [.magickcore]libMagick.olb;*,[...]*.obj;*
+$    deletee/log [.coders]libCoders.olb;*,[...]*.obj;*
+$    exit
+$ endif
+$ if option .eqs. "DISTCLEAN"
+$ then
+$    deletee/log [.magickcore]libMagick.olb;*,[...]*.obj;*,*.exe;*,magickshr.olb;*
+$    deletee/log [.coders]libCoders.olb;*,[...]*.obj;*,*.exe;*,magickshr.olb;*
+$    exit
+$ endif
+$ if option .eqs. "NOSHR"
+$ then
+$    share := n
+$    option :=
+$ endif
+$ if option .nes. ""
+$ then
+$    write sys$error "Unknown option \", option, "\"
+$    exit
+$ endif
+$ p1 :=
+$link_options="/nodebug/notraceback"
+$if (f$trnlnm("X11") .eqs. "") then define/nolog X11 decw$include:
+$library_options=""
+$compile_options="/nodebug/optimize"
+$if (f$search("sys$system:decc$compiler.exe") .nes. "")
+$then       ! VAX with DEC C compiler
+$  compile_options="/decc/nodebug/optimize"
+$  library_options="_decc"
+$else       ! VAX with VAX C compiler, (GCC library needed for PNG format only)
+$  define/nolog lnk$library sys$library:vaxcrtl
+$  define/nolog sys sys$share
+$  if (f$trnlnm("gnu_cc") .nes. "") then define/nolog lnk$library_1 gnu_cc:[000000]gcclib.olb
+$endif
+$if (f$getsyi("HW_MODEL") .gt. 1023)
+$then       ! Alpha with DEC C compiler
+$  define/nolog sys decc$library_include
+$  compile_options="/debug/optimize/prefix=all/name=(as_is,short)/float=ieee"
+$  library_options="_axp"
+$  share := 'share'y
+$else
+$  share := n
+$endif
+$
+$write sys$output "Making in [.magickcore]"
+$set default [.magickcore]
+$@make
+$set default [-]
+$write sys$output "Making in [.coders]"
+$set default [.coders]
+$@make
+$set default [-]
+$
+$ if share
+$ then
+$    write sys$output "Making shareable image"
+$    link/share/exe=magickshr.exe   [.magickcore]libMagick.olb/lib, -
+  [.coders]libCoders.olb/lib,[.magickcore]libMagick.olb/lib, -
+  []magickshr.opt/opt, -
+  sys$library:freetype.olb/lib, -
+  sys$library:libjasper.olb/lib, -
+  sys$library:libjpeg.olb/lib, -
+  sys$library:libpng.olb/lib, -
+  sys$library:tiff.olb/lib, -
+  sys$library:libz.olb/lib, -
+  sys$library:libbz2.olb/lib, -
+  sys$library:libjbig.olb/lib
+$ libr/crea/share/log magickshr.olb magickshr.exe
+$    set file/trunc magickshr.olb
+$    purge magickshr.olb
+$    link_libraries := [-]magickshr.olb/lib
+$    define/nolog magickshr 'f$environment("default")'magickshr.exe
+$    write sys$output "Shareable image logical MAGICKSHR defined:"
+$    show logi magickshr
+$ else
+$    link_libraries := [.magickcore]libMagick.olb/lib, -
+  [.coders]libCoders.olb/lib, -
+  sys$library:libjasper.olb/lib
+  sys$library:libjpeg.olb/lib, -
+  sys$library:libpng.olb/lib, -
+  sys$library:tiff.olb/lib, -
+  sys$library:freetype.olb/l, -
+  sys$library:libz.olb/lib,-
+  sys$library:libjbig.olb/lib, -
+  sys$library:libbz2.olb/lib
+$ endif
+$ define magickcore [-.magickcore]
+$ set default [.utilities]
+$ define magickwand [-.magickwand]
+$if ((p1 .nes. "") .and. (p1 .nes. "DISPLAY")) then goto SkipDisplay
+$write sys$output "Making Display..."
+$call Make display.c
+$
+$link'link_options' display.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$display:==$'f$environment("default")'display
+$write sys$output "..symbol DISPLAY defined."
+$
+$SkipDisplay:
+$if ((p1 .nes. "") .and. (p1 .nes. "IMPORT")) then goto SkipImport
+$write sys$output "Making Import..."
+$call Make import.c
+$
+$link'link_options' import.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$import:==$'f$environment("default")'import
+$write sys$output "..symbol IMPORT defined."
+$SkipImport:
+$
+$if ((p1 .nes. "") .and. (p1 .nes. "ANIMATE")) then goto SkipAnimate
+$write sys$output "Making Animate..."
+$call Make animate.c
+$
+$link'link_options' animate.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$animate:==$'f$environment("default")'animate
+$write sys$output "..symbol ANIMATE defined."
+$
+$SkipAnimate:
+$if ((p1 .nes. "") .and. (p1 .nes. "MONTAGE")) then goto SkipMontage
+$write sys$output "Making Montage..."
+$call Make montage.c
+$
+$link'link_options' montage.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$montage:==$'f$environment("default")'montage
+$write sys$output "..symbol MONTAGE defined."
+$
+$SkipMontage:
+$if ((p1 .nes. "") .and. (p1 .nes. "MOGRIFY")) then goto SkipMogrify
+$write sys$output "Making Mogrify..."
+$call Make mogrify.c
+$
+$link'link_options' mogrify.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$mogrify:==$'f$environment("default")'mogrify
+$write sys$output "..symbol MOGRIFY defined."
+$
+$SkipMogrify:
+$if ((p1 .nes. "") .and. (p1 .nes. "CONVERT")) then goto SkipConvert
+$write sys$output "Making Convert..."
+$call Make convert.c
+$
+$link'link_options' convert.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$convert:==$'f$environment("default")'convert
+$write sys$output "..symbol CONVERT defined."
+$SkipConvert:
+$if ((p1 .nes. "") .and. (p1 .nes. "COMPARE")) then goto SkipCompare
+$write sys$output "Making Compare..."
+$call Make compare.c
+$
+$link'link_options' compare.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$compare:==$'f$environment("default")'compare
+$write sys$output "..symbol COMPARE defined."
+$SkipCompare:
+$if ((p1 .nes. "") .and. (p1 .nes. "IDENTIFY")) then goto SkipIdentify
+$write sys$output "Making Identify..."
+$call Make identify.c
+$
+$link'link_options' identify.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$identify:==$'f$environment("default")'identify
+$write sys$output "..symbol IDENTIFY defined."
+$SkipIdentify:
+$if ((p1 .nes. "") .and. (p1 .nes. "COMPOSITE")) then goto SkipComposite
+$write sys$output "Making Composite..."
+$call Make composite.c
+$
+$link'link_options' composite.obj, -
+  'link_libraries',sys$input:/opt
+  sys$share:decw$xlibshr.exe/share
+$
+$composite:==$'f$environment("default")'composite
+$write sys$output "..symbol COMPOSITE defined."
+$SkipComposite:
+$set def [-]
+$copy [.config]magic.xml sys$login:magic.xml
+$copy [.config]colors.xml sys$login:colors.xml
+$copy [.config]log.xml sys$login:log.xml
+$copy [.www.source]delegates.xml sys$login:delegates.xml
+$copy [.config]coder.xml sys$login:coder.xml
+$copy [.www.source]type.xml sys$login:type.xml
+$copy [.config]locale.xml sys$login:locale.xml
+$copy [.config]english.xml sys$login:english.xml
+$copy [.config]francais.xml sys$login:francais.xml
+$type sys$input
+
+Use this command to specify which X server to contact:
+
+  $set display/create/node=node_name::
+
+or
+
+  $set display/create/node=nodename/transport=tcpip
+
+This can be done automatically from your LOGIN.COM with the following
+command:
+
+  $if (f$trnlmn("sys$rem_node") .nes. "") then -
+  $  set display/create/node='f$trnlmn("sys$rem_node")'
+$exit
+$
+$Make: subroutine
+$!
+$! Primitive MMS hack for DCL.
+$!
+$if (p1 .eqs. "") then exit
+$source_file=f$search(f$parse(p1,".c"))
+$if (source_file .nes. "")
+$then
+$  object_file=f$parse(source_file,,,"name")+".obj"
+$  object_file=f$search( object_file )
+$  if (object_file .nes. "")
+$  then
+$    object_time=f$file_attribute(object_file,"cdt")
+$    source_time=f$file_attribute(source_file,"cdt")
+$    if (f$cvtime(object_time).lts.f$cvtime(source_time)) then -
+$      object_file=""
+$  endif
+$  if (object_file .eqs. "")
+$  then
+$    write sys$output "Compiling ",p1
+$    cc'compile_options'/include_directory=[-.magickcore] 'source_file'
+$  endif
+$endif
+$exit
+$endsubroutine
diff --git a/coders/Make.com b/coders/Make.com
new file mode 100755
index 0000000..6242120
--- /dev/null
+++ b/coders/Make.com
@@ -0,0 +1,189 @@
+$!
+$! Make ImageMagick image coders for VMS.
+$!
+$
+$ define/nolog MAGICKCORE [-.magickcore]
+$ define/nolog MAGICKWAND [-.magickwand]
+$if (f$trnlnm("X11") .eqs. "") then define/nolog X11 decw$include:
+$compile_options="/nodebug/optimize"
+$if (f$search("sys$system:decc$compiler.exe") .nes. "") 
+$then     ! VAX with DEC C
+$  compile_options="/decc/nodebug/optimize/warning=(disable=rightshiftovr)"
+$else     ! VAX with VAX C
+$define/nolog lnk$library sys$library:vaxcrtl
+$define/nolog sys sys$share
+$endif
+$if (f$getsyi("HW_MODEL") .gt. 1023)
+$then     ! Alpha with DEC C
+$  define/nolog sys decc$library_include
+$  compile_options="/nodebug/optimize/prefix=all/warning=(disable=(rightshiftovr,INPTRTYPE))/name=(as_is,short)/float=ieee"
+$endif
+$
+$
+$write sys$output "Making Coders..."
+$call Make aai.c
+$call Make art.c
+$call Make avs.c
+$call Make bgr.c
+$call Make bmp.c
+$call Make braille.c
+$call Make cals.c
+$call Make caption.c
+$call Make cip.c
+$call Make clip.c
+$call Make clipboard.c
+$call Make cmyk.c
+$call Make cut.c
+$call Make dcm.c
+$call Make dds.c
+$call Make debug.c
+$call Make dib.c
+$call Make dng.c
+$call Make dps.c
+$call Make dpx.c
+$call Make emf.c
+$call Make ept.c
+$call Make exr.c
+$call Make fax.c
+$call Make fd.c
+$call Make fits.c
+$call Make fpx.c
+$call Make gif.c
+$call Make gradient.c
+$call Make gray.c
+$call Make hald.c
+$call Make hdr.c
+$call Make histogram.c
+$call Make hrz.c
+$call Make html.c
+$call Make icon.c
+$call Make info.c
+$call Make inline.c
+$call Make ipl.c
+$call Make jbig.c
+$call Make jnx.c
+$call Make jpeg.c
+$call Make jp2.c
+$call Make json.c
+$call Make label.c
+$call Make mac.c
+$call Make magick.c
+$call Make map.c
+$call Make mat.c
+$call Make mask.c
+$call Make matte.c
+$call Make meta.c
+$call Make miff.c
+$call Make mpc.c
+$call Make mpeg.c
+$call Make mpr.c
+$call Make msl.c
+$call Make mono.c
+$call Make mtv.c
+$call Make mvg.c
+$call Make null.c
+$call Make otb.c
+$call Make palm.c
+$call Make pango.c
+$call Make pattern.c
+$call Make pcd.c
+$call Make pcl.c
+$call Make pcx.c
+$call Make pdb.c
+$call Make pdf.c
+$call Make pes.c
+$call Make pict.c
+$call Make pix.c
+$call Make plasma.c
+$call Make png.c
+$call Make pnm.c
+$call Make preview.c
+$call Make ps.c
+$call Make ps2.c
+$call Make ps3.c
+$call Make psd.c
+$call Make pwp.c
+$call Make raw.c
+$call Make rgb.c
+$call Make rgf.c
+$call Make rla.c
+$call Make rle.c
+$call Make screenshot.c
+$call Make sct.c
+$call Make sfw.c
+$call Make sgi.c
+$call Make sixel.c
+$call Make stegano.c
+$call Make sun.c
+$call Make svg.c
+$call Make tga.c
+$call Make thumbnail.c
+$call Make tiff.c
+$call Make tile.c
+$call Make tim.c
+$call Make ttf.c
+$call Make txt.c
+$call Make uil.c
+$call Make url.c
+$call Make uyvy.c
+$call Make vicar.c
+$call Make vid.c
+$call Make viff.c
+$call Make vips.c
+$call Make webp.c
+$call Make wbmp.c
+$call Make wmf.c
+$call Make wpg.c
+$call Make x.c
+$call Make xbm.c
+$call Make xc.c
+$call Make xcf.c
+$call Make xpm.c
+$call Make xps.c
+$call Make xtrn.c
+$call Make xwd.c
+$call Make ycbcr.c
+$call Make yuv.c
+$call Make cin.c
+$call Make magick.c
+$call Make scr.c
+$deass magickcore
+$deass magickwand
+$library/create libCoders.olb aai,art,avs,bgr,bmp,braille,clip,clipboard,cip, -
+  cmyk,cut,dcm,dds,debug,dib,dng,dps,dpx,emf,ept,exr,fax,fd,fits,fpx,gif, -
+  gradient,gray,hald,histogram,hrz,html,icon,info,inline,ipl,jbig,jpeg,jp2, -
+  jnx,json,hdr,label,cals,caption,palm,mac,magick,map,mat,matte,pango,rgf, -
+  meta,miff,mpc,mpr,msl,mpeg,mono,mtv,mvg,null,otb,pattern,pcd,pcl,pcx,pdb, -
+  pdf,pes,pict,pix,plasma,png,pnm,preview,ps,ps2,ps3,psd,pwp,raw,rgb,rla,rle, -
+  sct,sfw,sgi,stegano,sun,svg,tga,thumbnail,tiff,tile,tim,ttf,txt,uil,url, -
+  uyvy,vicar,vid,viff,wbmp,webp,wmf,wpg,x,xbm,xc,xcf,xpm,xps,xwd,ycbcr,yuv, -
+  mask,screenshot,vips,sixel,xtrn, -
+  cin,magick,scr,[-.magickcore]compress,[-.magickcore]prervicccm
+$exit
+$
+$Make: subroutine
+$!
+$! Primitive MMS hack for DCL.
+$!
+$if (p1 .eqs. "") then exit
+$source_file=f$search(f$parse(p1,".c"))
+$if (source_file .nes. "")
+$then
+$  object_file=f$parse(source_file,,,"name")+".obj"
+$  object_file=f$search( object_file )
+$  if (object_file .nes. "")
+$  then
+$    object_time=f$file_attribute(object_file,"cdt")
+$    source_time=f$file_attribute(source_file,"cdt")
+$    if (f$cvtime(object_time) .lts. f$cvtime(source_time)) then -
+$      object_file=""
+$  endif
+$  if (object_file .eqs. "")
+$  then
+$    write sys$output "Compiling ",p1
+$    cc'compile_options'/include_directory=([-],[-.magickcore],[-.jpeg],[-.png], -
+       [-.tiff],[-.ttf],[-.zlib]) 'source_file'  
+$  endif
+$endif
+$exit
+$endsubroutine
diff --git a/coders/tiff.c b/coders/tiff.c
old mode 100644
new mode 100755
index 022e10d..202d7f8
--- a/coders/tiff.c
+++ b/coders/tiff.c
@@ -36,6 +36,10 @@
 %
 */
 
+#ifdef __VMS
+#define JPEG_SUPPORT 1
+#endif
+
 /*
   Include declarations.
 */
@@ -567,6 +571,14 @@
   unsigned char
     *profile;
 
+   unsigned long* tietz_tmp;
+
+   length=0;
+   if (TIFFGetField(tiff,37706,&length,&tietz_tmp) == 1)
+     image->tietz_offset = tietz_tmp[0];
+   else
+     image->tietz_offset = 0;
+
   length=0;
   if (ping == MagickFalse)
     {