The friendly Operating System for the Internet of Things
fd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 INRIA.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef FD_H
22 #define FD_H
23 #include <stdlib.h>
24 #include <sys/types.h>
25 #include "kernel_types.h"
26 #include "cpu.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 typedef struct {
38 
41 
46  ssize_t (*read)(int fd, void *buf, size_t n);
47 
49  ssize_t (*write)(int fd, const void *buf, size_t n);
50 
52  int (*close)(int fd);
53 } fd_t;
54 
60 int fd_init(void);
61 
72 int fd_new(int internal_fd, ssize_t (*internal_read)(int, void *, size_t),
73  ssize_t (*internal_write)(int, const void *, size_t),
74  int (*internal_close)(int));
75 
85 fd_t *fd_get(int fd);
86 
92 void fd_destroy(int fd);
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /* FD_H */
99 
Types used by the kernel.
int fd_new(int internal_fd, ssize_t(*internal_read)(int, void *, size_t), ssize_t(*internal_write)(int, const void *, size_t), int(*internal_close)(int))
Creates a new file descriptor.
int fd_init(void)
Initializes file descriptors.
void fd_destroy(int fd)
Removes file descriptor table entry associated with fd from table.
fd_t * fd_get(int fd)
Gets the file descriptor table entry associated with file descriptor fd.
int internal_active
private status of this fd_t
Definition: fd.h:37
File descriptor table.
Definition: fd.h:35
stdlib.h wrapper for MSP430
int internal_fd
Stores the RIOT internal value for the file descriptor (not POSIX).
Definition: fd.h:40