/*** STRINDEX.  Returns position of first occurence of string T in
/    string S.  Returns -1 if T is not found.  If either string is
/    null, STRINDEX returns -1. */


#include <stdio.h>
#define  NOT        !

int caseless_strindex (s, t)
   char *s, *t;
{
   char *ps, *pt;
   int  pos;

   if (NOT *t)  return (-1);

   pos = 0;
   while (*s) {
      ps = s;
      pt = t;
      while (((*ps)&0x5f) == ((*pt)&0x5f)  &&  *pt) {
         ++ps;
         ++pt;
      }
      if (NOT *pt)  return (pos);
      ++s;
      ++pos;
   }

   return (-1);
}


