All pastes #622315 Raw Edit

Stuff

public text v1 · immutable
·published 2007-07-16 20:00 UTC
rendered paste body
In channel.c

/* Count number of channel spies by type, regardless of type */
int ast_channel_spy_count_by_type(struct ast_channel *chan, const char *type)
{
        int count = 0;
        struct ast_channel_spy *spy = NULL;

        if (!chan->spies)
                return count;

        AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
                if (spy->type == type)
                        count++;
        }
        AST_LIST_TRAVERSE_SAFE_END;
        return count;

}

/* Count number of channel spies by type that are running */
int ast_channel_spy_count_by_type_running(struct ast_channel *chan, const char *type)
{
        int count = 0;
        struct ast_channel_spy *spy = NULL;

        if (!chan->spies)
                return count;

        AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->spies->list, spy, list) {
                if ((spy->type == type) && (spy->status == CHANSPY_RUNNING))
                        count++;
        }
        AST_LIST_TRAVERSE_SAFE_END;
        return count;

}