MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
delegate.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % DDDD EEEEE L EEEEE GGGG AAA TTTTT EEEEE %
6 % D D E L E G A A T E %
7 % D D EEE L EEE G GG AAAAA T EEE %
8 % D D E L E G G A A T E %
9 % DDDD EEEEE LLLLL EEEEE GGG A A T EEEEE %
10 % %
11 % %
12 % MagickCore Methods to Read/Write/Invoke Delegates %
13 % %
14 % Software Design %
15 % Cristy %
16 % October 1998 %
17 % %
18 % %
19 % Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
20 % dedicated to making software imaging solutions freely available. %
21 % %
22 % You may not use this file except in compliance with the License. You may %
23 % obtain a copy of the License at %
24 % %
25 % https://www.imagemagick.org/script/license.php %
26 % %
27 % Unless required by applicable law or agreed to in writing, software %
28 % distributed under the License is distributed on an "AS IS" BASIS, %
29 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
30 % See the License for the specific language governing permissions and %
31 % limitations under the License. %
32 % %
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %
35 % The Delegates methods associate a set of commands with a particular
36 % image format. ImageMagick uses delegates for formats it does not handle
37 % directly.
38 %
39 % Thanks to Bob Friesenhahn for the initial inspiration and design of the
40 % delegates methods.
41 %
42 %
43 */
44 
45 /*
46  Include declarations.
47 */
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"
57 #include "MagickCore/exception.h"
59 #include "MagickCore/fx-private.h"
61 #include "MagickCore/linked-list.h"
62 #include "MagickCore/list.h"
63 #include "MagickCore/memory_.h"
66 #include "MagickCore/option.h"
67 #include "MagickCore/policy.h"
68 #include "MagickCore/property.h"
69 #include "MagickCore/resource_.h"
70 #include "MagickCore/semaphore.h"
71 #include "MagickCore/signature.h"
72 #include "MagickCore/string_.h"
73 #include "MagickCore/token.h"
75 #include "MagickCore/utility.h"
77 #include "MagickCore/xml-tree.h"
79 
80 /*
81  Define declarations.
82 */
83 #define DelegateFilename "delegates.xml"
84 
85 /*
86  Declare delegate map.
87 */
88 static const char
89  *DelegateMap = (const char *)
90  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
91  "<delegatemap>"
92  " <delegate decode=\"autotrace\" stealth=\"True\" command=\"&quot;autotrace&quot; -output-format svg -output-file &quot;%o&quot; &quot;%i&quot;\"/>"
93  " <delegate decode=\"avi:decode\" stealth=\"True\" command=\"&quot;mplayer&quot; &quot;%i&quot; -really-quiet -ao null -vo png:z=3\"/>"
94  " <delegate decode=\"browse\" stealth=\"True\" spawn=\"True\" command=\"&quot;xdg-open&quot; http://www.imagemagick.org/; rm &quot;%i&quot;\"/>"
95  " <delegate decode=\"cgm\" thread-support=\"False\" command=\"&quot;ralcgm&quot; -d ps -oC &lt; &quot;%i&quot; &gt; &quot;%o&quot; 2&gt; &quot;%u&quot;\"/>"
96  " <delegate decode=\"dng:decode\" command=\"&quot;ufraw-batch&quot; --silent --create-id=also --out-type=png --out-depth=16 &quot;--output=%u.png&quot; &quot;%i&quot;\"/>"
97  " <delegate decode=\"edit\" stealth=\"True\" command=\"&quot;xterm&quot; -title &quot;Edit Image Comment&quot; -e vi &quot;%o&quot;\"/>"
98  " <delegate decode=\"eps\" encode=\"pdf\" mode=\"bi\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pdfwrite&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;\"/>"
99  " <delegate decode=\"eps\" encode=\"ps\" mode=\"bi\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=ps2write&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;\"/>"
100  " <delegate decode=\"fig\" command=\"&quot;fig2dev&quot; -L ps &quot;%i&quot; &quot;%o&quot;\"/>"
101  " <delegate decode=\"hpg\" command=\"&quot;hp2xx&quot; -q -m eps -f `basename &quot;%o&quot;` &quot;%i&quot; mv -f `basename &quot;%o&quot;` &quot;%o&quot;\"/>"
102  " <delegate decode=\"hpgl\" command=\"&quot;hp2xx&quot; -q -m eps -f `basename &quot;%o&quot;` &quot;%i&quot; mv -f `basename &quot;%o&quot;` &quot;%o&quot;\"/>"
103  " <delegate decode=\"htm\" command=\"&quot;html2ps&quot; -U -o &quot;%o&quot; &quot;%i&quot;\"/>"
104  " <delegate decode=\"html\" command=\"&quot;html2ps&quot; -U -o &quot;%o&quot; &quot;%i&quot;\"/>"
105  " <delegate decode=\"https\" command=\"&quot;curl&quot; -s -k -L -o &quot;%o&quot; &quot;https:%M&quot;\"/>"
106  " <delegate decode=\"ilbm\" command=\"&quot;ilbmtoppm&quot; &quot;%i&quot; &gt; &quot;%o&quot;\"/>"
107  " <delegate decode=\"man\" command=\"&quot;groff&quot; -man -Tps &quot;%i&quot; &gt; &quot;%o&quot;\"/>"
108  " <delegate decode=\"mpeg:decode\" stealth=\"True\" command=\"&quot;ffmpeg&quot; -nostdin -v -1 -vframes %S -i &quot;%i&quot; -vcodec pam -an -f rawvideo -y &quot;%u.pam&quot; 2&gt; &quot;%Z&quot;\"/>"
109  " <delegate decode=\"null\" encode=\"mpeg:encode\" stealth=\"True\" command=\"&quot;ffmpeg&quot; -nostdin -v -1 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 300 -i &quot;%M%%d.jpg&quot; &quot;%u.%m&quot; 2&gt; &quot;%Z&quot;\"/>"
110  " <delegate decode=\"pcl:color\" stealth=\"True\" command=\"&quot;pcl6&quot; -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=ppmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;%s&quot;\"/>"
111  " <delegate decode=\"pcl:cmyk\" stealth=\"True\" command=\"&quot;pcl6&quot; -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=bmpsep8&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;%s&quot;\"/>"
112  " <delegate decode=\"pcl:mono\" stealth=\"True\" command=\"&quot;pcl6&quot; -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pbmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;%s&quot;\"/>"
113  " <delegate decode=\"pdf\" encode=\"eps\" mode=\"bi\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=eps2write&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;\"/>"
114  " <delegate decode=\"pdf\" encode=\"ps\" mode=\"bi\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=ps2write&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;\"/>"
115  " <delegate decode=\"pnm\" encode=\"ilbm\" mode=\"encode\" command=\"&quot;ppmtoilbm&quot; -24if &quot;%i&quot; &gt; &quot;%o&quot;\"/>"
116  " <delegate decode=\"pnm\" encode=\"launch\" mode=\"encode\" command=\"&quot;gimp&quot; &quot;%i&quot;\"/>"
117  " <delegate decode=\"pov\" command=\"&quot;povray&quot; &quot;+i&quot;%i&quot;&quot; -D0 +o&quot;%o&quot; +fn%q +w%w +h%h +a -q9 -kfi&quot;%s&quot; -kff&quot;%n&quot; &quot;convert&quot; -concatenate &quot;%o*.png&quot; &quot;%o&quot;\"/>"
118  " <delegate decode=\"ps\" encode=\"eps\" mode=\"bi\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=eps2write&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;\"/>"
119  " <delegate decode=\"ps\" encode=\"pdf\" mode=\"bi\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pdfwrite&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;\"/>"
120  " <delegate decode=\"ps\" encode=\"print\" mode=\"encode\" command=\"lpr &quot;%i&quot;\"/>"
121  " <delegate decode=\"ps:alpha\" stealth=\"True\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pngalpha&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;\"/>"
122  " <delegate decode=\"ps:bbox\" stealth=\"True\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=bbox&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;\"/>"
123  " <delegate decode=\"ps:cmyk\" stealth=\"True\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=bmpsep8&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;\"/>"
124  " <delegate decode=\"ps:color\" stealth=\"True\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pnmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;\"/>"
125  " <delegate decode=\"ps:mono\" stealth=\"True\" command=\"&quot;gs&quot; -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=pnmraw&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;-f%s&quot; &quot;-f%s&quot;\"/>"
126  " <delegate decode=\"rgba\" encode=\"rle\" mode=\"encode\" command=\"&quot;rawtorle&quot; -o &quot;%o&quot; -v &quot;%i&quot;\"/>"
127  " <delegate decode=\"scan\" command=\"&quot;scanimage&quot; -d &quot;%i&quot; &gt; &quot;%o&quot;\"/>"
128  " <delegate encode=\"show\" spawn=\"True\" command=\"&quot;display&quot; -immutable -delay 0 -title &quot;%M&quot; &quot;%i&quot;\"/>"
129  " <delegate decode=\"shtml\" command=\"&quot;html2ps&quot; -U -o &quot;%o&quot; &quot;%i&quot;\"/>"
130  " <delegate decode=\"svg\" command=\"&quot;rsvg&quot; &quot;%i&quot; &quot;%o&quot;\"/>"
131  " <delegate decode=\"txt\" encode=\"ps\" mode=\"bi\" command=\"&quot;enscript&quot; -o &quot;%o&quot; &quot;%i&quot;\"/>"
132  " <delegate encode=\"win\" stealth=\"True\" spawn=\"True\" command=\"&quot;display&quot; -immutable -delay 0 -title &quot;%M&quot; &quot;%i&quot;\"/>"
133  " <delegate decode=\"wmf\" command=\"&quot;wmf2eps&quot; -o &quot;%o&quot; &quot;%i&quot;\"/>"
134  "</delegatemap>";
135 
136 /*
137  Global declaractions.
138 */
139 static LinkedListInfo
141 
142 static SemaphoreInfo
144 
145 /*
146  Forward declaractions.
147 */
148 static MagickBooleanType
150  LoadDelegateCache(LinkedListInfo *,const char *,const char *,const size_t,
151  ExceptionInfo *);
152 
153 /*
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 % %
156 % %
157 % %
158 % A c q u i r e D e l e g a t e C a c h e %
159 % %
160 % %
161 % %
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 %
164 % AcquireDelegateCache() caches one or more delegate configurations which
165 % provides a mapping between delegate attributes and a delegate name.
166 %
167 % The format of the AcquireDelegateCache method is:
168 %
169 % LinkedListInfo *AcquireDelegateCache(const char *filename,
170 % ExceptionInfo *exception)
171 %
172 % A description of each parameter follows:
173 %
174 % o filename: the font file name.
175 %
176 % o exception: return any errors or warnings in this structure.
177 %
178 */
179 static LinkedListInfo *AcquireDelegateCache(const char *filename,
180  ExceptionInfo *exception)
181 {
183  *cache;
184 
186  status;
187 
188  cache=NewLinkedList(0);
189  status=MagickTrue;
190 #if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
191  {
192  const StringInfo
193  *option;
194 
196  *options;
197 
198  options=GetConfigureOptions(filename,exception);
199  option=(const StringInfo *) GetNextValueInLinkedList(options);
200  while (option != (const StringInfo *) NULL)
201  {
202  status&=LoadDelegateCache(cache,(const char *)
203  GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
204  option=(const StringInfo *) GetNextValueInLinkedList(options);
205  }
206  options=DestroyConfigureOptions(options);
207  }
208 #endif
209  if (IsLinkedListEmpty(cache) != MagickFalse)
210  status&=LoadDelegateCache(cache,DelegateMap,"built-in",0,exception);
211  return(cache);
212 }
213 
214 /*
215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216 % %
217 % %
218 % %
219 + D e l e g a t e C o m p o n e n t G e n e s i s %
220 % %
221 % %
222 % %
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 %
225 % DelegateComponentGenesis() instantiates the delegate component.
226 %
227 % The format of the DelegateComponentGenesis method is:
228 %
229 % MagickBooleanType DelegateComponentGenesis(void)
230 %
231 */
233 {
234  if (delegate_semaphore == (SemaphoreInfo *) NULL)
236  return(MagickTrue);
237 }
238 
239 /*
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 % %
242 % %
243 % %
244 % D e l e g a t e C o m p o n e n t T e r m i n u s %
245 % %
246 % %
247 % %
248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249 %
250 % DelegateComponentTerminus() destroys the delegate component.
251 %
252 % The format of the DelegateComponentTerminus method is:
253 %
254 % DelegateComponentTerminus(void)
255 %
256 */
257 
258 static void *DestroyDelegate(void *delegate_info)
259 {
260  register DelegateInfo
261  *p;
262 
263  p=(DelegateInfo *) delegate_info;
264  if (p->path != (char *) NULL)
265  p->path=DestroyString(p->path);
266  if (p->decode != (char *) NULL)
267  p->decode=DestroyString(p->decode);
268  if (p->encode != (char *) NULL)
269  p->encode=DestroyString(p->encode);
270  if (p->commands != (char *) NULL)
272  if (p->semaphore != (SemaphoreInfo *) NULL)
275  return((void *) NULL);
276 }
277 
279 {
280  if (delegate_semaphore == (SemaphoreInfo *) NULL)
283  if (delegate_cache != (LinkedListInfo *) NULL)
287 }
288 
289 /*
290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291 % %
292 % %
293 % %
294 + E x t e r n a l D e l e g a t e C o m m a n d %
295 % %
296 % %
297 % %
298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299 %
300 % ExternalDelegateCommand() executes the specified command and waits until it
301 % terminates. The returned value is the exit status of the command.
302 %
303 % The format of the ExternalDelegateCommand method is:
304 %
305 % int ExternalDelegateCommand(const MagickBooleanType asynchronous,
306 % const MagickBooleanType verbose,const char *command,
307 % char *message,ExceptionInfo *exception)
308 %
309 % A description of each parameter follows:
310 %
311 % o asynchronous: a value other than 0 executes the parent program
312 % concurrently with the new child process.
313 %
314 % o verbose: a value other than 0 prints the executed command before it is
315 % invoked.
316 %
317 % o command: this string is the command to execute.
318 %
319 % o message: an option buffer to receive any message posted to stdout or
320 % stderr.
321 %
322 % o exception: return any errors here.
323 %
324 */
326  const MagickBooleanType verbose,const char *command,char *message,
327  ExceptionInfo *exception)
328 {
329  char
330  **arguments,
331  *sanitize_command;
332 
333  int
334  number_arguments,
335  status;
336 
338  domain;
339 
341  rights;
342 
343  register ssize_t
344  i;
345 
346  status=(-1);
347  arguments=StringToArgv(command,&number_arguments);
348  if (arguments == (char **) NULL)
349  return(status);
350  if (*arguments[1] == '\0')
351  {
352  for (i=0; i < (ssize_t) number_arguments; i++)
353  arguments[i]=DestroyString(arguments[i]);
354  arguments=(char **) RelinquishMagickMemory(arguments);
355  return(-1);
356  }
357  rights=ExecutePolicyRights;
358  domain=DelegatePolicyDomain;
359  if (IsRightsAuthorized(domain,rights,arguments[1]) == MagickFalse)
360  {
361  errno=EPERM;
363  "NotAuthorized","`%s'",arguments[1]);
364  for (i=0; i < (ssize_t) number_arguments; i++)
365  arguments[i]=DestroyString(arguments[i]);
366  arguments=(char **) RelinquishMagickMemory(arguments);
367  return(-1);
368  }
369  if (verbose != MagickFalse)
370  {
371  (void) FormatLocaleFile(stderr,"%s\n",command);
372  (void) fflush(stderr);
373  }
374  sanitize_command=SanitizeString(command);
375  if (asynchronous != MagickFalse)
376  (void) ConcatenateMagickString(sanitize_command,"&",MagickPathExtent);
377  if (message != (char *) NULL)
378  *message='\0';
379 #if defined(MAGICKCORE_POSIX_SUPPORT)
380 #if !defined(MAGICKCORE_HAVE_EXECVP)
381  status=system(sanitize_command);
382 #else
383  if ((asynchronous != MagickFalse) ||
384  (strpbrk(sanitize_command,"&;<>|") != (char *) NULL))
385  status=system(sanitize_command);
386  else
387  {
388  pid_t
389  child_pid;
390 
391  /*
392  Call application directly rather than from a shell.
393  */
394  child_pid=(pid_t) fork();
395  if (child_pid == (pid_t) -1)
396  status=system(sanitize_command);
397  else
398  if (child_pid == 0)
399  {
400  status=execvp(arguments[1],arguments+1);
401  _exit(1);
402  }
403  else
404  {
405  int
406  child_status;
407 
408  pid_t
409  pid;
410 
411  child_status=0;
412  pid=(pid_t) waitpid(child_pid,&child_status,0);
413  if (pid == -1)
414  status=(-1);
415  else
416  {
417  if (WIFEXITED(child_status) != 0)
418  status=WEXITSTATUS(child_status);
419  else
420  if (WIFSIGNALED(child_status))
421  status=(-1);
422  }
423  }
424  }
425 #endif
426 #elif defined(MAGICKCORE_WINDOWS_SUPPORT)
427  {
428  register char
429  *p;
430 
431  /*
432  If a command shell is executed we need to change the forward slashes in
433  files to a backslash. We need to do this to keep Windows happy when we
434  want to 'move' a file.
435 
436  TODO: This won't work if one of the delegate parameters has a forward
437  slash as aparameter.
438  */
439  p=strstr(sanitize_command, "cmd.exe /c");
440  if (p != (char*) NULL)
441  {
442  p+=10;
443  for (; *p != '\0'; p++)
444  if (*p == '/')
445  *p=*DirectorySeparator;
446  }
447  }
448  status=NTSystemCommand(sanitize_command,message);
449 #elif defined(macintosh)
450  status=MACSystemCommand(sanitize_command);
451 #elif defined(vms)
452  status=system(sanitize_command);
453 #else
454 # error No suitable system() method.
455 #endif
456  if (status < 0)
457  {
458  if ((message != (char *) NULL) && (*message != '\0'))
460  "FailedToExecuteCommand","`%s' (%s)",sanitize_command,message);
461  else
463  "FailedToExecuteCommand","`%s' (%d)",sanitize_command,status);
464  }
465  sanitize_command=DestroyString(sanitize_command);
466  for (i=0; i < (ssize_t) number_arguments; i++)
467  arguments[i]=DestroyString(arguments[i]);
468  arguments=(char **) RelinquishMagickMemory(arguments);
469  return(status);
470 }
471 
472 /*
473 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474 % %
475 % %
476 % %
477 % G e t D e l e g a t e C o m m a n d %
478 % %
479 % %
480 % %
481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
482 %
483 % GetDelegateCommand() replaces any embedded formatting characters with the
484 % appropriate image attribute and returns the resulting command.
485 %
486 % The format of the GetDelegateCommand method is:
487 %
488 % char *GetDelegateCommand(const ImageInfo *image_info,Image *image,
489 % const char *decode,const char *encode,ExceptionInfo *exception)
490 %
491 % A description of each parameter follows:
492 %
493 % o command: Method GetDelegateCommand returns the command associated
494 % with specified delegate tag.
495 %
496 % o image_info: the image info.
497 %
498 % o image: the image.
499 %
500 % o decode: Specifies the decode delegate we are searching for as a
501 % character string.
502 %
503 % o encode: Specifies the encode delegate we are searching for as a
504 % character string.
505 %
506 % o exception: return any errors or warnings in this structure.
507 %
508 */
509 
510 static char *GetMagickPropertyLetter(ImageInfo *image_info,Image *image,
511  const char letter,ExceptionInfo *exception)
512 {
513 #define WarnNoImageReturn(format,letter) \
514  if (image == (Image *) NULL) \
515  { \
516  (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
517  "NoImageForProperty",format,letter); \
518  break; \
519  }
520 #define WarnNoImageInfoReturn(format,letter) \
521  if (image_info == (ImageInfo *) NULL) \
522  { \
523  (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
524  "NoImageInfoForProperty",format,letter); \
525  break; \
526  }
527 
528  char
529  value[MagickPathExtent];
530 
531  const char
532  *string;
533 
534  if ((image != (Image *) NULL) && (image->debug != MagickFalse))
535  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
536  else
537  if ((image_info != (ImageInfo *) NULL) &&
538  (image_info->debug != MagickFalse))
539  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
540  /*
541  Get properties that are directly defined by images.
542  */
543  *value='\0'; /* formatted string */
544  string=(const char *) value;
545  switch (letter)
546  {
547  case 'a': /* authentication passphase */
548  {
549  WarnNoImageInfoReturn("\"%%%c\"",letter);
550  string=GetImageOption(image_info,"authenticate");
551  break;
552  }
553  case 'b': /* image size read in - in bytes */
554  {
555  WarnNoImageReturn("\"%%%c\"",letter);
557  value);
558  if (image->extent == 0)
559  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
560  MagickPathExtent,value);
561  break;
562  }
563  case 'd': /* Directory component of filename */
564  {
565  WarnNoImageReturn("\"%%%c\"",letter);
567  break;
568  }
569  case 'e': /* Filename extension (suffix) of image file */
570  {
571  WarnNoImageReturn("\"%%%c\"",letter);
573  break;
574  }
575  case 'f': /* Filename without directory component */
576  {
577  WarnNoImageReturn("\"%%%c\"",letter);
579  break;
580  }
581  case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */
582  {
583  WarnNoImageReturn("\"%%%c\"",letter);
585  "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,(double)
586  image->page.height,(double) image->page.x,(double) image->page.y);
587  break;
588  }
589  case 'h': /* Image height (current) */
590  {
591  WarnNoImageReturn("\"%%%c\"",letter);
592  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
593  (image->rows != 0 ? image->rows : image->magick_rows));
594  break;
595  }
596  case 'i': /* Filename last used for an image (read or write) */
597  {
598  WarnNoImageReturn("\"%%%c\"",letter);
599  string=image->filename;
600  break;
601  }
602  case 'm': /* Image format (file magick) */
603  {
604  WarnNoImageReturn("\"%%%c\"",letter);
605  string=image->magick;
606  break;
607  }
608  case 'n': /* Number of images in the list. */
609  {
610  if (image != (Image *) NULL)
611  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
612  GetImageListLength(image));
613  break;
614  }
615  case 'o': /* Output Filename */
616  {
617  WarnNoImageInfoReturn("\"%%%c\"",letter);
618  string=image_info->filename;
619  break;
620  }
621  case 'p': /* Image index in current image list */
622  {
623  WarnNoImageReturn("\"%%%c\"",letter);
624  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
625  GetImageIndexInList(image));
626  break;
627  }
628  case 'q': /* Quantum depth of image in memory */
629  {
630  WarnNoImageReturn("\"%%%c\"",letter);
631  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
633  break;
634  }
635  case 'r': /* Image storage class, colorspace, and alpha enabled. */
636  {
638  colorspace;
639 
640  WarnNoImageReturn("\"%%%c\"",letter);
641  colorspace=image->colorspace;
642  if (SetImageGray(image,exception) != MagickFalse)
643  colorspace=GRAYColorspace; /* FUTURE: this is IMv6 not IMv7 */
644  (void) FormatLocaleString(value,MagickPathExtent,"%s %s %s",
647  (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
648  "Alpha" : "");
649  break;
650  }
651  case 's': /* Image scene number */
652  {
653  WarnNoImageReturn("\"%%%c\"",letter);
654  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
655  image->scene);
656  break;
657  }
658  case 't': /* Base filename without directory or extention */
659  {
660  WarnNoImageReturn("\"%%%c\"",letter);
662  break;
663  }
664  case 'u': /* Unique filename */
665  {
666  WarnNoImageInfoReturn("\"%%%c\"",letter);
667  string=image_info->unique;
668  break;
669  }
670  case 'w': /* Image width (current) */
671  {
672  WarnNoImageReturn("\"%%%c\"",letter);
673  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
674  (image->columns != 0 ? image->columns : image->magick_columns));
675  break;
676  }
677  case 'x': /* Image horizontal resolution (with units) */
678  {
679  WarnNoImageReturn("\"%%%c\"",letter);
680  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
681  fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x : 72.0);
682  break;
683  }
684  case 'y': /* Image vertical resolution (with units) */
685  {
686  WarnNoImageReturn("\"%%%c\"",letter);
687  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
688  fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y : 72.0);
689  break;
690  }
691  case 'z': /* Image depth as read in */
692  {
693  WarnNoImageReturn("\"%%%c\"",letter);
694  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
695  (double) image->depth);
696  break;
697  }
698  case 'A': /* Image alpha channel */
699  {
700  WarnNoImageReturn("\"%%%c\"",letter);
702  image->alpha_trait);
703  break;
704  }
705  case 'C': /* Image compression method. */
706  {
707  WarnNoImageReturn("\"%%%c\"",letter);
709  (ssize_t) image->compression);
710  break;
711  }
712  case 'D': /* Image dispose method. */
713  {
714  WarnNoImageReturn("\"%%%c\"",letter);
716  (ssize_t) image->dispose);
717  break;
718  }
719  case 'F':
720  {
721  /*
722  Magick filename - filename given incl. coder & read mods.
723  */
724  WarnNoImageReturn("\"%%%c\"",letter);
726  break;
727  }
728  case 'G': /* Image size as geometry = "%wx%h" */
729  {
730  WarnNoImageReturn("\"%%%c\"",letter);
731  (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",
732  (double) image->magick_columns,(double) image->magick_rows);
733  break;
734  }
735  case 'H': /* layer canvas height */
736  {
737  WarnNoImageReturn("\"%%%c\"",letter);
738  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
739  (double) image->page.height);
740  break;
741  }
742  case 'M': /* Magick filename - filename given incl. coder & read mods */
743  {
744  WarnNoImageReturn("\"%%%c\"",letter);
745  string=image->magick_filename;
746  break;
747  }
748  case 'O': /* layer canvas offset with sign = "+%X+%Y" */
749  {
750  WarnNoImageReturn("\"%%%c\"",letter);
751  (void) FormatLocaleString(value,MagickPathExtent,"%+ld%+ld",(long)
752  image->page.x,(long) image->page.y);
753  break;
754  }
755  case 'P': /* layer canvas page size = "%Wx%H" */
756  {
757  WarnNoImageReturn("\"%%%c\"",letter);
758  (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",
759  (double) image->page.width,(double) image->page.height);
760  break;
761  }
762  case 'Q': /* image compression quality */
763  {
764  WarnNoImageReturn("\"%%%c\"",letter);
765  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
766  (image->quality == 0 ? 92 : image->quality));
767  break;
768  }
769  case 'S': /* Number of scenes in image list. */
770  {
771  WarnNoImageInfoReturn("\"%%%c\"",letter);
772  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
773  (image_info->number_scenes == 0 ? 2147483647 :
774  image_info->number_scenes));
775  break;
776  }
777  case 'T': /* image time delay for animations */
778  {
779  WarnNoImageReturn("\"%%%c\"",letter);
780  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
781  image->delay);
782  break;
783  }
784  case 'U': /* Image resolution units. */
785  {
786  WarnNoImageReturn("\"%%%c\"",letter);
788  (ssize_t) image->units);
789  break;
790  }
791  case 'W': /* layer canvas width */
792  {
793  WarnNoImageReturn("\"%%%c\"",letter);
794  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
795  image->page.width);
796  break;
797  }
798  case 'X': /* layer canvas X offset */
799  {
800  WarnNoImageReturn("\"%%%c\"",letter);
801  (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
802  image->page.x);
803  break;
804  }
805  case 'Y': /* layer canvas Y offset */
806  {
807  WarnNoImageReturn("\"%%%c\"",letter);
808  (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
809  image->page.y);
810  break;
811  }
812  case '%': /* percent escaped */
813  {
814  string="%";
815  break;
816  }
817  case '@': /* Trim bounding box, without actually trimming! */
818  {
820  page;
821 
822  WarnNoImageReturn("\"%%%c\"",letter);
823  page=GetImageBoundingBox(image,exception);
825  "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double) page.height,
826  (double) page.x,(double) page.y);
827  break;
828  }
829  case '#':
830  {
831  /*
832  Image signature.
833  */
834  WarnNoImageReturn("\"%%%c\"",letter);
835  (void) SignatureImage(image,exception);
836  string=GetImageProperty(image,"signature",exception);
837  break;
838  }
839  }
840  return(SanitizeString(string));
841 }
842 
843 static char *InterpretDelegateProperties(ImageInfo *image_info,
844  Image *image,const char *embed_text,ExceptionInfo *exception)
845 {
846 #define ExtendInterpretText(string_length) \
847 DisableMSCWarning(4127) \
848 { \
849  size_t length=(string_length); \
850  if ((size_t) (q-interpret_text+length+1) >= extent) \
851  { \
852  extent+=length; \
853  interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
854  MaxTextExtent,sizeof(*interpret_text)); \
855  if (interpret_text == (char *) NULL) \
856  return((char *) NULL); \
857  q=interpret_text+strlen(interpret_text); \
858  } \
859 } \
860 RestoreMSCWarning
861 
862 #define AppendKeyValue2Text(key,value)\
863 DisableMSCWarning(4127) \
864 { \
865  size_t length=strlen(key)+strlen(value)+2; \
866  if ((size_t) (q-interpret_text+length+1) >= extent) \
867  { \
868  extent+=length; \
869  interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
870  MaxTextExtent,sizeof(*interpret_text)); \
871  if (interpret_text == (char *) NULL) \
872  return((char *) NULL); \
873  q=interpret_text+strlen(interpret_text); \
874  } \
875  q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
876 } \
877 RestoreMSCWarning
878 
879 #define AppendString2Text(string) \
880 DisableMSCWarning(4127) \
881 { \
882  size_t length=strlen((string)); \
883  if ((size_t) (q-interpret_text+length+1) >= extent) \
884  { \
885  extent+=length; \
886  interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
887  MaxTextExtent,sizeof(*interpret_text)); \
888  if (interpret_text == (char *) NULL) \
889  return((char *) NULL); \
890  q=interpret_text+strlen(interpret_text); \
891  } \
892  (void) CopyMagickString(q,(string),extent); \
893  q+=length; \
894 } \
895 RestoreMSCWarning
896 
897  char
898  *interpret_text,
899  *string;
900 
901  register char
902  *q; /* current position in interpret_text */
903 
904  register const char
905  *p; /* position in embed_text string being expanded */
906 
907  size_t
908  extent; /* allocated length of interpret_text */
909 
911  number;
912 
913  assert(image == NULL || image->signature == MagickCoreSignature);
914  assert(image_info == NULL || image_info->signature == MagickCoreSignature);
915  if ((image != (Image *) NULL) && (image->debug != MagickFalse))
916  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
917  else
918  if ((image_info != (ImageInfo *) NULL) && (image_info->debug != MagickFalse))
919  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image");
920  if (embed_text == (const char *) NULL)
921  return(ConstantString(""));
922  p=embed_text;
923  while ((isspace((int) ((unsigned char) *p)) != 0) && (*p != '\0'))
924  p++;
925  if (*p == '\0')
926  return(ConstantString(""));
927  /*
928  Translate any embedded format characters.
929  */
930  interpret_text=AcquireString(embed_text); /* new string with extra space */
931  extent=MagickPathExtent; /* allocated space in string */
932  number=MagickFalse; /* is last char a number? */
933  for (q=interpret_text; *p!='\0';
934  number=isdigit(*p) ? MagickTrue : MagickFalse,p++)
935  {
936  /*
937  Interpret escape characters (e.g. Filename: %M).
938  */
939  *q='\0';
941  switch (*p)
942  {
943  case '\\':
944  {
945  switch (*(p+1))
946  {
947  case '\0':
948  continue;
949  case 'r': /* convert to RETURN */
950  {
951  *q++='\r';
952  p++;
953  continue;
954  }
955  case 'n': /* convert to NEWLINE */
956  {
957  *q++='\n';
958  p++;
959  continue;
960  }
961  case '\n': /* EOL removal UNIX,MacOSX */
962  {
963  p++;
964  continue;
965  }
966  case '\r': /* EOL removal DOS,Windows */
967  {
968  p++;
969  if (*p == '\n') /* return-newline EOL */
970  p++;
971  continue;
972  }
973  default:
974  {
975  p++;
976  *q++=(*p);
977  }
978  }
979  continue;
980  }
981  case '&':
982  {
983  if (LocaleNCompare("&lt;",p,4) == 0)
984  {
985  *q++='<';
986  p+=3;
987  }
988  else
989  if (LocaleNCompare("&gt;",p,4) == 0)
990  {
991  *q++='>';
992  p+=3;
993  }
994  else
995  if (LocaleNCompare("&amp;",p,5) == 0)
996  {
997  *q++='&';
998  p+=4;
999  }
1000  else
1001  *q++=(*p);
1002  continue;
1003  }
1004  case '%':
1005  break; /* continue to next set of handlers */
1006  default:
1007  {
1008  *q++=(*p); /* any thing else is 'as normal' */
1009  continue;
1010  }
1011  }
1012  p++; /* advance beyond the percent */
1013  /*
1014  Doubled Percent - or percent at end of string.
1015  */
1016  if ((*p == '\0') || (*p == '\'') || (*p == '"'))
1017  p--;
1018  if (*p == '%')
1019  {
1020  *q++='%';
1021  continue;
1022  }
1023  /*
1024  Single letter escapes %c.
1025  */
1026  if (number != MagickFalse)
1027  {
1028  /*
1029  But only if not preceeded by a number!
1030  */
1031  *q++='%'; /* do NOT substitute the percent */
1032  p--; /* back up one */
1033  continue;
1034  }
1035  string=GetMagickPropertyLetter(image_info,image,*p, exception);
1036  if (string != (char *) NULL)
1037  {
1038  AppendString2Text(string);
1039  string=DestroyString(string);
1040  continue;
1041  }
1043  "UnknownImageProperty","\"%%%c\"",*p);
1044  }
1045  *q='\0';
1046  return(interpret_text);
1047 }
1048 
1049 MagickExport char *GetDelegateCommand(const ImageInfo *image_info,Image *image,
1050  const char *decode,const char *encode,ExceptionInfo *exception)
1051 {
1052  char
1053  *command,
1054  **commands;
1055 
1056  const DelegateInfo
1057  *delegate_info;
1058 
1059  register ssize_t
1060  i;
1061 
1062  assert(image_info != (ImageInfo *) NULL);
1063  assert(image_info->signature == MagickCoreSignature);
1064  assert(image != (Image *) NULL);
1065  assert(image->signature == MagickCoreSignature);
1066  if (image->debug != MagickFalse)
1067  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1068 
1069  delegate_info=GetDelegateInfo(decode,encode,exception);
1070  if (delegate_info == (const DelegateInfo *) NULL)
1071  {
1073  "NoTagFound","`%s'",decode ? decode : encode);
1074  return((char *) NULL);
1075  }
1076  commands=StringToList(delegate_info->commands);
1077  if (commands == (char **) NULL)
1078  {
1079  (void) ThrowMagickException(exception,GetMagickModule(),
1080  ResourceLimitError,"MemoryAllocationFailed","`%s'",decode ? decode :
1081  encode);
1082  return((char *) NULL);
1083  }
1084  command=InterpretDelegateProperties((ImageInfo *) image_info,image,
1085  commands[0],exception);
1086  if (command == (char *) NULL)
1088  "MemoryAllocationFailed","`%s'",commands[0]);
1089  /*
1090  Relinquish resources.
1091  */
1092  for (i=0; commands[i] != (char *) NULL; i++)
1093  commands[i]=DestroyString(commands[i]);
1094  commands=(char **) RelinquishMagickMemory(commands);
1095  return(command);
1096 }
1097 
1098 /*
1099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1100 % %
1101 % %
1102 % %
1103 % G e t D e l e g a t e C o m m a n d s %
1104 % %
1105 % %
1106 % %
1107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1108 %
1109 % GetDelegateCommands() returns the commands associated with a delegate.
1110 %
1111 % The format of the GetDelegateCommands method is:
1112 %
1113 % const char *GetDelegateCommands(const DelegateInfo *delegate_info)
1114 %
1115 % A description of each parameter follows:
1116 %
1117 % o delegate_info: The delegate info.
1118 %
1119 */
1120 MagickExport const char *GetDelegateCommands(const DelegateInfo *delegate_info)
1121 {
1122  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1123 
1124  assert(delegate_info != (DelegateInfo *) NULL);
1125  assert(delegate_info->signature == MagickCoreSignature);
1126  return(delegate_info->commands);
1127 }
1128 
1129 /*
1130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1131 % %
1132 % %
1133 % %
1134 % G e t D e l e g a t e I n f o %
1135 % %
1136 % %
1137 % %
1138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1139 %
1140 % GetDelegateInfo() returns any delegates associated with the specified tag.
1141 %
1142 % The format of the GetDelegateInfo method is:
1143 %
1144 % const DelegateInfo *GetDelegateInfo(const char *decode,
1145 % const char *encode,ExceptionInfo *exception)
1146 %
1147 % A description of each parameter follows:
1148 %
1149 % o decode: Specifies the decode delegate we are searching for as a
1150 % character string.
1151 %
1152 % o encode: Specifies the encode delegate we are searching for as a
1153 % character string.
1154 %
1155 % o exception: return any errors or warnings in this structure.
1156 %
1157 */
1158 MagickExport const DelegateInfo *GetDelegateInfo(const char *decode,
1159  const char *encode,ExceptionInfo *exception)
1160 {
1161  register const DelegateInfo
1162  *p;
1163 
1164  assert(exception != (ExceptionInfo *) NULL);
1165  if (IsDelegateCacheInstantiated(exception) == MagickFalse)
1166  return((const DelegateInfo *) NULL);
1167  /*
1168  Search for named delegate.
1169  */
1173  if ((LocaleCompare(decode,"*") == 0) && (LocaleCompare(encode,"*") == 0))
1174  {
1176  return(p);
1177  }
1178  while (p != (const DelegateInfo *) NULL)
1179  {
1180  if (p->mode > 0)
1181  {
1182  if (LocaleCompare(p->decode,decode) == 0)
1183  break;
1185  continue;
1186  }
1187  if (p->mode < 0)
1188  {
1189  if (LocaleCompare(p->encode,encode) == 0)
1190  break;
1192  continue;
1193  }
1194  if (LocaleCompare(decode,p->decode) == 0)
1195  if (LocaleCompare(encode,p->encode) == 0)
1196  break;
1197  if (LocaleCompare(decode,"*") == 0)
1198  if (LocaleCompare(encode,p->encode) == 0)
1199  break;
1200  if (LocaleCompare(decode,p->decode) == 0)
1201  if (LocaleCompare(encode,"*") == 0)
1202  break;
1204  }
1205  if (p != (const DelegateInfo *) NULL)
1209  return(p);
1210 }
1211 
1212 /*
1213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 % %
1215 % %
1216 % %
1217 % G e t D e l e g a t e I n f o L i s t %
1218 % %
1219 % %
1220 % %
1221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1222 %
1223 % GetDelegateInfoList() returns any delegates that match the specified pattern.
1224 %
1225 % The delegate of the GetDelegateInfoList function is:
1226 %
1227 % const DelegateInfo **GetDelegateInfoList(const char *pattern,
1228 % size_t *number_delegates,ExceptionInfo *exception)
1229 %
1230 % A description of each parameter follows:
1231 %
1232 % o pattern: Specifies a pointer to a text string containing a pattern.
1233 %
1234 % o number_delegates: This integer returns the number of delegates in the
1235 % list.
1236 %
1237 % o exception: return any errors or warnings in this structure.
1238 %
1239 */
1240 
1241 #if defined(__cplusplus) || defined(c_plusplus)
1242 extern "C" {
1243 #endif
1244 
1245 static int DelegateInfoCompare(const void *x,const void *y)
1246 {
1247  const DelegateInfo
1248  **p,
1249  **q;
1250 
1251  int
1252  cmp;
1253 
1254  p=(const DelegateInfo **) x,
1255  q=(const DelegateInfo **) y;
1256  cmp=LocaleCompare((*p)->path,(*q)->path);
1257  if (cmp == 0)
1258  {
1259  if ((*p)->decode == (char *) NULL)
1260  if (((*p)->encode != (char *) NULL) &&
1261  ((*q)->encode != (char *) NULL))
1262  return(strcmp((*p)->encode,(*q)->encode));
1263  if (((*p)->decode != (char *) NULL) &&
1264  ((*q)->decode != (char *) NULL))
1265  return(strcmp((*p)->decode,(*q)->decode));
1266  }
1267  return(cmp);
1268 }
1269 
1270 #if defined(__cplusplus) || defined(c_plusplus)
1271 }
1272 #endif
1273 
1274 MagickExport const DelegateInfo **GetDelegateInfoList(const char *pattern,
1275  size_t *number_delegates,ExceptionInfo *exception)
1276 {
1277  const DelegateInfo
1278  **delegates;
1279 
1280  register const DelegateInfo
1281  *p;
1282 
1283  register ssize_t
1284  i;
1285 
1286  /*
1287  Allocate delegate list.
1288  */
1289  assert(number_delegates != (size_t *) NULL);
1290  assert(pattern != (char *) NULL);
1291  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1292 
1293  *number_delegates=0;
1294  p=GetDelegateInfo("*","*",exception);
1295  if (p == (const DelegateInfo *) NULL)
1296  return((const DelegateInfo **) NULL);
1297  delegates=(const DelegateInfo **) AcquireQuantumMemory((size_t)
1298  GetNumberOfElementsInLinkedList(delegate_cache)+1UL,sizeof(*delegates));
1299  if (delegates == (const DelegateInfo **) NULL)
1300  return((const DelegateInfo **) NULL);
1301  /*
1302  Generate delegate list.
1303  */
1307  for (i=0; p != (const DelegateInfo *) NULL; )
1308  {
1309  if( (p->stealth == MagickFalse) &&
1310  ( GlobExpression(p->decode,pattern,MagickFalse) != MagickFalse ||
1311  GlobExpression(p->encode,pattern,MagickFalse) != MagickFalse) )
1312  delegates[i++]=p;
1314  }
1316  qsort((void *) delegates,(size_t) i,sizeof(*delegates),DelegateInfoCompare);
1317  delegates[i]=(DelegateInfo *) NULL;
1318  *number_delegates=(size_t) i;
1319  return(delegates);
1320 }
1321 
1322 /*
1323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1324 % %
1325 % %
1326 % %
1327 % G e t D e l e g a t e L i s t %
1328 % %
1329 % %
1330 % %
1331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1332 %
1333 % GetDelegateList() returns any image format delegates that match the
1334 % specified pattern.
1335 %
1336 % The format of the GetDelegateList function is:
1337 %
1338 % char **GetDelegateList(const char *pattern,
1339 % size_t *number_delegates,ExceptionInfo *exception)
1340 %
1341 % A description of each parameter follows:
1342 %
1343 % o pattern: Specifies a pointer to a text string containing a pattern.
1344 %
1345 % o number_delegates: This integer returns the number of delegates
1346 % in the list.
1347 %
1348 % o exception: return any errors or warnings in this structure.
1349 %
1350 */
1351 
1352 #if defined(__cplusplus) || defined(c_plusplus)
1353 extern "C" {
1354 #endif
1355 
1356 static int DelegateCompare(const void *x,const void *y)
1357 {
1358  register const char
1359  **p,
1360  **q;
1361 
1362  p=(const char **) x;
1363  q=(const char **) y;
1364  return(LocaleCompare(*p,*q));
1365 }
1366 
1367 #if defined(__cplusplus) || defined(c_plusplus)
1368 }
1369 #endif
1370 
1371 MagickExport char **GetDelegateList(const char *pattern,
1372  size_t *number_delegates,ExceptionInfo *exception)
1373 {
1374  char
1375  **delegates;
1376 
1377  register const DelegateInfo
1378  *p;
1379 
1380  register ssize_t
1381  i;
1382 
1383  /*
1384  Allocate delegate list.
1385  */
1386  assert(pattern != (char *) NULL);
1387  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1388 
1389  assert(number_delegates != (size_t *) NULL);
1390  *number_delegates=0;
1391  p=GetDelegateInfo("*","*",exception);
1392  if (p == (const DelegateInfo *) NULL)
1393  return((char **) NULL);
1394  delegates=(char **) AcquireQuantumMemory((size_t)
1395  GetNumberOfElementsInLinkedList(delegate_cache)+1UL,sizeof(*delegates));
1396  if (delegates == (char **) NULL)
1397  return((char **) NULL);
1401  for (i=0; p != (const DelegateInfo *) NULL; )
1402  {
1403  if( (p->stealth == MagickFalse) &&
1404  GlobExpression(p->decode,pattern,MagickFalse) != MagickFalse )
1405  delegates[i++]=ConstantString(p->decode);
1406  if( (p->stealth == MagickFalse) &&
1407  GlobExpression(p->encode,pattern,MagickFalse) != MagickFalse )
1408  delegates[i++]=ConstantString(p->encode);
1410  }
1412  qsort((void *) delegates,(size_t) i,sizeof(*delegates),DelegateCompare);
1413  delegates[i]=(char *) NULL;
1414  *number_delegates=(size_t) i;
1415  return(delegates);
1416 }
1417 
1418 /*
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420 % %
1421 % %
1422 % %
1423 % G e t D e l e g a t e M o d e %
1424 % %
1425 % %
1426 % %
1427 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1428 %
1429 % GetDelegateMode() returns the mode of the delegate.
1430 %
1431 % The format of the GetDelegateMode method is:
1432 %
1433 % ssize_t GetDelegateMode(const DelegateInfo *delegate_info)
1434 %
1435 % A description of each parameter follows:
1436 %
1437 % o delegate_info: The delegate info.
1438 %
1439 */
1440 MagickExport ssize_t GetDelegateMode(const DelegateInfo *delegate_info)
1441 {
1442  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1443 
1444  assert(delegate_info != (DelegateInfo *) NULL);
1445  assert(delegate_info->signature == MagickCoreSignature);
1446  return(delegate_info->mode);
1447 }
1448 
1449 /*
1450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1451 % %
1452 % %
1453 % %
1454 + G e t D e l e g a t e T h r e a d S u p p o r t %
1455 % %
1456 % %
1457 % %
1458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1459 %
1460 % GetDelegateThreadSupport() returns MagickTrue if the delegate supports
1461 % threads.
1462 %
1463 % The format of the GetDelegateThreadSupport method is:
1464 %
1465 % MagickBooleanType GetDelegateThreadSupport(
1466 % const DelegateInfo *delegate_info)
1467 %
1468 % A description of each parameter follows:
1469 %
1470 % o delegate_info: The delegate info.
1471 %
1472 */
1474  const DelegateInfo *delegate_info)
1475 {
1476  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
1477 
1478  assert(delegate_info != (DelegateInfo *) NULL);
1479  assert(delegate_info->signature == MagickCoreSignature);
1480  return(delegate_info->thread_support);
1481 }
1482 
1483 /*
1484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1485 % %
1486 % %
1487 % %
1488 + I s D e l e g a t e C a c h e I n s t a n t i a t e d %
1489 % %
1490 % %
1491 % %
1492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1493 %
1494 % IsDelegateCacheInstantiated() determines if the delegate cache is
1495 % instantiated. If not, it instantiates the cache and returns it.
1496 %
1497 % The format of the IsDelegateInstantiated method is:
1498 %
1499 % MagickBooleanType IsDelegateCacheInstantiated(ExceptionInfo *exception)
1500 %
1501 % A description of each parameter follows.
1502 %
1503 % o exception: return any errors or warnings in this structure.
1504 %
1505 */
1507 {
1508  if (delegate_cache == (LinkedListInfo *) NULL)
1509  {
1510  if (delegate_semaphore == (SemaphoreInfo *) NULL)
1513  if (delegate_cache == (LinkedListInfo *) NULL)
1516  }
1517  return(delegate_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
1518 }
1519 
1520 /*
1521 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1522 % %
1523 % %
1524 % %
1525 % I n v o k e D e l e g a t e %
1526 % %
1527 % %
1528 % %
1529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1530 %
1531 % InvokeDelegate replaces any embedded formatting characters with the
1532 % appropriate image attribute and executes the resulting command. MagickFalse
1533 % is returned if the commands execute with success otherwise MagickTrue.
1534 %
1535 % The format of the InvokeDelegate method is:
1536 %
1537 % MagickBooleanType InvokeDelegate(ImageInfo *image_info,Image *image,
1538 % const char *decode,const char *encode,ExceptionInfo *exception)
1539 %
1540 % A description of each parameter follows:
1541 %
1542 % o image_info: the imageInfo.
1543 %
1544 % o image: the image.
1545 %
1546 % o exception: return any errors or warnings in this structure.
1547 %
1548 */
1549 
1550 static MagickBooleanType CopyDelegateFile(const char *source,
1551  const char *destination,const MagickBooleanType overwrite)
1552 {
1553  int
1554  destination_file,
1555  source_file;
1556 
1558  status;
1559 
1560  register size_t
1561  i;
1562 
1563  size_t
1564  length,
1565  quantum;
1566 
1567  ssize_t
1568  count;
1569 
1570  struct stat
1571  attributes;
1572 
1573  unsigned char
1574  *buffer;
1575 
1576  /*
1577  Copy source file to destination.
1578  */
1579  assert(source != (const char *) NULL);
1580  assert(destination != (char *) NULL);
1581  if (overwrite == MagickFalse)
1582  {
1583  status=GetPathAttributes(destination,&attributes);
1584  if (status != MagickFalse)
1585  return(MagickTrue);
1586  }
1587  destination_file=open_utf8(destination,O_WRONLY | O_BINARY | O_CREAT,S_MODE);
1588  if (destination_file == -1)
1589  return(MagickFalse);
1590  source_file=open_utf8(source,O_RDONLY | O_BINARY,0);
1591  if (source_file == -1)
1592  {
1593  (void) close(destination_file);
1594  return(MagickFalse);
1595  }
1596  quantum=(size_t) MagickMaxBufferExtent;
1597  if ((fstat(source_file,&attributes) == 0) && (attributes.st_size > 0))
1598  quantum=MagickMin((size_t) attributes.st_size,MagickMaxBufferExtent);
1599  buffer=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*buffer));
1600  if (buffer == (unsigned char *) NULL)
1601  {
1602  (void) close(source_file);
1603  (void) close(destination_file);
1604  return(MagickFalse);
1605  }
1606  length=0;
1607  for (i=0; ; i+=count)
1608  {
1609  count=(ssize_t) read(source_file,buffer,quantum);
1610  if (count <= 0)
1611  break;
1612  length=(size_t) count;
1613  count=(ssize_t) write(destination_file,buffer,length);
1614  if ((size_t) count != length)
1615  break;
1616  }
1617  (void) close(destination_file);
1618  (void) close(source_file);
1619  buffer=(unsigned char *) RelinquishMagickMemory(buffer);
1620  return(i != 0 ? MagickTrue : MagickFalse);
1621 }
1622 
1624  Image *image,const char *decode,const char *encode,ExceptionInfo *exception)
1625 {
1626  char
1627  *command,
1628  **commands,
1629  input_filename[MagickPathExtent],
1630  output_filename[MagickPathExtent];
1631 
1632  const DelegateInfo
1633  *delegate_info;
1634 
1636  status,
1637  temporary;
1638 
1639  PolicyRights
1640  rights;
1641 
1642  register ssize_t
1643  i;
1644 
1645  /*
1646  Get delegate.
1647  */
1648  assert(image_info != (ImageInfo *) NULL);
1649  assert(image_info->signature == MagickCoreSignature);
1650  assert(image != (Image *) NULL);
1651  assert(image->signature == MagickCoreSignature);
1652  if (image->debug != MagickFalse)
1653  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1654  rights=ExecutePolicyRights;
1655  if (IsRightsAuthorized(DelegatePolicyDomain,rights,decode) == MagickFalse)
1656  {
1657  errno=EPERM;
1659  "NotAuthorized","`%s'",decode);
1660  return(MagickFalse);
1661  }
1662  if (IsRightsAuthorized(DelegatePolicyDomain,rights,encode) == MagickFalse)
1663  {
1664  errno=EPERM;
1666  "NotAuthorized","`%s'",encode);
1667  return(MagickFalse);
1668  }
1669  temporary=*image->filename == '\0' ? MagickTrue : MagickFalse;
1670  if ((temporary != MagickFalse) && (AcquireUniqueFilename(image->filename) ==
1671  MagickFalse))
1672  {
1673  ThrowFileException(exception,FileOpenError,"UnableToCreateTemporaryFile",
1674  image->filename);
1675  return(MagickFalse);
1676  }
1677  delegate_info=GetDelegateInfo(decode,encode,exception);
1678  if (delegate_info == (DelegateInfo *) NULL)
1679  {
1680  if (temporary != MagickFalse)
1681  (void) RelinquishUniqueFileResource(image->filename);
1683  "NoTagFound","`%s'",decode ? decode : encode);
1684  return(MagickFalse);
1685  }
1686  if (*image_info->filename == '\0')
1687  {
1688  if (AcquireUniqueFilename(image_info->filename) == MagickFalse)
1689  {
1690  if (temporary != MagickFalse)
1691  (void) RelinquishUniqueFileResource(image->filename);
1693  "UnableToCreateTemporaryFile",image_info->filename);
1694  return(MagickFalse);
1695  }
1696  image_info->temporary=MagickTrue;
1697  }
1698  if ((delegate_info->mode != 0) && (((decode != (const char *) NULL) &&
1699  (delegate_info->encode != (char *) NULL)) ||
1700  ((encode != (const char *) NULL) &&
1701  (delegate_info->decode != (char *) NULL))))
1702  {
1703  char
1704  *magick;
1705 
1706  ImageInfo
1707  *clone_info;
1708 
1709  register Image
1710  *p;
1711 
1712  /*
1713  Delegate requires a particular image format.
1714  */
1715  if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1716  {
1718  "UnableToCreateTemporaryFile",image_info->unique);
1719  return(MagickFalse);
1720  }
1721  magick=InterpretImageProperties(image_info,image,decode != (char *) NULL ?
1722  delegate_info->encode : delegate_info->decode,exception);
1723  if (magick == (char *) NULL)
1724  {
1725  (void) RelinquishUniqueFileResource(image_info->unique);
1726  if (temporary != MagickFalse)
1727  (void) RelinquishUniqueFileResource(image->filename);
1728  (void) ThrowMagickException(exception,GetMagickModule(),
1729  DelegateError,"DelegateFailed","`%s'",decode ? decode : encode);
1730  return(MagickFalse);
1731  }
1732  LocaleUpper(magick);
1733  clone_info=CloneImageInfo(image_info);
1734  (void) CopyMagickString((char *) clone_info->magick,magick,
1736  if (LocaleCompare(magick,"NULL") != 0)
1737  (void) CopyMagickString(image->magick,magick,MagickPathExtent);
1738  magick=DestroyString(magick);
1739  (void) FormatLocaleString(clone_info->filename,MagickPathExtent,"%s:",
1740  delegate_info->decode);
1741  (void) SetImageInfo(clone_info,(unsigned int) GetImageListLength(image),
1742  exception);
1743  (void) CopyMagickString(clone_info->filename,image_info->filename,
1745  (void) CopyMagickString(image_info->filename,image->filename,
1747  for (p=image; p != (Image *) NULL; p=GetNextImageInList(p))
1748  {
1749  (void) FormatLocaleString(p->filename,MagickPathExtent,"%s:%s",
1750  delegate_info->decode,clone_info->filename);
1751  status=WriteImage(clone_info,p,exception);
1752  if (status == MagickFalse)
1753  {
1754  (void) RelinquishUniqueFileResource(image_info->unique);
1755  if (temporary != MagickFalse)
1756  (void) RelinquishUniqueFileResource(image->filename);
1757  clone_info=DestroyImageInfo(clone_info);
1758  (void) ThrowMagickException(exception,GetMagickModule(),
1759  DelegateError,"DelegateFailed","`%s'",decode ? decode : encode);
1760  return(MagickFalse);
1761  }
1762  if (clone_info->adjoin != MagickFalse)
1763  break;
1764  }
1765  (void) RelinquishUniqueFileResource(image_info->unique);
1766  clone_info=DestroyImageInfo(clone_info);
1767  }
1768  /*
1769  Invoke delegate.
1770  */
1771  commands=StringToList(delegate_info->commands);
1772  if (commands == (char **) NULL)
1773  {
1774  if (temporary != MagickFalse)
1775  (void) RelinquishUniqueFileResource(image->filename);
1776  (void) ThrowMagickException(exception,GetMagickModule(),
1777  ResourceLimitError,"MemoryAllocationFailed","`%s'",
1778  decode ? decode : encode);
1779  return(MagickFalse);
1780  }
1781  command=(char *) NULL;
1782  status=MagickTrue;
1783  (void) CopyMagickString(output_filename,image_info->filename,
1785  (void) CopyMagickString(input_filename,image->filename,MagickPathExtent);
1786  for (i=0; commands[i] != (char *) NULL; i++)
1787  {
1788  (void) AcquireUniqueSymbolicLink(output_filename,image_info->filename);
1789  if (AcquireUniqueFilename(image_info->unique) == MagickFalse)
1790  {
1792  "UnableToCreateTemporaryFile",image_info->unique);
1793  break;
1794  }
1795  if (LocaleCompare(decode,"SCAN") != 0)
1796  {
1797  status=AcquireUniqueSymbolicLink(input_filename,image->filename);
1798  if (status == MagickFalse)
1799  {
1801  "UnableToCreateTemporaryFile",input_filename);
1802  break;
1803  }
1804  }
1805  status=MagickTrue;
1806  command=InterpretDelegateProperties(image_info,image,commands[i],exception);
1807  if (command != (char *) NULL)
1808  {
1809  /*
1810  Execute delegate.
1811  */
1812  if (ExternalDelegateCommand(delegate_info->spawn,image_info->verbose,
1813  command,(char *) NULL,exception) != 0)
1814  status=MagickFalse;
1815  if (delegate_info->spawn != MagickFalse)
1816  {
1817  ssize_t
1818  count;
1819 
1820  /*
1821  Wait for input file to 'disappear', or maximum 2 seconds.
1822  */
1823  count=20;
1824  while ((count-- > 0) && (access_utf8(image->filename,F_OK) == 0))
1825  (void) MagickDelay(100); /* sleep 0.1 seconds */
1826  }
1827  command=DestroyString(command);
1828  }
1829  if (LocaleCompare(decode,"SCAN") != 0)
1830  {
1831  if (CopyDelegateFile(image->filename,input_filename,MagickFalse) == MagickFalse)
1832  (void) RelinquishUniqueFileResource(input_filename);
1833  }
1834  if ((strcmp(input_filename,output_filename) != 0) &&
1835  (CopyDelegateFile(image_info->filename,output_filename,MagickTrue) == MagickFalse))
1836  (void) RelinquishUniqueFileResource(output_filename);
1837  if (image_info->temporary != MagickFalse)
1838  (void) RelinquishUniqueFileResource(image_info->filename);
1839  (void) RelinquishUniqueFileResource(image_info->unique);
1840  (void) RelinquishUniqueFileResource(image_info->filename);
1841  (void) RelinquishUniqueFileResource(image->filename);
1842  if (status == MagickFalse)
1843  {
1845  "DelegateFailed","`%s'",commands[i]);
1846  break;
1847  }
1848  commands[i]=DestroyString(commands[i]);
1849  }
1850  (void) CopyMagickString(image_info->filename,output_filename,
1852  (void) CopyMagickString(image->filename,input_filename,MagickPathExtent);
1853  /*
1854  Relinquish resources.
1855  */
1856  for ( ; commands[i] != (char *) NULL; i++)
1857  commands[i]=DestroyString(commands[i]);
1858  commands=(char **) RelinquishMagickMemory(commands);
1859  if (temporary != MagickFalse)
1860  (void) RelinquishUniqueFileResource(image->filename);
1861  return(status);
1862 }
1863 
1864 /*
1865 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1866 % %
1867 % %
1868 % %
1869 % L i s t D e l e g a t e I n f o %
1870 % %
1871 % %
1872 % %
1873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1874 %
1875 % ListDelegateInfo() lists the image formats to a file.
1876 %
1877 % The format of the ListDelegateInfo method is:
1878 %
1879 % MagickBooleanType ListDelegateInfo(FILE *file,ExceptionInfo *exception)
1880 %
1881 % A description of each parameter follows.
1882 %
1883 % o file: An pointer to a FILE.
1884 %
1885 % o exception: return any errors or warnings in this structure.
1886 %
1887 */
1889  ExceptionInfo *exception)
1890 {
1891  const DelegateInfo
1892  **delegate_info;
1893 
1894  char
1895  **commands,
1896  delegate[MagickPathExtent];
1897 
1898  const char
1899  *path;
1900 
1901  register ssize_t
1902  i;
1903 
1904  size_t
1905  number_delegates;
1906 
1907  ssize_t
1908  j;
1909 
1910  if (file == (const FILE *) NULL)
1911  file=stdout;
1912  delegate_info=GetDelegateInfoList("*",&number_delegates,exception);
1913  if (delegate_info == (const DelegateInfo **) NULL)
1914  return(MagickFalse);
1915  path=(const char *) NULL;
1916  for (i=0; i < (ssize_t) number_delegates; i++)
1917  {
1918  if (delegate_info[i]->stealth != MagickFalse)
1919  continue;
1920  if ((path == (const char *) NULL) ||
1921  (LocaleCompare(path,delegate_info[i]->path) != 0))
1922  {
1923  if (delegate_info[i]->path != (char *) NULL)
1924  (void) FormatLocaleFile(file,"\nPath: %s\n\n",delegate_info[i]->path);
1925  (void) FormatLocaleFile(file,"Delegate Command\n");
1926  (void) FormatLocaleFile(file,
1927  "-------------------------------------------------"
1928  "------------------------------\n");
1929  }
1930  path=delegate_info[i]->path;
1931  *delegate='\0';
1932  if (delegate_info[i]->encode != (char *) NULL)
1933  (void) CopyMagickString(delegate,delegate_info[i]->encode,
1935  (void) ConcatenateMagickString(delegate," ",MagickPathExtent);
1936  delegate[8]='\0';
1937  commands=StringToList(delegate_info[i]->commands);
1938  if (commands == (char **) NULL)
1939  continue;
1940  (void) FormatLocaleFile(file,"%11s%c=%c%s ",delegate_info[i]->decode ?
1941  delegate_info[i]->decode : "",delegate_info[i]->mode <= 0 ? '<' : ' ',
1942  delegate_info[i]->mode >= 0 ? '>' : ' ',delegate);
1943  StripString(commands[0]);
1944  (void) FormatLocaleFile(file,"\"%s\"\n",commands[0]);
1945  for (j=1; commands[j] != (char *) NULL; j++)
1946  {
1947  StripString(commands[j]);
1948  (void) FormatLocaleFile(file," \"%s\"\n",commands[j]);
1949  }
1950  for (j=0; commands[j] != (char *) NULL; j++)
1951  commands[j]=DestroyString(commands[j]);
1952  commands=(char **) RelinquishMagickMemory(commands);
1953  }
1954  (void) fflush(file);
1955  delegate_info=(const DelegateInfo **)
1956  RelinquishMagickMemory((void *) delegate_info);
1957  return(MagickTrue);
1958 }
1959 
1960 /*
1961 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1962 % %
1963 % %
1964 % %
1965 + L o a d D e l e g a t e C a c h e %
1966 % %
1967 % %
1968 % %
1969 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1970 %
1971 % LoadDelegateCache() loads the delegate configurations which provides a
1972 % mapping between delegate attributes and a delegate name.
1973 %
1974 % The format of the LoadDelegateCache method is:
1975 %
1976 % MagickBooleanType LoadDelegateCache(LinkedListInfo *cache,
1977 % const char *xml,const char *filename,const size_t depth,
1978 % ExceptionInfo *exception)
1979 %
1980 % A description of each parameter follows:
1981 %
1982 % o xml: The delegate list in XML format.
1983 %
1984 % o filename: The delegate list filename.
1985 %
1986 % o depth: depth of <include /> statements.
1987 %
1988 % o exception: return any errors or warnings in this structure.
1989 %
1990 */
1992  const char *xml,const char *filename,const size_t depth,
1993  ExceptionInfo *exception)
1994 {
1995  char
1996  keyword[MagickPathExtent],
1997  *token;
1998 
1999  const char
2000  *q;
2001 
2002  DelegateInfo
2003  *delegate_info;
2004 
2006  status;
2007 
2008  size_t
2009  extent;
2010 
2011  /*
2012  Load the delegate map file.
2013  */
2015  "Loading delegate configuration file \"%s\" ...",filename);
2016  if (xml == (const char *) NULL)
2017  return(MagickFalse);
2018  status=MagickTrue;
2019  delegate_info=(DelegateInfo *) NULL;
2020  token=AcquireString(xml);
2021  extent=strlen(token)+MagickPathExtent;
2022  for (q=(const char *) xml; *q != '\0'; )
2023  {
2024  /*
2025  Interpret XML.
2026  */
2027  GetNextToken(q,&q,extent,token);
2028  if (*token == '\0')
2029  break;
2030  (void) CopyMagickString(keyword,token,MagickPathExtent);
2031  if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
2032  {
2033  /*
2034  Doctype element.
2035  */
2036  while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
2037  GetNextToken(q,&q,extent,token);
2038  continue;
2039  }
2040  if (LocaleNCompare(keyword,"<!--",4) == 0)
2041  {
2042  /*
2043  Comment element.
2044  */
2045  while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
2046  GetNextToken(q,&q,extent,token);
2047  continue;
2048  }
2049  if (LocaleCompare(keyword,"<include") == 0)
2050  {
2051  /*
2052  Include element.
2053  */
2054  while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
2055  {
2056  (void) CopyMagickString(keyword,token,MagickPathExtent);
2057  GetNextToken(q,&q,extent,token);
2058  if (*token != '=')
2059  continue;
2060  GetNextToken(q,&q,extent,token);
2061  if (LocaleCompare(keyword,"file") == 0)
2062  {
2063  if (depth > 200)
2064  (void) ThrowMagickException(exception,GetMagickModule(),
2065  ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
2066  else
2067  {
2068  char
2069  path[MagickPathExtent],
2070  *file_xml;
2071 
2072  GetPathComponent(filename,HeadPath,path);
2073  if (*path != '\0')
2076  if (*token == *DirectorySeparator)
2077  (void) CopyMagickString(path,token,MagickPathExtent);
2078  else
2079  (void) ConcatenateMagickString(path,token,MagickPathExtent);
2080  file_xml=FileToXML(path,~0UL);
2081  if (file_xml != (char *) NULL)
2082  {
2083  status&=LoadDelegateCache(cache,file_xml,path,
2084  depth+1,exception);
2085  file_xml=DestroyString(file_xml);
2086  }
2087  }
2088  }
2089  }
2090  continue;
2091  }
2092  if (LocaleCompare(keyword,"<delegate") == 0)
2093  {
2094  /*
2095  Delegate element.
2096  */
2097  delegate_info=(DelegateInfo *) AcquireCriticalMemory(
2098  sizeof(*delegate_info));
2099  (void) ResetMagickMemory(delegate_info,0,sizeof(*delegate_info));
2100  delegate_info->path=ConstantString(filename);
2101  delegate_info->thread_support=MagickTrue;
2102  delegate_info->signature=MagickCoreSignature;
2103  continue;
2104  }
2105  if (delegate_info == (DelegateInfo *) NULL)
2106  continue;
2107  if ((LocaleCompare(keyword,"/>") == 0) ||
2108  (LocaleCompare(keyword,"</policy>") == 0))
2109  {
2110  status=AppendValueToLinkedList(cache,delegate_info);
2111  if (status == MagickFalse)
2112  (void) ThrowMagickException(exception,GetMagickModule(),
2113  ResourceLimitError,"MemoryAllocationFailed","`%s'",
2114  delegate_info->commands);
2115  delegate_info=(DelegateInfo *) NULL;
2116  continue;
2117  }
2118  GetNextToken(q,(const char **) NULL,extent,token);
2119  if (*token != '=')
2120  continue;
2121  GetNextToken(q,&q,extent,token);
2122  GetNextToken(q,&q,extent,token);
2123  switch (*keyword)
2124  {
2125  case 'C':
2126  case 'c':
2127  {
2128  if (LocaleCompare((char *) keyword,"command") == 0)
2129  {
2130  char
2131  *commands;
2132 
2133  commands=AcquireString(token);
2134 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
2135  if (strchr(commands,'@') != (char *) NULL)
2136  {
2137  char
2138  path[MagickPathExtent];
2139 
2140  NTGhostscriptEXE(path,MagickPathExtent);
2141  (void) SubstituteString((char **) &commands,"@PSDelegate@",
2142  path);
2143  (void) SubstituteString((char **) &commands,"\\","/");
2144  }
2145  (void) SubstituteString((char **) &commands,"&quot;","\"");
2146 #else
2147  (void) SubstituteString((char **) &commands,"&quot;","'");
2148 #endif
2149  (void) SubstituteString((char **) &commands,"&amp;","&");
2150  (void) SubstituteString((char **) &commands,"&gt;",">");
2151  (void) SubstituteString((char **) &commands,"&lt;","<");
2152  delegate_info->commands=commands;
2153  break;
2154  }
2155  break;
2156  }
2157  case 'D':
2158  case 'd':
2159  {
2160  if (LocaleCompare((char *) keyword,"decode") == 0)
2161  {
2162  delegate_info->decode=ConstantString(token);
2163  delegate_info->mode=1;
2164  break;
2165  }
2166  break;
2167  }
2168  case 'E':
2169  case 'e':
2170  {
2171  if (LocaleCompare((char *) keyword,"encode") == 0)
2172  {
2173  delegate_info->encode=ConstantString(token);
2174  delegate_info->mode=(-1);
2175  break;
2176  }
2177  break;
2178  }
2179  case 'M':
2180  case 'm':
2181  {
2182  if (LocaleCompare((char *) keyword,"mode") == 0)
2183  {
2184  delegate_info->mode=1;
2185  if (LocaleCompare(token,"bi") == 0)
2186  delegate_info->mode=0;
2187  else
2188  if (LocaleCompare(token,"encode") == 0)
2189  delegate_info->mode=(-1);
2190  break;
2191  }
2192  break;
2193  }
2194  case 'S':
2195  case 's':
2196  {
2197  if (LocaleCompare((char *) keyword,"spawn") == 0)
2198  {
2199  delegate_info->spawn=IsStringTrue(token);
2200  break;
2201  }
2202  if (LocaleCompare((char *) keyword,"stealth") == 0)
2203  {
2204  delegate_info->stealth=IsStringTrue(token);
2205  break;
2206  }
2207  break;
2208  }
2209  case 'T':
2210  case 't':
2211  {
2212  if (LocaleCompare((char *) keyword,"thread-support") == 0)
2213  {
2214  delegate_info->thread_support=IsStringTrue(token);
2215  if (delegate_info->thread_support == MagickFalse)
2216  delegate_info->semaphore=AcquireSemaphoreInfo();
2217  break;
2218  }
2219  break;
2220  }
2221  default:
2222  break;
2223  }
2224  }
2225  token=(char *) RelinquishMagickMemory(token);
2226  return(status != 0 ? MagickTrue : MagickFalse);
2227 }
size_t rows
Definition: image.h:172
MagickExport ssize_t FormatMagickSize(const MagickSizeType size, const MagickBooleanType bi, const char *suffix, const size_t length, char *format)
Definition: string.c:1081
size_t signature
Definition: image.h:479
static int DelegateCompare(const void *x, const void *y)
Definition: delegate.c:1356
MagickExport MagickBooleanType GetPathAttributes(const char *path, void *attributes)
Definition: utility.c:1165
DisposeType dispose
Definition: image.h:237
char magick[MagickPathExtent]
Definition: image.h:471
MagickExport MagickBooleanType GetDelegateThreadSupport(const DelegateInfo *delegate_info)
Definition: delegate.c:1473
MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain, const PolicyRights rights, const char *pattern)
Definition: policy.c:589
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:450
MagickExport void ResetLinkedListIterator(LinkedListInfo *list_info)
Definition: linked-list.c:959
MagickExport const DelegateInfo ** GetDelegateInfoList(const char *pattern, size_t *number_delegates, ExceptionInfo *exception)
Definition: delegate.c:1274
static SemaphoreInfo * delegate_semaphore
Definition: delegate.c:143
PolicyRights
Definition: policy.h:40
MagickExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
Definition: linked-list.c:219
static MagickBooleanType IsDelegateCacheInstantiated(ExceptionInfo *)
Definition: delegate.c:1506
#define WarnNoImageReturn(format, letter)
size_t number_scenes
Definition: image.h:387
#define WarnNoImageInfoReturn(format, letter)
MagickExport size_t ConcatenateMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:410
MagickBooleanType debug
Definition: image.h:476
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
Definition: semaphore.c:192
MagickExport MagickBooleanType InsertValueInLinkedList(LinkedListInfo *list_info, const size_t index, const void *value)
Definition: linked-list.c:447
MagickExport char ** GetDelegateList(const char *pattern, size_t *number_delegates, ExceptionInfo *exception)
Definition: delegate.c:1371
MagickExport const DelegateInfo * GetDelegateInfo(const char *decode, const char *encode, ExceptionInfo *exception)
Definition: delegate.c:1158
#define MagickMaxBufferExtent
Definition: blob.h:25
MagickExport char * SanitizeString(const char *source)
Definition: string.c:1663
MagickExport MagickBooleanType IsLinkedListEmpty(const LinkedListInfo *list_info)
Definition: linked-list.c:633
MagickExport MagickBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
Definition: linked-list.c:111
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:473
MagickExport ssize_t GetDelegateMode(const DelegateInfo *delegate_info)
Definition: delegate.c:1440
ResolutionType units
Definition: image.h:198
MagickExport MagickBooleanType SignatureImage(Image *image, ExceptionInfo *exception)
Definition: signature.c:466
size_t delay
Definition: image.h:240
MagickExport void * RemoveElementByValueFromLinkedList(LinkedListInfo *list_info, const void *value)
Definition: linked-list.c:756
char magick[MagickPathExtent]
Definition: image.h:319
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
size_t magick_rows
Definition: image.h:324
MagickBooleanType verbose
Definition: image.h:436
MagickExport const char * GetDelegateCommands(const DelegateInfo *delegate_info)
Definition: delegate.c:1120
MagickExport const char * GetImageOption(const ImageInfo *image_info, const char *option)
Definition: option.c:2288
char * commands
Definition: delegate.h:31
#define MagickEpsilon
Definition: magick-type.h:110
CompressionType compression
Definition: image.h:160
#define O_BINARY
Definition: studio.h:320
ClassType storage_class
Definition: image.h:154
MagickExport void StripString(char *message)
Definition: string.c:2473
size_t width
Definition: geometry.h:129
MagickExport MagickBooleanType AcquireUniqueFilename(char *path)
Definition: utility.c:111
Definition: log.h:52
MagickBooleanType thread_support
Definition: delegate.h:40
Definition: image.h:151
SemaphoreInfo * semaphore
Definition: delegate.h:45
MagickExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
Definition: linked-list.c:305
MagickExport MagickBooleanType SetImageGray(Image *image, ExceptionInfo *exception)
Definition: colorspace.c:1162
static char * InterpretDelegateProperties(ImageInfo *image_info, Image *image, const char *embed_text, ExceptionInfo *exception)
Definition: delegate.c:843
static char * GetMagickPropertyLetter(ImageInfo *image_info, Image *image, const char letter, ExceptionInfo *exception)
Definition: delegate.c:510
double x
Definition: geometry.h:122
#define MagickCoreSignature
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1283
MagickExport LinkedListInfo * GetConfigureOptions(const char *filename, ExceptionInfo *exception)
Definition: configure.c:654
static MagickBooleanType LoadDelegateCache(LinkedListInfo *, const char *, const char *, const size_t, ExceptionInfo *)
Definition: delegate.c:1991
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1213
static MagickBooleanType CopyDelegateFile(const char *source, const char *destination, const MagickBooleanType overwrite)
Definition: delegate.c:1550
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
Definition: locale.c:378
MagickBooleanType
Definition: magick-type.h:156
MagickExport char ** StringToList(const char *text)
Definition: string.c:2304
size_t scene
Definition: image.h:240
#define DirectorySeparator
Definition: studio.h:254
unsigned int MagickStatusType
Definition: magick-type.h:119
MagickExport char * AcquireString(const char *source)
Definition: string.c:124
MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info, Image *image, ExceptionInfo *exception)
Definition: constitute.c:973
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1164
MagickExport const char * CommandOptionToMnemonic(const CommandOption option, const ssize_t type)
Definition: option.c:2666
MagickPrivate void DelegateComponentTerminus(void)
Definition: delegate.c:278
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:529
char filename[MagickPathExtent]
Definition: image.h:471
MagickExport char * GetDelegateCommand(const ImageInfo *image_info, Image *image, const char *decode, const char *encode, ExceptionInfo *exception)
Definition: delegate.c:1049
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
Definition: locale.c:1509
double y
Definition: geometry.h:122
MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
Definition: resource.c:1131
char * decode
Definition: delegate.h:31
RectangleInfo page
Definition: image.h:212
size_t magick_columns
Definition: image.h:324
MagickExport MagickBooleanType GlobExpression(const char *expression, const char *pattern, const MagickBooleanType case_insensitive)
Definition: token.c:349
#define MagickPathExtent
MagickExport void MagickDelay(const MagickSizeType milliseconds)
Definition: utility.c:1703
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1464
MagickExport MagickBooleanType static void * AcquireCriticalMemory(const size_t size)
#define ThrowFileException(exception, severity, tag, context)
PixelTrait alpha_trait
Definition: image.h:280
size_t signature
Definition: delegate.h:48
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2596
char magick_filename[MagickPathExtent]
Definition: image.h:319
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1058
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1397
static int open_utf8(const char *path, int flags, mode_t mode)
size_t signature
Definition: image.h:354
size_t columns
Definition: image.h:172
MagickExport MagickBooleanType AcquireUniqueSymbolicLink(const char *source, char *destination)
Definition: utility.c:153
MagickExport MagickBooleanType SubstituteString(char **string, const char *search, const char *replace)
Definition: string.c:2535
ssize_t x
Definition: geometry.h:133
size_t height
Definition: geometry.h:129
MagickExport LinkedListInfo * NewLinkedList(const size_t capacity)
Definition: linked-list.c:713
MagickPrivate MagickBooleanType DelegateComponentGenesis(void)
Definition: delegate.c:232
ssize_t mode
Definition: delegate.h:37
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:742
MagickExport int ExternalDelegateCommand(const MagickBooleanType asynchronous, const MagickBooleanType verbose, const char *command, char *message, ExceptionInfo *exception)
Definition: delegate.c:325
#define S_MODE
Definition: studio.h:234
MagickBooleanType spawn
Definition: delegate.h:40
static void * DestroyDelegate(void *delegate_info)
Definition: delegate.c:258
#define AppendString2Text(string)
size_t quality
Definition: image.h:163
PolicyDomain
Definition: policy.h:28
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1409
char filename[MagickPathExtent]
Definition: image.h:319
#define GetMagickModule()
Definition: log.h:28
MagickBooleanType stealth
Definition: delegate.h:40
MagickExport const char * GetStringInfoPath(const StringInfo *string_info)
Definition: string.c:1341
MagickExport char * InterpretImageProperties(ImageInfo *image_info, Image *image, const char *embed_text, ExceptionInfo *exception)
Definition: property.c:3274
MagickExport void GetNextToken(const char *start, const char **end, const size_t extent, char *token)
Definition: token.c:171
MagickExport MagickSizeType GetBlobSize(const Image *image)
Definition: blob.c:1686
char unique[MagickPathExtent]
Definition: image.h:471
MagickExport ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1253
static LinkedListInfo * delegate_cache
Definition: delegate.c:140
MagickExport MagickBooleanType ListDelegateInfo(FILE *file, ExceptionInfo *exception)
Definition: delegate.c:1888
char * path
Definition: delegate.h:31
#define DelegateFilename
Definition: delegate.c:83
MagickExport RectangleInfo GetImageBoundingBox(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:125
static const char * DelegateMap
Definition: delegate.c:89
MagickExport ssize_t GetImageIndexInList(const Image *images)
Definition: list.c:644
MagickExport Image * GetNextImageInList(const Image *images)
Definition: list.c:752
MagickExport char * DestroyString(char *string)
Definition: string.c:810
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:97
MagickExport const char * GetImageProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:2185
MagickExport size_t GetNumberOfElementsInLinkedList(const LinkedListInfo *list_info)
Definition: linked-list.c:348
MagickExport ImageInfo * CloneImageInfo(const ImageInfo *image_info)
Definition: image.c:942
#define ExtendInterpretText(string_length)
static int access_utf8(const char *path, int mode)
#define MagickMin(x, y)
Definition: image-private.h:27
ColorspaceType
Definition: colorspace.h:25
static LinkedListInfo * AcquireDelegateCache(const char *filename, ExceptionInfo *exception)
Definition: delegate.c:179
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1038
PointInfo resolution
Definition: image.h:209
MagickExport MagickBooleanType InvokeDelegate(ImageInfo *image_info, Image *image, const char *decode, const char *encode, ExceptionInfo *exception)
Definition: delegate.c:1623
#define MagickPrivate
MagickPrivate char * FileToXML(const char *, const size_t)
Definition: xml-tree.c:600
#define MagickExport
MagickSizeType extent
Definition: image.h:270
char * encode
Definition: delegate.h:31
ssize_t y
Definition: geometry.h:133
MagickExport char ** StringToArgv(const char *text, int *argc)
Definition: string.c:2029
MagickBooleanType adjoin
Definition: image.h:375
MagickExport size_t GetImageListLength(const Image *images)
Definition: list.c:680
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
MagickExport LinkedListInfo * DestroyConfigureOptions(LinkedListInfo *options)
Definition: configure.c:326
MagickExport void LocaleUpper(char *string)
Definition: locale.c:1567
MagickExport char * ConstantString(const char *source)
Definition: string.c:687
static int DelegateInfoCompare(const void *x, const void *y)
Definition: delegate.c:1245
ColorspaceType colorspace
Definition: image.h:157
MagickBooleanType temporary
Definition: image.h:375
MagickBooleanType debug
Definition: image.h:334
size_t depth
Definition: image.h:172