_cs_funcs.c 2.0 KB

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