MagickCore  7.0.10
string.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % SSSSS TTTTT RRRR IIIII N N GGGG %
7 % SS T R R I NN N G %
8 % SSS T RRRR I N N N G GGG %
9 % SS T R R I N NN G G %
10 % SSSSS T R R IIIII N N GGGG %
11 % %
12 % %
13 % MagickCore String Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % August 2003 %
18 % %
19 % %
20 % Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
22 % %
23 % You may not use this file except in compliance with the license. You may %
24 % obtain a copy of the license at %
25 % %
26 % https://imagemagick.org/script/license.php %
27 % %
28 % unless required by applicable law or agreed to in writing, software %
29 % distributed under the license is distributed on an "as is" basis, %
30 % without warranties or conditions of any kind, either express or implied. %
31 % See the license for the specific language governing permissions and %
32 % limitations under the license. %
33 % %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 */
38 
39 /*
40  include declarations.
41 */
42 #include "MagickCore/studio.h"
43 #include "MagickCore/blob.h"
45 #include "MagickCore/exception.h"
48 #include "MagickCore/list.h"
49 #include "MagickCore/locale_.h"
50 #include "MagickCore/log.h"
51 #include "MagickCore/memory_.h"
54 #include "MagickCore/property.h"
55 #include "MagickCore/resource_.h"
57 #include "MagickCore/string_.h"
60 
61 /*
62  Define declarations.
63 */
64 #define CharsPerLine 0x14
65 
66 /*
67  Static declarations.
68 */
69 #ifdef __VMS
70 #define asciimap AsciiMap
71 #endif
72 #if !defined(MAGICKCORE_HAVE_STRCASECMP) || !defined(MAGICKCORE_HAVE_STRNCASECMP)
73 static const unsigned char
75  {
76  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
77  0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
78  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
79  0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
80  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
81  0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
82  0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
83  0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
84  0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
85  0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
86  0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
87  0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
88  0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
89  0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
90  0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
91  0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
92  0xc0, 0xe1, 0xe2, 0xe3, 0xe4, 0xc5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
93  0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
94  0xf8, 0xf9, 0xfa, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
95  0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
96  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
97  0xfc, 0xfd, 0xfe, 0xff,
98  };
99 #endif
100 
101 /*
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 % %
104 % %
105 % %
106 % A c q u i r e S t r i n g %
107 % %
108 % %
109 % %
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 %
112 % AcquireString() returns an new extented string, containing a clone of the
113 % given string.
114 %
115 % An extended string is the string length, plus an extra MagickPathExtent space
116 % to allow for the string to be actively worked on.
117 %
118 % The returned string shoud be freed using DestoryString().
119 %
120 % The format of the AcquireString method is:
121 %
122 % char *AcquireString(const char *source)
123 %
124 % A description of each parameter follows:
125 %
126 % o source: A character string.
127 %
128 */
129 MagickExport char *AcquireString(const char *source)
130 {
131  char
132  *destination;
133 
134  size_t
135  length;
136 
137  length=0;
138  if (source != (char *) NULL)
139  length+=strlen(source);
140  if (~length < MagickPathExtent)
141  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
142  destination=(char *) AcquireQuantumMemory(length+MagickPathExtent,
143  sizeof(*destination));
144  if (destination == (char *) NULL)
145  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
146  *destination='\0';
147  if (source != (char *) NULL)
148  (void) memcpy(destination,source,length*sizeof(*destination));
149  destination[length]='\0';
150  return(destination);
151 }
152 
153 /*
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 % %
156 % %
157 % %
158 % A c q u i r e S t r i n g I n f o %
159 % %
160 % %
161 % %
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 %
164 % AcquireStringInfo() allocates the StringInfo structure.
165 %
166 % The format of the AcquireStringInfo method is:
167 %
168 % StringInfo *AcquireStringInfo(const size_t length)
169 %
170 % A description of each parameter follows:
171 %
172 % o length: the string length.
173 %
174 */
175 
177 {
178  StringInfo
179  *string_info;
180 
181  string_info=(StringInfo *) AcquireCriticalMemory(sizeof(*string_info));
182  (void) memset(string_info,0,sizeof(*string_info));
183  string_info->signature=MagickCoreSignature;
184  return(string_info);
185 }
186 
188 {
189  StringInfo
190  *string_info;
191 
192  string_info=AcquireStringInfoContainer();
193  string_info->length=length;
194  if (~string_info->length >= (MagickPathExtent-1))
195  string_info->datum=(unsigned char *) AcquireQuantumMemory(
196  string_info->length+MagickPathExtent,sizeof(*string_info->datum));
197  if (string_info->datum == (unsigned char *) NULL)
198  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
199  (void) memset(string_info->datum,0,(length+MagickPathExtent)*
200  sizeof(*string_info->datum));
201  return(string_info);
202 }
203 
204 /*
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 % %
207 % %
208 % %
209 % B l o b T o S t r i n g I n f o %
210 % %
211 % %
212 % %
213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 %
215 % BlobToStringInfo() returns the contents of a blob as a StringInfo structure
216 % with MagickPathExtent extra space.
217 %
218 % The format of the BlobToStringInfo method is:
219 %
220 % StringInfo *BlobToStringInfo(const void *blob,const size_t length)
221 %
222 % A description of each parameter follows:
223 %
224 % o blob: the blob.
225 %
226 % o length: the length of the blob.
227 %
228 */
229 MagickExport StringInfo *BlobToStringInfo(const void *blob,const size_t length)
230 {
231  StringInfo
232  *string_info;
233 
234  if (~length < MagickPathExtent)
235  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
236  string_info=AcquireStringInfoContainer();
237  string_info->length=length;
238  string_info->datum=(unsigned char *) AcquireQuantumMemory(length+
239  MagickPathExtent,sizeof(*string_info->datum));
240  if (string_info->datum == (unsigned char *) NULL)
241  {
242  string_info=DestroyStringInfo(string_info);
243  return((StringInfo *) NULL);
244  }
245  if (blob != (const void *) NULL)
246  (void) memcpy(string_info->datum,blob,length);
247  else
248  (void) memset(string_info->datum,0,length*sizeof(*string_info->datum));
249  (void) memset(string_info->datum+length,0,MagickPathExtent*
250  sizeof(*string_info->datum));
251  return(string_info);
252 }
253 
254 /*
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 % %
257 % %
258 % %
259 % C l o n e S t r i n g %
260 % %
261 % %
262 % %
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264 %
265 % CloneString() replaces or frees the destination string to make it
266 % a clone of the input string plus MagickPathExtent more space so the string
267 % may be worked on.
268 %
269 % If source is a NULL pointer the destination string will be freed and set to
270 % a NULL pointer. A pointer to the stored in the destination is also returned.
271 %
272 % When finished the non-NULL string should be freed using DestoryString()
273 % or using CloneString() with a NULL pointed for the source.
274 %
275 % The format of the CloneString method is:
276 %
277 % char *CloneString(char **destination,const char *source)
278 %
279 % A description of each parameter follows:
280 %
281 % o destination: A pointer to a character string.
282 %
283 % o source: A character string.
284 %
285 */
286 MagickExport char *CloneString(char **destination,const char *source)
287 {
288  size_t
289  length;
290 
291  assert(destination != (char **) NULL);
292  if (source == (const char *) NULL)
293  {
294  if (*destination != (char *) NULL)
295  *destination=DestroyString(*destination);
296  return(*destination);
297  }
298  if (*destination == (char *) NULL)
299  {
300  *destination=AcquireString(source);
301  return(*destination);
302  }
303  length=strlen(source);
304  if (~length < MagickPathExtent)
305  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
306  *destination=(char *) ResizeQuantumMemory(*destination,length+
307  MagickPathExtent,sizeof(**destination));
308  if (*destination == (char *) NULL)
309  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
310  if (length != 0)
311  (void) memcpy(*destination,source,length*sizeof(**destination));
312  (*destination)[length]='\0';
313  return(*destination);
314 }
315 
316 /*
317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318 % %
319 % %
320 % %
321 % C l o n e S t r i n g I n f o %
322 % %
323 % %
324 % %
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 %
327 % CloneStringInfo() clones a copy of the StringInfo structure.
328 %
329 % The format of the CloneStringInfo method is:
330 %
331 % StringInfo *CloneStringInfo(const StringInfo *string_info)
332 %
333 % A description of each parameter follows:
334 %
335 % o string_info: the string info.
336 %
337 */
339 {
340  StringInfo
341  *clone_info;
342 
343  assert(string_info != (StringInfo *) NULL);
344  assert(string_info->signature == MagickCoreSignature);
345  clone_info=AcquireStringInfo(string_info->length);
346  (void) CloneString(&clone_info->path,string_info->path);
347  (void) CloneString(&clone_info->name,string_info->name);
348  if (string_info->length != 0)
349  (void) memcpy(clone_info->datum,string_info->datum,string_info->length+1);
350  return(clone_info);
351 }
352 
353 /*
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355 % %
356 % %
357 % %
358 % C o m p a r e S t r i n g I n f o %
359 % %
360 % %
361 % %
362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363 %
364 % CompareStringInfo() compares the two datums target and source. It returns
365 % an integer less than, equal to, or greater than zero if target is found,
366 % respectively, to be less than, to match, or be greater than source.
367 %
368 % The format of the CompareStringInfo method is:
369 %
370 % int CompareStringInfo(const StringInfo *target,const StringInfo *source)
371 %
372 % A description of each parameter follows:
373 %
374 % o target: the target string.
375 %
376 % o source: the source string.
377 %
378 */
379 
381  const StringInfo *source)
382 {
383  int
384  status;
385 
386  assert(target != (StringInfo *) NULL);
387  assert(target->signature == MagickCoreSignature);
388  assert(source != (StringInfo *) NULL);
389  assert(source->signature == MagickCoreSignature);
390  status=memcmp(target->datum,source->datum,MagickMin(target->length,
391  source->length));
392  if (status != 0)
393  return(status);
394  if (target->length == source->length)
395  return(0);
396  return(target->length < source->length ? -1 : 1);
397 }
398 
399 /*
400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401 % %
402 % %
403 % %
404 % C o n c a t e n a t e M a g i c k S t r i n g %
405 % %
406 % %
407 % %
408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 %
410 % ConcatenateMagickString() concatenates the source string to the destination
411 % string. The destination buffer is always null-terminated even if the
412 % string must be truncated.
413 %
414 % The format of the ConcatenateMagickString method is:
415 %
416 % size_t ConcatenateMagickString(char *magick_restrict destination,
417 % const char *magick_restrict source,const size_t length)
418 %
419 % A description of each parameter follows:
420 %
421 % o destination: the destination string.
422 %
423 % o source: the source string.
424 %
425 % o length: the length of the destination string.
426 %
427 */
429  const char *magick_restrict source,const size_t length)
430 {
431  register char
432  *magick_restrict q;
433 
434  register const char
435  *magick_restrict p;
436 
437  register size_t
438  i;
439 
440  size_t
441  count;
442 
443  assert(destination != (char *) NULL);
444  assert(source != (const char *) NULL);
445  assert(length >= 1);
446  p=source;
447  q=destination;
448  i=length;
449  while ((i-- != 0) && (*q != '\0'))
450  q++;
451  count=(size_t) (q-destination);
452  i=length-count;
453  if (i == 0)
454  return(count+strlen(p));
455  while (*p != '\0')
456  {
457  if (i != 1)
458  {
459  *q++=(*p);
460  i--;
461  }
462  p++;
463  }
464  *q='\0';
465  return(count+(p-source));
466 }
467 
468 /*
469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
470 % %
471 % %
472 % %
473 % C o n c a t e n a t e S t r i n g %
474 % %
475 % %
476 % %
477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
478 %
479 % ConcatenateString() appends a copy of string source, including the
480 % terminating null character, to the end of string destination.
481 %
482 % The format of the ConcatenateString method is:
483 %
484 % MagickBooleanType ConcatenateString(char **magick_restrict destination,
485 % const char *magick_restrict source)
486 %
487 % A description of each parameter follows:
488 %
489 % o destination: A pointer to a character string.
490 %
491 % o source: A character string.
492 %
493 */
495  char **magick_restrict destination,const char *magick_restrict source)
496 {
497  size_t
498  destination_length,
499  length,
500  source_length;
501 
502  assert(destination != (char **) NULL);
503  if (source == (const char *) NULL)
504  return(MagickTrue);
505  if (*destination == (char *) NULL)
506  {
507  *destination=AcquireString(source);
508  return(MagickTrue);
509  }
510  destination_length=strlen(*destination);
511  source_length=strlen(source);
512  length=destination_length;
513  if (~length < source_length)
514  ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
515  length+=source_length;
516  if (~length < MagickPathExtent)
517  ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
518  *destination=(char *) ResizeQuantumMemory(*destination,length+
519  MagickPathExtent,sizeof(**destination));
520  if (*destination == (char *) NULL)
521  ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
522  if (source_length != 0)
523  (void) memcpy((*destination)+destination_length,source,source_length);
524  (*destination)[length]='\0';
525  return(MagickTrue);
526 }
527 
528 /*
529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 % %
531 % %
532 % %
533 % C o n c a t e n a t e S t r i n g I n f o %
534 % %
535 % %
536 % %
537 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
538 %
539 % ConcatenateStringInfo() concatenates the source string to the destination
540 % string.
541 %
542 % The format of the ConcatenateStringInfo method is:
543 %
544 % void ConcatenateStringInfo(StringInfo *string_info,
545 % const StringInfo *source)
546 %
547 % A description of each parameter follows:
548 %
549 % o string_info: the string info.
550 %
551 % o source: the source string.
552 %
553 */
555  const StringInfo *source)
556 {
557  size_t
558  length;
559 
560  assert(string_info != (StringInfo *) NULL);
561  assert(string_info->signature == MagickCoreSignature);
562  assert(source != (const StringInfo *) NULL);
563  length=string_info->length;
564  if (~length < source->length)
565  ThrowFatalException(ResourceLimitFatalError,"UnableToConcatenateString");
566  SetStringInfoLength(string_info,length+source->length);
567  (void) memcpy(string_info->datum+length,source->datum,source->length);
568 }
569 
570 /*
571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 % %
573 % %
574 % %
575 % C o n f i g u r e F i l e T o S t r i n g I n f o %
576 % %
577 % %
578 % %
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580 %
581 % ConfigureFileToStringInfo() returns the contents of a configure file as a
582 % string.
583 %
584 % The format of the ConfigureFileToStringInfo method is:
585 %
586 % StringInfo *ConfigureFileToStringInfo(const char *filename)
587 % ExceptionInfo *exception)
588 %
589 % A description of each parameter follows:
590 %
591 % o filename: the filename.
592 %
593 */
595 {
596  char
597  *string;
598 
599  int
600  file;
601 
603  offset;
604 
605  size_t
606  length;
607 
608  StringInfo
609  *string_info;
610 
611  void
612  *map;
613 
614  assert(filename != (const char *) NULL);
615  file=open_utf8(filename,O_RDONLY | O_BINARY,0);
616  if (file == -1)
617  return((StringInfo *) NULL);
618  offset=(MagickOffsetType) lseek(file,0,SEEK_END);
619  if ((offset < 0) || (offset != (MagickOffsetType) ((ssize_t) offset)))
620  {
621  file=close(file)-1;
622  return((StringInfo *) NULL);
623  }
624  length=(size_t) offset;
625  string=(char *) NULL;
626  if (~length >= (MagickPathExtent-1))
627  string=(char *) AcquireQuantumMemory(length+MagickPathExtent,
628  sizeof(*string));
629  if (string == (char *) NULL)
630  {
631  file=close(file)-1;
632  return((StringInfo *) NULL);
633  }
634  map=MapBlob(file,ReadMode,0,length);
635  if (map != (void *) NULL)
636  {
637  (void) memcpy(string,map,length);
638  (void) UnmapBlob(map,length);
639  }
640  else
641  {
642  register size_t
643  i;
644 
645  ssize_t
646  count;
647 
648  (void) lseek(file,0,SEEK_SET);
649  for (i=0; i < length; i+=count)
650  {
651  count=read(file,string+i,(size_t) MagickMin(length-i,(size_t)
652  SSIZE_MAX));
653  if (count <= 0)
654  {
655  count=0;
656  if (errno != EINTR)
657  break;
658  }
659  }
660  if (i < length)
661  {
662  file=close(file)-1;
663  string=DestroyString(string);
664  return((StringInfo *) NULL);
665  }
666  }
667  string[length]='\0';
668  file=close(file)-1;
669  string_info=AcquireStringInfoContainer();
670  string_info->path=ConstantString(filename);
671  string_info->length=length;
672  string_info->datum=(unsigned char *) string;
673  return(string_info);
674 }
675 
676 /*
677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
678 % %
679 % %
680 % %
681 % C o n s t a n t S t r i n g %
682 % %
683 % %
684 % %
685 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
686 %
687 % ConstantString() allocates exactly the needed memory for a string and
688 % copies the source string to that memory location. A NULL string pointer
689 % will allocate an empty string containing just the NUL character.
690 %
691 % When finished the string should be freed using DestoryString()
692 %
693 % The format of the ConstantString method is:
694 %
695 % char *ConstantString(const char *source)
696 %
697 % A description of each parameter follows:
698 %
699 % o source: A character string.
700 %
701 */
702 MagickExport char *ConstantString(const char *source)
703 {
704  char
705  *destination;
706 
707  size_t
708  length;
709 
710  length=0;
711  if (source != (char *) NULL)
712  length+=strlen(source);
713  destination=(char *) NULL;
714  if (~length >= 1UL)
715  destination=(char *) AcquireQuantumMemory(length+1UL,sizeof(*destination));
716  if (destination == (char *) NULL)
717  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
718  *destination='\0';
719  if (source != (char *) NULL)
720  (void) memcpy(destination,source,length*sizeof(*destination));
721  destination[length]='\0';
722  return(destination);
723 }
724 
725 /*
726 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
727 % %
728 % %
729 % %
730 % C o p y M a g i c k S t r i n g %
731 % %
732 % %
733 % %
734 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
735 %
736 % CopyMagickString() copies the source string to the destination string, with
737 % out exceeding the given pre-declared length.
738 %
739 % The destination buffer is always null-terminated even if the string must be
740 % truncated. The return value is the length of the string.
741 %
742 % The format of the CopyMagickString method is:
743 %
744 % size_t CopyMagickString(const char *magick_restrict destination,
745 % char *magick_restrict source,const size_t length)
746 %
747 % A description of each parameter follows:
748 %
749 % o destination: the destination string.
750 %
751 % o source: the source string.
752 %
753 % o length: the length of the destination string.
754 %
755 */
757  const char *magick_restrict source,const size_t length)
758 {
759  register char
760  *magick_restrict q;
761 
762  register const char
763  *magick_restrict p;
764 
765  register size_t
766  n;
767 
768  p=source;
769  q=destination;
770  for (n=length; n > 4; n-=4)
771  {
772  if (((*q++)=(*p++)) == '\0')
773  return((size_t) (p-source-1));
774  if (((*q++)=(*p++)) == '\0')
775  return((size_t) (p-source-1));
776  if (((*q++)=(*p++)) == '\0')
777  return((size_t) (p-source-1));
778  if (((*q++)=(*p++)) == '\0')
779  return((size_t) (p-source-1));
780  }
781  if (length != 0)
782  {
783  while (--n != 0)
784  if (((*q++)=(*p++)) == '\0')
785  return((size_t) (p-source-1));
786  *q='\0';
787  }
788  return((size_t) (p-source));
789 }
790 
791 /*
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
793 % %
794 % %
795 % %
796 % D e s t r o y S t r i n g %
797 % %
798 % %
799 % %
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
801 %
802 % DestroyString() destroys memory associated with a string.
803 %
804 % The format of the DestroyString method is:
805 %
806 % char *DestroyString(char *string)
807 %
808 % A description of each parameter follows:
809 %
810 % o string: the string.
811 %
812 */
813 MagickExport char *DestroyString(char *string)
814 {
815  return((char *) RelinquishMagickMemory(string));
816 }
817 
818 /*
819 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
820 % %
821 % %
822 % %
823 % D e s t r o y S t r i n g I n f o %
824 % %
825 % %
826 % %
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 %
829 % DestroyStringInfo() destroys memory associated with the StringInfo structure.
830 %
831 % The format of the DestroyStringInfo method is:
832 %
833 % StringInfo *DestroyStringInfo(StringInfo *string_info)
834 %
835 % A description of each parameter follows:
836 %
837 % o string_info: the string info.
838 %
839 */
841 {
842  assert(string_info != (StringInfo *) NULL);
843  assert(string_info->signature == MagickCoreSignature);
844  if (string_info->datum != (unsigned char *) NULL)
845  string_info->datum=(unsigned char *) RelinquishMagickMemory(
846  string_info->datum);
847  if (string_info->name != (char *) NULL)
848  string_info->name=DestroyString(string_info->name);
849  if (string_info->path != (char *) NULL)
850  string_info->path=DestroyString(string_info->path);
851  string_info->signature=(~MagickCoreSignature);
852  string_info=(StringInfo *) RelinquishMagickMemory(string_info);
853  return(string_info);
854 }
855 
856 /*
857 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
858 % %
859 % %
860 % %
861 % D e s t r o y S t r i n g L i s t %
862 % %
863 % %
864 % %
865 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 %
867 % DestroyStringList() zeros memory associated with a string list.
868 %
869 % The format of the DestroyStringList method is:
870 %
871 % char **DestroyStringList(char **list)
872 %
873 % A description of each parameter follows:
874 %
875 % o list: the string list.
876 %
877 */
878 MagickExport char **DestroyStringList(char **list)
879 {
880  register ssize_t
881  i;
882 
883  assert(list != (char **) NULL);
884  for (i=0; list[i] != (char *) NULL; i++)
885  list[i]=DestroyString(list[i]);
886  list=(char **) RelinquishMagickMemory(list);
887  return(list);
888 }
889 
890 /*
891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
892 % %
893 % %
894 % %
895 % E s c a p e S t r i n g %
896 % %
897 % %
898 % %
899 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
900 %
901 % EscapeString() allocates memory for a backslash-escaped version of a
902 % source text string, copies the escaped version of the text to that
903 % memory location while adding backslash characters, and returns the
904 % escaped string.
905 %
906 % The format of the EscapeString method is:
907 %
908 % char *EscapeString(const char *source,const char escape)
909 %
910 % A description of each parameter follows:
911 %
912 % o allocate_string: Method EscapeString returns the escaped string.
913 %
914 % o source: A character string.
915 %
916 % o escape: the quoted string termination character to escape (e.g. '"').
917 %
918 */
919 MagickExport char *EscapeString(const char *source,const char escape)
920 {
921  char
922  *destination;
923 
924  register char
925  *q;
926 
927  register const char
928  *p;
929 
930  size_t
931  length;
932 
933  assert(source != (const char *) NULL);
934  length=0;
935  for (p=source; *p != '\0'; p++)
936  {
937  if ((*p == '\\') || (*p == escape))
938  {
939  if (~length < 1)
940  ThrowFatalException(ResourceLimitFatalError,"UnableToEscapeString");
941  length++;
942  }
943  length++;
944  }
945  destination=(char *) NULL;
946  if (~length >= (MagickPathExtent-1))
947  destination=(char *) AcquireQuantumMemory(length+MagickPathExtent,
948  sizeof(*destination));
949  if (destination == (char *) NULL)
950  ThrowFatalException(ResourceLimitFatalError,"UnableToEscapeString");
951  *destination='\0';
952  q=destination;
953  for (p=source; *p != '\0'; p++)
954  {
955  if ((*p == '\\') || (*p == escape))
956  *q++='\\';
957  *q++=(*p);
958  }
959  *q='\0';
960  return(destination);
961 }
962 
963 /*
964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
965 % %
966 % %
967 % %
968 % F i l e T o S t r i n g %
969 % %
970 % %
971 % %
972 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
973 %
974 % FileToString() returns the contents of a file as a string.
975 %
976 % The format of the FileToString method is:
977 %
978 % char *FileToString(const char *filename,const size_t extent,
979 % ExceptionInfo *exception)
980 %
981 % A description of each parameter follows:
982 %
983 % o filename: the filename.
984 %
985 % o extent: Maximum length of the string.
986 %
987 % o exception: return any errors or warnings in this structure.
988 %
989 */
990 MagickExport char *FileToString(const char *filename,const size_t extent,
992 {
993  size_t
994  length;
995 
996  assert(filename != (const char *) NULL);
997  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
998  assert(exception != (ExceptionInfo *) NULL);
999  return((char *) FileToBlob(filename,extent,&length,exception));
1000 }
1001 
1002 /*
1003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 % %
1005 % %
1006 % %
1007 % F i l e T o S t r i n g I n f o %
1008 % %
1009 % %
1010 % %
1011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 %
1013 % FileToStringInfo() returns the contents of a file as a string.
1014 %
1015 % The format of the FileToStringInfo method is:
1016 %
1017 % StringInfo *FileToStringInfo(const char *filename,const size_t extent,
1018 % ExceptionInfo *exception)
1019 %
1020 % A description of each parameter follows:
1021 %
1022 % o filename: the filename.
1023 %
1024 % o extent: Maximum length of the string.
1025 %
1026 % o exception: return any errors or warnings in this structure.
1027 %
1028 */
1030  const size_t extent,ExceptionInfo *exception)
1031 {
1032  StringInfo
1033  *string_info;
1034 
1035  assert(filename != (const char *) NULL);
1036  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
1037  assert(exception != (ExceptionInfo *) NULL);
1038  string_info=AcquireStringInfoContainer();
1039  string_info->path=ConstantString(filename);
1040  string_info->datum=(unsigned char *) FileToBlob(filename,extent,
1041  &string_info->length,exception);
1042  if (string_info->datum == (unsigned char *) NULL)
1043  {
1044  string_info=DestroyStringInfo(string_info);
1045  return((StringInfo *) NULL);
1046  }
1047  return(string_info);
1048 }
1049 
1050 /*
1051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1052 % %
1053 % %
1054 % %
1055 % F o r m a t M a g i c k S i z e %
1056 % %
1057 % %
1058 % %
1059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1060 %
1061 % FormatMagickSize() converts a size to a human readable format, for example,
1062 % 14k, 234m, 2.7g, or 3.0t. Scaling is done by repetitively dividing by
1063 % 1000.
1064 %
1065 % The format of the FormatMagickSize method is:
1066 %
1067 % ssize_t FormatMagickSize(const MagickSizeType size,const char *suffix,
1068 % const size_t length,char *format)
1069 %
1070 % A description of each parameter follows:
1071 %
1072 % o size: convert this size to a human readable format.
1073 %
1074 % o bi: use power of two rather than power of ten.
1075 %
1076 % o suffix: append suffix, typically B or P.
1077 %
1078 % o length: the maximum length of the string.
1079 %
1080 % o format: human readable format.
1081 %
1082 */
1084  const MagickBooleanType bi,const char *suffix,const size_t length,
1085  char *format)
1086 {
1087  char
1088  p[MagickPathExtent],
1089  q[MagickPathExtent];
1090 
1091  const char
1092  **units;
1093 
1094  double
1095  bytes,
1096  extent;
1097 
1098  register ssize_t
1099  i;
1100 
1101  ssize_t
1102  count;
1103 
1104  static const char
1105  *bi_units[] =
1106  {
1107  "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi", (char *) NULL
1108  },
1109  *traditional_units[] =
1110  {
1111  "", "K", "M", "G", "T", "P", "E", "Z", "Y", (char *) NULL
1112  };
1113 
1114  bytes=1000.0;
1115  units=traditional_units;
1116  if (bi != MagickFalse)
1117  {
1118  bytes=1024.0;
1119  units=bi_units;
1120  }
1121 #if defined(_MSC_VER) && (_MSC_VER == 1200)
1122  extent=(double) ((MagickOffsetType) size);
1123 #else
1124  extent=(double) size;
1125 #endif
1127  extent);
1128  (void) FormatLocaleString(q,MagickPathExtent,"%.20g",extent);
1129  if (strtod(p,(char **) NULL) == strtod(q,(char **) NULL))
1130  {
1131  if (suffix == (const char *) NULL)
1132  count=FormatLocaleString(format,length,"%.20g%s",extent,units[0]);
1133  else
1134  count=FormatLocaleString(format,length,"%.20g%s%s",extent,units[0],
1135  suffix);
1136  return(count);
1137  }
1138  for (i=0; (extent >= bytes) && (units[i+1] != (const char *) NULL); i++)
1139  extent/=bytes;
1140  if (suffix == (const char *) NULL)
1141  count=FormatLocaleString(format,length,"%.*g%s",GetMagickPrecision(),
1142  extent,units[i]);
1143  else
1144  count=FormatLocaleString(format,length,"%.*g%s%s",GetMagickPrecision(),
1145  extent,units[i],suffix);
1146  return(count);
1147 }
1148 
1149 /*
1150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1151 % %
1152 % %
1153 % %
1154 % G e t E n v i r o n m e n t V a l u e %
1155 % %
1156 % %
1157 % %
1158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1159 %
1160 % GetEnvironmentValue() returns the environment string that matches the
1161 % specified name.
1162 %
1163 % The format of the GetEnvironmentValue method is:
1164 %
1165 % char *GetEnvironmentValue(const char *name)
1166 %
1167 % A description of each parameter follows:
1168 %
1169 % o name: the environment name.
1170 %
1171 */
1172 MagickExport char *GetEnvironmentValue(const char *name)
1173 {
1174  const char
1175  *environment;
1176 
1177  environment=getenv(name);
1178  if (environment == (const char *) NULL)
1179  return((char *) NULL);
1180  return(ConstantString(environment));
1181 }
1182 
1183 /*
1184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1185 % %
1186 % %
1187 % %
1188 % G e t S t r i n g I n f o D a t u m %
1189 % %
1190 % %
1191 % %
1192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1193 %
1194 % GetStringInfoDatum() returns the datum associated with the string.
1195 %
1196 % The format of the GetStringInfoDatum method is:
1197 %
1198 % unsigned char *GetStringInfoDatum(const StringInfo *string_info)
1199 %
1200 % A description of each parameter follows:
1201 %
1202 % o string_info: the string info.
1203 %
1204 */
1205 MagickExport unsigned char *GetStringInfoDatum(const StringInfo *string_info)
1206 {
1207  assert(string_info != (StringInfo *) NULL);
1208  assert(string_info->signature == MagickCoreSignature);
1209  return(string_info->datum);
1210 }
1211 
1212 /*
1213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 % %
1215 % %
1216 % %
1217 % G e t S t r i n g I n f o L e n g t h %
1218 % %
1219 % %
1220 % %
1221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1222 %
1223 % GetStringInfoLength() returns the string length.
1224 %
1225 % The format of the GetStringInfoLength method is:
1226 %
1227 % size_t GetStringInfoLength(const StringInfo *string_info)
1228 %
1229 % A description of each parameter follows:
1230 %
1231 % o string_info: the string info.
1232 %
1233 */
1234 MagickExport size_t GetStringInfoLength(const StringInfo *string_info)
1235 {
1236  assert(string_info != (StringInfo *) NULL);
1237  assert(string_info->signature == MagickCoreSignature);
1238  return(string_info->length);
1239 }
1240 
1241 /*
1242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1243 % %
1244 % %
1245 % %
1246 % G e t S t r i n g I n f o N a m e %
1247 % %
1248 % %
1249 % %
1250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1251 %
1252 % GetStringInfoName() returns the name associated with the string.
1253 %
1254 % The format of the GetStringInfoName method is:
1255 %
1256 % const char *GetStringInfoName(const StringInfo *string_info)
1257 %
1258 % A description of each parameter follows:
1259 %
1260 % o string_info: the string info.
1261 %
1262 */
1263 MagickExport const char *GetStringInfoName(const StringInfo *string_info)
1264 {
1265  assert(string_info != (StringInfo *) NULL);
1266  assert(string_info->signature == MagickCoreSignature);
1267  return(string_info->name);
1268 }
1269 
1270 /*
1271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1272 % %
1273 % %
1274 % %
1275 % G e t S t r i n g I n f o P a t h %
1276 % %
1277 % %
1278 % %
1279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1280 %
1281 % GetStringInfoPath() returns the path associated with the string.
1282 %
1283 % The format of the GetStringInfoPath method is:
1284 %
1285 % const char *GetStringInfoPath(const StringInfo *string_info)
1286 %
1287 % A description of each parameter follows:
1288 %
1289 % o string_info: the string info.
1290 %
1291 */
1292 MagickExport const char *GetStringInfoPath(const StringInfo *string_info)
1293 {
1294  assert(string_info != (StringInfo *) NULL);
1295  assert(string_info->signature == MagickCoreSignature);
1296  return(string_info->path);
1297 }
1298 
1299 /*
1300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1301 % %
1302 % %
1303 % %
1304 + I n t e r p r e t S i P r e f i x V a l u e %
1305 % %
1306 % %
1307 % %
1308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1309 %
1310 % InterpretSiPrefixValue() converts the initial portion of the string to a
1311 % double representation. It also recognizes SI prefixes (e.g. B, KB, MiB,
1312 % etc.).
1313 %
1314 % The format of the InterpretSiPrefixValue method is:
1315 %
1316 % double InterpretSiPrefixValue(const char *value,char **sentinal)
1317 %
1318 % A description of each parameter follows:
1319 %
1320 % o value: the string value.
1321 %
1322 % o sentinal: if sentinal is not NULL, return a pointer to the character
1323 % after the last character used in the conversion.
1324 %
1325 */
1327  char **magick_restrict sentinal)
1328 {
1329  char
1330  *q;
1331 
1332  double
1333  value;
1334 
1335  value=InterpretLocaleValue(string,&q);
1336  if (q != string)
1337  {
1338  if ((*q >= 'E') && (*q <= 'z'))
1339  {
1340  double
1341  e;
1342 
1343  switch ((int) ((unsigned char) *q))
1344  {
1345  case 'y': e=(-24.0); break;
1346  case 'z': e=(-21.0); break;
1347  case 'a': e=(-18.0); break;
1348  case 'f': e=(-15.0); break;
1349  case 'p': e=(-12.0); break;
1350  case 'n': e=(-9.0); break;
1351  case 'u': e=(-6.0); break;
1352  case 'm': e=(-3.0); break;
1353  case 'c': e=(-2.0); break;
1354  case 'd': e=(-1.0); break;
1355  case 'h': e=2.0; break;
1356  case 'k': e=3.0; break;
1357  case 'K': e=3.0; break;
1358  case 'M': e=6.0; break;
1359  case 'G': e=9.0; break;
1360  case 'T': e=12.0; break;
1361  case 'P': e=15.0; break;
1362  case 'E': e=18.0; break;
1363  case 'Z': e=21.0; break;
1364  case 'Y': e=24.0; break;
1365  default: e=0.0; break;
1366  }
1367  if (e >= MagickEpsilon)
1368  {
1369  if (q[1] == 'i')
1370  {
1371  value*=pow(2.0,e/0.3);
1372  q+=2;
1373  }
1374  else
1375  {
1376  value*=pow(10.0,e);
1377  q++;
1378  }
1379  }
1380  }
1381  if ((*q == 'B') || (*q == 'P'))
1382  q++;
1383  }
1384  if (sentinal != (char **) NULL)
1385  *sentinal=q;
1386  return(value);
1387 }
1388 
1389 /*
1390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1391 % %
1392 % %
1393 % %
1394 % I s S t r i n g T r u e %
1395 % %
1396 % %
1397 % %
1398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1399 %
1400 % IsStringTrue() returns MagickTrue if the value is "true", "on", "yes" or
1401 % "1". Any other string or undefined returns MagickFalse.
1402 %
1403 % Typically this is used to look at strings (options or artifacts) which
1404 % has a default value of "false", when not defined.
1405 %
1406 % The format of the IsStringTrue method is:
1407 %
1408 % MagickBooleanType IsStringTrue(const char *value)
1409 %
1410 % A description of each parameter follows:
1411 %
1412 % o value: Specifies a pointer to a character array.
1413 %
1414 */
1416 {
1417  if (value == (const char *) NULL)
1418  return(MagickFalse);
1419  if (LocaleCompare(value,"true") == 0)
1420  return(MagickTrue);
1421  if (LocaleCompare(value,"on") == 0)
1422  return(MagickTrue);
1423  if (LocaleCompare(value,"yes") == 0)
1424  return(MagickTrue);
1425  if (LocaleCompare(value,"1") == 0)
1426  return(MagickTrue);
1427  return(MagickFalse);
1428 }
1429 
1430 /*
1431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1432 % %
1433 % %
1434 % %
1435 % I s S t r i n g F a l s e %
1436 % %
1437 % %
1438 % %
1439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1440 %
1441 % IsStringFalse() returns MagickTrue if the value is "false", "off", "no" or
1442 % "0". Any other string or undefined returns MagickFalse.
1443 %
1444 % Typically this is used to look at strings (options or artifacts) which
1445 % has a default value of "true", when it has not been defined.
1446 %
1447 % The format of the IsStringFalse method is:
1448 %
1449 % MagickBooleanType IsStringFalse(const char *value)
1450 %
1451 % A description of each parameter follows:
1452 %
1453 % o value: Specifies a pointer to a character array.
1454 %
1455 */
1457 {
1458  if (value == (const char *) NULL)
1459  return(MagickFalse);
1460  if (LocaleCompare(value,"false") == 0)
1461  return(MagickTrue);
1462  if (LocaleCompare(value,"off") == 0)
1463  return(MagickTrue);
1464  if (LocaleCompare(value,"no") == 0)
1465  return(MagickTrue);
1466  if (LocaleCompare(value,"0") == 0)
1467  return(MagickTrue);
1468  return(MagickFalse);
1469 }
1470 
1471 /*
1472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1473 % %
1474 % %
1475 % %
1476 % P r i n t S t r i n g I n f o %
1477 % %
1478 % %
1479 % %
1480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1481 %
1482 % PrintStringInfo() prints the string.
1483 %
1484 % The format of the PrintStringInfo method is:
1485 %
1486 % void PrintStringInfo(FILE *file,const char *id,
1487 % const StringInfo *string_info)
1488 %
1489 % A description of each parameter follows:
1490 %
1491 % o file: the file, typically stdout.
1492 %
1493 % o id: the string id.
1494 %
1495 % o string_info: the string info.
1496 %
1497 */
1498 MagickExport void PrintStringInfo(FILE *file,const char *id,
1499  const StringInfo *string_info)
1500 {
1501  register const char
1502  *p;
1503 
1504  register size_t
1505  i,
1506  j;
1507 
1508  assert(id != (const char *) NULL);
1509  assert(string_info != (StringInfo *) NULL);
1510  assert(string_info->signature == MagickCoreSignature);
1511  p=(char *) string_info->datum;
1512  for (i=0; i < string_info->length; i++)
1513  {
1514  if (((int) ((unsigned char) *p) < 32) &&
1515  (isspace((int) ((unsigned char) *p)) == 0))
1516  break;
1517  p++;
1518  }
1519  (void) FormatLocaleFile(file,"%s(%.20g):\n",id,(double) string_info->length);
1520  if (i == string_info->length)
1521  {
1522  for (i=0; i < string_info->length; i++)
1523  (void) fputc(string_info->datum[i],file);
1524  (void) fputc('\n',file);
1525  return;
1526  }
1527  /*
1528  Convert string to a HEX list.
1529  */
1530  p=(char *) string_info->datum;
1531  for (i=0; i < string_info->length; i+=CharsPerLine)
1532  {
1533  (void) FormatLocaleFile(file,"0x%08lx: ",(unsigned long) (CharsPerLine*i));
1534  for (j=1; j <= MagickMin(string_info->length-i,CharsPerLine); j++)
1535  {
1536  (void) FormatLocaleFile(file,"%02lx",(unsigned long) (*(p+j)) & 0xff);
1537  if ((j % 0x04) == 0)
1538  (void) fputc(' ',file);
1539  }
1540  for ( ; j <= CharsPerLine; j++)
1541  {
1542  (void) fputc(' ',file);
1543  (void) fputc(' ',file);
1544  if ((j % 0x04) == 0)
1545  (void) fputc(' ',file);
1546  }
1547  (void) fputc(' ',file);
1548  for (j=1; j <= MagickMin(string_info->length-i,CharsPerLine); j++)
1549  {
1550  if (isprint((int) ((unsigned char) *p)) != 0)
1551  (void) fputc(*p,file);
1552  else
1553  (void) fputc('-',file);
1554  p++;
1555  }
1556  (void) fputc('\n',file);
1557  }
1558 }
1559 
1560 /*
1561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1562 % %
1563 % %
1564 % %
1565 % R e s e t S t r i n g I n f o %
1566 % %
1567 % %
1568 % %
1569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1570 %
1571 % ResetStringInfo() reset the string to all null bytes.
1572 %
1573 % The format of the ResetStringInfo method is:
1574 %
1575 % void ResetStringInfo(StringInfo *string_info)
1576 %
1577 % A description of each parameter follows:
1578 %
1579 % o string_info: the string info.
1580 %
1581 */
1583 {
1584  assert(string_info != (StringInfo *) NULL);
1585  assert(string_info->signature == MagickCoreSignature);
1586  (void) memset(string_info->datum,0,string_info->length);
1587 }
1588 
1589 /*
1590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1591 % %
1592 % %
1593 % %
1594 % S a n t i z e S t r i n g %
1595 % %
1596 % %
1597 % %
1598 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1599 %
1600 % SanitizeString() returns n new string removes all characters except
1601 % letters, digits and !#$%&'*+-=?^_`{|}~@.[].
1602 %
1603 % Free the sanitized string with DestroyString().
1604 %
1605 % The format of the SanitizeString method is:
1606 %
1607 % char *SanitizeString(const char *source)
1608 %
1609 % A description of each parameter follows:
1610 %
1611 % o source: A character string.
1612 %
1613 */
1614 MagickExport char *SanitizeString(const char *source)
1615 {
1616  char
1617  *sanitize_source;
1618 
1619  const char
1620  *q;
1621 
1622  register char
1623  *p;
1624 
1625  static char
1626  whitelist[] =
1627  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
1628  "$-_.+!*'(),{}|\\^~[]`\"><#%;/?:@&=";
1629 
1630  sanitize_source=AcquireString(source);
1631  p=sanitize_source;
1632  q=sanitize_source+strlen(sanitize_source);
1633  for (p+=strspn(p,whitelist); p != q; p+=strspn(p,whitelist))
1634  *p='_';
1635  return(sanitize_source);
1636 }
1637 
1638 /*
1639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1640 % %
1641 % %
1642 % %
1643 % S e t S t r i n g I n f o %
1644 % %
1645 % %
1646 % %
1647 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1648 %
1649 % SetStringInfo() copies the source string to the destination string.
1650 %
1651 % The format of the SetStringInfo method is:
1652 %
1653 % void SetStringInfo(StringInfo *string_info,const StringInfo *source)
1654 %
1655 % A description of each parameter follows:
1656 %
1657 % o string_info: the string info.
1658 %
1659 % o source: the source string.
1660 %
1661 */
1663  const StringInfo *source)
1664 {
1665  assert(string_info != (StringInfo *) NULL);
1666  assert(string_info->signature == MagickCoreSignature);
1667  assert(source != (StringInfo *) NULL);
1668  assert(source->signature == MagickCoreSignature);
1669  if (string_info->length == 0)
1670  return;
1671  (void) memset(string_info->datum,0,string_info->length);
1672  (void) memcpy(string_info->datum,source->datum,MagickMin(string_info->length,
1673  source->length));
1674 }
1675 
1676 /*
1677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1678 % %
1679 % %
1680 % %
1681 % S e t S t r i n g I n f o D a t u m %
1682 % %
1683 % %
1684 % %
1685 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1686 %
1687 % SetStringInfoDatum() copies bytes from the source string for the length of
1688 % the destination string.
1689 %
1690 % The format of the SetStringInfoDatum method is:
1691 %
1692 % void SetStringInfoDatum(StringInfo *string_info,
1693 % const unsigned char *source)
1694 %
1695 % A description of each parameter follows:
1696 %
1697 % o string_info: the string info.
1698 %
1699 % o source: the source string.
1700 %
1701 */
1703  const unsigned char *source)
1704 {
1705  assert(string_info != (StringInfo *) NULL);
1706  assert(string_info->signature == MagickCoreSignature);
1707  if (string_info->length != 0)
1708  (void) memcpy(string_info->datum,source,string_info->length);
1709 }
1710 
1711 /*
1712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1713 % %
1714 % %
1715 % %
1716 % S e t S t r i n g I n f o L e n g t h %
1717 % %
1718 % %
1719 % %
1720 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1721 %
1722 % SetStringInfoLength() set the string length to the specified value.
1723 %
1724 % The format of the SetStringInfoLength method is:
1725 %
1726 % void SetStringInfoLength(StringInfo *string_info,const size_t length)
1727 %
1728 % A description of each parameter follows:
1729 %
1730 % o string_info: the string info.
1731 %
1732 % o length: the string length.
1733 %
1734 */
1736  const size_t length)
1737 {
1738  assert(string_info != (StringInfo *) NULL);
1739  assert(string_info->signature == MagickCoreSignature);
1740  if (string_info->length == length)
1741  return;
1742  if (~length < MagickPathExtent)
1743  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1744  string_info->length=length;
1745  if (string_info->datum == (unsigned char *) NULL)
1746  string_info->datum=(unsigned char *) AcquireQuantumMemory(length+
1747  MagickPathExtent,sizeof(*string_info->datum));
1748  else
1749  string_info->datum=(unsigned char *) ResizeQuantumMemory(string_info->datum,
1750  length+MagickPathExtent,sizeof(*string_info->datum));
1751  if (string_info->datum == (unsigned char *) NULL)
1752  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1753 }
1754 
1755 /*
1756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1757 % %
1758 % %
1759 % %
1760 % S e t S t r i n g I n f o N a m e %
1761 % %
1762 % %
1763 % %
1764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1765 %
1766 % SetStringInfoName() sets the name associated with the string.
1767 %
1768 % The format of the SetStringInfoName method is:
1769 %
1770 % void SetStringInfoName(StringInfo *string_info,const char *name)
1771 %
1772 % A description of each parameter follows:
1773 %
1774 % o string_info: the string info.
1775 %
1776 % o name: the name.
1777 %
1778 */
1779 MagickExport void SetStringInfoName(StringInfo *string_info,const char *name)
1780 {
1781  assert(string_info != (StringInfo *) NULL);
1782  assert(string_info->signature == MagickCoreSignature);
1783  assert(name != (const char *) NULL);
1784  string_info->name=ConstantString(name);
1785 }
1786 
1787 /*
1788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1789 % %
1790 % %
1791 % %
1792 % S e t S t r i n g I n f o P a t h %
1793 % %
1794 % %
1795 % %
1796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1797 %
1798 % SetStringInfoPath() sets the path associated with the string.
1799 %
1800 % The format of the SetStringInfoPath method is:
1801 %
1802 % void SetStringInfoPath(StringInfo *string_info,const char *path)
1803 %
1804 % A description of each parameter follows:
1805 %
1806 % o string_info: the string info.
1807 %
1808 % o path: the path.
1809 %
1810 */
1811 MagickExport void SetStringInfoPath(StringInfo *string_info,const char *path)
1812 {
1813  assert(string_info != (StringInfo *) NULL);
1814  assert(string_info->signature == MagickCoreSignature);
1815  assert(path != (const char *) NULL);
1816  string_info->path=ConstantString(path);
1817 }
1818 
1819 /*
1820 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1821 % %
1822 % %
1823 % %
1824 % S p l i t S t r i n g I n f o %
1825 % %
1826 % %
1827 % %
1828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1829 %
1830 % SplitStringInfo() splits a string into two and returns it.
1831 %
1832 % The format of the SplitStringInfo method is:
1833 %
1834 % StringInfo *SplitStringInfo(StringInfo *string_info,const size_t offset)
1835 %
1836 % A description of each parameter follows:
1837 %
1838 % o string_info: the string info.
1839 %
1840 */
1842  const size_t offset)
1843 {
1844  StringInfo
1845  *split_info;
1846 
1847  assert(string_info != (StringInfo *) NULL);
1848  assert(string_info->signature == MagickCoreSignature);
1849  if (offset > string_info->length)
1850  return((StringInfo *) NULL);
1851  split_info=AcquireStringInfo(offset);
1852  SetStringInfo(split_info,string_info);
1853  (void) memmove(string_info->datum,string_info->datum+offset,
1854  string_info->length-offset+MagickPathExtent);
1855  SetStringInfoLength(string_info,string_info->length-offset);
1856  return(split_info);
1857 }
1858 
1859 /*
1860 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1861 % %
1862 % %
1863 % %
1864 % S t r i n g I n f o T o S t r i n g %
1865 % %
1866 % %
1867 % %
1868 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1869 %
1870 % StringInfoToString() converts a string info string to a C string.
1871 %
1872 % The format of the StringInfoToString method is:
1873 %
1874 % char *StringInfoToString(const StringInfo *string_info)
1875 %
1876 % A description of each parameter follows:
1877 %
1878 % o string_info: the string.
1879 %
1880 */
1881 MagickExport char *StringInfoToString(const StringInfo *string_info)
1882 {
1883  char
1884  *string;
1885 
1886  size_t
1887  length;
1888 
1889  string=(char *) NULL;
1890  length=string_info->length;
1891  if (~length >= (MagickPathExtent-1))
1892  string=(char *) AcquireQuantumMemory(length+MagickPathExtent,
1893  sizeof(*string));
1894  if (string == (char *) NULL)
1895  return((char *) NULL);
1896  (void) memcpy(string,(char *) string_info->datum,length*sizeof(*string));
1897  string[length]='\0';
1898  return(string);
1899 }
1900 
1901 /*
1902 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1903 % %
1904 % %
1905 % %
1906 % S t r i n g I n f o T o H e x S t r i n g %
1907 % %
1908 % %
1909 % %
1910 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1911 %
1912 % StringInfoToHexString() converts a string info string to a C string.
1913 %
1914 % The format of the StringInfoToHexString method is:
1915 %
1916 % char *StringInfoToHexString(const StringInfo *string_info)
1917 %
1918 % A description of each parameter follows:
1919 %
1920 % o string_info: the string.
1921 %
1922 */
1924 {
1925  char
1926  *string;
1927 
1928  register const unsigned char
1929  *p;
1930 
1931  register ssize_t
1932  i;
1933 
1934  register unsigned char
1935  *q;
1936 
1937  size_t
1938  length;
1939 
1940  unsigned char
1941  hex_digits[16];
1942 
1943  length=string_info->length;
1944  if (~length < MagickPathExtent)
1945  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
1946  string=(char *) AcquireQuantumMemory(length+MagickPathExtent,2*
1947  sizeof(*string));
1948  if (string == (char *) NULL)
1949  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
1950  hex_digits[0]='0';
1951  hex_digits[1]='1';
1952  hex_digits[2]='2';
1953  hex_digits[3]='3';
1954  hex_digits[4]='4';
1955  hex_digits[5]='5';
1956  hex_digits[6]='6';
1957  hex_digits[7]='7';
1958  hex_digits[8]='8';
1959  hex_digits[9]='9';
1960  hex_digits[10]='a';
1961  hex_digits[11]='b';
1962  hex_digits[12]='c';
1963  hex_digits[13]='d';
1964  hex_digits[14]='e';
1965  hex_digits[15]='f';
1966  p=string_info->datum;
1967  q=(unsigned char *) string;
1968  for (i=0; i < (ssize_t) string_info->length; i++)
1969  {
1970  *q++=hex_digits[(*p >> 4) & 0x0f];
1971  *q++=hex_digits[*p & 0x0f];
1972  p++;
1973  }
1974  *q='\0';
1975  return(string);
1976 }
1977 
1978 /*
1979 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1980 % %
1981 % %
1982 % %
1983 % S t r i n g T o A r g v %
1984 % %
1985 % %
1986 % %
1987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1988 %
1989 % StringToArgv() converts a text string into command line arguments.
1990 % The 'argv' array of arguments, is returned while the number of arguments
1991 % is returned via the provided integer variable pointer.
1992 %
1993 % Simple 'word' tokenizer, which allows for each word to be optionally
1994 % quoted. However it will not allow use of partial quotes, or escape
1995 % characters.
1996 %
1997 % The format of the StringToArgv method is:
1998 %
1999 % char **StringToArgv(const char *text,int *argc)
2000 %
2001 % A description of each parameter follows:
2002 %
2003 % o argv: Method StringToArgv returns the string list unless an error
2004 % occurs, otherwise NULL.
2005 %
2006 % o text: Specifies the string to segment into a list.
2007 %
2008 % o argc: This integer pointer returns the number of arguments in the
2009 % list.
2010 %
2011 */
2012 MagickExport char **StringToArgv(const char *text,int *argc)
2013 {
2014  char
2015  **argv;
2016 
2017  register const char
2018  *p,
2019  *q;
2020 
2021  register ssize_t
2022  i;
2023 
2024  *argc=0;
2025  if (text == (char *) NULL)
2026  return((char **) NULL);
2027  /*
2028  Determine the number of arguments.
2029  */
2030  for (p=text; *p != '\0'; )
2031  {
2032  while (isspace((int) ((unsigned char) *p)) != 0)
2033  p++;
2034  if (*p == '\0')
2035  break;
2036  (*argc)++;
2037  if (*p == '"')
2038  for (p++; (*p != '"') && (*p != '\0'); p++) ;
2039  if (*p == '\'')
2040  for (p++; (*p != '\'') && (*p != '\0'); p++) ;
2041  while ((isspace((int) ((unsigned char) *p)) == 0) && (*p != '\0'))
2042  p++;
2043  }
2044  (*argc)++;
2045  argv=(char **) AcquireQuantumMemory((size_t) (*argc+1UL),sizeof(*argv));
2046  if (argv == (char **) NULL)
2047  ThrowFatalException(ResourceLimitFatalError,"UnableToConvertStringToARGV");
2048  /*
2049  Convert string to an ASCII list.
2050  */
2051  argv[0]=AcquireString("magick");
2052  p=text;
2053  for (i=1; i < (ssize_t) *argc; i++)
2054  {
2055  while (isspace((int) ((unsigned char) *p)) != 0)
2056  p++;
2057  q=p;
2058  if (*q == '"')
2059  {
2060  p++;
2061  for (q++; (*q != '"') && (*q != '\0'); q++) ;
2062  }
2063  else
2064  if (*q == '\'')
2065  {
2066  p++;
2067  for (q++; (*q != '\'') && (*q != '\0'); q++) ;
2068  }
2069  else
2070  while ((isspace((int) ((unsigned char) *q)) == 0) && (*q != '\0'))
2071  q++;
2072  argv[i]=(char *) AcquireQuantumMemory((size_t) (q-p)+MagickPathExtent,
2073  sizeof(**argv));
2074  if (argv[i] == (char *) NULL)
2075  {
2076  for (i--; i >= 0; i--)
2077  argv[i]=DestroyString(argv[i]);
2078  argv=(char **) RelinquishMagickMemory(argv);
2080  "UnableToConvertStringToARGV");
2081  }
2082  (void) memcpy(argv[i],p,(size_t) (q-p));
2083  argv[i][q-p]='\0';
2084  p=q;
2085  while ((isspace((int) ((unsigned char) *p)) == 0) && (*p != '\0'))
2086  p++;
2087  }
2088  argv[i]=(char *) NULL;
2089  return(argv);
2090 }
2091 
2092 /*
2093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2094 % %
2095 % %
2096 % %
2097 % S t r i n g T o A r r a y O f D o u b l e s %
2098 % %
2099 % %
2100 % %
2101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2102 %
2103 % StringToArrayOfDoubles() converts a string of space or comma separated
2104 % numbers into array of floating point numbers (doubles). Any number that
2105 % failes to parse properly will produce a syntax error. As will two commas
2106 % without a number between them. However a final comma at the end will
2107 % not be regarded as an error so as to simplify automatic list generation.
2108 %
2109 % A NULL value is returned on syntax or memory errors.
2110 %
2111 % Use RelinquishMagickMemory() to free returned array when finished.
2112 %
2113 % The format of the StringToArrayOfDoubles method is:
2114 %
2115 % double *StringToArrayOfDoubles(const char *string,size_t *count,
2116 % ExceptionInfo *exception)
2117 %
2118 % A description of each parameter follows:
2119 %
2120 % o string: the string containing the comma/space separated values.
2121 %
2122 % o count: returns number of arguments in returned array
2123 %
2124 % o exception: return any errors or warnings in this structure.
2125 %
2126 */
2127 MagickExport double *StringToArrayOfDoubles(const char *string,ssize_t *count,
2129 {
2130  char
2131  *q;
2132 
2133  const char
2134  *p;
2135 
2136  double
2137  *array;
2138 
2139  register ssize_t
2140  i;
2141 
2142  /*
2143  Determine count of values, and check syntax.
2144  */
2145  assert(exception != (ExceptionInfo *) NULL);
2146  assert(exception->signature == MagickCoreSignature);
2147  *count=0;
2148  if (string == (char *) NULL)
2149  return((double *) NULL); /* no value found */
2150  i=0;
2151  p=string;
2152  while (*p != '\0')
2153  {
2154  (void) StringToDouble(p,&q); /* get value - ignores leading space */
2155  if (p == q)
2156  return((double *) NULL); /* no value found */
2157  p=q;
2158  i++; /* increment value count */
2159  while (isspace((int) ((unsigned char) *p)) != 0)
2160  p++; /* skip spaces */
2161  if (*p == ',')
2162  p++; /* skip comma */
2163  while (isspace((int) ((unsigned char) *p)) != 0)
2164  p++; /* and more spaces */
2165  }
2166  /*
2167  Allocate floating point argument list.
2168  */
2169  *count=i;
2170  array=(double *) AcquireQuantumMemory((size_t) i,sizeof(*array));
2171  if (array == (double *) NULL)
2172  {
2173  (void) ThrowMagickException(exception,GetMagickModule(),
2174  ResourceLimitError,"MemoryAllocationFailed","`%s'","");
2175  return((double *) NULL);
2176  }
2177  /*
2178  Fill in the floating point values.
2179  */
2180  i=0;
2181  p=string;
2182  while ((*p != '\0') && (i < *count))
2183  {
2184  array[i++]=StringToDouble(p,&q);
2185  p=q;
2186  while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
2187  p++;
2188  }
2189  return(array);
2190 }
2191 
2192 /*
2193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2194 % %
2195 % %
2196 % %
2197 + S t r i n g T o k e n %
2198 % %
2199 % %
2200 % %
2201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2202 %
2203 % StringToken() looks for any one of given delimiters and splits the string
2204 % into two separate strings by replacing the delimiter character found with a
2205 % null character.
2206 %
2207 % The given string pointer is changed to point to the string following the
2208 % delimiter character found, or NULL. A pointer to the start of the
2209 % string is returned, representing the token before the delimiter.
2210 %
2211 % In may ways this is equivent to the strtok() C library function, but with
2212 % multiple delimiter characters rather than a delimiter string.
2213 %
2214 % The format of the StringToken method is:
2215 %
2216 % char *StringToken(const char *delimiters,char **string)
2217 %
2218 % A description of each parameter follows:
2219 %
2220 % o delimiters: one or more delimiters.
2221 %
2222 % o string: return the first token in the string. If none is found, return
2223 % NULL.
2224 %
2225 */
2226 MagickExport char *StringToken(const char *delimiters,char **string)
2227 {
2228  char
2229  *q;
2230 
2231  register char
2232  *p;
2233 
2234  register const char
2235  *r;
2236 
2237  register int
2238  c,
2239  d;
2240 
2241  p=(*string);
2242  if (p == (char *) NULL)
2243  return((char *) NULL);
2244  q=p;
2245  for ( ; ; )
2246  {
2247  c=(*p++);
2248  r=delimiters;
2249  do
2250  {
2251  d=(*r++);
2252  if (c == d)
2253  {
2254  if (c == '\0')
2255  p=(char *) NULL;
2256  else
2257  p[-1]='\0';
2258  *string=p;
2259  return(q);
2260  }
2261  } while (d != '\0');
2262  }
2263 }
2264 
2265 /*
2266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2267 % %
2268 % %
2269 % %
2270 % S t r i n g T o L i s t %
2271 % %
2272 % %
2273 % %
2274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2275 %
2276 % StringToList() converts a text string into a list by segmenting the text
2277 % string at each carriage return discovered. The list is converted to HEX
2278 % characters if any control characters are discovered within the text string.
2279 %
2280 % The format of the StringToList method is:
2281 %
2282 % char **StringToList(const char *text)
2283 %
2284 % A description of each parameter follows:
2285 %
2286 % o text: Specifies the string to segment into a list.
2287 %
2288 */
2289 MagickExport char **StringToList(const char *text)
2290 {
2291  return(StringToStrings(text,(size_t *) NULL));
2292 }
2293 
2294 /*
2295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2296 % %
2297 % %
2298 % %
2299 % S t r i n g T o S t r i n g s %
2300 % %
2301 % %
2302 % %
2303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2304 %
2305 % StringToStrings() converts a text string into a list by segmenting the text
2306 % string at each carriage return discovered. The list is converted to HEX
2307 % characters if any control characters are discovered within the text string.
2308 %
2309 % The format of the StringToList method is:
2310 %
2311 % char **StringToList(const char *text,size_t *lines)
2312 %
2313 % A description of each parameter follows:
2314 %
2315 % o text: Specifies the string to segment into a list.
2316 %
2317 % o count: Return value for the number of items in the list.
2318 %
2319 */
2320 MagickExport char **StringToStrings(const char *text,size_t *count)
2321 {
2322  char
2323  **textlist;
2324 
2325  register const char
2326  *p;
2327 
2328  register ssize_t
2329  i;
2330 
2331  size_t
2332  lines;
2333 
2334  if (text == (char *) NULL)
2335  {
2336  if (count != (size_t *) NULL)
2337  *count=0;
2338  return((char **) NULL);
2339  }
2340  for (p=text; *p != '\0'; p++)
2341  if (((int) ((unsigned char) *p) < 32) &&
2342  (isspace((int) ((unsigned char) *p)) == 0))
2343  break;
2344  if (*p == '\0')
2345  {
2346  register const char
2347  *q;
2348 
2349  /*
2350  Convert string to an ASCII list.
2351  */
2352  lines=1;
2353  for (p=text; *p != '\0'; p++)
2354  if (*p == '\n')
2355  lines++;
2356  textlist=(char **) AcquireQuantumMemory((size_t) lines+1UL,
2357  sizeof(*textlist));
2358  if (textlist == (char **) NULL)
2359  ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
2360  p=text;
2361  for (i=0; i < (ssize_t) lines; i++)
2362  {
2363  for (q=p; *q != '\0'; q++)
2364  if ((*q == '\r') || (*q == '\n'))
2365  break;
2366  textlist[i]=(char *) AcquireQuantumMemory((size_t) (q-p)+1,
2367  sizeof(**textlist));
2368  if (textlist[i] == (char *) NULL)
2369  ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
2370  (void) memcpy(textlist[i],p,(size_t) (q-p));
2371  textlist[i][q-p]='\0';
2372  if (*q == '\r')
2373  q++;
2374  p=q+1;
2375  }
2376  }
2377  else
2378  {
2379  char
2380  hex_string[MagickPathExtent];
2381 
2382  register char
2383  *q;
2384 
2385  register ssize_t
2386  j;
2387 
2388  /*
2389  Convert string to a HEX list.
2390  */
2391  lines=(size_t) (strlen(text)/CharsPerLine)+1;
2392  textlist=(char **) AcquireQuantumMemory((size_t) lines+1UL,
2393  sizeof(*textlist));
2394  if (textlist == (char **) NULL)
2395  ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
2396  p=text;
2397  for (i=0; i < (ssize_t) lines; i++)
2398  {
2399  size_t
2400  length;
2401 
2402  textlist[i]=(char *) AcquireQuantumMemory(2UL*MagickPathExtent,
2403  sizeof(**textlist));
2404  if (textlist[i] == (char *) NULL)
2405  ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
2406  (void) FormatLocaleString(textlist[i],MagickPathExtent,"0x%08lx: ",
2407  (long) (CharsPerLine*i));
2408  q=textlist[i]+strlen(textlist[i]);
2409  length=strlen(p);
2410  for (j=1; j <= (ssize_t) MagickMin(length,CharsPerLine); j++)
2411  {
2412  (void) FormatLocaleString(hex_string,MagickPathExtent,"%02x",*(p+j));
2413  (void) CopyMagickString(q,hex_string,MagickPathExtent);
2414  q+=2;
2415  if ((j % 0x04) == 0)
2416  *q++=' ';
2417  }
2418  for ( ; j <= CharsPerLine; j++)
2419  {
2420  *q++=' ';
2421  *q++=' ';
2422  if ((j % 0x04) == 0)
2423  *q++=' ';
2424  }
2425  *q++=' ';
2426  for (j=1; j <= (ssize_t) MagickMin(length,CharsPerLine); j++)
2427  {
2428  if (isprint((int) ((unsigned char) *p)) != 0)
2429  *q++=(*p);
2430  else
2431  *q++='-';
2432  p++;
2433  }
2434  *q='\0';
2435  textlist[i]=(char *) ResizeQuantumMemory(textlist[i],(size_t) (q-
2436  textlist[i]+1),sizeof(**textlist));
2437  if (textlist[i] == (char *) NULL)
2438  ThrowFatalException(ResourceLimitFatalError,"UnableToConvertText");
2439  }
2440  }
2441  if (count != (size_t *) NULL)
2442  *count=lines;
2443  textlist[i]=(char *) NULL;
2444  return(textlist);
2445 }
2446 
2447 /*
2448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2449 % %
2450 % %
2451 % %
2452 % S t r i n g T o S t r i n g I n f o %
2453 % %
2454 % %
2455 % %
2456 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2457 %
2458 % StringToStringInfo() converts a string to a StringInfo type.
2459 %
2460 % The format of the StringToStringInfo method is:
2461 %
2462 % StringInfo *StringToStringInfo(const char *string)
2463 %
2464 % A description of each parameter follows:
2465 %
2466 % o string: The string.
2467 %
2468 */
2470 {
2471  StringInfo
2472  *string_info;
2473 
2474  assert(string != (const char *) NULL);
2475  string_info=AcquireStringInfo(strlen(string));
2476  SetStringInfoDatum(string_info,(const unsigned char *) string);
2477  return(string_info);
2478 }
2479 
2480 /*
2481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2482 % %
2483 % %
2484 % %
2485 % S t r i p S t r i n g %
2486 % %
2487 % %
2488 % %
2489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2490 %
2491 % StripString() strips any whitespace or quotes from the beginning and end of
2492 % a string of characters.
2493 %
2494 % The format of the StripString method is:
2495 %
2496 % void StripString(char *message)
2497 %
2498 % A description of each parameter follows:
2499 %
2500 % o message: Specifies an array of characters.
2501 %
2502 */
2503 MagickExport void StripString(char *message)
2504 {
2505  register char
2506  *p,
2507  *q;
2508 
2509  size_t
2510  length;
2511 
2512  assert(message != (char *) NULL);
2513  if (*message == '\0')
2514  return;
2515  length=strlen(message);
2516  p=message;
2517  while (isspace((int) ((unsigned char) *p)) != 0)
2518  p++;
2519  if ((*p == '\'') || (*p == '"'))
2520  p++;
2521  q=message+length-1;
2522  while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
2523  q--;
2524  if (q > p)
2525  if ((*q == '\'') || (*q == '"'))
2526  q--;
2527  (void) memmove(message,p,(size_t) (q-p+1));
2528  message[q-p+1]='\0';
2529  for (p=message; *p != '\0'; p++)
2530  if (*p == '\n')
2531  *p=' ';
2532 }
2533 
2534 /*
2535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2536 % %
2537 % %
2538 % %
2539 % S u b s t i t u t e S t r i n g %
2540 % %
2541 % %
2542 % %
2543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2544 %
2545 % SubstituteString() performs string substitution on a string, replacing the
2546 % string with the substituted version. Buffer must be allocated from the heap.
2547 % If the string is matched and status, MagickTrue is returned otherwise
2548 % MagickFalse.
2549 %
2550 % The format of the SubstituteString method is:
2551 %
2552 % MagickBooleanType SubstituteString(char **string,const char *search,
2553 % const char *replace)
2554 %
2555 % A description of each parameter follows:
2556 %
2557 % o string: the string to perform replacements on; replaced with new
2558 % allocation if a replacement is made.
2559 %
2560 % o search: search for this string.
2561 %
2562 % o replace: replace any matches with this string.
2563 %
2564 */
2566  const char *search,const char *replace)
2567 {
2569  status;
2570 
2571  register char
2572  *p;
2573 
2574  size_t
2575  extent,
2576  replace_extent,
2577  search_extent;
2578 
2579  ssize_t
2580  offset;
2581 
2582  status=MagickFalse;
2583  search_extent=0,
2584  replace_extent=0;
2585  for (p=strchr(*string,*search); p != (char *) NULL; p=strchr(p+1,*search))
2586  {
2587  if (search_extent == 0)
2588  search_extent=strlen(search);
2589  if (strncmp(p,search,search_extent) != 0)
2590  continue;
2591  /*
2592  We found a match.
2593  */
2594  status=MagickTrue;
2595  if (replace_extent == 0)
2596  replace_extent=strlen(replace);
2597  if (replace_extent > search_extent)
2598  {
2599  /*
2600  Make room for the replacement string.
2601  */
2602  offset=(ssize_t) (p-(*string));
2603  extent=strlen(*string)+replace_extent-search_extent+1;
2604  *string=(char *) ResizeQuantumMemory(*string,extent+MagickPathExtent,
2605  sizeof(*p));
2606  if (*string == (char *) NULL)
2607  ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString");
2608  p=(*string)+offset;
2609  }
2610  /*
2611  Replace string.
2612  */
2613  if (search_extent != replace_extent)
2614  (void) memmove(p+replace_extent,p+search_extent,
2615  strlen(p+search_extent)+1);
2616  (void) memcpy(p,replace,replace_extent);
2617  p+=replace_extent-1;
2618  }
2619  return(status);
2620 }
#define magick_restrict
Definition: MagickCore.h:41
MagickExport double InterpretSiPrefixValue(const char *magick_restrict string, char **magick_restrict sentinal)
Definition: string.c:1326
MagickExport ssize_t FormatMagickSize(const MagickSizeType size, const MagickBooleanType bi, const char *suffix, const size_t length, char *format)
Definition: string.c:1083
Definition: blob.h:30
MagickExport MagickBooleanType IsStringFalse(const char *value)
Definition: string.c:1456
MagickExport int CompareStringInfo(const StringInfo *target, const StringInfo *source)
Definition: string.c:380
static const unsigned char AsciiMap[]
Definition: string.c:74
MagickExport StringInfo * StringToStringInfo(const char *string)
Definition: string.c:2469
MagickExport size_t ConcatenateMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:428
MagickExport void SetStringInfoPath(StringInfo *string_info, const char *path)
Definition: string.c:1811
static StringInfo * AcquireStringInfoContainer()
Definition: string.c:176
char * map
Definition: stream.c:84
#define ThrowFatalException(severity, tag)
size_t signature
Definition: exception.h:123
unsigned char * datum
Definition: string_.h:33
MagickExport char * EscapeString(const char *source, const char escape)
Definition: string.c:919
static double StringToDouble(const char *magick_restrict string, char **magick_restrict sentinal)
MagickExport char * SanitizeString(const char *source)
Definition: string.c:1614
MagickExport void ConcatenateStringInfo(StringInfo *string_info, const StringInfo *source)
Definition: string.c:554
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:499
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:756
#define MagickEpsilon
Definition: magick-type.h:114
MagickExport void * ResizeQuantumMemory(void *memory, const size_t count, const size_t quantum)
Definition: memory.c:1408
#define O_BINARY
Definition: studio.h:325
MagickExport void StripString(char *message)
Definition: string.c:2503
Definition: log.h:52
MagickExport char * FileToString(const char *filename, const size_t extent, ExceptionInfo *exception)
Definition: string.c:990
ssize_t MagickOffsetType
Definition: magick-type.h:133
#define MagickCoreSignature
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1205
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
Definition: locale.c:404
MagickBooleanType
Definition: magick-type.h:169
MagickExport char ** StringToList(const char *text)
Definition: string.c:2289
MagickExport char * AcquireString(const char *source)
Definition: string.c:129
MagickExport void * FileToBlob(const char *filename, const size_t extent, size_t *length, ExceptionInfo *exception)
Definition: blob.c:1393
MagickExport void * AcquireCriticalMemory(const size_t size)
Definition: memory.c:595
MagickExport StringInfo * FileToStringInfo(const char *filename, const size_t extent, ExceptionInfo *exception)
Definition: string.c:1029
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition: string.c:840
MagickExport void ResetStringInfo(StringInfo *string_info)
Definition: string.c:1582
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:634
size_t MagickSizeType
Definition: magick-type.h:134
#define MagickPathExtent
MagickExport void PrintStringInfo(FILE *file, const char *id, const StringInfo *string_info)
Definition: string.c:1498
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1415
MagickExport int GetMagickPrecision(void)
Definition: magick.c:942
MagickExport StringInfo * BlobToStringInfo(const void *blob, const size_t length)
Definition: string.c:229
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:1145
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1660
static int open_utf8(const char *path, int flags, mode_t mode)
ExceptionInfo * exception
Definition: stream.c:99
MagickExport double * StringToArrayOfDoubles(const char *string, ssize_t *count, ExceptionInfo *exception)
Definition: string.c:2127
MagickExport MagickBooleanType SubstituteString(char **string, const char *search, const char *replace)
Definition: string.c:2565
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1172
MagickExport StringInfo * ConfigureFileToStringInfo(const char *filename)
Definition: string.c:594
MagickExport StringInfo * AcquireStringInfo(const size_t length)
Definition: string.c:187
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1435
#define GetMagickModule()
Definition: log.h:28
MagickExport const char * GetStringInfoPath(const StringInfo *string_info)
Definition: string.c:1292
MagickExport void SetStringInfoName(StringInfo *string_info, const char *name)
Definition: string.c:1779
MagickExport char * StringToken(const char *delimiters, char **string)
Definition: string.c:2226
MagickExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
Definition: string.c:1735
MagickExport char * DestroyString(char *string)
Definition: string.c:813
char * name
Definition: string_.h:40
MagickExport char ** DestroyStringList(char **list)
Definition: string.c:878
#define MagickMin(x, y)
Definition: image-private.h:37
MagickExport MagickBooleanType ConcatenateString(char **magick_restrict destination, const char *magick_restrict source)
Definition: string.c:494
char * path
Definition: string_.h:30
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1123
MagickExport MagickBooleanType UnmapBlob(void *, const size_t)
Definition: blob.c:5554
size_t signature
Definition: string_.h:36
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:286
MagickExport char ** StringToStrings(const char *text, size_t *count)
Definition: string.c:2320
#define CharsPerLine
Definition: string.c:64
size_t length
Definition: string_.h:36
#define MagickExport
MagickExport StringInfo * SplitStringInfo(StringInfo *string_info, const size_t offset)
Definition: string.c:1841
MagickExport char * StringInfoToString(const StringInfo *string_info)
Definition: string.c:1881
MagickExport char * StringInfoToHexString(const StringInfo *string_info)
Definition: string.c:1923
MagickExport char ** StringToArgv(const char *text, int *argc)
Definition: string.c:2012
MagickExport size_t GetStringInfoLength(const StringInfo *string_info)
Definition: string.c:1234
MagickExport const char * GetStringInfoName(const StringInfo *string_info)
Definition: string.c:1263
MagickExport char * ConstantString(const char *source)
Definition: string.c:702
MagickExport StringInfo * CloneStringInfo(const StringInfo *string_info)
Definition: string.c:338
MagickExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
Definition: string.c:1702
MagickExport void * MapBlob(int, const MapMode, const MagickOffsetType, const size_t)
MagickExport void SetStringInfo(StringInfo *string_info, const StringInfo *source)
Definition: string.c:1662
MagickExport double InterpretLocaleValue(const char *magick_restrict string, char **magick_restrict sentinal)
Definition: locale.c:1003