fputws.c 368 B

1234567891011121314151617181920212223
  1. #include "stdio_impl.h"
  2. int fputws(const wchar_t *ws, FILE *f)
  3. {
  4. unsigned char buf[BUFSIZ];
  5. size_t l=0;
  6. FLOCK(f);
  7. f->mode |= f->mode+1;
  8. while (ws && (l = wcsrtombs((void *)buf, (void*)&ws, sizeof buf, 0))+1 > 1)
  9. if (__fwritex(buf, l, f) < l) {
  10. FUNLOCK(f);
  11. return -1;
  12. }
  13. FUNLOCK(f);
  14. return l; /* 0 or -1 */
  15. }
  16. weak_alias(fputws, fputws_unlocked);