#include #include #include #include FILE term = 0; void print(const char *s) { fprint(term, s); } void printf(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(term, format, ap); va_end(ap); } void fprint(FILE f, const char *s) { write(f, 0, strlen(s), s); } void fprintf(FILE f, const char* format, ...) { va_list ap; va_start(ap, format); vfprintf(f, format, ap); va_end(ap); } void vfprintf(FILE f, const char *fmt, va_list ap) { va_list ap2; va_copy(ap2, ap); int l = printf_str_len(fmt, ap2); va_end(ap2); char buf[l+1]; l = vsprintf(buf, fmt, ap); if (l > 0) write(f, 0, l, buf); }