38#include <systemd/sd-daemon.h> 
   40#ifndef SD_LISTEN_FDS_START 
   41#define SD_LISTEN_FDS_START 3 
   67#define GROW_SHRINK_SIZE 512 
  203    if (*
id > ioc->
fdcnt)
 
  207        ioc->
fds[*
id].fd = fd;
 
 
  220    int getfrom, putto = 0;
 
  227    for (getfrom = 0; getfrom < ioc->
fdcnt; getfrom++) {
 
  228        if (ioc->
ior[getfrom].
id) {
 
  230            if (getfrom != putto) {
 
  231                ioc->
fds[putto] = ioc->
fds[getfrom];
 
  232                ioc->
ior[putto] = ioc->
ior[getfrom];
 
  233                *(ioc->
ior[putto].
id) = putto;
 
 
  254    for (x = 0; x < ioc->
fdcnt; x++) {
 
  255        if (ioc->
ior[x].
id == _id) {
 
  259            ioc->
fds[x].events = 0;
 
  260            ioc->
fds[x].revents = 0;
 
 
  289    origcnt = ioc->
fdcnt;
 
  290    for (x = 0; x < origcnt; x++) {
 
  293        if (ioc->
fds[x].revents && ioc->
ior[x].
id) {
 
 
  321    ast_debug(1, 
"================================================\n");
 
  322    ast_debug(1, 
"| ID    FD     Callback    Data        Events  |\n");
 
  323    ast_debug(1, 
"+------+------+-----------+-----------+--------+\n");
 
  324    for (x = 0; x < ioc->
fdcnt; x++) {
 
  325        ast_debug(1, 
"| %.4d | %.4d | %p | %p | %.6x |\n",
 
  330                (
unsigned)ioc->
fds[x].events);
 
  332    ast_debug(1, 
"================================================\n");
 
 
  344    res = tcgetattr(fd, &tios);
 
  347    old = tios.c_lflag & (
ECHO | ECHONL);
 
  348    tios.c_lflag &= ~ECHO;
 
  349    tios.c_lflag |= ECHONL;
 
  350    res = tcsetattr(fd, TCSAFLUSH, &tios);
 
 
  362    res = tcgetattr(fd, &tios);
 
  365    tios.c_lflag &= ~(
ECHO | ECHONL);
 
  366    tios.c_lflag |= oldstate;
 
  367    res = tcsetattr(fd, TCSAFLUSH, &tios);
 
 
  381    if ( ioctl(fd, TIOCGWINSZ, &win) != -1 ) {
 
  382        if ( !cols && win.ws_col > 0 )
 
  383            cols = (int) win.ws_col;
 
 
  394    return sd_notify(0, 
state);
 
 
  409static int ast_sd_is_socket_sockaddr(
int fd, 
int type, 
const struct ast_sockaddr* addr)
 
  416    if (sd_is_socket(fd, AF_UNSPEC, 
type, 1) <= 0) {
 
  421    if (getsockname(fd, &ss, &ss_len) != 0) {
 
  425    if (ss.sa_family == AF_UNSPEC && canretry) {
 
  441    int count = sd_listen_fds(0);
 
  444    for (idx = 0; idx < count; idx++) {
 
  445        if (!ast_sd_is_socket_sockaddr(idx + SD_LISTEN_FDS_START, 
type, addr)) {
 
  446            return idx + SD_LISTEN_FDS_START;
 
 
  457    int count = sd_listen_fds(0);
 
  460    for (idx = 0; idx < count; idx++) {
 
  461        if (sd_is_socket_unix(idx + SD_LISTEN_FDS_START, 
type, 1, path, 0) > 0) {
 
  462            return idx + SD_LISTEN_FDS_START;
 
 
static const struct adsi_event events[]
Asterisk main include file. File version handling, generic pbx functions.
#define ast_realloc(p, len)
A wrapper for realloc()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
#define ast_debug(level,...)
Log a DEBUG message.
int ast_hide_password(int fd)
Hide password.
static int io_shrink(struct io_context *ioc)
struct io_context * io_context_create(void)
Create an I/O context.
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Add a new I/O entry for this file descriptor with the given event mask, to call callback with data as...
void io_context_destroy(struct io_context *ioc)
Destroys a context.
int * ast_io_change(struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data)
Changes an IO handler.
int ast_io_wait(struct io_context *ioc, int howlong)
Make the poll call, and call the callbacks for anything that needs to be handled.
int ast_io_remove(struct io_context *ioc, int *_id)
Removes an IO context.
int ast_sd_get_fd(int type, const struct ast_sockaddr *addr)
Find a listening file descriptor provided by socket activation.
int ast_get_termcols(int fd)
Columns of Terminal.
static int io_grow(struct io_context *ioc)
Grow the size of our arrays.
int ast_sd_notify(const char *state)
a wrapper for sd_notify(): notify systemd of any state changes.
void ast_io_dump(struct io_context *ioc)
Dumps the IO array.
int ast_sd_get_fd_un(int type, const char *path)
Find a listening AF_LOCAL file descriptor provided by socket activation.
int ast_restore_tty(int fd, int oldstate)
Restores TTY mode.
I/O Management (derived from Cheops-NG)
int(* ast_io_cb)(int *id, int fd, short events, void *cbdata)
static void ast_sockaddr_copy_sockaddr(struct ast_sockaddr *dst, struct sockaddr *src, socklen_t len)
Copies the data from a sockaddr to an ast_sockaddr.
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
#define ast_poll(a, b, c)
Socket address structure.
Global IO variables are now in a struct in order to be made threadsafe.
Kept for each file descriptor.