[FFmpeg-cvslog] lavf/aviobuf: add ff_get_chomp_line
Jun Zhao
git at videolan.org
Thu Apr 12 11:10:08 EEST 2018
ffmpeg | branch: master | Jun Zhao <mypopydev at gmail.com> | Mon Apr 9 23:05:42 2018 +0800| [cdd107b96586916508f8665b08be7de54d9633cf] | committer: Jun Zhao
lavf/aviobuf: add ff_get_chomp_line
Same as ff_get_line but strip the white-space characters in the
string tail.
Signed-off-by: Jun Zhao <mypopydev at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cdd107b96586916508f8665b08be7de54d9633cf
---
libavformat/aviobuf.c | 8 ++++++++
libavformat/internal.h | 10 ++++++++++
2 files changed, 18 insertions(+)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 95b3364478..e752d0e1a6 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -823,6 +823,14 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
return i;
}
+int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen)
+{
+ int len = ff_get_line(s, buf, maxlen);
+ while (len > 0 && av_isspace(buf[len - 1]))
+ buf[--len] = '\0';
+ return len;
+}
+
int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp)
{
int len, end;
diff --git a/libavformat/internal.h b/libavformat/internal.h
index c50382ad29..3582682925 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -300,6 +300,16 @@ void ff_put_v(AVIOContext *bc, uint64_t val);
int ff_get_line(AVIOContext *s, char *buf, int maxlen);
/**
+ * Same as ff_get_line but strip the white-space characters in the text tail
+ *
+ * @param s the read-only AVIOContext
+ * @param buf buffer to store the read line
+ * @param maxlen size of the buffer
+ * @return the length of the string written in the buffer
+ */
+int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen);
+
+/**
* Read a whole line of text from AVIOContext to an AVBPrint buffer. Stop
* reading after reaching a \\r, a \\n, a \\r\\n, a \\0 or EOF. The line
* ending characters are NOT included in the buffer, but they are skipped on
More information about the ffmpeg-cvslog
mailing list