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/property.h"
70 #include "MagickCore/resource_.h"
71 #include "MagickCore/semaphore.h"
72 #include "MagickCore/signature.h"
73 #include "MagickCore/string_.h"
74 #include "MagickCore/token.h"
75 #include "MagickCore/token-private.h"
76 #include "MagickCore/utility.h"
77 #include "MagickCore/utility-private.h"
78 #include "MagickCore/xml-tree.h"
79 #include "MagickCore/xml-tree-private.h"
84 #if defined(__APPLE__)
85 #include "TargetConditionals.h"
86 #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
87 #define system(s) ((s)==NULL ? 0 : -1)
89 #elif defined(__ANDROID__)
90 #define system(s) ((s)==NULL ? 0 : -1)
92 #define DelegateFilename "delegates.xml"
93 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
94 #define DELEGATE_ESC """
96 #define DELEGATE_ESC "'"
103 *DelegateMap = (
const char *)
104 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
106 " <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
"\"/>"
107 " <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
"\"/>"
108 " <delegate decode=\"browse\" stealth=\"True\" spawn=\"True\" command=\"" DELEGATE_ESC
"xdg-open" DELEGATE_ESC
" https://imagemagick.org/; rm " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
109 " <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
"\"/>"
110 " <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
"\"/>"
111 " <delegate decode=\"https\" command=\"" DELEGATE_ESC
"curl" DELEGATE_ESC
" -s -k -L -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"https:%M" DELEGATE_ESC
"\"/>"
112 " <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
"\"/>"
113 " <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
"\"/>"
114 " <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
"\"/>"
115 " <delegate decode=\"dot\" command=\"" DELEGATE_ESC
"dot" DELEGATE_ESC
" -Tsvg " DELEGATE_ESC
"%i" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
116 " <delegate decode=\"dvi\" command=\"" DELEGATE_ESC
"dvips" DELEGATE_ESC
" -sstdout=%%stderr -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
117 " <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
"\"/>"
118 " <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
"\"/>"
119 " <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
"\"/>"
120 " <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
"\"/>"
121 " <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
"\"/>"
122 " <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
"\"/>"
123 " <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
"\"/>"
124 " <delegate decode=\"htm\" command=\"" DELEGATE_ESC
"html2ps" DELEGATE_ESC
" -U -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
125 " <delegate decode=\"html\" command=\"" DELEGATE_ESC
"html2ps" DELEGATE_ESC
" -U -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
126 " <delegate decode=\"ilbm\" command=\"" DELEGATE_ESC
"ilbmtoppm" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" > " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
127 " <delegate decode=\"jpg\" encode=\"lep\" mode=\"encode\" command=\"" DELEGATE_ESC
"lepton" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
128 " <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
"\"/>"
129 " <delegate decode=\"lep\" mode=\"decode\" command=\"" DELEGATE_ESC
"lepton" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
" " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
130 " <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
"\"/>"
131 " <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
"\"/>"
132 " <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
"\"/>"
133 " <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
"\"/>"
134 " <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
"\"/>"
135 " <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
"\"/>"
136 " <delegate decode=\"png\" encode=\"clipboard\" command=\"" DELEGATE_ESC
"xclip" DELEGATE_ESC
" -selection clipboard -t image/png " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
137 " <delegate decode=\"clipboard\" command=\"" DELEGATE_ESC
"xclip" DELEGATE_ESC
" -selection clipboard -o > " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
138 " <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
"\"/>"
139 " <delegate decode=\"pnm\" encode=\"ilbm\" mode=\"encode\" command=\"" DELEGATE_ESC
"ppmtoilbm" DELEGATE_ESC
" -24if " DELEGATE_ESC
"%i" DELEGATE_ESC
" > " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
140 " <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
"\"/>"
141 " <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
"\"/>"
142 " <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
"\"/>"
143 " <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
"\"/>"
144 " <delegate decode=\"ps\" encode=\"prt\" command=\"" DELEGATE_ESC
"lpr" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
145 " <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
"\"/>"
146 " <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
"\"/>"
147 " <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
"\"/>"
148 " <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
"\"/>"
149 " <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
"\"/>"
150 " <delegate decode=\"ps\" encode=\"print\" mode=\"encode\" command=\"lpr " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
151 " <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
"\"/>"
152 " <delegate decode=\"shtml\" command=\"" DELEGATE_ESC
"html2ps" DELEGATE_ESC
" -U -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
153 " <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
"\"/>"
154 " <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
"\"/>"
155 #ifndef MAGICKCORE_RSVG_DELEGATE
156 " <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
"\"/>"
158 " <delegate decode=\"tiff\" encode=\"launch\" mode=\"encode\" command=\"" DELEGATE_ESC
"gimp" DELEGATE_ESC
" " DELEGATE_ESC
"%i" DELEGATE_ESC
"\"/>"
159 " <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
"\"/>"
160 " <delegate decode=\"webp\" command=\"" DELEGATE_ESC
"dwebp" DELEGATE_ESC
" -pam " DELEGATE_ESC
"%i" DELEGATE_ESC
" -o " DELEGATE_ESC
"%o" DELEGATE_ESC
"\"/>"
161 " <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
"\"/>"
162 " <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
"\"/>"
163 " <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
"\"/>"
164 " <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
"\"/>"
165 " <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
"\"/>"
166 " <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
"\"/>"
167 " <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
"\"/>"
183 static MagickBooleanType
185 LoadDelegateCache(
LinkedListInfo *,
const char *,
const char *,
const size_t,
220 cache=NewLinkedList(0);
221 #if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
229 options=GetConfigureOptions(filename,exception);
230 option=(
const StringInfo *) GetNextValueInLinkedList(options);
233 (void) LoadDelegateCache(cache,(
const char *)
234 GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
235 option=(
const StringInfo *) GetNextValueInLinkedList(options);
237 options=DestroyConfigureOptions(options);
240 magick_unreferenced(filename);
242 if (IsLinkedListEmpty(cache) != MagickFalse)
243 (void) LoadDelegateCache(cache,DelegateMap,
"built-in",0,exception);
265 MagickPrivate MagickBooleanType DelegateComponentGenesis(
void)
268 delegate_semaphore=AcquireSemaphoreInfo();
291 static void *DestroyDelegate(
void *delegate_info)
297 if (p->path != (
char *) NULL)
298 p->path=DestroyString(p->path);
299 if (p->decode != (
char *) NULL)
300 p->decode=DestroyString(p->decode);
301 if (p->encode != (
char *) NULL)
302 p->encode=DestroyString(p->encode);
303 if (p->commands != (
char *) NULL)
304 p->commands=DestroyString(p->commands);
306 RelinquishSemaphoreInfo(&p->semaphore);
308 return((
void *) NULL);
311 MagickPrivate
void DelegateComponentTerminus(
void)
314 ActivateSemaphoreInfo(&delegate_semaphore);
315 LockSemaphoreInfo(delegate_semaphore);
317 delegate_cache=DestroyLinkedList(delegate_cache,DestroyDelegate);
318 UnlockSemaphoreInfo(delegate_semaphore);
319 RelinquishSemaphoreInfo(&delegate_semaphore);
358 MagickExport
int ExternalDelegateCommand(
const MagickBooleanType asynchronous,
359 const MagickBooleanType verbose,
const char *command,
char *message,
380 arguments=StringToArgv(command,&number_arguments);
381 if (arguments == (
char **) NULL)
383 if (*arguments[1] ==
'\0')
385 for (i=0; i < (ssize_t) number_arguments; i++)
386 arguments[i]=DestroyString(arguments[i]);
387 arguments=(
char **) RelinquishMagickMemory(arguments);
390 rights=ExecutePolicyRights;
391 domain=DelegatePolicyDomain;
392 if (IsRightsAuthorized(domain,rights,arguments[1]) == MagickFalse)
395 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
396 "NotAuthorized",
"`%s'",arguments[1]);
397 for (i=0; i < (ssize_t) number_arguments; i++)
398 arguments[i]=DestroyString(arguments[i]);
399 arguments=(
char **) RelinquishMagickMemory(arguments);
402 if (verbose != MagickFalse)
404 (void) FormatLocaleFile(stderr,
"%s\n",command);
405 (void) fflush(stderr);
407 sanitize_command=SanitizeString(command);
408 if (asynchronous != MagickFalse)
409 (void) ConcatenateMagickString(sanitize_command,
"&",MagickPathExtent);
410 if (message != (
char *) NULL)
412 #if defined(MAGICKCORE_POSIX_SUPPORT)
413 #if defined(MAGICKCORE_HAVE_POPEN)
414 if ((asynchronous == MagickFalse) && (message != (
char *) NULL))
419 file=popen_utf8(sanitize_command,
"r");
420 if (file == (FILE *) NULL)
421 status=system(sanitize_command);
427 while ((offset < MagickPathExtent) &&
428 (fgets(message+offset,MagickPathExtent-offset,file) != NULL))
429 offset+=strlen(message);
436 #if !defined(MAGICKCORE_HAVE_EXECVP)
437 status=system(sanitize_command);
439 if ((asynchronous != MagickFalse) ||
440 (strpbrk(sanitize_command,
"&;<>|") != (
char *) NULL))
441 status=system(sanitize_command);
450 child_pid=(pid_t) fork();
451 if (child_pid == (pid_t) -1)
452 status=system(sanitize_command);
456 status=execvp(arguments[1],arguments+1);
468 pid=(pid_t) waitpid(child_pid,&child_status,0);
473 if (WIFEXITED(child_status) != 0)
474 status=WEXITSTATUS(child_status);
476 if (WIFSIGNALED(child_status))
483 #elif defined(MAGICKCORE_WINDOWS_SUPPORT)
496 p=strstr(sanitize_command,
"cmd.exe /c");
497 if (p != (
char*) NULL)
500 for ( ; *p !=
'\0'; p++)
502 *p=(*DirectorySeparator);
505 status=NTSystemCommand(sanitize_command,message);
507 status=system(sanitize_command);
509 # error No suitable system() method.
513 if ((message != (
char *) NULL) && (*message !=
'\0'))
514 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
515 "FailedToExecuteCommand",
"`%s' (%s)",sanitize_command,message);
517 (
void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
518 "FailedToExecuteCommand",
"`%s' (%d)",sanitize_command,status);
520 sanitize_command=DestroyString(sanitize_command);
521 for (i=0; i < (ssize_t) number_arguments; i++)
522 arguments[i]=DestroyString(arguments[i]);
523 arguments=(
char **) RelinquishMagickMemory(arguments);
565 static char *GetMagickPropertyLetter(
ImageInfo *image_info,
Image *image,
568 #define WarnNoImageReturn(format,letter) \
569 if (image == (Image *) NULL) \
571 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
572 "NoImageForProperty",format,letter); \
575 #define WarnNoImageInfoReturn(format,letter) \
576 if (image_info == (ImageInfo *) NULL) \
578 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
579 "NoImageInfoForProperty",format,letter); \
584 value[MagickPathExtent];
589 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
590 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
592 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
593 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
598 string=(
const char *) value;
603 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
604 string=GetImageOption(image_info,
"authenticate");
609 WarnNoImageReturn(
"\"%%%c\"",letter);
610 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
612 if (image->extent == 0)
613 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
614 MagickPathExtent,value);
619 WarnNoImageReturn(
"\"%%%c\"",letter);
620 GetPathComponent(image->magick_filename,HeadPath,value);
625 WarnNoImageReturn(
"\"%%%c\"",letter);
626 GetPathComponent(image->magick_filename,ExtensionPath,value);
631 WarnNoImageReturn(
"\"%%%c\"",letter);
632 GetPathComponent(image->magick_filename,TailPath,value);
637 WarnNoImageReturn(
"\"%%%c\"",letter);
638 (void) FormatLocaleString(value,MagickPathExtent,
639 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(double)
640 image->page.height,(
double) image->page.x,(double) image->page.y);
645 WarnNoImageReturn(
"\"%%%c\"",letter);
646 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
647 (image->rows != 0 ? image->rows : image->magick_rows));
652 WarnNoImageReturn(
"\"%%%c\"",letter);
653 string=image->filename;
658 WarnNoImageReturn(
"\"%%%c\"",letter);
659 string=image->magick;
664 if (image != (
Image *) NULL)
665 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
666 GetImageListLength(image));
671 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
672 string=image_info->filename;
677 WarnNoImageReturn(
"\"%%%c\"",letter);
678 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
679 GetImageIndexInList(image));
684 WarnNoImageReturn(
"\"%%%c\"",letter);
685 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
686 MAGICKCORE_QUANTUM_DEPTH);
694 WarnNoImageReturn(
"\"%%%c\"",letter);
695 colorspace=image->colorspace;
696 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
697 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
698 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
699 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
705 WarnNoImageReturn(
"\"%%%c\"",letter);
706 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
712 WarnNoImageReturn(
"\"%%%c\"",letter);
713 GetPathComponent(image->magick_filename,BasePath,value);
718 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
719 string=image_info->unique;
724 WarnNoImageReturn(
"\"%%%c\"",letter);
725 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
726 (image->columns != 0 ? image->columns : image->magick_columns));
731 WarnNoImageReturn(
"\"%%%c\"",letter);
732 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
733 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
734 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
740 WarnNoImageReturn(
"\"%%%c\"",letter);
741 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
742 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
743 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
749 WarnNoImageReturn(
"\"%%%c\"",letter);
750 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
751 (
double) image->depth);
756 WarnNoImageReturn(
"\"%%%c\"",letter);
757 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
763 WarnNoImageReturn(
"\"%%%c\"",letter);
764 string=CommandOptionToMnemonic(MagickCompressOptions,
765 (ssize_t) image->compression);
770 WarnNoImageReturn(
"\"%%%c\"",letter);
771 string=CommandOptionToMnemonic(MagickDisposeOptions,
772 (ssize_t) image->dispose);
780 WarnNoImageReturn(
"\"%%%c\"",letter);
781 (void) CopyMagickString(value,image->magick_filename,MagickPathExtent);
786 WarnNoImageReturn(
"\"%%%c\"",letter);
787 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
788 (
double) image->magick_columns,(double) image->magick_rows);
793 WarnNoImageReturn(
"\"%%%c\"",letter);
794 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
795 (
double) image->page.height);
800 WarnNoImageReturn(
"\"%%%c\"",letter);
801 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
807 WarnNoImageReturn(
"\"%%%c\"",letter);
808 string=image->magick_filename;
813 WarnNoImageReturn(
"\"%%%c\"",letter);
814 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
815 image->page.x,(long) image->page.y);
820 WarnNoImageReturn(
"\"%%%c\"",letter);
821 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
822 (
double) image->page.width,(double) image->page.height);
827 WarnNoImageReturn(
"\"%%%c\"",letter);
828 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
829 (100-(image->quality == 0 ? 42 : image->quality))/2);
834 WarnNoImageReturn(
"\"%%%c\"",letter);
835 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
836 (image->quality == 0 ? 92 : image->quality));
841 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
842 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
843 (image_info->number_scenes == 0 ? 2147483647 :
844 image_info->number_scenes));
849 WarnNoImageReturn(
"\"%%%c\"",letter);
850 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
856 WarnNoImageReturn(
"\"%%%c\"",letter);
857 string=CommandOptionToMnemonic(MagickResolutionOptions,
858 (ssize_t) image->units);
863 WarnNoImageReturn(
"\"%%%c\"",letter);
864 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
870 WarnNoImageReturn(
"\"%%%c\"",letter);
871 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
877 WarnNoImageReturn(
"\"%%%c\"",letter);
878 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
892 WarnNoImageReturn(
"\"%%%c\"",letter);
893 page=GetImageBoundingBox(image,exception);
894 (void) FormatLocaleString(value,MagickPathExtent,
895 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(double) page.height,
896 (
double) page.x,(double) page.y);
904 WarnNoImageReturn(
"\"%%%c\"",letter);
905 (void) SignatureImage(image,exception);
906 string=GetImageProperty(image,
"signature",exception);
910 return(SanitizeDelegateString(
string));
913 static char *InterpretDelegateProperties(
ImageInfo *image_info,
916 #define ExtendInterpretText(string_length) \
918 size_t length=(string_length); \
919 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
922 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
923 MagickPathExtent,sizeof(*interpret_text)); \
924 if (interpret_text == (char *) NULL) \
925 return((char *) NULL); \
926 q=interpret_text+strlen(interpret_text); \
930 #define AppendKeyValue2Text(key,value)\
932 size_t length=strlen(key)+strlen(value)+2; \
933 if ((size_t) (q-interpret_text+length+1) >= extent) \
936 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
937 MagickPathExtent,sizeof(*interpret_text)); \
938 if (interpret_text == (char *) NULL) \
939 return((char *) NULL); \
940 q=interpret_text+strlen(interpret_text); \
942 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
945 #define AppendString2Text(string) \
947 size_t length=strlen((string)); \
948 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
951 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
952 MagickPathExtent,sizeof(*interpret_text)); \
953 if (interpret_text == (char *) NULL) \
954 return((char *) NULL); \
955 q=interpret_text+strlen(interpret_text); \
957 (void) CopyMagickString(q,(string),extent); \
958 q+=(ptrdiff_t) length; \
977 assert(image == NULL || image->signature == MagickCoreSignature);
978 assert(image_info == NULL || image_info->signature == MagickCoreSignature);
979 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
980 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
982 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
983 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-image");
984 if (embed_text == (
const char *) NULL)
985 return(ConstantString(
""));
987 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
990 return(ConstantString(
""));
994 interpret_text=AcquireString(embed_text);
995 extent=MagickPathExtent;
997 for (q=interpret_text; *p!=
'\0';
998 number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
1004 ExtendInterpretText(MagickPathExtent);
1047 if (LocaleNCompare(
"<",p,4) == 0)
1053 if (LocaleNCompare(
">",p,4) == 0)
1059 if (LocaleNCompare(
"&",p,5) == 0)
1080 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
1090 if (number != MagickFalse)
1099 string=GetMagickPropertyLetter(image_info,image,*p,exception);
1100 if (
string != (
char *) NULL)
1102 AppendString2Text(
string);
1103 string=DestroyString(
string);
1106 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
1107 "UnknownImageProperty",
"\"%%%c\"",*p);
1110 return(interpret_text);
1113 MagickExport
char *GetDelegateCommand(
const ImageInfo *image_info,
Image *image,
1114 const char *decode,
const char *encode,
ExceptionInfo *exception)
1126 assert(image_info != (
ImageInfo *) NULL);
1127 assert(image_info->signature == MagickCoreSignature);
1128 assert(image != (
Image *) NULL);
1129 assert(image->signature == MagickCoreSignature);
1130 if (IsEventLogging() != MagickFalse)
1131 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1132 delegate_info=GetDelegateInfo(decode,encode,exception);
1135 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1136 "NoTagFound",
"`%s'",decode ? decode : encode);
1137 return((
char *) NULL);
1139 commands=StringToList(delegate_info->commands);
1140 if (commands == (
char **) NULL)
1142 (void) ThrowMagickException(exception,GetMagickModule(),
1143 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",decode ? decode :
1145 return((
char *) NULL);
1147 command=InterpretDelegateProperties((
ImageInfo *) image_info,image,
1148 commands[0],exception);
1149 if (command == (
char *) NULL)
1150 (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
1151 "MemoryAllocationFailed",
"`%s'",commands[0]);
1155 for (i=0; commands[i] != (
char *) NULL; i++)
1156 commands[i]=DestroyString(commands[i]);
1157 commands=(
char **) RelinquishMagickMemory(commands);
1183 MagickExport
const char *GetDelegateCommands(
const DelegateInfo *delegate_info)
1185 if (IsEventLogging() != MagickFalse)
1186 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1188 assert(delegate_info->signature == MagickCoreSignature);
1189 return(delegate_info->commands);
1221 MagickExport
const DelegateInfo *GetDelegateInfo(
const char *decode,
1231 if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1237 LockSemaphoreInfo(delegate_semaphore);
1238 p=GetHeadElementInLinkedList(delegate_cache);
1239 if ((LocaleCompare(decode,
"*") == 0) && (LocaleCompare(encode,
"*") == 0))
1241 UnlockSemaphoreInfo(delegate_semaphore);
1244 return(delegate_info);
1249 if (delegate_info->mode > 0)
1251 if (LocaleCompare(delegate_info->decode,decode) == 0)
1256 if (delegate_info->mode < 0)
1258 if (LocaleCompare(delegate_info->encode,encode) == 0)
1263 if (LocaleCompare(decode,delegate_info->decode) == 0)
1264 if (LocaleCompare(encode,delegate_info->encode) == 0)
1266 if (LocaleCompare(decode,
"*") == 0)
1267 if (LocaleCompare(encode,delegate_info->encode) == 0)
1269 if (LocaleCompare(decode,delegate_info->decode) == 0)
1270 if (LocaleCompare(encode,
"*") == 0)
1277 SetHeadElementInLinkedList(delegate_cache,p);
1278 UnlockSemaphoreInfo(delegate_semaphore);
1279 return(delegate_info);
1311 #if defined(__cplusplus) || defined(c_plusplus)
1315 static int DelegateInfoCompare(
const void *x,
const void *y)
1326 cmp=LocaleCompare((*p)->path,(*q)->path);
1329 if ((*p)->decode == (
char *) NULL)
1330 if (((*p)->encode != (
char *) NULL) &&
1331 ((*q)->encode != (
char *) NULL))
1332 return(strcmp((*p)->encode,(*q)->encode));
1333 if (((*p)->decode != (
char *) NULL) &&
1334 ((*q)->decode != (
char *) NULL))
1335 return(strcmp((*p)->decode,(*q)->decode));
1340 #if defined(__cplusplus) || defined(c_plusplus)
1344 MagickExport
const DelegateInfo **GetDelegateInfoList(
const char *pattern,
1356 assert(number_delegates != (
size_t *) NULL);
1357 assert(pattern != (
char *) NULL);
1358 if (IsEventLogging() != MagickFalse)
1359 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
1360 *number_delegates=0;
1361 if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1363 delegates=(
const DelegateInfo **) AcquireQuantumMemory((
size_t)
1364 GetNumberOfElementsInLinkedList(delegate_cache)+1UL,
sizeof(*delegates));
1367 LockSemaphoreInfo(delegate_semaphore);
1368 p=GetHeadElementInLinkedList(delegate_cache);
1375 if( (delegate_info->stealth == MagickFalse) &&
1376 (GlobExpression(delegate_info->decode,pattern,MagickFalse) != MagickFalse ||
1377 GlobExpression(delegate_info->encode,pattern,MagickFalse) != MagickFalse))
1378 delegates[i++]=delegate_info;
1381 UnlockSemaphoreInfo(delegate_semaphore);
1383 delegates=(
const DelegateInfo **) RelinquishMagickMemory((
void*) delegates);
1386 qsort((
void *) delegates,(
size_t) i,
sizeof(*delegates),DelegateInfoCompare);
1389 *number_delegates=(size_t) i;
1423 #if defined(__cplusplus) || defined(c_plusplus)
1427 static int DelegateCompare(
const void *x,
const void *y)
1433 p=(
const char **) x;
1434 q=(
const char **) y;
1435 return(LocaleCompare(*p,*q));
1438 #if defined(__cplusplus) || defined(c_plusplus)
1442 MagickExport
char **GetDelegateList(
const char *pattern,
1454 assert(pattern != (
char *) NULL);
1455 if (IsEventLogging() != MagickFalse)
1456 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
1457 assert(number_delegates != (
size_t *) NULL);
1458 *number_delegates=0;
1459 if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1460 return((
char **) NULL);
1461 delegates=(
char **) AcquireQuantumMemory((
size_t)
1462 GetNumberOfElementsInLinkedList(delegate_cache)+1UL,
sizeof(*delegates));
1463 if (delegates == (
char **) NULL)
1464 return((
char **) NULL);
1465 LockSemaphoreInfo(delegate_semaphore);
1466 p=GetHeadElementInLinkedList(delegate_cache);
1473 if ((delegate_info->stealth == MagickFalse) &&
1474 (GlobExpression(delegate_info->decode,pattern,MagickFalse) != MagickFalse))
1475 delegates[i++]=ConstantString(delegate_info->decode);
1476 if ((delegate_info->stealth == MagickFalse) &&
1477 (GlobExpression(delegate_info->encode,pattern,MagickFalse) != MagickFalse))
1478 delegates[i++]=ConstantString(delegate_info->encode);
1481 UnlockSemaphoreInfo(delegate_semaphore);
1483 delegates=(
char **) RelinquishMagickMemory(delegates);
1486 qsort((
void *) delegates,(
size_t) i,
sizeof(*delegates),DelegateCompare);
1487 delegates[i]=(
char *) NULL;
1489 *number_delegates=(size_t) i;
1515 MagickExport ssize_t GetDelegateMode(
const DelegateInfo *delegate_info)
1517 if (IsEventLogging() != MagickFalse)
1518 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1520 assert(delegate_info->signature == MagickCoreSignature);
1521 return(delegate_info->mode);
1548 MagickExport MagickBooleanType GetDelegateThreadSupport(
1552 assert(delegate_info->signature == MagickCoreSignature);
1553 if (IsEventLogging() != MagickFalse)
1554 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
1555 return(delegate_info->thread_support);
1581 static MagickBooleanType IsDelegateCacheInstantiated(
ExceptionInfo *exception)
1586 ActivateSemaphoreInfo(&delegate_semaphore);
1587 LockSemaphoreInfo(delegate_semaphore);
1589 delegate_cache=AcquireDelegateCache(DelegateFilename,exception);
1590 UnlockSemaphoreInfo(delegate_semaphore);
1592 return(delegate_cache != (
LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
1625 static MagickBooleanType CopyDelegateFile(
const char *source,
1626 const char *destination,
const MagickBooleanType overwrite)
1652 assert(source != (
const char *) NULL);
1653 assert(destination != (
char *) NULL);
1654 if (overwrite == MagickFalse)
1656 status=GetPathAttributes(destination,&attributes);
1657 if (status != MagickFalse)
1660 destination_file=open_utf8(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE);
1661 if (destination_file == -1)
1662 return(MagickFalse);
1663 source_file=open_utf8(source,O_RDONLY | O_BINARY,0);
1664 if (source_file == -1)
1666 (void) close(destination_file);
1667 return(MagickFalse);
1669 quantum=(size_t) MagickMaxBufferExtent;
1670 if ((fstat(source_file,&attributes) == 0) && (attributes.st_size > 0))
1671 quantum=MagickMin((
size_t) attributes.st_size,MagickMaxBufferExtent);
1672 buffer=(
unsigned char *) AcquireQuantumMemory(quantum,
sizeof(*buffer));
1673 if (buffer == (
unsigned char *) NULL)
1675 (void) close(source_file);
1676 (void) close(destination_file);
1677 return(MagickFalse);
1680 for (i=0; ; i+=(ssize_t) count)
1682 count=(ssize_t) read(source_file,buffer,quantum);
1685 length=(size_t) count;
1686 count=(ssize_t) write(destination_file,buffer,length);
1687 if ((
size_t) count != length)
1690 (void) close(destination_file);
1691 (void) close(source_file);
1692 buffer=(
unsigned char *) RelinquishMagickMemory(buffer);
1693 return(i != 0 ? MagickTrue : MagickFalse);
1696 MagickExport MagickBooleanType InvokeDelegate(
ImageInfo *image_info,
1702 input_filename[MagickPathExtent],
1703 output_filename[MagickPathExtent];
1721 assert(image_info != (
ImageInfo *) NULL);
1722 assert(image_info->signature == MagickCoreSignature);
1723 assert(image != (
Image *) NULL);
1724 assert(image->signature == MagickCoreSignature);
1725 if (IsEventLogging() != MagickFalse)
1726 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1727 rights=ExecutePolicyRights;
1728 if ((decode != (
const char *) NULL) &&
1729 (IsRightsAuthorized(DelegatePolicyDomain,rights,decode) == MagickFalse))
1732 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1733 "NotAuthorized",
"`%s'",decode);
1734 return(MagickFalse);
1736 if ((encode != (
const char *) NULL) &&
1737 (IsRightsAuthorized(DelegatePolicyDomain,rights,encode) == MagickFalse))
1740 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1741 "NotAuthorized",
"`%s'",encode);
1742 return(MagickFalse);
1744 temporary=*image->filename ==
'\0' ? MagickTrue : MagickFalse;
1745 if ((temporary != MagickFalse) && (AcquireUniqueFilename(image->filename) ==
1748 ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",
1750 return(MagickFalse);
1752 delegate_info=GetDelegateInfo(decode,encode,exception);
1755 if (temporary != MagickFalse)
1756 (void) RelinquishUniqueFileResource(image->filename);
1757 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1758 "NoTagFound",
"`%s'",decode ? decode : encode);
1759 return(MagickFalse);
1761 if (*image_info->filename ==
'\0')
1763 if (AcquireUniqueFilename(image_info->filename) == MagickFalse)
1765 if (temporary != MagickFalse)
1766 (void) RelinquishUniqueFileResource(image->filename);
1767 ThrowFileException(exception,FileOpenError,
1768 "UnableToCreateTemporaryFile",image_info->filename);
1769 return(MagickFalse);
1771 image_info->temporary=MagickTrue;
1773 if ((delegate_info->mode != 0) && (((decode != (
const char *) NULL) &&
1774 (delegate_info->encode != (
char *) NULL)) ||
1775 ((encode != (
const char *) NULL) &&
1776 (delegate_info->decode != (
char *) NULL))))
1790 if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1792 ThrowFileException(exception,FileOpenError,
1793 "UnableToCreateTemporaryFile",image_info->unique);
1794 return(MagickFalse);
1796 magick=InterpretImageProperties(image_info,image,decode != (
char *) NULL ?
1797 delegate_info->encode : delegate_info->decode,exception);
1798 if (magick == (
char *) NULL)
1800 (void) RelinquishUniqueFileResource(image_info->unique);
1801 if (temporary != MagickFalse)
1802 (void) RelinquishUniqueFileResource(image->filename);
1803 (void) ThrowMagickException(exception,GetMagickModule(),
1804 DelegateError,
"DelegateFailed",
"`%s'",decode ? decode : encode);
1805 return(MagickFalse);
1807 LocaleUpper(magick);
1808 clone_info=CloneImageInfo(image_info);
1809 (void) CopyMagickString((
char *) clone_info->magick,magick,
1811 if (LocaleCompare(magick,
"NULL") != 0)
1812 (
void) CopyMagickString(image->magick,magick,MagickPathExtent);
1813 magick=DestroyString(magick);
1814 (void) FormatLocaleString(clone_info->filename,MagickPathExtent,
"%s:",
1815 delegate_info->decode);
1816 (void) SetImageInfo(clone_info,(
unsigned int) GetImageListLength(image),
1818 (void) CopyMagickString(clone_info->filename,image_info->filename,
1820 (void) CopyMagickString(image_info->filename,image->filename,
1822 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1824 (void) FormatLocaleString(p->filename,MagickPathExtent,
"%s:%s",
1825 delegate_info->decode,clone_info->filename);
1826 status=WriteImage(clone_info,p,exception);
1827 if (status == MagickFalse)
1829 (void) RelinquishUniqueFileResource(image_info->unique);
1830 if (temporary != MagickFalse)
1831 (void) RelinquishUniqueFileResource(image->filename);
1832 clone_info=DestroyImageInfo(clone_info);
1833 (void) ThrowMagickException(exception,GetMagickModule(),
1834 DelegateError,
"DelegateFailed",
"`%s'",decode ? decode : encode);
1835 return(MagickFalse);
1837 if (clone_info->adjoin != MagickFalse)
1840 (void) RelinquishUniqueFileResource(image_info->unique);
1841 clone_info=DestroyImageInfo(clone_info);
1846 commands=StringToList(delegate_info->commands);
1847 if (commands == (
char **) NULL)
1849 if (temporary != MagickFalse)
1850 (void) RelinquishUniqueFileResource(image->filename);
1851 (void) ThrowMagickException(exception,GetMagickModule(),
1852 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
1853 decode ? decode : encode);
1854 return(MagickFalse);
1856 command=(
char *) NULL;
1858 (void) CopyMagickString(output_filename,image_info->filename,
1860 (void) CopyMagickString(input_filename,image->filename,MagickPathExtent);
1861 for (i=0; commands[i] != (
char *) NULL; i++)
1863 (void) AcquireUniqueSymbolicLink(output_filename,image_info->filename);
1864 if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1866 ThrowFileException(exception,FileOpenError,
1867 "UnableToCreateTemporaryFile",image_info->unique);
1870 if (LocaleCompare(decode,
"SCAN") != 0)
1872 status=AcquireUniqueSymbolicLink(input_filename,image->filename);
1873 if (status == MagickFalse)
1875 ThrowFileException(exception,FileOpenError,
1876 "UnableToCreateTemporaryFile",input_filename);
1881 command=InterpretDelegateProperties(image_info,image,commands[i],exception);
1882 if (command != (
char *) NULL)
1887 if (ExternalDelegateCommand(delegate_info->spawn,image_info->verbose,
1888 command,(
char *) NULL,exception) != 0)
1890 if (delegate_info->spawn != MagickFalse)
1899 while ((count-- > 0) && (access_utf8(image->filename,F_OK) == 0))
1900 (void) MagickDelay(100);
1902 command=DestroyString(command);
1904 if (LocaleCompare(decode,
"SCAN") != 0)
1906 if (CopyDelegateFile(image->filename,input_filename,MagickFalse) == MagickFalse)
1907 (void) RelinquishUniqueFileResource(input_filename);
1909 if ((strcmp(input_filename,output_filename) != 0) &&
1910 (CopyDelegateFile(image_info->filename,output_filename,MagickTrue) == MagickFalse))
1911 (void) RelinquishUniqueFileResource(output_filename);
1912 if (image_info->temporary != MagickFalse)
1913 (void) RelinquishUniqueFileResource(image_info->filename);
1914 (void) RelinquishUniqueFileResource(image_info->unique);
1915 (void) RelinquishUniqueFileResource(image_info->filename);
1916 (void) RelinquishUniqueFileResource(image->filename);
1917 if (status == MagickFalse)
1919 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1920 "DelegateFailed",
"`%s'",commands[i]);
1923 commands[i]=DestroyString(commands[i]);
1925 (void) CopyMagickString(image_info->filename,output_filename,
1927 (void) CopyMagickString(image->filename,input_filename,MagickPathExtent);
1931 for ( ; commands[i] != (
char *) NULL; i++)
1932 commands[i]=DestroyString(commands[i]);
1933 commands=(
char **) RelinquishMagickMemory(commands);
1934 if (temporary != MagickFalse)
1935 (void) RelinquishUniqueFileResource(image->filename);
1963 MagickExport MagickBooleanType ListDelegateInfo(FILE *file,
1971 delegate[MagickPathExtent];
1985 if (file == (
const FILE *) NULL)
1987 delegate_info=GetDelegateInfoList(
"*",&number_delegates,exception);
1989 return(MagickFalse);
1990 path=(
const char *) NULL;
1991 for (i=0; i < (ssize_t) number_delegates; i++)
1993 if (delegate_info[i]->stealth != MagickFalse)
1995 if ((path == (
const char *) NULL) ||
1996 (LocaleCompare(path,delegate_info[i]->path) != 0))
1998 if (delegate_info[i]->path != (
char *) NULL)
1999 (
void) FormatLocaleFile(file,
"\nPath: %s\n\n",delegate_info[i]->path);
2000 (void) FormatLocaleFile(file,
"Delegate Command\n");
2001 (void) FormatLocaleFile(file,
2002 "-------------------------------------------------"
2003 "------------------------------\n");
2005 path=delegate_info[i]->path;
2007 if (delegate_info[i]->encode != (
char *) NULL)
2008 (
void) CopyMagickString(delegate,delegate_info[i]->encode,
2010 (void) ConcatenateMagickString(delegate,
" ",MagickPathExtent);
2012 commands=StringToList(delegate_info[i]->commands);
2013 if (commands == (
char **) NULL)
2015 (void) FormatLocaleFile(file,
"%11s%c=%c%s ",delegate_info[i]->decode ?
2016 delegate_info[i]->decode :
"",delegate_info[i]->mode <= 0 ?
'<' :
' ',
2017 delegate_info[i]->mode >= 0 ?
'>' :
' ',delegate);
2018 (void) StripMagickString(commands[0]);
2019 (void) FormatLocaleFile(file,
"\"%s\"\n",commands[0]);
2020 for (j=1; commands[j] != (
char *) NULL; j++)
2022 (void) StripMagickString(commands[j]);
2023 (void) FormatLocaleFile(file,
" \"%s\"\n",commands[j]);
2025 for (j=0; commands[j] != (
char *) NULL; j++)
2026 commands[j]=DestroyString(commands[j]);
2027 commands=(
char **) RelinquishMagickMemory(commands);
2029 (void) fflush(file);
2031 RelinquishMagickMemory((
void *) delegate_info);
2066 static MagickBooleanType LoadDelegateCache(
LinkedListInfo *cache,
2067 const char *xml,
const char *filename,
const size_t depth,
2071 keyword[MagickPathExtent],
2089 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
2090 "Loading delegate configuration file \"%s\" ...",filename);
2091 if (xml == (
const char *) NULL)
2092 return(MagickFalse);
2095 token=AcquireString(xml);
2096 extent=strlen(token)+MagickPathExtent;
2097 for (q=(
const char *) xml; *q !=
'\0'; )
2102 (void) GetNextToken(q,&q,extent,token);
2105 (void) CopyMagickString(keyword,token,MagickPathExtent);
2106 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
2111 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
2112 (
void) GetNextToken(q,&q,extent,token);
2115 if (LocaleNCompare(keyword,
"<!--",4) == 0)
2120 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
2121 (void) GetNextToken(q,&q,extent,token);
2124 if (LocaleCompare(keyword,
"<include") == 0)
2129 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
2131 (void) CopyMagickString(keyword,token,MagickPathExtent);
2132 (void) GetNextToken(q,&q,extent,token);
2135 (void) GetNextToken(q,&q,extent,token);
2136 if (LocaleCompare(keyword,
"file") == 0)
2138 if (depth > MagickMaxRecursionDepth)
2139 (void) ThrowMagickException(exception,GetMagickModule(),
2140 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
2144 path[MagickPathExtent],
2147 GetPathComponent(filename,HeadPath,path);
2149 (void) ConcatenateMagickString(path,DirectorySeparator,
2151 if (*token == *DirectorySeparator)
2152 (void) CopyMagickString(path,token,MagickPathExtent);
2154 (
void) ConcatenateMagickString(path,token,MagickPathExtent);
2155 file_xml=FileToXML(path,~0UL);
2156 if (file_xml != (
char *) NULL)
2158 status&=(MagickStatusType) LoadDelegateCache(cache,
2159 file_xml,path,depth+1,exception);
2160 file_xml=DestroyString(file_xml);
2167 if (LocaleCompare(keyword,
"<delegate") == 0)
2173 sizeof(*delegate_info));
2174 (void) memset(delegate_info,0,
sizeof(*delegate_info));
2175 delegate_info->path=ConstantString(filename);
2176 delegate_info->thread_support=MagickTrue;
2177 delegate_info->signature=MagickCoreSignature;
2182 if ((LocaleCompare(keyword,
"/>") == 0) ||
2183 (LocaleCompare(keyword,
"</policy>") == 0))
2185 status=AppendValueToLinkedList(cache,delegate_info);
2186 if (status == MagickFalse)
2187 (void) ThrowMagickException(exception,GetMagickModule(),
2188 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
2189 delegate_info->commands);
2193 (void) GetNextToken(q,(
const char **) NULL,extent,token);
2196 (void) GetNextToken(q,&q,extent,token);
2197 (void) GetNextToken(q,&q,extent,token);
2203 if (LocaleCompare((
char *) keyword,
"command") == 0)
2208 commands=AcquireString(token);
2209 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
2210 if (strchr(commands,
'@') != (
char *) NULL)
2213 path[MagickPathExtent];
2215 NTGhostscriptEXE(path,MagickPathExtent);
2216 (void) SubstituteString((
char **) &commands,
"@PSDelegate@",
2218 (void) SubstituteString((
char **) &commands,
"\\",
"/");
2221 (void) SubstituteString((
char **) &commands,
""",
"\"");
2222 (void) SubstituteString((
char **) &commands,
"'",
"'");
2223 (void) SubstituteString((
char **) &commands,
"&",
"&");
2224 (void) SubstituteString((
char **) &commands,
">",
">");
2225 (void) SubstituteString((
char **) &commands,
"<",
"<");
2226 if (delegate_info->commands != (
char *) NULL)
2227 delegate_info->commands=DestroyString(delegate_info->commands);
2228 delegate_info->commands=commands;
2236 if (LocaleCompare((
char *) keyword,
"decode") == 0)
2238 delegate_info->decode=ConstantString(token);
2239 delegate_info->mode=1;
2247 if (LocaleCompare((
char *) keyword,
"encode") == 0)
2249 delegate_info->encode=ConstantString(token);
2250 delegate_info->mode=(-1);
2258 if (LocaleCompare((
char *) keyword,
"mode") == 0)
2260 delegate_info->mode=1;
2261 if (LocaleCompare(token,
"bi") == 0)
2262 delegate_info->mode=0;
2264 if (LocaleCompare(token,
"encode") == 0)
2265 delegate_info->mode=(-1);
2273 if (LocaleCompare((
char *) keyword,
"spawn") == 0)
2275 delegate_info->spawn=IsStringTrue(token);
2278 if (LocaleCompare((
char *) keyword,
"stealth") == 0)
2280 delegate_info->stealth=IsStringTrue(token);
2288 if (LocaleCompare((
char *) keyword,
"thread-support") == 0)
2290 delegate_info->thread_support=IsStringTrue(token);
2291 if (delegate_info->thread_support == MagickFalse)
2292 delegate_info->semaphore=AcquireSemaphoreInfo();
2301 token=(
char *) RelinquishMagickMemory(token);
2302 return(status != 0 ? MagickTrue : MagickFalse);