ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
io.h File Reference
#include <stdbool.h>
#include <sys/uio.h>

Go to the source code of this file.

Typedefs

typedef void(* io_destroy_func_t )(void *data)
 
typedef bool(* io_callback_func_t )(struct io *io, void *user_data)
 

Functions

struct ioio_new (int fd)
 
void io_destroy (struct io *io)
 
int io_get_fd (struct io *io)
 
bool io_set_close_on_destroy (struct io *io, bool do_close)
 
ssize_t io_send (struct io *io, const struct iovec *iov, int iovcnt)
 
bool io_shutdown (struct io *io)
 
bool io_set_read_handler (struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy)
 
bool io_set_write_handler (struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy)
 
bool io_set_disconnect_handler (struct io *io, io_callback_func_t callback, void *user_data, io_destroy_func_t destroy)
 

Typedef Documentation

typedef bool(* io_callback_func_t)(struct io *io, void *user_data)

Definition at line 40 of file io.h.

typedef void(* io_destroy_func_t)(void *data)

Definition at line 27 of file io.h.

Function Documentation

void io_destroy ( struct io io)

remove the fd from the 'mainloop' and reset all io call back, unref the io data structure

Parameters
iopointer to the io data structure

Definition at line 226 of file io-mainloop.c.

References io::disconnect_callback, io::fd, io_unref(), mainloop_remove_fd(), io::read_callback, and io::write_callback.

Referenced by bt_att_free(), and disconnect_cb().

int io_get_fd ( struct io io)

return the fd (file descriptor, can be a socket) attached to the io data structure

Parameters
iopointer to io data structure
Returns

Definition at line 246 of file io-mainloop.c.

References io::fd.

struct io* io_new ( int  fd)

create a new io data structure

Parameters
fdfile descriptor (includes socket)
Returns
NULL if error or io data structure

Definition at line 197 of file io-mainloop.c.

References io::close_on_destroy, io::events, io::fd, io_callback(), io_cleanup(), io_ref(), mainloop_add_fd(), and new0.

Referenced by bt_att_new().

ssize_t io_send ( struct io io,
const struct iovec *  iov,
int  iovcnt 
)

send data to the underlying socket (actual write)

Parameters
ioio structure which describe the underlying socket and its context
iovpointer to pdu, pdu length structure
iovcntnumber of pdu to send (iov is an array)
Returns
The return value is a count of bytes written, or -errno indicating an error.

Definition at line 395 of file io-mainloop.c.

References io::fd.

Referenced by can_write_data().

bool io_set_close_on_destroy ( struct io io,
bool  do_close 
)
Parameters
io
do_close
Returns

Definition at line 260 of file io-mainloop.c.

References io::close_on_destroy.

Referenced by bt_att_set_close_on_unref().

bool io_set_disconnect_handler ( struct io io,
io_callback_func_t  callback,
void *  user_data,
io_destroy_func_t  destroy 
)
Parameters
io
callback
user_data
destroy
Returns

Definition at line 356 of file io-mainloop.c.

References io::disconnect_callback, io::disconnect_data, io::disconnect_destroy, io::events, io::fd, and mainloop_modify_fd().

Referenced by bt_att_new().

bool io_set_read_handler ( struct io io,
io_callback_func_t  callback,
void *  user_data,
io_destroy_func_t  destroy 
)
Parameters
io
callback
user_data
destroy
Returns

Definition at line 278 of file io-mainloop.c.

References io::events, io::fd, mainloop_modify_fd(), io::read_callback, io::read_data, and io::read_destroy.

Referenced by bt_att_new().

bool io_set_write_handler ( struct io io,
io_callback_func_t  callback,
void *  user_data,
io_destroy_func_t  destroy 
)
Parameters
io
callback
user_data
destroy
Returns

Definition at line 317 of file io-mainloop.c.

References io::events, io::fd, mainloop_modify_fd(), io::write_callback, io::write_data, and io::write_destroy.

Referenced by wakeup_writer().

bool io_shutdown ( struct io io)
Parameters
io
Returns

Definition at line 417 of file io-mainloop.c.

References io::fd.

Referenced by can_read_data(), handle_conf(), handle_rsp(), and timeout_cb().