/*====================================================================*/
/* generated by the classic REXX to NetRexx converter */
/* (c) Thomas.Schneider@Donauland.at */
/*====================================================================*/
/* orig. REXX source: softunpk */
/* generated at: 2003-01-02 16:53:27 */
/* with: rex_nrx.nrx vs. 4.00 */
/* Rexx2Nrx options: */
/* Vars Localized: NO */
/* IO-method used : 3 ( RexxFile Object oriented ) */
/*====================================================================*/
import Rexx2Nrx.Rexx2RT.SysCmd
import Rexx2Nrx.Rexx2RT.RexxFile
import Rexx2Nrx.Rexx2RT.RexxMsg
import Rexx2Nrx.Rexx2RT.RexxTime
import Rexx2Nrx.Rexx2RT.strfun
class softunpk uses RexxFile, RexxMsg
properties public static
/* ... Declare Global Exposed Imported File-Descriptors */
FD_softpack_file = RexxFile Null
FD_control_file = RexxFile Null
FD_file = RexxFile Null
/* ... Declare Global File-Names */
softpack_file = Rexx ''
control_file = Rexx ''
file = Rexx ''
/* ... Declare Global Numbers */
opt_purge = int 0
n_files = int 0
/* ... Declare Global Strings */
date_time_stamp = Rexx ''
banner = Rexx ''
parm = Rexx ''
new_fp = Rexx ''
option = Rexx ''
control_fx = Rexx ''
control_fn = Rexx ''
control_fp = Rexx ''
x = Rexx ''
banner_line = Rexx ''
control_line_1 = Rexx ''
fn = Rexx ''
ft = Rexx ''
file_1 = Rexx ''
fp_soft = Rexx ''
line = Rexx ''
/* ... Declare Global other Variables */
processor = Rexx ''
control_file_1 = Rexx ''
date_time_stamp_1 = Rexx ''
softpack_file_1 = Rexx ''
control_line = Rexx ''
fp = Rexx ''
method main(args=String[]) static
arg=Rexx(args) -- program arguments as single string
arg=arg -- avoid NetRexx warning
opt_purge = 0
parse source processor .
date_time_stamp = DTS()
banner = '/*<>*<>*<>*<>*!! SOFTUNPK: ' date_time_stamp -
'!!*<>*<>*<>*<>*/'
parse arg parm
if parm = '' then do
say 'expected softpack-file-name;new-path-name;options'
exit 99
end--if
parse parm softpack_file ';' new_fp ';' option
FD_softpack_file = RexxFile.FD(softpack_file)
control_fx = RexxFile.parsefid(softpack_file)
control_fn = control_fx.word(1)
control_fp = control_fx.word(3)
control_file = fileid_function(control_fn,'FILELIST',new_fp)
FD_control_file = RexxFile.FD(control_file)
FD_softpack_file.open()
x = FD_softpack_file.linein()
parse x 'SOFTPACK: (c) Th. Schneider, 1994'
x = FD_softpack_file.linein()
parse x ' control file: ' control_file_1
x = FD_softpack_file.linein()
parse x ' DTS: ' date_time_stamp_1
x = FD_softpack_file.linein()
parse x ' SOFTPACK file: ' softpack_file_1
RexxMsg.info('**************************************************'-
'****')
RexxMsg.info('* SOFTUNPK: UNPACK SOFTWARE distribution '-
' *')
RexxMsg.info('* (c) Th. Schneider, 1994 '-
' *')
RexxMsg.info('**************************************************'-
'****')
RexxMsg.info('orig. SOFTPACK file: '||softpack_file_1)
RexxMsg.info('orig. control file: '||control_file_1)
RexxMsg.info('SOFT DTS: '||date_time_stamp_1)
RexxMsg.info('**************************************************'-
'****')
FD_control_file.scratch()
n_files = 0
if option = 'PURGE' then do
opt_purge = 1
end--if
banner_line = FD_softpack_file.linein()
loop while FD_softpack_file.lines() > 0
control_line_1 = FD_softpack_file.linein()
parse control_line_1 '/* ' control_line ' */'
FD_control_file.lineout(control_line)
parse control_line fn ft fp .
file_1 = fn ft fp
fp_soft = new_fp
file = fileid_function(fn,ft,fp_soft)
FD_file = RexxFile.FD(file)
RexxMsg.info('... unpacking file: '||file ' (origin:'-
''||file_1 ')')
FD_file.scratch()
n_files = n_files + 1
loop while FD_softpack_file.lines() > 0
line = FD_softpack_file.linein()
if line = banner_line then do
leave
end--if
FD_file.lineout(line)
end--loop
FD_file.close()
end--loop
FD_softpack_file.lineout(banner)
FD_softpack_file.close()
FD_control_file.close()
RexxMsg.info('**************************************************'-
'****')
RexxMsg.info(n_files ' files SOFT-unpacked from: '||softpack_file)
RexxMsg.info('**************************************************'-
'****')
exit
method info(say_line = Rexx) static public ;
/* ... Rexx Procedure (nothing exposed) */
say say_line
return
method scratch(fileid = Rexx) static public returns int;
/* ... Declare Local REXX variables: */
xop = Rexx ''
status = Rexx ''
reason = Rexx ''
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
FD_fileid = RexxFile.FD(fileid)
RexxFile.FD(fileid).delete() /* == 'ERASE '... */
xop = FD_fileid.open("write")
parse xop status ':' reason
if status <> 'READY' then do
RexxMsg.abort('unable to SCRATCH file '||fileid 'STATUS='||status)
end--if
return 0
method open(fileid = Rexx) static public returns int;
/* ... Declare Local REXX variables: */
xop = Rexx ''
status = Rexx ''
etc = Rexx ''
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
FD_fileid = RexxFile.FD(fileid)
xop = FD_fileid.open("read")
parse xop status ':' etc
if status = 'ERROR' then do
say "INPUT file: "||fileid||" MUST EXIST ...!!!"
say "*** PROGRAM ABORTED ***"
return - 99
end
else do
return 0
end--if
method close(fileid = Rexx) static public ;
/* ... Declare Local REXX variables: */
xop = Rexx ''
status = Rexx ''
reason = Rexx ''
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
FD_fileid = RexxFile.FD(fileid)
if fileid = "" then do
return
end--if
xop = FD_fileid.close()
parse xop status ':' reason
if status <> 'READY' then do
say 'CANNOT CLOSE file: ' fileid ', reason code:'||reason
exit 99
end--if
return
method DTS() static public returns Rexx;
/* ... Rexx Procedure (nothing exposed) */
return RexxTime.date('O') RexxTime.time()
method abort(message = Rexx) static public returns int;
/* ... Rexx Procedure (nothing exposed) */
say message
say "*** Program aborted ***"
return - 99
method parsefid($arg=Rexx '') static public returns Rexx;
/* ... Declare Local REXX variables: */
processor1 = Rexx ''
ipoint = int 0
iback = int 0
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
parse source processor1 .
if processor1 = 'CMS' then do
parse $arg fn1 ft1 fp1 .
end
else if processor1 = 'MVS' then do
parse $arg fp1 '(' fn1 ')'
ipoint = fp1.lastpos('.')
if ipoint > 0 then do
ft1 = fp1.substr(ipoint + 1)
fp1 = fp1.substr(1,ipoint - 1)
end
else do
ft1 = ''
end--if
end
else do
parse $arg fp1 '.' ft1
iback = fp1.lastpos('\\')
if iback > 0 then do
fn1 = fp1.substr(iback + 1)
fp1 = fp1.substr(1,iback - 1)
end
else do
fn1 = fp1
fp1 = ''
end--if
end--if
return fn1 ft1 fp1
method fileid_function(fn1 = Rexx,ft1 = Rexx,fp1 = Rexx)-
static public returns Rexx;
/* ... Declare Local REXX variables: */
processor1 = Rexx ''
file1 = Rexx ''
/* ... End of local REXX variable declarations */
/* ... Rexx Procedure (nothing exposed) */
parse source processor1 .
if processor1 = 'CMS' then do
if fp1 = " " then do
fp1 = "A"
end--if
file1 = fn1 ft1 fp1
end
else if processor1 = 'MVS' then do
if ft1 <> '' then do
file1 = fp1||'.'||ft1||'('||fn1||')'
end
else do
file1 = fp1||'('||fn1||')'
end--if
end
else do
if (processor1 = 'OS/2') & (ft1 = 'EXEC') then do
ft1 = 'cmd'
end--if
if (processor1 = 'Windows95') & (ft1 = 'EXEC') then do
ft1 = 'rexx'
end--if
if (processor1 = 'Java') & (ft1 = 'EXEC') then do
ft1 = 'rexx'
end--if
fn1 = strfun.lower(fn1)
ft1 = strfun.lower(ft1)
fp1 = strfun.lower(fp1)
if (processor1 = 'PC-DOS') & (ft1.length() > 3) then do
ft1 = ft1.substr(1,3)
end--if
if ft1 <> '' then do
file1 = fn1||'.'||ft1
end
else do
file1 = fn1
end--if
end--if
return file1
method lower(string = Rexx) static public returns Rexx;
return string.translate('abcdefghijklmnopqrstuvwxyz',-
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')