[FFmpeg-devel] [PATCH 2/5] lavu/bprint: add XML escape convenience function
Rodger Combs
rodger.combs at gmail.com
Fri Jul 17 04:04:40 CEST 2015
---
libavutil/bprint.c | 7 +++++++
libavutil/bprint.h | 9 +++++++++
2 files changed, 16 insertions(+)
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index 64d2ab1..746868b 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -334,6 +334,13 @@ void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_cha
}
}
+const char *av_xml_escape_str(AVBPrint *dst, const char *src)
+{
+ av_bprint_clear(dst);
+ av_bprint_escape(dst, src, NULL, AV_ESCAPE_MODE_XML, 0);
+ return dst->str;
+}
+
#ifdef TEST
#undef printf
diff --git a/libavutil/bprint.h b/libavutil/bprint.h
index c09b1ac..006fa8c 100644
--- a/libavutil/bprint.h
+++ b/libavutil/bprint.h
@@ -216,4 +216,13 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str);
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
enum AVEscapeMode mode, int flags);
+/**
+ * Clear the contents of dst, use it to XML-escape a string, and return the result.
+ * This is a convenience function that escapes only the default XML special characters.
+ *
+ * @param dst already inited destination bprint buffer
+ * @param src string containing the text to escape
+ */
+const char *av_xml_escape_str(AVBPrint *dst, const char *src);
+
#endif /* AVUTIL_BPRINT_H */
--
2.4.1
More information about the ffmpeg-devel
mailing list