char *vstrmake (size_t *lenp, va_list ap) { const char *fmt; fmt = va_arg (ap, const char*); return vstrfmtmake (lenp, fmt, ap); }
void xprintf (const char *fmt, ...) { va_list ap; size_t size; ssize_t written; char *buffer, *head; va_start (ap, fmt); buffer = vstrfmtmake (&size, fmt, ap); head = buffer; va_end (ap); while ((written = write (1, head, size)) != size) { if (written == -1) report (R_FATAL, "Can't write logs: %d", errno); head += written; size -= written; } free (buffer); }
void xprintf (const char *fmt, ...) { va_list ap; size_t size; DWORD written; char *buffer, *head; va_start (ap, fmt); buffer = vstrfmtmake (&size, fmt, ap); head = buffer; va_end (ap); while (size) { if (!WriteFile( logfile, head, size, &written, NULL )) report (R_FATAL, "Can't write logs: %u", GetLastError()); head += written; size -= written; } heap_free (buffer); }