summaryrefslogtreecommitdiff
path: root/ffmpeg/libavutil/bprint.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavutil/bprint.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavutil/bprint.c')
-rw-r--r--ffmpeg/libavutil/bprint.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/ffmpeg/libavutil/bprint.c b/ffmpeg/libavutil/bprint.c
index fd7611a..7786e3b 100644
--- a/ffmpeg/libavutil/bprint.c
+++ b/ffmpeg/libavutil/bprint.c
@@ -26,6 +26,7 @@
#include "avstring.h"
#include "bprint.h"
#include "common.h"
+#include "compat/va_copy.h"
#include "error.h"
#include "mem.h"
@@ -113,6 +114,29 @@ void av_bprintf(AVBPrint *buf, const char *fmt, ...)
av_bprint_grow(buf, extra_len);
}
+void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
+{
+ unsigned room;
+ char *dst;
+ int extra_len;
+ va_list vl;
+
+ while (1) {
+ room = av_bprint_room(buf);
+ dst = room ? buf->str + buf->len : NULL;
+ va_copy(vl, vl_arg);
+ extra_len = vsnprintf(dst, room, fmt, vl);
+ va_end(vl);
+ if (extra_len <= 0)
+ return;
+ if (extra_len < room)
+ break;
+ if (av_bprint_alloc(buf, extra_len))
+ break;
+ }
+ av_bprint_grow(buf, extra_len);
+}
+
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
{
unsigned room, real_n;
@@ -131,6 +155,24 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
av_bprint_grow(buf, n);
}
+void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
+{
+ unsigned room, real_n;
+
+ while (1) {
+ room = av_bprint_room(buf);
+ if (size < room)
+ break;
+ if (av_bprint_alloc(buf, size))
+ break;
+ }
+ if (room) {
+ real_n = FFMIN(size, room - 1);
+ memcpy(buf->str + buf->len, data, real_n);
+ }
+ av_bprint_grow(buf, size);
+}
+
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
{
unsigned room;