1 #include <newlib.h> 2 3 #ifdef _FVWRITE_IN_STREAMIO 4 5 #include <stdio.h> 6 #include <wchar.h> 7 #include "fvwrite.h" 8 9 /* 10 * Flush out all the vectors defined by the given uio, 11 * then reset it so that it can be reused. 12 */ 13 int __swprint(FILE * fp,register struct __suio * uio)14__swprint ( 15 FILE *fp, 16 register struct __suio *uio) 17 { 18 register int err = 0; 19 struct __siov *iov; 20 wchar_t *p; 21 int i, len; 22 23 if (uio->uio_resid == 0) { 24 uio->uio_iovcnt = 0; 25 return (0); 26 } 27 iov = uio->uio_iov; 28 for (; uio->uio_resid != 0; 29 uio->uio_resid -= len, iov++) { 30 p = (wchar_t *) iov->iov_base; 31 len = iov->iov_len; 32 for (i = 0; i < len; i++) { 33 if (fputwc (p[i], fp) == WEOF) { 34 err = -1; 35 goto out; 36 } 37 } 38 } 39 out: 40 uio->uio_resid = 0; 41 uio->uio_iovcnt = 0; 42 return (err); 43 } 44 45 #endif 46