I/O Management (derived from Cheops-NG) More...
#include "asterisk/poll-compat.h"
Go to the source code of this file.
Macros | |
#define | AST_IO_CB(a) ((ast_io_cb)(a)) |
#define | AST_IO_ERR POLLERR |
#define | AST_IO_HUP POLLHUP |
#define | AST_IO_IN POLLIN |
#define | AST_IO_NVAL POLLNVAL |
#define | AST_IO_OUT POLLOUT |
#define | AST_IO_PRI POLLPRI |
Typedefs | |
typedef int(* | ast_io_cb )(int *id, int fd, short events, void *cbdata) |
Functions | |
int | ast_get_termcols (int fd) |
int | ast_hide_password (int fd) |
int * | ast_io_add (struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data) |
Adds an IO context. More... | |
int * | ast_io_change (struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data) |
Changes an IO handler. More... | |
void | ast_io_dump (struct io_context *ioc) |
Dumps the IO array. Debugging: Dump everything in the I/O array. More... | |
int | ast_io_remove (struct io_context *ioc, int *id) |
Removes an IO context. More... | |
int | ast_io_wait (struct io_context *ioc, int howlong) |
Waits for IO. More... | |
int | ast_restore_tty (int fd, int oldstatus) |
Restores TTY mode. Call with result from previous ast_hide_password. More... | |
struct io_context * | io_context_create (void) |
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up some default values. More... | |
void | io_context_destroy (struct io_context *ioc) |
Destroys a context. More... | |
I/O Management (derived from Cheops-NG)
Definition in file io.h.
#define AST_IO_ERR POLLERR |
#define AST_IO_IN POLLIN |
Input ready
Definition at line 33 of file io.h.
Referenced by ast_netsock_bindaddr(), ast_udptl_new_with_bindaddr(), do_monitor(), and network_thread().
#define AST_IO_PRI POLLPRI |
int ast_get_termcols | ( | int | fd | ) |
Definition at line 368 of file io.c.
References isatty().
Referenced by ast_cli_display_match_list().
int ast_hide_password | ( | int | fd | ) |
int* ast_io_add | ( | struct io_context * | ioc, |
int | fd, | ||
ast_io_cb | callback, | ||
short | events, | ||
void * | data | ||
) |
Adds an IO context.
ioc | which context to use |
fd | which fd to monitor |
callback | callback function to run |
events | event mask of events to wait for |
data | data to pass to the callback Watch for any of revents activites on fd, calling callback with data as callback data. |
a | pointer to ID of the IO event |
NULL | on failure |
Adds an IO context.
Definition at line 157 of file io.c.
References ast_debug, ast_malloc, io_rec::callback, io_rec::data, DEBUG, events, io_context::fdcnt, io_context::fds, io_rec::id, io_grow(), io_context::ior, and io_context::maxfdcnt.
Referenced by ast_netsock_bindaddr(), ast_udptl_new_with_bindaddr(), do_monitor(), and network_thread().
int* ast_io_change | ( | struct io_context * | ioc, |
int * | id, | ||
int | fd, | ||
ast_io_cb | callback, | ||
short | events, | ||
void * | data | ||
) |
Changes an IO handler.
ioc | which context to use |
id | |
fd | the fd you wish it to contain now |
callback | new callback function |
events | event mask to wait for |
data | data to pass to the callback function Change an I/O handler, updating fd if > -1, callback if non-null, and revents if >-1, and data if non-null. |
a | pointer to the ID of the IO event |
NULL | on failure |
Definition at line 195 of file io.c.
References io_rec::callback, io_rec::data, events, io_context::fdcnt, io_context::fds, id, and io_context::ior.
Referenced by do_monitor().
void ast_io_dump | ( | struct io_context * | ioc | ) |
Dumps the IO array. Debugging: Dump everything in the I/O array.
Definition at line 307 of file io.c.
References ast_debug, io_rec::callback, io_rec::data, io_context::fdcnt, io_context::fds, io_rec::id, io_context::ior, and io_context::maxfdcnt.
int ast_io_remove | ( | struct io_context * | ioc, |
int * | id | ||
) |
Removes an IO context.
ioc | which io_context to remove it from |
id | which ID to remove Remove an I/O id from consideration |
0 | on success |
-1 | on failure |
Definition at line 240 of file io.c.
References ast_free, ast_log(), io_context::current_ioc, io_context::fdcnt, io_context::fds, io_rec::id, io_shrink(), io_context::ior, LOG_NOTICE, LOG_WARNING, and io_context::needshrink.
Referenced by ast_io_wait(), ast_netsock_destroy(), ast_udptl_destroy(), do_monitor(), network_thread(), reload_config(), and unload_module().
int ast_io_wait | ( | struct io_context * | ioc, |
int | howlong | ||
) |
Waits for IO.
ioc | which context to act upon |
howlong | how many milliseconds to wait Wait for I/O to happen, returning after howlong milliseconds, and after processing any necessary I/O. |
Waits for IO.
Definition at line 273 of file io.c.
References ast_debug, ast_io_remove(), ast_poll, io_rec::callback, io_context::current_ioc, io_rec::data, DEBUG, io_context::fdcnt, io_context::fds, io_rec::id, io_shrink(), io_context::ior, and io_context::needshrink.
Referenced by do_monitor(), network_thread(), and reload_config().
int ast_restore_tty | ( | int | fd, |
int | oldstatus | ||
) |
struct io_context* io_context_create | ( | void | ) |
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up some default values.
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up some default values.
Definition at line 76 of file io.c.
References ast_calloc, ast_free, ast_malloc, io_context::current_ioc, io_context::fdcnt, io_context::fds, GROW_SHRINK_SIZE, io_context::ior, io_context::maxfdcnt, and io_context::needshrink.
Referenced by load_module().
void io_context_destroy | ( | struct io_context * | ioc | ) |
Destroys a context.
ioc | structure to destroy Destroy a context for I/O operations Frees all memory associated with the given io_context structure along with the structure itself |
Definition at line 102 of file io.c.
References ast_free, io_context::fds, and io_context::ior.
Referenced by load_module(), and unload_module().