home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / pr2_pmm.zip / pr2_2_pmm.cmd next >
OS/2 REXX Batch file  |  1997-04-13  |  4KB  |  125 lines

  1. /* REXX -- Convert Postroad Mailer messages to PM Mail format */
  2.  
  3. /* Usage: make the PRM messages directory the current directory and 
  4.           run this program. It will find all *.pop files and convert
  5.           them to *.msg files, ready for PM Mail message importing.
  6.           
  7.           It isn't perfect, but it proved to be perfect enough for me.
  8.           If I find more info on the PRM tags I may revisit this.
  9. */
  10.  
  11. /* Example messaage and PRM Decoding matrix (an emperical study)
  12.    To: ibm-netrexx@hursley.ibm.com
  13.    CC: slick.willy@whitehouse.gov
  14.    N/A sent
  15.    N/A C:\PR2\DPETERSO\sent
  16.    Priority: 2Normal
  17.    From:  Dennis Peterson <dpeterso@halcyon.com>
  18.    Reply-To: 1Dennis Peterson <dpeterso@halcyon.com>
  19.    Subject: Java Sort Demo
  20. Message body follows mandatory blank line
  21.  
  22. Does anyone recall this and know where to locate it, and what it might take to convert it to 
  23. the current version of Java? 
  24.  .
  25.  .
  26.  .
  27.  
  28.    N/A 
  29. Regards, 
  30. Dennis Peterson 
  31. dpeterso@halcyon.com
  32. */
  33.  
  34. signal on halt name CLEANUP
  35.  
  36. Do while queued() > 0
  37.    parse pull junk
  38. end
  39.  
  40. crlf     = '0d0a'x
  41. ugly_bit = '05'x
  42. To_bit   = '01'x
  43. CC_bit   = '02'x
  44. From_bit = '0b'x
  45. Subject_bit  = '0f'x
  46. Reply_To_bit = '31'x
  47. Priority_bit = '32'x
  48.  
  49. rc = sysfiletree('*pop','file_list','fo')
  50. do i = 1 to file_list.0
  51.    say file_list.i
  52.    cc_flag = 0
  53.  
  54.    parse value file_list.i with base_name '.' debris
  55.    outfile = base_name || '.msg'
  56.    rc = SysFileTree(outfile,'junk','f')
  57.    if rc = 0 then
  58.       call SysFileDelete(outfile)
  59.    else
  60.       rc = stream(outfile,'C', 'open write')
  61.  
  62. /* for reasons I cannot recall, I used the command line 'cat' command
  63.    to stream the data to rxqueue. If you don't have it you can always
  64.    use the more normal OS/2 type command. I'm a Unix admin -- I use
  65.    cat a lot :-)
  66.    
  67.    I think I had trouble with conventional methods and this is was an easy
  68.    fix.
  69. */
  70.       
  71.    '@cat 'file_list.i'|rxqueue'
  72.  
  73.    Do While queued() > 0
  74.       parse pull current_line
  75.       tag = left(current_line,2)
  76.       current_line = strip(current_line,l,ugly_bit)
  77.       select
  78.          when tag = '0501'x then do /* To:  */
  79.             call lineout outfile, 'To:' strip(current_line,l,to_bit)
  80.          end
  81.          
  82.          when tag = '0502'x then do /* CC:  */
  83.             if cc_flag = 0 then
  84.                call lineout outfile, 'CC:' strip(current_line,l,CC_bit) || ','
  85.             else
  86.                call lineout outfile, '   ' strip(current_line,l,CC_bit) || ','
  87.             cc_flag = 1
  88.          end
  89.          
  90.          when tag = '050b'x then do /* Call From   */
  91.             call lineout outfile, 'From:' strip(current_line,l,From_bit)
  92.          end
  93.          
  94.          when tag = '050f'x then do /* Call Subject */
  95.             call lineout outfile, 'Subject:' strip(current_line,l,Subject_bit) || crlf
  96.          end
  97.          
  98.          when tag = '0531'x then do  /* Call Reply-To */
  99.             call lineout outfile, 'Reply-To:' strip(current_line,l,Reply_To_bit)
  100.          end
  101.          
  102.          when tag = '0532'x then do  /* Call Priority */
  103.             call lineout outfile, 'Priority:' strip(current_line,l,Priority_bit)
  104.          end
  105.  
  106.          when tag = '0535'x then  /* CC: list at end of message */
  107.             do while queued() > 0
  108.                parse pull junk       /* strip it out */
  109.             end
  110.  
  111.          when tag = '' then NOP
  112.          when tag = '' then NOP
  113.          when tag = '' then NOP
  114.          otherwise call lineout outfile, current_line
  115.       end
  116.    end
  117.    rc = stream(outfile,'C', 'close')
  118. end
  119. exit
  120. CLEANUP:
  121. Do while queued() > 0
  122.    parse pull junk
  123. end
  124. exit
  125.