Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
10 bprintf(const char *fmt
, ...)
16 if ((ret
= vsnprintf(buf
, sizeof(buf
), fmt
, ap
)) < 0) {
17 fprintf(stderr
, "vsnprintf: %s\n", strerror(errno
));
18 } else if ((size_t)ret
>= sizeof(buf
)) {
19 fprintf(stderr
, "vsnprintf: Output truncated\n");
27 pscanf(const char *path
, const char *fmt
, ...)
33 if (!(fp
= fopen(path
, "r"))) {
34 fprintf(stderr
, "fopen '%s': %s\n", path
, strerror(errno
));
38 n
= vfscanf(fp
, fmt
, ap
);
42 return (n
== EOF
) ? -1 : n
;