| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | #include "wizard/studio.h" |
|---|
| 43 | #include "wizard/blob.h" |
|---|
| 44 | #include "wizard/client.h" |
|---|
| 45 | #include "wizard/configure.h" |
|---|
| 46 | #include "wizard/exception.h" |
|---|
| 47 | #include "wizard/exception-private.h" |
|---|
| 48 | #include "wizard/hashmap.h" |
|---|
| 49 | #include "wizard/log.h" |
|---|
| 50 | #include "wizard/memory_.h" |
|---|
| 51 | #include "wizard/semaphore.h" |
|---|
| 52 | #include "wizard/string_.h" |
|---|
| 53 | #include "wizard/token.h" |
|---|
| 54 | #include "wizard/utility.h" |
|---|
| 55 | #include "wizard/xml-tree.h" |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | #define ConfigureFilename "configure.xml" |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | typedef struct _ConfigureMapInfo |
|---|
| 66 | { |
|---|
| 67 | const char |
|---|
| 68 | *name, |
|---|
| 69 | *value; |
|---|
| 70 | } ConfigureMapInfo; |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | static const ConfigureMapInfo |
|---|
| 76 | ConfigureMap[] = |
|---|
| 77 | { |
|---|
| 78 | { "NAME", "ImageMagick" } |
|---|
| 79 | }; |
|---|
| 80 | |
|---|
| 81 | static LinkedListInfo |
|---|
| 82 | *configure_list = (LinkedListInfo *) NULL; |
|---|
| 83 | |
|---|
| 84 | static SemaphoreInfo |
|---|
| 85 | *configure_semaphore = (SemaphoreInfo *) NULL; |
|---|
| 86 | |
|---|
| 87 | static volatile WizardBooleanType |
|---|
| 88 | instantiate_configure = WizardFalse; |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | static WizardBooleanType |
|---|
| 94 | InitializeConfigureList(ExceptionInfo *), |
|---|
| 95 | LoadConfigureLists(const char *,ExceptionInfo *); |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | WizardExport WizardBooleanType ConfigureComponentGenesis(void) |
|---|
| 116 | { |
|---|
| 117 | AcquireSemaphoreInfo(&configure_semaphore); |
|---|
| 118 | return(WizardTrue); |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | static void *DestroyConfigureElement(void *configure_info) |
|---|
| 142 | { |
|---|
| 143 | register ConfigureInfo |
|---|
| 144 | *p; |
|---|
| 145 | |
|---|
| 146 | p=(ConfigureInfo *) configure_info; |
|---|
| 147 | if (p->exempt == WizardFalse) |
|---|
| 148 | { |
|---|
| 149 | if (p->value != (char *) NULL) |
|---|
| 150 | p->value=(char *) RelinquishWizardMemory(p->value); |
|---|
| 151 | if (p->name != (char *) NULL) |
|---|
| 152 | p->name=(char *) RelinquishWizardMemory(p->name); |
|---|
| 153 | if (p->path != (char *) NULL) |
|---|
| 154 | p->path=(char *) RelinquishWizardMemory(p->path); |
|---|
| 155 | } |
|---|
| 156 | p=(ConfigureInfo *) RelinquishWizardMemory(p); |
|---|
| 157 | return((void *) NULL); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | WizardExport void ConfigureComponentTerminus(void) |
|---|
| 161 | { |
|---|
| 162 | if (configure_semaphore == (SemaphoreInfo *) NULL) |
|---|
| 163 | AcquireSemaphoreInfo(&configure_semaphore); |
|---|
| 164 | (void) LockSemaphoreInfo(configure_semaphore); |
|---|
| 165 | if (configure_list != (LinkedListInfo *) NULL) |
|---|
| 166 | configure_list=DestroyLinkedList(configure_list,DestroyConfigureElement); |
|---|
| 167 | configure_list=(LinkedListInfo *) NULL; |
|---|
| 168 | instantiate_configure=WizardFalse; |
|---|
| 169 | (void) UnlockSemaphoreInfo(configure_semaphore); |
|---|
| 170 | DestroySemaphoreInfo(&configure_semaphore); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | static void *DestroyOptions(void *option) |
|---|
| 198 | { |
|---|
| 199 | return(DestroyStringInfo((StringInfo *) option)); |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | WizardExport LinkedListInfo *DestroyConfigureOptions(LinkedListInfo *options) |
|---|
| 203 | { |
|---|
| 204 | assert(options != (LinkedListInfo *) NULL); |
|---|
| 205 | (void) LogWizardEvent(TraceEvent,GetWizardModule(),"..."); |
|---|
| 206 | return(DestroyLinkedList(options,DestroyOptions)); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | WizardExport const ConfigureInfo *GetConfigureInfo(const char *name, |
|---|
| 239 | ExceptionInfo *exception) |
|---|
| 240 | { |
|---|
| 241 | register const ConfigureInfo |
|---|
| 242 | *p; |
|---|
| 243 | |
|---|
| 244 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 245 | if ((configure_list == (LinkedListInfo *) NULL) || |
|---|
| 246 | (instantiate_configure == WizardFalse)) |
|---|
| 247 | if (InitializeConfigureList(exception) == WizardFalse) |
|---|
| 248 | return((const ConfigureInfo *) NULL); |
|---|
| 249 | if ((configure_list == (LinkedListInfo *) NULL) || |
|---|
| 250 | (IsLinkedListEmpty(configure_list) != WizardFalse)) |
|---|
| 251 | return((const ConfigureInfo *) NULL); |
|---|
| 252 | if ((name == (const char *) NULL) || (strcasecmp(name,"*") == 0)) |
|---|
| 253 | return((const ConfigureInfo *) GetValueFromLinkedList(configure_list,0)); |
|---|
| 254 | |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | (void) LockSemaphoreInfo(configure_semaphore); |
|---|
| 258 | ResetLinkedListIterator(configure_list); |
|---|
| 259 | p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); |
|---|
| 260 | while (p != (const ConfigureInfo *) NULL) |
|---|
| 261 | { |
|---|
| 262 | if (strcasecmp(name,p->name) == 0) |
|---|
| 263 | break; |
|---|
| 264 | p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); |
|---|
| 265 | } |
|---|
| 266 | if (p == (ConfigureInfo *) NULL) |
|---|
| 267 | (void) ThrowWizardException(exception,GetWizardModule(),OptionWarning, |
|---|
| 268 | "no such configure list `%s'",name); |
|---|
| 269 | else |
|---|
| 270 | (void) InsertValueInLinkedList(configure_list,0, |
|---|
| 271 | RemoveElementByValueFromLinkedList(configure_list,p)); |
|---|
| 272 | (void) UnlockSemaphoreInfo(configure_semaphore); |
|---|
| 273 | return(p); |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | |
|---|
| 291 | |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | |
|---|
| 306 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 307 | extern "C" { |
|---|
| 308 | #endif |
|---|
| 309 | |
|---|
| 310 | static int ConfigureInfoCompare(const void *x,const void *y) |
|---|
| 311 | { |
|---|
| 312 | const ConfigureInfo |
|---|
| 313 | **p, |
|---|
| 314 | **q; |
|---|
| 315 | |
|---|
| 316 | p=(const ConfigureInfo **) x, |
|---|
| 317 | q=(const ConfigureInfo **) y; |
|---|
| 318 | if (strcasecmp((*p)->path,(*q)->path) == 0) |
|---|
| 319 | return(strcasecmp((*p)->name,(*q)->name)); |
|---|
| 320 | return(strcasecmp((*p)->path,(*q)->path)); |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 324 | } |
|---|
| 325 | #endif |
|---|
| 326 | |
|---|
| 327 | WizardExport const ConfigureInfo **GetConfigureInfoList(const char *pattern, |
|---|
| 328 | unsigned long *number_options,ExceptionInfo *exception) |
|---|
| 329 | { |
|---|
| 330 | const ConfigureInfo |
|---|
| 331 | **options; |
|---|
| 332 | |
|---|
| 333 | register const ConfigureInfo |
|---|
| 334 | *p; |
|---|
| 335 | |
|---|
| 336 | register long |
|---|
| 337 | i; |
|---|
| 338 | |
|---|
| 339 | |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | assert(pattern != (char *) NULL); |
|---|
| 343 | (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",pattern); |
|---|
| 344 | assert(number_options != (unsigned long *) NULL); |
|---|
| 345 | *number_options=0; |
|---|
| 346 | p=GetConfigureInfo("*",exception); |
|---|
| 347 | if (p == (const ConfigureInfo *) NULL) |
|---|
| 348 | return((const ConfigureInfo **) NULL); |
|---|
| 349 | options=(const ConfigureInfo **) AcquireQuantumMemory((size_t) |
|---|
| 350 | GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options)); |
|---|
| 351 | if (options == (const ConfigureInfo **) NULL) |
|---|
| 352 | return((const ConfigureInfo **) NULL); |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | |
|---|
| 356 | (void) LockSemaphoreInfo(configure_semaphore); |
|---|
| 357 | ResetLinkedListIterator(configure_list); |
|---|
| 358 | p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); |
|---|
| 359 | for (i=0; p != (const ConfigureInfo *) NULL; ) |
|---|
| 360 | { |
|---|
| 361 | if ((p->stealth == WizardFalse) && |
|---|
| 362 | (GlobExpression(p->name,pattern,WizardFalse) != WizardFalse)) |
|---|
| 363 | options[i++]=p; |
|---|
| 364 | p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); |
|---|
| 365 | } |
|---|
| 366 | (void) UnlockSemaphoreInfo(configure_semaphore); |
|---|
| 367 | qsort((void *) options,(size_t) i,sizeof(*options),ConfigureInfoCompare); |
|---|
| 368 | options[i]=(ConfigureInfo *) NULL; |
|---|
| 369 | *number_options=(unsigned long) i; |
|---|
| 370 | return(options); |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | |
|---|
| 375 | |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | |
|---|
| 402 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 403 | extern "C" { |
|---|
| 404 | #endif |
|---|
| 405 | |
|---|
| 406 | static int ConfigureCompare(const void *x,const void *y) |
|---|
| 407 | { |
|---|
| 408 | register char |
|---|
| 409 | **p, |
|---|
| 410 | **q; |
|---|
| 411 | |
|---|
| 412 | p=(char **) x; |
|---|
| 413 | q=(char **) y; |
|---|
| 414 | return(strcasecmp(*p,*q)); |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 418 | } |
|---|
| 419 | #endif |
|---|
| 420 | |
|---|
| 421 | WizardExport char **GetConfigureList(const char *pattern, |
|---|
| 422 | unsigned long *number_options,ExceptionInfo *exception) |
|---|
| 423 | { |
|---|
| 424 | char |
|---|
| 425 | **options; |
|---|
| 426 | |
|---|
| 427 | register const ConfigureInfo |
|---|
| 428 | *p; |
|---|
| 429 | |
|---|
| 430 | register long |
|---|
| 431 | i; |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | |
|---|
| 436 | assert(pattern != (char *) NULL); |
|---|
| 437 | (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",pattern); |
|---|
| 438 | assert(number_options != (unsigned long *) NULL); |
|---|
| 439 | *number_options=0; |
|---|
| 440 | p=GetConfigureInfo("*",exception); |
|---|
| 441 | if (p == (const ConfigureInfo *) NULL) |
|---|
| 442 | return((char **) NULL); |
|---|
| 443 | (void) LockSemaphoreInfo(configure_semaphore); |
|---|
| 444 | (void) UnlockSemaphoreInfo(configure_semaphore); |
|---|
| 445 | options=(char **) AcquireQuantumMemory((size_t) |
|---|
| 446 | GetNumberOfElementsInLinkedList(configure_list)+1UL,sizeof(*options)); |
|---|
| 447 | if (options == (char **) NULL) |
|---|
| 448 | return((char **) NULL); |
|---|
| 449 | (void) LockSemaphoreInfo(configure_semaphore); |
|---|
| 450 | ResetLinkedListIterator(configure_list); |
|---|
| 451 | p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); |
|---|
| 452 | for (i=0; p != (const ConfigureInfo *) NULL; ) |
|---|
| 453 | { |
|---|
| 454 | if ((p->stealth == WizardFalse) && |
|---|
| 455 | (GlobExpression(p->name,pattern,WizardFalse) != WizardFalse)) |
|---|
| 456 | options[i++]=ConstantString(p->name); |
|---|
| 457 | p=(const ConfigureInfo *) GetNextValueInLinkedList(configure_list); |
|---|
| 458 | } |
|---|
| 459 | (void) UnlockSemaphoreInfo(configure_semaphore); |
|---|
| 460 | qsort((void *) options,(size_t) i,sizeof(*options),ConfigureCompare); |
|---|
| 461 | options[i]=(char *) NULL; |
|---|
| 462 | *number_options=(unsigned long) i; |
|---|
| 463 | return(options); |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | |
|---|
| 490 | |
|---|
| 491 | |
|---|
| 492 | WizardExport LinkedListInfo *GetConfigureOptions(const char *filename, |
|---|
| 493 | ExceptionInfo *exception) |
|---|
| 494 | { |
|---|
| 495 | char |
|---|
| 496 | path[MaxTextExtent]; |
|---|
| 497 | |
|---|
| 498 | const char |
|---|
| 499 | *element; |
|---|
| 500 | |
|---|
| 501 | LinkedListInfo |
|---|
| 502 | *options, |
|---|
| 503 | *paths; |
|---|
| 504 | |
|---|
| 505 | StringInfo |
|---|
| 506 | *xml; |
|---|
| 507 | |
|---|
| 508 | assert(filename != (const char *) NULL); |
|---|
| 509 | (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",filename); |
|---|
| 510 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 511 | (void) CopyWizardString(path,filename,MaxTextExtent); |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | |
|---|
| 515 | options=NewLinkedList(0); |
|---|
| 516 | paths=GetConfigurePaths(filename,exception); |
|---|
| 517 | if (paths != (LinkedListInfo *) NULL) |
|---|
| 518 | { |
|---|
| 519 | ResetLinkedListIterator(paths); |
|---|
| 520 | element=(const char *) GetNextValueInLinkedList(paths); |
|---|
| 521 | while (element != (const char *) NULL) |
|---|
| 522 | { |
|---|
| 523 | (void) FormatWizardString(path,MaxTextExtent,"%s%s",element,filename); |
|---|
| 524 | (void) LogWizardEvent(ConfigureEvent,GetWizardModule(), |
|---|
| 525 | "Searching for configure file: \"%s\"",path); |
|---|
| 526 | xml=ConfigureFileToStringInfo(path); |
|---|
| 527 | if (xml != (StringInfo *) NULL) |
|---|
| 528 | (void) AppendValueToLinkedList(options,xml); |
|---|
| 529 | element=(const char *) GetNextValueInLinkedList(paths); |
|---|
| 530 | } |
|---|
| 531 | paths=DestroyLinkedList(paths,RelinquishWizardMemory); |
|---|
| 532 | } |
|---|
| 533 | #if defined(__WINDOWS__) |
|---|
| 534 | { |
|---|
| 535 | char |
|---|
| 536 | *blob; |
|---|
| 537 | |
|---|
| 538 | blob=(char *) NTResourceToBlob(filename); |
|---|
| 539 | if (blob != (char *) NULL) |
|---|
| 540 | { |
|---|
| 541 | xml=StringToStringInfo(blob); |
|---|
| 542 | SetStringInfoPath(xml,filename); |
|---|
| 543 | (void) AppendValueToLinkedList(options,xml); |
|---|
| 544 | blob=(char *) RelinquishWizardMemory(blob); |
|---|
| 545 | } |
|---|
| 546 | } |
|---|
| 547 | #endif |
|---|
| 548 | if (GetNumberOfElementsInLinkedList(options) == 0) |
|---|
| 549 | (void) ThrowWizardException(exception,GetWizardModule(),ConfigureWarning, |
|---|
| 550 | "unable to open configure file `%s'",filename); |
|---|
| 551 | ResetLinkedListIterator(options); |
|---|
| 552 | return(options); |
|---|
| 553 | } |
|---|
| 554 | |
|---|
| 555 | |
|---|
| 556 | |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | |
|---|
| 560 | |
|---|
| 561 | |
|---|
| 562 | |
|---|
| 563 | |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | |
|---|
| 567 | |
|---|
| 568 | |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | |
|---|
| 572 | |
|---|
| 573 | |
|---|
| 574 | |
|---|
| 575 | |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | |
|---|
| 579 | |
|---|
| 580 | |
|---|
| 581 | WizardExport LinkedListInfo *GetConfigurePaths(const char *filename, |
|---|
| 582 | ExceptionInfo *exception) |
|---|
| 583 | { |
|---|
| 584 | char |
|---|
| 585 | path[MaxTextExtent]; |
|---|
| 586 | |
|---|
| 587 | LinkedListInfo |
|---|
| 588 | *paths; |
|---|
| 589 | |
|---|
| 590 | assert(filename != (const char *) NULL); |
|---|
| 591 | (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",filename); |
|---|
| 592 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 593 | (void) CopyWizardString(path,filename,MaxTextExtent); |
|---|
| 594 | paths=NewLinkedList(0); |
|---|
| 595 | { |
|---|
| 596 | char |
|---|
| 597 | *configure_path; |
|---|
| 598 | |
|---|
| 599 | register char |
|---|
| 600 | *q; |
|---|
| 601 | |
|---|
| 602 | register const char |
|---|
| 603 | *p; |
|---|
| 604 | |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | |
|---|
| 608 | configure_path=GetEnvironmentValue("WIZARD_CONFIGURE_PATH"); |
|---|
| 609 | if (configure_path != (char *) NULL) |
|---|
| 610 | { |
|---|
| 611 | for (p=configure_path-1; p != (char *) NULL; ) |
|---|
| 612 | { |
|---|
| 613 | (void) CopyWizardString(path,p+1,MaxTextExtent); |
|---|
| 614 | q=strchr(path,DirectoryListSeparator); |
|---|
| 615 | if (q != (char *) NULL) |
|---|
| 616 | *q='\0'; |
|---|
| 617 | q=path+strlen(path)-1; |
|---|
| 618 | if ((q >= path) && (*q != *DirectorySeparator)) |
|---|
| 619 | (void) ConcatenateWizardString(path,DirectorySeparator, |
|---|
| 620 | MaxTextExtent); |
|---|
| 621 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 622 | p=strchr(p+1,DirectoryListSeparator); |
|---|
| 623 | } |
|---|
| 624 | configure_path=(char *) RelinquishWizardMemory(configure_path); |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | #if defined(WIZARDSTOOLKIT_INSTALLED_SUPPORT) |
|---|
| 628 | #if defined(WIZARDSTOOLKIT_CONFIGURE_PATH) |
|---|
| 629 | (void) AppendValueToLinkedList(paths,AcquireString( |
|---|
| 630 | WIZARDSTOOLKIT_CONFIGURE_PATH)); |
|---|
| 631 | #endif |
|---|
| 632 | #if defined(WIZARDSTOOLKIT_SHARE_CONFIGURE_PATH) |
|---|
| 633 | (void) AppendValueToLinkedList(paths,AcquireString( |
|---|
| 634 | WIZARDSTOOLKIT_SHARE_CONFIGURE_PATH)); |
|---|
| 635 | #endif |
|---|
| 636 | #if defined(WIZARDSTOOLKIT_DOCUMENTATION_PATH) |
|---|
| 637 | (void) AppendValueToLinkedList(paths,AcquireString( |
|---|
| 638 | WIZARDSTOOLKIT_DOCUMENTATION_PATH)); |
|---|
| 639 | #endif |
|---|
| 640 | #if defined(WIZARDSTOOLKIT_SHARE_PATH) |
|---|
| 641 | (void) AppendValueToLinkedList(paths,AcquireString( |
|---|
| 642 | WIZARDSTOOLKIT_SHARE_PATH)); |
|---|
| 643 | #endif |
|---|
| 644 | #if defined(__WINDOWS__) && !(defined(WIZARDSTOOLKIT_CONFIGURE_PATH) || defined(WIZARDSTOOLKIT_SHARE_CONFIGURE_PATH)) |
|---|
| 645 | { |
|---|
| 646 | char |
|---|
| 647 | *registry_key; |
|---|
| 648 | |
|---|
| 649 | unsigned char |
|---|
| 650 | *key_value; |
|---|
| 651 | |
|---|
| 652 | |
|---|
| 653 | |
|---|
| 654 | |
|---|
| 655 | registry_key="ConfigurePath"; |
|---|
| 656 | key_value=NTRegistryKeyLookup(registry_key); |
|---|
| 657 | if (key_value != (unsigned char *) NULL) |
|---|
| 658 | { |
|---|
| 659 | (void) FormatWizardString(path,MaxTextExtent,"%s%s",(char *) key_value, |
|---|
| 660 | DirectorySeparator); |
|---|
| 661 | (void) AppendValueToLinkedList(paths,ConstantString(path)); |
|---|
| 662 | key_value=(unsigned char *) RelinquishWizardMemory(key_value); |
|---|
| 663 | } |
|---|
| 664 | } |
|---|
| 665 | #endif |
|---|
| 666 | #else |
|---|
| 667 | { |
|---|
| 668 | char |
|---|
| 669 | *home; |
|---|
| 670 | |
|---|
| 671 | |
|---|
| 672 | |
|---|
| 673 | |
|---|
| 674 | home=GetEnvironmentValue("WIZARD_HOME"); |
|---|
| 675 | if (home != (char *) NULL) |
|---|
| 676 | { |
|---|
| 677 | #if !defined(WIZARDSTOOLKIT_POSIX_SUPPORT) |
|---|
| 678 | (void) FormatWizardString(path,MaxTextExtent,"%s%s",home, |
|---|
| 679 | DirectorySeparator); |
|---|
| 680 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 681 | #else |
|---|
| 682 | (void) FormatWizardString(path,MaxTextExtent,"%s/lib/%s/",home, |
|---|
| 683 | WIZARDSTOOLKIT_CONFIGURE_RELATIVE_PATH); |
|---|
| 684 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 685 | (void) FormatWizardString(path,MaxTextExtent,"%s/share/%s/",home, |
|---|
| 686 | WIZARDSTOOLKIT_SHARE_CONFIGURE_RELATIVE_PATH); |
|---|
| 687 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 688 | #endif |
|---|
| 689 | home=(char *) RelinquishWizardMemory(home); |
|---|
| 690 | } |
|---|
| 691 | } |
|---|
| 692 | if (*GetClientPath() != '\0') |
|---|
| 693 | { |
|---|
| 694 | #if !defined(WIZARDSTOOLKIT_POSIX_SUPPORT) |
|---|
| 695 | (void) FormatWizardString(path,MaxTextExtent,"%s%s",GetClientPath(), |
|---|
| 696 | DirectorySeparator); |
|---|
| 697 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 698 | #else |
|---|
| 699 | char |
|---|
| 700 | prefix[MaxTextExtent]; |
|---|
| 701 | |
|---|
| 702 | |
|---|
| 703 | |
|---|
| 704 | |
|---|
| 705 | (void) CopyWizardString(prefix,GetClientPath(),MaxTextExtent); |
|---|
| 706 | ChopPathComponents(prefix,1); |
|---|
| 707 | (void) FormatWizardString(path,MaxTextExtent,"%s/lib/%s/",prefix, |
|---|
| 708 | WIZARDSTOOLKIT_CONFIGURE_RELATIVE_PATH); |
|---|
| 709 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 710 | (void) FormatWizardString(path,MaxTextExtent,"%s/share/%s/",prefix, |
|---|
| 711 | WIZARDSTOOLKIT_SHARE_CONFIGURE_RELATIVE_PATH); |
|---|
| 712 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 713 | #endif |
|---|
| 714 | } |
|---|
| 715 | #endif |
|---|
| 716 | { |
|---|
| 717 | char |
|---|
| 718 | *home; |
|---|
| 719 | |
|---|
| 720 | home=GetEnvironmentValue("HOME"); |
|---|
| 721 | if (home == (char *) NULL) |
|---|
| 722 | home=GetEnvironmentValue("USERPROFILE"); |
|---|
| 723 | if (home != (char *) NULL) |
|---|
| 724 | { |
|---|
| 725 | |
|---|
| 726 | |
|---|
| 727 | |
|---|
| 728 | (void) FormatWizardString(path,MaxTextExtent,"%s%s.wizard%s",home, |
|---|
| 729 | DirectorySeparator,DirectorySeparator); |
|---|
| 730 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 731 | home=(char *) RelinquishWizardMemory(home); |
|---|
| 732 | } |
|---|
| 733 | } |
|---|
| 734 | #if defined(__WINDOWS__) |
|---|
| 735 | { |
|---|
| 736 | char |
|---|
| 737 | module_path[MaxTextExtent]; |
|---|
| 738 | |
|---|
| 739 | if (NTGetModulePath("Wizard's Toolkit.dll",module_path) != WizardFalse) |
|---|
| 740 | { |
|---|
| 741 | char |
|---|
| 742 | *element; |
|---|
| 743 | |
|---|
| 744 | |
|---|
| 745 | |
|---|
| 746 | |
|---|
| 747 | (void) FormatWizardString(path,MaxTextExtent,"%s%s",module_path, |
|---|
| 748 | DirectorySeparator); |
|---|
| 749 | element=(char *) RemoveElementByValueFromLinkedList(paths,path); |
|---|
| 750 | if (element != (char *) NULL) |
|---|
| 751 | element=(char *) RelinquishWizardMemory(element); |
|---|
| 752 | (void) AppendValueToLinkedList(paths,AcquireString(path)); |
|---|
| 753 | } |
|---|
| 754 | } |
|---|
| 755 | #endif |
|---|
| 756 | |
|---|
| 757 | |
|---|
| 758 | |
|---|
| 759 | (void) AppendValueToLinkedList(paths,AcquireString("")); |
|---|
| 760 | return(paths); |
|---|
| 761 | } |
|---|
| 762 | |
|---|
| 763 | |
|---|
| 764 | |
|---|
| 765 | |
|---|
| 766 | |
|---|
| 767 | |
|---|
| 768 | |
|---|
| 769 | |
|---|
| 770 | |
|---|
| 771 | |
|---|
| 772 | |
|---|
| 773 | |
|---|
| 774 | |
|---|
| 775 | |
|---|
| 776 | |
|---|
| 777 | |
|---|
| 778 | |
|---|
| 779 | |
|---|
| 780 | |
|---|
| 781 | |
|---|
| 782 | |
|---|
| 783 | |
|---|
| 784 | |
|---|
| 785 | WizardExport const char *GetConfigureValue(const ConfigureInfo *configure_info) |
|---|
| 786 | { |
|---|
| 787 | (void) LogWizardEvent(TraceEvent,GetWizardModule(),"..."); |
|---|
| 788 | assert(configure_info != (ConfigureInfo *) NULL); |
|---|
| 789 | assert(configure_info->signature == WizardSignature); |
|---|
| 790 | return(configure_info->value); |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | |
|---|
| 794 | |
|---|
| 795 | |
|---|
| 796 | |
|---|
| 797 | |
|---|
| 798 | |
|---|
| 799 | |
|---|
| 800 | |
|---|
| 801 | |
|---|
| 802 | |
|---|
| 803 | |
|---|
| 804 | |
|---|
| 805 | |
|---|
| 806 | |
|---|
| 807 | |
|---|
| 808 | |
|---|
| 809 | |
|---|
| 810 | |
|---|
| 811 | |
|---|
| 812 | |
|---|
| 813 | |
|---|
| 814 | |
|---|
| 815 | static WizardBooleanType InitializeConfigureList(ExceptionInfo *exception) |
|---|
| 816 | { |
|---|
| 817 | if ((configure_list == (LinkedListInfo *) NULL) && |
|---|
| 818 | (instantiate_configure == WizardFalse)) |
|---|
| 819 | { |
|---|
| 820 | if (configure_semaphore == (SemaphoreInfo *) NULL) |
|---|
| 821 | AcquireSemaphoreInfo(&configure_semaphore); |
|---|
| 822 | (void) LockSemaphoreInfo(configure_semaphore); |
|---|
| 823 | if ((configure_list == (LinkedListInfo *) NULL) && |
|---|
| 824 | (instantiate_configure == WizardFalse)) |
|---|
| 825 | { |
|---|
| 826 | (void) LoadConfigureLists(ConfigureFilename,exception); |
|---|
| 827 | instantiate_configure=WizardTrue; |
|---|
| 828 | } |
|---|
| 829 | (void) UnlockSemaphoreInfo(configure_semaphore); |
|---|
| 830 | } |
|---|
| 831 | return(configure_list != (LinkedListInfo *) NULL ? WizardTrue : WizardFalse); |
|---|
| 832 | } |
|---|
| 833 | |
|---|
| 834 | |
|---|
| 835 | |
|---|
| 836 | |
|---|
| 837 | |
|---|
| 838 | |
|---|
| 839 | |
|---|
| 840 | |
|---|
| 841 | |
|---|
| 842 | |
|---|
| 843 | |
|---|
| 844 | |
|---|
| 845 | |
|---|
| 846 | |
|---|
| 847 | |
|---|
| 848 | |
|---|
| 849 | |
|---|
| 850 | |
|---|
| 851 | |
|---|
| 852 | |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | |
|---|
| 856 | |
|---|
| 857 | |
|---|
| 858 | WizardExport WizardBooleanType ListConfigureInfo(FILE *file, |
|---|
| 859 | ExceptionInfo *exception) |
|---|
| 860 | { |
|---|
| 861 | const char |
|---|
| 862 | *name, |
|---|
| 863 | *path, |
|---|
| 864 | *value; |
|---|
| 865 | |
|---|
| 866 | const ConfigureInfo |
|---|
| 867 | **configure_info; |
|---|
| 868 | |
|---|
| 869 | long |
|---|
| 870 | j; |
|---|
| 871 | |
|---|
| 872 | register long |
|---|
| 873 | i; |
|---|
| 874 | |
|---|
| 875 | unsigned long |
|---|
| 876 | number_options; |
|---|
| 877 | |
|---|
| 878 | if (file == (FILE *) NULL) |
|---|
| 879 | file=stdout; |
|---|
| 880 | configure_info=GetConfigureInfoList("*",&number_options,exception); |
|---|
| 881 | if (configure_info == (const ConfigureInfo **) NULL) |
|---|
| 882 | return(WizardFalse); |
|---|
| 883 | path=(const char *) NULL; |
|---|
| 884 | for (i=0; i < (long) number_options; i++) |
|---|
| 885 | { |
|---|
| 886 | if (configure_info[i]->stealth != WizardFalse) |
|---|
| 887 | continue; |
|---|
| 888 | if ((path == (const char *) NULL) || |
|---|
| 889 | (strcasecmp(path,configure_info[i]->path) != 0)) |
|---|
| 890 | { |
|---|
| 891 | if (configure_info[i]->path != (char *) NULL) |
|---|
| 892 | (void) fprintf(file,"\nPath: %s\n\n",configure_info[i]->path); |
|---|
| 893 | (void) fprintf(file,"Name Value\n"); |
|---|
| 894 | (void) fprintf(file,"-------------------------------------------------" |
|---|
| 895 | "------------------------------\n"); |
|---|
| 896 | } |
|---|
| 897 | path=configure_info[i]->path; |
|---|
| 898 | name="unknown"; |
|---|
| 899 | if (configure_info[i]->name != (char *) NULL) |
|---|
| 900 | name=configure_info[i]->name; |
|---|
| 901 | (void) fprintf(file,"%s",name); |
|---|
| 902 | for (j=(long) strlen(name); j <= 12; j++) |
|---|
| 903 | (void) fprintf(file," "); |
|---|
| 904 | (void) fprintf(file," "); |
|---|
| 905 | value="unknown"; |
|---|
| 906 | if (configure_info[i]->value != (char *) NULL) |
|---|
| 907 | value=configure_info[i]->value; |
|---|
| 908 | (void) fprintf(file,"%s",value); |
|---|
| 909 | (void) fprintf(file,"\n"); |
|---|
| 910 | } |
|---|
| 911 | (void) fflush(file); |
|---|
| 912 | configure_info=(const ConfigureInfo **) RelinquishWizardMemory((void *) |
|---|
| 913 | configure_info); |
|---|
| 914 | return(WizardTrue); |
|---|
| 915 | } |
|---|
| 916 | |
|---|
| 917 | |
|---|
| 918 | |
|---|
| 919 | |
|---|
| 920 | |
|---|
| 921 | |
|---|
| 922 | |
|---|
| 923 | |
|---|
| 924 | |
|---|
| 925 | |
|---|
| 926 | |
|---|
| 927 | |
|---|
| 928 | |
|---|
| 929 | |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | |
|---|
| 933 | |
|---|
| 934 | |
|---|
| 935 | |
|---|
| 936 | |
|---|
| 937 | |
|---|
| 938 | |
|---|
| 939 | |
|---|
| 940 | |
|---|
| 941 | |
|---|
| 942 | |
|---|
| 943 | |
|---|
| 944 | |
|---|
| 945 | |
|---|
| 946 | |
|---|
| 947 | static WizardBooleanType LoadConfigureList(const char *xml,const char *filename, |
|---|
| 948 | const unsigned long depth,ExceptionInfo *exception) |
|---|
| 949 | { |
|---|
| 950 | const char |
|---|
| 951 | *attribute; |
|---|
| 952 | |
|---|
| 953 | ConfigureInfo |
|---|
| 954 | *configure_info = (ConfigureInfo *) NULL; |
|---|
| 955 | |
|---|
| 956 | WizardBooleanType |
|---|
| 957 | status; |
|---|
| 958 | |
|---|
| 959 | XMLTreeInfo |
|---|
| 960 | *configure, |
|---|
| 961 | *configure_map, |
|---|
| 962 | *include; |
|---|
| 963 | |
|---|
| 964 | |
|---|
| 965 | |
|---|
| 966 | |
|---|
| 967 | (void) LogWizardEvent(ConfigureEvent,GetWizardModule(), |
|---|
| 968 | "Loading configure map \"%s\" ...",filename); |
|---|
| 969 | if (xml == (const char *) NULL) |
|---|
| 970 | return(WizardFalse); |
|---|
| 971 | if (configure_list == (LinkedListInfo *) NULL) |
|---|
| 972 | { |
|---|
| 973 | configure_list=NewLinkedList(0); |
|---|
| 974 | if (configure_list == (LinkedListInfo *) NULL) |
|---|
| 975 | { |
|---|
| 976 | (void) ThrowWizardException(exception,GetWizardModule(), |
|---|
| 977 | ResourceFatalError,"memory allocation failed `%s`",strerror(errno)); |
|---|
| 978 | return(WizardFalse); |
|---|
| 979 | } |
|---|
| 980 | } |
|---|
| 981 | configure_map=NewXMLTree(xml,exception); |
|---|
| 982 | if (configure_map == (XMLTreeInfo *) NULL) |
|---|
| 983 | return(WizardFalse); |
|---|
| 984 | status=WizardFalse; |
|---|
| 985 | include=GetXMLTreeChild(configure_map,"include"); |
|---|
| 986 | while (include != (XMLTreeInfo *) NULL) |
|---|
| 987 | { |
|---|
| 988 | |
|---|
| 989 | |
|---|
| 990 | |
|---|
| 991 | attribute=GetXMLTreeAttribute(include,"file"); |
|---|
| 992 | if (attribute != (const char *) NULL) |
|---|
| 993 | { |
|---|
| 994 | if (depth > 200) |
|---|
| 995 | (void) ThrowWizardException(exception,GetWizardModule(), |
|---|
| 996 | ConfigureError,"include element nested too deeply `%s'",filename); |
|---|
| 997 | else |
|---|
| 998 | { |
|---|
| 999 | char |
|---|
| 1000 | path[MaxTextExtent], |
|---|
| 1001 | *xml; |
|---|
| 1002 | |
|---|
| 1003 | GetPathComponent(filename,HeadPath,path); |
|---|
| 1004 | if (*path != '\0') |
|---|
| 1005 | (void) ConcatenateWizardString(path,DirectorySeparator, |
|---|
| 1006 | MaxTextExtent); |
|---|
| 1007 | (void) ConcatenateWizardString(path,attribute,MaxTextExtent); |
|---|
| 1008 | xml=FileToString(path,~0,exception); |
|---|
| 1009 | if (LoadConfigureList(xml,path,depth+1,exception) == WizardFalse) |
|---|
| 1010 | status=WizardFalse; |
|---|
| 1011 | xml=(char *) RelinquishWizardMemory(xml); |
|---|
| 1012 | } |
|---|
| 1013 | } |
|---|
| 1014 | include=GetNextXMLTreeTag(include); |
|---|
| 1015 | } |
|---|
| 1016 | configure=GetXMLTreeChild(configure_map,"configure"); |
|---|
| 1017 | while (configure != (XMLTreeInfo *) NULL) |
|---|
| 1018 | { |
|---|
| 1019 | const char |
|---|
| 1020 | *attribute; |
|---|
| 1021 | |
|---|
| 1022 | |
|---|
| 1023 | |
|---|
| 1024 | |
|---|
| 1025 | configure_info=(ConfigureInfo *) AcquireWizardMemory( |
|---|
| 1026 | sizeof(*configure_info)); |
|---|
| 1027 | if (configure_info == (ConfigureInfo *) NULL) |
|---|
| 1028 | ThrowFatalException(ResourceFatalError,"memory allocation failed `%s`"); |
|---|
| 1029 | (void) ResetWizardMemory(configure_info,0,sizeof(*configure_info)); |
|---|
| 1030 | configure_info->path=ConstantString(filename); |
|---|
| 1031 | configure_info->exempt=WizardFalse; |
|---|
| 1032 | configure_info->signature=WizardSignature; |
|---|
| 1033 | attribute=GetXMLTreeAttribute(configure,"name"); |
|---|
| 1034 | if (attribute != (const char *) NULL) |
|---|
| 1035 | configure_info->name=ConstantString(attribute); |
|---|
| 1036 | attribute=GetXMLTreeAttribute(configure,"stealth"); |
|---|
| 1037 | if (attribute != (const char *) NULL) |
|---|
| 1038 | configure_info->stealth=IsWizardTrue(attribute); |
|---|
| 1039 | attribute=GetXMLTreeAttribute(configure,"value"); |
|---|
| 1040 | if (attribute != (const char *) NULL) |
|---|
| 1041 | configure_info->value=ConstantString(attribute); |
|---|
| 1042 | status=AppendValueToLinkedList(configure_list,configure_info); |
|---|
| 1043 | if (status == WizardFalse) |
|---|
| 1044 | (void) ThrowWizardException(exception,GetWizardModule(), |
|---|
| 1045 | ResourceFatalError,"memory allocation failed `%s`",strerror(errno)); |
|---|
| 1046 | configure=GetNextXMLTreeTag(configure); |
|---|
| 1047 | } |
|---|
| 1048 | configure_map=DestroyXMLTree(configure_map); |
|---|
| 1049 | return(status); |
|---|
| 1050 | } |
|---|
| 1051 | |
|---|
| 1052 | |
|---|
| 1053 | |
|---|
| 1054 | |
|---|
| 1055 | |
|---|
| 1056 | |
|---|
| 1057 | |
|---|
| 1058 | |
|---|
| 1059 | |
|---|
| 1060 | |
|---|
| 1061 | |
|---|
| 1062 | |
|---|
| 1063 | |
|---|
| 1064 | |
|---|
| 1065 | |
|---|
| 1066 | |
|---|
| 1067 | |
|---|
| 1068 | |
|---|
| 1069 | |
|---|
| 1070 | |
|---|
| 1071 | |
|---|
| 1072 | |
|---|
| 1073 | |
|---|
| 1074 | |
|---|
| 1075 | |
|---|
| 1076 | |
|---|
| 1077 | |
|---|
| 1078 | static WizardBooleanType LoadConfigureLists(const char *filename, |
|---|
| 1079 | ExceptionInfo *exception) |
|---|
| 1080 | { |
|---|
| 1081 | char |
|---|
| 1082 | path[MaxTextExtent]; |
|---|
| 1083 | |
|---|
| 1084 | const StringInfo |
|---|
| 1085 | *option; |
|---|
| 1086 | |
|---|
| 1087 | LinkedListInfo |
|---|
| 1088 | *options; |
|---|
| 1089 | |
|---|
| 1090 | register long |
|---|
| 1091 | i; |
|---|
| 1092 | |
|---|
| 1093 | WizardStatusType |
|---|
| 1094 | status; |
|---|
| 1095 | |
|---|
| 1096 | |
|---|
| 1097 | |
|---|
| 1098 | |
|---|
| 1099 | status=WizardFalse; |
|---|
| 1100 | if (configure_list == (LinkedListInfo *) NULL) |
|---|
| 1101 | { |
|---|
| 1102 | configure_list=NewLinkedList(0); |
|---|
| 1103 | if (configure_list == (LinkedListInfo *) NULL) |
|---|
| 1104 | { |
|---|
| 1105 | ThrowFileException(exception,FileError,filename); |
|---|
| 1106 | return(WizardFalse); |
|---|
| 1107 | } |
|---|
| 1108 | } |
|---|
| 1109 | for (i=0; i < (long) (sizeof(ConfigureMap)/sizeof(*ConfigureMap)); i++) |
|---|
| 1110 | { |
|---|
| 1111 | ConfigureInfo |
|---|
| 1112 | *configure_info; |
|---|
| 1113 | |
|---|
| 1114 | register const ConfigureMapInfo |
|---|
| 1115 | *p; |
|---|
| 1116 | |
|---|
| 1117 | p=ConfigureMap+i; |
|---|
| 1118 | configure_info=(ConfigureInfo *) AcquireWizardMemory( |
|---|
| 1119 | sizeof(*configure_info)); |
|---|
| 1120 | if (configure_info == (ConfigureInfo *) NULL) |
|---|
| 1121 | { |
|---|
| 1122 | (void) ThrowWizardException(exception,GetWizardModule(),ResourceError, |
|---|
| 1123 | "memory allocation failed `%s'",strerror(errno)); |
|---|
| 1124 | continue; |
|---|
| 1125 | } |
|---|
| 1126 | (void) ResetWizardMemory(configure_info,0,sizeof(*configure_info)); |
|---|
| 1127 | configure_info->path=(char *) "[built-in]"; |
|---|
| 1128 | configure_info->name=(char *) p->name; |
|---|
| 1129 | configure_info->value=(char *) p->value; |
|---|
| 1130 | configure_info->exempt=WizardTrue; |
|---|
| 1131 | configure_info->signature=WizardSignature; |
|---|
| 1132 | status=AppendValueToLinkedList(configure_list,configure_info); |
|---|
| 1133 | if (status == WizardFalse) |
|---|
| 1134 | (void) ThrowWizardException(exception,GetWizardModule(),ResourceError, |
|---|
| 1135 | "memory allocation failed `%s'",strerror(errno)); |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | |
|---|
| 1139 | |
|---|
| 1140 | *path='\0'; |
|---|
| 1141 | options=GetConfigureOptions(filename,exception); |
|---|
| 1142 | option=(const StringInfo *) GetNextValueInLinkedList(options); |
|---|
| 1143 | while (option != (const StringInfo *) NULL) |
|---|
| 1144 | { |
|---|
| 1145 | (void) CopyWizardString(path,GetStringInfoPath(option),MaxTextExtent); |
|---|
| 1146 | status|=LoadConfigureList((const char *) GetStringInfoDatum(option), |
|---|
| 1147 | GetStringInfoPath(option),0,exception); |
|---|
| 1148 | option=(const StringInfo *) GetNextValueInLinkedList(options); |
|---|
| 1149 | } |
|---|
| 1150 | options=DestroyConfigureOptions(options); |
|---|
| 1151 | return(status != 0 ? WizardTrue : WizardFalse); |
|---|
| 1152 | } |
|---|