Commit b85a5e87 authored by Vladimir Pantelic's avatar Vladimir Pantelic Committed by Luca Barbato

lavu: Add av_strnstr()

This is a length limited version of strstr()
Signed-off-by: 's avatarVladimir Pantelic <vladoman@gmail.com>
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent a84fb6e0
Entries are sorted chronologically from oldest to youngest within each release, Entries are sorted chronologically from oldest to youngest within each release,
releases are sorted from youngest to oldest. releases are sorted from youngest to oldest.
version 10:
- av_strnstr
version 9: version 9:
- av_basename and av_dirname - av_basename and av_dirname
- adobe and limelight publisher authentication in RTMP - adobe and limelight publisher authentication in RTMP
......
...@@ -13,6 +13,9 @@ libavutil: 2012-10-22 ...@@ -13,6 +13,9 @@ libavutil: 2012-10-22
API changes, most recent first: API changes, most recent first:
2013-01-xx - xxxxxxx - lavu 52.6.0 - avstring.h
Add av_strnstr()
2013-01-xx - xxxxxxx - lavu 52.5.0 - hmac.h 2013-01-xx - xxxxxxx - lavu 52.5.0 - hmac.h
Add AVHMAC. Add AVHMAC.
......
...@@ -65,6 +65,20 @@ char *av_stristr(const char *s1, const char *s2) ...@@ -65,6 +65,20 @@ char *av_stristr(const char *s1, const char *s2)
return NULL; return NULL;
} }
char *av_strnstr(const char *haystack, const char *needle, size_t hay_length)
{
size_t needle_len = strlen(needle);
if (!needle_len)
return haystack;
while (hay_length >= needle_len) {
hay_length--;
if (!memcmp(haystack, needle, needle_len))
return haystack;
haystack++;
}
return NULL;
}
size_t av_strlcpy(char *dst, const char *src, size_t size) size_t av_strlcpy(char *dst, const char *src, size_t size)
{ {
size_t len = 0; size_t len = 0;
......
...@@ -66,6 +66,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr); ...@@ -66,6 +66,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr);
*/ */
char *av_stristr(const char *haystack, const char *needle); char *av_stristr(const char *haystack, const char *needle);
/**
* Locate the first occurrence of the string needle in the string haystack
* where not more than hay_length characters are searched. A zero-length
* string needle is considered to match at the start of haystack.
*
* This function is a length-limited version of the standard strstr().
*
* @param haystack string to search in
* @param needle string to search for
* @param hay_length length of string to search in
* @return pointer to the located match within haystack
* or a null pointer if no match
*/
char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
/** /**
* Copy the string src to dst, but no more than size - 1 bytes, and * Copy the string src to dst, but no more than size - 1 bytes, and
* null-terminate dst. * null-terminate dst.
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
*/ */
#define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 5 #define LIBAVUTIL_VERSION_MINOR 6
#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment