diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2011-03-03 13:51:55 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-03-05 02:29:28 +0100 |
commit | 3e1a8e1ec1897086f063667480ec1a0eafd03392 (patch) | |
tree | fb024d7f94429567f0b086a4b1b810308c341821 /libavformat/aviobuf.c | |
parent | a960576f20534589cc911395e71f6ee89255426f (diff) | |
download | ffmpeg-3e1a8e1ec1897086f063667480ec1a0eafd03392.tar.gz |
avio: add avio_get_str()
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit 41d8555f72e3bc60cf93af2a1a4786b452fd2736)
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 3f3721c58b..5b2f9c0fe7 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -705,6 +705,23 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) return i; } +int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) +{ + int i; + + // reserve 1 byte for terminating 0 + buflen = FFMIN(buflen - 1, maxlen); + for (i = 0; i < buflen; i++) + if (!(buf[i] = avio_r8(s))) + return i + 1; + if (buflen) + buf[i] = 0; + for (; i < maxlen; i++) + if (!avio_r8(s)) + return i + 1; + return maxlen; +} + #define GET_STR16(type, read) \ int avio_get_str16 ##type(AVIOContext *pb, int maxlen, char *buf, int buflen)\ {\ |