_cs_funcs.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (C) 2004-2005 Manuel Novoa III <mjn3@codepoet.org>
  2. *
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. *
  5. * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
  6. */
  7. #include "_stdio.h"
  8. #ifdef __UCLIBC_HAS_LFS__
  9. #else
  10. #endif
  11. /**********************************************************************/
  12. #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
  13. /**********************************************************************/
  14. ssize_t attribute_hidden _cs_read(void *cookie, char *buf, size_t bufsize)
  15. {
  16. return read(*((int *) cookie), buf, bufsize);
  17. }
  18. /**********************************************************************/
  19. ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize)
  20. {
  21. return write(*((int *) cookie), (char *) buf, bufsize);
  22. }
  23. /**********************************************************************/
  24. int attribute_hidden _cs_seek(void *cookie, register __offmax_t *pos, int whence)
  25. {
  26. __offmax_t res;
  27. #ifdef __UCLIBC_HAS_LFS__
  28. res = lseek64(*((int *) cookie), *pos, whence);
  29. #else
  30. res = lseek(*((int *) cookie), *pos, whence);
  31. #endif
  32. return (res >= 0) ? ((*pos = res), 0) : ((int) res);
  33. }
  34. /**********************************************************************/
  35. int attribute_hidden _cs_close(void *cookie)
  36. {
  37. return close(*((int *) cookie));
  38. }
  39. /**********************************************************************/
  40. #else
  41. /**********************************************************************/
  42. int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int whence)
  43. {
  44. __offmax_t res;
  45. #ifdef __UCLIBC_HAS_LFS__
  46. res = lseek64(stream->__filedes, *pos, whence);
  47. #else
  48. res = lseek(stream->__filedes, *pos, whence);
  49. #endif
  50. return (res >= 0) ? ((*pos = res), 0) : ((int) res);
  51. }
  52. /**********************************************************************/
  53. #endif
  54. /**********************************************************************/