]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Wed, 6 Feb 2013 11:09:54 +0000 (11:09 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Wed, 6 Feb 2013 11:09:54 +0000 (11:09 +0000)
MagickCore/delegate.c
MagickCore/delegate.h
coders/pdf.c
coders/ps.c

index a49b45bdd77c281b276ffd0066a50604fff508a9..e28ab4b30fba361d47e8bc126bed5583b52a3d11 100644 (file)
@@ -1093,6 +1093,139 @@ MagickExport MagickBooleanType InvokeDelegate(ImageInfo *image_info,
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   I n v o k e P o s t s r i p t D e l e g a t e                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  InvokePostscriptDelegate() executes the Postscript interpreter with the
+%  specified command.
+%
+%  The format of the InvokePostscriptDelegate method is:
+%
+%      MagickBooleanType InvokePostscriptDelegate(
+%        const MagickBooleanType verbose,const char *command,
+%        ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o verbose: A value other than zero displays the command prior to
+%      executing it.
+%
+%    o command: the address of a character string containing the command to
+%      execute.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport MagickBooleanType InvokePostscriptDelegate(
+  const MagickBooleanType verbose,const char *command,ExceptionInfo *exception)
+{
+  int
+    status;
+
+#if defined(MAGICKCORE_GS_DELEGATE) || defined(MAGICKCORE_WINDOWS_SUPPORT)
+  char
+    **argv;
+
+  const GhostInfo
+    *ghost_info;
+
+  gs_main_instance
+    *interpreter;
+
+  int
+    argc,
+    code;
+
+  register ssize_t
+    i;
+
+  if (delegate_semaphore == (SemaphoreInfo *) NULL)
+    AcquireSemaphoreInfo(&delegate_semaphore);
+  LockSemaphoreInfo(delegate_semaphore);
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+  ghost_info=NTGhostscriptDLLVectors();
+#else
+  GhostInfo
+    ghost_info_struct;
+
+  ghost_info=(&ghost_info_struct);
+  (void) ResetMagickMemory(&ghost_info,0,sizeof(ghost_info));
+  ghost_info_struct.new_instance=(int (*)(gs_main_instance **,void *))
+    gsapi_new_instance;
+  ghost_info_struct.init_with_args=(int (*)(gs_main_instance *,int,char **))
+    gsapi_init_with_args;
+  ghost_info_struct.run_string=(int (*)(gs_main_instance *,const char *,int,
+    int *)) gsapi_run_string;
+  ghost_info_struct.delete_instance=(void (*)(gs_main_instance *))
+    gsapi_delete_instance;
+  ghost_info_struct.exit=(int (*)(gs_main_instance *)) gsapi_exit;
+#endif
+  if (ghost_info == (GhostInfo *) NULL)
+    {
+      UnlockSemaphoreInfo(delegate_semaphore);
+      status=SystemCommand(MagickFalse,verbose,command,exception);
+      return(status == 0 ? MagickTrue : MagickFalse);
+    }
+  if (verbose != MagickFalse)
+    {
+      (void) fputs("[ghostscript library]",stdout);
+      (void) fputs(strchr(command,' '),stdout);
+    }
+  status=(ghost_info->new_instance)(&interpreter,(void *) NULL);
+  if (status < 0)
+    {
+      UnlockSemaphoreInfo(delegate_semaphore);
+      status=SystemCommand(MagickFalse,verbose,command,exception);
+      return(status == 0 ? MagickTrue : MagickFalse);
+    }
+  code=0;
+  argv=StringToArgv(command,&argc);
+  if (argv == (char **) NULL)
+    {
+      UnlockSemaphoreInfo(delegate_semaphore);
+      return(MagickFalse);
+    }
+  status=(ghost_info->init_with_args)(interpreter,argc-1,argv+1);
+  if (status == 0)
+    status=(ghost_info->run_string)(interpreter,"systemdict /start get exec\n",
+      0,&code);
+  (ghost_info->exit)(interpreter);
+  (ghost_info->delete_instance)(interpreter);
+#if defined(MAGICKCORE_WINDOWS_SUPPORT)
+  NTGhostscriptUnLoadDLL();
+#endif
+  UnlockSemaphoreInfo(delegate_semaphore);
+  for (i=0; i < (ssize_t) argc; i++)
+    argv[i]=DestroyString(argv[i]);
+  argv=(char **) RelinquishMagickMemory(argv);
+  if ((status != 0) && (status != -101))
+    {
+      char
+        *message;
+
+      message=GetExceptionMessage(errno);
+      (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
+        "`%s': %s",command,message);
+      message=DestroyString(message);
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+        "Ghostscript returns status %d, exit code %d",status,code);
+      return(MagickFalse);
+    }
+  return(MagickTrue);
+#else
+  status=SystemCommand(MagickFalse,verbose,command,exception);
+  return(status == 0 ? MagickTrue : MagickFalse);
+#endif
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %  L i s t D e l e g a t e I n f o                                            %
 %                                                                             %
 %                                                                             %
index 3e43defc64eaf394cd14626a0739c3f7370e25f5..f411a480576930e811f79bde1be11e1dfe2906cf 100644 (file)
@@ -60,6 +60,8 @@ extern MagickExport ssize_t
 extern MagickExport MagickBooleanType
   GetDelegateThreadSupport(const DelegateInfo *),
   InvokeDelegate(ImageInfo *,Image *,const char *,const char *,ExceptionInfo *),
+  InvokePostscriptDelegate(const MagickBooleanType,const char *,
+    ExceptionInfo *),
   ListDelegateInfo(FILE *,ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
index d506607facf9221454eeb25b2eebf0068c5007b3..1bcf91a762b933d951db6a430179c4821e0fb30b 100644 (file)
@@ -99,128 +99,6 @@ static MagickBooleanType
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   I n v o k e P D F D e l e g a t e                                         %
-%                                                                             %
-%                                                                             %
-%                                                                             %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-%  InvokePDFDelegate() executes the PDF interpreter with the specified command.
-%
-%  The format of the InvokePDFDelegate method is:
-%
-%      MagickBooleanType InvokePDFDelegate(const MagickBooleanType verbose,
-%        const char *command,ExceptionInfo *exception)
-%
-%  A description of each parameter follows:
-%
-%    o verbose: A value other than zero displays the command prior to
-%      executing it.
-%
-%    o command: the address of a character string containing the command to
-%      execute.
-%
-%    o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType InvokePDFDelegate(const MagickBooleanType verbose,
-  const char *command,ExceptionInfo *exception)
-{
-  int
-    status;
-
-#if defined(MAGICKCORE_GS_DELEGATE) || defined(MAGICKCORE_WINDOWS_SUPPORT)
-  char
-    **argv;
-
-  const GhostInfo
-    *ghost_info;
-
-  gs_main_instance
-    *interpreter;
-
-  int
-    argc,
-    code;
-
-  register ssize_t
-    i;
-
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
-  ghost_info=NTGhostscriptDLLVectors();
-#else
-  GhostInfo
-    ghost_info_struct;
-
-  ghost_info=(&ghost_info_struct);
-  (void) ResetMagickMemory(&ghost_info,0,sizeof(ghost_info));
-  ghost_info_struct.new_instance=(int (*)(gs_main_instance **,void *))
-    gsapi_new_instance;
-  ghost_info_struct.init_with_args=(int (*)(gs_main_instance *,int,char **))
-    gsapi_init_with_args;
-  ghost_info_struct.run_string=(int (*)(gs_main_instance *,const char *,int,
-    int *)) gsapi_run_string;
-  ghost_info_struct.delete_instance=(void (*)(gs_main_instance *))
-    gsapi_delete_instance;
-  ghost_info_struct.exit=(int (*)(gs_main_instance *)) gsapi_exit;
-#endif
-  if (ghost_info == (GhostInfo *) NULL)
-    {
-      status=SystemCommand(MagickFalse,verbose,command,exception);
-      return(status == 0 ? MagickTrue : MagickFalse);
-    }
-  if (verbose != MagickFalse)
-    {
-      (void) fputs("[ghostscript library]",stdout);
-      (void) fputs(strchr(command,' '),stdout);
-    }
-  status=(ghost_info->new_instance)(&interpreter,(void *) NULL);
-  if (status < 0)
-    {
-      status=SystemCommand(MagickFalse,verbose,command,exception);
-      return(status == 0 ? MagickTrue : MagickFalse);
-    }
-  code=0;
-  argv=StringToArgv(command,&argc);
-  if (argv == (char **) NULL)
-    return(MagickFalse);
-  status=(ghost_info->init_with_args)(interpreter,argc-1,argv+1);
-  if (status == 0)
-    status=(ghost_info->run_string)(interpreter,"systemdict /start get exec\n",
-      0,&code);
-  (ghost_info->exit)(interpreter);
-  (ghost_info->delete_instance)(interpreter);
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
-  NTGhostscriptUnLoadDLL();
-#endif
-  for (i=0; i < (ssize_t) argc; i++)
-    argv[i]=DestroyString(argv[i]);
-  argv=(char **) RelinquishMagickMemory(argv);
-  if ((status != 0) && (status != -101))
-    {
-      char
-        *message;
-
-      message=GetExceptionMessage(errno);
-      (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
-        "`%s': %s",command,message);
-      message=DestroyString(message);
-      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "Ghostscript returns status %d, exit code %d",status,code);
-      return(MagickFalse);
-    }
-  return(MagickTrue);
-#else
-  status=SystemCommand(MagickFalse,verbose,command,exception);
-  return(status == 0 ? MagickTrue : MagickFalse);
-#endif
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                                                             %
-%                                                                             %
-%                                                                             %
 %   I s P D F                                                                 %
 %                                                                             %
 %                                                                             %
@@ -642,7 +520,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     read_info->antialias != MagickFalse ? 4 : 1,
     read_info->antialias != MagickFalse ? 4 : 1,density,options,filename,
     postscript_filename,input_filename);
-  status=InvokePDFDelegate(read_info->verbose,command,exception);
+  status=InvokePostscriptDelegate(read_info->verbose,command,exception);
   (void) RelinquishUniqueFileResource(postscript_filename);
   (void) RelinquishUniqueFileResource(input_filename);
   pdf_image=(Image *) NULL;
@@ -762,7 +640,6 @@ ModuleExport size_t RegisterPDFImage(void)
   entry->adjoin=MagickFalse;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString("Adobe Illustrator CS2");
   entry->module=ConstantString("PDF");
   (void) RegisterMagickInfo(entry);
@@ -772,7 +649,6 @@ ModuleExport size_t RegisterPDFImage(void)
   entry->adjoin=MagickFalse;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString("Encapsulated Portable Document Format");
   entry->module=ConstantString("PDF");
   (void) RegisterMagickInfo(entry);
@@ -782,7 +658,6 @@ ModuleExport size_t RegisterPDFImage(void)
   entry->magick=(IsImageFormatHandler *) IsPDF;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString("Portable Document Format");
   entry->module=ConstantString("PDF");
   (void) RegisterMagickInfo(entry);
@@ -792,7 +667,6 @@ ModuleExport size_t RegisterPDFImage(void)
   entry->magick=(IsImageFormatHandler *) IsPDF;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString("Portable Document Archive Format");
   entry->module=ConstantString("PDF");
   (void) RegisterMagickInfo(entry);
index aa19a0cf00e6978034510e895278c643532f67c8..8135cd807b797ac410b6dffe76da28fee0004177 100644 (file)
@@ -86,130 +86,6 @@ static MagickBooleanType
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   I n v o k e P o s t s r i p t D e l e g a t e                             %
-%                                                                             %
-%                                                                             %
-%                                                                             %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-%  InvokePostscriptDelegate() executes the Postscript interpreter with the
-%  specified command.
-%
-%  The format of the InvokePostscriptDelegate method is:
-%
-%      MagickBooleanType InvokePostscriptDelegate(
-%        const MagickBooleanType verbose,const char *command,
-%        ExceptionInfo *exception)
-%
-%  A description of each parameter follows:
-%
-%    o verbose: A value other than zero displays the command prior to
-%      executing it.
-%
-%    o command: the address of a character string containing the command to
-%      execute.
-%
-%    o exception: return any errors or warnings in this structure.
-%
-*/
-static MagickBooleanType InvokePostscriptDelegate(
-  const MagickBooleanType verbose,const char *command,ExceptionInfo *exception)
-{
-  int
-    status;
-
-#if defined(MAGICKCORE_GS_DELEGATE) || defined(MAGICKCORE_WINDOWS_SUPPORT)
-  char
-    **argv;
-
-  const GhostInfo
-    *ghost_info;
-
-  gs_main_instance
-    *interpreter;
-
-  int
-    argc,
-    code;
-
-  register ssize_t
-    i;
-
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
-  ghost_info=NTGhostscriptDLLVectors();
-#else
-  GhostInfo
-    ghost_info_struct;
-
-  ghost_info=(&ghost_info_struct);
-  (void) ResetMagickMemory(&ghost_info,0,sizeof(ghost_info));
-  ghost_info_struct.new_instance=(int (*)(gs_main_instance **,void *))
-    gsapi_new_instance;
-  ghost_info_struct.init_with_args=(int (*)(gs_main_instance *,int,char **))
-    gsapi_init_with_args;
-  ghost_info_struct.run_string=(int (*)(gs_main_instance *,const char *,int,
-    int *)) gsapi_run_string;
-  ghost_info_struct.delete_instance=(void (*)(gs_main_instance *))
-    gsapi_delete_instance;
-  ghost_info_struct.exit=(int (*)(gs_main_instance *)) gsapi_exit;
-#endif
-  if (ghost_info == (GhostInfo *) NULL)
-    {
-      status=SystemCommand(MagickFalse,verbose,command,exception);
-      return(status == 0 ? MagickTrue : MagickFalse);
-    }
-  if (verbose != MagickFalse)
-    {
-      (void) fputs("[ghostscript library]",stdout);
-      (void) fputs(strchr(command,' '),stdout);
-    }
-  status=(ghost_info->new_instance)(&interpreter,(void *) NULL);
-  if (status < 0)
-    {
-      status=SystemCommand(MagickFalse,verbose,command,exception);
-      return(status == 0 ? MagickTrue : MagickFalse);
-    }
-  code=0;
-  argv=StringToArgv(command,&argc);
-  if (argv == (char **) NULL)
-    return(MagickFalse);
-  status=(ghost_info->init_with_args)(interpreter,argc-1,argv+1);
-  if (status == 0)
-    status=(ghost_info->run_string)(interpreter,"systemdict /start get exec\n",
-      0,&code);
-  (ghost_info->exit)(interpreter);
-  (ghost_info->delete_instance)(interpreter);
-#if defined(MAGICKCORE_WINDOWS_SUPPORT)
-  NTGhostscriptUnLoadDLL();
-#endif
-  for (i=0; i < (ssize_t) argc; i++)
-    argv[i]=DestroyString(argv[i]);
-  argv=(char **) RelinquishMagickMemory(argv);
-  if ((status != 0) && (status != -101))
-    {
-      char
-        *message;
-
-      message=GetExceptionMessage(errno);
-      (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
-        "`%s': %s",command,message);
-      message=DestroyString(message);
-      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "Ghostscript returns status %d, exit code %d",status,code);
-      return(MagickFalse);
-    }
-  return(MagickTrue);
-#else
-  status=SystemCommand(MagickFalse,verbose,command,exception);
-  return(status == 0 ? MagickTrue : MagickFalse);
-#endif
-}
-\f
-/*
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                                                             %
-%                                                                             %
-%                                                                             %
 %   I s P S                                                                   %
 %                                                                             %
 %                                                                             %
@@ -923,7 +799,6 @@ ModuleExport size_t RegisterPSImage(void)
   entry->adjoin=MagickFalse;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString(
    "Encapsulated PostScript Interchange format");
   entry->module=ConstantString("PS");
@@ -935,7 +810,6 @@ ModuleExport size_t RegisterPSImage(void)
   entry->adjoin=MagickFalse;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString("Encapsulated PostScript");
   entry->module=ConstantString("PS");
   (void) RegisterMagickInfo(entry);
@@ -956,7 +830,6 @@ ModuleExport size_t RegisterPSImage(void)
   entry->adjoin=MagickFalse;
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString(
     "Encapsulated PostScript Interchange format");
   entry->module=ConstantString("PS");
@@ -968,7 +841,6 @@ ModuleExport size_t RegisterPSImage(void)
   entry->module=ConstantString("PS");
   entry->blob_support=MagickFalse;
   entry->seekable_stream=MagickTrue;
-  entry->thread_support=EncoderThreadSupport;
   entry->description=ConstantString("PostScript");
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);