30 static int lely_io_ref;
41 WORD wVersionRequested = MAKEWORD(2, 2);
43 if ((errc = WSAStartup(wVersionRequested, &wsaData)))
44 goto error_WSAStartup;
61 if (lely_io_ref <= 0) {
103 return INVALID_HANDLE_VALUE;
118 int flags = handle->
flags;
135 if (flags != handle->
flags) {
137 result = handle->
vtab->
flags(handle, flags);
139 handle->
flags = flags;
157 assert(handle->
vtab);
163 return handle->
vtab->
read(handle, buf, nbytes);
174 assert(handle->
vtab);
180 return handle->
vtab->
write(handle, buf, nbytes);
191 assert(handle->
vtab);
This header file is part of the utilities library; it contains the native and platform-independent er...
@ ERRNUM_NXIO
No such device or address.
@ ERRNUM_BADF
Bad file descriptor.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
void io_handle_unlock(struct io_handle *handle)
Unlocks a locked I/O device handle.
void io_handle_lock(struct io_handle *handle)
Locks an unlocked I/O device handle, so the flags (and other device-specific fields) can safely be ac...
This is the internal header file of the I/O handle declarations.
@ IO_FLAG_NONBLOCK
Perform I/O operations in non-blocking mode.
@ IO_FLAG_LOOPBACK
Receive own messages (i.e., sent by the same device).
@ IO_FLAG_NO_CLOSE
Do not close the native file descriptor when closing an I/O device.
#define IO_HANDLE_ERROR
The value of an invalid I/O device handle.
void io_handle_release(io_handle_t handle)
Decrements the reference count of an I/O device handle.
void lely_io_fini(void)
Finalizes the I/O library and terminates the availability of the I/O functions.
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,...
ssize_t io_read(io_handle_t handle, void *buf, size_t nbytes)
Performs a read operation.
int lely_io_init(void)
Initializes the I/O library and makes the I/O functions available for use.
HANDLE io_get_fd(io_handle_t handle)
Returns the native file descriptor of an I/O device.
int io_flush(io_handle_t handle)
Flushes the write buffer of a an I/O device.
int io_set_flags(io_handle_t handle, int flags)
Sets the flags of an I/O device.
int io_get_flags(io_handle_t handle)
Obtains the flags of an I/O device.
ssize_t io_write(io_handle_t handle, const void *buf, size_t nbytes)
Performs a write operation.
This is the internal header file of the Windows-specific I/O declarations.
int(* flush)(struct io_handle *handle)
A pointer to the flush method.
int(* flags)(struct io_handle *handle, int flags)
A pointer to the static flags method.
ssize_t(* write)(struct io_handle *handle, const void *buf, size_t nbytes)
A pointer to the write method.
ssize_t(* read)(struct io_handle *handle, void *buf, size_t nbytes)
A pointer to the read method.
int type
The type of the device (one of IO_TYPE_CAN, IO_TYPE_FILE, IO_TYPE_PIPE, IO_TYPE_SERIAL or IO_TYPE_SOC...
int fd
The native file descriptor.
int flags
The I/O device flags (any combination of IO_FLAG_NO_CLOSE and IO_FLAG_NONBLOCK).
const struct io_handle_vtab * vtab
A pointer to the virtual table.