unistd - marinus-lab/z88dk GitHub Wiki
| Include | #include <unistd.h>
|
| -------------------------------------------------------------------------------------------------------------------------------
| Header | {z88dk}/include/_DEVELOPMENT/sccz80/unistd.h |
| | {z88dk}/include/_DEVELOPMENT/sdcc/unistd.h |
Other References:
| NULL | %%((void*)(0))%% | pointer to nothing |
| -----------------------------------------------------------
| | | |
| SEEK_SET | 0 | offset is an absolute file position |
| SEEK_CUR | 1 | offset is relative to current file position |
| SEEK_END | 2 | offset is relative to EOF |
| | | |
| STDIN_FILENO | 0 | fd stdin is attached to |
| STDOUT_FILENO | 1 | fd stdout is attached to |
| STDERR_FILENO | 2 | fd stderr is attached to |
| intptr_t | int | signed integer that can hold a pointer value |
| ---------------------------------------------------------------------------------
| off_t | long | file offset |
| size_t | unsigned int | used for size of objects |
| ssize_t | unsigned int | used for count of bytes |
Clear the file descriptor fd in the file table making the file descriptor available for a newly opened file. Decrease the file's reference count and if it reaches zero, flush and close the file. Return 0 on success and -1 on failure.
If an error occurs, carry flag is set and errno is set to:
- [EBDFD] if fd is not an open file
Duplicate the file descriptor fd into the first available slot in the file table in numerical order. Returns the duplicate fd on success and -1 on failure.
If an error occurs, carry flag is set and errno is set to:
-
[EBDFD] if fd is not an open file
-
[ENFILE] if the file table is full
Duplicate the file descriptor fd into fd2. If fd2 is associated with an open file, close it first. Returns fd2 on success or -1 on failure.
If an error occurs, carry flag is set and errno is set to:
-
[EBDFD] if fd is not an open file
-
[EBDFD] if fd2 is out of range
Same as _Exit(status)
Adjust the file pointer by amount offset according to whence:
| whence | | | ------------- | SEEK_SET | Set the file pointer to offset | | SEEK_CUR | Adjust the current file pointer by signed offset | | SEEK_END | Set the file pointer to the EOF position plus signed offset |
Return the new file pointer position on success or -1 on error.
If an error occurs, carry flag is set and errno is set to:
-
[EBDFD] if fd is not an open file
-
[EINVAL] if whence is invalid
The driver may return other errors.
Read a maximum of nbyte bytes from the stream and write them into buffer buf. Returns the number of bytes actually read or -1 on error.
If an error occurs, carry flag is set and errno is set to:
-
[EACCES] if fd is not open for reading
-
[EBDFD] if fd is not an open file
The driver may return other errors.
Attempt to write nbyte bytes from buffer buf to the stream. Return the number of bytes actually written or -1 on error.
If an error occurs, carry flag is set and errno is set to:
-
[EACCES] if fd is not open for writing
-
[EBDFD] if fd is not an open file
The driver may return other errors.