home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / wCNews_1.0.30.lha / contrib / RebuildHistory / rh.pass1.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-07-08  |  1.9 KB  |  78 lines

  1. /* rh.pass1.rexx, (c) 1993 by Gerald Malitz <gm@germal.escape.de> */
  2. /* rh.pass1.rexx, chngs (c) 1993 by Kai 'wusel' Siering <wusel@hactar.hanse.de> */
  3.  
  4. /*
  5.         date = 252460800+days*86400+mins*60+ticks/50
  6. */
  7.  
  8. if ~show('L', "rexxsupport.library") then do
  9.    if ~addlib("rexxsupport.library", 0, -30, 0)
  10.       then exit 10
  11. end
  12.  
  13. /* wusel, Thu, 8 Jul 1993 16:38:24 +0200:
  14.  *
  15.  * first get all expired articles out of uulib:news/history
  16.  */
  17. if open(histfile, "uulib:news/history", 'R') then do
  18.    do forever
  19.       line = readln(histfile)
  20.       if eof(histfile) then leave
  21.  
  22.       parse value line with msgid '09'x date '09'x files
  23.  
  24.       if(files=="")
  25.          then say date ||'09'x|| msgid ||'09'x|| files
  26.    end
  27.    close(histfile)
  28. end
  29.  
  30. /* Perform the scan, rebuilding the history.
  31.  * NOTE: for sorting purposes date & id are reversed, corrected
  32.  * with rh.pass2.rexx.
  33.  */
  34.  
  35. do forever
  36.    parse pull filename
  37.    if eof(stdin) then leave
  38.  
  39.    parse value statef(filename) with typ . . . days mins ticks .
  40.    if typ ~= "FILE" then iterate
  41.  
  42.    if ~open(infile, filename, 'R') then iterate
  43.  
  44.    date = 252460800+days*86400+mins*60+ticks/50
  45.  
  46.    name = substr(filename, lastpos(':', filename)+1)
  47.    pos = lastpos('/', name)
  48.    name = translate(left(name, pos-1), '.', '/') || substr(name, pos)
  49.  
  50.    msgid = ""
  51.    xref = ""
  52.    expires = "-"
  53.    do forever
  54.       line = readln(infile)
  55.       if eof(infile) | line == "" then leave
  56.       pos = pos(':', line)
  57.       if pos = 0 then iterate
  58.       field = upper(left(line, pos-1))
  59.       if field = "MESSAGE-ID"
  60.          then msgid = strip(substr(line, pos+1))
  61.       if field = "XREF"
  62.          then xref = strip(substr(line, pos+1))
  63.       if field = "EXPIRES"
  64.          then expires = strip(substr(line, pos+1))
  65.    end
  66.    close(infile)
  67.  
  68.    if xref ~= "" then do
  69.       xref = translate(xref,รก'/', ':')
  70.       parse var xref . first xref
  71.       if first ~= name then iterate
  72.    end
  73.  
  74.    say date ||"~"|| expires ||'09'x|| msgid ||'09'x|| name || xref
  75. end
  76.  
  77. exit 0
  78.