Don't try to setup and use X11 shared memory if
[tangerine.git] / compiler / clib / read.c
blob759f019c61bd11e3f41dff532809298ae75df295
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C 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 "__errno.h"
14 #include "__stdio.h"
15 #include "__open.h"
17 /*****************************************************************************
19 NAME */
20 #include <unistd.h>
22 ssize_t read (
24 /* SYNOPSIS */
25 int fd,
26 void * buf,
27 size_t count)
29 /* FUNCTION
30 Read an amount of bytes from a file descriptor.
32 INPUTS
33 fd - The file descriptor to read from
34 buf - The buffer to read the bytes into
35 count - Read this many bytes.
37 RESULT
38 The number of characters read (may range from 0 when the file
39 descriptor contains no more characters to count) or -1 on error.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
48 open(), read(), fread()
50 INTERNALS
52 ******************************************************************************/
54 ssize_t cnt;
55 fdesc *fdesc = __getfdesc(fd);
57 if (!fdesc)
59 errno = EBADF;
60 return -1;
63 if(fdesc->fcb->isdir)
65 errno = EISDIR;
66 return -1;
69 cnt = Read ((BPTR)fdesc->fcb->fh, buf, count);
71 if (cnt == -1)
72 errno = IoErr2errno (IoErr ());
74 return cnt;
75 } /* read */