File: printf.c

package info (click to toggle)
squashfs-tools-ng 1.3.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,612 kB
  • sloc: ansic: 26,145; sh: 616; makefile: 53
file content (30 lines) | stat: -rw-r--r-- 486 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
}