diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-06-26 22:51:27 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2022-07-08 19:17:35 +0200 |
commit | 359d71e90050a8b83f7bc7d2ecd4ff29c477cc22 (patch) | |
tree | df2b7a585b78e6776446d4ca9be62a22db27f0a7 /lib/io/printf.c | |
parent | 2087cc237cd0fe1ed29ebf891648bacb46f4833b (diff) |
Cleanup: rename libfstream to libio, split headers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/printf.c')
-rw-r--r-- | lib/io/printf.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/io/printf.c b/lib/io/printf.c new file mode 100644 index 0000000..3850487 --- /dev/null +++ b/lib/io/printf.c @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * printf.c + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#include "internal.h" + +int ostream_printf(ostream_t *strm, const char *fmt, ...) +{ + char *temp = NULL; + va_list ap; + int ret; + + va_start(ap, fmt); + + ret = vasprintf(&temp, fmt, ap); + if (ret < 0) + perror(strm->get_filename(strm)); + va_end(ap); + + if (ret < 0) + return -1; + + if (strm->append(strm, temp, ret)) + ret = -1; + + free(temp); + return ret; +} |