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 / getaddrfrm.c < prev    next >
C/C++ Source or Header  |  1993-01-12  |  2KB  |  89 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: getaddrfrm.c,v 5.2 1992/11/07 20:05:52 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: getaddrfrm.c,v $
  17.  * Revision 5.2  1992/11/07  20:05:52  syd
  18.  * change to use header_cmp to allow for linear white space around the colon
  19.  * From: Syd
  20.  *
  21.  * Revision 5.1  1992/10/03  22:41:36  syd
  22.  * Initial checkin as of 2.4 Release at PL0
  23.  *
  24.  *
  25.  ******************************************************************************/
  26.  
  27. /** 
  28.  
  29. **/
  30.  
  31. #include "headers.h"
  32. #include <ctype.h>
  33.  
  34. #ifdef USE_EMBEDDED_ADDRESSES
  35.  
  36. get_address_from(line, buffer)
  37. char *line, *buffer;
  38. {
  39.     /** This routine extracts the address from either a 'From:' line
  40.         or a 'Reply-To:' line.  The strategy is as follows:  if the
  41.         line contains a '<', then the stuff enclosed is returned.
  42.         Otherwise we go through the line and strip out comments
  43.         and return that.  White space will be elided from the result.
  44.     **/
  45.  
  46.     register char *s;
  47.     register int l;
  48.  
  49.     /**  Skip start of line over prefix, e.g. "From:".  **/
  50.     if ((s = index(line, ':')) != NULL)
  51.     line = s + 1;
  52.  
  53.     /**  If there is a '<' then copy from it to '>' into the buffer.  **/
  54.     if ( (s = index(line,'<')) != NULL ) {
  55.     s++;
  56.     while (*s != '\0' && *s != '>') {
  57.         l = len_next_part(s);
  58.         if (l == 1) {
  59.           if ( !isspace(*s) )
  60.         *buffer++ = *s;
  61.           s++;
  62.         } else {
  63.           while (--l >= 0)
  64.         *buffer++ = *s++;
  65.         }
  66.     }
  67.     *buffer = '\0';
  68.     return;
  69.     }
  70.  
  71.     /**  Otherwise, strip comments and get address with whitespace elided.  **/
  72.     s = strip_parens(line);
  73.     while (*s != '\0') {
  74.     l = len_next_part(s);
  75.     if (l == 1) {
  76.       if ( !isspace(*s) )
  77.         *buffer++ = *s;
  78.       s++;
  79.     } else {
  80.       while (--l >= 0)
  81.         *buffer++ = *s++;
  82.     }
  83.     }
  84.     *buffer = '\0';
  85.  
  86. }
  87.  
  88. #endif
  89.