1570af302Sopenharmony_ci#include "stdio_impl.h" 2570af302Sopenharmony_ci#include <sys/ioctl.h> 3570af302Sopenharmony_ci 4570af302Sopenharmony_cisize_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) 5570af302Sopenharmony_ci{ 6570af302Sopenharmony_ci struct winsize wsz; 7570af302Sopenharmony_ci f->write = __stdio_write; 8570af302Sopenharmony_ci /* 9570af302Sopenharmony_ci * write directly at first time. 10570af302Sopenharmony_ci * check f->flags & tty, and take effect later. 11570af302Sopenharmony_ci */ 12570af302Sopenharmony_ci size_t cnt = __stdio_write(f, buf, len); 13570af302Sopenharmony_ci 14570af302Sopenharmony_ci if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz)) 15570af302Sopenharmony_ci f->lbf = -1; 16570af302Sopenharmony_ci 17570af302Sopenharmony_ci return cnt; 18570af302Sopenharmony_ci} 19