Category : C Source Code
Archive   : MIKES40C.ZIP
Filename : INSTR.C

 
Output of file : INSTR.C contained in archive : MIKES40C.ZIP
/************************************************************************
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. */

}




  3 Responses to “Category : C Source Code
Archive   : MIKES40C.ZIP
Filename : INSTR.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/