CCL Home Page
Up Directory CCL find_string
#include "utility.h"

char *find_string(line,string)
/*=========================================================================*/
/* PURPOSE: DETERMINE WHETHER STRING IS CONTAINED IN LINE.
/* INPUTS:
/*	LINE		RAW LINE POSSIBLY CONTAINING STRING.
/*	STRING		STRING TO BE MATCHED.
/* OUTPUTS:
/*	RETURN VALUE	POINTER TO START OF MATCHED STRING, ELSE NULL.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
   char line[];
   char string[];
   {
   char *i;			/* LOOP INDEX TO CHARACTER POSITION. */
   size_t string_length;	/* LENGTH OF STRING. */

   string_length=(size_t)strlen(string);

   /* CHECK EACH I-TH SUBSTRING FOR A MATCH (THIS IS VERY CRUDE). */
   for (i=line; *i!=(char)0; i++)
      {
      /* IF THE STRING MATCHES THE BEGINNING OF THE I-TH SUBSTRING, RETURN */
      /* POINTER TO START OF MATCH. */
      if (strncmp(string,i,string_length)==0) return(i);
      }

   /* HIT END OF LINE WITHOUT FINDING STRING. */
   return(NULL);
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 5177 times since Sat Apr 17 21:58:53 1999 GMT