00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "magick/studio.h"
00043 #include "magick/blob.h"
00044 #include "magick/client.h"
00045 #include "magick/configure.h"
00046 #include "magick/exception.h"
00047 #include "magick/exception-private.h"
00048 #include "magick/hashmap.h"
00049 #include "magick/log.h"
00050 #include "magick/memory_.h"
00051 #include "magick/semaphore.h"
00052 #include "magick/string_.h"
00053 #include "magick/token.h"
00054 #include "magick/utility.h"
00055 #include "magick/xml-tree.h"
00056
00057
00058
00059
00060 #define ConfigureFilename "configure.xml"
00061
00062
00063
00064
00065 static const char
00066 *ConfigureMap = (char *)
00067 "<?xml version=\"1.0\"?>"
00068 "<configuremap>"
00069 " <configure stealth=\"True\" />"
00070 "</configuremap>";
00071
00072 static LinkedListInfo
00073 *configure_list = (LinkedListInfo *) NULL;
00074
00075 static SemaphoreInfo
00076 *configure_semaphore = (SemaphoreInfo *) NULL;
00077
00078 static volatile MagickBooleanType
00079 instantiate_configure = MagickFalse;
00080
00081
00082
00083
00084 static MagickBooleanType
00085 InitializeConfigureList(ExceptionInfo *),
00086 LoadConfigureLists(const char *,ExceptionInfo *);
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 static void *DestroyConfigureElement(void *configure_info)
00108 {
00109 register ConfigureInfo
00110 *p;
00111
00112 p=(ConfigureInfo *) configure_info;
00113 if (p->path != (char *) NULL)
00114 p->path=DestroyString(p->path);
00115 if (p->name != (char *) NULL)
00116 p->name=DestroyString(p->name);
00117 if (p->value != (char *) NULL)
00118 p->value=DestroyString(p->value);
00119 p=(ConfigureInfo *) RelinquishMagickMemory(p);
00120 return((void *) NULL);
00121 }
00122
00123 MagickExport void DestroyConfigureList(void)
00124 {
00125 AcquireSemaphoreInfo(&configure_semaphore);
00126 if (configure_list != (LinkedListInfo *) NULL)
00127 configure_list=DestroyLinkedList(configure_list,DestroyConfigureElement);
00128 configure_list=(LinkedListInfo *) NULL;
00129 instantiate_configure=MagickFalse;
00130 RelinquishSemaphoreInfo(configure_semaphore);
00131 DestroySemaphoreInfo(&configure_semaphore);
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 static void *DestroyOptions(void *option)
00159 {
00160 return(DestroyStringInfo((StringInfo *) option));
00161 }
00162
00163 MagickExport LinkedListInfo *DestroyConfigureOptions(LinkedListInfo *options)
00164 {
00165 assert(options != (LinkedListInfo *) NULL);
00166 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00167 return(DestroyLinkedList(options,DestroyOptions));
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 MagickExport const ConfigureInfo *GetConfigureInfo(const char *name,
00200 ExceptionInfo *exception)
00201 {
00202 register const ConfigureInfo
00203 *p;
00204
00205 assert(exception != (ExceptionInfo *) NULL);
00206 if ((configure_list == (LinkedListInfo *) NULL) ||
00207 (instantiate_configure == MagickFalse))
00208 if (InitializeConfigureList(exception) == MagickFalse)
00209 return((const ConfigureInfo *) NULL);
00210 if ((configure_list == (LinkedListInfo *) NULL) ||
00211 (IsLinkedListEmpty(configure_list) != MagickFalse))
00212 return((const ConfigureInfo *) NULL);
00213 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
00214 return((const ConfigureInfo *) GetValueFromLinkedList(configure_list,0));
00215
00216
00217
00218 AcquireSemaphoreInfo(&configure_semaphore);
00219 ResetLinkedListIterator(configure_list);
00220 p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
00221 while (p != (const ConfigureInfo *) NULL)
00222 {
00223 if (LocaleCompare(name,p->name) == 0)
00224 break;
00225 p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
00226 }
00227 if (p != (ConfigureInfo *) NULL)
00228 (void) InsertValueInLinkedList(configure_list,0,
00229 RemoveElementByValueFromLinkedList(configure_list,p));
00230 RelinquishSemaphoreInfo(configure_semaphore);
00231 return(p);
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 #if defined(__cplusplus) || defined(c_plusplus)
00265 extern "C" {
00266 #endif
00267
00268 static int ConfigureInfoCompare(const void *x,const void *y)
00269 {
00270 const ConfigureInfo
00271 **p,
00272 **q;
00273
00274 p=(const ConfigureInfo **) x,
00275 q=(const ConfigureInfo **) y;
00276 if (LocaleCompare((*p)->path,(*q)->path) == 0)
00277 return(LocaleCompare((*p)->name,(*q)->name));
00278 return(LocaleCompare((*p)->path,(*q)->path));
00279 }
00280
00281 #if defined(__cplusplus) || defined(c_plusplus)
00282 }
00283 #endif
00284
00285 MagickExport const ConfigureInfo **GetConfigureInfoList(const char *pattern,
00286 unsigned long *number_options,ExceptionInfo *exception)
00287 {
00288 const ConfigureInfo
00289 **options;
00290
00291 register const ConfigureInfo
00292 *p;
00293
00294 register long
00295 i;
00296
00297
00298
00299
00300 assert(pattern != (char *) NULL);
00301 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
00302 assert(number_options != (unsigned long *) NULL);
00303 *number_options=0;
00304 p=GetConfigureInfo("*",exception);
00305 if (p == (const ConfigureInfo *) NULL)
00306 return((const ConfigureInfo **) NULL);
00307 options=(const ConfigureInfo **) AcquireQuantumMemory((size_t)
00308 GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options));
00309 if (options == (const ConfigureInfo **) NULL)
00310 return((const ConfigureInfo **) NULL);
00311
00312
00313
00314 AcquireSemaphoreInfo(&configure_semaphore);
00315 ResetLinkedListIterator(configure_list);
00316 p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
00317 for (i=0; p != (const ConfigureInfo *) NULL; )
00318 {
00319 if ((p->stealth == MagickFalse) &&
00320 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
00321 options[i++]=p;
00322 p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
00323 }
00324 RelinquishSemaphoreInfo(configure_semaphore);
00325 qsort((void *) options,(size_t) i,sizeof(*options),ConfigureInfoCompare);
00326 options[i]=(ConfigureInfo *) NULL;
00327 *number_options=(unsigned long) i;
00328 return(options);
00329 }
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 #if defined(__cplusplus) || defined(c_plusplus)
00361 extern "C" {
00362 #endif
00363
00364 static int ConfigureCompare(const void *x,const void *y)
00365 {
00366 register char
00367 **p,
00368 **q;
00369
00370 p=(char **) x;
00371 q=(char **) y;
00372 return(LocaleCompare(*p,*q));
00373 }
00374
00375 #if defined(__cplusplus) || defined(c_plusplus)
00376 }
00377 #endif
00378
00379 MagickExport char **GetConfigureList(const char *pattern,
00380 unsigned long *number_options,ExceptionInfo *exception)
00381 {
00382 char
00383 **options;
00384
00385 register const ConfigureInfo
00386 *p;
00387
00388 register long
00389 i;
00390
00391
00392
00393
00394 assert(pattern != (char *) NULL);
00395 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
00396 assert(number_options != (unsigned long *) NULL);
00397 *number_options=0;
00398 p=GetConfigureInfo("*",exception);
00399 if (p == (const ConfigureInfo *) NULL)
00400 return((char **) NULL);
00401 AcquireSemaphoreInfo(&configure_semaphore);
00402 RelinquishSemaphoreInfo(configure_semaphore);
00403 options=(char **) AcquireQuantumMemory((size_t)
00404 GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options));
00405 if (options == (char **) NULL)
00406 return((char **) NULL);
00407 AcquireSemaphoreInfo(&configure_semaphore);
00408 ResetLinkedListIterator(configure_list);
00409 p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
00410 for (i=0; p != (const ConfigureInfo *) NULL; )
00411 {
00412 if ((p->stealth == MagickFalse) &&
00413 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
00414 options[i++]=ConstantString(p->name);
00415 p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list);
00416 }
00417 RelinquishSemaphoreInfo(configure_semaphore);
00418 qsort((void *) options,(size_t) i,sizeof(*options),ConfigureCompare);
00419 options[i]=(char *) NULL;
00420 *number_options=(unsigned long) i;
00421 return(options);
00422 }
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 MagickExport char *GetConfigureOption(const char *option)
00447 {
00448 const char
00449 *value;
00450
00451 const ConfigureInfo
00452 *configure_info;
00453
00454 ExceptionInfo
00455 *exception;
00456
00457 assert(option != (const char *) NULL);
00458 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",option);
00459 exception=AcquireExceptionInfo();
00460 configure_info=GetConfigureInfo(option,exception);
00461 exception=DestroyExceptionInfo(exception);
00462 if (configure_info == (ConfigureInfo *) NULL)
00463 return((char *) NULL);
00464 value=GetConfigureValue(configure_info);
00465 if ((value == (const char *) NULL) || (*value == '\0'))
00466 return((char *) NULL);
00467 return(ConstantString(value));
00468 }
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496 MagickExport LinkedListInfo *GetConfigureOptions(const char *filename,
00497 ExceptionInfo *exception)
00498 {
00499 char
00500 path[MaxTextExtent];
00501
00502 const char
00503 *element;
00504
00505 LinkedListInfo
00506 *options,
00507 *paths;
00508
00509 StringInfo
00510 *xml;
00511
00512 assert(filename != (const char *) NULL);
00513 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
00514 assert(exception != (ExceptionInfo *) NULL);
00515 (void) CopyMagickString(path,filename,MaxTextExtent);
00516
00517
00518
00519 options=NewLinkedList(0);
00520 paths=GetConfigurePaths(filename,exception);
00521 if (paths != (LinkedListInfo *) NULL)
00522 {
00523 ResetLinkedListIterator(paths);
00524 element=(const char *) GetNextValueInLinkedList(paths);
00525 while (element != (const char *) NULL)
00526 {
00527 (void) FormatMagickString(path,MaxTextExtent,"%s%s",element,filename);
00528 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
00529 "Searching for configure file: \"%s\"",path);
00530 xml=ConfigureFileToStringInfo(path);
00531 if (xml != (StringInfo *) NULL)
00532 (void) AppendValueToLinkedList(options,xml);
00533 element=(const char *) GetNextValueInLinkedList(paths);
00534 }
00535 paths=DestroyLinkedList(paths,RelinquishMagickMemory);
00536 }
00537 #if defined(__WINDOWS__)
00538 {
00539 char
00540 *blob;
00541
00542 blob=(char *) NTResourceToBlob(filename);
00543 if (blob != (char *) NULL)
00544 {
00545 xml=StringToStringInfo(blob);
00546 SetStringInfoPath(xml,filename);
00547 (void) AppendValueToLinkedList(options,xml);
00548 blob=DestroyString(blob);
00549 }
00550 }
00551 #endif
00552 if (GetNumberOfElementsInLinkedList(options) == 0)
00553 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning,
00554 "UnableToOpenConfigureFile","`%s'",filename);
00555 ResetLinkedListIterator(options);
00556 return(options);
00557 }
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585 MagickExport LinkedListInfo *GetConfigurePaths(const char *filename,
00586 ExceptionInfo *exception)
00587 {
00588 char
00589 path[MaxTextExtent];
00590
00591 LinkedListInfo
00592 *paths;
00593
00594 assert(filename != (const char *) NULL);
00595 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
00596 assert(exception != (ExceptionInfo *) NULL);
00597 (void) CopyMagickString(path,filename,MaxTextExtent);
00598 paths=NewLinkedList(0);
00599 {
00600 char
00601 *configure_path;
00602
00603
00604
00605
00606 configure_path=GetEnvironmentValue("MAGICK_CONFIGURE_PATH");
00607 if (configure_path != (char *) NULL)
00608 {
00609 register char
00610 *p,
00611 *q;
00612
00613 for (p=configure_path-1; p != (char *) NULL; )
00614 {
00615 (void) CopyMagickString(path,p+1,MaxTextExtent);
00616 q=strchr(path,DirectoryListSeparator);
00617 if (q != (char *) NULL)
00618 *q='\0';
00619 q=path+strlen(path)-1;
00620 if ((q >= path) && (*q != *DirectorySeparator))
00621 (void) ConcatenateMagickString(path,DirectorySeparator,
00622 MaxTextExtent);
00623 (void) AppendValueToLinkedList(paths,ConstantString(path));
00624 p=strchr(p+1,DirectoryListSeparator);
00625 }
00626 configure_path=DestroyString(configure_path);
00627 }
00628 }
00629 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
00630 #if defined(MAGICKCORE_SHARE_CONFIGURE_PATH)
00631 (void) AppendValueToLinkedList(paths,ConstantString(
00632 MAGICKCORE_SHARE_CONFIGURE_PATH));
00633 #endif
00634 #if defined(MAGICKCORE_CONFIGURE_PATH)
00635 (void) AppendValueToLinkedList(paths,ConstantString(
00636 MAGICKCORE_CONFIGURE_PATH));
00637 #endif
00638 #if defined(MAGICKCORE_DOCUMENTATION_PATH)
00639 (void) AppendValueToLinkedList(paths,ConstantString(
00640 MAGICKCORE_DOCUMENTATION_PATH));
00641 #endif
00642 #if defined(MAGICKCORE_SHARE_PATH)
00643 (void) AppendValueToLinkedList(paths,ConstantString(MAGICKCORE_SHARE_PATH));
00644 #endif
00645 #if defined(__WINDOWS__) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_CONFIGURE_PATH))
00646 {
00647 char
00648 *registry_key;
00649
00650 unsigned char
00651 *key_value;
00652
00653
00654
00655
00656 registry_key="ConfigurePath";
00657 key_value=NTRegistryKeyLookup(registry_key);
00658 if (key_value != (unsigned char *) NULL)
00659 {
00660 (void) FormatMagickString(path,MaxTextExtent,"%s%s",(char *) key_value,
00661 DirectorySeparator);
00662 (void) AppendValueToLinkedList(paths,ConstantString(path));
00663 key_value=(unsigned char *) RelinquishMagickMemory(key_value);
00664 }
00665 }
00666 #endif
00667 #else
00668 {
00669 char
00670 *home;
00671
00672
00673
00674
00675 home=GetEnvironmentValue("MAGICK_HOME");
00676 if (home != (char *) NULL)
00677 {
00678 #if !defined(MAGICKCORE_POSIX_SUPPORT)
00679 (void) FormatMagickString(path,MaxTextExtent,"%s%s",home,
00680 DirectorySeparator);
00681 (void) AppendValueToLinkedList(paths,ConstantString(path));
00682 #else
00683 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/",home,
00684 MAGICKCORE_CONFIGURE_RELATIVE_PATH);
00685 (void) AppendValueToLinkedList(paths,ConstantString(path));
00686 (void) FormatMagickString(path,MaxTextExtent,"%s/share/%s/",home,
00687 MAGICKCORE_SHARE_CONFIGURE_RELATIVE_PATH);
00688 (void) AppendValueToLinkedList(paths,ConstantString(path));
00689 #endif
00690 home=DestroyString(home);
00691 }
00692 }
00693 if (*GetClientPath() != '\0')
00694 {
00695 #if !defined(MAGICKCORE_POSIX_SUPPORT)
00696 (void) FormatMagickString(path,MaxTextExtent,"%s%s",GetClientPath(),
00697 DirectorySeparator);
00698 (void) AppendValueToLinkedList(paths,ConstantString(path));
00699 #else
00700 char
00701 prefix[MaxTextExtent];
00702
00703
00704
00705
00706 (void) CopyMagickString(prefix,GetClientPath(),MaxTextExtent);
00707 ChopPathComponents(prefix,1);
00708 (void) FormatMagickString(path,MaxTextExtent,"%s/share/%s/",prefix,
00709 MAGICKCORE_SHARE_CONFIGURE_RELATIVE_PATH);
00710 (void) AppendValueToLinkedList(paths,ConstantString(path));
00711 (void) FormatMagickString(path,MaxTextExtent,"%s/lib/%s/",prefix,
00712 MAGICKCORE_CONFIGURE_RELATIVE_PATH);
00713 (void) AppendValueToLinkedList(paths,ConstantString(path));
00714 #endif
00715 }
00716 #endif
00717 {
00718 char
00719 *home;
00720
00721 home=GetEnvironmentValue("HOME");
00722 if (home == (char *) NULL)
00723 home=GetEnvironmentValue("USERPROFILE");
00724 if (home != (char *) NULL)
00725 {
00726
00727
00728
00729 (void) FormatMagickString(path,MaxTextExtent,"%s%s.magick%s",home,
00730 DirectorySeparator,DirectorySeparator);
00731 (void) AppendValueToLinkedList(paths,ConstantString(path));
00732 home=DestroyString(home);
00733 }
00734 }
00735 #if defined(__WINDOWS__)
00736 {
00737 char
00738 module_path[MaxTextExtent];
00739
00740 if ((NTGetModulePath("CORE_RL_magick_.dll",module_path) != MagickFalse) ||
00741 (NTGetModulePath("CORE_DB_magick_.dll",module_path) != MagickFalse))
00742 {
00743 char
00744 *element;
00745
00746
00747
00748
00749 (void) FormatMagickString(path,MaxTextExtent,"%s%s",module_path,
00750 DirectorySeparator);
00751 element=(char *) RemoveElementByValueFromLinkedList(paths,path);
00752 if (element != (char *) NULL)
00753 element=DestroyString(element);
00754 (void) AppendValueToLinkedList(paths,ConstantString(path));
00755 }
00756 if (NTGetModulePath("Magick.dll",module_path) != MagickFalse)
00757 {
00758
00759
00760
00761 (void) FormatMagickString(path,MaxTextExtent,"%s%s",module_path,
00762 DirectorySeparator);
00763 (void) AppendValueToLinkedList(paths,ConstantString(path));
00764 (void) FormatMagickString(path,MaxTextExtent,"%s%s",module_path,
00765 "\\inc\\lib\\auto\\Image\\Magick\\");
00766 (void) AppendValueToLinkedList(paths,ConstantString(path));
00767 }
00768 }
00769 #endif
00770
00771
00772
00773 (void) AppendValueToLinkedList(paths,ConstantString(""));
00774 return(paths);
00775 }
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 MagickExport const char *GetConfigureValue(const ConfigureInfo *configure_info)
00800 {
00801 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00802 assert(configure_info != (ConfigureInfo *) NULL);
00803 assert(configure_info->signature == MagickSignature);
00804 return(configure_info->value);
00805 }
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829 static MagickBooleanType InitializeConfigureList(ExceptionInfo *exception)
00830 {
00831 if ((configure_list == (LinkedListInfo *) NULL) &&
00832 (instantiate_configure == MagickFalse))
00833 {
00834 AcquireSemaphoreInfo(&configure_semaphore);
00835 if ((configure_list == (LinkedListInfo *) NULL) &&
00836 (instantiate_configure == MagickFalse))
00837 {
00838 (void) LoadConfigureLists(ConfigureFilename,exception);
00839 instantiate_configure=MagickTrue;
00840 }
00841 RelinquishSemaphoreInfo(configure_semaphore);
00842 }
00843 return(configure_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
00844 }
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870 MagickExport MagickBooleanType ListConfigureInfo(FILE *file,
00871 ExceptionInfo *exception)
00872 {
00873 const char
00874 *name,
00875 *path,
00876 *value;
00877
00878 const ConfigureInfo
00879 **configure_info;
00880
00881 long
00882 j;
00883
00884 register long
00885 i;
00886
00887 unsigned long
00888 number_options;
00889
00890 if (file == (const FILE *) NULL)
00891 file=stdout;
00892 configure_info=GetConfigureInfoList("*",&number_options,exception);
00893 if (configure_info == (const ConfigureInfo **) NULL)
00894 return(MagickFalse);
00895 path=(const char *) NULL;
00896 for (i=0; i < (long) number_options; i++)
00897 {
00898 if (configure_info[i]->stealth != MagickFalse)
00899 continue;
00900 if ((path == (const char *) NULL) ||
00901 (LocaleCompare(path,configure_info[i]->path) != 0))
00902 {
00903 if (configure_info[i]->path != (char *) NULL)
00904 (void) fprintf(file,"\nPath: %s\n\n",configure_info[i]->path);
00905 (void) fprintf(file,"Name Value\n");
00906 (void) fprintf(file,"-------------------------------------------------"
00907 "------------------------------\n");
00908 }
00909 path=configure_info[i]->path;
00910 name="unknown";
00911 if (configure_info[i]->name != (char *) NULL)
00912 name=configure_info[i]->name;
00913 (void) fprintf(file,"%s",name);
00914 for (j=(long) strlen(name); j <= 12; j++)
00915 (void) fprintf(file," ");
00916 (void) fprintf(file," ");
00917 value="unknown";
00918 if (configure_info[i]->value != (char *) NULL)
00919 value=configure_info[i]->value;
00920 (void) fprintf(file,"%s",value);
00921 (void) fprintf(file,"\n");
00922 }
00923 (void) fflush(file);
00924 configure_info=(const ConfigureInfo **)
00925 RelinquishMagickMemory((void *) configure_info);
00926 return(MagickTrue);
00927 }
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959 static MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
00960 const unsigned long depth,ExceptionInfo *exception)
00961 {
00962 char
00963 keyword[MaxTextExtent],
00964 *token;
00965
00966 ConfigureInfo
00967 *configure_info;
00968
00969 const char
00970 *q;
00971
00972 MagickBooleanType
00973 status;
00974
00975
00976
00977
00978 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
00979 "Loading configure file \"%s\" ...",filename);
00980 if (configure_list == (LinkedListInfo *) NULL)
00981 {
00982 configure_list=NewLinkedList(0);
00983 if (configure_list == (LinkedListInfo *) NULL)
00984 {
00985 ThrowFileException(exception,ResourceLimitError,
00986 "MemoryAllocationFailed",filename);
00987 return(MagickFalse);
00988 }
00989 }
00990 status=MagickTrue;
00991 configure_info=(ConfigureInfo *) NULL;
00992 if (xml == (char *) NULL)
00993 token=AcquireString(ConfigureMap);
00994 else
00995 token=AcquireString((char *) xml);
00996 for (q=(char *) xml; *q != '\0'; )
00997 {
00998
00999
01000
01001 GetMagickToken(q,&q,token);
01002 if (*token == '\0')
01003 break;
01004 (void) CopyMagickString(keyword,token,MaxTextExtent);
01005 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
01006 {
01007
01008
01009
01010 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
01011 GetMagickToken(q,&q,token);
01012 continue;
01013 }
01014 if (LocaleNCompare(keyword,"<!--",4) == 0)
01015 {
01016
01017
01018
01019 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
01020 GetMagickToken(q,&q,token);
01021 continue;
01022 }
01023 if (LocaleCompare(keyword,"<include") == 0)
01024 {
01025
01026
01027
01028 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
01029 {
01030 (void) CopyMagickString(keyword,token,MaxTextExtent);
01031 GetMagickToken(q,&q,token);
01032 if (*token != '=')
01033 continue;
01034 GetMagickToken(q,&q,token);
01035 if (LocaleCompare(keyword,"file") == 0)
01036 {
01037 if (depth > 200)
01038 (void) ThrowMagickException(exception,GetMagickModule(),
01039 ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
01040 else
01041 {
01042 char
01043 path[MaxTextExtent],
01044 *xml;
01045
01046 GetPathComponent(filename,HeadPath,path);
01047 if (*path != '\0')
01048 (void) ConcatenateMagickString(path,DirectorySeparator,
01049 MaxTextExtent);
01050 if (*token == *DirectorySeparator)
01051 (void) CopyMagickString(path,token,MaxTextExtent);
01052 else
01053 (void) ConcatenateMagickString(path,token,MaxTextExtent);
01054 xml=FileToString(path,~0,exception);
01055 if (xml != (char *) NULL)
01056 {
01057 status=LoadConfigureList(xml,path,depth+1,exception);
01058 xml=(char *) RelinquishMagickMemory(xml);
01059 }
01060 }
01061 }
01062 }
01063 continue;
01064 }
01065 if (LocaleCompare(keyword,"<configure") == 0)
01066 {
01067
01068
01069
01070 configure_info=(ConfigureInfo *) AcquireMagickMemory(
01071 sizeof(*configure_info));
01072 if (configure_info == (ConfigureInfo *) NULL)
01073 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
01074 (void) ResetMagickMemory(configure_info,0,sizeof(*configure_info));
01075 configure_info->path=ConstantString(filename);
01076 configure_info->signature=MagickSignature;
01077 continue;
01078 }
01079 if (configure_info == (ConfigureInfo *) NULL)
01080 continue;
01081 if (LocaleCompare(keyword,"/>") == 0)
01082 {
01083 status=AppendValueToLinkedList(configure_list,configure_info);
01084 if (status == MagickFalse)
01085 (void) ThrowMagickException(exception,GetMagickModule(),
01086 ResourceLimitError,"MemoryAllocationFailed","`%s'",
01087 configure_info->name);
01088 configure_info=(ConfigureInfo *) NULL;
01089 }
01090
01091
01092
01093 GetMagickToken(q,(const char **) NULL,token);
01094 if (*token != '=')
01095 continue;
01096 GetMagickToken(q,&q,token);
01097 GetMagickToken(q,&q,token);
01098 switch (*keyword)
01099 {
01100 case 'N':
01101 case 'n':
01102 {
01103 if (LocaleCompare((char *) keyword,"name") == 0)
01104 {
01105 configure_info->name=ConstantString(token);
01106 break;
01107 }
01108 break;
01109 }
01110 case 'S':
01111 case 's':
01112 {
01113 if (LocaleCompare((char *) keyword,"stealth") == 0)
01114 {
01115 configure_info->stealth=IsMagickTrue(token);
01116 break;
01117 }
01118 break;
01119 }
01120 case 'V':
01121 case 'v':
01122 {
01123 if (LocaleCompare((char *) keyword,"value") == 0)
01124 {
01125 configure_info->value=ConstantString(token);
01126 break;
01127 }
01128 break;
01129 }
01130 default:
01131 break;
01132 }
01133 }
01134 token=(char *) RelinquishMagickMemory(token);
01135 return(status);
01136 }
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164 static MagickBooleanType LoadConfigureLists(const char *filename,
01165 ExceptionInfo *exception)
01166 {
01167 #if defined(MAGICKCORE_EMBEDDABLE_SUPPORT)
01168 return(LoadConfigureList(ConfigureMap,"built-in",0,exception));
01169 #else
01170 const StringInfo
01171 *option;
01172
01173 LinkedListInfo
01174 *options;
01175
01176 MagickStatusType
01177 status;
01178
01179 status=MagickFalse;
01180 options=GetConfigureOptions(filename,exception);
01181 option=(const StringInfo *) GetNextValueInLinkedList(options);
01182 while (option != (const StringInfo *) NULL)
01183 {
01184 status|=LoadConfigureList((const char *) GetStringInfoDatum(option),
01185 GetStringInfoPath(option),0,exception);
01186 option=(const StringInfo *) GetNextValueInLinkedList(options);
01187 }
01188 options=DestroyConfigureOptions(options);
01189 if ((configure_list == (LinkedListInfo *) NULL) ||
01190 (IsLinkedListEmpty(configure_list) != MagickFalse))
01191 status|=LoadConfigureList(ConfigureMap,"built-in",0,exception);
01192 return(status != 0 ? MagickTrue : MagickFalse);
01193 #endif
01194 }