BA
/
BaBoRo_test2
Backup 1
mbed-os/platform/mbed_retarget.h@0:02dd72d1d465, 2018-04-24 (annotated)
- Committer:
- borlanic
- Date:
- Tue Apr 24 11:45:18 2018 +0000
- Revision:
- 0:02dd72d1d465
BaBoRo_test2 - backup 1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
borlanic | 0:02dd72d1d465 | 1 | /* |
borlanic | 0:02dd72d1d465 | 2 | * mbed Microcontroller Library |
borlanic | 0:02dd72d1d465 | 3 | * Copyright (c) 2006-2016 ARM Limited |
borlanic | 0:02dd72d1d465 | 4 | * |
borlanic | 0:02dd72d1d465 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
borlanic | 0:02dd72d1d465 | 6 | * you may not use this file except in compliance with the License. |
borlanic | 0:02dd72d1d465 | 7 | * You may obtain a copy of the License at |
borlanic | 0:02dd72d1d465 | 8 | * |
borlanic | 0:02dd72d1d465 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
borlanic | 0:02dd72d1d465 | 10 | * |
borlanic | 0:02dd72d1d465 | 11 | * Unless required by applicable law or agreed to in writing, software |
borlanic | 0:02dd72d1d465 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
borlanic | 0:02dd72d1d465 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
borlanic | 0:02dd72d1d465 | 14 | * See the License for the specific language governing permissions and |
borlanic | 0:02dd72d1d465 | 15 | * limitations under the License. |
borlanic | 0:02dd72d1d465 | 16 | * |
borlanic | 0:02dd72d1d465 | 17 | */ |
borlanic | 0:02dd72d1d465 | 18 | |
borlanic | 0:02dd72d1d465 | 19 | #ifndef RETARGET_H |
borlanic | 0:02dd72d1d465 | 20 | #define RETARGET_H |
borlanic | 0:02dd72d1d465 | 21 | |
borlanic | 0:02dd72d1d465 | 22 | #if __cplusplus |
borlanic | 0:02dd72d1d465 | 23 | #include <cstdio> |
borlanic | 0:02dd72d1d465 | 24 | #else |
borlanic | 0:02dd72d1d465 | 25 | #include <stdio.h> |
borlanic | 0:02dd72d1d465 | 26 | #endif //__cplusplus |
borlanic | 0:02dd72d1d465 | 27 | #include <stdint.h> |
borlanic | 0:02dd72d1d465 | 28 | #include <stddef.h> |
borlanic | 0:02dd72d1d465 | 29 | |
borlanic | 0:02dd72d1d465 | 30 | /* We can get the following standard types from sys/types for gcc, but we |
borlanic | 0:02dd72d1d465 | 31 | * need to define the types ourselves for the other compilers that normally |
borlanic | 0:02dd72d1d465 | 32 | * target embedded systems */ |
borlanic | 0:02dd72d1d465 | 33 | typedef signed int ssize_t; ///< Signed size type, usually encodes negative errors |
borlanic | 0:02dd72d1d465 | 34 | typedef signed long off_t; ///< Offset in a data stream |
borlanic | 0:02dd72d1d465 | 35 | typedef unsigned int nfds_t; ///< Number of file descriptors |
borlanic | 0:02dd72d1d465 | 36 | typedef unsigned long long fsblkcnt_t; ///< Count of file system blocks |
borlanic | 0:02dd72d1d465 | 37 | #if defined(__ARMCC_VERSION) || !defined(__GNUC__) |
borlanic | 0:02dd72d1d465 | 38 | typedef unsigned int mode_t; ///< Mode for opening files |
borlanic | 0:02dd72d1d465 | 39 | typedef unsigned int dev_t; ///< Device ID type |
borlanic | 0:02dd72d1d465 | 40 | typedef unsigned long ino_t; ///< File serial number |
borlanic | 0:02dd72d1d465 | 41 | typedef unsigned int nlink_t; ///< Number of links to a file |
borlanic | 0:02dd72d1d465 | 42 | typedef unsigned int uid_t; ///< User ID |
borlanic | 0:02dd72d1d465 | 43 | typedef unsigned int gid_t; ///< Group ID |
borlanic | 0:02dd72d1d465 | 44 | #endif |
borlanic | 0:02dd72d1d465 | 45 | |
borlanic | 0:02dd72d1d465 | 46 | #define O_RDONLY 0 ///< Open for reading |
borlanic | 0:02dd72d1d465 | 47 | #define O_WRONLY 1 ///< Open for writing |
borlanic | 0:02dd72d1d465 | 48 | #define O_RDWR 2 ///< Open for reading and writing |
borlanic | 0:02dd72d1d465 | 49 | #define O_CREAT 0x0200 ///< Create file if it does not exist |
borlanic | 0:02dd72d1d465 | 50 | #define O_TRUNC 0x0400 ///< Truncate file to zero length |
borlanic | 0:02dd72d1d465 | 51 | #define O_EXCL 0x0800 ///< Fail if file exists |
borlanic | 0:02dd72d1d465 | 52 | #define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write |
borlanic | 0:02dd72d1d465 | 53 | #define O_BINARY 0x8000 ///< Open file in binary mode |
borlanic | 0:02dd72d1d465 | 54 | |
borlanic | 0:02dd72d1d465 | 55 | #define NAME_MAX 255 ///< Maximum size of a name in a file path |
borlanic | 0:02dd72d1d465 | 56 | |
borlanic | 0:02dd72d1d465 | 57 | #define STDIN_FILENO 0 |
borlanic | 0:02dd72d1d465 | 58 | #define STDOUT_FILENO 1 |
borlanic | 0:02dd72d1d465 | 59 | #define STDERR_FILENO 2 |
borlanic | 0:02dd72d1d465 | 60 | |
borlanic | 0:02dd72d1d465 | 61 | #include <time.h> |
borlanic | 0:02dd72d1d465 | 62 | |
borlanic | 0:02dd72d1d465 | 63 | /** \addtogroup platform */ |
borlanic | 0:02dd72d1d465 | 64 | /** @{*/ |
borlanic | 0:02dd72d1d465 | 65 | /** |
borlanic | 0:02dd72d1d465 | 66 | * \defgroup platform_retarget Retarget functions |
borlanic | 0:02dd72d1d465 | 67 | * @{ |
borlanic | 0:02dd72d1d465 | 68 | */ |
borlanic | 0:02dd72d1d465 | 69 | |
borlanic | 0:02dd72d1d465 | 70 | /* DIR declarations must also be here */ |
borlanic | 0:02dd72d1d465 | 71 | #if __cplusplus |
borlanic | 0:02dd72d1d465 | 72 | namespace mbed { |
borlanic | 0:02dd72d1d465 | 73 | |
borlanic | 0:02dd72d1d465 | 74 | class FileHandle; |
borlanic | 0:02dd72d1d465 | 75 | class DirHandle; |
borlanic | 0:02dd72d1d465 | 76 | |
borlanic | 0:02dd72d1d465 | 77 | /** Targets may implement this to change stdin, stdout, stderr. |
borlanic | 0:02dd72d1d465 | 78 | * |
borlanic | 0:02dd72d1d465 | 79 | * If the application hasn't provided mbed_override_console, this is called |
borlanic | 0:02dd72d1d465 | 80 | * to give the target a chance to specify a FileHandle for the console. |
borlanic | 0:02dd72d1d465 | 81 | * |
borlanic | 0:02dd72d1d465 | 82 | * If this is not provided or returns NULL, the console will be: |
borlanic | 0:02dd72d1d465 | 83 | * - UARTSerial if configuration option "platform.stdio-buffered-serial" is |
borlanic | 0:02dd72d1d465 | 84 | * true and the target has DEVICE_SERIAL; |
borlanic | 0:02dd72d1d465 | 85 | * - Raw HAL serial via serial_getc and serial_putc if |
borlanic | 0:02dd72d1d465 | 86 | * "platform.stdio-buffered-serial" is false and the target has DEVICE_SERIAL; |
borlanic | 0:02dd72d1d465 | 87 | * - stdout/stderr will be a sink and stdin will input a stream of 0s if the |
borlanic | 0:02dd72d1d465 | 88 | * target does not have DEVICE_SERIAL. |
borlanic | 0:02dd72d1d465 | 89 | * |
borlanic | 0:02dd72d1d465 | 90 | * @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO |
borlanic | 0:02dd72d1d465 | 91 | * @return pointer to FileHandle to override normal stream otherwise NULL |
borlanic | 0:02dd72d1d465 | 92 | */ |
borlanic | 0:02dd72d1d465 | 93 | FileHandle* mbed_target_override_console(int fd); |
borlanic | 0:02dd72d1d465 | 94 | |
borlanic | 0:02dd72d1d465 | 95 | /** Applications may implement this to change stdin, stdout, stderr. |
borlanic | 0:02dd72d1d465 | 96 | * |
borlanic | 0:02dd72d1d465 | 97 | * This hook gives the application a chance to specify a custom FileHandle |
borlanic | 0:02dd72d1d465 | 98 | * for the console. |
borlanic | 0:02dd72d1d465 | 99 | * |
borlanic | 0:02dd72d1d465 | 100 | * If this is not provided or returns NULL, the console will be specified |
borlanic | 0:02dd72d1d465 | 101 | * by mbed_target_override_console, else will default to serial - see |
borlanic | 0:02dd72d1d465 | 102 | * mbed_target_override_console for more details. |
borlanic | 0:02dd72d1d465 | 103 | * |
borlanic | 0:02dd72d1d465 | 104 | * Example: |
borlanic | 0:02dd72d1d465 | 105 | * @code |
borlanic | 0:02dd72d1d465 | 106 | * FileHandle* mbed::mbed_override_console(int) { |
borlanic | 0:02dd72d1d465 | 107 | * static UARTSerial my_serial(D0, D1); |
borlanic | 0:02dd72d1d465 | 108 | * return &my_serial; |
borlanic | 0:02dd72d1d465 | 109 | * } |
borlanic | 0:02dd72d1d465 | 110 | * @endcode |
borlanic | 0:02dd72d1d465 | 111 | |
borlanic | 0:02dd72d1d465 | 112 | * @param fd file descriptor - STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO |
borlanic | 0:02dd72d1d465 | 113 | * @return pointer to FileHandle to override normal stream otherwise NULL |
borlanic | 0:02dd72d1d465 | 114 | */ |
borlanic | 0:02dd72d1d465 | 115 | FileHandle* mbed_override_console(int fd); |
borlanic | 0:02dd72d1d465 | 116 | |
borlanic | 0:02dd72d1d465 | 117 | } |
borlanic | 0:02dd72d1d465 | 118 | |
borlanic | 0:02dd72d1d465 | 119 | typedef mbed::DirHandle DIR; |
borlanic | 0:02dd72d1d465 | 120 | #else |
borlanic | 0:02dd72d1d465 | 121 | typedef struct Dir DIR; |
borlanic | 0:02dd72d1d465 | 122 | #endif |
borlanic | 0:02dd72d1d465 | 123 | |
borlanic | 0:02dd72d1d465 | 124 | /* The intent of this section is to unify the errno error values to match |
borlanic | 0:02dd72d1d465 | 125 | * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is |
borlanic | 0:02dd72d1d465 | 126 | * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some |
borlanic | 0:02dd72d1d465 | 127 | * symbol definitions used by the POSIX filesystem API to return errno codes. |
borlanic | 0:02dd72d1d465 | 128 | * Note also that ARMCC errno.h defines some symbol values differently from |
borlanic | 0:02dd72d1d465 | 129 | * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against |
borlanic | 0:02dd72d1d465 | 130 | * this and future changes by changing the symbol definition as shown below. |
borlanic | 0:02dd72d1d465 | 131 | */ |
borlanic | 0:02dd72d1d465 | 132 | #undef EPERM |
borlanic | 0:02dd72d1d465 | 133 | #define EPERM 1 /* Operation not permitted */ |
borlanic | 0:02dd72d1d465 | 134 | #undef ENOENT |
borlanic | 0:02dd72d1d465 | 135 | #define ENOENT 2 /* No such file or directory */ |
borlanic | 0:02dd72d1d465 | 136 | #undef ESRCH |
borlanic | 0:02dd72d1d465 | 137 | #define ESRCH 3 /* No such process */ |
borlanic | 0:02dd72d1d465 | 138 | #undef EINTR |
borlanic | 0:02dd72d1d465 | 139 | #define EINTR 4 /* Interrupted system call */ |
borlanic | 0:02dd72d1d465 | 140 | #undef EIO |
borlanic | 0:02dd72d1d465 | 141 | #define EIO 5 /* I/O error */ |
borlanic | 0:02dd72d1d465 | 142 | #undef ENXIO |
borlanic | 0:02dd72d1d465 | 143 | #define ENXIO 6 /* No such device or address */ |
borlanic | 0:02dd72d1d465 | 144 | #undef E2BIG |
borlanic | 0:02dd72d1d465 | 145 | #define E2BIG 7 /* Argument list too long */ |
borlanic | 0:02dd72d1d465 | 146 | #undef ENOEXEC |
borlanic | 0:02dd72d1d465 | 147 | #define ENOEXEC 8 /* Exec format error */ |
borlanic | 0:02dd72d1d465 | 148 | #undef EBADF |
borlanic | 0:02dd72d1d465 | 149 | #define EBADF 9 /* Bad file number */ |
borlanic | 0:02dd72d1d465 | 150 | #undef ECHILD |
borlanic | 0:02dd72d1d465 | 151 | #define ECHILD 10 /* No child processes */ |
borlanic | 0:02dd72d1d465 | 152 | #undef EAGAIN |
borlanic | 0:02dd72d1d465 | 153 | #define EAGAIN 11 /* Try again */ |
borlanic | 0:02dd72d1d465 | 154 | #undef ENOMEM |
borlanic | 0:02dd72d1d465 | 155 | #define ENOMEM 12 /* Out of memory */ |
borlanic | 0:02dd72d1d465 | 156 | #undef EACCES |
borlanic | 0:02dd72d1d465 | 157 | #define EACCES 13 /* Permission denied */ |
borlanic | 0:02dd72d1d465 | 158 | #undef EFAULT |
borlanic | 0:02dd72d1d465 | 159 | #define EFAULT 14 /* Bad address */ |
borlanic | 0:02dd72d1d465 | 160 | #undef ENOTBLK |
borlanic | 0:02dd72d1d465 | 161 | #define ENOTBLK 15 /* Block device required */ |
borlanic | 0:02dd72d1d465 | 162 | #undef EBUSY |
borlanic | 0:02dd72d1d465 | 163 | #define EBUSY 16 /* Device or resource busy */ |
borlanic | 0:02dd72d1d465 | 164 | #undef EEXIST |
borlanic | 0:02dd72d1d465 | 165 | #define EEXIST 17 /* File exists */ |
borlanic | 0:02dd72d1d465 | 166 | #undef EXDEV |
borlanic | 0:02dd72d1d465 | 167 | #define EXDEV 18 /* Cross-device link */ |
borlanic | 0:02dd72d1d465 | 168 | #undef ENODEV |
borlanic | 0:02dd72d1d465 | 169 | #define ENODEV 19 /* No such device */ |
borlanic | 0:02dd72d1d465 | 170 | #undef ENOTDIR |
borlanic | 0:02dd72d1d465 | 171 | #define ENOTDIR 20 /* Not a directory */ |
borlanic | 0:02dd72d1d465 | 172 | #undef EISDIR |
borlanic | 0:02dd72d1d465 | 173 | #define EISDIR 21 /* Is a directory */ |
borlanic | 0:02dd72d1d465 | 174 | #undef EINVAL |
borlanic | 0:02dd72d1d465 | 175 | #define EINVAL 22 /* Invalid argument */ |
borlanic | 0:02dd72d1d465 | 176 | #undef ENFILE |
borlanic | 0:02dd72d1d465 | 177 | #define ENFILE 23 /* File table overflow */ |
borlanic | 0:02dd72d1d465 | 178 | #undef EMFILE |
borlanic | 0:02dd72d1d465 | 179 | #define EMFILE 24 /* Too many open files */ |
borlanic | 0:02dd72d1d465 | 180 | #undef ENOTTY |
borlanic | 0:02dd72d1d465 | 181 | #define ENOTTY 25 /* Not a typewriter */ |
borlanic | 0:02dd72d1d465 | 182 | #undef ETXTBSY |
borlanic | 0:02dd72d1d465 | 183 | #define ETXTBSY 26 /* Text file busy */ |
borlanic | 0:02dd72d1d465 | 184 | #undef EFBIG |
borlanic | 0:02dd72d1d465 | 185 | #define EFBIG 27 /* File too large */ |
borlanic | 0:02dd72d1d465 | 186 | #undef ENOSPC |
borlanic | 0:02dd72d1d465 | 187 | #define ENOSPC 28 /* No space left on device */ |
borlanic | 0:02dd72d1d465 | 188 | #undef ESPIPE |
borlanic | 0:02dd72d1d465 | 189 | #define ESPIPE 29 /* Illegal seek */ |
borlanic | 0:02dd72d1d465 | 190 | #undef EROFS |
borlanic | 0:02dd72d1d465 | 191 | #define EROFS 30 /* Read-only file system */ |
borlanic | 0:02dd72d1d465 | 192 | #undef EMLINK |
borlanic | 0:02dd72d1d465 | 193 | #define EMLINK 31 /* Too many links */ |
borlanic | 0:02dd72d1d465 | 194 | #undef EPIPE |
borlanic | 0:02dd72d1d465 | 195 | #define EPIPE 32 /* Broken pipe */ |
borlanic | 0:02dd72d1d465 | 196 | #undef EDOM |
borlanic | 0:02dd72d1d465 | 197 | #define EDOM 33 /* Math argument out of domain of func */ |
borlanic | 0:02dd72d1d465 | 198 | #undef ERANGE |
borlanic | 0:02dd72d1d465 | 199 | #define ERANGE 34 /* Math result not representable */ |
borlanic | 0:02dd72d1d465 | 200 | #undef EDEADLK |
borlanic | 0:02dd72d1d465 | 201 | #define EDEADLK 35 /* Resource deadlock would occur */ |
borlanic | 0:02dd72d1d465 | 202 | #undef ENAMETOOLONG |
borlanic | 0:02dd72d1d465 | 203 | #define ENAMETOOLONG 36 /* File name too long */ |
borlanic | 0:02dd72d1d465 | 204 | #undef ENOLCK |
borlanic | 0:02dd72d1d465 | 205 | #define ENOLCK 37 /* No record locks available */ |
borlanic | 0:02dd72d1d465 | 206 | #undef ENOSYS |
borlanic | 0:02dd72d1d465 | 207 | #define ENOSYS 38 /* Function not implemented */ |
borlanic | 0:02dd72d1d465 | 208 | #undef ENOTEMPTY |
borlanic | 0:02dd72d1d465 | 209 | #define ENOTEMPTY 39 /* Directory not empty */ |
borlanic | 0:02dd72d1d465 | 210 | #undef ELOOP |
borlanic | 0:02dd72d1d465 | 211 | #define ELOOP 40 /* Too many symbolic links encountered */ |
borlanic | 0:02dd72d1d465 | 212 | #undef EWOULDBLOCK |
borlanic | 0:02dd72d1d465 | 213 | #define EWOULDBLOCK EAGAIN /* Operation would block */ |
borlanic | 0:02dd72d1d465 | 214 | #undef ENOMSG |
borlanic | 0:02dd72d1d465 | 215 | #define ENOMSG 42 /* No message of desired type */ |
borlanic | 0:02dd72d1d465 | 216 | #undef EIDRM |
borlanic | 0:02dd72d1d465 | 217 | #define EIDRM 43 /* Identifier removed */ |
borlanic | 0:02dd72d1d465 | 218 | #undef ECHRNG |
borlanic | 0:02dd72d1d465 | 219 | #define ECHRNG 44 /* Channel number out of range */ |
borlanic | 0:02dd72d1d465 | 220 | #undef EL2NSYNC |
borlanic | 0:02dd72d1d465 | 221 | #define EL2NSYNC 45 /* Level 2 not synchronized */ |
borlanic | 0:02dd72d1d465 | 222 | #undef EL3HLT |
borlanic | 0:02dd72d1d465 | 223 | #define EL3HLT 46 /* Level 3 halted */ |
borlanic | 0:02dd72d1d465 | 224 | #undef EL3RST |
borlanic | 0:02dd72d1d465 | 225 | #define EL3RST 47 /* Level 3 reset */ |
borlanic | 0:02dd72d1d465 | 226 | #undef ELNRNG |
borlanic | 0:02dd72d1d465 | 227 | #define ELNRNG 48 /* Link number out of range */ |
borlanic | 0:02dd72d1d465 | 228 | #undef EUNATCH |
borlanic | 0:02dd72d1d465 | 229 | #define EUNATCH 49 /* Protocol driver not attached */ |
borlanic | 0:02dd72d1d465 | 230 | #undef ENOCSI |
borlanic | 0:02dd72d1d465 | 231 | #define ENOCSI 50 /* No CSI structure available */ |
borlanic | 0:02dd72d1d465 | 232 | #undef EL2HLT |
borlanic | 0:02dd72d1d465 | 233 | #define EL2HLT 51 /* Level 2 halted */ |
borlanic | 0:02dd72d1d465 | 234 | #undef EBADE |
borlanic | 0:02dd72d1d465 | 235 | #define EBADE 52 /* Invalid exchange */ |
borlanic | 0:02dd72d1d465 | 236 | #undef EBADR |
borlanic | 0:02dd72d1d465 | 237 | #define EBADR 53 /* Invalid request descriptor */ |
borlanic | 0:02dd72d1d465 | 238 | #undef EXFULL |
borlanic | 0:02dd72d1d465 | 239 | #define EXFULL 54 /* Exchange full */ |
borlanic | 0:02dd72d1d465 | 240 | #undef ENOANO |
borlanic | 0:02dd72d1d465 | 241 | #define ENOANO 55 /* No anode */ |
borlanic | 0:02dd72d1d465 | 242 | #undef EBADRQC |
borlanic | 0:02dd72d1d465 | 243 | #define EBADRQC 56 /* Invalid request code */ |
borlanic | 0:02dd72d1d465 | 244 | #undef EBADSLT |
borlanic | 0:02dd72d1d465 | 245 | #define EBADSLT 57 /* Invalid slot */ |
borlanic | 0:02dd72d1d465 | 246 | #undef EDEADLOCK |
borlanic | 0:02dd72d1d465 | 247 | #define EDEADLOCK EDEADLK /* Resource deadlock would occur */ |
borlanic | 0:02dd72d1d465 | 248 | #undef EBFONT |
borlanic | 0:02dd72d1d465 | 249 | #define EBFONT 59 /* Bad font file format */ |
borlanic | 0:02dd72d1d465 | 250 | #undef ENOSTR |
borlanic | 0:02dd72d1d465 | 251 | #define ENOSTR 60 /* Device not a stream */ |
borlanic | 0:02dd72d1d465 | 252 | #undef ENODATA |
borlanic | 0:02dd72d1d465 | 253 | #define ENODATA 61 /* No data available */ |
borlanic | 0:02dd72d1d465 | 254 | #undef ETIME |
borlanic | 0:02dd72d1d465 | 255 | #define ETIME 62 /* Timer expired */ |
borlanic | 0:02dd72d1d465 | 256 | #undef ENOSR |
borlanic | 0:02dd72d1d465 | 257 | #define ENOSR 63 /* Out of streams resources */ |
borlanic | 0:02dd72d1d465 | 258 | #undef ENONET |
borlanic | 0:02dd72d1d465 | 259 | #define ENONET 64 /* Machine is not on the network */ |
borlanic | 0:02dd72d1d465 | 260 | #undef ENOPKG |
borlanic | 0:02dd72d1d465 | 261 | #define ENOPKG 65 /* Package not installed */ |
borlanic | 0:02dd72d1d465 | 262 | #undef EREMOTE |
borlanic | 0:02dd72d1d465 | 263 | #define EREMOTE 66 /* Object is remote */ |
borlanic | 0:02dd72d1d465 | 264 | #undef ENOLINK |
borlanic | 0:02dd72d1d465 | 265 | #define ENOLINK 67 /* Link has been severed */ |
borlanic | 0:02dd72d1d465 | 266 | #undef EADV |
borlanic | 0:02dd72d1d465 | 267 | #define EADV 68 /* Advertise error */ |
borlanic | 0:02dd72d1d465 | 268 | #undef ESRMNT |
borlanic | 0:02dd72d1d465 | 269 | #define ESRMNT 69 /* Srmount error */ |
borlanic | 0:02dd72d1d465 | 270 | #undef ECOMM |
borlanic | 0:02dd72d1d465 | 271 | #define ECOMM 70 /* Communication error on send */ |
borlanic | 0:02dd72d1d465 | 272 | #undef EPROTO |
borlanic | 0:02dd72d1d465 | 273 | #define EPROTO 71 /* Protocol error */ |
borlanic | 0:02dd72d1d465 | 274 | #undef EMULTIHOP |
borlanic | 0:02dd72d1d465 | 275 | #define EMULTIHOP 72 /* Multihop attempted */ |
borlanic | 0:02dd72d1d465 | 276 | #undef EDOTDOT |
borlanic | 0:02dd72d1d465 | 277 | #define EDOTDOT 73 /* RFS specific error */ |
borlanic | 0:02dd72d1d465 | 278 | #undef EBADMSG |
borlanic | 0:02dd72d1d465 | 279 | #define EBADMSG 74 /* Not a data message */ |
borlanic | 0:02dd72d1d465 | 280 | #undef EOVERFLOW |
borlanic | 0:02dd72d1d465 | 281 | #define EOVERFLOW 75 /* Value too large for defined data type */ |
borlanic | 0:02dd72d1d465 | 282 | #undef ENOTUNIQ |
borlanic | 0:02dd72d1d465 | 283 | #define ENOTUNIQ 76 /* Name not unique on network */ |
borlanic | 0:02dd72d1d465 | 284 | #undef EBADFD |
borlanic | 0:02dd72d1d465 | 285 | #define EBADFD 77 /* File descriptor in bad state */ |
borlanic | 0:02dd72d1d465 | 286 | #undef EREMCHG |
borlanic | 0:02dd72d1d465 | 287 | #define EREMCHG 78 /* Remote address changed */ |
borlanic | 0:02dd72d1d465 | 288 | #undef ELIBACC |
borlanic | 0:02dd72d1d465 | 289 | #define ELIBACC 79 /* Can not access a needed shared library */ |
borlanic | 0:02dd72d1d465 | 290 | #undef ELIBBAD |
borlanic | 0:02dd72d1d465 | 291 | #define ELIBBAD 80 /* Accessing a corrupted shared library */ |
borlanic | 0:02dd72d1d465 | 292 | #undef ELIBSCN |
borlanic | 0:02dd72d1d465 | 293 | #define ELIBSCN 81 /* .lib section in a.out corrupted */ |
borlanic | 0:02dd72d1d465 | 294 | #undef ELIBMAX |
borlanic | 0:02dd72d1d465 | 295 | #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ |
borlanic | 0:02dd72d1d465 | 296 | #undef ELIBEXEC |
borlanic | 0:02dd72d1d465 | 297 | #define ELIBEXEC 83 /* Cannot exec a shared library directly */ |
borlanic | 0:02dd72d1d465 | 298 | #undef EILSEQ |
borlanic | 0:02dd72d1d465 | 299 | #define EILSEQ 84 /* Illegal byte sequence */ |
borlanic | 0:02dd72d1d465 | 300 | #undef ERESTART |
borlanic | 0:02dd72d1d465 | 301 | #define ERESTART 85 /* Interrupted system call should be restarted */ |
borlanic | 0:02dd72d1d465 | 302 | #undef ESTRPIPE |
borlanic | 0:02dd72d1d465 | 303 | #define ESTRPIPE 86 /* Streams pipe error */ |
borlanic | 0:02dd72d1d465 | 304 | #undef EUSERS |
borlanic | 0:02dd72d1d465 | 305 | #define EUSERS 87 /* Too many users */ |
borlanic | 0:02dd72d1d465 | 306 | #undef ENOTSOCK |
borlanic | 0:02dd72d1d465 | 307 | #define ENOTSOCK 88 /* Socket operation on non-socket */ |
borlanic | 0:02dd72d1d465 | 308 | #undef EDESTADDRREQ |
borlanic | 0:02dd72d1d465 | 309 | #define EDESTADDRREQ 89 /* Destination address required */ |
borlanic | 0:02dd72d1d465 | 310 | #undef EMSGSIZE |
borlanic | 0:02dd72d1d465 | 311 | #define EMSGSIZE 90 /* Message too long */ |
borlanic | 0:02dd72d1d465 | 312 | #undef EPROTOTYPE |
borlanic | 0:02dd72d1d465 | 313 | #define EPROTOTYPE 91 /* Protocol wrong type for socket */ |
borlanic | 0:02dd72d1d465 | 314 | #undef ENOPROTOOPT |
borlanic | 0:02dd72d1d465 | 315 | #define ENOPROTOOPT 92 /* Protocol not available */ |
borlanic | 0:02dd72d1d465 | 316 | #undef EPROTONOSUPPORT |
borlanic | 0:02dd72d1d465 | 317 | #define EPROTONOSUPPORT 93 /* Protocol not supported */ |
borlanic | 0:02dd72d1d465 | 318 | #undef ESOCKTNOSUPPORT |
borlanic | 0:02dd72d1d465 | 319 | #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ |
borlanic | 0:02dd72d1d465 | 320 | #undef EOPNOTSUPP |
borlanic | 0:02dd72d1d465 | 321 | #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ |
borlanic | 0:02dd72d1d465 | 322 | #undef EPFNOSUPPORT |
borlanic | 0:02dd72d1d465 | 323 | #define EPFNOSUPPORT 96 /* Protocol family not supported */ |
borlanic | 0:02dd72d1d465 | 324 | #undef EAFNOSUPPORT |
borlanic | 0:02dd72d1d465 | 325 | #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ |
borlanic | 0:02dd72d1d465 | 326 | #undef EADDRINUSE |
borlanic | 0:02dd72d1d465 | 327 | #define EADDRINUSE 98 /* Address already in use */ |
borlanic | 0:02dd72d1d465 | 328 | #undef EADDRNOTAVAIL |
borlanic | 0:02dd72d1d465 | 329 | #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ |
borlanic | 0:02dd72d1d465 | 330 | #undef ENETDOWN |
borlanic | 0:02dd72d1d465 | 331 | #define ENETDOWN 100 /* Network is down */ |
borlanic | 0:02dd72d1d465 | 332 | #undef ENETUNREACH |
borlanic | 0:02dd72d1d465 | 333 | #define ENETUNREACH 101 /* Network is unreachable */ |
borlanic | 0:02dd72d1d465 | 334 | #undef ENETRESET |
borlanic | 0:02dd72d1d465 | 335 | #define ENETRESET 102 /* Network dropped connection because of reset */ |
borlanic | 0:02dd72d1d465 | 336 | #undef ECONNABORTED |
borlanic | 0:02dd72d1d465 | 337 | #define ECONNABORTED 103 /* Software caused connection abort */ |
borlanic | 0:02dd72d1d465 | 338 | #undef ECONNRESET |
borlanic | 0:02dd72d1d465 | 339 | #define ECONNRESET 104 /* Connection reset by peer */ |
borlanic | 0:02dd72d1d465 | 340 | #undef ENOBUFS |
borlanic | 0:02dd72d1d465 | 341 | #define ENOBUFS 105 /* No buffer space available */ |
borlanic | 0:02dd72d1d465 | 342 | #undef EISCONN |
borlanic | 0:02dd72d1d465 | 343 | #define EISCONN 106 /* Transport endpoint is already connected */ |
borlanic | 0:02dd72d1d465 | 344 | #undef ENOTCONN |
borlanic | 0:02dd72d1d465 | 345 | #define ENOTCONN 107 /* Transport endpoint is not connected */ |
borlanic | 0:02dd72d1d465 | 346 | #undef ESHUTDOWN |
borlanic | 0:02dd72d1d465 | 347 | #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ |
borlanic | 0:02dd72d1d465 | 348 | #undef ETOOMANYREFS |
borlanic | 0:02dd72d1d465 | 349 | #define ETOOMANYREFS 109 /* Too many references: cannot splice */ |
borlanic | 0:02dd72d1d465 | 350 | #undef ETIMEDOUT |
borlanic | 0:02dd72d1d465 | 351 | #define ETIMEDOUT 110 /* Connection timed out */ |
borlanic | 0:02dd72d1d465 | 352 | #undef ECONNREFUSED |
borlanic | 0:02dd72d1d465 | 353 | #define ECONNREFUSED 111 /* Connection refused */ |
borlanic | 0:02dd72d1d465 | 354 | #undef EHOSTDOWN |
borlanic | 0:02dd72d1d465 | 355 | #define EHOSTDOWN 112 /* Host is down */ |
borlanic | 0:02dd72d1d465 | 356 | #undef EHOSTUNREACH |
borlanic | 0:02dd72d1d465 | 357 | #define EHOSTUNREACH 113 /* No route to host */ |
borlanic | 0:02dd72d1d465 | 358 | #undef EALREADY |
borlanic | 0:02dd72d1d465 | 359 | #define EALREADY 114 /* Operation already in progress */ |
borlanic | 0:02dd72d1d465 | 360 | #undef EINPROGRESS |
borlanic | 0:02dd72d1d465 | 361 | #define EINPROGRESS 115 /* Operation now in progress */ |
borlanic | 0:02dd72d1d465 | 362 | #undef ESTALE |
borlanic | 0:02dd72d1d465 | 363 | #define ESTALE 116 /* Stale NFS file handle */ |
borlanic | 0:02dd72d1d465 | 364 | #undef EUCLEAN |
borlanic | 0:02dd72d1d465 | 365 | #define EUCLEAN 117 /* Structure needs cleaning */ |
borlanic | 0:02dd72d1d465 | 366 | #undef ENOTNAM |
borlanic | 0:02dd72d1d465 | 367 | #define ENOTNAM 118 /* Not a XENIX named type file */ |
borlanic | 0:02dd72d1d465 | 368 | #undef ENAVAIL |
borlanic | 0:02dd72d1d465 | 369 | #define ENAVAIL 119 /* No XENIX semaphores available */ |
borlanic | 0:02dd72d1d465 | 370 | #undef EISNAM |
borlanic | 0:02dd72d1d465 | 371 | #define EISNAM 120 /* Is a named type file */ |
borlanic | 0:02dd72d1d465 | 372 | #undef EREMOTEIO |
borlanic | 0:02dd72d1d465 | 373 | #define EREMOTEIO 121 /* Remote I/O error */ |
borlanic | 0:02dd72d1d465 | 374 | #undef EDQUOT |
borlanic | 0:02dd72d1d465 | 375 | #define EDQUOT 122 /* Quota exceeded */ |
borlanic | 0:02dd72d1d465 | 376 | #undef ENOMEDIUM |
borlanic | 0:02dd72d1d465 | 377 | #define ENOMEDIUM 123 /* No medium found */ |
borlanic | 0:02dd72d1d465 | 378 | #undef EMEDIUMTYPE |
borlanic | 0:02dd72d1d465 | 379 | #define EMEDIUMTYPE 124 /* Wrong medium type */ |
borlanic | 0:02dd72d1d465 | 380 | #undef ECANCELED |
borlanic | 0:02dd72d1d465 | 381 | #define ECANCELED 125 /* Operation Canceled */ |
borlanic | 0:02dd72d1d465 | 382 | #undef ENOKEY |
borlanic | 0:02dd72d1d465 | 383 | #define ENOKEY 126 /* Required key not available */ |
borlanic | 0:02dd72d1d465 | 384 | #undef EKEYEXPIRED |
borlanic | 0:02dd72d1d465 | 385 | #define EKEYEXPIRED 127 /* Key has expired */ |
borlanic | 0:02dd72d1d465 | 386 | #undef EKEYREVOKED |
borlanic | 0:02dd72d1d465 | 387 | #define EKEYREVOKED 128 /* Key has been revoked */ |
borlanic | 0:02dd72d1d465 | 388 | #undef EKEYREJECTED |
borlanic | 0:02dd72d1d465 | 389 | #define EKEYREJECTED 129 /* Key was rejected by service */ |
borlanic | 0:02dd72d1d465 | 390 | #undef EOWNERDEAD |
borlanic | 0:02dd72d1d465 | 391 | #define EOWNERDEAD 130 /* Owner died */ |
borlanic | 0:02dd72d1d465 | 392 | #undef ENOTRECOVERABLE |
borlanic | 0:02dd72d1d465 | 393 | #define ENOTRECOVERABLE 131 /* State not recoverable */ |
borlanic | 0:02dd72d1d465 | 394 | |
borlanic | 0:02dd72d1d465 | 395 | /* Missing stat.h defines. |
borlanic | 0:02dd72d1d465 | 396 | * The following are sys/stat.h definitions not currently present in the ARMCC |
borlanic | 0:02dd72d1d465 | 397 | * errno.h. Note, ARMCC errno.h defines some symbol values differing from |
borlanic | 0:02dd72d1d465 | 398 | * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future |
borlanic | 0:02dd72d1d465 | 399 | * changes by changing the symbol definition for filesystem use. |
borlanic | 0:02dd72d1d465 | 400 | */ |
borlanic | 0:02dd72d1d465 | 401 | #define _IFMT 0170000 //< type of file |
borlanic | 0:02dd72d1d465 | 402 | #define _IFSOCK 0140000 //< socket |
borlanic | 0:02dd72d1d465 | 403 | #define _IFLNK 0120000 //< symbolic link |
borlanic | 0:02dd72d1d465 | 404 | #define _IFREG 0100000 //< regular |
borlanic | 0:02dd72d1d465 | 405 | #define _IFBLK 0060000 //< block special |
borlanic | 0:02dd72d1d465 | 406 | #define _IFDIR 0040000 //< directory |
borlanic | 0:02dd72d1d465 | 407 | #define _IFCHR 0020000 //< character special |
borlanic | 0:02dd72d1d465 | 408 | #define _IFIFO 0010000 //< fifo special |
borlanic | 0:02dd72d1d465 | 409 | |
borlanic | 0:02dd72d1d465 | 410 | #define S_IFMT _IFMT //< type of file |
borlanic | 0:02dd72d1d465 | 411 | #define S_IFSOCK _IFSOCK //< socket |
borlanic | 0:02dd72d1d465 | 412 | #define S_IFLNK _IFLNK //< symbolic link |
borlanic | 0:02dd72d1d465 | 413 | #define S_IFREG _IFREG //< regular |
borlanic | 0:02dd72d1d465 | 414 | #define S_IFBLK _IFBLK //< block special |
borlanic | 0:02dd72d1d465 | 415 | #define S_IFDIR _IFDIR //< directory |
borlanic | 0:02dd72d1d465 | 416 | #define S_IFCHR _IFCHR //< character special |
borlanic | 0:02dd72d1d465 | 417 | #define S_IFIFO _IFIFO //< fifo special |
borlanic | 0:02dd72d1d465 | 418 | |
borlanic | 0:02dd72d1d465 | 419 | #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) |
borlanic | 0:02dd72d1d465 | 420 | #define S_IRUSR 0000400 ///< read permission, owner |
borlanic | 0:02dd72d1d465 | 421 | #define S_IWUSR 0000200 ///< write permission, owner |
borlanic | 0:02dd72d1d465 | 422 | #define S_IXUSR 0000100 ///< execute/search permission, owner |
borlanic | 0:02dd72d1d465 | 423 | #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) |
borlanic | 0:02dd72d1d465 | 424 | #define S_IRGRP 0000040 ///< read permission, group |
borlanic | 0:02dd72d1d465 | 425 | #define S_IWGRP 0000020 ///< write permission, group |
borlanic | 0:02dd72d1d465 | 426 | #define S_IXGRP 0000010 ///< execute/search permission, group |
borlanic | 0:02dd72d1d465 | 427 | #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) |
borlanic | 0:02dd72d1d465 | 428 | #define S_IROTH 0000004 ///< read permission, other |
borlanic | 0:02dd72d1d465 | 429 | #define S_IWOTH 0000002 ///< write permission, other |
borlanic | 0:02dd72d1d465 | 430 | #define S_IXOTH 0000001 ///< execute/search permission, other |
borlanic | 0:02dd72d1d465 | 431 | |
borlanic | 0:02dd72d1d465 | 432 | /* Refer to sys/stat standard |
borlanic | 0:02dd72d1d465 | 433 | * Note: Not all fields may be supported by the underlying filesystem |
borlanic | 0:02dd72d1d465 | 434 | */ |
borlanic | 0:02dd72d1d465 | 435 | struct stat { |
borlanic | 0:02dd72d1d465 | 436 | dev_t st_dev; ///< Device ID containing file |
borlanic | 0:02dd72d1d465 | 437 | ino_t st_ino; ///< File serial number |
borlanic | 0:02dd72d1d465 | 438 | mode_t st_mode; ///< Mode of file |
borlanic | 0:02dd72d1d465 | 439 | nlink_t st_nlink; ///< Number of links to file |
borlanic | 0:02dd72d1d465 | 440 | |
borlanic | 0:02dd72d1d465 | 441 | uid_t st_uid; ///< User ID |
borlanic | 0:02dd72d1d465 | 442 | gid_t st_gid; ///< Group ID |
borlanic | 0:02dd72d1d465 | 443 | |
borlanic | 0:02dd72d1d465 | 444 | off_t st_size; ///< Size of file in bytes |
borlanic | 0:02dd72d1d465 | 445 | |
borlanic | 0:02dd72d1d465 | 446 | time_t st_atime; ///< Time of last access |
borlanic | 0:02dd72d1d465 | 447 | time_t st_mtime; ///< Time of last data modification |
borlanic | 0:02dd72d1d465 | 448 | time_t st_ctime; ///< Time of last status change |
borlanic | 0:02dd72d1d465 | 449 | }; |
borlanic | 0:02dd72d1d465 | 450 | |
borlanic | 0:02dd72d1d465 | 451 | struct statvfs { |
borlanic | 0:02dd72d1d465 | 452 | unsigned long f_bsize; ///< Filesystem block size |
borlanic | 0:02dd72d1d465 | 453 | unsigned long f_frsize; ///< Fragment size (block size) |
borlanic | 0:02dd72d1d465 | 454 | |
borlanic | 0:02dd72d1d465 | 455 | fsblkcnt_t f_blocks; ///< Number of blocks |
borlanic | 0:02dd72d1d465 | 456 | fsblkcnt_t f_bfree; ///< Number of free blocks |
borlanic | 0:02dd72d1d465 | 457 | fsblkcnt_t f_bavail; ///< Number of free blocks for unprivileged users |
borlanic | 0:02dd72d1d465 | 458 | |
borlanic | 0:02dd72d1d465 | 459 | unsigned long f_fsid; ///< Filesystem ID |
borlanic | 0:02dd72d1d465 | 460 | |
borlanic | 0:02dd72d1d465 | 461 | unsigned long f_namemax; ///< Maximum filename length |
borlanic | 0:02dd72d1d465 | 462 | }; |
borlanic | 0:02dd72d1d465 | 463 | |
borlanic | 0:02dd72d1d465 | 464 | /* The following are dirent.h definitions are declared here to guarantee |
borlanic | 0:02dd72d1d465 | 465 | * consistency where structure may be different with different toolchains |
borlanic | 0:02dd72d1d465 | 466 | */ |
borlanic | 0:02dd72d1d465 | 467 | struct dirent { |
borlanic | 0:02dd72d1d465 | 468 | char d_name[NAME_MAX+1]; ///< Name of file |
borlanic | 0:02dd72d1d465 | 469 | uint8_t d_type; ///< Type of file |
borlanic | 0:02dd72d1d465 | 470 | }; |
borlanic | 0:02dd72d1d465 | 471 | |
borlanic | 0:02dd72d1d465 | 472 | enum { |
borlanic | 0:02dd72d1d465 | 473 | DT_UNKNOWN, ///< The file type could not be determined. |
borlanic | 0:02dd72d1d465 | 474 | DT_FIFO, ///< This is a named pipe (FIFO). |
borlanic | 0:02dd72d1d465 | 475 | DT_CHR, ///< This is a character device. |
borlanic | 0:02dd72d1d465 | 476 | DT_DIR, ///< This is a directory. |
borlanic | 0:02dd72d1d465 | 477 | DT_BLK, ///< This is a block device. |
borlanic | 0:02dd72d1d465 | 478 | DT_REG, ///< This is a regular file. |
borlanic | 0:02dd72d1d465 | 479 | DT_LNK, ///< This is a symbolic link. |
borlanic | 0:02dd72d1d465 | 480 | DT_SOCK, ///< This is a UNIX domain socket. |
borlanic | 0:02dd72d1d465 | 481 | }; |
borlanic | 0:02dd72d1d465 | 482 | |
borlanic | 0:02dd72d1d465 | 483 | struct pollfd { |
borlanic | 0:02dd72d1d465 | 484 | int fd; |
borlanic | 0:02dd72d1d465 | 485 | short events; |
borlanic | 0:02dd72d1d465 | 486 | short revents; |
borlanic | 0:02dd72d1d465 | 487 | }; |
borlanic | 0:02dd72d1d465 | 488 | |
borlanic | 0:02dd72d1d465 | 489 | /* POSIX-compatible I/O functions */ |
borlanic | 0:02dd72d1d465 | 490 | #if __cplusplus |
borlanic | 0:02dd72d1d465 | 491 | extern "C" { |
borlanic | 0:02dd72d1d465 | 492 | #endif |
borlanic | 0:02dd72d1d465 | 493 | int open(const char *path, int oflag, ...); |
borlanic | 0:02dd72d1d465 | 494 | #ifndef __IAR_SYSTEMS_ICC__ /* IAR provides fdopen itself */ |
borlanic | 0:02dd72d1d465 | 495 | #if __cplusplus |
borlanic | 0:02dd72d1d465 | 496 | std::FILE* fdopen(int fildes, const char *mode); |
borlanic | 0:02dd72d1d465 | 497 | #else |
borlanic | 0:02dd72d1d465 | 498 | FILE* fdopen(int fildes, const char *mode); |
borlanic | 0:02dd72d1d465 | 499 | #endif |
borlanic | 0:02dd72d1d465 | 500 | #endif |
borlanic | 0:02dd72d1d465 | 501 | ssize_t write(int fildes, const void *buf, size_t nbyte); |
borlanic | 0:02dd72d1d465 | 502 | ssize_t read(int fildes, void *buf, size_t nbyte); |
borlanic | 0:02dd72d1d465 | 503 | off_t lseek(int fildes, off_t offset, int whence); |
borlanic | 0:02dd72d1d465 | 504 | int isatty(int fildes); |
borlanic | 0:02dd72d1d465 | 505 | int fsync(int fildes); |
borlanic | 0:02dd72d1d465 | 506 | int fstat(int fh, struct stat *st); |
borlanic | 0:02dd72d1d465 | 507 | int poll(struct pollfd fds[], nfds_t nfds, int timeout); |
borlanic | 0:02dd72d1d465 | 508 | int close(int fildes); |
borlanic | 0:02dd72d1d465 | 509 | int stat(const char *path, struct stat *st); |
borlanic | 0:02dd72d1d465 | 510 | int statvfs(const char *path, struct statvfs *buf); |
borlanic | 0:02dd72d1d465 | 511 | DIR *opendir(const char*); |
borlanic | 0:02dd72d1d465 | 512 | struct dirent *readdir(DIR *); |
borlanic | 0:02dd72d1d465 | 513 | int closedir(DIR*); |
borlanic | 0:02dd72d1d465 | 514 | void rewinddir(DIR*); |
borlanic | 0:02dd72d1d465 | 515 | long telldir(DIR*); |
borlanic | 0:02dd72d1d465 | 516 | void seekdir(DIR*, long); |
borlanic | 0:02dd72d1d465 | 517 | int mkdir(const char *name, mode_t n); |
borlanic | 0:02dd72d1d465 | 518 | #if __cplusplus |
borlanic | 0:02dd72d1d465 | 519 | }; // extern "C" |
borlanic | 0:02dd72d1d465 | 520 | |
borlanic | 0:02dd72d1d465 | 521 | namespace mbed { |
borlanic | 0:02dd72d1d465 | 522 | |
borlanic | 0:02dd72d1d465 | 523 | /** This call is an analogue to POSIX fdopen(). |
borlanic | 0:02dd72d1d465 | 524 | * |
borlanic | 0:02dd72d1d465 | 525 | * It associates a C stream to an already-opened FileHandle, to allow you to |
borlanic | 0:02dd72d1d465 | 526 | * use C printf/scanf/fwrite etc. The provided FileHandle must remain open - |
borlanic | 0:02dd72d1d465 | 527 | * it will be closed by the C library when fclose(FILE) is called. |
borlanic | 0:02dd72d1d465 | 528 | * |
borlanic | 0:02dd72d1d465 | 529 | * The net effect is fdopen(bind_to_fd(fh), mode), with error handling. |
borlanic | 0:02dd72d1d465 | 530 | * |
borlanic | 0:02dd72d1d465 | 531 | * @param fh a pointer to an opened FileHandle |
borlanic | 0:02dd72d1d465 | 532 | * @param mode operation upon the file descriptor, e.g., "w+" |
borlanic | 0:02dd72d1d465 | 533 | * |
borlanic | 0:02dd72d1d465 | 534 | * @returns a pointer to FILE |
borlanic | 0:02dd72d1d465 | 535 | */ |
borlanic | 0:02dd72d1d465 | 536 | std::FILE* fdopen(mbed::FileHandle *fh, const char *mode); |
borlanic | 0:02dd72d1d465 | 537 | |
borlanic | 0:02dd72d1d465 | 538 | /** Bind an mbed FileHandle to a POSIX file descriptor |
borlanic | 0:02dd72d1d465 | 539 | * |
borlanic | 0:02dd72d1d465 | 540 | * This is similar to fdopen, but only operating at the POSIX layer - it |
borlanic | 0:02dd72d1d465 | 541 | * associates a POSIX integer file descriptor with a FileHandle, to allow you |
borlanic | 0:02dd72d1d465 | 542 | * to use POSIX read/write calls etc. The provided FileHandle must remain open - |
borlanic | 0:02dd72d1d465 | 543 | * it will be closed when close(int) is called. |
borlanic | 0:02dd72d1d465 | 544 | * |
borlanic | 0:02dd72d1d465 | 545 | * @param fh a pointer to an opened FileHandle |
borlanic | 0:02dd72d1d465 | 546 | * |
borlanic | 0:02dd72d1d465 | 547 | * @return an integer file descriptor, or negative if no descriptors available |
borlanic | 0:02dd72d1d465 | 548 | */ |
borlanic | 0:02dd72d1d465 | 549 | int bind_to_fd(mbed::FileHandle *fh); |
borlanic | 0:02dd72d1d465 | 550 | |
borlanic | 0:02dd72d1d465 | 551 | } // namespace mbed |
borlanic | 0:02dd72d1d465 | 552 | |
borlanic | 0:02dd72d1d465 | 553 | #endif // __cplusplus |
borlanic | 0:02dd72d1d465 | 554 | |
borlanic | 0:02dd72d1d465 | 555 | /**@}*/ |
borlanic | 0:02dd72d1d465 | 556 | |
borlanic | 0:02dd72d1d465 | 557 | /**@}*/ |
borlanic | 0:02dd72d1d465 | 558 | |
borlanic | 0:02dd72d1d465 | 559 | #endif /* RETARGET_H */ |