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

  1. static char rcsid[] = "@(#)$Id: header_cmp.c,v 5.2 1992/11/07 20:59:49 syd Exp $";
  2.  
  3. /*******************************************************************************
  4.  *  The Elm Mail System  -  $Revision: 5.2 $   $State: Exp $
  5.  *
  6.  *            Copyright (c) 1988-1992 USENET Community Trust
  7.  *            Copyright (c) 1986,1987 Dave Taylor
  8.  *******************************************************************************
  9.  * Bug reports, patches, comments, suggestions should be sent to:
  10.  *
  11.  *    Syd Weinstein, Elm Coordinator
  12.  *    elm@DSI.COM            dsinc!elm
  13.  *
  14.  *******************************************************************************
  15.  * $Log: header_cmp.c,v $
  16.  * Revision 5.2  1992/11/07  20:59:49  syd
  17.  * fix typo
  18.  *
  19.  * Revision 5.1  1992/11/07  20:16:29  syd
  20.  * Initial Checkin
  21.  *
  22.  *
  23.  ******************************************************************************/
  24.  
  25. /** 
  26.     compare a header, ignoring case and allowing linear white space
  27.     around the :.  Header must be anchored to the start of the line.
  28.  
  29.     returns NULL if no match, or first character after trailing linear
  30.     white space of the :.
  31.  
  32. **/
  33.  
  34. #include "headers.h"
  35. #include <ctype.h>
  36.  
  37. #ifdef BSD
  38. #undef tolower
  39. #endif
  40.  
  41.  
  42. char *
  43. header_cmp(header, prefix, suffix)
  44. register char *header, *prefix, *suffix;
  45. {
  46.     int len;
  47.  
  48.     len = strlen(prefix);
  49.     if (strincmp(header, prefix, len))
  50.         return(NULL);
  51.  
  52.     /* skip over while space if any */
  53.     header += len;
  54.  
  55.     if (*header != ':')    /* headers must end in a : */
  56.         return(NULL);
  57.  
  58.     /* skip over while space if any */
  59.     header++;
  60.  
  61.     while (*header) {
  62.         if (!whitespace(*header))
  63.             break;
  64.         header++;
  65.     }
  66.  
  67.     if (suffix != NULL) {
  68.         len = strlen(suffix);
  69.         if (len > 0)
  70.             if (strincmp(header, suffix, len))
  71.                 return(NULL);
  72.     }
  73.  
  74.     return(header);
  75. }
  76.