35 #include <sys/ioctl.h>
62 #define GROW_SHRINK_SIZE 512
198 if (*
id > ioc->
fdcnt)
202 ioc->
fds[*
id].fd = fd;
215 int getfrom, putto = 0;
222 for (getfrom = 0; getfrom < ioc->
fdcnt; getfrom++) {
223 if (ioc->
ior[getfrom].
id) {
225 if (getfrom != putto) {
226 ioc->
fds[putto] = ioc->
fds[getfrom];
227 ioc->
ior[putto] = ioc->
ior[getfrom];
228 *(ioc->
ior[putto].
id) = putto;
249 for (x = 0; x < ioc->
fdcnt; x++) {
250 if (ioc->
ior[x].
id == _id) {
253 ioc->
ior[x].
id = NULL;
254 ioc->
fds[x].events = 0;
255 ioc->
fds[x].revents = 0;
284 origcnt = ioc->
fdcnt;
285 for (x = 0; x < origcnt; x++) {
288 if (ioc->
fds[x].revents && ioc->
ior[x].
id) {
316 ast_debug(1,
"================================================\n");
317 ast_debug(1,
"| ID FD Callback Data Events |\n");
318 ast_debug(1,
"+------+------+-----------+-----------+--------+\n");
319 for (x = 0; x < ioc->
fdcnt; x++) {
320 ast_debug(1,
"| %.4d | %.4d | %p | %p | %.6x |\n",
325 (
unsigned)ioc->
fds[x].events);
327 ast_debug(1,
"================================================\n");
339 res = tcgetattr(fd, &tios);
342 old = tios.c_lflag & (
ECHO | ECHONL);
343 tios.c_lflag &= ~
ECHO;
344 tios.c_lflag |= ECHONL;
345 res = tcsetattr(fd, TCSAFLUSH, &tios);
357 res = tcgetattr(fd, &tios);
360 tios.c_lflag &= ~(
ECHO | ECHONL);
361 tios.c_lflag |= oldstate;
362 res = tcsetattr(fd, TCSAFLUSH, &tios);
376 if ( ioctl(fd, TIOCGWINSZ, &win) != -1 ) {
377 if ( !cols && win.ws_col > 0 )
378 cols = (int) win.ws_col;
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
Asterisk main include file. File version handling, generic pbx functions.
static int io_shrink(struct io_context *ioc)
int ast_hide_password(int fd)
Kept for each file descriptor.
void ast_io_dump(struct io_context *ioc)
Dumps the IO array. Debugging: Dump everything in the I/O array.
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
I/O Management (derived from Cheops-NG)
int ast_get_termcols(int fd)
int ast_restore_tty(int fd, int oldstatus)
Restores TTY mode. Call with result from previous ast_hide_password.
#define ast_debug(level,...)
Log a DEBUG message.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
#define ast_poll(a, b, c)
Global IO variables are now in a struct in order to be made threadsafe.
static int io_grow(struct io_context *ioc)
Grow the size of our arrays.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
int ast_io_remove(struct io_context *ioc, int *id)
Removes an IO context.
int(* ast_io_cb)(int *id, int fd, short events, void *cbdata)
#define ast_realloc(a, b)
int * ast_io_change(struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data)
Changes an IO handler.
static struct adsi_event events[]
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
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 s...