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"
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=\"http\" command=\"" DELEGATE_ESC
"curl" DELEGATE_ESC
" -s -L -o " DELEGATE_ESC
"%o" DELEGATE_ESC
" " DELEGATE_ESC
"http:%M" DELEGATE_ESC
"\"/>"
112 " <delegate decode=\"https\" command=\"" DELEGATE_ESC
"curl" DELEGATE_ESC
" -s -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,(
int) (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)
1653 assert(source != (
const char *) NULL);
1654 assert(destination != (
char *) NULL);
1655 if (overwrite == MagickFalse)
1657 status=GetPathAttributes(destination,&attributes);
1658 if (status != MagickFalse)
1661 destination_file=open_utf8(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE);
1662 if (destination_file == -1)
1663 return(MagickFalse);
1664 source_file=open_utf8(source,O_RDONLY | O_BINARY,0);
1665 if (source_file == -1)
1667 (void) close(destination_file);
1668 return(MagickFalse);
1670 quantum=(size_t) MagickMaxBufferExtent;
1671 if ((fstat(source_file,&attributes) == 0) && (attributes.st_size > 0))
1672 quantum=MagickMin((
size_t) attributes.st_size,MagickMaxBufferExtent);
1673 buffer=(
unsigned char *) AcquireQuantumMemory(quantum,
sizeof(*buffer));
1674 if (buffer == (
unsigned char *) NULL)
1676 (void) close(source_file);
1677 (void) close(destination_file);
1678 return(MagickFalse);
1681 for (i=0; ; i+=(ssize_t) count)
1683 count=(ssize_t) read(source_file,buffer,quantum);
1686 length=(size_t) count;
1687 count=(ssize_t) write(destination_file,buffer,length);
1688 if ((
size_t) count != length)
1691 (void) close(destination_file);
1692 (void) close(source_file);
1693 buffer=(
unsigned char *) RelinquishMagickMemory(buffer);
1694 return(i != 0 ? MagickTrue : MagickFalse);
1697MagickExport MagickBooleanType InvokeDelegate(
ImageInfo *image_info,
1703 input_filename[MagickPathExtent],
1704 output_filename[MagickPathExtent];
1722 assert(image_info != (
ImageInfo *) NULL);
1723 assert(image_info->signature == MagickCoreSignature);
1724 assert(image != (
Image *) NULL);
1725 assert(image->signature == MagickCoreSignature);
1726 if (IsEventLogging() != MagickFalse)
1727 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
1728 rights=ExecutePolicyRights;
1729 if ((decode != (
const char *) NULL) &&
1730 (IsRightsAuthorized(DelegatePolicyDomain,rights,decode) == MagickFalse))
1733 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1734 "NotAuthorized",
"`%s'",decode);
1735 return(MagickFalse);
1737 if ((encode != (
const char *) NULL) &&
1738 (IsRightsAuthorized(DelegatePolicyDomain,rights,encode) == MagickFalse))
1741 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
1742 "NotAuthorized",
"`%s'",encode);
1743 return(MagickFalse);
1745 temporary=*image->filename ==
'\0' ? MagickTrue : MagickFalse;
1746 if ((temporary != MagickFalse) && (AcquireUniqueFilename(image->filename) ==
1749 ThrowFileException(exception,FileOpenError,
"UnableToCreateTemporaryFile",
1751 return(MagickFalse);
1753 delegate_info=GetDelegateInfo(decode,encode,exception);
1756 if (temporary != MagickFalse)
1757 (void) RelinquishUniqueFileResource(image->filename);
1758 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1759 "NoTagFound",
"`%s'",decode ? decode : encode);
1760 return(MagickFalse);
1762 if (*image_info->filename ==
'\0')
1764 if (AcquireUniqueFilename(image_info->filename) == MagickFalse)
1766 if (temporary != MagickFalse)
1767 (void) RelinquishUniqueFileResource(image->filename);
1768 ThrowFileException(exception,FileOpenError,
1769 "UnableToCreateTemporaryFile",image_info->filename);
1770 return(MagickFalse);
1772 image_info->temporary=MagickTrue;
1774 if ((delegate_info->mode != 0) && (((decode != (
const char *) NULL) &&
1775 (delegate_info->encode != (
char *) NULL)) ||
1776 ((encode != (
const char *) NULL) &&
1777 (delegate_info->decode != (
char *) NULL))))
1791 if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1793 ThrowFileException(exception,FileOpenError,
1794 "UnableToCreateTemporaryFile",image_info->unique);
1795 return(MagickFalse);
1797 magick=InterpretImageProperties(image_info,image,decode != (
char *) NULL ?
1798 delegate_info->encode : delegate_info->decode,exception);
1799 if (magick == (
char *) NULL)
1801 (void) RelinquishUniqueFileResource(image_info->unique);
1802 if (temporary != MagickFalse)
1803 (void) RelinquishUniqueFileResource(image->filename);
1804 (void) ThrowMagickException(exception,GetMagickModule(),
1805 DelegateError,
"DelegateFailed",
"`%s'",decode ? decode : encode);
1806 return(MagickFalse);
1808 LocaleUpper(magick);
1809 clone_info=CloneImageInfo(image_info);
1810 (void) CopyMagickString((
char *) clone_info->magick,magick,
1812 if (LocaleCompare(magick,
"NULL") != 0)
1813 (void) CopyMagickString(image->magick,magick,MagickPathExtent);
1814 magick=DestroyString(magick);
1815 (void) FormatLocaleString(clone_info->filename,MagickPathExtent,
"%s:",
1816 delegate_info->decode);
1817 (void) SetImageInfo(clone_info,(
unsigned int) GetImageListLength(image),
1819 (void) CopyMagickString(clone_info->filename,image_info->filename,
1821 (void) CopyMagickString(image_info->filename,image->filename,
1823 for (p=image; p != (
Image *) NULL; p=GetNextImageInList(p))
1825 (void) FormatLocaleString(p->filename,MagickPathExtent,
"%s:%s",
1826 delegate_info->decode,clone_info->filename);
1827 status=WriteImage(clone_info,p,exception);
1828 if (status == MagickFalse)
1830 (void) RelinquishUniqueFileResource(image_info->unique);
1831 if (temporary != MagickFalse)
1832 (void) RelinquishUniqueFileResource(image->filename);
1833 clone_info=DestroyImageInfo(clone_info);
1834 (void) ThrowMagickException(exception,GetMagickModule(),
1835 DelegateError,
"DelegateFailed",
"`%s'",decode ? decode : encode);
1836 return(MagickFalse);
1838 if (clone_info->adjoin != MagickFalse)
1841 (void) RelinquishUniqueFileResource(image_info->unique);
1842 clone_info=DestroyImageInfo(clone_info);
1847 commands=StringToList(delegate_info->commands);
1848 if (commands == (
char **) NULL)
1850 if (temporary != MagickFalse)
1851 (void) RelinquishUniqueFileResource(image->filename);
1852 (void) ThrowMagickException(exception,GetMagickModule(),
1853 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
1854 decode ? decode : encode);
1855 return(MagickFalse);
1857 command=(
char *) NULL;
1859 (void) CopyMagickString(output_filename,image_info->filename,
1861 (void) CopyMagickString(input_filename,image->filename,MagickPathExtent);
1862 for (i=0; commands[i] != (
char *) NULL; i++)
1864 (void) AcquireUniqueSymbolicLink(output_filename,image_info->filename);
1865 if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1867 ThrowFileException(exception,FileOpenError,
1868 "UnableToCreateTemporaryFile",image_info->unique);
1871 if (LocaleCompare(decode,
"SCAN") != 0)
1873 status=AcquireUniqueSymbolicLink(input_filename,image->filename);
1874 if (status == MagickFalse)
1876 ThrowFileException(exception,FileOpenError,
1877 "UnableToCreateTemporaryFile",input_filename);
1882 command=InterpretDelegateProperties(image_info,image,commands[i],exception);
1883 if (command != (
char *) NULL)
1888 if (ExternalDelegateCommand(delegate_info->spawn,image_info->verbose,
1889 command,(
char *) NULL,exception) != 0)
1891 if (delegate_info->spawn != MagickFalse)
1900 while ((count-- > 0) && (access_utf8(image->filename,F_OK) == 0))
1901 (void) MagickDelay(100);
1903 command=DestroyString(command);
1905 if (LocaleCompare(decode,
"SCAN") != 0)
1907 if (CopyDelegateFile(image->filename,input_filename,MagickFalse) == MagickFalse)
1908 (void) RelinquishUniqueFileResource(input_filename);
1910 if ((strcmp(input_filename,output_filename) != 0) &&
1911 (CopyDelegateFile(image_info->filename,output_filename,MagickTrue) == MagickFalse))
1912 (void) RelinquishUniqueFileResource(output_filename);
1913 if (image_info->temporary != MagickFalse)
1914 (void) RelinquishUniqueFileResource(image_info->filename);
1915 (void) RelinquishUniqueFileResource(image_info->unique);
1916 (void) RelinquishUniqueFileResource(image_info->filename);
1917 (void) RelinquishUniqueFileResource(image->filename);
1918 if (status == MagickFalse)
1920 (void) ThrowMagickException(exception,GetMagickModule(),DelegateError,
1921 "DelegateFailed",
"`%s'",commands[i]);
1924 commands[i]=DestroyString(commands[i]);
1926 (void) CopyMagickString(image_info->filename,output_filename,
1928 (void) CopyMagickString(image->filename,input_filename,MagickPathExtent);
1932 for ( ; commands[i] != (
char *) NULL; i++)
1933 commands[i]=DestroyString(commands[i]);
1934 commands=(
char **) RelinquishMagickMemory(commands);
1935 if (temporary != MagickFalse)
1936 (void) RelinquishUniqueFileResource(image->filename);
1964MagickExport MagickBooleanType ListDelegateInfo(FILE *file,
1972 delegate[MagickPathExtent];
1986 if (file == (
const FILE *) NULL)
1988 delegate_info=GetDelegateInfoList(
"*",&number_delegates,exception);
1990 return(MagickFalse);
1991 path=(
const char *) NULL;
1992 for (i=0; i < (ssize_t) number_delegates; i++)
1994 if (delegate_info[i]->stealth != MagickFalse)
1996 if ((path == (
const char *) NULL) ||
1997 (LocaleCompare(path,delegate_info[i]->path) != 0))
1999 if (delegate_info[i]->path != (
char *) NULL)
2000 (void) FormatLocaleFile(file,
"\nPath: %s\n\n",delegate_info[i]->path);
2001 (void) FormatLocaleFile(file,
"Delegate Command\n");
2002 (void) FormatLocaleFile(file,
2003 "-------------------------------------------------"
2004 "------------------------------\n");
2006 path=delegate_info[i]->path;
2008 if (delegate_info[i]->encode != (
char *) NULL)
2009 (void) CopyMagickString(delegate,delegate_info[i]->encode,
2011 (void) ConcatenateMagickString(delegate,
" ",MagickPathExtent);
2013 commands=StringToList(delegate_info[i]->commands);
2014 if (commands == (
char **) NULL)
2016 (void) FormatLocaleFile(file,
"%11s%c=%c%s ",delegate_info[i]->decode ?
2017 delegate_info[i]->decode :
"",delegate_info[i]->mode <= 0 ?
'<' :
' ',
2018 delegate_info[i]->mode >= 0 ?
'>' :
' ',delegate);
2019 (void) StripMagickString(commands[0]);
2020 (void) FormatLocaleFile(file,
"\"%s\"\n",commands[0]);
2021 for (j=1; commands[j] != (
char *) NULL; j++)
2023 (void) StripMagickString(commands[j]);
2024 (void) FormatLocaleFile(file,
" \"%s\"\n",commands[j]);
2026 for (j=0; commands[j] != (
char *) NULL; j++)
2027 commands[j]=DestroyString(commands[j]);
2028 commands=(
char **) RelinquishMagickMemory(commands);
2030 (void) fflush(file);
2032 RelinquishMagickMemory((
void *) delegate_info);
2068 const char *xml,
const char *filename,
const size_t depth,
2072 keyword[MagickPathExtent],
2090 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
2091 "Loading delegate configuration file \"%s\" ...",filename);
2092 if (xml == (
const char *) NULL)
2093 return(MagickFalse);
2096 token=AcquireString(xml);
2097 extent=strlen(token)+MagickPathExtent;
2098 for (q=(
const char *) xml; *q !=
'\0'; )
2103 (void) GetNextToken(q,&q,extent,token);
2106 (void) CopyMagickString(keyword,token,MagickPathExtent);
2107 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
2112 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
2113 (void) GetNextToken(q,&q,extent,token);
2116 if (LocaleNCompare(keyword,
"<!--",4) == 0)
2121 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
2122 (void) GetNextToken(q,&q,extent,token);
2125 if (LocaleCompare(keyword,
"<include") == 0)
2130 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
2132 (void) CopyMagickString(keyword,token,MagickPathExtent);
2133 (void) GetNextToken(q,&q,extent,token);
2136 (void) GetNextToken(q,&q,extent,token);
2137 if (LocaleCompare(keyword,
"file") == 0)
2139 if (depth > MagickMaxRecursionDepth)
2140 (void) ThrowMagickException(exception,GetMagickModule(),
2141 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
2145 path[MagickPathExtent],
2148 GetPathComponent(filename,HeadPath,path);
2150 (void) ConcatenateMagickString(path,DirectorySeparator,
2152 if (*token == *DirectorySeparator)
2153 (void) CopyMagickString(path,token,MagickPathExtent);
2155 (
void) ConcatenateMagickString(path,token,MagickPathExtent);
2156 file_xml=FileToXML(path,~0UL);
2157 if (file_xml != (
char *) NULL)
2159 status&=(MagickStatusType) LoadDelegateCache(cache,
2160 file_xml,path,depth+1,exception);
2161 file_xml=DestroyString(file_xml);
2168 if (LocaleCompare(keyword,
"<delegate") == 0)
2174 sizeof(*delegate_info));
2175 (void) memset(delegate_info,0,
sizeof(*delegate_info));
2176 delegate_info->path=ConstantString(filename);
2177 delegate_info->thread_support=MagickTrue;
2178 delegate_info->signature=MagickCoreSignature;
2183 if ((LocaleCompare(keyword,
"/>") == 0) ||
2184 (LocaleCompare(keyword,
"</policy>") == 0))
2186 status=AppendValueToLinkedList(cache,delegate_info);
2187 if (status == MagickFalse)
2188 (void) ThrowMagickException(exception,GetMagickModule(),
2189 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
2190 delegate_info->commands);
2194 (void) GetNextToken(q,(
const char **) NULL,extent,token);
2197 (void) GetNextToken(q,&q,extent,token);
2198 (void) GetNextToken(q,&q,extent,token);
2204 if (LocaleCompare((
char *) keyword,
"command") == 0)
2209 commands=AcquireString(token);
2210#if defined(MAGICKCORE_WINDOWS_SUPPORT)
2211 if (strchr(commands,
'@') != (
char *) NULL)
2214 path[MagickPathExtent];
2216 NTGhostscriptEXE(path,MagickPathExtent);
2217 (void) SubstituteString((
char **) &commands,
"@PSDelegate@",
2219 (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 (void) SubstituteString((
char **) &commands,
"<",
"<");
2227 if (delegate_info->commands != (
char *) NULL)
2228 delegate_info->commands=DestroyString(delegate_info->commands);
2229 delegate_info->commands=commands;
2237 if (LocaleCompare((
char *) keyword,
"decode") == 0)
2239 delegate_info->decode=ConstantString(token);
2240 delegate_info->mode=1;
2248 if (LocaleCompare((
char *) keyword,
"encode") == 0)
2250 delegate_info->encode=ConstantString(token);
2251 delegate_info->mode=(-1);
2259 if (LocaleCompare((
char *) keyword,
"mode") == 0)
2261 delegate_info->mode=1;
2262 if (LocaleCompare(token,
"bi") == 0)
2263 delegate_info->mode=0;
2265 if (LocaleCompare(token,
"encode") == 0)
2266 delegate_info->mode=(-1);
2274 if (LocaleCompare((
char *) keyword,
"spawn") == 0)
2276 delegate_info->spawn=IsStringTrue(token);
2279 if (LocaleCompare((
char *) keyword,
"stealth") == 0)
2281 delegate_info->stealth=IsStringTrue(token);
2289 if (LocaleCompare((
char *) keyword,
"thread-support") == 0)
2291 delegate_info->thread_support=IsStringTrue(token);
2292 if (delegate_info->thread_support == MagickFalse)
2293 delegate_info->semaphore=AcquireSemaphoreInfo();
2302 token=(
char *) RelinquishMagickMemory(token);
2303 return(status != 0 ? MagickTrue : MagickFalse);