]> granicus.if.org Git - imagemagick/blobdiff - coders/dot.c
(no commit message)
[imagemagick] / coders / dot.c
index 54c5e35d527695add8423816ba96b9baa718bbb4..27bae00751790fa62279a79cc2202da8c8a593d8 100644 (file)
 %                      Read/Write Graphviz DOT Format                         %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  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  %
 /*
   Include declarations.
 */
-#include "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/client.h"
-#include "magick/constitute.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/option.h"
-#include "magick/resource_.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/utility.h"
-#include "magick/xwindow-private.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/client.h"
+#include "MagickCore/constitute.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/option.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/utility.h"
+#include "MagickCore/xwindow-private.h"
 #if defined(MAGICKCORE_GVC_DELEGATE)
 #undef HAVE_CONFIG_H
 #include <gvc.h>
@@ -125,7 +125,7 @@ static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  image=AcquireImage(image_info);
+  image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     return((Image *) NULL);
@@ -133,11 +133,18 @@ static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
   SetImageInfoBlob(read_info,(void *) NULL,0);
   (void) CopyMagickString(read_info->magick,"SVG",MaxTextExtent);
   (void) AcquireUniqueFilename(read_info->filename);
-  (void) FormatMagickString(command,MaxTextExtent,"-Tsvg -o%s %s",
+  (void) FormatLocaleString(command,MaxTextExtent,"-Tsvg -o%s %s",
     read_info->filename,image_info->filename);
+#if !defined(WITH_CGRAPH)
   graph=agread(GetBlobFileHandle(image));
+#else
+  graph=agread(GetBlobFileHandle(image),(Agdisc_t *) NULL);
+#endif
   if (graph == (graph_t *) NULL)
-    return ((Image *) NULL);
+    {
+      (void) RelinquishUniqueFileResource(read_info->filename);
+      return ((Image *) NULL);
+    }
   option=GetImageOption(image_info,"dot:layout-engine");
   if (option == (const char *) NULL)
     gvLayout(graphic_context,graph,(char *) "dot");
@@ -145,6 +152,7 @@ static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     gvLayout(graphic_context,graph,(char *) option);
   gvRenderFilename(graphic_context,graph,(char *) "svg",read_info->filename);
   gvFreeLayout(graphic_context,graph);
+  agclose(graph);
   /*
     Read SVG graph.
   */
@@ -189,7 +197,15 @@ ModuleExport size_t RegisterDOTImage(void)
 #if defined(MAGICKCORE_GVC_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadDOTImage;
 #endif
-  entry->blob_support=MagickFalse;
+  entry->flags^=CoderBlobSupportFlag;
+  entry->description=ConstantString("Graphviz");
+  entry->module=ConstantString("DOT");
+  (void) RegisterMagickInfo(entry);
+  entry=SetMagickInfo("GV");
+#if defined(MAGICKCORE_GVC_DELEGATE)
+  entry->decoder=(DecodeImageHandler *) ReadDOTImage;
+#endif
+  entry->flags^=CoderBlobSupportFlag;
   entry->description=ConstantString("Graphviz");
   entry->module=ConstantString("DOT");
   (void) RegisterMagickInfo(entry);
@@ -220,6 +236,7 @@ ModuleExport size_t RegisterDOTImage(void)
 */
 ModuleExport void UnregisterDOTImage(void)
 {
+  (void) UnregisterMagickInfo("GV");
   (void) UnregisterMagickInfo("DOT");
 #if defined(MAGICKCORE_GVC_DELEGATE)
   gvFreeContext(graphic_context);