fputws.c 405 B

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