From 817f4cd1d8f0a3144c3f11af0b51a25fd07ef9fd Mon Sep 17 00:00:00 2001 From: cristy Date: Wed, 6 Feb 2013 11:45:42 +0000 Subject: [PATCH] --- MagickCore/delegate.c | 124 ------------------------------------------ MagickCore/delegate.h | 2 - coders/pdf.c | 124 +++++++++++++++++++++++++++++++++++++++++- coders/ps.c | 124 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 247 insertions(+), 127 deletions(-) diff --git a/MagickCore/delegate.c b/MagickCore/delegate.c index 93063df29..a49b45bdd 100644 --- a/MagickCore/delegate.c +++ b/MagickCore/delegate.c @@ -1093,130 +1093,6 @@ 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 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 -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % % 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 f411a4805..3e43defc6 100644 --- a/MagickCore/delegate.h +++ b/MagickCore/delegate.h @@ -60,8 +60,6 @@ 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 1bcf91a76..61535ba72 100644 --- a/coders/pdf.c +++ b/coders/pdf.c @@ -99,6 +99,128 @@ 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 % % % % % @@ -520,7 +642,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=InvokePostscriptDelegate(read_info->verbose,command,exception); + status=InvokePDFDelegate(read_info->verbose,command,exception); (void) RelinquishUniqueFileResource(postscript_filename); (void) RelinquishUniqueFileResource(input_filename); pdf_image=(Image *) NULL; diff --git a/coders/ps.c b/coders/ps.c index 8135cd807..b0e79a995 100644 --- a/coders/ps.c +++ b/coders/ps.c @@ -86,6 +86,130 @@ 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 % % % % % -- 2.40.0