Lely core libraries
2.3.4
|
This file is part of the I/O library; it contains the implementation of the the initialization and finalization functions. More...
Go to the source code of this file.
Functions | |
int | lely_io_init (void) |
Initializes the I/O library and makes the I/O functions available for use. More... | |
void | lely_io_fini (void) |
Finalizes the I/O library and terminates the availability of the I/O functions. More... | |
int | io_close (io_handle_t handle) |
Closes an I/O device. More... | |
int | io_get_type (io_handle_t handle) |
Returns the type of an I/O device (one of IO_TYPE_CAN, IO_TYPE_FILE, IO_TYPE_PIPE, IO_TYPE_SERIAL or IO_TYPE_SOCK), or -1 on error. More... | |
HANDLE | io_get_fd (io_handle_t handle) |
Returns the native file descriptor of an I/O device. | |
int | io_get_flags (io_handle_t handle) |
Obtains the flags of an I/O device. More... | |
int | io_set_flags (io_handle_t handle, int flags) |
Sets the flags of an I/O device. More... | |
ssize_t | io_read (io_handle_t handle, void *buf, size_t nbytes) |
Performs a read operation. More... | |
ssize_t | io_write (io_handle_t handle, const void *buf, size_t nbytes) |
Performs a write operation. More... | |
int | io_flush (io_handle_t handle) |
Flushes the write buffer of a an I/O device. More... | |
This file is part of the I/O library; it contains the implementation of the the initialization and finalization functions.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file io.c.
int lely_io_init | ( | void | ) |
Initializes the I/O library and makes the I/O functions available for use.
On Windows this function invokes WSAStartup()
. This function is not thread safe, but can be invoked multiple times, as long as it is matched by an equal number of calls to lely_io_fini().
void lely_io_fini | ( | void | ) |
Finalizes the I/O library and terminates the availability of the I/O functions.
On Windows this function invokes WSACleanup()
. Note that this function MUST be invoked once for each corresponding call to lely_io_init(). Only the last invocation will finalize the library.
int io_close | ( | io_handle_t | handle | ) |
Closes an I/O device.
int io_get_type | ( | io_handle_t | handle | ) |
Returns the type of an I/O device (one of IO_TYPE_CAN, IO_TYPE_FILE, IO_TYPE_PIPE, IO_TYPE_SERIAL or IO_TYPE_SOCK), or -1 on error.
In the latter case, the error number can be obtained with get_errc().
int io_get_flags | ( | io_handle_t | handle | ) |
Obtains the flags of an I/O device.
int io_set_flags | ( | io_handle_t | handle, |
int | flags | ||
) |
Sets the flags of an I/O device.
handle | a valid I/O device handle. |
flags | the I/O device flags (any combination of IO_FLAG_NO_CLOSE, IO_FLAG_NONBLOCK and IO_FLAG_LOOPBACK). |
ssize_t io_read | ( | io_handle_t | handle, |
void * | buf, | ||
size_t | nbytes | ||
) |
Performs a read operation.
For regular files, this function updates the file pointer on success.
handle | a valid I/O device handle. |
buf | a pointer to the destination buffer. |
nbytes | the number of bytes to read. |
ssize_t io_write | ( | io_handle_t | handle, |
const void * | buf, | ||
size_t | nbytes | ||
) |
Performs a write operation.
For regular files, this function updates the file pointer on success.
handle | a valid I/O device handle. |
buf | a pointer to the source buffer. |
nbytes | the number of bytes to write. |
int io_flush | ( | io_handle_t | handle | ) |
Flushes the write buffer of a an I/O device.
This function waits until all buffered data has been written.