]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/avstring.h
lavf/utils: dont't explicitly check AVIOContext.error
[ffmpeg] / libavutil / avstring.h
index 954174555c015ab33e51b1bd4d812a83ccaa9f84..04d11973867a16234e2a440717f54be96a01e829 100644 (file)
@@ -29,7 +29,7 @@
  *
  * @param str input string
  * @param pfx prefix to test
- * @param ptr updated after the prefix in str in there is a match
+ * @param ptr updated if the prefix is matched inside str
  * @return non-zero if the prefix matches, zero otherwise
  */
 int av_strstart(const char *str, const char *pfx, const char **ptr);
@@ -41,14 +41,28 @@ int av_strstart(const char *str, const char *pfx, const char **ptr);
  *
  * @param str input string
  * @param pfx prefix to test
- * @param ptr updated after the prefix in str in there is a match
+ * @param ptr updated if the prefix is matched inside str
  * @return non-zero if the prefix matches, zero otherwise
  */
 int av_stristart(const char *str, const char *pfx, const char **ptr);
 
+/**
+ * Locate the first case-independent occurrence in the string haystack
+ * of the string needle.  A zero-length string needle is considered to
+ * match at the start of haystack.
+ *
+ * This function is a case-insensitive version of the standard strstr().
+ *
+ * @param haystack string to search in
+ * @param needle   string to search for
+ * @return         pointer to the located match within haystack
+ *                 or a null pointer if no match
+ */
+char *av_stristr(const char *haystack, const char *needle);
+
 /**
  * Copy the string src to dst, but no more than size - 1 bytes, and
- * null terminate dst.
+ * null-terminate dst.
  *
  * This function is the same as BSD strlcpy().
  *
@@ -56,12 +70,16 @@ int av_stristart(const char *str, const char *pfx, const char **ptr);
  * @param src source string
  * @param size size of destination buffer
  * @return the length of src
+ *
+ * WARNING: since the return value is the length of src, src absolutely
+ * _must_ be a properly 0-terminated string, otherwise this will read beyond
+ * the end of the buffer and possibly crash.
  */
 size_t av_strlcpy(char *dst, const char *src, size_t size);
 
 /**
  * Append the string src to the string dst, but to a total length of
- * no more than size - 1 bytes, and null terminate dst.
+ * no more than size - 1 bytes, and null-terminate dst.
  *
  * This function is similar to BSD strlcat(), but differs when
  * size <= strlen(dst).
@@ -70,12 +88,16 @@ size_t av_strlcpy(char *dst, const char *src, size_t size);
  * @param src source string
  * @param size size of destination buffer
  * @return the total length of src and dst
+ *
+ * WARNING: since the return value use the length of src and dst, these absolutely
+ * _must_ be a properly 0-terminated strings, otherwise this will read beyond
+ * the end of the buffer and possibly crash.
  */
 size_t av_strlcat(char *dst, const char *src, size_t size);
 
 /**
  * Append output to a string, according to a format. Never write out of
- * the destination buffer, and and always put a terminating 0 within
+ * the destination buffer, and always put a terminating 0 within
  * the buffer.
  * @param dst destination buffer (string to which the output is
  *  appended)
@@ -87,4 +109,25 @@ size_t av_strlcat(char *dst, const char *src, size_t size);
  */
 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...);
 
+/**
+ * Convert a number to a av_malloced string.
+ */
+char *av_d2str(double d);
+
+/**
+ * Unescape the given string until a non escaped terminating char,
+ * and return the token corresponding to the unescaped string.
+ *
+ * The normal \ and ' escaping is supported. Leading and trailing
+ * whitespaces are removed, unless they are escaped with '\' or are
+ * enclosed between ''.
+ *
+ * @param buf the buffer to parse, buf will be updated to point to the
+ * terminating char
+ * @param term a 0-terminated list of terminating chars
+ * @return the malloced unescaped string, which must be av_freed by
+ * the user, NULL in case of allocation failure
+ */
+char *av_get_token(const char **buf, const char *term);
+
 #endif /* AVUTIL_AVSTRING_H */