]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/avstring.h
lavu: add LOCAL_ALIGNED_32
[ffmpeg] / libavutil / avstring.h
index acd6610d38fc0998fcfe4f1bab4f92ad50ddc7cd..780f109164506c4db7bfdca49e7b64948ac4f959 100644 (file)
@@ -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);
 
+/**
+ * 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
  * null-terminate dst.
@@ -136,10 +151,35 @@ char *av_d2str(double d);
  */
 char *av_get_token(const char **buf, const char *term);
 
+/**
+ * Locale-independent conversion of ASCII isdigit.
+ */
+static inline av_const int av_isdigit(int c)
+{
+    return c >= '0' && c <= '9';
+}
+
+/**
+ * Locale-independent conversion of ASCII isgraph.
+ */
+static inline av_const int av_isgraph(int c)
+{
+    return c > 32 && c < 127;
+}
+
+/**
+ * Locale-independent conversion of ASCII isspace.
+ */
+static inline av_const int av_isspace(int c)
+{
+    return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' ||
+           c == '\v';
+}
+
 /**
  * Locale-independent conversion of ASCII characters to uppercase.
  */
-static inline int av_toupper(int c)
+static inline av_const int av_toupper(int c)
 {
     if (c >= 'a' && c <= 'z')
         c ^= 0x20;
@@ -149,13 +189,22 @@ static inline int av_toupper(int c)
 /**
  * Locale-independent conversion of ASCII characters to lowercase.
  */
-static inline int av_tolower(int c)
+static inline av_const int av_tolower(int c)
 {
     if (c >= 'A' && c <= 'Z')
         c ^= 0x20;
     return c;
 }
 
+/**
+ * Locale-independent conversion of ASCII isxdigit.
+ */
+static inline av_const int av_isxdigit(int c)
+{
+    c = av_tolower(c);
+    return av_isdigit(c) || (c >= 'a' && c <= 'f');
+}
+
 /*
  * Locale-independent case-insensitive compare.
  * @note This means only ASCII-range characters are case-insensitive
@@ -184,6 +233,15 @@ const char *av_basename(const char *path);
  */
 const char *av_dirname(char *path);
 
+
+/**
+ * Match instances of a name in a comma-separated list of names.
+ * @param name  Name to look for.
+ * @param names List of names.
+ * @return 1 on match, 0 otherwise.
+ */
+int av_match_name(const char *name, const char *names);
+
 /**
  * @}
  */