Miam-Player  0.8.0
A nice music player
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 <stdarg.h>
25 
26 #include "attributes.h"
27 #include "avstring.h"
28 
34 #define FF_PAD_STRUCTURE(name, size, ...) \
35 struct ff_pad_helper_##name { __VA_ARGS__ }; \
36 typedef struct name { \
37  __VA_ARGS__ \
38  char reserved_padding[size - sizeof(struct ff_pad_helper_##name)]; \
39 } name;
40 
82 FF_PAD_STRUCTURE(AVBPrint, 1024,
83  char *str;
84  unsigned len;
85  unsigned size;
86  unsigned size_max;
87  char reserved_internal_buffer[1];
88 )
89 
94 #define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
95 #define AV_BPRINT_SIZE_AUTOMATIC 1
96 #define AV_BPRINT_SIZE_COUNT_ONLY 0
97 
111 void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
112 
122 void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
123 
127 void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
128 
132 void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg);
133 
137 void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
138 
146 void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size);
147 
148 struct tm;
160 void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
161 
171 void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
172  unsigned char **mem, unsigned *actual_size);
173 
177 void av_bprint_clear(AVBPrint *buf);
178 
185 static inline int av_bprint_is_complete(const AVBPrint *buf)
186 {
187  return buf->len < buf->size;
188 }
189 
201 int av_bprint_finalize(AVBPrint *buf, char **ret_str);
202 
216 void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
217  enum AVEscapeMode mode, int flags);
218 
219 #endif /* AVUTIL_BPRINT_H */
void av_bprint_clear(AVBPrint *buf)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
void void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
size_t size
Definition: mem.h:207
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
void av_bprint_get_buffer(AVBPrint *buf, unsigned size, unsigned char **mem, unsigned *actual_size)
#define AV_BPRINT_SIZE_UNLIMITED
#define av_printf_format(fmtpos, attrpos)
Definition: attributes.h:159
void av_bprintf(AVBPrint *buf, const char *fmt,...) av_printf_format(2
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
#define FF_PAD_STRUCTURE(name, size,...)
Definition: bprint.h:34
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
unsigned unsigned size_max
Definition: bprint.h:111
unsigned size_init
Definition: bprint.h:111
AVEscapeMode
Definition: avstring.h:308