softpack.nrx 10.12.2002 19:03:28
/*====================================================================*/
/* generated by the classic REXX to NetRexx converter */
/* (c) Thomas.Schneider@Donauland.at */
/*====================================================================*/
/* orig. REXX source: softpack */
/* generated at: 2002-12-10 19:00:19 */
/* with: rex_nrx.nrx vs. 4.00 pre 28 */
/* Rexx2Nrx options: */
/* Vars Localized: NO */
/* IO-method used : 3 ( RexxFile Object oriented ) */
/*====================================================================*/
import Rexx2Nrx.Rexx2RT.RexxMsg
import Rexx2Nrx.Rexx2RT.RexxFile
import Rexx2Nrx.Rexx2RT.strfun
class softpack uses RexxMsg, RexxFile
properties public static
/* ... Declare Global Exposed Imported File-Descriptors */
FD_control_file = RexxFile Null
FD_softpack_file = RexxFile Null
FD_control_line = RexxFile Null
FD_file1 = RexxFile Null
FD_fn = RexxFile Null
FD_file3 = RexxFile Null
/* ... Declare Global File-Names */
control_file = Rexx ''
softpack_file = Rexx ''
control_line = Rexx ''
file1 = Rexx ''
fn = Rexx ''
file3 = Rexx ''
/* ... Declare Global Numbers */
n_files = int 0
n_queued = int 0
i_queued = int 1
n_ignored = int 0
/* ... Declare Global Strings */
work_disk = Rexx 'E1'
fp_copy = Rexx ''
cobol_copy_libs = Rexx 'COPY TST1COPY KOOPCOPY PRODCOPY'
rexx_copy_libs = Rexx 'REXXINCL REXX EXEC'
run_time_package = Rexx 'INFO FILEIO REXXMSG REXXFILE STRFUN'-
'WORDLIST'
opt_include = Rexx 1
opt_purge = Rexx 0
date_time_stamp = Rexx ''
banner = Rexx ''
parm = Rexx ''
control_fn = Rexx ''
s_filetype = Rexx ''
tx = Rexx ''
language = Rexx 'COBOL'
copy_libs = Rexx ''
x_file = Rexx ''
x1 = Rexx ''
name2 = Rexx ''
w2 = Rexx ''
ft3 = Rexx ''
/* ... Declare Global Stems / Arrays */
queue = Rexx '' /*Stem!*/
/* ... Declare Global other Variables */
options = Rexx ''
ft = Rexx ''
fm = Rexx ''
A1 = Rexx 'A1'
iw = int 0
iq = int 0
method main(args=String[]) static
arg=Rexx(args) -- program arguments as single string
arg=arg -- avoid NetRexx warning
work_disk = 'E1'
RexxMsg.init_info('SOFTPACK','NEW')
fp_copy = ''
cobol_copy_libs = 'COPY TST1COPY KOOPCOPY PRODCOPY'
rexx_copy_libs = 'REXXINCL REXX EXEC'
run_time_package = 'INFO FILEIO REXXMSG REXXFILE STRFUN WORDLIST'
opt_include = 1
opt_purge = 0
date_time_stamp = RexxFile.DTS()
banner = '/*<>*<>*<>*<>*!! SOFTPACK: ' date_time_stamp -
'!!*<>*<>*<>*<>*/'
parse arg parm
if parm = '' then do
say '========================================================'-
'===='
say 'SOFTPACK packs a given FILELIST into a single SOFTPACK file'
say 'parameter required. parameters are:'
say 'control-file;softpack-file;options'
say 'at least the name of the control-file must be given'
say 'the control-file should contain a list of file-names which'
say 'should be soft-packed for distribution'
say '========================================================'-
'===='
exit 99
end--if
parse parm control_file ';' softpack_file ';' options
FD_control_file = RexxFile.FD(control_file)
FD_softpack_file = RexxFile.FD(softpack_file)
control_fn = RexxFile.parsefid(control_file).word(1)
if softpack_file = '' then do
softpack_file = RexxFile.fileid(control_fn,'SOFTPACK',work_disk)
FD_softpack_file = RexxFile.FD(softpack_file)
end--if
FD_control_file.open()
FD_softpack_file.scratch()
control('SOFTPACK: (c) Th. Schneider, 1994')
control(' control file: '||control_file)
control(' DTS: '||date_time_stamp)
control(' SOFTPACK file: '||softpack_file)
n_files = 0
n_queued = 0
queue = ''
if strfun.is_member('PURGE',options) then do
opt_purge = 1
end--if
if strfun.is_member('COPIES',options) then do
opt_include = 1
end--if
if strfun.is_member('NOCOPIES',options) then do
opt_include = 0
end--if
if strfun.is_member('INCL',options) then do
opt_include = 1
end--if
if strfun.is_member('NOINCL',options) then do
opt_include = 0
end--if
loop while FD_control_file.lines() > 0
control_line = FD_control_file.linein()
FD_control_line = RexxFile.FD(control_line)
if control_line.substr(1,1) = '*' then do
iterate
end--if
file1 = RexxFile.parsefid(control_line)
FD_file1 = RexxFile.FD(file1)
soft_packer(file1)
end--loop
i_queued = 1
loop while i_queued <= n_queued
file1 = queue[i_queued]
FD_file1 = RexxFile.FD(file1)
control_line = RexxFile.parsefid(file1)
FD_control_line = RexxFile.FD(control_line)
soft_packer(file1)
i_queued = i_queued + 1
end--loop
FD_softpack_file.lineout(banner)
FD_softpack_file.close()
FD_control_file.close()
RexxMsg.closelog()
say n_files ' files SOFT-packed to: '||softpack_file
exit
method soft_packer(s_file = Rexx '') static public ;
s_file=s_file.upper()
FD_s_file = RexxFile.FD(s_file)
s_filetype = s_file.word(2)
tx = strfun.upper(s_filetype)
select
when 'COBOL COBOL2 COPY KOOPCOPY PRODCOPY '.wordpos(-
tx) > 0 then do
language = 'COBOL'
copy_libs = cobol_copy_libs
end--when
when 'REXX REXXINCL EXEC'.wordpos(tx) > 0 then do
language = 'REXX'
copy_libs = rexx_copy_libs
end--when
otherwise do
do
language = 'unknown'
copy_libs = 'COPY'
end
end--otherwise
end--select
if RexxFile.exists(s_file) = 0 then do
RexxMsg.info('file:' s_file 'does not exist, entry ignored ...')
return
end--if
n_files = n_files + 1
FD_softpack_file.lineout(banner)
FD_softpack_file.lineout('/* '||control_line||' */')
if RexxFile.ispacked(s_file) then do
say 'file:' s_file 'is packed'
x_file = RexxFile.parsefid(s_file)
parse x_file fn ft fm
file1 = RexxFile.fileid(fn,ft,A1)
FD_file1 = RexxFile.FD(file1)
RexxFile.unpack(s_file,file1)
say 'file:' s_file 'unpacked to:' file1
say '... SOFT-packing file: '||file1
append_file(file1,softpack_file)
if file1 <> s_file then do
RexxFile.purge(file1)
end--if
end
else do
say '... SOFT-packing file: '||s_file
append_file(s_file,softpack_file)
end--if
return
method control(x_line = Rexx '') static public ;
say x_line
FD_softpack_file.lineout(x_line)
return
method append_file(a_file1 = Rexx '',toa_file1 = Rexx '')-
static public ;
FD_a_file1 = RexxFile.FD(a_file1)
FD_toa_file1 = RexxFile.FD(toa_file1)
FD_a_file1.extend()
loop while FD_a_file1.lines() > 0
RexxMsg.line = FD_a_file1.linein()
if opt_include then do
queue_includes()
end--if
FD_toa_file1.lineout(RexxMsg.line)
end--loop
FD_a_file1.close()
return
method queue_includes() static public ;
x1 = RexxMsg.line.strip()
if (language = 'COBOL') & (x1.word(1) = 'COPY') then do
name2 = x1.word(2).strip('T','.').strip()
queue_name(name2)
end--if
if (language = 'REXX') & (x1.word(1) = '/*%INCLUDE') then do
w2 = x1.word(2)
if w2.pos('*/') > 0 then do
w2 = w2.substr(1,w2.pos('*/') - 1)
end--if
name2 = w2.strip()
queue_name(name2)
end--if
return
method queue_name(name3 = Rexx '') static public ;
name3=name3.upper()
FD_name3 = RexxFile.FD(name3)
if run_time_package.wordpos(name3) > 0 then do
RexxMsg.info('Module:' name3 'is part of RUN-time-package,'-
'ignored')
return
end--if
loop iw = 1 to copy_libs.words()
ft3 = copy_libs.word(iw)
file3 = RexxFile.fileid(name3,ft3,fp_copy)
FD_file3 = RexxFile.FD(file3)
if RexxFile.exists(file3) then do
queue_file(file3)
return
end--if
end--loop iw
RexxMsg.info('copy name:' name3 'is not found in: '||copy_libs)
RexxMsg.info('copy name:' name3 'ignored')
n_ignored = n_ignored + 1
return
method queue_file(file4 = Rexx '') static public ;
file4=file4.upper()
FD_file4 = RexxFile.FD(file4)
loop iq = 1 to n_queued
if queue[iq] = file4 then do
return
end--if
end--loop iq
n_queued = n_queued + 1
iq = n_queued
queue[iq] = file4
RexxMsg.info(' include file:' file4 'queued')
return