purge remaining gpl code from clib, and make clib build again
[tangerine.git] / compiler / clib / read.c
blob6b2f571095857def82d4668d3d8b22ffa7968b25
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 cnt = Read ((BPTR)fdesc->fh, buf, count);
65 if (cnt == -1)
66 errno = IoErr2errno (IoErr ());
68 return cnt;
69 } /* read */