home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / syssplit.zip / syssplit.cmd next >
OS/2 REXX Batch file  |  1996-09-19  |  4KB  |  151 lines

  1. /* rexx */
  2. /* Trace SYSTEM.T?F file split utility */
  3. /* R.J.Moore 4th May 1996 */
  4. /* version 1.3 */
  5. say 'SYSSPLIT: TRACE SYSTEM.T?F split file list utility version 1.3'
  6. say 'Author: Richard Moore - 19 September 1996'
  7. say 'Copyright (C) 1995, IBM UK Ltd.'
  8. say ''
  9.  
  10. trace 'o'
  11.  
  12. !.=''
  13. arg !.0sysfile d .
  14.  
  15. if d='DEBUG' then !.0dbg=(0=0)
  16. else !.0dbg=(0=1)
  17.  
  18. if !.0sysfile='' then do
  19.    say 'SYSSPLIT SYSTEM.T?F'
  20.    exit 4
  21. end  /* Do */
  22.  
  23. !.0tffopen=0=1
  24. signal on halt name haltexit
  25.  
  26. !.0rxcc=rxfuncadd('SysFileTree','REXXUTIL','SysFileTree')
  27. call SysFileTree !.0sysfile,'x','F'
  28. if x.0=0 then do
  29.    say 'File' !.0sysfile 'not found'
  30.    if !.0rxcc=0 then call rxfuncdrop 'SysFileTree'
  31.    exit 4
  32. end  /* Do */
  33. if !.0rxcc=0 then call rxfuncdrop 'SysFileTree'
  34.  
  35. extents.=''     /* list of duplicate suffixes per TFF */
  36. namelst.=0=1    /* boolean test for name existence */
  37. uniqnames.=''   /* list of unique names */
  38. j=0             /* number of unique names */
  39.  
  40. hdrsize=c2d(getword(0))
  41. files=c2d(getword(2))
  42.  
  43. /* either create temporary TFFs  */
  44. /* or final TDFs                  */
  45. !.0tfftype=0=1
  46. offset=4
  47. do i=1 to files
  48.    name=getbyte(offset,15)
  49.    name=strip(name,'T','0'x)
  50.    parse var name name '.' ext
  51.    if ext='TFF' then do
  52.       extents.name=extents.name 'F'i
  53.       if ¬namelst.name then do
  54.          namelst.name=0=0 /*true*/
  55.          j=j+1
  56.          uniqnames.j=name
  57.       end  /* Do */
  58.       name=name'.F'i
  59.       !.0tfftype=0=0
  60.    end /* do */
  61.    else name=name'.'ext
  62.    offset=offset+15
  63.    file_size=c2d(getdword(offset))
  64.    offset=offset+4
  65.    file_offset=c2d(getdword(offset))
  66.    offset=offset+4
  67.    if !.0dbg then do
  68.       say 'size: x'd2x(file_size)
  69.       say 'offset: x'd2x(file_offset)
  70.    end /* do */
  71.    data=getbyte(file_offset,file_size)
  72.    if ext='TFF' then,
  73.       say 'Generating temporary TFF:' name
  74.    else,
  75.       say 'Generating:' name
  76.    '@erase' name '2>NUL'
  77.    x=charout(name,data)
  78.    x=charout(name)
  79. end /* do */
  80. uniqnames.0=j
  81.  
  82. /* now look for duplicate names, if found used */
  83. /* TRCUST to combine them                      */
  84. /* if not found then rename tor *.TFF          */
  85.  
  86. trace 'o'
  87. if !.0tfftype then do i=1 to uniqnames.0
  88.    name=uniqnames.i
  89.    if words(extents.name)>1 then do
  90.       say 'Combining TFFs for' name 'from:'
  91.       '@erase @@COMB@@.TSF 2>NUL'
  92.       do j=1 to words(extents.name)
  93.          ext=word(extents.name,j)
  94.          say '  ' name'.'ext
  95.          x=lineout('@@COMB@@.TSF',name'.'ext)
  96.       end /* do */
  97.       x=lineout('@@COMB@@.TSF')
  98.       say 'Generating:' name'.TFF'
  99.       'TRCUST @@COMB@@.TSF /C='name'.TFF'
  100.       do j=1 to words(extents.name)
  101.          ext=word(extents.name,j)
  102.          '@ERASE' name'.'ext '2>NUL'
  103.       end /* do */
  104.    end  /* Do */
  105.    else do
  106.       say 'Generating:' name'.TFF'
  107.       ext=word(extents.name,1)
  108.       '@erase' name'.TFF' '2>NUL'
  109.       '@rename' name'.'ext name'.TFF' '2>NUL'
  110.    end  /* Do */
  111. end /* do */
  112. '@erase @@COMB@@.TSF 2>NUL'
  113.  
  114.  
  115. haltexit: if !.0tffopen then x=lineout(!.0sysfile) /* close tfffile */
  116.  
  117. exit 0
  118.  
  119.  
  120.  
  121. x=getbyte(!.0tff.i.0offset)
  122. do while x<>'0'x
  123.    !.0tff.i.0fmt=!.0tff.i.0fmt || x
  124.    !.0tff.i.0offset=!.0tff.i.0offset+1
  125.    x=getbyte(!.0tff.i.0offset)
  126. end /* do */
  127.  
  128. return 0     
  129.  
  130.  
  131. getbyte: procedure expose !.
  132. /* read one or more bytes from the .tff file from given offset */
  133.  
  134. parse arg offset,length
  135. if length='' then length=1
  136. return charin(!.0sysfile,offset+1,length)
  137.  
  138. getword: procedure expose !.
  139. /* read a word from the .tff file from given offset */
  140.  
  141. parse arg offset
  142. x=charin(!.0sysfile,offset+1,2)
  143. return translate('12',x,'21')
  144.  
  145. getdword: procedure expose !.
  146. /* read a double word from the .tff file from given offset */
  147.  
  148. parse arg offset
  149. x=charin(!.0sysfile,offset+1,4)
  150. return translate('1234',x,'4321')
  151.