- Wait for mouse acks properly.
[cake.git] / compiler / clib / write.c
blobf97d5c92172b505b8e4daa53003fc4014ab54586
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function write().
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 "__stdio.h"
14 #include "__errno.h"
15 #include "__open.h"
17 /*****************************************************************************
19 NAME */
20 #include <unistd.h>
22 ssize_t write (
24 /* SYNOPSIS */
25 int fd,
26 const void * buf,
27 size_t count)
29 /* FUNCTION
30 Write an amount of characters to the specified file descriptor.
32 INPUTS
33 fd - The file descriptor to write to
34 buf - Write these bytes into the file descriptor
35 count - Write that many bytes
37 RESULT
38 The number of characters written or -1 on error.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
48 INTERNALS
50 ******************************************************************************/
52 ssize_t cnt;
54 fdesc *fdesc = __getfdesc(fd);
55 if (!fdesc)
57 errno = EBADF;
58 return -1;
61 cnt = Write ((BPTR)fdesc->fcb->fh, (void *)buf, count);
63 if (cnt == -1)
64 errno = IoErr2errno (IoErr ());
66 return cnt;
67 } /* write */