Changeset 1758
- Timestamp:
- Mar 5, 2014, 1:20:16 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/cfgmgr.cmd (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/cfgmgr.cmd
r1589 r1758 27 27 Edit to make sure this program is located correctly 28 28 Add version checking 29 Fully implement logging 29 30 30 31 Change log: … … 37 38 insert the UNZIP v6 entry from .\TMPLATES\ARCHVER.TMP into ,\ARCHIVER.BB2 (at the end) 38 39 30 Jun 11 JBS Ticket 459: Fix a bug and improve text when support for Unzip v6 has already been added. 40 05 Mar 14 JBS Ticket #532: Modified to append additional archiver definitions to ARCHIVER,BB2 41 Also, reworked the code to make appending more definitions easier in the future 42 Also, added missing features and a partial implementation of logging. 39 43 40 44 */ … … 48 52 signal on NOVALUE name Error 49 53 signal on SYNTAX name Error 50 /*51 54 signal on novalue /* for debugging */ 52 */53 55 54 56 call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs' … … 64 66 signal ErrorExit 65 67 66 if cfg.unattended = 0 then67 call GetUserOptions68 69 if cfg.userabort = 1 then70 signal NormalExit71 72 68 if cfg.operation = 'INSTALL' then 73 69 call UpdateFM2Ini 74 70 75 cfg.action_taken = 0 71 if cfg.attended = 1 then 72 do 73 call GetUserOptions 74 if cfg.userabort = 1 then 75 signal NormalExit 76 end 77 78 /* 79 * 80 * The following code 81 * Installs default files if /DEFAUTLS is specified or if a cfg file is missing 82 * Handles all /DEINSTALL actions 83 * It should precede the call to UpdateArchiverBB2 84 * 85 */ 86 87 /* 88 trace '?i' 89 */ 76 90 do f = 1 to cfg.file.0 77 91 file_exists = stream(cfg.file.f.name, 'c' , 'query exists') … … 83 97 if FilesAreDifferent(cfg.file.f.default, cfg.file.f.name) = 1 then 84 98 do 85 if cfg. unattended = 0then99 if cfg.attended = 1 then 86 100 do 87 user_choice = PromptForReplaceOption(f) 88 if user_choice == 'Q' then 89 signal NormalExit 90 if user_choice == 'N' then 101 if PromptForReplaceOption(f) = 'N' then 91 102 iterate 92 103 end 93 /* unattended = 1 or user_choice = 'Y' */104 /* attended = 0 or user choice = 'Y' */ 94 105 cfg.errorcode = CfgAction( 'RESETTODEFAULT', f ) 95 106 end … … 97 108 nop 98 109 else 99 if (cfg.file.f.toolbar = 1) & (cfg. unattended = 1) & (translate(right(cfg.file.f.name, 13, ' ')) \= '\QUICKTLS.DAT') then110 if (cfg.file.f.toolbar = 1) & (cfg.attended = 0) & (translate(right(cfg.file.f.name, 13, ' ')) \= '\QUICKTLS.DAT') then 100 111 call Ticket267Fix cfg.file.f.name 101 112 end … … 108 119 if BackupFileIsOK(f) = 0 then 109 120 iterate 110 if cfg. unattended = 0then121 if cfg.attended = 1 then 111 122 do 112 123 user_choice = PromptForReplaceOption(f) … … 122 133 end 123 134 124 if cfg.operation = 'INSTALL' then 125 call UpdateArchiverBB2 126 127 if cfg.errorcode \= 0 then 128 signal ErrorExit 129 130 if cfg.action_taken = 0 then 131 do 132 say 133 say 'No action taken.' 134 say 135 say 'FM/2 configuration files are already as you desire.' 136 end 137 138 signal NormalExit 135 call UpdateArchiverBB2 139 136 140 137 ErrorExit: 141 select 142 when cfg.errorcode = 1 then 143 call Usage 144 when cfg.errorcode = 2 then 145 call Usage 146 when cfg.errorcode = 3 then 147 call ProgramError 148 otherwise 149 call ProgramError 150 end 138 select 139 when cfg.errorcode = 0 then 140 nop 141 when cfg.errorcode = 1 then 142 call Usage 143 when cfg.errorcode = 2 then 144 call Usage 145 when cfg.errorcode = 5 then 146 do 147 say 'Fatal error occurred in updating your ARCHIVER.BB2 file!' 148 end 149 when cfg.errorcode = 3 then 150 call ProgramError 151 otherwise 152 call ProgramError 153 end 151 154 152 155 NormalExit: 156 signal off notready 157 call stream cfg.log_file, 'c', 'close' 153 158 n = endlocal() 154 159 exit cfg.errorcode 155 160 156 161 /* Subroutines */ 162 163 /*=== Error() Report ERROR, FAILURE etc. and exit ===*/ 164 165 Error: 166 say 167 parse source . . cmd 168 say 'CONDITION'('C') 'signaled at' cmd 'line' SIGL'.' 169 if 'CONDITION'('D') \= '' then 170 say 'REXX reason =' 'CONDITION'('D')'.' 171 if 'CONDITION'('C') == 'SYNTAX' & 'SYMBOL'('RC') == 'VAR' then 172 say 'REXX error =' RC '-' 'ERRORTEXT'(RC)'.' 173 else if 'SYMBOL'('RC') == 'VAR' then 174 say 'RC =' RC'.' 175 say 'Source =' 'SOURCELINE'(SIGL) 176 177 if 'CONDITION'('I') \== 'CALL' | 'CONDITION'('C') == 'NOVALUE' | 'CONDITION'('C') == 'SYNTAX' then do 178 trace '?A' 179 say 'Exiting.' 180 call 'SYSSLEEP' 2 181 exit 'CONDITION'('C') 182 end 183 return 184 185 /* end Error */ 186 187 novalue: 188 say 'Uninitialized variable: ' || condition('D') || ' on line: 'sigl 189 say 'Line text: 'sourceline(sigl) 190 cfg.errorcode = 3 191 signal ErrorExit 192 193 157 194 Init: procedure expose (globals) 158 195 159 button. = ''160 161 button.CMDS.helptext = 'Commands toolbar'162 button.CMDS.text = 'Cmds'163 button.CMDS.id = 4900164 165 button.UTILS.helptext = 'Utility toolbar'166 button.UTILS.text = 'Utils'167 button.UTILS.id = 4901168 169 button.SORT.helptext = 'Sort toolbar'170 button.SORT.text = 'Sort'171 button.SORT.id = 4902172 173 button.SELECT.helptext = 'Select toolbar'174 button.SELECT.text = 'Select'175 button.SELECT.id = 4903176 177 button.CONFIG.helptext = 'Configuration toolbar'178 button.CONFIG.text = 'Cmds'179 button.CONFIG.id = 4904180 181 button.FILES.helptext = 'Files toolbar'182 button.FILES.text = 'Files'183 button.FILES.id = 4905184 185 button.VIEWS.helptext = 'Views toolbar'186 button.VIEWS.text = 'Views'187 button.VIEWS.id = 4906196 button. = '' 197 198 button.CMDS.helptext = 'Commands toolbar' 199 button.CMDS.text = 'Cmds' 200 button.CMDS.id = 4900 201 202 button.UTILS.helptext = 'Utility toolbar' 203 button.UTILS.text = 'Utils' 204 button.UTILS.id = 4901 205 206 button.SORT.helptext = 'Sort toolbar' 207 button.SORT.text = 'Sort' 208 button.SORT.id = 4902 209 210 button.SELECT.helptext = 'Select toolbar' 211 button.SELECT.text = 'Select' 212 button.SELECT.id = 4903 213 214 button.CONFIG.helptext = 'Configuration toolbar' 215 button.CONFIG.text = 'Cmds' 216 button.CONFIG.id = 4904 217 218 button.FILES.helptext = 'Files toolbar' 219 button.FILES.text = 'Files' 220 button.FILES.id = 4905 221 222 button.VIEWS.helptext = 'Views toolbar' 223 button.VIEWS.text = 'Views' 224 button.VIEWS.id = 4906 188 225 189 226 cfg. = '' 190 227 cfg.errorcode = 0 191 228 cfg.defaults = 0 192 cfg. unattended = 0229 cfg.attended = 1 193 230 cfg.toolbarsonly = 0 194 cfg.actionmethod = 'COPY' /* The default method of backing up and restoring */ 195 cfg.backupdir = '.\User_Config_Backup' 196 197 call SysMkDir cfg.backupdir 231 cfg.actionmethod = 'COPY' /* The default (and currently only) method of backing up and restoring */ 232 cfg.log_file = 'cfgmgr.log' 233 cfg.vio_output_control = '>NUL 2>NUL' 234 235 parse source . . thispgm 236 p = lastpos('\', thispgm) 237 cfg.this_dir = filespec('D', thispgm) || filespec('P', thispgm) /* Directory w/ backslash */ 238 cfg.this_dir = left(cfg.this_dir, length(cfg.this_dir) - 1) /* Directory w/o backslash */ 239 if length(cfg.this_dir) = 2 then /* If root dir */ 240 call directory cfg.this_dir || '\' 241 else /* not root dir */ 242 call directory left(cfg.this_dir, length(cfg.this_dir) - 1) 243 244 cfg.backup_dir = cfg.this_dir || '\User_Config_Backup' 245 call SysMkDir cfg.backup_dir 246 247 cfg.pgmname = translate(substr(thispgm, p + 1, lastpos('.', thispgm) - p - 1)) 248 249 fm3ini = value('FM3INI',,'OS2ENVIRONMENT') 250 if fm3ini = '' then 251 cfg.inifile = cfg.this_dir || '\FM3.INI' 252 else 253 cfg.inifile = fm3ini 254 255 256 /* Read from a file instead? */ 198 257 199 258 f = 0 200 201 /* Read from a file instead? */202 259 203 260 f = f + 1 … … 315 372 cfg.file.0 = f 316 373 317 parse source . . thispgm 318 p = lastpos('\', thispgm) 319 cfg.pgmname = translate(substr(thispgm, p + 1, lastpos('.', thispgm) - p - 1)) 320 thisdir = left(thispgm, lastpos('\', thispgm) - 1) 321 if length(thisdir) = 2 then 322 thisdir = thisdir || '\' 323 call directory thisdir 324 fm2ini = value('FM3INI',,'OS2ENVIRONMENT') 325 if fm2ini = '' then 326 if right(thisdir, 1) \= '\' then 327 cfg.inifile = thisdir || '\' || 'FM3.INI' 328 else 329 cfg.inifile = thisdir || 'FM3.INI' 330 else 331 cfg.inifile = fm2ini 332 333 /* edit for correct directory here? */ 334 374 375 /* 376 * Unused code 377 * 335 378 parse value SysTextScreenSize() with . cfg.screen_width 336 379 if cfg.screen_width = 0 then /* for running in PMREXX */ 337 380 cfg.screen_width = 80 381 */ 338 382 339 383 return … … 341 385 ProcessArgs: procedure expose (globals) 342 386 parse arg args 387 call lineout cfg.log_file, 'Arguments:' args 343 388 if pos('/ToOlBaRsOnLy', args) > 0 then 344 389 cfg.specialiconrun = 1 … … 360 405 cfg.operation = 'DEINSTALL' 361 406 when param = '/UNATTENDED' then 362 cfg. unattended = 1407 cfg.attended = 0 363 408 when param = '/DEFAULTS' then 364 409 cfg.defaults = 1 … … 371 416 if cfg.operation = '' then 372 417 cfg.errorcode = 1 418 /* 373 419 else 374 420 if cfg.operation = 'INSTALL' & cfg.defaults = 0 then 375 cfg.unattended = 1 421 cfg.attended = 0 422 */ 376 423 return 377 424 … … 406 453 say 'default values.' 407 454 say 408 if GetResponse('Type ''Y'' to proceed, an thing else cancels') = 'Y' then409 cfg. unattended = 1455 if GetResponse('Type ''Y'' to proceed, anything else cancels') = 'Y' then 456 cfg.attended = 0 410 457 else 411 458 cfg.userabort = 1 … … 424 471 say 425 472 if GetResponse('Type ''Y'' to proceed, anthing else cancels') = 'Y' then 426 cfg. unattended = 1473 cfg.attended = 0 427 474 else 428 475 cfg.userabort = 1 … … 451 498 retval = 0 452 499 end 500 drop file. 453 501 return retval 454 502 … … 505 553 506 554 ProgramError: procedure expose (globals) 507 say 'Fatal pr gram error.'555 say 'Fatal program error.' 508 556 say 509 557 say 'This file may have been altered in some way. Please re-install FM/2.' … … 521 569 when cfg.actionmethod = 'COPY' then 522 570 do 523 'copy 'cfg.file.f.name cfg.backupdir 524 'copy 'cfg.file.f.default cfg.file.f.name 525 cfg.action_taken = 1 571 call CopyFile cfg.file.f.name, cfg.backup_dir 572 call CopyFile cfg.file.f.default, cfg.file.f.name 526 573 end 527 574 /* Implement other archive/restore methods here */ … … 533 580 when cfg.actionmethod = 'COPY' then 534 581 do 535 'copy 'cfg.file.f.default cfg.file.f.name 536 cfg.action_taken = 1 582 call CopyFile cfg.file.f.default, cfg.file.f.name 537 583 end 538 584 /* Implement other archive/restore methods here */ … … 545 591 when cfg.actionmethod = 'COPY' then 546 592 do 547 'copy 'cfg.backupdir || '\' || cfg.file.f.name' .' 548 cfg.action_taken = 1 593 call CopyFile cfg.backup_dir || '\' || cfg.file.f.name, ' .' 549 594 end 550 595 /* Implement other archive/restore methods here */ … … 558 603 if FilesAreDifferent(cfg.file.f.name, cfg.file.f.default) = 0 then 559 604 do 560 'del 'cfg.file.f.name 561 cfg.action_taken = 1 605 '@del 'cfg.file.f.name cfg.vio_output_control 562 606 end 563 607 /* Implement other archive/restore methods here */ … … 580 624 when cfg.actionmethod = 'COPY' then 581 625 do 582 backup_file = cfg.backup dir || '\' || cfg.file.f.name626 backup_file = cfg.backup_dir || '\' || cfg.file.f.name 583 627 if stream(backup_file, 'c', 'query exists') \= '' then 584 628 retval = FilesAreDifferent(cfg.file.f.name, backup_file) … … 625 669 if pos('FM2Shutdown' || null, StateNames) = 0 then 626 670 StateNames = StateNames || 'FM2Shutdown' || null 627 call charout , 'One-time conversion of states to new format...'628 671 do while StateNames \= '' 629 672 parse var StateNames StateName (null) StateNames … … 635 678 d2 = NumDirCnrs + 1 - d /* Work from the last to the first */ 636 679 do f = 1 to NumKeyFragments 637 call charout , '.'638 680 frag = word(KeyFragments, f) 639 681 OldKey = StateName || '.DirCnr' || frag || '.' || d2 … … 704 746 if abort_fix = 0 then 705 747 do 706 'copy' infile cfg.backup dir /* backup tls file */748 'copy' infile cfg.backup_dir /* backup tls file */ 707 749 'copy' outfile infile /* "install" new tls file */ 708 cfg.action_taken = 1709 750 end 710 751 call SysFileDelete outfile 711 752 return 712 753 754 /* Write a message to the log file and, if attended, to the screen */ 755 WriteMsg: procedure expose (globals) 756 parse arg msg 757 call lineout cfg.log_file, date() time() ':' msg 758 if cfg.attended = 1 then 759 say msg 760 return 761 762 CopyFile: procedure expose (globals) 763 parse arg from_file, to_file 764 '@copy' from_file to_file cfg.vio_output_control 765 return rc 766 713 767 UpdateArchiverBB2: procedure expose (globals) 714 bb2_file = '.\ARCHIVER.BB2' 715 bb2_v6_startline = FindUnzip6(bb2_file) 716 if bb2_v6_startline = 0 then 768 myrc = 0 769 770 /* If CFGMGR was called with /DEFAULTS and/or /DEINSTALL parameters 771 then there is nothing to do here! */ 772 if cfg.defaults = 1 | cfg.operation = 'DEINSTALL' then 773 return myrc 774 775 bb2_file = cfg.this_dir || '\ARCHIVER.BB2' 776 bb2_template_file = cfg.this_dir || '\Tmplates\archiver.tmp' 777 778 bb2_backup_file = cfg.backup_dir || '\Backup.bb2' /* <== Change this each new archivers are to be inserted */ 779 780 myrc = CopyFile(bb2_file, bb2_backup_file) 781 if myrc \= 0 then 717 782 do 718 tmp_file = '.\Tmplates\archiver.tmp' 719 tmp_v6_startline = FindUnzip6(tmp_file) 720 if tmp_v6_startline \= 0 then 721 do 722 backup_file = '.\User_Config_backup\B4Unzip6.bb2' 723 if stream(backup_file, 'c', 'query exists') \= '' then 724 if cfg.unattended = 0 then 783 if cfg.attended = 1 then 784 do 785 say 786 call WriteMsg 'Error: Unable to back up' filespec('n', bb2_file) || '.' 787 say 788 if cfg.defaults = 1 then 789 msgend = 'reverting to a default FM/2 ARCHIVER.BB2.' 790 else 791 msgend = 'appending new archiver definitions to' filespec('n', bb2_file) || '.' 792 call WriteMsg "Enter 'P' to proceed with" msgend ', or...' 793 user_option = GetResponse("Enter 'Q' to abort" cfg.pgmname '(P/q)') 794 end 795 else 796 user_option = 'P' 797 end 798 else 799 user_option = 'P' 800 if user_option = 'P' then 801 do 802 if cfg.attended = 1 & myrc \= 0 then 803 do 804 say 805 call WriteMsg 'Appending new archiver definitions to' filespec('n', bb2_file) || '.' 806 say 807 user_option = GetResponse("OK to proceed? (Y/n)") 808 end 809 else 810 user_option = 'Y' 811 if user_option = 'Y' then 812 do 813 myrc = InsertNewArchivers(bb2_file, bb2_template_file) 814 select 815 when myrc < 0 then 725 816 do 726 say 'Support for Unzip v6 has previously been added.' 727 if GetResponse("If you want to repeat this process, type 'Y'") \= 'Y' then 728 return 817 if cfg.attended = 1 then 818 do 819 say 820 call WriteMsg filespec('n', bb2_file) 'already has definitions for the new archivers.' 821 end 822 myrc = 0 729 823 end 730 else 731 return 732 insert_line = FindEndOfDefinitions(bb2_file) 733 if insert_line > 0 then 824 when myrc = 0 then 825 if cfg.attended = 1 then 826 do 827 say 828 call WriteMsg filespec('n', bb2_file) 'successfully updated with new archivers definitions.' 829 end 830 otherwise 831 do 832 if cfg.attended = 1 then 833 do 834 say 835 call WriteMsg 'Error: Unable to update' filespec('n', bb2_file) 'with new archiver definitions.' 836 say 837 call WriteMsg 'Current file continues in use.' 838 say 839 call WriteMsg "Enter 'P' to proceed with other updates or..." 840 user_option = GetResponse("Enter 'Q' to abort" cfg.pgmname '(P/q)') 841 if user_option = 'Q' then 842 cfg.userabort = 1 843 end 844 end 845 end 846 end 847 end /* Install, append new */ 848 else /* Backup not OK, no proceed */ 849 cfg.userabort = 1 850 return (5*(myrc \= 0)) /* Convert any non-zero into a 5 */ 851 852 InsertNewArchivers: procedure expose(globals) 853 parse arg bb2_file, bb2_template_file 854 myrc = 0 855 856 files.1.name = bb2_file 857 files.2.name = bb2_template_file 858 files.0 = 2 859 860 do i = 1 to files.0 861 j = 0 862 do while lines(files.i.name) > 0 863 j = j + 1 864 files.i.lines.j = linein(files.i.name) 865 end 866 files.i.lines.0 = j 867 call stream files.i.name, 'c', 'close' 868 end 869 870 zip6_liststart_line = '-------- ------ ------- ---- ---------- ----- -------- ----' 871 zip6_listend_line = '-------- ------- --- -------' 872 873 markers. = '' 874 i = 0 875 i = i + 1 876 markers.i.name = 'Zip v6.0' 877 markers.i.markerline_start = zip6_listend_line 878 markers.i.markerline_pos_in_def = 16 879 markers.i.pos_of_def_in_file.1 = 0 880 markers.i.pos_of_def_in_file.2 = 0 881 i = i + 1 882 markers.i.name = '7 Zip' 883 markers.i.markerline_start = '7ZA.EXE' 884 markers.i.markerline_pos_in_def = 4 885 markers.i.pos_of_def_in_file.1 = 0 886 markers.i.pos_of_def_in_file.2 = 0 887 i = i + 1 888 markers.i.name = 'LZip' 889 markers.i.markerline_start = 'LZIP.EXE' 890 markers.i.markerline_pos_in_def = 4 891 markers.i.pos_of_def_in_file.1 = 0 892 markers.i.pos_of_def_in_file.2 = 0 893 i = i + 1 894 markers.i.name = 'XC' 895 markers.i.markerline_start = 'XC.EXE' 896 markers.i.markerline_pos_in_def = 4 897 markers.i.pos_of_def_in_file.1 = 0 898 markers.i.pos_of_def_in_file.2 = 0 899 900 markers.0 = i - 1 /* test: skip xc for now */ 901 902 do i = 1 to files.0 903 in_def = 0 904 do j = 1 to files.i.lines.0 905 if left(files.i.lines.j, 1) = ';' then 906 do 907 if in_def = 1 then in_def = 0 908 iterate 909 end 910 else 911 if in_def = 0 then 912 if strip(files.i.lines.j) = '' then /* 1st line of def can't be blank? */ 913 iterate 914 else 734 915 do 735 '@copy' bb2_file backup_file '>NUL 2>NUL' 736 if rc \= 0 then 737 return 738 call SysFileDelete bb2_file 739 do i = 1 to insert_line 740 call lineout bb2_file, bb2_lines.i 741 end 742 do j = 1 to tmp_v6_startline 743 line = linein(tmp_file) 744 end 745 do 25 /* 21 lines of def + 3 prefix comment lines + 1 postfix comment */ 746 line = linein(tmp_file) 747 call lineout bb2_file, line 748 end 749 call stream tmp_file, 'c', 'close' 750 do j = i to bb2_lines.0 751 call lineout bb2_file, bb2_lines.j 752 end 753 call stream bb2_file, 'c', 'close' 754 cfg.action_taken = 1 916 in_def = 1 917 def_line = 1 918 last_def.i = j 755 919 end 756 else 757 if cfg.unattended = 1 then 758 say 'Unable to find place to insert definition.' 920 else 921 def_line = def_line + 1 922 do m = 1 to markers.0 923 if markers.m.pos_of_def_in_file.i = 0 then 924 if markers.m.markerline_pos_in_def = def_line then 925 do /* Check for marker line here */ 926 if abbrev(translate(files.i.lines.j), markers.m.markerline_start) = 1 then 927 do 928 if markers.m.name \= 'Zip v6.0' then 929 do 930 markers.m.pos_of_def_in_file.i = j - markers.m.markerline_pos_in_def + 1 931 /* 932 call WriteMsg 'Found' markers.m.name 'definition in' filespec('n', files.i.name) || '.' 933 */ 934 end 935 else 936 do /* special code for zip 6 with 2 marker lines */ 937 q = j - 1 938 if abbrev(files.i.lines.q, zip6_liststart_line) = 1 then 939 do 940 markers.m.pos_of_def_in_file.i = j - markers.m.markerline_pos_in_def + 1 941 /* 942 call WriteMsg 'Found' markers.m.name 'definition in' filespec('n', files.i.name) || '.' 943 */ 944 end 945 end 946 end 947 end 948 end 949 end 950 end 951 end_of_archivers_line = last_def.1 + 21 952 953 temp_file = SysTempFilename(cfg.this_dir || '\bb2temp.???') 954 new_data_written = 0 955 do j = 1 to end_of_archivers_line 956 call lineout temp_file, files.1.lines.j 957 end 958 do m = 1 to markers.0 959 if markers.m.pos_of_def_in_file.1 = 0 then 960 /* 961 Don't bother checking to see if archiver.tmp has new defs. Just assume this. 962 if markers.m.pos_of_def_in_file.2 = 0 then 963 do 964 call WriteMsg 'Definition for' markers.m.name 'not found in either file!!' 759 965 end 760 966 else 761 if cfg.unattended = 1 then 762 say 'Unable to find Unzip v6 definition' 967 */ 968 do 969 call WriteMsg 'Inserting definition for' markers.m.name 970 start_at = markers.m.pos_of_def_in_file.2 - 3 971 end_at = start_at + 21 + 4 - 1 972 do q = start_at to end_at 973 call lineout temp_file, files.2.lines.q 974 end 975 new_data_written = 1 976 end 977 /* 978 Debug code 979 else 980 if markers.m.pos_of_def_in_file.2 = 0 then 981 do 982 call WriteMsg 'Definition for' markers.m.name 'not found in' filespec('n', files.2.name) || '!!' 983 end 984 else 985 do 986 call WriteMsg markers.m.name 'found in' files.1.name 'and' files.2.name 987 end 988 */ 989 end 990 if new_data_written = 1 then 991 do 992 do q = j to files.1.lines.0 /* "j" is from the earlier loop */ 993 call lineout temp_file, files.1.lines.q 994 end 995 call stream temp_file, 'c', 'close' 996 call SysFileDelete files.1.name 997 myrc = CopyFile( temp_file, files.1.name ) 763 998 end 764 999 else 765 if cfg.unattended = 1 then 766 say 'Unzip v6 definition is already installed.' 767 return 768 769 FindUnzip6: procedure expose (globals) 770 parse arg filename 771 start_string = '-------- ------ ------- ---- ---------- ----- -------- ----' 772 end_string = '-------- ------- --- -------' 773 call SysFileSearch start_string, filename, 'start_lines.', 'N' 774 call SysFileSearch end_string, filename, 'end_lines.', 'N' 775 start_line = 0 776 do i = 1 to start_lines.0 777 do j = 1 to end_lines.0 778 if word(end_lines.j, 1) = word(start_lines.i, 1) + 1 then 779 do 780 start_line = word(start_lines.i, 1) - 18 781 i = start_lines.0 782 j = end_lines.0 783 end 784 end 785 end 786 drop start_lines. 787 drop end_lines. 788 return start_line 789 790 FindEndOfDefinitions: procedure expose (globals) bb2_lines. 791 parse arg bb2_file 792 end_of_defs_line = 0 793 i = 0 794 do while lines(bb2_file) > 0 795 i = i + 1 796 bb2_lines.i = linein(bb2_file) 797 if strip(bb2_lines.i) \= '' then 798 if abbrev(bb2_lines.i, ';') then 799 if end_of_defs_line = 0 then 800 end_of_defs_line = i 801 else 802 nop 803 else 804 end_of_defs_line = 0 805 end 806 call stream bb2_file, 'c', 'close' 807 bb2_lines.0 = i 808 return end_of_defs_line 809 810 811 /*=== Error() Report ERROR, FAILURE etc. and exit ===*/ 812 813 Error: 814 say 815 parse source . . cmd 816 say 'CONDITION'('C') 'signaled at' cmd 'line' SIGL'.' 817 if 'CONDITION'('D') \= '' then 818 say 'REXX reason =' 'CONDITION'('D')'.' 819 if 'CONDITION'('C') == 'SYNTAX' & 'SYMBOL'('RC') == 'VAR' then 820 say 'REXX error =' RC '-' 'ERRORTEXT'(RC)'.' 821 else if 'SYMBOL'('RC') == 'VAR' then 822 say 'RC =' RC'.' 823 say 'Source =' 'SOURCELINE'(SIGL) 824 825 if 'CONDITION'('I') \== 'CALL' | 'CONDITION'('C') == 'NOVALUE' | 'CONDITION'('C') == 'SYNTAX' then do 826 trace '?A' 827 say 'Exiting.' 828 call 'SYSSLEEP' 2 829 exit 'CONDITION'('C') 830 end 831 return 832 833 /* end Error */ 834 835 novalue: 836 say 'Uninitialized variable: ' || condition('D') || ' on line: 'sigl 837 say 'Line text: 'sourceline(sigl) 838 cfg.errorcode = 3 839 signal ErrorExit 840 841 1000 do /* No need to update ARCHIVER.BB2 */ 1001 myrc = -1 1002 call stream temp_file, 'c', 'close' 1003 end 1004 call SysFileDelete temp_file 1005 return myrc 1006
Note:
See TracChangeset
for help on using the changeset viewer.
