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 / chloc.c < prev    next >
C/C++ Source or Header  |  1992-10-03  |  1KB  |  68 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: chloc.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: chloc.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. int
  30. chloc(string, ch)
  31. char *string;
  32. register char ch;
  33. {
  34.     /** returns the index of ch in string, or -1 if not in string **/
  35.     register char *s;
  36.  
  37.     for (s = string; *s; s++)
  38.         if (*s == ch)
  39.             return(s - string);
  40.     return(-1);
  41. }
  42.  
  43. int
  44. qchloc(string, ch)
  45. char *string;
  46. register char ch;
  47. {
  48.     /* returns the index of ch in string, or -1 if not in string
  49.          * skips over quoted portions of the string
  50.      */
  51.     register char *s;
  52.     register int l;
  53.  
  54.     for (s = string; *s; s++) {
  55.         l = len_next_part(s);
  56.         if (l > 1) { /* a quoted char/string can not be a match */
  57.             s += l - 1;
  58.             continue;
  59.         }
  60.  
  61.         if (*s == ch)
  62.             return(s - string);
  63.     }
  64.  
  65.     return(-1);
  66. }
  67.  
  68.