source: rtems/cpukit/libcsupport/src/write.c @ 95083c0

4.104.114.84.95
Last change on this file since 95083c0 was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44

2001-01-08 Ralf Corsepius <corsepiu@…>

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  write() - POSIX 1003.1b 6.4.2 - Write to a File
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.OARcorp.com/rtems/license.html.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/libio_.h>
19
20
21/*
22 * write
23 *
24 * This routine writes count bytes from from buffer pointed to by buffer
25 * to the file associated with the open file descriptor, fildes.
26 */
27
28ssize_t write(
29  int         fd,
30  const void *buffer,
31  size_t      count
32)
33{
34  rtems_status_code  rc;
35  rtems_libio_t     *iop;
36
37  rtems_libio_check_fd( fd );
38  iop = rtems_libio_iop( fd );
39  rtems_libio_check_is_open(iop);
40  rtems_libio_check_buffer( buffer );
41  rtems_libio_check_count( count );
42  rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
43
44  /*
45   *  Now process the write() request.
46   */
47
48  if ( !iop->handlers->write_h )
49    set_errno_and_return_minus_one( ENOTSUP );
50
51  rc = (*iop->handlers->write_h)( iop, buffer, count );
52
53  if ( rc > 0 )
54    iop->offset += rc;
55
56  return rc;
57}
58
59/*
60 *  _write_r
61 *
62 *  This is the Newlib dependent reentrant version of write().
63 */
64
65#if defined(RTEMS_NEWLIB)
66
67#include <reent.h>
68
69long _write_r(
70  struct _reent *ptr,
71  int            fd,
72  const void    *buf,
73  size_t         nbytes
74)
75{
76  return write( fd, buf, nbytes );
77}
78#endif
Note: See TracBrowser for help on using the repository browser.