_cs_funcs.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /**********************************************************************/
  9. #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
  10. /**********************************************************************/
  11. ssize_t attribute_hidden _cs_read(void *cookie, char *buf, size_t bufsize)
  12. {
  13. return __read(*((int *) cookie), buf, bufsize);
  14. }
  15. /**********************************************************************/
  16. ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize)
  17. {
  18. return __write(*((int *) cookie), (char *) buf, bufsize);
  19. }
  20. /**********************************************************************/
  21. int attribute_hidden _cs_seek(void *cookie, register __offmax_t *pos, int whence)
  22. {
  23. __offmax_t res;
  24. #ifdef __UCLIBC_HAS_LFS__
  25. res = __lseek64(*((int *) cookie), *pos, whence);
  26. #else
  27. res = __lseek(*((int *) cookie), *pos, whence);
  28. #endif
  29. return (res >= 0) ? ((*pos = res), 0) : ((int) res);
  30. }
  31. /**********************************************************************/
  32. int attribute_hidden _cs_close(void *cookie)
  33. {
  34. return __close(*((int *) cookie));
  35. }
  36. /**********************************************************************/
  37. #else
  38. /**********************************************************************/
  39. int attribute_hidden __stdio_seek(FILE *stream, register __offmax_t *pos, int whence)
  40. {
  41. __offmax_t res;
  42. #ifdef __UCLIBC_HAS_LFS__
  43. res = __lseek64(stream->__filedes, *pos, whence);
  44. #else
  45. res = __lseek(stream->__filedes, *pos, whence);
  46. #endif
  47. return (res >= 0) ? ((*pos = res), 0) : ((int) res);
  48. }
  49. /**********************************************************************/
  50. #endif
  51. /**********************************************************************/