/************************************************************************
      instr(pos, string, target)                                        
            Beginning at offset pos, in string, find target.          
            returns starting position in string of target if found,  
            returns (-1) if not found                                 
            <?> can be used as wild card in target
            This routine is not case sensitive.
************************************************************************/
instr(p, s, t)
char *s, *t;
int p;
{
    int i, j, k, l;
    char up[80];
    register char *a, *b;

    l = strlen(s + p) + p;     /* So we don't wild card beyond EOS */
    strcpy(up, s);
    strupr(up);   /* convert both to upper case for compare */
    strupr(t);

    for (i = p; up[i]; i++) {  /* Loop thru string.  */
        a = &up[i];
        k = 0;  /* Reset target to beginning.  */
        for (j = i, b = &t[k]; *b; a++, b++, j++) {  /* Loop thru target. */
            while ( *b == '?' && j <= l)
                a++, b++;      /* Skip if ? in target. */

            if (*a != *b)      /* Check for char match.  */
                break;         /* Incr thru string if not. */

        }

        if (*b == '\0') /* Reached end of target without a mismatch.*/
            return(i); /* Return offset where match started.  */

    }
    return(-1); /* Reached end of string without a match.  */

}


