Changeset 445 for WizardsToolkit/trunk
- Timestamp:
- 10/24/09 14:26:18 (4 weeks ago)
- Location:
- WizardsToolkit/trunk/wizard
- Files:
-
- 12 modified
-
log.c (modified) (3 diffs)
-
log.h (modified) (2 diffs)
-
mime.c (modified) (3 diffs)
-
mime.h (modified) (2 diffs)
-
nt-base.c (modified) (1 diff)
-
random.c (modified) (3 diffs)
-
random_.h (modified) (2 diffs)
-
resource.c (modified) (7 diffs)
-
resource_.h (modified) (2 diffs)
-
semaphore.c (modified) (3 diffs)
-
semaphore.h (modified) (1 diff)
-
wizard.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
WizardsToolkit/trunk/wizard/log.c
r428 r445 235 235 } 236 236 RelinquishSemaphoreInfo(log_semaphore); 237 }238 239 /*240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%241 % %242 % %243 % %244 + D e s t r o y L o g C o m p o n e n t %245 % %246 % %247 % %248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%249 %250 % DestroyLogComponent() destroys the log component.251 %252 % The format of the DestroyLogComponent method is:253 %254 % DestroyLogComponent(void)255 %256 */257 258 static void *DestroyLogElement(void *log_info)259 {260 register LogInfo261 *p;262 263 p=(LogInfo *) log_info;264 if (p->file != (FILE *) NULL)265 {266 if (p->append == WizardFalse)267 (void) fprintf(p->file,"</log>\n");268 (void) fclose(p->file);269 p->file=(FILE *) NULL;270 }271 if (p->exempt == WizardFalse)272 {273 if (p->format != (char *) NULL)274 p->format=DestroyString(p->format);275 if (p->filename != (char *) NULL)276 p->filename=DestroyString(p->filename);277 if (p->path != (char *) NULL)278 p->path=DestroyString(p->path);279 }280 if (p->timer != (TimerInfo *) NULL)281 p->timer=DestroyTimerInfo(p->timer);282 p=(LogInfo *) RelinquishWizardMemory(p);283 return((void *) NULL);284 }285 286 WizardExport void DestroyLogComponent(void)287 {288 AcquireSemaphoreInfo(&log_semaphore);289 if (log_list != (LinkedListInfo *) NULL)290 log_list=DestroyLinkedList(log_list,DestroyLogElement);291 instantiate_log=WizardFalse;292 RelinquishSemaphoreInfo(log_semaphore);293 DestroySemaphoreInfo(&log_semaphore);294 237 } 295 238 … … 609 552 % % 610 553 % % 611 + I n s t a n t i a t e L o g C o m p o n e n t %612 % %613 % %614 % %615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%616 %617 % InstantiateLogComponent() instantiates the log component.618 %619 % The format of the InstantiateLogComponent method is:620 %621 % WizardBooleanType InstantiateLogComponent(void)622 %623 */624 WizardExport WizardBooleanType InstantiateLogComponent(void)625 {626 AcquireSemaphoreInfo(&log_semaphore);627 RelinquishSemaphoreInfo(log_semaphore);628 return(WizardFalse);629 }630 631 /*632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%633 % %634 % %635 % %636 554 % I s E v e n t L o g g i n g % 637 555 % % … … 747 665 log_info=(const LogInfo **) RelinquishWizardMemory((void *) log_info); 748 666 return(WizardTrue); 667 } 668 669 /* 670 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 671 % % 672 % % 673 % % 674 + L o g C o m p o n e n t G e n e s i s % 675 % % 676 % % 677 % % 678 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 679 % 680 % LogComponentGenesis() instantiates the log component. 681 % 682 % The format of the LogComponentGenesis method is: 683 % 684 % WizardBooleanType LogComponentGenesis(void) 685 % 686 */ 687 WizardExport WizardBooleanType LogComponentGenesis(void) 688 { 689 AcquireSemaphoreInfo(&log_semaphore); 690 RelinquishSemaphoreInfo(log_semaphore); 691 return(WizardTrue); 692 } 693 694 /* 695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 696 % % 697 % % 698 % % 699 + L o g C o m p o n e n t T e r m i n u s % 700 % % 701 % % 702 % % 703 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 704 % 705 % LogComponentTerminus() destroys the log component. 706 % 707 % The format of the LogComponentTerminus method is: 708 % 709 % LogComponentTerminus(void) 710 % 711 */ 712 713 static void *DestroyLogElement(void *log_info) 714 { 715 register LogInfo 716 *p; 717 718 p=(LogInfo *) log_info; 719 if (p->file != (FILE *) NULL) 720 { 721 if (p->append == WizardFalse) 722 (void) fprintf(p->file,"</log>\n"); 723 (void) fclose(p->file); 724 p->file=(FILE *) NULL; 725 } 726 if (p->exempt == WizardFalse) 727 { 728 if (p->format != (char *) NULL) 729 p->format=DestroyString(p->format); 730 if (p->filename != (char *) NULL) 731 p->filename=DestroyString(p->filename); 732 if (p->path != (char *) NULL) 733 p->path=DestroyString(p->path); 734 } 735 if (p->timer != (TimerInfo *) NULL) 736 p->timer=DestroyTimerInfo(p->timer); 737 p=(LogInfo *) RelinquishWizardMemory(p); 738 return((void *) NULL); 739 } 740 741 WizardExport void LogComponentTerminus(void) 742 { 743 AcquireSemaphoreInfo(&log_semaphore); 744 if (log_list != (LinkedListInfo *) NULL) 745 log_list=DestroyLinkedList(log_list,DestroyLogElement); 746 instantiate_log=WizardFalse; 747 RelinquishSemaphoreInfo(log_semaphore); 748 DestroySemaphoreInfo(&log_semaphore); 749 749 } 750 750 -
WizardsToolkit/trunk/wizard/log.h
r415 r445 68 68 69 69 extern WizardExport WizardBooleanType 70 InstantiateLogComponent(void),71 70 IsEventLogging(void), 72 71 ListLogInfo(FILE *,ExceptionInfo *), 72 LogComponentGenesis(void), 73 73 LogWizardEvent(const LogEventType,const char *,const char *, 74 74 const unsigned long,const char *,...) … … 80 80 extern WizardExport void 81 81 CloseWizardLog(void), 82 DestroyLogComponent(void),82 LogComponentTerminus(void), 83 83 SetLogFormat(const char *), 84 84 SetLogPreamble(const char *); -
WizardsToolkit/trunk/wizard/mime.c
r415 r445 126 126 static WizardBooleanType 127 127 InitializeMimeList(ExceptionInfo *); 128 129 /*130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%131 % %132 % %133 % %134 + D e s t r o y M i m e C o m p o n e n t %135 % %136 % %137 % %138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%139 %140 % DestroyMimeComponent() destroys the mime component.141 %142 % The format of the DestroyMimeComponent method is:143 %144 % DestroyMimeComponent(void)145 %146 */147 148 static void *DestroyMimeElement(void *mime_info)149 {150 register MimeInfo151 *p;152 153 p=(MimeInfo *) mime_info;154 if (p->magic != (unsigned char *) NULL)155 p->magic=(unsigned char *) RelinquishWizardMemory(p->magic);156 if (p->pattern != (char *) NULL)157 p->pattern=DestroyString(p->pattern);158 if (p->description != (char *) NULL)159 p->description=DestroyString(p->description);160 if (p->type != (char *) NULL)161 p->type=DestroyString(p->type);162 if (p->path != (char *) NULL)163 p->path=DestroyString(p->path);164 p=(MimeInfo *) RelinquishWizardMemory(p);165 return((void *) NULL);166 }167 168 WizardExport void DestroyMimeComponent(void)169 {170 AcquireSemaphoreInfo(&mime_semaphore);171 if (mime_list != (LinkedListInfo *) NULL)172 mime_list=DestroyLinkedList(mime_list,DestroyMimeElement);173 instantiate_mime=WizardFalse;174 RelinquishSemaphoreInfo(mime_semaphore);175 DestroySemaphoreInfo(&mime_semaphore);176 }177 128 178 129 /* … … 671 622 % % 672 623 % % 673 + I n s t a n t i a t e M i m e C o m p o n e n t %674 % %675 % %676 % %677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%678 %679 % InstantiateMimeComponent() instantiates the mime component.680 %681 % The format of the InstantiateMimeComponent method is:682 %683 % WizardBooleanType InstantiateMimeComponent(void)684 %685 */686 WizardExport WizardBooleanType InstantiateMimeComponent(void)687 {688 AcquireSemaphoreInfo(&mime_semaphore);689 RelinquishSemaphoreInfo(mime_semaphore);690 return(WizardTrue);691 }692 693 /*694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%695 % %696 % %697 % %698 624 % L i s t M i m e I n f o % 699 625 % % … … 1057 983 % % 1058 984 % % 985 + M i m e C o m p o n e n t G e n e s i s % 986 % % 987 % % 988 % % 989 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 990 % 991 % MimeComponentGenesis() instantiates the mime component. 992 % 993 % The format of the MimeComponentGenesis method is: 994 % 995 % WizardBooleanType MimeComponentGenesis(void) 996 % 997 */ 998 WizardExport WizardBooleanType MimeComponentGenesis(void) 999 { 1000 AcquireSemaphoreInfo(&mime_semaphore); 1001 RelinquishSemaphoreInfo(mime_semaphore); 1002 return(WizardTrue); 1003 } 1004 1005 /* 1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1007 % % 1008 % % 1009 % % 1010 + M i m e C o m p o n e n t T e r m i n u s % 1011 % % 1012 % % 1013 % % 1014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1015 % 1016 % MimeComponentTerminus() destroys the mime component. 1017 % 1018 % The format of the MimeComponentTerminus method is: 1019 % 1020 % MimeComponentTerminus(void) 1021 % 1022 */ 1023 1024 static void *DestroyMimeElement(void *mime_info) 1025 { 1026 register MimeInfo 1027 *p; 1028 1029 p=(MimeInfo *) mime_info; 1030 if (p->magic != (unsigned char *) NULL) 1031 p->magic=(unsigned char *) RelinquishWizardMemory(p->magic); 1032 if (p->pattern != (char *) NULL) 1033 p->pattern=DestroyString(p->pattern); 1034 if (p->description != (char *) NULL) 1035 p->description=DestroyString(p->description); 1036 if (p->type != (char *) NULL) 1037 p->type=DestroyString(p->type); 1038 if (p->path != (char *) NULL) 1039 p->path=DestroyString(p->path); 1040 p=(MimeInfo *) RelinquishWizardMemory(p); 1041 return((void *) NULL); 1042 } 1043 1044 WizardExport void MimeComponentTerminus(void) 1045 { 1046 AcquireSemaphoreInfo(&mime_semaphore); 1047 if (mime_list != (LinkedListInfo *) NULL) 1048 mime_list=DestroyLinkedList(mime_list,DestroyMimeElement); 1049 instantiate_mime=WizardFalse; 1050 RelinquishSemaphoreInfo(mime_semaphore); 1051 DestroySemaphoreInfo(&mime_semaphore); 1052 } 1053 1054 /* 1055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1056 % % 1057 % % 1058 % % 1059 1059 + W i z a r d T o M i m e % 1060 1060 % % -
WizardsToolkit/trunk/wizard/mime.h
r415 r445 35 35 36 36 extern WizardExport WizardBooleanType 37 InstantiateMimeComponent(void),38 37 ListMimeInfo(FILE *,ExceptionInfo *), 39 LoadMimeLists(const char *,ExceptionInfo *); 38 LoadMimeLists(const char *,ExceptionInfo *), 39 MimeComponentGenesis(void); 40 40 41 41 extern WizardExport const MimeInfo … … 44 44 45 45 extern WizardExport void 46 DestroyMimeComponent(void);46 MimeComponentTerminus(void); 47 47 48 48 #if defined(__cplusplus) || defined(c_plusplus) -
WizardsToolkit/trunk/wizard/nt-base.c
r415 r445 330 330 static BOOL ControlHandler(DWORD type) 331 331 { 332 Asynchronous DestroyResourceComponent();332 AsynchronousResourceComponentTerminus(); 333 333 return(FALSE); 334 334 } -
WizardsToolkit/trunk/wizard/random.c
r415 r445 299 299 random_info=(RandomInfo *) RelinquishWizardMemory(random_info); 300 300 return(random_info); 301 }302 303 /*304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%305 % %306 % %307 % %308 + D e s t r o y R a n d o m C o m p o n e n t %309 % %310 % %311 % %312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%313 %314 % DestroyRandomComponent() destroys the random component.315 %316 % The format of the DestroyRandomComponent method is:317 %318 % DestroyRandomComponent(void)319 %320 */321 WizardExport void DestroyRandomComponent(void)322 {323 AcquireSemaphoreInfo(&random_semaphore);324 RelinquishSemaphoreInfo(random_semaphore);325 DestroySemaphoreInfo(&random_semaphore);326 301 } 327 302 … … 775 750 % % 776 751 % % 777 + I n s t a n t i a t e R a n d o m C o m p o n e n t %778 % %779 % %780 % %781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%782 %783 % InstantiateRandomComponent() instantiates the random component.784 %785 % The format of the InstantiateRandomComponent method is:786 %787 % InstantiateRandomComponent(void)788 %789 */790 WizardExport WizardBooleanType InstantiateRandomComponent(void)791 {792 AcquireSemaphoreInfo(&random_semaphore);793 RelinquishSemaphoreInfo(random_semaphore);794 return(WizardTrue);795 }796 797 /*798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%799 % %800 % %801 % %802 752 % G e t P s e u d o R a n d o m V a l u e % 803 753 % % … … 906 856 } while (key == range); 907 857 return((double) key/range); 858 } 859 860 /* 861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 862 % % 863 % % 864 % % 865 + R a n d o m C o m p o n e n t G e n e s i s % 866 % % 867 % % 868 % % 869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 870 % 871 % RandomComponentGenesis() instantiates the random component. 872 % 873 % The format of the RandomComponentGenesis method is: 874 % 875 % RandomComponentGenesis(void) 876 % 877 */ 878 WizardExport WizardBooleanType RandomComponentGenesis(void) 879 { 880 AcquireSemaphoreInfo(&random_semaphore); 881 RelinquishSemaphoreInfo(random_semaphore); 882 return(WizardTrue); 883 } 884 885 /* 886 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 887 % % 888 % % 889 % % 890 + R a n d o m C o m p o n e n t T e r m i n u s % 891 % % 892 % % 893 % % 894 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 895 % 896 % RandomComponentTerminus() destroys the random component. 897 % 898 % The format of the RandomComponentTerminus method is: 899 % 900 % RandomComponentTerminus(void) 901 % 902 */ 903 WizardExport void RandomComponentTerminus(void) 904 { 905 AcquireSemaphoreInfo(&random_semaphore); 906 RelinquishSemaphoreInfo(random_semaphore); 907 DestroySemaphoreInfo(&random_semaphore); 908 908 } 909 909 -
WizardsToolkit/trunk/wizard/random_.h
r415 r445 46 46 47 47 extern WizardExport void 48 DestroyRandomComponent(void),48 RandomComponentTerminus(void), 49 49 SeedPseudoRandomGenerator(const unsigned long), 50 50 SetRandomKey(RandomInfo *,const size_t,unsigned char *), … … 52 52 53 53 extern WizardExport WizardBooleanType 54 InstantiateRandomComponent(void);54 RandomComponentGenesis(void); 55 55 56 56 #if defined(__cplusplus) || defined(c_plusplus) -
WizardsToolkit/trunk/wizard/resource.c
r419 r445 449 449 % % 450 450 % % 451 + A s y n c h r o n o u s D e s t r o y R e s o u r c e C o m p o n e n t%452 % % 453 % % 454 % % 455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 456 % 457 % Asynchronous DestroyResourceComponent() destroys the resource environment.458 % It differs from DestroyResourceComponent() in that it can be called from a451 + A s y n c h r o n o u s R e s o u r c e C o m p o n e n t T e r m i n u s % 452 % % 453 % % 454 % % 455 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 456 % 457 % AsynchronousResourceComponentTerminus() destroys the resource environment. 458 % It differs from ResourceComponentTerminus() in that it can be called from a 459 459 % asynchronous signal handler. 460 460 % 461 % The format of the DestroyResourceComponent() method is:462 % 463 % DestroyResourceComponent(void)464 % 465 */ 466 WizardExport void Asynchronous DestroyResourceComponent(void)461 % The format of the ResourceComponentTerminus() method is: 462 % 463 % ResourceComponentTerminus(void) 464 % 465 */ 466 WizardExport void AsynchronousResourceComponentTerminus(void) 467 467 { 468 468 const char … … 490 490 % % 491 491 % % 492 + D e s t r o y R e s o u r c e C o m p o n e n t %493 % %494 % %495 % %496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%497 %498 % DestroyResourceComponent() destroys the resource component.499 %500 % The format of the DestroyResourceComponent() method is:501 %502 % DestroyResourceComponent(void)503 %504 */505 WizardExport void DestroyResourceComponent(void)506 {507 AcquireSemaphoreInfo(&resource_semaphore);508 if (temporary_resources != (SplayTreeInfo *) NULL)509 temporary_resources=DestroySplayTree(temporary_resources);510 RelinquishSemaphoreInfo(resource_semaphore);511 DestroySemaphoreInfo(&resource_semaphore);512 }513 514 /*515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%516 % %517 % %518 % %519 492 % G e t W i z a r d R e s o u r c e % 520 493 % % … … 643 616 % % 644 617 % % 645 + I n s t a n t i a t e R e s o u r c e C o m p o n e n t % 646 % % 647 % % 648 % % 649 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 650 % 651 % InstantiateResourceComponent() instantiates the resource component. 652 % 653 % The format of the InstantiateResourceComponent method is: 654 % 655 % WizardBooleanType InstantiateResourceComponent(void) 618 % L i s t W i z a r d R e s o u r c e I n f o % 619 % % 620 % % 621 % % 622 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 623 % 624 % ListWizardResourceInfo() lists the resource info to a file. 625 % 626 % The format of the ListWizardResourceInfo method is: 627 % 628 % WizardBooleanType ListWizardResourceInfo(FILE *file, 629 % ExceptionInfo *exception) 630 % 631 % A description of each parameter follows. 632 % 633 % o file: An pointer to a FILE. 634 % 635 % o exception: Return any errors or warnings in this structure. 636 % 637 */ 638 WizardExport WizardBooleanType ListWizardResourceInfo(FILE *file, 639 ExceptionInfo *wizard_unused(exception)) 640 { 641 char 642 area_limit[MaxTextExtent], 643 disk_limit[MaxTextExtent], 644 map_limit[MaxTextExtent], 645 memory_limit[MaxTextExtent]; 646 647 if (file == (const FILE *) NULL) 648 file=stdout; 649 AcquireSemaphoreInfo(&resource_semaphore); 650 (void) FormatWizardSize(resource_info.area_limit,area_limit); 651 (void) FormatWizardSize(resource_info.disk_limit,disk_limit); 652 (void) FormatWizardSize(resource_info.map_limit,map_limit); 653 (void) FormatWizardSize(resource_info.memory_limit,memory_limit); 654 (void) fprintf(file,"File Area Memory Map Disk\n"); 655 (void) fprintf(file,"----------------------------------------------------\n"); 656 (void) fprintf(file,"%4lu %10s %10s %10s %10s\n",(unsigned long) 657 resource_info.file_limit,area_limit,memory_limit,map_limit,disk_limit); 658 (void) fflush(file); 659 RelinquishSemaphoreInfo(resource_semaphore); 660 return(WizardTrue); 661 } 662 663 /* 664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 665 % % 666 % % 667 % % 668 % R e l i n q u i s h W i z a r d R e s o u r c e % 669 % % 670 % % 671 % % 672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 673 % 674 % RelinquishWizardResource() relinquishes resources of the specified type. 675 % 676 % The format of the RelinquishWizardResource() method is: 677 % 678 % void RelinquishWizardResource(const ResourceType type, 679 % const WizardSizeType size) 680 % 681 % A description of each parameter follows: 682 % 683 % o type: The type of resource. 684 % 685 % o size: The size of the resource. 686 % 687 */ 688 WizardExport void RelinquishWizardResource(const ResourceType type, 689 const WizardSizeType size) 690 { 691 char 692 resource_current[MaxTextExtent], 693 resource_limit[MaxTextExtent], 694 resource_request[MaxTextExtent]; 695 696 (void) FormatWizardSize(size,resource_request); 697 AcquireSemaphoreInfo(&resource_semaphore); 698 switch (type) 699 { 700 case AreaResource: 701 { 702 resource_info.area=(WizardOffsetType) size; 703 (void) FormatWizardSize((WizardSizeType) resource_info.area, 704 resource_current); 705 (void) FormatWizardSize(resource_info.area_limit,resource_limit); 706 break; 707 } 708 case MemoryResource: 709 { 710 resource_info.memory-=size; 711 (void) FormatWizardSize((WizardSizeType) resource_info.memory, 712 resource_current); 713 (void) FormatWizardSize(resource_info.memory_limit,resource_limit); 714 break; 715 } 716 case MapResource: 717 { 718 resource_info.map-=size; 719 (void) FormatWizardSize((WizardSizeType) resource_info.map, 720 resource_current); 721 (void) FormatWizardSize(resource_info.map_limit,resource_limit); 722 break; 723 } 724 case DiskResource: 725 { 726 resource_info.disk-=size; 727 (void) FormatWizardSize((WizardSizeType) resource_info.disk, 728 resource_current); 729 (void) FormatWizardSize(resource_info.disk_limit,resource_limit); 730 break; 731 } 732 case FileResource: 733 { 734 resource_info.file-=size; 735 (void) FormatWizardSize((WizardSizeType) resource_info.file, 736 resource_current); 737 (void) FormatWizardSize((WizardSizeType) resource_info.file_limit, 738 resource_limit); 739 break; 740 } 741 default: 742 break; 743 } 744 RelinquishSemaphoreInfo(resource_semaphore); 745 (void) LogWizardEvent(ResourceEvent,GetWizardModule(),"%s: %s/%s/%s", 746 WizardOptionToMnemonic(WizardResourceOptions,(long) type),resource_request, 747 resource_current,resource_limit); 748 } 749 750 /* 751 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 752 % % 753 % % 754 % % 755 % R e l i n q u i s h U n i q u e F i l e R e s o u r c e % 756 % % 757 % % 758 % % 759 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 760 % 761 % RelinquishUniqueFileResource() relinquishes a unique file resource. 762 % 763 % The format of the RelinquishUniqueFileResource() method is: 764 % 765 % WizardBooleanType RelinquishUniqueFileResource(const char *path, 766 % const WizardBooleanType trash)) 767 % 768 % A description of each parameter follows: 769 % 770 % o name: the name of the temporary resource. 771 % 772 % o trash: a value other than 0 trashs the file at the specified path. 773 % 774 */ 775 WizardExport WizardBooleanType RelinquishUniqueFileResource(const char *path, 776 const WizardBooleanType trash) 777 { 778 WizardAssert(ResourceDomain,path != (const char *) NULL); 779 (void) LogWizardEvent(ResourceEvent,GetWizardModule(),"%s",path); 780 if (temporary_resources != (SplayTreeInfo *) NULL) 781 { 782 register char 783 *p; 784 785 ResetSplayTreeIterator(temporary_resources); 786 p=(char *) GetNextKeyInSplayTree(temporary_resources); 787 while (p != (char *) NULL) 788 { 789 if (LocaleCompare(p,path) == 0) 790 break; 791 p=(char *) GetNextKeyInSplayTree(temporary_resources); 792 } 793 if (p != (char *) NULL) 794 (void) DeleteNodeFromSplayTree(temporary_resources,p); 795 } 796 if (trash == WizardFalse) 797 return(WizardTrue); 798 return(remove(path) == 0 ? WizardTrue : WizardFalse); 799 } 800 801 /* 802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 803 % % 804 % % 805 % % 806 + R e s o u r c e C o m p o n e n t G e n e s i s % 807 % % 808 % % 809 % % 810 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 811 % 812 % ResourceComponentGenesis() instantiates the resource component. 813 % 814 % The format of the ResourceComponentGenesis method is: 815 % 816 % WizardBooleanType ResourceComponentGenesis(void) 656 817 % 657 818 */ … … 664 825 } 665 826 666 WizardExport WizardBooleanType InstantiateResourceComponent(void)827 WizardExport WizardBooleanType ResourceComponentGenesis(void) 667 828 { 668 829 char … … 747 908 % % 748 909 % % 749 % L i s t W i z a r d R e s o u r c e I n f o % 750 % % 751 % % 752 % % 753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 754 % 755 % ListWizardResourceInfo() lists the resource info to a file. 756 % 757 % The format of the ListWizardResourceInfo method is: 758 % 759 % WizardBooleanType ListWizardResourceInfo(FILE *file, 760 % ExceptionInfo *exception) 761 % 762 % A description of each parameter follows. 763 % 764 % o file: An pointer to a FILE. 765 % 766 % o exception: Return any errors or warnings in this structure. 767 % 768 */ 769 WizardExport WizardBooleanType ListWizardResourceInfo(FILE *file, 770 ExceptionInfo *wizard_unused(exception)) 771 { 772 char 773 area_limit[MaxTextExtent], 774 disk_limit[MaxTextExtent], 775 map_limit[MaxTextExtent], 776 memory_limit[MaxTextExtent]; 777 778 if (file == (const FILE *) NULL) 779 file=stdout; 910 + R e s o u r c e C o m p o n e n t G e n e s i s % 911 % % 912 % % 913 % % 914 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 915 % 916 % ResourceComponentTerminus() destroys the resource component. 917 % 918 % The format of the ResourceComponentTerminus() method is: 919 % 920 % ResourceComponentTerminus(void) 921 % 922 */ 923 WizardExport void ResourceComponentTerminus(void) 924 { 780 925 AcquireSemaphoreInfo(&resource_semaphore); 781 (void) FormatWizardSize(resource_info.area_limit,area_limit); 782 (void) FormatWizardSize(resource_info.disk_limit,disk_limit); 783 (void) FormatWizardSize(resource_info.map_limit,map_limit); 784 (void) FormatWizardSize(resource_info.memory_limit,memory_limit); 785 (void) fprintf(file,"File Area Memory Map Disk\n"); 786 (void) fprintf(file,"----------------------------------------------------\n"); 787 (void) fprintf(file,"%4lu %10s %10s %10s %10s\n",(unsigned long) 788 resource_info.file_limit,area_limit,memory_limit,map_limit,disk_limit); 789 (void) fflush(file); 926 if (temporary_resources != (SplayTreeInfo *) NULL) 927 temporary_resources=DestroySplayTree(temporary_resources); 790 928 RelinquishSemaphoreInfo(resource_semaphore); 791 return(WizardTrue);792 } 793 794 /* 795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 796 % % 797 % % 798 % % 799 % R e l i n q u i s h W i z a r d R e s o u r c e%800 % % 801 % % 802 % % 803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 804 % 805 % RelinquishWizardResource() relinquishes resources of the specified type.806 % 807 % The format of the RelinquishWizardResource() method is:808 % 809 % void RelinquishWizardResource(const ResourceType type,810 % const Wizard SizeType size)929 DestroySemaphoreInfo(&resource_semaphore); 930 } 931 932 /* 933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 934 % % 935 % % 936 % % 937 % S e t W i z a r d R e s o u r c e L i m i t % 938 % % 939 % % 940 % % 941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 942 % 943 % SetWizardResourceLimit() sets the limit for a particular resource in bytes. 944 % 945 % The format of the SetWizardResourceLimit() method is: 946 % 947 % WizardBooleanType SetWizardResourceLimit(const ResourceType type, 948 % const WizardResourceType limit) 811 949 % 812 950 % A description of each parameter follows: … … 814 952 % o type: The type of resource. 815 953 % 816 % o size: The size of the resource. 817 % 818 */ 819 WizardExport void RelinquishWizardResource(const ResourceType type, 820 const WizardSizeType size) 821 { 822 char 823 resource_current[MaxTextExtent], 824 resource_limit[MaxTextExtent], 825 resource_request[MaxTextExtent]; 826 827 (void) FormatWizardSize(size,resource_request); 954 % o limit: The maximum limit for the resource. 955 % 956 */ 957 WizardExport WizardBooleanType SetWizardResourceLimit(const ResourceType type, 958 const WizardSizeType limit) 959 { 828 960 AcquireSemaphoreInfo(&resource_semaphore); 829 961 switch (type) … … 831 963 case AreaResource: 832 964 { 833 resource_info.area=(WizardOffsetType) size;834 (void) FormatWizardSize((WizardSizeType) resource_info.area,835 resource_current);836 (void) FormatWizardSize(resource_info.area_limit,resource_limit);837 break;838 }839 case MemoryResource:840 {841 resource_info.memory-=size;842 (void) FormatWizardSize((WizardSizeType) resource_info.memory,843 resource_current);844 (void) FormatWizardSize(resource_info.memory_limit,resource_limit);845 break;846 }847 case MapResource:848 {849 resource_info.map-=size;850 (void) FormatWizardSize((WizardSizeType) resource_info.map,851 resource_current);852 (void) FormatWizardSize(resource_info.map_limit,resource_limit);853 break;854 }855 case DiskResource:856 {857 resource_info.disk-=size;858 (void) FormatWizardSize((WizardSizeType) resource_info.disk,859 resource_current);860 (void) FormatWizardSize(resource_info.disk_limit,resource_limit);861 break;862 }863 case FileResource:864 {865 resource_info.file-=size;866 (void) FormatWizardSize((WizardSizeType) resource_info.file,867 resource_current);868 (void) FormatWizardSize((WizardSizeType) resource_info.file_limit,869 resource_limit);870 break;871 }872 default:873 break;874 }875 RelinquishSemaphoreInfo(resource_semaphore);876 (void) LogWizardEvent(ResourceEvent,GetWizardModule(),"%s: %s/%s/%s",877 WizardOptionToMnemonic(WizardResourceOptions,(long) type),resource_request,878 resource_current,resource_limit);879 }880 881 /*882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%883 % %884 % %885 % %886 % R e l i n q u i s h U n i q u e F i l e R e s o u r c e %887 % %888 % %889 % %890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%891 %892 % RelinquishUniqueFileResource() relinquishes a unique file resource.893 %894 % The format of the RelinquishUniqueFileResource() method is:895 %896 % WizardBooleanType RelinquishUniqueFileResource(const char *path,897 % const WizardBooleanType trash))898 %899 % A description of each parameter follows:900 %901 % o name: the name of the temporary resource.902 %903 % o trash: a value other than 0 trashs the file at the specified path.904 %905 */906 WizardExport WizardBooleanType RelinquishUniqueFileResource(const char *path,907 const WizardBooleanType trash)908 {909 WizardAssert(ResourceDomain,path != (const char *) NULL);910 (void) LogWizardEvent(ResourceEvent,GetWizardModule(),"%s",path);911 if (temporary_resources != (SplayTreeInfo *) NULL)912 {913 register char914 *p;915 916 ResetSplayTreeIterator(temporary_resources);917 p=(char *) GetNextKeyInSplayTree(temporary_resources);918 while (p != (char *) NULL)919 {920 if (LocaleCompare(p,path) == 0)921 break;922 p=(char *) GetNextKeyInSplayTree(temporary_resources);923 }924 if (p != (char *) NULL)925 (void) DeleteNodeFromSplayTree(temporary_resources,p);926 }927 if (trash == WizardFalse)928 return(WizardTrue);929 return(remove(path) == 0 ? WizardTrue : WizardFalse);930 }931 932 /*933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%934 % %935 % %936 % %937 % S e t W i z a r d R e s o u r c e L i m i t %938 % %939 % %940 % %941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%942 %943 % SetWizardResourceLimit() sets the limit for a particular resource in bytes.944 %945 % The format of the SetWizardResourceLimit() method is:946 %947 % WizardBooleanType SetWizardResourceLimit(const ResourceType type,948 % const WizardResourceType limit)949 %950 % A description of each parameter follows:951 %952 % o type: The type of resource.953 %954 % o limit: The maximum limit for the resource.955 %956 */957 WizardExport WizardBooleanType SetWizardResourceLimit(const ResourceType type,958 const WizardSizeType limit)959 {960 AcquireSemaphoreInfo(&resource_semaphore);961 switch (type)962 {963 case AreaResource:964 {965 965 resource_info.area_limit=limit; 966 966 break; -
WizardsToolkit/trunk/wizard/resource_.h
r415 r445 45 45 AcquireWizardResource(const ResourceType,const WizardSizeType), 46 46 AcquireUniqueFilename(char *,ExceptionInfo *), 47 InstantiateResourceComponent(void),48 47 ListWizardResourceInfo(FILE *,ExceptionInfo *), 49 48 RelinquishUniqueFileResource(const char *,const WizardBooleanType), 49 ResourceComponentGenesis(void), 50 50 SetWizardResourceLimit(const ResourceType,const WizardSizeType); 51 51 … … 54 54 55 55 extern WizardExport void 56 Asynchronous DestroyResourceComponent(void),57 DestroyResourceComponent(void),58 Re linquishWizardResource(const ResourceType,const WizardSizeType);56 AsynchronousResourceComponentTerminus(void), 57 RelinquishWizardResource(const ResourceType,const WizardSizeType), 58 ResourceComponentTerminus(void); 59 59 60 60 #if defined(__cplusplus) || defined(c_plusplus) -
WizardsToolkit/trunk/wizard/semaphore.c
r436 r445 196 196 % % 197 197 % % 198 % D e s t r o y S e m a p h o r e C o m p o n e n t %199 % %200 % %201 % %202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%203 %204 % DestroySemaphoreComponent() destroys the semaphore environment.205 %206 % The format of the DestroySemaphoreComponent method is:207 %208 % DestroySemaphoreComponent(void)209 %210 */211 WizardExport void DestroySemaphoreComponent(void)212 {213 #if defined(WIZARDSTOOLKIT_HAVE_PTHREAD)214 if (pthread_mutex_destroy(&semaphore_mutex) != 0)215 (void) fprintf(stderr,"pthread_mutex_destroy failed %s\n",216 GetExceptionMessage(errno));217 #endif218 }219 220 /*221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%222 % %223 % %224 % %225 198 % D e s t r o y S e m a p h o r e I n f o % 226 199 % % … … 254 227 *semaphore_info=(SemaphoreInfo *) RelinquishAlignedMemory(*semaphore_info); 255 228 UnlockWizardMutex(); 256 }257 258 /*259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%260 % %261 % %262 % %263 % I n s t a n t i a t e S e m a p h o r e C o m p o n e n t %264 % %265 % %266 % %267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%268 %269 % InstantiateSemaphoreComponent() instantiates the semaphore component.270 %271 % The format of the InstantiateSemaphoreComponent method is:272 %273 % WizardBooleanType InstantiateSemaphore(void)274 %275 */276 WizardExport WizardBooleanType InstantiateSemaphoreComponent(void)277 {278 LockWizardMutex();279 UnlockWizardMutex();280 return(WizardTrue);281 229 } 282 230 … … 411 359 % % 412 360 % % 361 % S e m a p h o r e C o m p o n e n t G e n e s i s % 362 % % 363 % % 364 % % 365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 366 % 367 % SemaphoreComponentGenesis() instantiates the semaphore component. 368 % 369 % The format of the SemaphoreComponentGenesis method is: 370 % 371 % WizardBooleanType SemaphoreComponentGenesis(void) 372 % 373 */ 374 WizardExport WizardBooleanType SemaphoreComponentGenesis(void) 375 { 376 LockWizardMutex(); 377 UnlockWizardMutex(); 378 return(WizardTrue); 379 } 380 381 /* 382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 383 % % 384 % % 385 % % 386 % S e m a p h o r e C o m p o n e n t T e r m i n u s % 387 % % 388 % % 389 % % 390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 391 % 392 % SemaphoreComponentTerminus() destroys the semaphore environment. 393 % 394 % The format of the SemaphoreComponentTerminus method is: 395 % 396 % SemaphoreComponentTerminus(void) 397 % 398 */ 399 WizardExport void SemaphoreComponentTerminus(void) 400 { 401 #if defined(WIZARDSTOOLKIT_HAVE_PTHREAD) 402 if (pthread_mutex_destroy(&semaphore_mutex) != 0) 403 (void) fprintf(stderr,"pthread_mutex_destroy failed %s\n", 404 GetExceptionMessage(errno)); 405 #endif 406 } 407 408 /* 409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 410 % % 411 % % 412 % % 413 413 + U n l o c k W i z a r d M u t e x % 414 414 % % -
WizardsToolkit/trunk/wizard/semaphore.h
r436 r445 31 31 extern WizardExport void 32 32 AcquireSemaphoreInfo(SemaphoreInfo **), 33 DestroySemaphoreComponent(void),34 33 DestroySemaphoreInfo(SemaphoreInfo **), 35 RelinquishSemaphoreInfo(SemaphoreInfo *); 34 RelinquishSemaphoreInfo(SemaphoreInfo *), 35 SemaphoreComponentTerminus(void); 36 36 37 37 extern WizardExport WizardBooleanType 38 InstantiateSemaphoreComponent(void),39 38 LockSemaphoreInfo(SemaphoreInfo *), 39 SemaphoreComponentGenesis(void), 40 40 UnlockSemaphoreInfo(SemaphoreInfo *); 41 41 -
WizardsToolkit/trunk/wizard/wizard.c
r436 r445 153 153 (void) signal(signal_number,SIG_IGN); 154 154 #endif 155 Asynchronous DestroyResourceComponent();155 AsynchronousResourceComponentTerminus(); 156 156 instantiate_wizard=WizardFalse; 157 157 (void) SetWizardSignalHandler(signal_number,signal_handlers[signal_number]); … … 215 215 (void) setlocale(LC_NUMERIC,"C"); 216 216 seconds=time((time_t *) NULL); 217 (void) InstantiateSemaphore();218 (void) InstantiateLogComponent();219 (void) InstantiateRandomComponent();217 (void) SemaphoreComponentGenesis(); 218 (void) LogComponentGenesis(); 219 (void) RandomComponentGenesis(); 220 220 events=GetEnvironmentValue("WIZARD_DEBUG"); 221 221 if (events != (char *) NULL) … … 294 294 Initialize wizard resources. 295 295 */ 296 (void) InstantiateResourceComponent();297 (void) InstantiateMimeComponent();296 (void) ResourceComponentGenesis(); 297 (void) MimeComponentGenesis(); 298 298 } 299 299 … … 318 318 WizardExport void WizardsToolkitTerminus(void) 319 319 { 320 DestroyMimeComponent();321 DestroyResourceComponent();322 DestroyRandomComponent();323 DestroyLogComponent();324 DestroySemaphoreComponent();325 } 320 MimeComponentTerminus(); 321 ResourceComponentTerminus(); 322 RandomComponentTerminus(); 323 LogComponentTerminus(); 324 SemaphoreComponentTerminus(); 325 }
