#include <stdio.h>
#include <stdlib.h>

/*

Basically an strstr with a hole in the middle

returns 0 if it matched, -1 if it didn't.

*/

int CompWithGap(char *string, char *fblock, char *lblock, char gapover)
{
int	i=0;
int	k=0;
char	SearchMe[1024];
char	First[1024];
char	Last[1024];

strcpy(SearchMe,string);
strcpy(First,fblock);
strcpy(Last,lblock);

while ( 1 )
   {
   if ( SearchMe[i] == First[k] )
      {
      while ( SearchMe[i] == First[k] )
         k++;
      if ( First[i] == 0 )
         {
         /* The mismatching char was a NULL, we got a match */
         break;
         }
      }
   i++;
   if ( SearchMe[i] == 0 )
      {
      /* Reached the end of string with not match */
      return -1;
      }
   }

/* Seek past gap */
while ( SearchMe[i] != gapover )
   i++;

/* Compare last block */
k=0;
while ( SearchMe[i] == Last[k] )
   {
   k++;
   i++;
   if (( SearchMe[i] == 0 ) && ( Last[k] == 0 ))
      {
      /* Matched Last part */
      return 0;
      }
   }

/* Didn't match */
return -1;

}
