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