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