home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / lib / figadrssee.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-02  |  2.3 KB  |  78 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: figadrssee.c,v 5.2 1993/02/03 16:25:45 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: figadrssee.c,v $
  17.  * Revision 5.2  1993/02/03  16:25:45  syd
  18.  * Adresses with double quoted strings that contains comma was parsed
  19.  * wrongly by break_down_tolist() and figure_out_addressee().
  20.  * From: Jan Djarv <Jan.Djarv@sa.erisoft.se>
  21.  *
  22.  * Revision 5.1  1992/10/03  22:41:36  syd
  23.  * Initial checkin as of 2.4 Release at PL0
  24.  *
  25.  *
  26.  ******************************************************************************/
  27.  
  28. /** 
  29.  
  30. **/
  31.  
  32. #include "headers.h"
  33.  
  34. figure_out_addressee(buffer, mail_to)
  35. char *buffer;
  36. char *mail_to;
  37. {
  38.     /** This routine steps through all the addresses in the "To:"
  39.         list, initially setting it to the first entry (if mail_to
  40.         is NULL) or, if the user is found (eg "alternatives") to
  41.         the current "username".
  42.     **/
  43.  
  44.     char *address, *bufptr, mybuf[SLEN];
  45.     register int index2 = 0;
  46.     
  47.     if (equal(mail_to, username)) return;    /* can't be better! */
  48.  
  49.     bufptr = (char *) buffer;           /* use the string directly   */
  50.  
  51.     while (whitespace(*bufptr)) bufptr++;
  52.     while ((address = strtokq(bufptr, ",\t\n\r", 1)) != NULL) {
  53.  
  54.       if (! okay_address(address, "don't match me!")) {
  55.         strcpy(mail_to, username);    /* it's to YOU! */
  56.         return;
  57.       }
  58.       else if (strlen(mail_to) == 0) {    /* it's SOMEthing! */
  59.     
  60.         /** this next bit is kinda gory, but allows us to use the
  61.         existing routines to parse the address - by pretending
  62.         it's a From: line and going from there...
  63.         Ah well - you get what you pay for, right?
  64.         **/
  65.  
  66.           if (strlen(address) > (sizeof mybuf) - 7)    /* ensure it ain't */
  67.         address[(sizeof mybuf)-7] = '\0';    /*  too long mon!  */
  68.  
  69.           sprintf(mybuf, "From: %s", address);
  70.           parse_arpa_who(mybuf, mail_to, TRUE);
  71.       }
  72.  
  73.       bufptr = (char *) NULL;    /* set to null */
  74.     }
  75.  
  76.     return;
  77. }
  78.