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; }