/* OS/2 REXX interface for WinWpi.exe and ZIP.exe repacking the */ /* packages in a WPI (Warpin) archive. Spaces in paths are not */ /* yet supported. WinWpi.exe and ZIP.exe must be in the path. */ signal on novalue name TRAP ; signal on syntax name TRAP signal on failure name TRAP ; signal on halt name TRAP parse arg WPI ZIP ; signal on error name TRAP N = 0 ; PCK.0 = 0 if WPI = '' | ZIP <> '' then do parse source . . WPI ; say 'usage:' WPI 'src.wpi' say 'create src.zip using temporary subdir.s below CWD' exit 1 end ZIP = stream( WPI, 'c', 'query exists' ) if ZIP = '' then exit TRAP( 'not found:' WPI ) WPI = ZIP ZIP = translate( ZIP, '\', '/' ) ZIP = substr( ZIP, 1 + lastpos( '\', ZIP )) ZIP = left( ZIP, length( ZIP ) - 4 ) address CMD '@WinWpi' WPI '-p | rxqueue' rxqueue( 'get') do while sign( queued()) parse pull PACK FILE NAME /* package number, files, name */ if datatype( PACK, 'w' ) = 0 then iterate if datatype( FILE, 'w' ) = 0 then iterate N = PCK.0 + 1 ; PCK.0 = N PCK.N = PACK ; REN.N = strip( NAME ) end /* WIS (Warpin install script): */ address CMD '@WinWpi' WPI '-X >' ZIP || '.wis' address CMD '@zip -m' ZIP ZIP || '.wis' do N = 1 to PCK.0 /* extract packages to subdir.s: */ address CMD '@MD' PCK.N ; call directory PCK.N address CMD '@WinWpi' WPI '-x' N call directory '..' ; signal off error address CMD '@REN' PCK.N '"' || REN.N || '"' signal on error name TRAP /* use the number if REN failed: */ if rc = 0 then address CMD '@zip -S -r -m' ZIP '"' || REN.N || '"' else address CMD '@zip -S -r -m' ZIP PCK.N end N exit 0 /* see , (c) F. Ellermann */ TRAP: /* select REXX exception handler */ call trace 'O' ; trace N /* don't trace interactive */ parse source TRAP /* source on separate line */ TRAP = x2c( 0D ) || right( '+++', 10 ) TRAP || x2c( 0D0A ) TRAP = TRAP || right( '+++', 10 ) /* = standard trace prefix */ TRAP = TRAP strip( condition( 'c' ) 'trap:' condition( 'd' )) select when wordpos( condition( 'c' ), 'ERROR FAILURE' ) > 0 then do if condition( 'd' ) > '' /* need an additional line */ then TRAP = TRAP || x2c( 0D0A ) || right( '+++', 10 ) TRAP = TRAP '(RC' rc || ')' /* any system error codes */ if condition( 'c' ) = 'FAILURE' then rc = -3 end when wordpos( condition( 'c' ), 'HALT SYNTAX' ) > 0 then do if condition( 'c' ) = 'HALT' then rc = 4 if condition( 'd' ) > '' & condition( 'd' ) <> rc then do if condition( 'd' ) <> errortext( rc ) then do TRAP = TRAP || x2c( 0D0A ) || right( '+++', 10 ) TRAP = TRAP errortext( rc ) end /* future condition( 'd' ) */ end /* may use errortext( rc ) */ else TRAP = TRAP errortext( rc ) rc = -rc /* rc < 0: REXX error code */ end when condition( 'c' ) = 'NOVALUE' then rc = -2 /* dubious */ when condition( 'c' ) = 'NOTREADY' then rc = -1 /* dubious */ otherwise /* force non-zero whole rc */ if datatype( value( 'RC' ), 'W' ) = 0 then rc = 1 if rc = 0 then rc = 1 if condition() = '' then TRAP = TRAP arg( 1 ) end /* direct: TRAP( message ) */ TRAP = TRAP || x2c( 0D0A ) || format( sigl, 6 ) signal on syntax name TRAP.SIGL /* throw syntax error 3... */ if 0 < sigl & sigl <= sourceline() /* if no handle for source */ then TRAP = TRAP '*-*' strip( sourceline( sigl )) else TRAP = TRAP '+++ (source line unavailable)' TRAP.SIGL: /* ...catch syntax error 3 */ if abbrev( right( TRAP, 2 + 6 ), x2c( 0D0A )) then do TRAP = TRAP '+++ (source line unreadable)' ; rc = -rc end select when 0 then do /* in pipes STDERR: output */ parse version TRAP.REXX . . /* REXX/Personal: \dev\con */ signal on syntax name TRAP.FAIL if TRAP.REXX = 'REXXSAA' /* fails if no more handle */ then call lineout 'STDERR' , TRAP else call lineout '\dev\con', TRAP end when 0 then do /* OS/2 PM: RxMessageBox() */ signal on syntax name TRAP.FAIL call RxMessageBox , /* fails if not in PMREXX */ translate( TRAP, ' ', x2c( 0D )), , 'CANCEL', 'WARNING' end /* replace any CR by blank */ otherwise say TRAP ; trace ?L /* interactive Label trace */ end if condition() = 'SIGNAL' then signal TRAP.EXIT TRAP.CALL: return rc /* continue after CALL ON */ TRAP.FAIL: say TRAP ; rc = 0 - rc /* force TRAP error output */ TRAP.EXIT: exit rc /* exit for any SIGNAL ON */