Commit cdd107b9 authored by Jun Zhao's avatar Jun Zhao Committed by 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: 's avatarJun Zhao <mypopydev@gmail.com>
parent bc62d20d
...@@ -823,6 +823,14 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) ...@@ -823,6 +823,14 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen)
return i; 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) int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp)
{ {
int len, end; int len, end;
......
...@@ -299,6 +299,16 @@ void ff_put_v(AVIOContext *bc, uint64_t val); ...@@ -299,6 +299,16 @@ void ff_put_v(AVIOContext *bc, uint64_t val);
*/ */
int ff_get_line(AVIOContext *s, char *buf, int maxlen); 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 * 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 * reading after reaching a \\r, a \\n, a \\r\\n, a \\0 or EOF. The line
......
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