xref: /third_party/musl/libc-test/src/nativehook/print.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/libc-test/src/nativehook/
1570af302Sopenharmony_ci#include <stdio.h>
2570af302Sopenharmony_ci#include <stdarg.h>
3570af302Sopenharmony_ci#include <unistd.h>
4570af302Sopenharmony_ci#include "test.h"
5570af302Sopenharmony_ci
6570af302Sopenharmony_civolatile int t_status = 0;
7570af302Sopenharmony_ci
8570af302Sopenharmony_ciint t_printf(const char *s, ...)
9570af302Sopenharmony_ci{
10570af302Sopenharmony_ci	va_list ap;
11570af302Sopenharmony_ci	char buf[512];
12570af302Sopenharmony_ci	int n;
13570af302Sopenharmony_ci
14570af302Sopenharmony_ci	t_status = 1;
15570af302Sopenharmony_ci	va_start(ap, s);
16570af302Sopenharmony_ci	n = vsnprintf(buf, sizeof buf, s, ap);
17570af302Sopenharmony_ci	va_end(ap);
18570af302Sopenharmony_ci	if (n < 0)
19570af302Sopenharmony_ci		n = 0;
20570af302Sopenharmony_ci	else if (n >= sizeof buf) {
21570af302Sopenharmony_ci		n = sizeof buf;
22570af302Sopenharmony_ci		buf[n - 1] = '\n';
23570af302Sopenharmony_ci		buf[n - 2] = '.';
24570af302Sopenharmony_ci		buf[n - 3] = '.';
25570af302Sopenharmony_ci		buf[n - 4] = '.';
26570af302Sopenharmony_ci	}
27570af302Sopenharmony_ci	return write(1, buf, n);
28570af302Sopenharmony_ci}
29

Indexes created Thu Nov 07 10:32:03 CST 2024