blob: fef219b20119b402545bd76ef4ec049c9dc8ac5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* ISC license. */
#include <sys/types.h>
#include <string.h>
#include <skalibs/bytestr.h>
size_t str_strn (char const *haystack, size_t hlen, char const *needle, size_t nlen)
{
char haystack2[hlen+1] ;
char needle2[nlen+1] ;
char *p ;
byte_copy(haystack2, hlen, haystack) ; haystack2[hlen] = 0 ;
byte_copy(needle2, nlen, needle) ; needle2[nlen] = 0 ;
p = strstr(haystack2, needle2) ;
return p ? p - haystack2 : hlen ;
}
|