home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mlp09.zip / MLP.CMD < prev    next >
OS/2 REXX Batch file  |  1995-07-18  |  3KB  |  85 lines

  1. /* Global filter for MLP 0.9 by Jivko Koltchev                         */
  2. /* =================================================================== */
  3. /* This filter reads all header lines of the mail file and puts them   */
  4. /* in correspondig vars. All characters of the header key words other  */
  5. /* than [0-9,A-Z,a-z] will be translated into underline characters "_" */
  6. /* (Example: content of header line "Message-Id:" will be placed into  */
  7. /* var "Message_Id")                                                   */
  8. /* =================================================================== */
  9. /* Search for "your code" to find where to place your own code.        */
  10. /* =================================================================== */
  11. /* Written by Michael Warmuth (Michael.Warmuth@wu-wien.ac.at)          */
  12.  
  13. /* Load the REXX Utility Functions */
  14. if rxfuncquery('SysLoadFuncs') then do
  15.    call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  16.    call SysLoadFuncs
  17. end  /* Do */
  18.  
  19. /* Get argument */
  20. parse arg mail_file .
  21.  
  22.  
  23.  
  24. /* Put all header lines in corresponding vars */
  25. /* Create translation tables */
  26. chars_not =
  27. xrange('00'x,'2f'x)xrange('3a'x,'40'x)xrange('5b'x,'60'x)xrange('7b'x,'ff'x)
  28. chars_ok  = left('',length(chars_not),'_')
  29.  
  30. /* Quit if file doesn't exist */
  31. if stream(mail_file,'c','query exists')='' then return
  32.  
  33. /* Open mail file */
  34. do while stream(mail_file,'c','open read')\='READY:'
  35.    call SysSleep 1
  36. end /* do */
  37.  
  38. /* Read header */
  39. do until next_line=''
  40.    next_line = strip(linein(mail_file))
  41.    if right(word(next_line,1),1)=':' then do
  42.       parse var next_line keyword ':' content
  43.  
  44.       /* Replace all single quotes in content */
  45.       content2 = ''
  46.       do while pos("'",content)\=0
  47.          parse var content tmp "'" content
  48.          content2 = content2||tmp"''"
  49.       end /* do */
  50.       content = content2 || content
  51.  
  52.       /* Replace all special chars in var name */
  53.       keyword = translate(space(keyword,1),chars_ok,chars_not)
  54.  
  55.       k = keyword "= '"strip(content)"'"
  56.       interpret k
  57.    end  /* Do */
  58. end /* do */
  59. call stream mail_file, 'c', 'close'
  60.  
  61.  
  62.  
  63. /* =================================================================== */
  64. /* Put your code after this comment                                    */
  65. /* =================================================================== */
  66.  
  67. /* Delete file if it is a command and there are illegal characters */
  68. if left(subject,1)='[' & (pos('|',subject)\=0 | pos('&',subject)\=0 |,
  69.       pos('>',subject)\=0 | pos('<',subject)\=0) then
  70.    call SysFileDelete mail_file
  71.  
  72.  
  73. /* Delete file if it is from a MAILER-DAEMON */
  74. if pos('MAILER-DAEMON',from)\=0 then
  75.    call SysFileDelete mail_file
  76.  
  77. /* =================================================================== */
  78. /* Put your code before this comment                                   */
  79. /* =================================================================== */
  80.  
  81.  
  82.  
  83. return
  84.  
  85.