4 #include <syscall-nr.h>
6 /* The standard vprintf() function,
7 which is like printf() but uses a va_list. */
9 vprintf (const char *format, va_list args)
11 return vhprintf (STDOUT_FILENO, format, args);
14 /* Like printf(), but writes output to the given HANDLE. */
16 hprintf (int handle, const char *format, ...)
21 va_start (args, format);
22 retval = vhprintf (handle, format, args);
28 /* Writes string S to the console, followed by a new-line
33 write (STDOUT_FILENO, s, strlen (s));
39 /* Writes C to the console. */
44 write (STDOUT_FILENO, &c2, 1);
48 /* Auxiliary data for vhprintf_helper(). */
51 char buf[64]; /* Character buffer. */
52 char *p; /* Current position in buffer. */
53 int char_cnt; /* Total characters written so far. */
54 int handle; /* Output file handle. */
57 static void add_char (char, void *);
58 static void flush (struct vhprintf_aux *);
60 /* Formats the printf() format specification FORMAT with
61 arguments given in ARGS and writes the output to the given
64 vhprintf (int handle, const char *format, va_list args)
66 struct vhprintf_aux aux;
70 __vprintf (format, args, add_char, &aux);
75 /* Adds C to the buffer in AUX, flushing it if the buffer fills
78 add_char (char c, void *aux_)
80 struct vhprintf_aux *aux = aux_;
82 if (aux->p >= aux->buf + sizeof aux->buf)
87 /* Flushes the buffer in AUX. */
89 flush (struct vhprintf_aux *aux)
91 if (aux->p > aux->buf)
92 write (aux->handle, aux->buf, aux->p - aux->buf);