fsetpos.c 679 B

123456789101112131415161718192021222324252627282930313233
  1. /* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
  2. *
  3. * GNU Library General Public License (LGPL) version 2 or later.
  4. *
  5. * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
  6. */
  7. #include "_stdio.h"
  8. int fsetpos(FILE *stream, register const fpos_t *pos)
  9. {
  10. #ifdef __STDIO_MBSTATE
  11. int retval = -1;
  12. __STDIO_AUTO_THREADLOCK_VAR;
  13. __STDIO_AUTO_THREADLOCK(stream);
  14. if ((retval = fseek(stream, pos->__pos, SEEK_SET)) == 0) {
  15. __COPY_MBSTATE(&(stream->__state), &(pos->__mbstate));
  16. stream->__ungot_width[0]= pos->__mblen_pending;
  17. }
  18. __STDIO_AUTO_THREADUNLOCK(stream);
  19. return retval;
  20. #else
  21. return fseek(stream, pos->__pos, SEEK_SET);
  22. #endif
  23. }