% October 1998 %
% %
% %
-% Copyright 1999-2014 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 "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/hashmap.h"
+#include "MagickCore/image-private.h"
#include "MagickCore/list.h"
#include "MagickCore/memory_.h"
#include "MagickCore/nt-base-private.h"
" <delegate decode=\"avi:decode\" stealth=\"True\" command=\""mplayer" "%i" -really-quiet -ao null -vo png:z=3\"/>"
" <delegate decode=\"browse\" stealth=\"True\" spawn=\"True\" command=\""xdg-open" http://www.imagemagick.org/; rm "%i"\"/>"
" <delegate decode=\"cgm\" thread-support=\"False\" command=\""ralcgm" -d ps -oC < "%i" > "%o" 2> "%u"\"/>"
- " <delegate decode=\"dng:decode\" command=\""/usr/bin/ufraw-batch" --silent --wb=camera --black-point=auto --exposure=auto --create-id=also --out-type=ppm16 "--output=%u.pnm" "%i"\"/>"
+ " <delegate decode=\"dng:decode\" command=\""ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i"\"/>"
" <delegate decode=\"edit\" stealth=\"True\" command=\""xterm" -title "Edit Image Comment" -e vi "%o"\"/>"
" <delegate decode=\"eps\" encode=\"pdf\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"\"/>"
- " <delegate decode=\"eps\" encode=\"ps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"\"/>"
+ " <delegate decode=\"eps\" encode=\"ps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ps2write" "-sOutputFile=%o" "-f%i"\"/>"
" <delegate decode=\"fig\" command=\""fig2dev" -L ps "%i" "%o"\"/>"
" <delegate decode=\"gplt\" command=\""echo" "set size 1.25,0.62 set terminal postscript portrait color solid; set output "%o"; load "%i"" > "%u";"gnuplot" "%u"\"/>"
" <delegate decode=\"hpg\" command=\""hp2xx" -q -m eps -f `basename "%o"` "%i" mv -f `basename "%o"` "%o"\"/>"
" <delegate decode=\"https\" command=\""wget" -q -O "%o" "https:%M"\"/>"
" <delegate decode=\"ilbm\" command=\""ilbmtoppm" "%i" > "%o"\"/>"
" <delegate decode=\"man\" command=\""groff" -man -Tps "%i" > "%o"\"/>"
- " <delegate decode=\"mpeg:decode\" stealth=\"True\" command=\""ffmpeg" -v -1 -vframes %S -i "%i" -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"\"/>"
- " <delegate decode=\"null\" encode=\"mpeg:encode\" stealth=\"True\" command=\""ffmpeg" -v -1 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 300 -i "%M%%d.jpg" "%u.%m" 2> "%Z"\"/>"
+ " <delegate decode=\"mpeg:decode\" stealth=\"True\" command=\""ffmpeg" -nostdin -v -1 -vframes %S -i "%i" -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"\"/>"
+ " <delegate decode=\"null\" encode=\"mpeg:encode\" stealth=\"True\" command=\""ffmpeg" -nostdin -v -1 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 300 -i "%M%%d.jpg" "%u.%m" 2> "%Z"\"/>"
" <delegate decode=\"pcl:color\" stealth=\"True\" command=\""pcl6" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ppmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s"\"/>"
" <delegate decode=\"pcl:cmyk\" stealth=\"True\" command=\""pcl6" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=bmpsep8" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s"\"/>"
" <delegate decode=\"pcl:mono\" stealth=\"True\" command=\""pcl6" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s"\"/>"
- " <delegate decode=\"pdf\" encode=\"eps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"\"/>"
- " <delegate decode=\"pdf\" encode=\"ps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"\"/>"
+ " <delegate decode=\"pdf\" encode=\"eps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=eps2write" "-sOutputFile=%o" "-f%i"\"/>"
+ " <delegate decode=\"pdf\" encode=\"ps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ps2write" "-sOutputFile=%o" "-f%i"\"/>"
" <delegate decode=\"pnm\" encode=\"ilbm\" mode=\"encode\" command=\""ppmtoilbm" -24if "%i" > "%o"\"/>"
" <delegate decode=\"pnm\" encode=\"launch\" mode=\"encode\" command=\""gimp" "%i"\"/>"
" <delegate decode=\"pov\" command=\""povray" "+i"%i"" -D0 +o"%o" +fn%q +w%w +h%h +a -q9 -kfi"%s" -kff"%n" "convert" -concatenate "%o*.png" "%o"\"/>"
- " <delegate decode=\"ps\" encode=\"eps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"\"/>"
+ " <delegate decode=\"ps\" encode=\"eps\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=eps2write" "-sOutputFile=%o" "-f%i"\"/>"
" <delegate decode=\"ps\" encode=\"pdf\" mode=\"bi\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"\"/>"
" <delegate decode=\"ps\" encode=\"print\" mode=\"encode\" command=\"lpr "%i"\"/>"
" <delegate decode=\"ps:alpha\" stealth=\"True\" command=\""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s"\"/>"
% %
% %
% %
++ E x t e r n a l D e l e g a t e C o m m a n d %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ExternalDelegateCommand() executes the specified command and waits until it
+% terminates. The returned value is the exit status of the command.
+%
+% The format of the ExternalDelegateCommand method is:
+%
+% int ExternalDelegateCommand(const MagickBooleanType asynchronous,
+% const MagickBooleanType verbose,const char *command,
+% char *message,ExceptionInfo *exception)
+%
+% A description of each parameter follows:
+%
+% o asynchronous: a value other than 0 executes the parent program
+% concurrently with the new child process.
+%
+% o verbose: a value other than 0 prints the executed command before it is
+% invoked.
+%
+% o command: this string is the command to execute.
+%
+% o message: an option buffer to receive any message posted to stdout or
+% stderr.
+%
+% o exception: return any errors here.
+%
+*/
+
+static char *SanitizeDelegateCommand(const char *command)
+{
+ char
+ *sanitize_command;
+
+ const char
+ *q;
+
+ register char
+ *p;
+
+ static char
+ whitelist[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_- "
+ ".@&;<>()|/\\\'\":%=~`";
+
+ sanitize_command=AcquireString(command);
+ p=sanitize_command;
+ q=sanitize_command+strlen(sanitize_command);
+ for (p+=strspn(p,whitelist); p != q; p+=strspn(p,whitelist))
+ *p='_';
+ return(sanitize_command);
+}
+
+MagickExport int ExternalDelegateCommand(const MagickBooleanType asynchronous,
+ const MagickBooleanType verbose,const char *command,char *message,
+ ExceptionInfo *exception)
+{
+ char
+ **arguments,
+ *sanitize_command;
+
+ int
+ number_arguments,
+ status;
+
+ PolicyDomain
+ domain;
+
+ PolicyRights
+ rights;
+
+ register ssize_t
+ i;
+
+ status=(-1);
+ arguments=StringToArgv(command,&number_arguments);
+ if (arguments == (char **) NULL)
+ return(status);
+ if (*arguments[1] == '\0')
+ {
+ for (i=0; i < (ssize_t) number_arguments; i++)
+ arguments[i]=DestroyString(arguments[i]);
+ arguments=(char **) RelinquishMagickMemory(arguments);
+ return(-1);
+ }
+ rights=ExecutePolicyRights;
+ domain=DelegatePolicyDomain;
+ if (IsRightsAuthorized(domain,rights,arguments[1]) == MagickFalse)
+ {
+ errno=EPERM;
+ (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
+ "NotAuthorized","`%s'",arguments[1]);
+ for (i=0; i < (ssize_t) number_arguments; i++)
+ arguments[i]=DestroyString(arguments[i]);
+ arguments=(char **) RelinquishMagickMemory(arguments);
+ return(-1);
+ }
+ if (verbose != MagickFalse)
+ {
+ (void) FormatLocaleFile(stderr,"%s\n",command);
+ (void) fflush(stderr);
+ }
+ sanitize_command=SanitizeDelegateCommand(command);
+ if (asynchronous != MagickFalse)
+ (void) ConcatenateMagickString(sanitize_command,"&",MagickPathExtent);
+ if (message != (char *) NULL)
+ *message='\0';
+#if defined(MAGICKCORE_POSIX_SUPPORT)
+#if !defined(MAGICKCORE_HAVE_EXECVP)
+ status=system(sanitize_command);
+#else
+ if ((asynchronous != MagickFalse) ||
+ (strpbrk(sanitize_command,"&;<>|") != (char *) NULL))
+ status=system(sanitize_command);
+ else
+ {
+ pid_t
+ child_pid;
+
+ /*
+ Call application directly rather than from a shell.
+ */
+ child_pid=(pid_t) fork();
+ if (child_pid == (pid_t) -1)
+ status=system(sanitize_command);
+ else
+ if (child_pid == 0)
+ {
+ status=execvp(arguments[1],arguments+1);
+ _exit(1);
+ }
+ else
+ {
+ int
+ child_status;
+
+ pid_t
+ pid;
+
+ child_status=0;
+ pid=(pid_t) waitpid(child_pid,&child_status,0);
+ if (pid == -1)
+ status=(-1);
+ else
+ {
+ if (WIFEXITED(child_status) != 0)
+ status=WEXITSTATUS(child_status);
+ else
+ if (WIFSIGNALED(child_status))
+ status=(-1);
+ }
+ }
+ }
+#endif
+#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
+ {
+ register char
+ *p;
+
+ /*
+ If a command shell is executed we need to change the forward slashes in
+ files to a backslash. We need to do this to keep Windows happy when we
+ want to 'move' a file.
+
+ TODO: This won't work if one of the delegate parameters has a forward
+ slash as aparameter.
+ */
+ p=strstr(sanitize_command, "cmd.exe /c");
+ if (p != (char*) NULL)
+ {
+ p+=10;
+ for (; *p != '\0'; p++)
+ if (*p == '/')
+ *p=*DirectorySeparator;
+ }
+ }
+ status=NTSystemCommand(sanitize_command,message);
+#elif defined(macintosh)
+ status=MACSystemCommand(sanitize_command);
+#elif defined(vms)
+ status=system(sanitize_command);
+#else
+# error No suitable system() method.
+#endif
+ if (status < 0)
+ {
+ if ((message != (char *) NULL) && (*message != '\0'))
+ (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
+ "FailedToExecuteCommand","`%s' (%s)",sanitize_command,message);
+ else
+ (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
+ "FailedToExecuteCommand","`%s' (%d)",sanitize_command,status);
+ }
+ sanitize_command=DestroyString(sanitize_command);
+ for (i=0; i < (ssize_t) number_arguments; i++)
+ arguments[i]=DestroyString(arguments[i]);
+ arguments=(char **) RelinquishMagickMemory(arguments);
+ return(status);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% G e t D e l e g a t e C o m m a n d %
% %
% %
i;
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if( IfMagickTrue(image->debug) )
+ assert(image->signature == MagickCoreSignature);
+ if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
delegate_info=GetDelegateInfo(decode,encode,exception);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(delegate_info != (DelegateInfo *) NULL);
- assert(delegate_info->signature == MagickSignature);
+ assert(delegate_info->signature == MagickCoreSignature);
return(delegate_info->commands);
}
\f
**p,
**q;
+ int
+ cmp;
+
p=(const DelegateInfo **) x,
q=(const DelegateInfo **) y;
- if (LocaleCompare((*p)->path,(*q)->path) == 0)
+ cmp=LocaleCompare((*p)->path,(*q)->path);
+ if (cmp == 0)
{
if ((*p)->decode == (char *) NULL)
if (((*p)->encode != (char *) NULL) &&
((*q)->decode != (char *) NULL))
return(strcmp((*p)->decode,(*q)->decode));
}
- return(LocaleCompare((*p)->path,(*q)->path));
+ return(cmp);
}
#if defined(__cplusplus) || defined(c_plusplus)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(delegate_info != (DelegateInfo *) NULL);
- assert(delegate_info->signature == MagickSignature);
+ assert(delegate_info->signature == MagickCoreSignature);
return(delegate_info->mode);
}
\f
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(delegate_info != (DelegateInfo *) NULL);
- assert(delegate_info->signature == MagickSignature);
+ assert(delegate_info->signature == MagickCoreSignature);
return(delegate_info->thread_support);
}
\f
delegate_cache=AcquireDelegateCache(DelegateFilename,exception);
UnlockSemaphoreInfo(delegate_semaphore);
}
- return(IsMagickNotNULL(delegate_cache));
+ return(delegate_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
}
\f
/*
%
*/
-static inline size_t MagickMin(const size_t x,const size_t y)
-{
- if (x < y)
- return(x);
- return(y);
-}
-
static MagickBooleanType CopyDelegateFile(const char *source,
- const char *destination)
+ const char *destination,const MagickBooleanType overwrite)
{
int
destination_file,
*/
assert(source != (const char *) NULL);
assert(destination != (char *) NULL);
- status=GetPathAttributes(destination,&attributes);
- if( IfMagickTrue(status) && (attributes.st_size != 0))
- return(MagickTrue);
+ if (overwrite == MagickFalse)
+ {
+ status=GetPathAttributes(destination,&attributes);
+ if (status != MagickFalse)
+ return(MagickTrue);
+ }
destination_file=open_utf8(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE);
if (destination_file == -1)
return(MagickFalse);
return(MagickFalse);
}
quantum=(size_t) MagickMaxBufferExtent;
- if ((fstat(source_file,&attributes) == 0) && (attributes.st_size != 0))
+ if ((fstat(source_file,&attributes) == 0) && (attributes.st_size > 0))
quantum=MagickMin((size_t) attributes.st_size,MagickMaxBufferExtent);
buffer=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*buffer));
if (buffer == (unsigned char *) NULL)
(void) close(destination_file);
(void) close(source_file);
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
- return(IsMagickTrue(i!=0));
-}
-
-static char *SanitizeDelegateCommand(const char *command)
-{
- char
- *sanitize_command;
-
- const char
- *q;
-
- register char
- *p;
-
- static char
- whitelist[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_- "
- ".@&;<>|/\\\'\":%=~";
-
- sanitize_command=AcquireString(command);
- p=sanitize_command;
- q=sanitize_command+strlen(sanitize_command);
- for (p+=strspn(p,whitelist); p != q; p+=strspn(p,whitelist))
- *p='_';
- return(sanitize_command);
+ return(i != 0 ? MagickTrue : MagickFalse);
}
MagickExport MagickBooleanType InvokeDelegate(ImageInfo *image_info,
char
*command,
**commands,
- input_filename[MaxTextExtent],
- output_filename[MaxTextExtent];
+ input_filename[MagickPathExtent],
+ output_filename[MagickPathExtent];
const DelegateInfo
*delegate_info;
Get delegate.
*/
assert(image_info != (ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
- if( IfMagickTrue(image->debug) )
+ assert(image->signature == MagickCoreSignature);
+ if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
rights=ExecutePolicyRights;
- if( IfMagickFalse(IsRightsAuthorized(DelegatePolicyDomain,rights,decode)) )
+ if (IsRightsAuthorized(DelegatePolicyDomain,rights,decode) == MagickFalse)
{
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
"NotAuthorized","`%s'",decode);
return(MagickFalse);
}
- if( IfMagickFalse(IsRightsAuthorized(DelegatePolicyDomain,rights,encode)) )
+ if (IsRightsAuthorized(DelegatePolicyDomain,rights,encode) == MagickFalse)
{
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
"NotAuthorized","`%s'",encode);
return(MagickFalse);
}
- temporary=IsMagickTrue(*image->filename == '\0');
- if( IfMagickTrue(temporary) )
- if( IfMagickFalse(AcquireUniqueFilename(image->filename)) )
- {
- ThrowFileException(exception,FileOpenError,
- "UnableToCreateTemporaryFile",image->filename);
- return(MagickFalse);
- }
+ temporary=*image->filename == '\0' ? MagickTrue : MagickFalse;
+ if ((temporary != MagickFalse) && (AcquireUniqueFilename(image->filename) ==
+ MagickFalse))
+ {
+ ThrowFileException(exception,FileOpenError,"UnableToCreateTemporaryFile",
+ image->filename);
+ return(MagickFalse);
+ }
delegate_info=GetDelegateInfo(decode,encode,exception);
if (delegate_info == (DelegateInfo *) NULL)
{
- if( IfMagickTrue(temporary) )
+ if (temporary != MagickFalse)
(void) RelinquishUniqueFileResource(image->filename);
(void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
"NoTagFound","`%s'",decode ? decode : encode);
}
if (*image_info->filename == '\0')
{
- if( IfMagickFalse(AcquireUniqueFilename(image_info->filename)) )
+ if (AcquireUniqueFilename(image_info->filename) == MagickFalse)
{
- if( IfMagickTrue(temporary) )
+ if (temporary != MagickFalse)
(void) RelinquishUniqueFileResource(image->filename);
ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",image_info->filename);
/*
Delegate requires a particular image format.
*/
- if( IfMagickFalse(AcquireUniqueFilename(image_info->unique)) )
+ if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
{
ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",image_info->unique);
return(MagickFalse);
}
- if( IfMagickFalse(AcquireUniqueFilename(image_info->zero)) )
+ if (AcquireUniqueFilename(image_info->zero) == MagickFalse)
{
(void) RelinquishUniqueFileResource(image_info->unique);
ThrowFileException(exception,FileOpenError,
{
(void) RelinquishUniqueFileResource(image_info->unique);
(void) RelinquishUniqueFileResource(image_info->zero);
- if( IfMagickTrue(temporary) )
+ if (temporary != MagickFalse)
(void) RelinquishUniqueFileResource(image->filename);
(void) ThrowMagickException(exception,GetMagickModule(),
DelegateError,"DelegateFailed","`%s'",decode ? decode : encode);
LocaleUpper(magick);
clone_info=CloneImageInfo(image_info);
(void) CopyMagickString((char *) clone_info->magick,magick,
- MaxTextExtent);
+ MagickPathExtent);
if (LocaleCompare(magick,"NULL") != 0)
- (void) CopyMagickString(image->magick,magick,MaxTextExtent);
+ (void) CopyMagickString(image->magick,magick,MagickPathExtent);
magick=DestroyString(magick);
- (void) FormatLocaleString(clone_info->filename,MaxTextExtent,"%s:",
+ (void) FormatLocaleString(clone_info->filename,MagickPathExtent,"%s:",
delegate_info->decode);
(void) SetImageInfo(clone_info,(unsigned int) GetImageListLength(image),
exception);
(void) CopyMagickString(clone_info->filename,image_info->filename,
- MaxTextExtent);
+ MagickPathExtent);
(void) CopyMagickString(image_info->filename,image->filename,
- MaxTextExtent);
+ MagickPathExtent);
for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
{
- (void) FormatLocaleString(p->filename,MaxTextExtent,"%s:%s",
+ (void) FormatLocaleString(p->filename,MagickPathExtent,"%s:%s",
delegate_info->decode,clone_info->filename);
status=WriteImage(clone_info,p,exception);
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
{
(void) RelinquishUniqueFileResource(image_info->unique);
(void) RelinquishUniqueFileResource(image_info->zero);
- if( IfMagickTrue(temporary) )
+ if (temporary != MagickFalse)
(void) RelinquishUniqueFileResource(image->filename);
clone_info=DestroyImageInfo(clone_info);
(void) ThrowMagickException(exception,GetMagickModule(),
DelegateError,"DelegateFailed","`%s'",decode ? decode : encode);
return(MagickFalse);
}
- if( IfMagickTrue(clone_info->adjoin) )
+ if (clone_info->adjoin != MagickFalse)
break;
}
(void) RelinquishUniqueFileResource(image_info->unique);
return(MagickFalse);
}
command=(char *) NULL;
- status=MagickFalse;
- (void) CopyMagickString(output_filename,image_info->filename,MaxTextExtent);
- (void) CopyMagickString(input_filename,image->filename,MaxTextExtent);
+ status=MagickTrue;
+ (void) CopyMagickString(output_filename,image_info->filename,
+ MagickPathExtent);
+ (void) CopyMagickString(input_filename,image->filename,MagickPathExtent);
for (i=0; commands[i] != (char *) NULL; i++)
{
- status=AcquireUniqueSymbolicLink(output_filename,image_info->filename);
- if( IfMagickFalse(AcquireUniqueFilename(image_info->unique)) )
+ (void) AcquireUniqueSymbolicLink(output_filename,image_info->filename);
+ if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
{
ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",image_info->unique);
break;
}
- if( IfMagickFalse(AcquireUniqueFilename(image_info->zero)) )
+ if (AcquireUniqueFilename(image_info->zero) == MagickFalse)
{
(void) RelinquishUniqueFileResource(image_info->unique);
ThrowFileException(exception,FileOpenError,
if (LocaleCompare(decode,"SCAN") != 0)
{
status=AcquireUniqueSymbolicLink(input_filename,image->filename);
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
{
ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",input_filename);
break;
}
}
- status=MagickFalse;
+ status=MagickTrue;
command=InterpretImageProperties(image_info,image,commands[i],exception);
if (command != (char *) NULL)
{
- char
- *sanitize_command;
-
/*
Execute delegate.
*/
- sanitize_command=SanitizeDelegateCommand(command);
- status=IsMagickTrue(SystemCommand(delegate_info->spawn,
- image_info->verbose,sanitize_command,exception) != 0);
- sanitize_command=DestroyString(sanitize_command);
- if (IfMagickTrue(delegate_info->spawn))
+ if (ExternalDelegateCommand(delegate_info->spawn,image_info->verbose,
+ command,(char *) NULL,exception) != 0)
+ status=MagickFalse;
+ if (delegate_info->spawn != MagickFalse)
{
ssize_t
count;
}
if (LocaleCompare(decode,"SCAN") != 0)
{
- if( IfMagickFalse(CopyDelegateFile(image->filename,input_filename)) )
+ if (CopyDelegateFile(image->filename,input_filename,MagickFalse) == MagickFalse)
(void) RelinquishUniqueFileResource(input_filename);
}
- if( IfMagickFalse(CopyDelegateFile(image_info->filename,output_filename)) )
+ if (CopyDelegateFile(image_info->filename,output_filename,MagickTrue) == MagickFalse)
(void) RelinquishUniqueFileResource(output_filename);
- if( IfMagickTrue(image_info->temporary) )
+ if (image_info->temporary != MagickFalse)
(void) RelinquishUniqueFileResource(image_info->filename);
(void) RelinquishUniqueFileResource(image_info->unique);
(void) RelinquishUniqueFileResource(image_info->zero);
(void) RelinquishUniqueFileResource(image_info->filename);
(void) RelinquishUniqueFileResource(image->filename);
- if( IfMagickTrue(status) )
+ if (status == MagickFalse)
{
(void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
"DelegateFailed","`%s'",commands[i]);
}
commands[i]=DestroyString(commands[i]);
}
- (void) CopyMagickString(image_info->filename,output_filename,MaxTextExtent);
- (void) CopyMagickString(image->filename,input_filename,MaxTextExtent);
+ (void) CopyMagickString(image_info->filename,output_filename,MagickPathExtent);
+ (void) CopyMagickString(image->filename,input_filename,MagickPathExtent);
/*
Relinquish resources.
*/
for ( ; commands[i] != (char *) NULL; i++)
commands[i]=DestroyString(commands[i]);
commands=(char **) RelinquishMagickMemory(commands);
- if( IfMagickTrue(temporary) )
+ if (temporary != MagickFalse)
(void) RelinquishUniqueFileResource(image->filename);
- return(IsMagickFalse(status));
+ return(status);
}
\f
/*
char
**commands,
- delegate[MaxTextExtent];
+ delegate[MagickPathExtent];
const char
*path;
path=delegate_info[i]->path;
*delegate='\0';
if (delegate_info[i]->encode != (char *) NULL)
- (void) CopyMagickString(delegate,delegate_info[i]->encode,MaxTextExtent);
- (void) ConcatenateMagickString(delegate," ",MaxTextExtent);
+ (void) CopyMagickString(delegate,delegate_info[i]->encode,MagickPathExtent);
+ (void) ConcatenateMagickString(delegate," ",MagickPathExtent);
delegate[8]='\0';
commands=StringToList(delegate_info[i]->commands);
if (commands == (char **) NULL)
ExceptionInfo *exception)
{
char
- keyword[MaxTextExtent],
+ keyword[MagickPathExtent],
*token;
const char
DelegateInfo
*delegate_info;
- MagickBooleanType
+ MagickStatusType
status;
/*
GetMagickToken(q,&q,token);
if (*token == '\0')
break;
- (void) CopyMagickString(keyword,token,MaxTextExtent);
+ (void) CopyMagickString(keyword,token,MagickPathExtent);
if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
{
/*
*/
while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
{
- (void) CopyMagickString(keyword,token,MaxTextExtent);
+ (void) CopyMagickString(keyword,token,MagickPathExtent);
GetMagickToken(q,&q,token);
if (*token != '=')
continue;
else
{
char
- path[MaxTextExtent],
+ path[MagickPathExtent],
*xml;
GetPathComponent(filename,HeadPath,path);
if (*path != '\0')
(void) ConcatenateMagickString(path,DirectorySeparator,
- MaxTextExtent);
+ MagickPathExtent);
if (*token == *DirectorySeparator)
- (void) CopyMagickString(path,token,MaxTextExtent);
+ (void) CopyMagickString(path,token,MagickPathExtent);
else
- (void) ConcatenateMagickString(path,token,MaxTextExtent);
+ (void) ConcatenateMagickString(path,token,MagickPathExtent);
xml=FileToXML(path,~0UL);
if (xml != (char *) NULL)
{
(void) ResetMagickMemory(delegate_info,0,sizeof(*delegate_info));
delegate_info->path=ConstantString(filename);
delegate_info->thread_support=MagickTrue;
- delegate_info->signature=MagickSignature;
+ delegate_info->signature=MagickCoreSignature;
continue;
}
if (delegate_info == (DelegateInfo *) NULL)
if (strchr(commands,'@') != (char *) NULL)
{
char
- path[MaxTextExtent];
+ path[MagickPathExtent];
- NTGhostscriptEXE(path,MaxTextExtent);
+ NTGhostscriptEXE(path,MagickPathExtent);
(void) SubstituteString((char **) &commands,"@PSDelegate@",
path);
(void) SubstituteString((char **) &commands,"\\","/");
}
}
token=(char *) RelinquishMagickMemory(token);
- return(status);
+ return(status != 0 ? MagickTrue : MagickFalse);
}