muimaster.library: support Listview_List in List
[AROS.git] / compiler / posixc / read.c
blob02ea055d00c40ef2b785702e87320ebacaadf5f8
1 /*
2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX.1-2008 function read().
6 */
8 #include <errno.h>
9 #include <dos/dos.h>
10 #include <dos/dosextens.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include "__fdesc.h"
15 /*****************************************************************************
17 NAME */
18 #include <unistd.h>
20 ssize_t read (
22 /* SYNOPSIS */
23 int fd,
24 void * buf,
25 size_t count)
27 /* FUNCTION
28 Read an amount of bytes from a file descriptor.
30 INPUTS
31 fd - The file descriptor to read from
32 buf - The buffer to read the bytes into
33 count - Read this many bytes.
35 RESULT
36 The number of characters read (may range from 0 when the file
37 descriptor contains no more characters to count) or -1 on error.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 open(), read(), fread()
48 INTERNALS
50 ******************************************************************************/
52 ssize_t cnt;
53 fdesc *fdesc = __getfdesc(fd);
55 if (!fdesc)
57 errno = EBADF;
58 return -1;
61 if(fdesc->fcb->privflags & _FCB_ISDIR)
63 errno = EISDIR;
64 return -1;
67 cnt = Read (fdesc->fcb->handle, buf, count);
69 if (cnt == -1)
70 errno = __stdc_ioerr2errno (IoErr ());
72 return cnt;
73 } /* read */