| 3748 | } |
| 3749 | |
| 3750 | static int fseek(FILE *stream, long offset, int whence) |
| 3751 | { |
| 3752 | switch (whence) |
| 3753 | { |
| 3754 | case SEEK_SET: case SEEK_CUR: case SEEK_END: |
| 3755 | break; |
| 3756 | default: |
| 3757 | errno = EINVAL; |
| 3758 | return -1; |
| 3759 | } |
| 3760 | stdio_lock(stream, -1); |
| 3761 | if (fflush_unlocked(stream) < 0) |
| 3762 | { |
| 3763 | stdio_unlock(stream); |
| 3764 | return -1; |
| 3765 | } |
| 3766 | if (lseek(stream->fd, offset, whence) < 0) |
| 3767 | { |
| 3768 | stdio_unlock(stream); |
| 3769 | return -1; |
| 3770 | } |
| 3771 | stream->flags &= ~STDIO_FLAG_EOF; |
| 3772 | stdio_unlock(stream); |
| 3773 | return 0; |
| 3774 | } |
| 3775 | |
| 3776 | static long ftell(FILE *stream) |
| 3777 | { |