1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2016 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifndef VLC_MEMSTREAM_H
22 # define VLC_MEMSTREAM_H 1
39 int vlc_memstream_open(struct vlc_memstream
*ms
);
42 int vlc_memstream_flush(struct vlc_memstream
*ms
) VLC_USED
;
45 int vlc_memstream_close(struct vlc_memstream
*ms
) VLC_USED
;
48 size_t vlc_memstream_write(struct vlc_memstream
*ms
,
49 const void *ptr
, size_t len
);
52 int vlc_memstream_putc(struct vlc_memstream
*ms
, int c
);
55 int vlc_memstream_puts(struct vlc_memstream
*ms
, const char *str
);
58 int vlc_memstream_vprintf(struct vlc_memstream
*ms
, const char *fmt
,
62 int vlc_memstream_printf(struct vlc_memstream
*s
, const char *fmt
,
66 static inline int vlc_memstream_puts_len(struct vlc_memstream
*ms
,
67 const char *str
, size_t len
)
69 return (vlc_memstream_write(ms
, str
, len
) == len
) ? (int)len
: EOF
;
71 # define vlc_memstream_puts(ms,s) \
72 (__builtin_constant_p(__builtin_strlen(s)) ? \
73 vlc_memstream_puts_len(ms,s,__builtin_strlen(s)) : \
74 vlc_memstream_puts(ms,s))
76 #endif /* VLC_MEMSTREAM_H */