return iter;
}
+FT_DECLARE(ftdm_iterator_t *) ftdm_get_span_iterator(ftdm_iterator_t *iter)
+{
+ if (!(iter = ftdm_get_iterator(FTDM_ITERATOR_SPANS, iter))) {
+ return NULL;
+ }
+
+ iter->pvt.hashiter = hashtable_first(globals.span_hash);
+ return iter;
+}
+
FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter)
{
if (!span->chan_count) {
switch (iter->type) {
case FTDM_ITERATOR_VARS:
+ case FTDM_ITERATOR_SPANS:
if (!iter->pvt.hashiter) {
return NULL;
}
hashtable_this(iter->pvt.hashiter, &key, NULL, &val);
/* I decided to return the key instead of the value since the value can be retrieved using the key */
return (void *)key;
+ case FTDM_ITERATOR_SPANS:
+ hashtable_this(iter->pvt.hashiter, &key, NULL, &val);
+ return (void *)val;
case FTDM_ITERATOR_CHANS:
ftdm_assert_return(iter->pvt.chaniter.index, NULL, "channel iterator index cannot be zero!\n");
ftdm_assert_return(iter->pvt.chaniter.index <= iter->pvt.chaniter.span->chan_count, NULL, "channel iterator index bigger than span chan count!\n");
/*! \brief Get iterator current value (depends on the iterator type)
* \note Channel iterators return a pointer to ftdm_channel_t
+ * Span iterators return a pointer to ftdm_span_t
* Variable iterators return a pointer to the variable name (not the variable value)
*/
FT_DECLARE(void *) ftdm_iterator_current(ftdm_iterator_t *iter);
*/
FT_DECLARE(ftdm_iterator_t *) ftdm_span_get_chan_iterator(const ftdm_span_t *span, ftdm_iterator_t *iter);
+/*! \brief Get iterator for spans
+ * \param iter Optional iterator. You can reuse an old iterator (not previously freed) to avoid the extra allocation of a new iterator.
+ */
+FT_DECLARE(ftdm_iterator_t *) ftdm_get_span_iterator(ftdm_iterator_t *iter);
+
/*!
* \brief Execute a text command. The text command output will be returned and must be free'd
*