home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / elm-2.4-pl20.tar.Z / elm-2.4-pl20.tar / lib / figadrssee.c < prev    next >
C/C++ Source or Header  |  1992-10-03  |  2KB  |  72 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: figadrssee.c,v 5.1 1992/10/03 22:41:36 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.1 $   $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.1  1992/10/03  22:41:36  syd
  18.  * Initial checkin as of 2.4 Release at PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** 
  24.  
  25. **/
  26.  
  27. #include "headers.h"
  28.  
  29. figure_out_addressee(buffer, mail_to)
  30. char *buffer;
  31. char *mail_to;
  32. {
  33.     /** This routine steps through all the addresses in the "To:"
  34.         list, initially setting it to the first entry (if mail_to
  35.         is NULL) or, if the user is found (eg "alternatives") to
  36.         the current "username".
  37.     **/
  38.  
  39.     char *address, *bufptr, mybuf[SLEN];
  40.     register int index2 = 0;
  41.     
  42.     if (equal(mail_to, username)) return;    /* can't be better! */
  43.  
  44.     bufptr = (char *) buffer;           /* use the string directly   */
  45.  
  46.     while ((address = strtok(bufptr, ",\t\n\r")) != NULL) {
  47.  
  48.       if (! okay_address(address, "don't match me!")) {
  49.         strcpy(mail_to, username);    /* it's to YOU! */
  50.         return;
  51.       }
  52.       else if (strlen(mail_to) == 0) {    /* it's SOMEthing! */
  53.     
  54.         /** this next bit is kinda gory, but allows us to use the
  55.         existing routines to parse the address - by pretending
  56.         it's a From: line and going from there...
  57.         Ah well - you get what you pay for, right?
  58.         **/
  59.  
  60.           if (strlen(address) > (sizeof mybuf) - 7)    /* ensure it ain't */
  61.         address[(sizeof mybuf)-7] = '\0';    /*  too long mon!  */
  62.  
  63.           sprintf(mybuf, "From: %s", address);
  64.           parse_arpa_who(mybuf, mail_to, TRUE);
  65.       }
  66.  
  67.       bufptr = (char *) NULL;    /* set to null */
  68.     }
  69.  
  70.     return;
  71. }
  72.