src
is a non-null terminated char string whose length is data_len
.
I want to start from the end of this array, and find the first occurrence of html </body>
tag.
find_pos
should hold the position of the </body>
tag with src
Does the code below look correct to you?
char *strrcasestr_len(const char *hay, size_t haylen, const char *ndl,size_t ndllen)
{
char *ret = NULL;
int i;
for (i = haylen - ndllen; i >= 0; i--) {
if (!strncasecmp(&hay[i], ndl, ndllen)) {
break;
}
}
if (i == -1)
return ret;
else
return (char *)&hay[i];
}