home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / nn.tar / nn-6.5.1 / contrib / nnsub / Findsub.c < prev    next >
C/C++ Source or Header  |  1995-04-29  |  617b  |  28 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #ifdef SYSV
  4. #define index strchr
  5. #endif
  6.  
  7. char * Findsub(sC,sF)
  8. char *sC, *sF;
  9. /*
  10.     return the start of substring sF in string sC
  11.     or NULL if sC doesn't contain sF
  12.  
  13.     Copyright
  14.     Rudi van Houten, Academic Computer Centre Utrecht
  15.              Budapestlaan 6  3584 CD  Utrecht  Netherlands
  16. */
  17. {
  18.     int iFlen;
  19.     register char *pcC;
  20.     iFlen= strlen(sF);
  21.     if ((pcC= index(sC,sF[0])) == NULL) return(NULL);
  22.     while (strlen(pcC) >= iFlen)
  23.     if (strncmp(pcC,sF,iFlen) == 0) return(pcC);
  24.     else
  25.     if ((pcC= index(++pcC,sF[0])) == NULL) return(NULL);
  26.     return(NULL);
  27. } /* Findsub */
  28.