#include <sys/time.h>
#include <sys/select.h>
Go to the source code of this file.
Defines | |
#define | _ABLE_CLIB_UNISTD_H 1 |
#define | SEEK_SET (0) |
#define | SEEK_CUR (1) |
#define | SEEK_END (2) |
#define | R_OK 4 |
#define | W_OK 2 |
#define | X_OK 1 |
#define | F_OK 0 |
Functions | |
int | close (int fd) |
Close a file descriptor. | |
int | dup2 (int oldfd, int newfd) |
Duplicate the file descriptor. | |
int | dup (int oldfd) |
Duplicate the file descriptor. | |
int | pipe (int *pipefd) |
Create a pipe. | |
ssize_t | read (int fd, void *data, size_t size) |
Read from the fd. | |
ssize_t | write (int fd, const void *data, size_t size) |
Write data block to an fd. | |
off64_t | lseek64 (int fd, off64_t off, int whence) |
Seek fd with an 64bit offset. | |
off_t | lseek (int fd, off_t offset, int whence) |
Seek fd with an standard file offset. | |
ssize_t | readlink (const char *path, char *buf, size_t bufsiz) |
Read the value of a symbolic link. | |
char * | getcwd (char *buf, size_t size) |
Get the current working directory. | |
void | _exit (int status) |
Exit a running process without atexit processing. | |
int | getopt (int argc, char *const *argv, const char *options) |
Process command line options. | |
int | access (const char *pathname, int mode) |
Check a users permissions for accessing a file. | |
int | isatty (int desc) |
Check if a file descriptor refers to a terminal. | |
unsigned int | sleep (unsigned int seconds) |
Delay exceution of a task for a given number of seconds. | |
Variables | |
char * | optarg |
The argument to the returned option, if any. | |
int | opterr |
Flag to inhibit the display of error messages. | |
int | optind |
The index of the last processed option. | |
int | optopt |
If the option character is unrecognised it is stored in this variable. |
#define _ABLE_CLIB_UNISTD_H 1 |
#define F_OK 0 |
#define R_OK 4 |
#define SEEK_CUR (1) |
#define SEEK_END (2) |
#define SEEK_SET (0) |
#define W_OK 2 |
#define X_OK 1 |
void _exit | ( | int | status | ) |
Exit a running process without atexit processing.
int access | ( | const char * | pathname, | |
int | mode | |||
) |
Check a users permissions for accessing a file.
Checks whether the calling process can access a file with a specific mode.
pathname | The path to check. | |
mode | The mode to check with. |
int close | ( | int | fd | ) |
Close a file descriptor.
Close this file descriptor, ending the use of this file descriptor and freeing the resources used if this is the last user of the open stream.
fd | FD to close. |
int dup | ( | int | oldfd | ) |
Duplicate the file descriptor.
This call duplicates the oldfd on to the next available file descriptor. The two file descriptors share the same file pointers and status flags.
File status flags shared are O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_ASYNC, O_DIRECT and O_NONBLOCK.
Note, the man page on my laptop disagrees about the flags-sharing but all other the online references say that the flags are shared.
oldfd | The file descriptor to copy from. |
int dup2 | ( | int | oldfd, | |
int | newfd | |||
) |
Duplicate the file descriptor.
This call duplicates the oldfd on to the newfd. The two file descriptors share the same file pointers and status flags.
File status flags shared are O_RDONLY, O_WRONLY, O_RDWR, O_APPEND, O_ASYNC, O_DIRECT and O_NONBLOCK.
Note, the man page on my laptop disagrees about the flags-sharing but all other the online references say that the flags are shared.
oldfd | The file descriptor to copy from. | |
newfd | The file descriptor to copy oldfd onto. |
char* getcwd | ( | char * | buf, | |
size_t | size | |||
) |
Get the current working directory.
int getopt | ( | int | argc, | |
char *const * | argv, | |||
const char * | options | |||
) |
Process command line options.
Process the passed string vector an element at a time serching for valid option switches. Each time the function is called it returns either the option character specified in the options or -1 if there are no more options to process. On each iteration the variables optarg, opterr and optind are updated as apropriate for the option being parsed. If the option character is unrecognise dit is stored in optopt and a '?' character is returned. If opterr is set to 0 the display of the default error message is inhibited.
argc | The number of elements in the argument vector argv. | |
argv | The argument vector. | |
options | The short options string. |
int isatty | ( | int | desc | ) |
Check if a file descriptor refers to a terminal.
desc | The descriptor to check. |
Seek fd with an standard file offset.
Change the position of the given file descriptor using off and whence. The value of whence controls how the off is interpreted. SEEK_SET indicats off is a direct pointer into the stream, SEEK_CUR means that off is an offset from the current pointer, and SEEK_END is an offset from the file end.
fd | File descriptor to change pointers of. | |
offset | Offset to use, see whence for meaning. | |
whence | Type of offset, such as SEEK_SET, SEEK_CUR or SEEK_END. |
Seek fd with an 64bit offset.
Change the position of the given file descriptor using off and whence. The value of whence controls how the off is interpreted. SEEK_SET indicates off is a direct pointer into the stream, SEEK_CUR means that off is an offset from the current pointer, and SEEK_END is an offset from the file end.
fd | File descriptor to change pointers of. | |
off | Offset to use, see whence for meaning. | |
whence | Type of offset, such as SEEK_SET, SEEK_CUR or SEEK_END. |
int pipe | ( | int * | pipefd | ) |
Create a pipe.
Creates a buffered unidirectional data channel which can be used for interprocess communication. The array contains two file descriptors connected to each end of the pipe. pipefd[0] is the read end of the pipe and pipefd[1] is the write end of the pipe. The written data is buffered by the kernel until it is read from the other end of the pipe.
pipefd | array of two integers. |
Read from the fd.
Read data from the given file descriptor into the specified block of memory. The call will try and fill the buffer with data, unless the call would block, and the fd is marked O_NONBLOCK.
This behaves as close as possible to the POSIX standard read call.
fd | File descriptor to read from. | |
data | Data block to write data into. | |
size | Size available in data block. |
unsigned int sleep | ( | unsigned int | seconds | ) |
Delay exceution of a task for a given number of seconds.
seconds | The number of seconds to wait. |
Write data block to an fd.
Write data to the given file descriptor into the specified block of memory. The call will try and write the whole buffer, unless the call would block and the fd is marked O_NONBLOCK.
This behaves as close as possible to the POSIX standard write call.
fd | File descriptor to write to. | |
data | Data block to write data from. | |
size | Size available in data block. |
int opterr |
Flag to inhibit the display of error messages.