Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.8 KiB

#include "npcommon.h"
// strstrf(str, srch)
//
// Returns a pointer to the first occurrence of srch within
// str (like strchrf, but search parameter is a string, not
// a single character). Returns NULL if not found.
// REVIEW: simple algorithm here, but depending on usage,
// might be overkill to complicate it.
LPSTR WINAPI strstrf(LPCSTR lpString, LPCSTR lpSearch)
{
INT cbSearch = strlenf(lpSearch);
INT cbToSearch;
LPSTR lp;
// calculate the maximum distance to go -- the length
// of the string to look in less the length of the
// string to search for, since beyond that the string
// being searched for would not fit.
cbToSearch = strlenf(lpString) - cbSearch;
if (cbToSearch < 0)
return NULL; /* string being searched is shorter */
for (lp = (LPSTR)lpString; lp - lpString <= cbToSearch; ADVANCE(lp)) {
if (strncmpf(lp, lpSearch, cbSearch) == 0)
return lp;
}
return NULL;
}
// stristrf(str, srch)
//
// Returns a pointer to the first occurrence of srch within
// str, case-insensitive. Returns NULL if not found.
// REVIEW: simple algorithm here, but depending on usage,
// might be overkill to complicate it.
LPSTR WINAPI stristrf(LPCSTR lpString, LPCSTR lpSearch)
{
INT cbSearch = strlenf(lpSearch);
INT cbToSearch;
LPSTR lp;
// calculate the maximum distance to go -- the length
// of the string to look in less the length of the
// string to search for, since beyond that the string
// being searched for would not fit.
cbToSearch = strlenf(lpString) - cbSearch;
if (cbToSearch < 0)
return NULL; /* string being searched is shorter */
for (lp = (LPSTR)lpString; lp - lpString <= cbToSearch; ADVANCE(lp)) {
if (strnicmpf(lp, lpSearch, cbSearch) == 0)
return lp;
}
return NULL;
}