MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
resource.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % RRRR EEEEE SSSSS OOO U U RRRR CCCC EEEEE %
7 % R R E SS O O U U R R C E %
8 % RRRR EEE SSS O O U U RRRR C EEE %
9 % R R E SS O O U U R R C E %
10 % R R EEEEE SSSSS OOO UUU R R CCCC EEEEE %
11 % %
12 % %
13 % Get/Set MagickCore Resources %
14 % %
15 % Software Design %
16 % Cristy %
17 % September 2002 %
18 % %
19 % %
20 % Copyright 1999-2018 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://www.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/cache.h"
45 #include "MagickCore/configure.h"
46 #include "MagickCore/exception.h"
48 #include "MagickCore/linked-list.h"
49 #include "MagickCore/log.h"
50 #include "MagickCore/image.h"
52 #include "MagickCore/memory_.h"
54 #include "MagickCore/option.h"
55 #include "MagickCore/policy.h"
56 #include "MagickCore/random_.h"
57 #include "MagickCore/registry.h"
58 #include "MagickCore/resource_.h"
60 #include "MagickCore/semaphore.h"
62 #include "MagickCore/string_.h"
64 #include "MagickCore/splay-tree.h"
66 #include "MagickCore/token.h"
67 #include "MagickCore/utility.h"
69 
70 /*
71  Define declarations.
72 */
73 #define MagickPathTemplate "XXXXXXXXXXXX"
74 
75 /*
76  Typedef declarations.
77 */
78 typedef struct _ResourceInfo
79 {
82  height,
84  area,
85  memory,
86  map,
87  disk,
88  file,
89  thread,
90  throttle,
91  time;
92 
97  area_limit,
99  map_limit,
100  disk_limit,
101  file_limit,
102  thread_limit,
104  time_limit;
105 } ResourceInfo;
106 
107 /*
108  Global declarations.
109 */
110 static RandomInfo
111  *random_info = (RandomInfo *) NULL;
112 
113 static ResourceInfo
115  {
116  MagickULLConstant(0), /* initial width */
117  MagickULLConstant(0), /* initial height */
118  MagickULLConstant(0), /* initial list length */
119  MagickULLConstant(0), /* initial area */
120  MagickULLConstant(0), /* initial memory */
121  MagickULLConstant(0), /* initial map */
122  MagickULLConstant(0), /* initial disk */
123  MagickULLConstant(0), /* initial file */
124  MagickULLConstant(0), /* initial thread */
125  MagickULLConstant(0), /* initial throttle */
126  MagickULLConstant(0), /* initial time */
127  (INT_MAX/(5*sizeof(Quantum))), /* width limit */
128  (INT_MAX/(5*sizeof(Quantum))), /* height limit */
129  MagickResourceInfinity, /* list length limit */
130  MagickULLConstant(3072)*1024*1024, /* area limit */
131  MagickULLConstant(1536)*1024*1024, /* memory limit */
132  MagickULLConstant(3072)*1024*1024, /* map limit */
133  MagickResourceInfinity, /* disk limit */
134  MagickULLConstant(768), /* file limit */
135  MagickULLConstant(1), /* thread limit */
136  MagickULLConstant(0), /* throttle limit */
137  MagickResourceInfinity /* time limit */
138  };
139 
140 static SemaphoreInfo
142 
143 static SplayTreeInfo
145 
146 /*
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 % %
149 % %
150 % %
151 % A c q u i r e M a g i c k R e s o u r c e %
152 % %
153 % %
154 % %
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 %
157 % AcquireMagickResource() acquires resources of the specified type.
158 % MagickFalse is returned if the specified resource is exhausted otherwise
159 % MagickTrue.
160 %
161 % The format of the AcquireMagickResource() method is:
162 %
163 % MagickBooleanType AcquireMagickResource(const ResourceType type,
164 % const MagickSizeType size)
165 %
166 % A description of each parameter follows:
167 %
168 % o type: the type of resource.
169 %
170 % o size: the number of bytes needed from for this resource.
171 %
172 */
174  const MagickSizeType size)
175 {
176  char
177  resource_current[MagickFormatExtent],
178  resource_limit[MagickFormatExtent],
179  resource_request[MagickFormatExtent];
180 
182  logging,
183  status;
184 
186  limit;
187 
188  if ((MagickOffsetType) size < 0)
189  return(MagickFalse);
190  status=MagickFalse;
191  logging=IsEventLogging();
192  if (resource_semaphore == (SemaphoreInfo *) NULL)
195  switch (type)
196  {
197  case AreaResource:
198  {
201  if ((limit == MagickResourceInfinity) || (size < limit))
202  status=MagickTrue;
203  if (logging != MagickFalse)
204  {
205  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
206  MagickFormatExtent,resource_request);
207  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
208  MagickFormatExtent,resource_current);
209  (void) FormatMagickSize(limit,MagickFalse,(const char *) NULL,
210  MagickFormatExtent,resource_limit);
211  }
212  break;
213  }
214  case DiskResource:
215  {
216  if ((resource_info.disk+(MagickOffsetType) size) < 0)
217  return(MagickFalse);
220  if ((limit == MagickResourceInfinity) ||
221  (resource_info.disk < (MagickOffsetType) limit))
222  status=MagickTrue;
223  else
225  if (logging != MagickFalse)
226  {
228  resource_request);
230  MagickTrue,"B",MagickFormatExtent,resource_current);
231  (void) FormatMagickSize(limit,MagickTrue,"B",MagickFormatExtent,
232  resource_limit);
233  }
234  break;
235  }
236  case FileResource:
237  {
238  if ((resource_info.file+(MagickOffsetType) size) < 0)
239  return(MagickFalse);
242  if ((limit == MagickResourceInfinity) ||
243  (resource_info.file < (MagickOffsetType) limit))
244  status=MagickTrue;
245  if (logging != MagickFalse)
246  {
247  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
248  MagickFormatExtent,resource_request);
250  MagickFalse,(const char *) NULL,MagickFormatExtent,
251  resource_current);
252  (void) FormatMagickSize(limit,MagickTrue,(const char *) NULL,
253  MagickFormatExtent,resource_limit);
254  }
255  break;
256  }
257  case HeightResource:
258  {
261  if ((limit == MagickResourceInfinity) || (size < limit))
262  status=MagickTrue;
263  if (logging != MagickFalse)
264  {
266  resource_request);
268  resource_current);
270  resource_limit);
271  }
272  break;
273  }
274  case MapResource:
275  {
276  if ((resource_info.map+(MagickOffsetType) size) < 0)
277  return(MagickFalse);
279  limit=resource_info.map_limit;
280  if ((limit == MagickResourceInfinity) ||
281  (resource_info.map < (MagickOffsetType) limit))
282  status=MagickTrue;
283  else
285  if (logging != MagickFalse)
286  {
288  resource_request);
290  MagickTrue,"B",MagickFormatExtent,resource_current);
291  (void) FormatMagickSize(limit,MagickTrue,"B",MagickFormatExtent,
292  resource_limit);
293  }
294  break;
295  }
296  case ListLengthResource:
297  {
300  if ((limit == MagickResourceInfinity) || (size < limit))
301  status=MagickTrue;
302  if (logging != MagickFalse)
303  {
304  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
305  MagickFormatExtent,resource_request);
306  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
307  MagickFormatExtent,resource_current);
308  (void) FormatMagickSize(limit,MagickFalse,(const char *) NULL,
309  MagickFormatExtent,resource_limit);
310  }
311  break;
312  }
313  case MemoryResource:
314  {
315  if ((resource_info.memory+(MagickOffsetType) size) < 0)
316  return(MagickFalse);
319  if ((limit == MagickResourceInfinity) ||
321  status=MagickTrue;
322  else
324  if (logging != MagickFalse)
325  {
327  resource_request);
329  MagickTrue,"B",MagickFormatExtent,resource_current);
330  (void) FormatMagickSize(limit,MagickTrue,"B",MagickFormatExtent,
331  resource_limit);
332  }
333  break;
334  }
335  case ThreadResource:
336  {
338  if ((limit == MagickResourceInfinity) ||
340  status=MagickTrue;
341  if (logging != MagickFalse)
342  {
343  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
344  MagickFormatExtent,resource_request);
346  MagickFalse,(const char *) NULL,MagickFormatExtent,
347  resource_current);
348  (void) FormatMagickSize(limit,MagickFalse,(const char *) NULL,
349  MagickFormatExtent,resource_limit);
350  }
351  break;
352  }
353  case ThrottleResource:
354  {
356  if ((limit == MagickResourceInfinity) ||
358  status=MagickTrue;
359  if (logging != MagickFalse)
360  {
361  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
362  MagickFormatExtent,resource_request);
364  MagickFalse,(const char *) NULL,MagickFormatExtent,
365  resource_current);
366  (void) FormatMagickSize(limit,MagickFalse,(const char *) NULL,
367  MagickFormatExtent,resource_limit);
368  }
369  break;
370  }
371  case TimeResource:
372  {
373  if ((resource_info.time+(MagickOffsetType) size) < 0)
374  return(MagickFalse);
377  if ((limit == MagickResourceInfinity) ||
378  (resource_info.time < (MagickOffsetType) limit))
379  status=MagickTrue;
380  else
382  if (logging != MagickFalse)
383  {
384  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
385  MagickFormatExtent,resource_request);
387  MagickFalse,(const char *) NULL,MagickFormatExtent,
388  resource_current);
389  (void) FormatMagickSize(limit,MagickFalse,(const char *) NULL,
390  MagickFormatExtent,resource_limit);
391  }
392  break;
393  }
394  case WidthResource:
395  {
398  if ((limit == MagickResourceInfinity) || (size < limit))
399  status=MagickTrue;
400  if (logging != MagickFalse)
401  {
403  resource_request);
405  resource_current);
407  resource_limit);
408  }
409  break;
410  }
411  default:
412  break;
413  }
415  if (logging != MagickFalse)
416  {
417  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %s/%s/%s",
419  resource_request,resource_current,resource_limit);
420  }
421  return(status);
422 }
423 
424 /*
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426 % %
427 % %
428 % %
429 + A s y n c h r o n o u s R e s o u r c e C o m p o n e n t T e r m i n u s %
430 % %
431 % %
432 % %
433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
434 %
435 % AsynchronousResourceComponentTerminus() destroys the resource environment.
436 % It differs from ResourceComponentTerminus() in that it can be called from a
437 % asynchronous signal handler.
438 %
439 % The format of the ResourceComponentTerminus() method is:
440 %
441 % ResourceComponentTerminus(void)
442 %
443 */
445 {
446  const char
447  *path;
448 
449  if (temporary_resources == (SplayTreeInfo *) NULL)
450  return;
451  /*
452  Remove any lingering temporary files.
453  */
455  path=(const char *) GetNextKeyInSplayTree(temporary_resources);
456  while (path != (const char *) NULL)
457  {
458  (void) ShredFile(path);
459  path=(const char *) GetNextKeyInSplayTree(temporary_resources);
460  }
461 }
462 
463 /*
464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465 % %
466 % %
467 % %
468 % A c q u i r e U n i q u e F i l e R e s o u r c e %
469 % %
470 % %
471 % %
472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 %
474 % AcquireUniqueFileResource() returns a unique file name, and returns a file
475 % descriptor for the file open for reading and writing.
476 %
477 % The format of the AcquireUniqueFileResource() method is:
478 %
479 % int AcquireUniqueFileResource(char *path)
480 %
481 % A description of each parameter follows:
482 %
483 % o path: Specifies a pointer to an array of characters. The unique path
484 % name is returned in this array.
485 %
486 */
487 
488 static void *DestroyTemporaryResources(void *temporary_resource)
489 {
490  (void) ShredFile((char *) temporary_resource);
491  temporary_resource=DestroyString((char *) temporary_resource);
492  return((void *) NULL);
493 }
494 
496 {
497  char
498  *directory,
499  *value;
500 
502  *exception;
503 
505  status;
506 
507  struct stat
508  attributes;
509 
510  (void) FormatLocaleString(path,MagickPathExtent,"magick-%.20g"
511  MagickPathTemplate,(double) getpid());
512  exception=AcquireExceptionInfo();
513  directory=(char *) GetImageRegistry(StringRegistryType,"temporary-path",
514  exception);
515  exception=DestroyExceptionInfo(exception);
516  if (directory == (char *) NULL)
517  directory=GetEnvironmentValue("MAGICK_TEMPORARY_PATH");
518  if (directory == (char *) NULL)
519  directory=GetEnvironmentValue("MAGICK_TMPDIR");
520  if (directory == (char *) NULL)
521  directory=GetEnvironmentValue("TMPDIR");
522 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__OS2__) || defined(__CYGWIN__)
523  if (directory == (char *) NULL)
524  directory=GetEnvironmentValue("TMP");
525  if (directory == (char *) NULL)
526  directory=GetEnvironmentValue("TEMP");
527 #endif
528 #if defined(__VMS)
529  if (directory == (char *) NULL)
530  directory=GetEnvironmentValue("MTMPDIR");
531 #endif
532 #if defined(P_tmpdir)
533  if (directory == (char *) NULL)
534  directory=ConstantString(P_tmpdir);
535 #endif
536  if (directory == (char *) NULL)
537  return(MagickTrue);
538  value=GetPolicyValue("resource:temporary-path");
539  if (value != (char *) NULL)
540  {
541  (void) CloneString(&directory,value);
542  value=DestroyString(value);
543  }
544  if (strlen(directory) > (MagickPathExtent-25))
545  {
546  directory=DestroyString(directory);
547  return(MagickFalse);
548  }
549  status=GetPathAttributes(directory,&attributes);
550  if ((status == MagickFalse) || !S_ISDIR(attributes.st_mode))
551  {
552  directory=DestroyString(directory);
553  return(MagickFalse);
554  }
555  if (directory[strlen(directory)-1] == *DirectorySeparator)
557  "%smagick-%.20g" MagickPathTemplate,directory,(double) getpid());
558  else
560  "%s%smagick-%.20g" MagickPathTemplate,directory,DirectorySeparator,
561  (double) getpid());
562  directory=DestroyString(directory);
563 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
564  {
565  register char
566  *p;
567 
568  /*
569  Ghostscript does not like backslashes so we need to replace them. The
570  forward slash also works under Windows.
571  */
572  for (p=(path[1] == *DirectorySeparator ? path+2 : path); *p != '\0'; p++)
573  if (*p == *DirectorySeparator)
574  *p='/';
575  }
576 #endif
577  return(MagickTrue);
578 }
579 
581 {
582 #if !defined(O_NOFOLLOW)
583 #define O_NOFOLLOW 0
584 #endif
585 #if !defined(TMP_MAX)
586 # define TMP_MAX 238328
587 #endif
588 
589  int
590  c,
591  file;
592 
593  register char
594  *p;
595 
596  register ssize_t
597  i;
598 
599  static const char
600  portable_filename[65] =
601  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
602 
603  StringInfo
604  *key;
605 
606  unsigned char
607  *datum;
608 
609  assert(path != (char *) NULL);
611  if (random_info == (RandomInfo *) NULL)
612  {
614  if (random_info == (RandomInfo *) NULL)
617  }
618  file=(-1);
619  for (i=0; i < (ssize_t) TMP_MAX; i++)
620  {
621  register ssize_t
622  j;
623 
624  /*
625  Get temporary pathname.
626  */
627  (void) GetPathTemplate(path);
628  key=GetRandomKey(random_info,6);
629  p=path+strlen(path)-strlen(MagickPathTemplate);
630  datum=GetStringInfoDatum(key);
631  for (j=0; j < (ssize_t) GetStringInfoLength(key); j++)
632  {
633  c=(int) (datum[j] & 0x3f);
634  *p++=portable_filename[c];
635  }
636  key=DestroyStringInfo(key);
637 #if defined(MAGICKCORE_HAVE_MKSTEMP)
638  file=mkstemp(path);
639  if (file != -1)
640  {
641 #if defined(MAGICKCORE_HAVE_FCHMOD)
642  (void) fchmod(file,0600);
643 #endif
644 #if defined(__OS2__)
645  setmode(file,O_BINARY);
646 #endif
647  break;
648  }
649 #endif
651  p=path+strlen(path)-strlen(MagickPathTemplate);
652  datum=GetStringInfoDatum(key);
653  for (j=0; j < (ssize_t) GetStringInfoLength(key); j++)
654  {
655  c=(int) (datum[j] & 0x3f);
656  *p++=portable_filename[c];
657  }
658  key=DestroyStringInfo(key);
659  file=open_utf8(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,
660  S_MODE);
661  if ((file >= 0) || (errno != EEXIST))
662  break;
663  }
664  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
665  if (file == -1)
666  return(file);
667  if (resource_semaphore == (SemaphoreInfo *) NULL)
670  if (temporary_resources == (SplayTreeInfo *) NULL)
672  DestroyTemporaryResources,(void *(*)(void *)) NULL);
675  (const void *) NULL);
676  return(file);
677 }
678 
679 /*
680 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
681 % %
682 % %
683 % %
684 % G e t M a g i c k R e s o u r c e %
685 % %
686 % %
687 % %
688 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689 %
690 % GetMagickResource() returns the specified resource.
691 %
692 % The format of the GetMagickResource() method is:
693 %
694 % MagickSizeType GetMagickResource(const ResourceType type)
695 %
696 % A description of each parameter follows:
697 %
698 % o type: the type of resource.
699 %
700 */
702 {
704  resource;
705 
706  resource=0;
708  switch (type)
709  {
710  case AreaResource:
711  {
712  resource=(MagickSizeType) resource_info.area;
713  break;
714  }
715  case DiskResource:
716  {
717  resource=(MagickSizeType) resource_info.disk;
718  break;
719  }
720  case FileResource:
721  {
722  resource=(MagickSizeType) resource_info.file;
723  break;
724  }
725  case HeightResource:
726  {
728  break;
729  }
730  case ListLengthResource:
731  {
733  break;
734  }
735  case MapResource:
736  {
737  resource=(MagickSizeType) resource_info.map;
738  break;
739  }
740  case MemoryResource:
741  {
743  break;
744  }
745  case ThreadResource:
746  {
748  break;
749  }
750  case ThrottleResource:
751  {
753  break;
754  }
755  case TimeResource:
756  {
757  resource=(MagickSizeType) resource_info.time;
758  break;
759  }
760  case WidthResource:
761  {
763  break;
764  }
765  default:
766  break;
767  }
769  return(resource);
770 }
771 
772 /*
773 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
774 % %
775 % %
776 % %
777 % G e t M a g i c k R e s o u r c e L i m i t %
778 % %
779 % %
780 % %
781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
782 %
783 % GetMagickResourceLimit() returns the specified resource limit.
784 %
785 % The format of the GetMagickResourceLimit() method is:
786 %
787 % MagickSizeType GetMagickResourceLimit(const ResourceType type)
788 %
789 % A description of each parameter follows:
790 %
791 % o type: the type of resource.
792 %
793 */
795 {
797  resource;
798 
799  resource=0;
800  if (resource_semaphore == (SemaphoreInfo *) NULL)
803  switch (type)
804  {
805  case AreaResource:
806  {
807  resource=resource_info.area_limit;
808  break;
809  }
810  case DiskResource:
811  {
812  resource=resource_info.disk_limit;
813  break;
814  }
815  case FileResource:
816  {
817  resource=resource_info.file_limit;
818  break;
819  }
820  case HeightResource:
821  {
822  resource=resource_info.height_limit;
823  break;
824  }
825  case ListLengthResource:
826  {
828  break;
829  }
830  case MemoryResource:
831  {
832  resource=resource_info.memory_limit;
833  break;
834  }
835  case MapResource:
836  {
837  resource=resource_info.map_limit;
838  break;
839  }
840  case ThreadResource:
841  {
842  resource=resource_info.thread_limit;
843  break;
844  }
845  case ThrottleResource:
846  {
847  resource=resource_info.throttle_limit;
848  break;
849  }
850  case TimeResource:
851  {
852  resource=resource_info.time_limit;
853  break;
854  }
855  case WidthResource:
856  {
857  resource=resource_info.width_limit;
858  break;
859  }
860  default:
861  break;
862  }
864  return(resource);
865 }
866 
867 /*
868 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869 % %
870 % %
871 % %
872 % L i s t M a g i c k R e s o u r c e I n f o %
873 % %
874 % %
875 % %
876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
877 %
878 % ListMagickResourceInfo() lists the resource info to a file.
879 %
880 % The format of the ListMagickResourceInfo method is:
881 %
882 % MagickBooleanType ListMagickResourceInfo(FILE *file,
883 % ExceptionInfo *exception)
884 %
885 % A description of each parameter follows.
886 %
887 % o file: An pointer to a FILE.
888 %
889 % o exception: return any errors or warnings in this structure.
890 %
891 */
893  ExceptionInfo *magick_unused(exception))
894 {
895  char
904 
905  magick_unreferenced(exception);
906 
907  if (file == (const FILE *) NULL)
908  file=stdout;
909  if (resource_semaphore == (SemaphoreInfo *) NULL)
913  MagickFormatExtent,width_limit);
915  MagickFormatExtent,height_limit);
917  MagickFormatExtent,list_length_limit);
919  MagickFormatExtent,area_limit);
921  MagickFormatExtent,memory_limit);
923  MagickFormatExtent,map_limit);
924  (void) CopyMagickString(disk_limit,"unlimited",MagickFormatExtent);
927  MagickFormatExtent,disk_limit);
928  (void) CopyMagickString(time_limit,"unlimited",MagickFormatExtent);
930  (void) FormatLocaleString(time_limit,MagickFormatExtent,"%.20g",(double)
932  (void) FormatLocaleFile(file,"Resource limits:\n");
933  (void) FormatLocaleFile(file," Width: %s\n",width_limit);
934  (void) FormatLocaleFile(file," Height: %s\n",height_limit);
935  (void) FormatLocaleFile(file," List length: %s\n",list_length_limit);
936  (void) FormatLocaleFile(file," Area: %s\n",area_limit);
937  (void) FormatLocaleFile(file," Memory: %s\n",memory_limit);
938  (void) FormatLocaleFile(file," Map: %s\n",map_limit);
939  (void) FormatLocaleFile(file," Disk: %s\n",disk_limit);
940  (void) FormatLocaleFile(file," File: %.20g\n",(double) ((MagickOffsetType)
942  (void) FormatLocaleFile(file," Thread: %.20g\n",(double) ((MagickOffsetType)
944  (void) FormatLocaleFile(file," Throttle: %.20g\n",(double)
946  (void) FormatLocaleFile(file," Time: %s\n",time_limit);
947  (void) fflush(file);
949  return(MagickTrue);
950 }
951 
952 /*
953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % %
955 % %
956 % %
957 % R e l i n q u i s h M a g i c k R e s o u r c e %
958 % %
959 % %
960 % %
961 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
962 %
963 % RelinquishMagickResource() relinquishes resources of the specified type.
964 %
965 % The format of the RelinquishMagickResource() method is:
966 %
967 % void RelinquishMagickResource(const ResourceType type,
968 % const MagickSizeType size)
969 %
970 % A description of each parameter follows:
971 %
972 % o type: the type of resource.
973 %
974 % o size: the size of the resource.
975 %
976 */
978  const MagickSizeType size)
979 {
980  char
981  resource_current[MagickFormatExtent],
982  resource_limit[MagickFormatExtent],
983  resource_request[MagickFormatExtent];
984 
986  logging;
987 
988  logging=IsEventLogging();
989  if (resource_semaphore == (SemaphoreInfo *) NULL)
992  switch (type)
993  {
994  case AreaResource:
995  {
997  if (logging != MagickFalse)
998  {
999  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
1000  MagickFormatExtent,resource_request);
1002  MagickFalse,(const char *) NULL,MagickFormatExtent,
1003  resource_current);
1005  (const char *) NULL,MagickFormatExtent,resource_limit);
1006  }
1007  break;
1008  }
1009  case DiskResource:
1010  {
1011  resource_info.disk-=size;
1012  assert(resource_info.disk >= 0);
1013  if (logging != MagickFalse)
1014  {
1016  resource_request);
1018  MagickTrue,"B",MagickFormatExtent,resource_current);
1020  MagickFormatExtent,resource_limit);
1021  }
1022  break;
1023  }
1024  case FileResource:
1025  {
1026  resource_info.file-=size;
1027  assert(resource_info.file >= 0);
1028  if (logging != MagickFalse)
1029  {
1030  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
1031  MagickFormatExtent,resource_request);
1033  MagickFalse,(const char *) NULL,MagickFormatExtent,
1034  resource_current);
1036  MagickFalse,(const char *) NULL,MagickFormatExtent,resource_limit);
1037  }
1038  break;
1039  }
1040  case HeightResource:
1041  {
1043  if (logging != MagickFalse)
1044  {
1046  resource_request);
1048  MagickFalse,"P",MagickFormatExtent,resource_current);
1050  MagickFormatExtent,resource_limit);
1051  }
1052  break;
1053  }
1054  case ListLengthResource:
1055  {
1057  if (logging != MagickFalse)
1058  {
1059  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
1060  MagickFormatExtent,resource_request);
1062  MagickFalse,(const char *) NULL,MagickFormatExtent,
1063  resource_current);
1065  (const char *) NULL,MagickFormatExtent,resource_limit);
1066  }
1067  break;
1068  }
1069  case MapResource:
1070  {
1071  resource_info.map-=size;
1072  assert(resource_info.map >= 0);
1073  if (logging != MagickFalse)
1074  {
1076  resource_request);
1078  MagickTrue,"B",MagickFormatExtent,resource_current);
1080  MagickFormatExtent,resource_limit);
1081  }
1082  break;
1083  }
1084  case MemoryResource:
1085  {
1086  resource_info.memory-=size;
1087  assert(resource_info.memory >= 0);
1088  if (logging != MagickFalse)
1089  {
1091  resource_request);
1093  MagickTrue,"B",MagickFormatExtent,resource_current);
1095  MagickFormatExtent,resource_limit);
1096  }
1097  break;
1098  }
1099  case ThreadResource:
1100  {
1101  if (logging != MagickFalse)
1102  {
1103  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
1104  MagickFormatExtent,resource_request);
1106  MagickFalse,(const char *) NULL,MagickFormatExtent,
1107  resource_current);
1109  MagickFalse,(const char *) NULL,MagickFormatExtent,resource_limit);
1110  }
1111  break;
1112  }
1113  case ThrottleResource:
1114  {
1115  if (logging != MagickFalse)
1116  {
1117  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
1118  MagickFormatExtent,resource_request);
1120  MagickFalse,(const char *) NULL,MagickFormatExtent,
1121  resource_current);
1123  MagickFalse,(const char *) NULL,MagickFormatExtent,resource_limit);
1124  }
1125  break;
1126  }
1127  case TimeResource:
1128  {
1129  resource_info.time-=size;
1130  assert(resource_info.time >= 0);
1131  if (logging != MagickFalse)
1132  {
1133  (void) FormatMagickSize(size,MagickFalse,(const char *) NULL,
1134  MagickFormatExtent,resource_request);
1136  MagickFalse,(const char *) NULL,MagickFormatExtent,
1137  resource_current);
1139  MagickFalse,(const char *) NULL,MagickFormatExtent,resource_limit);
1140  }
1141  break;
1142  }
1143  case WidthResource:
1144  {
1146  if (logging != MagickFalse)
1147  {
1149  resource_request);
1151  MagickFalse,"P",MagickFormatExtent,resource_current);
1153  MagickFormatExtent,resource_limit);
1154  }
1155  break;
1156  }
1157  default:
1158  break;
1159  }
1161  if (logging != MagickFalse)
1162  {
1163  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %s/%s/%s",
1165  resource_request,resource_current,resource_limit);
1166  }
1167 }
1168 
1169 /*
1170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1171 % %
1172 % %
1173 % %
1174 % R e l i n q u i s h U n i q u e F i l e R e s o u r c e %
1175 % %
1176 % %
1177 % %
1178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1179 %
1180 % RelinquishUniqueFileResource() relinquishes a unique file resource.
1181 %
1182 % The format of the RelinquishUniqueFileResource() method is:
1183 %
1184 % MagickBooleanType RelinquishUniqueFileResource(const char *path)
1185 %
1186 % A description of each parameter follows:
1187 %
1188 % o name: the name of the temporary resource.
1189 %
1190 */
1192 {
1193  char
1194  cache_path[MagickPathExtent];
1195 
1197  status;
1198 
1199  assert(path != (const char *) NULL);
1200  status=MagickFalse;
1201  (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
1202  if (resource_semaphore == (SemaphoreInfo *) NULL)
1205  if (temporary_resources != (SplayTreeInfo *) NULL)
1206  status=DeleteNodeFromSplayTree(temporary_resources,(const void *) path);
1208  (void) CopyMagickString(cache_path,path,MagickPathExtent);
1209  AppendImageFormat("cache",cache_path);
1210  if (access_utf8(cache_path,F_OK) == 0)
1211  (void) ShredFile(cache_path);
1212  if (status == MagickFalse)
1213  status=ShredFile(path);
1214  return(status);
1215 }
1216 
1217 /*
1218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1219 % %
1220 % %
1221 % %
1222 + R e s o u r c e C o m p o n e n t G e n e s i s %
1223 % %
1224 % %
1225 % %
1226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1227 %
1228 % ResourceComponentGenesis() instantiates the resource component.
1229 %
1230 % The format of the ResourceComponentGenesis method is:
1231 %
1232 % MagickBooleanType ResourceComponentGenesis(void)
1233 %
1234 */
1235 
1237 {
1238  char
1239  *limit;
1240 
1242  memory;
1243 
1244  ssize_t
1245  files,
1246  pages,
1247  pagesize;
1248 
1249  /*
1250  Set Magick resource limits.
1251  */
1252  if (resource_semaphore == (SemaphoreInfo *) NULL)
1255  limit=GetEnvironmentValue("MAGICK_WIDTH_LIMIT");
1256  if (limit != (char *) NULL)
1257  {
1259  100.0));
1260  limit=DestroyString(limit);
1261  }
1263  limit=GetEnvironmentValue("MAGICK_HEIGHT_LIMIT");
1264  if (limit != (char *) NULL)
1265  {
1267  limit,100.0));
1268  limit=DestroyString(limit);
1269  }
1270  pagesize=GetMagickPageSize();
1271  pages=(-1);
1272 #if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PHYS_PAGES)
1273  pages=(ssize_t) sysconf(_SC_PHYS_PAGES);
1274 #endif
1275  memory=(MagickSizeType) pages*pagesize;
1276  if ((pagesize <= 0) || (pages <= 0))
1277  memory=2048UL*1024UL*1024UL;
1278 #if defined(PixelCacheThreshold)
1279  memory=PixelCacheThreshold;
1280 #endif
1281  (void) SetMagickResourceLimit(AreaResource,2*memory);
1282  limit=GetEnvironmentValue("MAGICK_AREA_LIMIT");
1283  if (limit != (char *) NULL)
1284  {
1286  100.0));
1287  limit=DestroyString(limit);
1288  }
1289  (void) SetMagickResourceLimit(MemoryResource,memory);
1290  limit=GetEnvironmentValue("MAGICK_MEMORY_LIMIT");
1291  if (limit != (char *) NULL)
1292  {
1294  limit,100.0));
1295  limit=DestroyString(limit);
1296  }
1297  (void) SetMagickResourceLimit(MapResource,2*memory);
1298  limit=GetEnvironmentValue("MAGICK_MAP_LIMIT");
1299  if (limit != (char *) NULL)
1300  {
1302  100.0));
1303  limit=DestroyString(limit);
1304  }
1306  limit=GetEnvironmentValue("MAGICK_DISK_LIMIT");
1307  if (limit != (char *) NULL)
1308  {
1310  100.0));
1311  limit=DestroyString(limit);
1312  }
1313  files=(-1);
1314 #if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
1315  files=(ssize_t) sysconf(_SC_OPEN_MAX);
1316 #endif
1317 #if defined(MAGICKCORE_HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
1318  if (files < 0)
1319  {
1320  struct rlimit
1321  resources;
1322 
1323  if (getrlimit(RLIMIT_NOFILE,&resources) != -1)
1324  files=(ssize_t) resources.rlim_cur;
1325  }
1326 #endif
1327 #if defined(MAGICKCORE_HAVE_GETDTABLESIZE) && defined(MAGICKCORE_POSIX_SUPPORT)
1328  if (files < 0)
1329  files=(ssize_t) getdtablesize();
1330 #endif
1331  if (files < 0)
1332  files=64;
1334  (3*files/4),64));
1335  limit=GetEnvironmentValue("MAGICK_FILE_LIMIT");
1336  if (limit != (char *) NULL)
1337  {
1339  100.0));
1340  limit=DestroyString(limit);
1341  }
1343  limit=GetEnvironmentValue("MAGICK_THREAD_LIMIT");
1344  if (limit != (char *) NULL)
1345  {
1347  limit,100.0));
1348  limit=DestroyString(limit);
1349  }
1351  limit=GetEnvironmentValue("MAGICK_THROTTLE_LIMIT");
1352  if (limit != (char *) NULL)
1353  {
1355  limit,100.0));
1356  limit=DestroyString(limit);
1357  }
1359  limit=GetEnvironmentValue("MAGICK_TIME_LIMIT");
1360  if (limit != (char *) NULL)
1361  {
1363  100.0));
1364  limit=DestroyString(limit);
1365  }
1367  limit=GetEnvironmentValue("MAGICK_LIST_LENGTH_LIMIT");
1368  if (limit != (char *) NULL)
1369  {
1371  StringToMagickSizeType(limit,100.0));
1372  limit=DestroyString(limit);
1373  }
1374  return(MagickTrue);
1375 }
1376 
1377 /*
1378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1379 % %
1380 % %
1381 % %
1382 + R e s o u r c e C o m p o n e n t T e r m i n u s %
1383 % %
1384 % %
1385 % %
1386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1387 %
1388 % ResourceComponentTerminus() destroys the resource component.
1389 %
1390 % The format of the ResourceComponentTerminus() method is:
1391 %
1392 % ResourceComponentTerminus(void)
1393 %
1394 */
1396 {
1397  if (resource_semaphore == (SemaphoreInfo *) NULL)
1400  if (temporary_resources != (SplayTreeInfo *) NULL)
1402  if (random_info != (RandomInfo *) NULL)
1406 }
1407 
1408 /*
1409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1410 % %
1411 % %
1412 % %
1413 % S e t M a g i c k R e s o u r c e L i m i t %
1414 % %
1415 % %
1416 % %
1417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1418 %
1419 % SetMagickResourceLimit() sets the limit for a particular resource.
1420 %
1421 % The format of the SetMagickResourceLimit() method is:
1422 %
1423 % MagickBooleanType SetMagickResourceLimit(const ResourceType type,
1424 % const MagickSizeType limit)
1425 %
1426 % A description of each parameter follows:
1427 %
1428 % o type: the type of resource.
1429 %
1430 % o limit: the maximum limit for the resource.
1431 %
1432 */
1433 
1435  const MagickSizeType limit)
1436 {
1437  char
1438  *value;
1439 
1441  status;
1442 
1443  status=MagickTrue;
1444  if (resource_semaphore == (SemaphoreInfo *) NULL)
1447  value=(char *) NULL;
1448  switch (type)
1449  {
1450  case AreaResource:
1451  {
1452  value=GetPolicyValue("resource:area");
1453  if (value == (char *) NULL)
1454  resource_info.area_limit=limit;
1455  else
1457  100.0));
1458  break;
1459  }
1460  case DiskResource:
1461  {
1462  value=GetPolicyValue("resource:disk");
1463  if (value == (char *) NULL)
1464  resource_info.disk_limit=limit;
1465  else
1467  100.0));
1468  break;
1469  }
1470  case FileResource:
1471  {
1472  value=GetPolicyValue("resource:file");
1473  if (value == (char *) NULL)
1474  resource_info.file_limit=limit;
1475  else
1477  100.0));
1478  break;
1479  }
1480  case HeightResource:
1481  {
1482  value=GetPolicyValue("resource:height");
1483  if (value == (char *) NULL)
1485  else
1487  value,100.0));
1488  break;
1489  }
1490  case ListLengthResource:
1491  {
1492  value=GetPolicyValue("resource:list-length");
1493  if (value == (char *) NULL)
1495  else
1497  StringToMagickSizeType(value,100.0));
1498  break;
1499  }
1500  case MapResource:
1501  {
1502  value=GetPolicyValue("resource:map");
1503  if (value == (char *) NULL)
1504  resource_info.map_limit=limit;
1505  else
1507  value,100.0));
1508  break;
1509  }
1510  case MemoryResource:
1511  {
1512  value=GetPolicyValue("resource:memory");
1513  if (value == (char *) NULL)
1515  else
1517  value,100.0));
1518  break;
1519  }
1520  case ThreadResource:
1521  {
1522  value=GetPolicyValue("resource:thread");
1523  if (value == (char *) NULL)
1525  else
1527  value,100.0));
1530  else
1531  if (resource_info.thread_limit == 0)
1533  break;
1534  }
1535  case ThrottleResource:
1536  {
1537  value=GetPolicyValue("resource:throttle");
1538  if (value == (char *) NULL)
1540  else
1542  value,100.0));
1543  break;
1544  }
1545  case TimeResource:
1546  {
1547  value=GetPolicyValue("resource:time");
1548  if (value == (char *) NULL)
1549  resource_info.time_limit=limit;
1550  else
1552  100.0));
1554  break;
1555  }
1556  case WidthResource:
1557  {
1558  value=GetPolicyValue("resource:width");
1559  if (value == (char *) NULL)
1560  resource_info.width_limit=limit;
1561  else
1563  100.0));
1564  break;
1565  }
1566  default:
1567  {
1568  status=MagickFalse;
1569  break;
1570  }
1571  }
1572  if (value != (char *) NULL)
1573  value=DestroyString(value);
1575  return(status);
1576 }
MagickExport ssize_t FormatMagickSize(const MagickSizeType size, const MagickBooleanType bi, const char *suffix, const size_t length, char *format)
Definition: string.c:1086
MagickOffsetType map
Definition: resource.c:81
MagickExport MagickBooleanType GetPathAttributes(const char *path, void *attributes)
Definition: utility.c:1165
MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
Definition: splay-tree.c:154
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:450
MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ExceptionInfo *magick_unused(exception))
Definition: resource.c:892
static void * DestroyTemporaryResources(void *temporary_resource)
Definition: resource.c:488
#define MagickULLConstant(c)
Definition: magick-type.h:36
struct _ResourceInfo ResourceInfo
MagickOffsetType file
Definition: resource.c:81
static size_t GetOpenMPMaximumThreads(void)
MagickOffsetType thread
Definition: resource.c:81
MagickSizeType height_limit
Definition: resource.c:94
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
Definition: semaphore.c:192
static ResourceInfo resource_info
Definition: resource.c:114
MagickSizeType map_limit
Definition: resource.c:94
MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
Definition: resource.c:1236
MagickOffsetType memory
Definition: resource.c:81
MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type, const MagickSizeType limit)
Definition: resource.c:1434
MagickOffsetType area
Definition: resource.c:81
#define S_ISDIR(mode)
Definition: studio.h:195
MagickSizeType area_limit
Definition: resource.c:94
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
Definition: exception.c:103
MagickOffsetType time
Definition: resource.c:81
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:472
MagickExport void RelinquishMagickResource(const ResourceType type, const MagickSizeType size)
Definition: resource.c:977
#define O_BINARY
Definition: studio.h:320
MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, const MagickSizeType size)
Definition: resource.c:173
ssize_t MagickOffsetType
Definition: magick-type.h:127
MagickOffsetType disk
Definition: resource.c:81
MagickExport RandomInfo * DestroyRandomInfo(RandomInfo *random_info)
Definition: random.c:274
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1288
MagickSizeType memory_limit
Definition: resource.c:94
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
Definition: locale.c:377
MagickBooleanType
Definition: magick-type.h:156
#define DirectorySeparator
Definition: studio.h:254
MagickExport int AcquireUniqueFileResource(char *path)
Definition: resource.c:580
MagickPrivate ssize_t GetMagickPageSize(void)
Definition: utility.c:1122
MagickExport const char * CommandOptionToMnemonic(const CommandOption option, const ssize_t type)
Definition: option.c:2667
static SplayTreeInfo * temporary_resources
Definition: resource.c:144
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition: string.c:843
MagickOffsetType list_length
Definition: resource.c:81
MagickSizeType time_limit
Definition: resource.c:94
MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
Definition: resource.c:1191
#define magick_unused(x)
MagickExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:682
size_t MagickSizeType
Definition: magick-type.h:128
#define MagickPathExtent
MagickOffsetType width
Definition: resource.c:81
MagickExport MagickBooleanType IsEventLogging(void)
Definition: log.c:716
MagickExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
Definition: splay-tree.c:1141
#define O_NOFOLLOW
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)
MagickExport RandomInfo * AcquireRandomInfo(void)
Definition: random.c:164
MagickExport MagickSizeType GetMagickResourceLimit(const ResourceType type)
Definition: resource.c:794
MagickExport char * GetEnvironmentValue(const char *name)
Definition: string.c:1255
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:748
MagickPrivate MagickBooleanType ShredFile(const char *)
Definition: utility.c:1812
#define S_MODE
Definition: studio.h:234
#define MagickMax(x, y)
Definition: image-private.h:26
MagickExport void AppendImageFormat(const char *format, char *filename)
Definition: utility.c:281
ResourceType
Definition: resource_.h:25
MagickSizeType throttle_limit
Definition: resource.c:94
MagickPrivate void AsynchronousResourceComponentTerminus(void)
Definition: resource.c:444
#define MagickFormatExtent
#define GetMagickModule()
Definition: log.h:28
MagickExport int CompareSplayTreeString(const void *target, const void *source)
Definition: splay-tree.c:412
MagickExport MagickSizeType GetMagickResource(const ResourceType type)
Definition: resource.c:701
#define MagickResourceInfinity
Definition: resource_.h:41
MagickExport const void * GetNextKeyInSplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:769
unsigned short Quantum
Definition: magick-type.h:82
MagickExport char * DestroyString(char *string)
Definition: string.c:816
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:97
MagickOffsetType throttle
Definition: resource.c:81
static MagickSizeType StringToMagickSizeType(const char *string, const double interval)
static int access_utf8(const char *path, int mode)
MagickSizeType list_length_limit
Definition: resource.c:94
MagickExport MagickBooleanType DeleteNodeFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
Definition: splay-tree.c:603
#define MagickMin(x, y)
Definition: image-private.h:27
MagickExport char * GetPolicyValue(const char *name)
Definition: policy.c:505
MagickSizeType thread_limit
Definition: resource.c:94
MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:1472
static RandomInfo * random_info
Definition: resource.c:111
MagickPrivate void ResetPixelCacheEpoch(void)
#define magick_unreferenced(x)
#define MagickPathTemplate
Definition: resource.c:73
MagickSizeType width_limit
Definition: resource.c:94
MagickExport void * GetImageRegistry(const RegistryType type, const char *key, ExceptionInfo *exception)
Definition: registry.c:187
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:279
#define MagickPrivate
#define MagickExport
MagickOffsetType height
Definition: resource.c:81
MagickExport StringInfo * GetRandomKey(RandomInfo *random_info, const size_t length)
Definition: random.c:710
#define TMP_MAX
MagickSizeType file_limit
Definition: resource.c:94
MagickExport size_t GetStringInfoLength(const StringInfo *string_info)
Definition: string.c:1317
MagickSizeType disk_limit
Definition: resource.c:94
MagickExport MagickBooleanType GetPathTemplate(char *path)
Definition: resource.c:495
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
MagickExport char * ConstantString(const char *source)
Definition: string.c:693
static SemaphoreInfo * resource_semaphore
Definition: resource.c:141
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:406
MagickPrivate void ResourceComponentTerminus(void)
Definition: resource.c:1395