xref: /original-bsd/usr.bin/window/wwprintf.c (revision bac0d407)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 #ifndef lint
14 static char sccsid[] = "@(#)wwprintf.c	3.7 (Berkeley) 02/21/88";
15 #endif /* not lint */
16 
17 #include "ww.h"
18 #include <varargs.h>
19 
20 /*VARARGS2*/
21 wwprintf(w, fmt, va_alist)
22 struct ww *w;
23 char *fmt;
24 va_dcl
25 {
26 #include <stdio.h>
27 	struct _iobuf _wwbuf;
28 	char buf[1024];
29 	va_list ap;
30 
31 	/*
32 	 * A danger is that when buf overflows, _flsbuf() will be
33 	 * called automatically.  It doesn't check for _IOSTR.
34 	 * We set the file descriptor to -1 so no actual io will be done.
35 	 */
36 	_wwbuf._flag = _IOWRT+_IOSTRG;
37 	_wwbuf._base = _wwbuf._ptr = buf;
38 	_wwbuf._cnt = sizeof buf;
39 	_wwbuf._file = -1;			/* safe */
40 	va_start(ap);
41 	_doprnt(fmt, ap, &_wwbuf);
42 	va_end(ap);
43 	(void) wwwrite(w, buf, _wwbuf._ptr - buf);
44 }
45