From c06e756b88fb9d4c01fe9bac6006e0f7c6eb4602 Mon Sep 17 00:00:00 2001 From: cristy Date: Wed, 6 Feb 2013 11:09:54 +0000 Subject: [PATCH] --- MagickCore/delegate.c | 133 ++++++++++++++++++++++++++++++++++++++++++ MagickCore/delegate.h | 2 + coders/pdf.c | 128 +--------------------------------------- coders/ps.c | 128 ---------------------------------------- 4 files changed, 136 insertions(+), 255 deletions(-) diff --git a/MagickCore/delegate.c b/MagickCore/delegate.c index a49b45bdd..e28ab4b30 100644 --- a/MagickCore/delegate.c +++ b/MagickCore/delegate.c @@ -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 +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % L i s t D e l e g a t e I n f o % % % % % diff --git a/MagickCore/delegate.h b/MagickCore/delegate.h index 3e43defc6..f411a4805 100644 --- a/MagickCore/delegate.h +++ b/MagickCore/delegate.h @@ -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) diff --git a/coders/pdf.c b/coders/pdf.c index d506607fa..1bcf91a76 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -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 -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % 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); diff --git a/coders/ps.c b/coders/ps.c index aa19a0cf0..8135cd807 100644 --- a/coders/ps.c +++ b/coders/ps.c @@ -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 -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % 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); -- 2.40.0