home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mr2i160.zip / MAILLIST.CCC < prev    next >
Text File  |  1996-02-26  |  3KB  |  110 lines

  1. /*
  2.     MR/2 ICE - MAILLIST.CMD
  3.  
  4.     Copyright (c) 1996, Nick Knight
  5.     All Rights Reserved.
  6.  
  7.     Author:     Nick Knight
  8.     Created:    02/26/96
  9.     Usage:        maillist addressFile MessageFile
  10.     Purpose:    maillist.cmd will parse message to an automated mailing
  11.                 list and handle adding and removing email addresses
  12.                 from the list via email command.  Subjects should
  13.                 start with either "SUBSCRIBE" or "UNSUBSCRIBE" where
  14.                 case of commands is not important.
  15.  
  16.     US Mail:    Nick Knight, PO Box 22366, Beachwood, Ohio 44122
  17.     Fidonet:    1:157/2 or 1:/157/200
  18.     Internet:    nick@secant.com
  19.     Compuserve: 76066,1240
  20.     BBS:        Private messages on Nerd's Nook (216) 356-1772 or 1872
  21. */
  22.  
  23. '@echo off'
  24. parse arg address_list msg_filename
  25.  
  26. status = stream(msg_filename,'c','open read')
  27.  
  28. replyto = ''
  29. from = ''
  30. tag = ''
  31. subject = ''
  32. value = ''
  33. tmp_lst = 'adr$$_$.$$$'
  34. mode = 0
  35.  
  36. ctr = 0
  37. do while ((ctr < 100) & (lines(msg_filename) > 0))
  38.     iline = linein(msg_filename)
  39.     Parse VALUE iline with tag ': ' value
  40.     Parse UPPER VALUE iline with tag ': '
  41.     say tag
  42.     
  43.     if (tag == 'REPLY-TO') then
  44.         replyto = value
  45.     else if (tag == 'FROM') then
  46.         from = value
  47.     else if (tag == 'SUBJECT') then
  48.         subject = value
  49.     
  50.     ctr = ctr + 1
  51. end
  52.  
  53. status = stream(msg_filename,'c','close')
  54.  
  55. /* for debugging, dump info to screen */
  56. say 'Reply to: '||replyto||', From: '||from
  57.  
  58. if Length(replyto) > 0 then
  59.     from = replyto
  60.     
  61. PARSE UPPER value subject with subject .
  62. if (subject == 'UNSUBSCRIBE') then
  63.     mode = 2
  64. else if (subject == 'SUBSCRIBE') then
  65.     mode = 1
  66.  
  67. say 'Subject: '||subject||' ('||mode||')'
  68.  
  69. if ((Length(replyto) > 0) | (Length(from) > 0)) then do
  70.  
  71.     if (mode == 2) then
  72.         status = stream(tmp_lst,'c','open write')
  73.     
  74.     status = stream(address_list,'c','open read')
  75.     fFound = 0
  76.     do while ((fFound == 0) & (lines(address_list) > 0))
  77.         iline = linein(address_list)
  78.         if (iline == from) then
  79.             fFound = 1
  80.         else if (mode == 2) then
  81.             rc = lineout(tmp_lst,iline)
  82.     end
  83.     status = stream(address_list,'c','close')
  84.     
  85.     if (mode == 2) then do
  86.         status = stream(tmp_lst,'c','close')
  87.         if (fFound <> 0) then do
  88.         
  89.             'copy '||address_list||' '||address_list||'-bak >nul'
  90.             'copy '||tmp_lst||' '||address_list||' >nul'
  91.             'del '||tmp_lst||' >nul'
  92.         end
  93.         else do
  94.             Say 'Error ... not in list!!'
  95.         end
  96.     end
  97.     else if (mode == 1) then do
  98.         if (fFound == 0) then do
  99.             status = stream(address_list,'c','open')
  100.             status = stream(address_list,'c','seek <0')
  101.             rc = lineout(address_list,from)
  102.             status = stream(address_list,'c','close')
  103.         end
  104.         else do
  105.             Say 'Error ... already in list!!'
  106.         end
  107.     end
  108. end
  109.  
  110.