48#include "MagickCore/studio.h"
49#include "MagickCore/artifact.h"
50#include "MagickCore/attribute.h"
51#include "MagickCore/blob.h"
52#include "MagickCore/client.h"
53#include "MagickCore/configure.h"
54#include "MagickCore/constitute.h"
55#include "MagickCore/delegate.h"
56#include "MagickCore/delegate-private.h"
57#include "MagickCore/exception.h"
58#include "MagickCore/exception-private.h"
59#include "MagickCore/fx-private.h"
60#include "MagickCore/image-private.h"
61#include "MagickCore/linked-list.h"
62#include "MagickCore/linked-list-private.h"
63#include "MagickCore/list.h"
64#include "MagickCore/memory_.h"
65#include "MagickCore/memory-private.h"
66#include "MagickCore/nt-base-private.h"
67#include "MagickCore/option.h"
68#include "MagickCore/policy.h"
69#include "MagickCore/policy-private.h"
70#include "MagickCore/property.h"
71#include "MagickCore/resource_.h"
72#include "MagickCore/semaphore.h"
73#include "MagickCore/signature.h"
74#include "MagickCore/string_.h"
75#include "MagickCore/token.h"
76#include "MagickCore/token-private.h"
77#include "MagickCore/utility.h"
78#include "MagickCore/utility-private.h"
79#include "MagickCore/xml-tree.h"
80#include "MagickCore/xml-tree-private.h"
86 #include "TargetConditionals.h"
87 #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
88 #define system(s) ((s)==NULL ? 0 : -1)
90#elif defined(__ANDROID__)
91 #define system(s) ((s)==NULL ? 0 : -1)
93#define DelegateFilename "delegates.xml"
94#if defined(MAGICKCORE_WINDOWS_SUPPORT)
95 #define DELEGATE_ESC """
97 #define DELEGATE_ESC "'"
104 *DelegateMap = (
const char *)
105 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
107 " <delegate decode=\"bpg\" command=\"" DELEGATE_ESC
"bpgdec" DELEGATE_ESC
" -b 16 -o " DELEGATE_ESC
"%o.png" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.png" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
108 " <delegate decode=\"png\" encode=\"bpg\" command=\"" DELEGATE_ESC
"bpgenc" DELEGATE_ESC
" -b 12 -q %~ -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
109 " <delegate decode=\"browse\" stealth=\"True\" spawn=\"True\" command=\"" DELEGATE_ESC
"xdg-open" DELEGATE_ESC
" https://imagemagick.org/; rm " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
110 " <delegate decode=\"cdr\" command=\"" DELEGATE_ESC
"uniconvertor" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
111 " <delegate decode=\"cgm\" command=\"" DELEGATE_ESC
"uniconvertor" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
112 " <delegate decode=\"https\" command=\"" DELEGATE_ESC
"curl" DELEGATE_ESC
" -s -k -L -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"https:%M" DELEGATE_ESC
"\"/>"
113 " <delegate decode=\"doc\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
114 " <delegate decode=\"docx\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
115 " <delegate decode=\"dng:decode\" command=\"" DELEGATE_ESC
"ufraw-batch" DELEGATE_ESC
" --silent --create-id=also --out-type=png --out-depth=16 " DELEGATE_ESC
"--output=%u.png" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
116 " <delegate decode=\"dot\" command=\"" DELEGATE_ESC
"dot" DELEGATE_ESC
" -Tsvg " DELEGATE_ESC
"%i" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
117 " <delegate decode=\"dvi\" command=\"" DELEGATE_ESC
"dvips" DELEGATE_ESC
" -sstdout=%%stderr -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
118 " <delegate decode=\"dxf\" command=\"" DELEGATE_ESC
"uniconvertor" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
119 " <delegate decode=\"edit\" stealth=\"True\" command=\"" DELEGATE_ESC
"xterm" DELEGATE_ESC
" -title " DELEGATE_ESC
"Edit Image Comment" DELEGATE_ESC
" -e vi " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
120 " <delegate decode=\"eps\" encode=\"pdf\" mode=\"bi\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 " DELEGATE_ESC
"-sDEVICE=pdfwrite" DELEGATE_ESC
" " DELEGATE_ESC
"-sOutputFile=%o" DELEGATE_ESC
" " DELEGATE_ESC
"-f%i" DELEGATE_ESC
"\"/>"
121 " <delegate decode=\"eps\" encode=\"ps\" mode=\"bi\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=ps2write" DELEGATE_ESC
" " DELEGATE_ESC
"-sOutputFile=%o" DELEGATE_ESC
" " DELEGATE_ESC
"-f%i" DELEGATE_ESC
"\"/>"
122 " <delegate decode=\"fig\" command=\"" DELEGATE_ESC
"uniconvertor" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.svg" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
123 " <delegate decode=\"hpg\" command=\"" DELEGATE_ESC
"hp2xx" DELEGATE_ESC
" -sstdout=%%stderr -m eps -f `basename " DELEGATE_ESC
"%o" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv -f `basename " DELEGATE_ESC
"%o" DELEGATE_ESC
"` " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
124 " <delegate decode=\"hpgl\" command=\"" DELEGATE_ESC
"hp2xx" DELEGATE_ESC
" -sstdout=%%stderr -m eps -f `basename " DELEGATE_ESC
"%o" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv -f `basename " DELEGATE_ESC
"%o" DELEGATE_ESC
"` " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
125 " <delegate decode=\"htm\" command=\"" DELEGATE_ESC
"html2ps" DELEGATE_ESC
" -U -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
126 " <delegate decode=\"html\" command=\"" DELEGATE_ESC
"html2ps" DELEGATE_ESC
" -U -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
127 " <delegate decode=\"ilbm\" command=\"" DELEGATE_ESC
"ilbmtoppm" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" > " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
128 " <delegate decode=\"jpg\" encode=\"lep\" mode=\"encode\" command=\"" DELEGATE_ESC
"lepton" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
129 " <delegate decode=\"jxr\" command=\"mv " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%i.jxr" DELEGATE_ESC
"; " DELEGATE_ESC
"JxrDecApp" DELEGATE_ESC
" -i " DELEGATE_ESC
"%i.jxr" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o.tiff" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.jxr" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.tiff" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
130 " <delegate decode=\"lep\" mode=\"decode\" command=\"" DELEGATE_ESC
"lepton" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
131 " <delegate decode=\"odt\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
132 " <delegate decode=\"pcl:cmyk\" stealth=\"True\" command=\"" DELEGATE_ESC
"pcl6" DELEGATE_ESC
" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pamcmyk32" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
133 " <delegate decode=\"pcl:color\" stealth=\"True\" command=\"" DELEGATE_ESC
"pcl6" DELEGATE_ESC
" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=ppmraw" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
134 " <delegate decode=\"pcl:mono\" stealth=\"True\" command=\"" DELEGATE_ESC
"pcl6" DELEGATE_ESC
" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pbmraw" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
135 " <delegate decode=\"pdf\" encode=\"eps\" mode=\"bi\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sPDFPassword=" DELEGATE_ESC
"%a" DELEGATE_ESC
" " DELEGATE_ESC
"-sDEVICE=eps2write" DELEGATE_ESC
" " DELEGATE_ESC
"-sOutputFile=%o" DELEGATE_ESC
" " DELEGATE_ESC
"-f%i" DELEGATE_ESC
"\"/>"
136 " <delegate decode=\"pdf\" encode=\"ps\" mode=\"bi\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=ps2write" DELEGATE_ESC
" -sPDFPassword=" DELEGATE_ESC
"%a" DELEGATE_ESC
" " DELEGATE_ESC
"-sOutputFile=%o" DELEGATE_ESC
" " DELEGATE_ESC
"-f%i" DELEGATE_ESC
"\"/>"
137 " <delegate decode=\"png\" encode=\"clipboard\" command=\"" DELEGATE_ESC
"xclip" DELEGATE_ESC
" -selection clipboard -t image/png " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
138 " <delegate decode=\"clipboard\" command=\"" DELEGATE_ESC
"xclip" DELEGATE_ESC
" -selection clipboard -o > " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
139 " <delegate decode=\"png\" encode=\"webp\" command=\"" DELEGATE_ESC
"cwebp" DELEGATE_ESC
" -quiet -q %Q " DELEGATE_ESC
"%i" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
140 " <delegate decode=\"pnm\" encode=\"ilbm\" mode=\"encode\" command=\"" DELEGATE_ESC
"ppmtoilbm" DELEGATE_ESC
" -24if " DELEGATE_ESC
"%i" DELEGATE_ESC
" > " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
141 " <delegate decode=\"tiff\" encode=\"jxr\" command=\"mv " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%i.tiff" DELEGATE_ESC
"; " DELEGATE_ESC
"JxrEncApp" DELEGATE_ESC
" -i " DELEGATE_ESC
"%i.tiff" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o.jxr" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.tiff" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.jxr" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
142 " <delegate decode=\"tiff\" encode=\"wdp\" command=\"mv " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%i.tiff" DELEGATE_ESC
"; " DELEGATE_ESC
"JxrEncApp" DELEGATE_ESC
" -i " DELEGATE_ESC
"%i.tiff" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o.jxr" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.tiff" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.jxr" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
143 " <delegate decode=\"ppt\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
144 " <delegate decode=\"pptx\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
145 " <delegate decode=\"ps\" encode=\"prt\" command=\"" DELEGATE_ESC
"lpr" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
146 " <delegate decode=\"ps:alpha\" stealth=\"True\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pngalpha" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
"\"/>"
147 " <delegate decode=\"ps:cmyk\" stealth=\"True\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pamcmyk32" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
"\"/>"
148 " <delegate decode=\"ps:color\" stealth=\"True\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pnmraw" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
"\"/>"
149 " <delegate decode=\"ps\" encode=\"eps\" mode=\"bi\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=eps2write" DELEGATE_ESC
" " DELEGATE_ESC
"-sOutputFile=%o" DELEGATE_ESC
" " DELEGATE_ESC
"-f%i" DELEGATE_ESC
"\"/>"
150 " <delegate decode=\"ps\" encode=\"pdf\" mode=\"bi\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pdfwrite" DELEGATE_ESC
" " DELEGATE_ESC
"-sOutputFile=%o" DELEGATE_ESC
" " DELEGATE_ESC
"-f%i" DELEGATE_ESC
"\"/>"
151 " <delegate decode=\"ps\" encode=\"print\" mode=\"encode\" command=\"lpr " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
152 " <delegate decode=\"ps:mono\" stealth=\"True\" command=\"" DELEGATE_ESC
"gs" DELEGATE_ESC
" -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pbmraw" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
" " DELEGATE_ESC
"-f%s" DELEGATE_ESC
"\"/>"
153 " <delegate decode=\"shtml\" command=\"" DELEGATE_ESC
"html2ps" DELEGATE_ESC
" -U -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
154 " <delegate decode=\"sid\" command=\"" DELEGATE_ESC
"mrsidgeodecode" DELEGATE_ESC
" -if sid -i " DELEGATE_ESC
"%i" DELEGATE_ESC
" -of tif -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" > " DELEGATE_ESC
"%u" DELEGATE_ESC
"\"/>"
155 " <delegate decode=\"svg\" command=\"" DELEGATE_ESC
"rsvg-convert" DELEGATE_ESC
" --dpi-x %x --dpi-y %y -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
156#ifndef MAGICKCORE_RSVG_DELEGATE
157 " <delegate decode=\"svg:decode\" stealth=\"True\" command=\"" DELEGATE_ESC
"inkscape" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
" --export-png=" DELEGATE_ESC
"%s" DELEGATE_ESC
" --export-dpi=" DELEGATE_ESC
"%s" DELEGATE_ESC
" --export-background=" DELEGATE_ESC
"%s" DELEGATE_ESC
" --export-background-opacity=" DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
159 " <delegate decode=\"tiff\" encode=\"launch\" mode=\"encode\" command=\"" DELEGATE_ESC
"gimp" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
160 " <delegate decode=\"wdp\" command=\"mv " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%i.jxr" DELEGATE_ESC
"; " DELEGATE_ESC
"JxrDecApp" DELEGATE_ESC
" -i " DELEGATE_ESC
"%i.jxr" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o.tiff" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.jxr" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%o.tiff" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
161 " <delegate decode=\"webp\" command=\"" DELEGATE_ESC
"dwebp" DELEGATE_ESC
" -pam " DELEGATE_ESC
"%i" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
162 " <delegate decode=\"xls\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
163 " <delegate decode=\"xlsx\" command=\"" DELEGATE_ESC
"soffice" DELEGATE_ESC
" --convert-to pdf -outdir `dirname " DELEGATE_ESC
"%i" DELEGATE_ESC
"` " DELEGATE_ESC
"%i" DELEGATE_ESC
" 2> " DELEGATE_ESC
"%u" DELEGATE_ESC
"; mv " DELEGATE_ESC
"%i.pdf" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
164 " <delegate decode=\"xps:cmyk\" stealth=\"True\" command=\"" DELEGATE_ESC
"gxps" DELEGATE_ESC
" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=bmpsep8" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
165 " <delegate decode=\"xps:color\" stealth=\"True\" command=\"" DELEGATE_ESC
"gxps" DELEGATE_ESC
" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=ppmraw" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
166 " <delegate decode=\"xps:mono\" stealth=\"True\" command=\"" DELEGATE_ESC
"gxps" DELEGATE_ESC
" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 " DELEGATE_ESC
"-sDEVICE=pbmraw" DELEGATE_ESC
" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u " DELEGATE_ESC
"-r%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"-sOutputFile=%s" DELEGATE_ESC
" " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
167 " <delegate decode=\"video:decode\" command=\"" DELEGATE_ESC
"ffmpeg" DELEGATE_ESC
" -nostdin -loglevel error -i " DELEGATE_ESC
"%s" DELEGATE_ESC
" -an -f rawvideo -y %s " DELEGATE_ESC
"%s" DELEGATE_ESC
"\"/>"
168 " <delegate encode=\"video:encode\" stealth=\"True\" command=\"" DELEGATE_ESC
"ffmpeg" DELEGATE_ESC
" -nostdin -loglevel error -i " DELEGATE_ESC
"%s%%d.%s" DELEGATE_ESC
" %s " DELEGATE_ESC
"%s.%s" DELEGATE_ESC
"\"/>"
184static MagickBooleanType
186 LoadDelegateCache(
LinkedListInfo *,
const char *,
const char *,
const size_t,
221 cache=NewLinkedList(0);
222#if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
230 options=GetConfigureOptions(filename,exception);
231 option=(
const StringInfo *) GetNextValueInLinkedList(options);
234 (void) LoadDelegateCache(cache,(
const char *)
235 GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
236 option=(
const StringInfo *) GetNextValueInLinkedList(options);
238 options=DestroyConfigureOptions(options);
241 magick_unreferenced(filename);
243 if (IsLinkedListEmpty(cache) != MagickFalse)
244 (void) LoadDelegateCache(cache,DelegateMap,
"built-in",0,exception);
266MagickPrivate MagickBooleanType DelegateComponentGenesis(
void)
269 delegate_semaphore=AcquireSemaphoreInfo();
292static void *DestroyDelegate(
void *delegate_info)
298 if (p->path != (
char *) NULL)
299 p->path=DestroyString(p->path);
300 if (p->decode != (
char *) NULL)
301 p->decode=DestroyString(p->decode);
302 if (p->encode != (
char *) NULL)
303 p->encode=DestroyString(p->encode);
304 if (p->commands != (
char *) NULL)
305 p->commands=DestroyString(p->commands);
307 RelinquishSemaphoreInfo(&p->semaphore);
309 return((
void *) NULL);
312MagickPrivate
void DelegateComponentTerminus(
void)
315 ActivateSemaphoreInfo(&delegate_semaphore);
316 LockSemaphoreInfo(delegate_semaphore);
318 delegate_cache=DestroyLinkedList(delegate_cache,DestroyDelegate);
319 UnlockSemaphoreInfo(delegate_semaphore);
320 RelinquishSemaphoreInfo(&delegate_semaphore);
359MagickExport
int ExternalDelegateCommand(
const MagickBooleanType asynchronous,
360 const MagickBooleanType verbose,
const char *command,
char *message,
381 arguments=StringToArgv(command,&number_arguments);
382 if (arguments == (
char **) NULL)
384 if (*arguments[1] ==
'\0')
386 for (i=0; i < (ssize_t) number_arguments; i++)
387 arguments[i]=DestroyString(arguments[i]);
388 arguments=(
char **) RelinquishMagickMemory(arguments);
391 rights=ExecutePolicyRights;
392 domain=DelegatePolicyDomain;
393 if (IsRightsAuthorized(domain,rights,arguments[1]) == MagickFalse)
396 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
397 "NotAuthorized",
"`%s'",arguments[1]);
398 for (i=0; i < (ssize_t) number_arguments; i++)
399 arguments[i]=DestroyString(arguments[i]);
400 arguments=(
char **) RelinquishMagickMemory(arguments);
403 if (verbose != MagickFalse)
405 (void) FormatLocaleFile(stderr,
"%s\n",command);
406 (void) fflush(stderr);
408 sanitize_command=SanitizeString(command);
409 if (asynchronous != MagickFalse)
410 (void) ConcatenateMagickString(sanitize_command,
"&",MagickPathExtent);
411 if (message != (
char *) NULL)
413#if defined(MAGICKCORE_POSIX_SUPPORT)
414#if defined(MAGICKCORE_HAVE_POPEN)
415 if ((asynchronous == MagickFalse) && (message != (
char *) NULL))
420 file=popen_utf8(sanitize_command,
"r");
421 if (file == (FILE *) NULL)
422 status=system(sanitize_command);
428 while ((offset < MagickPathExtent) &&
429 (fgets(message+offset,MagickPathExtent-offset,file) != NULL))
430 offset+=strlen(message);
437#if !defined(MAGICKCORE_HAVE_EXECVP)
438 status=system(sanitize_command);
440 if ((asynchronous != MagickFalse) ||
441 (strpbrk(sanitize_command,
"&;<>|") != (
char *) NULL))
442 status=system(sanitize_command);
451 child_pid=(pid_t) fork();
452 if (child_pid == (pid_t) -1)
453 status=system(sanitize_command);
457 status=execvp(arguments[1],arguments+1);
469 pid=(pid_t) waitpid(child_pid,&child_status,0);
474 if (WIFEXITED(child_status) != 0)
475 status=WEXITSTATUS(child_status);
477 if (WIFSIGNALED(child_status))
484#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
497 p=strstr(sanitize_command,
"cmd.exe /c");
498 if (p != (
char*) NULL)
501 for ( ; *p !=
'\0'; p++)
503 *p=(*DirectorySeparator);
506 status=NTSystemCommand(sanitize_command,message);
508 status=system(sanitize_command);
510# error No suitable system() method.
514 if ((message != (
char *) NULL) && (*message !=
'\0'))
515 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
516 "FailedToExecuteCommand",
"`%s' (%s)",sanitize_command,message);
518 (
void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
519 "FailedToExecuteCommand",
"`%s' (%d)",sanitize_command,status);
521 sanitize_command=DestroyString(sanitize_command);
522 for (i=0; i < (ssize_t) number_arguments; i++)
523 arguments[i]=DestroyString(arguments[i]);
524 arguments=(
char **) RelinquishMagickMemory(arguments);
566static char *GetMagickPropertyLetter(
ImageInfo *image_info,
Image *image,
569#define WarnNoImageReturn(format,letter) \
570 if (image == (Image *) NULL) \
572 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
573 "NoImageForProperty",format,letter); \
576#define WarnNoImageInfoReturn(format,letter) \
577 if (image_info == (ImageInfo *) NULL) \
579 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
580 "NoImageInfoForProperty",format,letter); \
585 value[MagickPathExtent];
590 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
591 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
593 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
594 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
599 string=(
const char *) value;
604 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
605 string=GetImageOption(image_info,
"authenticate");
610 WarnNoImageReturn(
"\"%%%c\"",letter);
611 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
613 if (image->extent == 0)
614 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
615 MagickPathExtent,value);
620 WarnNoImageReturn(
"\"%%%c\"",letter);
621 GetPathComponent(image->magick_filename,HeadPath,value);
626 WarnNoImageReturn(
"\"%%%c\"",letter);
627 GetPathComponent(image->magick_filename,ExtensionPath,value);
632 WarnNoImageReturn(
"\"%%%c\"",letter);
633 GetPathComponent(image->magick_filename,TailPath,value);
638 WarnNoImageReturn(
"\"%%%c\"",letter);
639 (void) FormatLocaleString(value,MagickPathExtent,
640 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(double)
641 image->page.height,(
double) image->page.x,(double) image->page.y);
646 WarnNoImageReturn(
"\"%%%c\"",letter);
647 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
648 (image->rows != 0 ? image->rows : image->magick_rows));
653 WarnNoImageReturn(
"\"%%%c\"",letter);
654 string=image->filename;
659 WarnNoImageReturn(
"\"%%%c\"",letter);
660 string=image->magick;
665 if (image != (
Image *) NULL)
666 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
667 GetImageListLength(image));
672 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
673 string=image_info->filename;
678 WarnNoImageReturn(
"\"%%%c\"",letter);
679 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
680 GetImageIndexInList(image));
685 WarnNoImageReturn(
"\"%%%c\"",letter);
686 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
687 MAGICKCORE_QUANTUM_DEPTH);
695 WarnNoImageReturn(
"\"%%%c\"",letter);
696 colorspace=image->colorspace;
697 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
698 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
699 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
700 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
706 WarnNoImageReturn(
"\"%%%c\"",letter);
707 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
713 WarnNoImageReturn(
"\"%%%c\"",letter);
714 GetPathComponent(image->magick_filename,BasePath,value);
719 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
720 string=image_info->unique;
725 WarnNoImageReturn(
"\"%%%c\"",letter);
726 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
727 (image->columns != 0 ? image->columns : image->magick_columns));
732 WarnNoImageReturn(
"\"%%%c\"",letter);
733 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
734 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
735 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
741 WarnNoImageReturn(
"\"%%%c\"",letter);
742 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
743 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
744 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
750 WarnNoImageReturn(
"\"%%%c\"",letter);
751 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
752 (
double) image->depth);
757 WarnNoImageReturn(
"\"%%%c\"",letter);
758 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
764 WarnNoImageReturn(
"\"%%%c\"",letter);
765 string=CommandOptionToMnemonic(MagickCompressOptions,
766 (ssize_t) image->compression);
771 WarnNoImageReturn(
"\"%%%c\"",letter);
772 string=CommandOptionToMnemonic(MagickDisposeOptions,
773 (ssize_t) image->dispose);
781 WarnNoImageReturn(
"\"%%%c\"",letter);
782 (void) CopyMagickString(value,image->magick_filename,MagickPathExtent);
787 WarnNoImageReturn(
"\"%%%c\"",letter);
788 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
789 (
double) image->magick_columns,(double) image->magick_rows);
794 WarnNoImageReturn(
"\"%%%c\"",letter);
795 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
796 (
double) image->page.height);
801 WarnNoImageReturn(
"\"%%%c\"",letter);
802 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
808 WarnNoImageReturn(
"\"%%%c\"",letter);
809 string=image->magick_filename;
814 WarnNoImageReturn(
"\"%%%c\"",letter);
815 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
816 image->page.x,(long) image->page.y);
821 WarnNoImageReturn(
"\"%%%c\"",letter);
822 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
823 (
double) image->page.width,(double) image->page.height);
828 WarnNoImageReturn(
"\"%%%c\"",letter);
829 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
830 (100-(image->quality == 0 ? 42 : image->quality))/2);
835 WarnNoImageReturn(
"\"%%%c\"",letter);
836 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
837 (image->quality == 0 ? 92 : image->quality));
842 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
843 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
844 (image_info->number_scenes == 0 ? 2147483647 :
845 image_info->number_scenes));
850 WarnNoImageReturn(
"\"%%%c\"",letter);
851 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
857 WarnNoImageReturn(
"\"%%%c\"",letter);
858 string=CommandOptionToMnemonic(MagickResolutionOptions,
859 (ssize_t) image->units);
864 WarnNoImageReturn(
"\"%%%c\"",letter);
865 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
871 WarnNoImageReturn(
"\"%%%c\"",letter);
872 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
878 WarnNoImageReturn(
"\"%%%c\"",letter);
879 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
893 WarnNoImageReturn(
"\"%%%c\"",letter);
894 page=GetImageBoundingBox(image,exception);
895 (void) FormatLocaleString(value,MagickPathExtent,
896 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(double) page.height,
897 (
double) page.x,(double) page.y);
905 WarnNoImageReturn(
"\"%%%c\"",letter);
906 (void) SignatureImage(image,exception);
907 string=GetImageProperty(image,
"signature",exception);
911 return(SanitizeDelegateString(
string));
914static char *InterpretDelegateProperties(
ImageInfo *image_info,
917#define ExtendInterpretText(string_length) \
919 size_t length=(string_length); \
920 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
923 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
924 MagickPathExtent,sizeof(*interpret_text)); \
925 if (interpret_text == (char *) NULL) \
926 return((char *) NULL); \
927 q=interpret_text+strlen(interpret_text); \
931#define AppendKeyValue2Text(key,value)\
933 size_t length=strlen(key)+strlen(value)+2; \
934 if ((size_t) (q-interpret_text+length+1) >= extent) \
937 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
938 MagickPathExtent,sizeof(*interpret_text)); \
939 if (interpret_text == (char *) NULL) \
940 return((char *) NULL); \
941 q=interpret_text+strlen(interpret_text); \
943 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
946#define AppendString2Text(string) \
948 size_t length=strlen((string)); \
949 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
952 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
953 MagickPathExtent,sizeof(*interpret_text)); \
954 if (interpret_text == (char *) NULL) \
955 return((char *) NULL); \
956 q=interpret_text+strlen(interpret_text); \
958 (void) CopyMagickString(q,(string),extent); \
959 q+=(ptrdiff_t) length; \
978 assert(image == NULL || image->signature == MagickCoreSignature);
979 assert(image_info == NULL || image_info->signature == MagickCoreSignature);
980 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
981 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
983 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
984 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-image");
985 if (embed_text == (
const char *) NULL)
986 return(ConstantString(
""));
988 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
991 return(ConstantString(
""));
995 interpret_text=AcquireString(embed_text);
996 extent=MagickPathExtent;
998 for (q=interpret_text; *p!=
'\0';
999 number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
1005 ExtendInterpretText(MagickPathExtent);
1048 if (LocaleNCompare(
"<",p,4) == 0)
1054 if (LocaleNCompare(
">",p,4) == 0)
1060 if (LocaleNCompare(
"&",p,5) == 0)
1081 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
1091 if (number != MagickFalse)
1100 string=GetMagickPropertyLetter(image_info,image,*p,exception);
1101 if (
string != (
char *) NULL)
1103 AppendString2Text(
string);
1104 string=DestroyString(
string);
1107 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
1108 "UnknownImageProperty",
"\"%%%c\"",*p);
1111 return(interpret_text);
1114MagickExport
char *GetDelegateCommand(
const ImageInfo *image_info,
Image *image,
1115 const char *decode,
const char *encode,
ExceptionInfo *exception)
1127 assert(image_info != (
ImageInfo *) NULL);
1128 assert(image_info->signature == MagickCoreSignature);
1129 assert(image != (
Image *) NULL);
1130 assert(image->signature == MagickCoreSignature);
1131 if (IsEventLogging() != MagickFalse)
1132 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1133 delegate_info=GetDelegateInfo(decode,encode,exception);
1136 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1137 "NoTagFound",
"`%s'",decode ? decode : encode);
1138 return((
char *) NULL);
1140 commands=StringToList(delegate_info->commands);
1141 if (commands == (
char **) NULL)
1143 (void) ThrowMagickException(exception,GetMagickModule(),
1144 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",decode ? decode :
1146 return((
char *) NULL);
1148 command=InterpretDelegateProperties((
ImageInfo *) image_info,image,
1149 commands[0],exception);
1150 if (command == (
char *) NULL)
1151 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
1152 "MemoryAllocationFailed",
"`%s'",commands[0]);
1156 for (i=0; commands[i] != (
char *) NULL; i++)
1157 commands[i]=DestroyString(commands[i]);
1158 commands=(
char **) RelinquishMagickMemory(commands);
1184MagickExport
const char *GetDelegateCommands(
const DelegateInfo *delegate_info)
1186 if (IsEventLogging() != MagickFalse)
1187 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1189 assert(delegate_info->signature == MagickCoreSignature);
1190 return(delegate_info->commands);
1222MagickExport
const DelegateInfo *GetDelegateInfo(
const char *decode,
1232 if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1238 LockSemaphoreInfo(delegate_semaphore);
1239 p=GetHeadElementInLinkedList(delegate_cache);
1240 if ((LocaleCompare(decode,
"*") == 0) && (LocaleCompare(encode,
"*") == 0))
1242 UnlockSemaphoreInfo(delegate_semaphore);
1245 return(delegate_info);
1250 if (delegate_info->mode > 0)
1252 if (LocaleCompare(delegate_info->decode,decode) == 0)
1257 if (delegate_info->mode < 0)
1259 if (LocaleCompare(delegate_info->encode,encode) == 0)
1264 if (LocaleCompare(decode,delegate_info->decode) == 0)
1265 if (LocaleCompare(encode,delegate_info->encode) == 0)
1267 if (LocaleCompare(decode,
"*") == 0)
1268 if (LocaleCompare(encode,delegate_info->encode) == 0)
1270 if (LocaleCompare(decode,delegate_info->decode) == 0)
1271 if (LocaleCompare(encode,
"*") == 0)
1278 SetHeadElementInLinkedList(delegate_cache,p);
1279 UnlockSemaphoreInfo(delegate_semaphore);
1280 return(delegate_info);
1312#if defined(__cplusplus) || defined(c_plusplus)
1316static int DelegateInfoCompare(
const void *x,
const void *y)
1327 cmp=LocaleCompare((*p)->path,(*q)->path);
1330 if ((*p)->decode == (
char *) NULL)
1331 if (((*p)->encode != (
char *) NULL) &&
1332 ((*q)->encode != (
char *) NULL))
1333 return(strcmp((*p)->encode,(*q)->encode));
1334 if (((*p)->decode != (
char *) NULL) &&
1335 ((*q)->decode != (
char *) NULL))
1336 return(strcmp((*p)->decode,(*q)->decode));
1341#if defined(__cplusplus) || defined(c_plusplus)
1345MagickExport
const DelegateInfo **GetDelegateInfoList(
const char *pattern,
1357 assert(number_delegates != (
size_t *) NULL);
1358 assert(pattern != (
char *) NULL);
1359 if (IsEventLogging() != MagickFalse)
1360 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
1361 *number_delegates=0;
1362 if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1364 delegates=(
const DelegateInfo **) AcquireQuantumMemory((
size_t)
1365 GetNumberOfElementsInLinkedList(delegate_cache)+1UL,
sizeof(*delegates));
1368 LockSemaphoreInfo(delegate_semaphore);
1369 p=GetHeadElementInLinkedList(delegate_cache);
1376 if( (delegate_info->stealth == MagickFalse) &&
1377 (GlobExpression(delegate_info->decode,pattern,MagickFalse) != MagickFalse ||
1378 GlobExpression(delegate_info->encode,pattern,MagickFalse) != MagickFalse))
1379 delegates[i++]=delegate_info;
1382 UnlockSemaphoreInfo(delegate_semaphore);
1384 delegates=(
const DelegateInfo **) RelinquishMagickMemory((
void*) delegates);
1387 qsort((
void *) delegates,(
size_t) i,
sizeof(*delegates),DelegateInfoCompare);
1390 *number_delegates=(size_t) i;
1424#if defined(__cplusplus) || defined(c_plusplus)
1428static int DelegateCompare(
const void *x,
const void *y)
1434 p=(
const char **) x;
1435 q=(
const char **) y;
1436 return(LocaleCompare(*p,*q));
1439#if defined(__cplusplus) || defined(c_plusplus)
1443MagickExport
char **GetDelegateList(
const char *pattern,
1455 assert(pattern != (
char *) NULL);
1456 if (IsEventLogging() != MagickFalse)
1457 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
1458 assert(number_delegates != (
size_t *) NULL);
1459 *number_delegates=0;
1460 if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1461 return((
char **) NULL);
1462 delegates=(
char **) AcquireQuantumMemory((
size_t)
1463 GetNumberOfElementsInLinkedList(delegate_cache)+1UL,
sizeof(*delegates));
1464 if (delegates == (
char **) NULL)
1465 return((
char **) NULL);
1466 LockSemaphoreInfo(delegate_semaphore);
1467 p=GetHeadElementInLinkedList(delegate_cache);
1474 if ((delegate_info->stealth == MagickFalse) &&
1475 (GlobExpression(delegate_info->decode,pattern,MagickFalse) != MagickFalse))
1476 delegates[i++]=ConstantString(delegate_info->decode);
1477 if ((delegate_info->stealth == MagickFalse) &&
1478 (GlobExpression(delegate_info->encode,pattern,MagickFalse) != MagickFalse))
1479 delegates[i++]=ConstantString(delegate_info->encode);
1482 UnlockSemaphoreInfo(delegate_semaphore);
1484 delegates=(
char **) RelinquishMagickMemory(delegates);
1487 qsort((
void *) delegates,(
size_t) i,
sizeof(*delegates),DelegateCompare);
1488 delegates[i]=(
char *) NULL;
1490 *number_delegates=(size_t) i;
1516MagickExport ssize_t GetDelegateMode(
const DelegateInfo *delegate_info)
1518 if (IsEventLogging() != MagickFalse)
1519 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1521 assert(delegate_info->signature == MagickCoreSignature);
1522 return(delegate_info->mode);
1549MagickExport MagickBooleanType GetDelegateThreadSupport(
1553 assert(delegate_info->signature == MagickCoreSignature);
1554 if (IsEventLogging() != MagickFalse)
1555 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1556 return(delegate_info->thread_support);
1582static MagickBooleanType IsDelegateCacheInstantiated(
ExceptionInfo *exception)
1587 ActivateSemaphoreInfo(&delegate_semaphore);
1588 LockSemaphoreInfo(delegate_semaphore);
1590 delegate_cache=AcquireDelegateCache(DelegateFilename,exception);
1591 UnlockSemaphoreInfo(delegate_semaphore);
1593 return(delegate_cache != (
LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
1626static MagickBooleanType CopyDelegateFile(
const char *source,
1627 const char *destination,
const MagickBooleanType overwrite,
1631 filename[MagickPathExtent];
1657 assert(source != (
const char *) NULL);
1658 assert(destination != (
char *) NULL);
1659 if (overwrite == MagickFalse)
1661 status=GetPathAttributes(destination,&attributes);
1662 if (status != MagickFalse)
1665 destination_file=AcquireUniqueFileResource(filename);
1666 if (destination_file == -1)
1667 return(MagickFalse);
1668 if (IsPathAuthorized(ReadPolicyRights,source) == MagickFalse)
1670 (void) close_utf8(destination_file);
1671 ThrowPolicyException(source,MagickFalse);
1673 source_file=open_utf8(source,O_RDONLY | O_BINARY,0);
1674 if (source_file == -1)
1676 (void) close_utf8(destination_file);
1677 return(MagickFalse);
1679 quantum=(size_t) MagickMaxBufferExtent;
1680 if ((fstat(source_file,&attributes) == 0) && (attributes.st_size > 0))
1681 quantum=MagickMin((
size_t) attributes.st_size,MagickMaxBufferExtent);
1682 buffer=(
unsigned char *) AcquireQuantumMemory(quantum,
sizeof(*buffer));
1683 if (buffer == (
unsigned char *) NULL)
1685 (void) close_utf8(source_file);
1686 (void) close_utf8(destination_file);
1687 return(MagickFalse);
1690 for (i=0; ; i+=(ssize_t) count)
1692 count=(ssize_t) read(source_file,buffer,quantum);
1695 length=(size_t) count;
1696 count=(ssize_t) write(destination_file,buffer,length);
1697 if ((
size_t) count != length)
1700 (void) close_utf8(destination_file);
1701 (void) close_utf8(source_file);
1702 buffer=(
unsigned char *) RelinquishMagickMemory(buffer);
1703 if (IsPathAuthorized(WritePolicyRights,destination) == MagickFalse)
1704 ThrowPolicyException(destination,MagickFalse);
1705 if (rename_utf8(filename,destination) != 0)
1706 return(MagickFalse);
1707 return(i != 0 ? MagickTrue : MagickFalse);
1710MagickExport MagickBooleanType InvokeDelegate(
ImageInfo *image_info,
1716 input_filename[MagickPathExtent],
1717 output_filename[MagickPathExtent];
1735 assert(image_info != (
ImageInfo *) NULL);
1736 assert(image_info->signature == MagickCoreSignature);
1737 assert(image != (
Image *) NULL);
1738 assert(image->signature == MagickCoreSignature);
1739 if (IsEventLogging() != MagickFalse)
1740 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1741 rights=ExecutePolicyRights;
1742 if ((decode != (
const char *) NULL) &&
1743 (IsRightsAuthorized(DelegatePolicyDomain,rights,decode) == MagickFalse))
1746 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1747 "NotAuthorized",
"`%s'",decode);
1748 return(MagickFalse);
1750 if ((encode != (
const char *) NULL) &&
1751 (IsRightsAuthorized(DelegatePolicyDomain,rights,encode) == MagickFalse))
1754 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1755 "NotAuthorized",
"`%s'",encode);
1756 return(MagickFalse);
1758 temporary=*image->filename ==
'\0' ? MagickTrue : MagickFalse;
1759 if ((temporary != MagickFalse) && (AcquireUniqueFilename(image->filename) ==
1762 ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",
1764 return(MagickFalse);
1766 delegate_info=GetDelegateInfo(decode,encode,exception);
1769 if (temporary != MagickFalse)
1770 (void) RelinquishUniqueFileResource(image->filename);
1771 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1772 "NoTagFound",
"`%s'",decode ? decode : encode);
1773 return(MagickFalse);
1775 if (*image_info->filename ==
'\0')
1777 if (AcquireUniqueFilename(image_info->filename) == MagickFalse)
1779 if (temporary != MagickFalse)
1780 (void) RelinquishUniqueFileResource(image->filename);
1781 ThrowFileException(exception,FileOpenError,
1782 "UnableToCreateTemporaryFile",image_info->filename);
1783 return(MagickFalse);
1785 image_info->temporary=MagickTrue;
1787 if ((delegate_info->mode != 0) && (((decode != (
const char *) NULL) &&
1788 (delegate_info->encode != (
char *) NULL)) ||
1789 ((encode != (
const char *) NULL) &&
1790 (delegate_info->decode != (
char *) NULL))))
1804 if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1806 ThrowFileException(exception,FileOpenError,
1807 "UnableToCreateTemporaryFile",image_info->unique);
1808 return(MagickFalse);
1810 magick=InterpretImageProperties(image_info,image,decode != (
char *) NULL ?
1811 delegate_info->encode : delegate_info->decode,exception);
1812 if (magick == (
char *) NULL)
1814 (void) RelinquishUniqueFileResource(image_info->unique);
1815 if (temporary != MagickFalse)
1816 (void) RelinquishUniqueFileResource(image->filename);
1817 (void) ThrowMagickException(exception,GetMagickModule(),
1818 DelegateError,
"DelegateFailed",
"`%s'",decode ? decode : encode);
1819 return(MagickFalse);
1821 LocaleUpper(magick);
1822 clone_info=CloneImageInfo(image_info);
1823 (void) CopyMagickString((
char *) clone_info->magick,magick,
1825 if (LocaleCompare(magick,
"NULL") != 0)
1826 (
void) CopyMagickString(image->magick,magick,MagickPathExtent);
1827 magick=DestroyString(magick);
1828 (void) FormatLocaleString(clone_info->filename,MagickPathExtent,
"%s:",
1829 delegate_info->decode);
1830 (void) SetImageInfo(clone_info,(
unsigned int) GetImageListLength(image),
1832 (void) CopyMagickString(clone_info->filename,image_info->filename,
1834 (void) CopyMagickString(image_info->filename,image->filename,
1836 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1838 (void) FormatLocaleString(p->filename,MagickPathExtent,
"%s:%s",
1839 delegate_info->decode,clone_info->filename);
1840 status=WriteImage(clone_info,p,exception);
1841 if (status == MagickFalse)
1843 (void) RelinquishUniqueFileResource(image_info->unique);
1844 if (temporary != MagickFalse)
1845 (void) RelinquishUniqueFileResource(image->filename);
1846 clone_info=DestroyImageInfo(clone_info);
1847 (void) ThrowMagickException(exception,GetMagickModule(),
1848 DelegateError,
"DelegateFailed",
"`%s'",decode ? decode : encode);
1849 return(MagickFalse);
1851 if (clone_info->adjoin != MagickFalse)
1854 (void) RelinquishUniqueFileResource(image_info->unique);
1855 clone_info=DestroyImageInfo(clone_info);
1860 commands=StringToList(delegate_info->commands);
1861 if (commands == (
char **) NULL)
1863 if (temporary != MagickFalse)
1864 (void) RelinquishUniqueFileResource(image->filename);
1865 (void) ThrowMagickException(exception,GetMagickModule(),
1866 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
1867 decode ? decode : encode);
1868 return(MagickFalse);
1870 command=(
char *) NULL;
1872 (void) CopyMagickString(output_filename,image_info->filename,
1874 (void) CopyMagickString(input_filename,image->filename,MagickPathExtent);
1875 for (i=0; commands[i] != (
char *) NULL; i++)
1877 (void) AcquireUniqueSymbolicLink(output_filename,image_info->filename);
1878 if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1880 ThrowFileException(exception,FileOpenError,
1881 "UnableToCreateTemporaryFile",image_info->unique);
1884 if (LocaleCompare(decode,
"SCAN") != 0)
1886 status=AcquireUniqueSymbolicLink(input_filename,image->filename);
1887 if (status == MagickFalse)
1889 ThrowFileException(exception,FileOpenError,
1890 "UnableToCreateTemporaryFile",input_filename);
1895 command=InterpretDelegateProperties(image_info,image,commands[i],exception);
1896 if (command != (
char *) NULL)
1901 if (ExternalDelegateCommand(delegate_info->spawn,image_info->verbose,command,(
char *) NULL,exception) != 0)
1903 if (delegate_info->spawn != MagickFalse)
1912 while ((count-- > 0) && (access_utf8(image->filename,F_OK) == 0))
1913 (void) MagickDelay(100);
1915 command=DestroyString(command);
1917 if (LocaleCompare(decode,
"SCAN") != 0)
1919 if (CopyDelegateFile(image->filename,input_filename,MagickFalse,exception) == MagickFalse)
1921 (void) RelinquishUniqueFileResource(input_filename);
1925 if ((strcmp(input_filename,output_filename) != 0) &&
1926 (CopyDelegateFile(image_info->filename,output_filename,MagickTrue,exception) == MagickFalse))
1928 (void) RelinquishUniqueFileResource(output_filename);
1931 if (image_info->temporary != MagickFalse)
1932 (void) RelinquishUniqueFileResource(image_info->filename);
1933 (void) RelinquishUniqueFileResource(image_info->unique);
1934 (void) RelinquishUniqueFileResource(image_info->filename);
1935 (void) RelinquishUniqueFileResource(image->filename);
1936 if (status == MagickFalse)
1938 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1939 "DelegateFailed",
"`%s'",commands[i]);
1942 commands[i]=DestroyString(commands[i]);
1944 (void) CopyMagickString(image_info->filename,output_filename,
1946 (void) CopyMagickString(image->filename,input_filename,MagickPathExtent);
1950 for ( ; commands[i] != (
char *) NULL; i++)
1951 commands[i]=DestroyString(commands[i]);
1952 commands=(
char **) RelinquishMagickMemory(commands);
1953 if (temporary != MagickFalse)
1954 (void) RelinquishUniqueFileResource(image->filename);
1982MagickExport MagickBooleanType ListDelegateInfo(FILE *file,
1990 delegate[MagickPathExtent];
2004 if (file == (
const FILE *) NULL)
2006 delegate_info=GetDelegateInfoList(
"*",&number_delegates,exception);
2008 return(MagickFalse);
2009 path=(
const char *) NULL;
2010 for (i=0; i < (ssize_t) number_delegates; i++)
2012 if (delegate_info[i]->stealth != MagickFalse)
2014 if ((path == (
const char *) NULL) ||
2015 (LocaleCompare(path,delegate_info[i]->path) != 0))
2017 if (delegate_info[i]->path != (
char *) NULL)
2018 (
void) FormatLocaleFile(file,
"\nPath: %s\n\n",delegate_info[i]->path);
2019 (void) FormatLocaleFile(file,
"Delegate Command\n");
2020 (void) FormatLocaleFile(file,
2021 "-------------------------------------------------"
2022 "------------------------------\n");
2024 path=delegate_info[i]->path;
2026 if (delegate_info[i]->encode != (
char *) NULL)
2027 (
void) CopyMagickString(delegate,delegate_info[i]->encode,
2029 (void) ConcatenateMagickString(delegate,
" ",MagickPathExtent);
2031 commands=StringToList(delegate_info[i]->commands);
2032 if (commands == (
char **) NULL)
2034 (void) FormatLocaleFile(file,
"%11s%c=%c%s ",delegate_info[i]->decode ?
2035 delegate_info[i]->decode :
"",delegate_info[i]->mode <= 0 ?
'<' :
' ',
2036 delegate_info[i]->mode >= 0 ?
'>' :
' ',delegate);
2037 (void) StripMagickString(commands[0]);
2038 (void) FormatLocaleFile(file,
"\"%s\"\n",commands[0]);
2039 for (j=1; commands[j] != (
char *) NULL; j++)
2041 (void) StripMagickString(commands[j]);
2042 (void) FormatLocaleFile(file,
" \"%s\"\n",commands[j]);
2044 for (j=0; commands[j] != (
char *) NULL; j++)
2045 commands[j]=DestroyString(commands[j]);
2046 commands=(
char **) RelinquishMagickMemory(commands);
2048 (void) fflush(file);
2050 RelinquishMagickMemory((
void *) delegate_info);
2086 const char *xml,
const char *filename,
const size_t depth,
2090 keyword[MagickPathExtent],
2108 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
2109 "Loading delegate configuration file \"%s\" ...",filename);
2110 if (xml == (
const char *) NULL)
2111 return(MagickFalse);
2114 token=AcquireString(xml);
2115 extent=strlen(token)+MagickPathExtent;
2116 for (q=(
const char *) xml; *q !=
'\0'; )
2121 (void) GetNextToken(q,&q,extent,token);
2124 (void) CopyMagickString(keyword,token,MagickPathExtent);
2125 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
2130 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
2131 (
void) GetNextToken(q,&q,extent,token);
2134 if (LocaleNCompare(keyword,
"<!--",4) == 0)
2139 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
2140 (void) GetNextToken(q,&q,extent,token);
2143 if (LocaleCompare(keyword,
"<include") == 0)
2148 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
2150 (void) CopyMagickString(keyword,token,MagickPathExtent);
2151 (void) GetNextToken(q,&q,extent,token);
2154 (void) GetNextToken(q,&q,extent,token);
2155 if (LocaleCompare(keyword,
"file") == 0)
2157 if (depth > MagickMaxRecursionDepth)
2158 (void) ThrowMagickException(exception,GetMagickModule(),
2159 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
2163 path[MagickPathExtent],
2166 GetPathComponent(filename,HeadPath,path);
2168 (void) ConcatenateMagickString(path,DirectorySeparator,
2170 if (*token == *DirectorySeparator)
2171 (void) CopyMagickString(path,token,MagickPathExtent);
2173 (
void) ConcatenateMagickString(path,token,MagickPathExtent);
2174 file_xml=FileToXML(path,~0UL);
2175 if (file_xml != (
char *) NULL)
2177 status&=(MagickStatusType) LoadDelegateCache(cache,
2178 file_xml,path,depth+1,exception);
2179 file_xml=DestroyString(file_xml);
2186 if (LocaleCompare(keyword,
"<delegate") == 0)
2192 sizeof(*delegate_info));
2193 (void) memset(delegate_info,0,
sizeof(*delegate_info));
2194 delegate_info->path=ConstantString(filename);
2195 delegate_info->thread_support=MagickTrue;
2196 delegate_info->signature=MagickCoreSignature;
2201 if ((LocaleCompare(keyword,
"/>") == 0) ||
2202 (LocaleCompare(keyword,
"</policy>") == 0))
2204 status=AppendValueToLinkedList(cache,delegate_info);
2205 if (status == MagickFalse)
2206 (void) ThrowMagickException(exception,GetMagickModule(),
2207 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
2208 delegate_info->commands);
2212 (void) GetNextToken(q,(
const char **) NULL,extent,token);
2215 (void) GetNextToken(q,&q,extent,token);
2216 (void) GetNextToken(q,&q,extent,token);
2222 if (LocaleCompare((
char *) keyword,
"command") == 0)
2227 commands=AcquireString(token);
2228#if defined(MAGICKCORE_WINDOWS_SUPPORT)
2229 if (strchr(commands,
'@') != (
char *) NULL)
2232 path[MagickPathExtent];
2234 NTGhostscriptEXE(path,MagickPathExtent);
2235 (void) SubstituteString((
char **) &commands,
"@PSDelegate@",
2237 (void) SubstituteString((
char **) &commands,
"\\",
"/");
2240 (void) SubstituteString((
char **) &commands,
""",
"\"");
2241 (void) SubstituteString((
char **) &commands,
"'",
"'");
2242 (void) SubstituteString((
char **) &commands,
"&",
"&");
2243 (void) SubstituteString((
char **) &commands,
">",
">");
2244 (void) SubstituteString((
char **) &commands,
"<",
"<");
2245 if (delegate_info->commands != (
char *) NULL)
2246 delegate_info->commands=DestroyString(delegate_info->commands);
2247 delegate_info->commands=commands;
2255 if (LocaleCompare((
char *) keyword,
"decode") == 0)
2257 delegate_info->decode=ConstantString(token);
2258 delegate_info->mode=1;
2266 if (LocaleCompare((
char *) keyword,
"encode") == 0)
2268 delegate_info->encode=ConstantString(token);
2269 delegate_info->mode=(-1);
2277 if (LocaleCompare((
char *) keyword,
"mode") == 0)
2279 delegate_info->mode=1;
2280 if (LocaleCompare(token,
"bi") == 0)
2281 delegate_info->mode=0;
2283 if (LocaleCompare(token,
"encode") == 0)
2284 delegate_info->mode=(-1);
2292 if (LocaleCompare((
char *) keyword,
"spawn") == 0)
2294 delegate_info->spawn=IsStringTrue(token);
2297 if (LocaleCompare((
char *) keyword,
"stealth") == 0)
2299 delegate_info->stealth=IsStringTrue(token);
2307 if (LocaleCompare((
char *) keyword,
"thread-support") == 0)
2309 delegate_info->thread_support=IsStringTrue(token);
2310 if (delegate_info->thread_support == MagickFalse)
2311 delegate_info->semaphore=AcquireSemaphoreInfo();
2320 token=(
char *) RelinquishMagickMemory(token);
2321 return(status != 0 ? MagickTrue : MagickFalse);