FFmpeg  1.2.12
bprint.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Nicolas George
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVUTIL_BPRINT_H
22 #define AVUTIL_BPRINT_H
23 
24 #include "attributes.h"
25 #include "avstring.h"
26 
31 #define FF_PAD_STRUCTURE(size, ...) \
32  __VA_ARGS__ \
33  char reserved_padding[size - sizeof(struct { __VA_ARGS__ })];
34 
75 typedef struct AVBPrint {
76  FF_PAD_STRUCTURE(1024,
77  char *str;
78  unsigned len;
79  unsigned size;
80  unsigned size_max;
81  char reserved_internal_buffer[1];
82  )
83 } AVBPrint;
84 
89 #define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
90 #define AV_BPRINT_SIZE_AUTOMATIC 1
91 #define AV_BPRINT_SIZE_COUNT_ONLY 0
92 
106 void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
107 
117 void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
118 
122 void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
123 
127 void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
128 
129 struct tm;
141 void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
142 
152 void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
153  unsigned char **mem, unsigned *actual_size);
154 
158 void av_bprint_clear(AVBPrint *buf);
159 
166 static inline int av_bprint_is_complete(AVBPrint *buf)
167 {
168  return buf->len < buf->size;
169 }
170 
182 int av_bprint_finalize(AVBPrint *buf, char **ret_str);
183 
197 void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
198  enum AVEscapeMode mode, int flags);
199 
200 #endif /* AVUTIL_BPRINT_H */