4.104.114.84.95
Last change
on this file since bde9bb5 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.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * This file contains the support infrastructure used to manage the |
---|
3 | * table of integer style file descriptors used by the socket calls. |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.OARcorp.com/rtems/license.html. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/libio_.h> /* libio_.h pulls in rtems */ |
---|
20 | #include <rtems.h> |
---|
21 | |
---|
22 | #include <errno.h> |
---|
23 | |
---|
24 | /* |
---|
25 | * Convert an RTEMS file descriptor to a BSD socket pointer. |
---|
26 | */ |
---|
27 | |
---|
28 | struct socket *rtems_bsdnet_fdToSocket( |
---|
29 | int fd |
---|
30 | ) |
---|
31 | { |
---|
32 | rtems_libio_t *iop; |
---|
33 | |
---|
34 | if ((unsigned32)fd >= rtems_libio_number_iops) { |
---|
35 | errno = EBADF; |
---|
36 | return NULL; |
---|
37 | } |
---|
38 | iop = &rtems_libio_iops[fd]; |
---|
39 | if (iop->data1 == NULL) |
---|
40 | errno = EBADF; |
---|
41 | return iop->data1; |
---|
42 | } |
---|
43 | |
---|
44 | /* |
---|
45 | * Create an RTEMS file descriptor for a socket |
---|
46 | */ |
---|
47 | |
---|
48 | int rtems_bsdnet_makeFdForSocket( |
---|
49 | void *so, |
---|
50 | const rtems_filesystem_file_handlers_r *h |
---|
51 | ) |
---|
52 | { |
---|
53 | rtems_libio_t *iop; |
---|
54 | int fd; |
---|
55 | |
---|
56 | iop = rtems_libio_allocate(); |
---|
57 | if (iop == 0) { |
---|
58 | errno = ENFILE; |
---|
59 | return -1; |
---|
60 | } |
---|
61 | fd = iop - rtems_libio_iops; |
---|
62 | iop->flags |= LIBIO_FLAGS_WRITE | LIBIO_FLAGS_READ; |
---|
63 | iop->data0 = fd; |
---|
64 | iop->data1 = so; |
---|
65 | iop->handlers = (rtems_filesystem_file_handlers_r *) h; |
---|
66 | return fd; |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.