1 #include <stdio.h> 2 #include <stdarg.h> 3 #include <unistd.h> 4 #include "test.h" 5 6 volatile int t_status = 0; 7 t_printf(const char * s,...)8int t_printf(const char *s, ...) 9 { 10 va_list ap; 11 char buf[512]; 12 int n; 13 14 t_status = 1; 15 va_start(ap, s); 16 n = vsnprintf(buf, sizeof buf, s, ap); 17 va_end(ap); 18 if (n < 0) 19 n = 0; 20 else if (n >= sizeof buf) { 21 n = sizeof buf; 22 buf[n - 1] = '\n'; 23 buf[n - 2] = '.'; 24 buf[n - 3] = '.'; 25 buf[n - 4] = '.'; 26 } 27 return write(1, buf, n); 28 } 29