Asterisk - The Open Source Telephony Project  18.5.0
Macros | Enumerations | Functions
vector.h File Reference

Vector container support. More...

#include "asterisk/lock.h"
Include dependency graph for vector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __make_room(idx, vec)
 
#define AST_VECTOR(name, type)
 Define a vector structure. More...
 
#define AST_VECTOR_ADD_SORTED(vec, elem, cmp)
 Add an element into a sorted vector. More...
 
#define AST_VECTOR_APPEND(vec, elem)
 Append an element to a vector, growing the vector if needed. More...
 
#define AST_VECTOR_CALLBACK(vec, callback, default_value, ...)
 Execute a callback on every element in a vector returning the first matched. More...
 
#define AST_VECTOR_CALLBACK_MULTIPLE(vec, callback, ...)
 Execute a callback on every element in a vector returning the matching elements in a new vector. More...
 
#define AST_VECTOR_CALLBACK_VOID(vec, callback, ...)
 Execute a callback on every element in a vector disregarding callback return. More...
 
#define AST_VECTOR_COMPACT(vec)
 Resize a vector so that its capacity is the same as its size. More...
 
#define AST_VECTOR_DEFAULT(vec, size, value)
 Default a vector up to size with the given value. More...
 
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
 Vector element cleanup that does nothing. More...
 
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)   ((elem) == (value))
 Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED() More...
 
#define AST_VECTOR_FREE(vec)
 Deallocates this vector. More...
 
#define AST_VECTOR_GET(vec, idx)
 Get an element from a vector. More...
 
#define AST_VECTOR_GET_ADDR(vec, idx)
 Get an address of element in a vector. More...
 
#define AST_VECTOR_GET_CMP(vec, value, cmp)
 Get an element from a vector that matches the given comparison. More...
 
#define AST_VECTOR_GET_INDEX(vec, value, cmp)   AST_VECTOR_GET_INDEX_NTH(vec, 1, value, cmp)
 Get the 1st index from a vector that matches the given comparison. More...
 
#define AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp)
 Get the nth index from a vector that matches the given comparison. More...
 
#define AST_VECTOR_INIT(vec, size)
 Initialize a vector. More...
 
#define AST_VECTOR_INSERT_AT(vec, idx, elem)
 Insert an element at a specific position in a vector, growing the vector if needed. More...
 
#define AST_VECTOR_MATCH_ALL(element)   (CMP_MATCH)
 Default callback for AST_VECTOR_CALLBACK() More...
 
#define AST_VECTOR_MAX_SIZE(vec)   (vec)->max
 Get the maximum number of elements the vector can currently hold. More...
 
#define AST_VECTOR_PTR_FREE(vec)
 Deallocates this vector pointer. More...
 
#define AST_VECTOR_REMOVE(vec, idx, preserve_ordered)
 Remove an element from a vector by index. More...
 
#define AST_VECTOR_REMOVE_ALL_CMP_ORDERED(vec, value, cmp, cleanup)
 Remove all elements from a vector that matches the given comparison while maintaining order. More...
 
#define AST_VECTOR_REMOVE_ALL_CMP_UNORDERED(vec, value, cmp, cleanup)
 Remove all elements from a vector that matches the given comparison. More...
 
#define AST_VECTOR_REMOVE_CMP_ORDERED(vec, value, cmp, cleanup)
 Remove an element from a vector that matches the given comparison while maintaining order. More...
 
#define AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup)
 Remove an element from a vector that matches the given comparison. More...
 
#define AST_VECTOR_REMOVE_ELEM_ORDERED(vec, elem, cleanup)
 Remove an element from a vector while maintaining order. More...
 
#define AST_VECTOR_REMOVE_ELEM_UNORDERED(vec, elem, cleanup)
 Remove an element from a vector. More...
 
#define AST_VECTOR_REMOVE_ORDERED(vec, idx)   AST_VECTOR_REMOVE(vec, idx, 1)
 Remove an element from a vector by index while maintaining order. More...
 
#define AST_VECTOR_REMOVE_UNORDERED(vec, idx)   AST_VECTOR_REMOVE(vec, idx, 0)
 Remove an element from an unordered vector by index. More...
 
#define AST_VECTOR_REPLACE(vec, idx, elem)
 Replace an element at a specific position in a vector, growing the vector if needed. More...
 
#define AST_VECTOR_RESET(vec, cleanup)
 Reset vector. More...
 
#define AST_VECTOR_RW(name, type)
 Define a vector structure with a read/write lock. More...
 
#define AST_VECTOR_RW_FREE(vec)
 Deallocates this locked vector. More...
 
#define AST_VECTOR_RW_INIT(vec, size)
 Initialize a vector with a read/write lock. More...
 
#define AST_VECTOR_RW_PTR_FREE(vec)
 Deallocates this locked vector pointer. More...
 
#define AST_VECTOR_RW_RDLOCK(vec)   ast_rwlock_rdlock(&(vec)->lock)
 Obtain read lock on vector. More...
 
#define AST_VECTOR_RW_RDLOCK_TIMED(vec, timespec)   ast_rwlock_timedrdlock(&(vec)->lock, timespec)
 Try to obtain read lock on vector failing after timeout if unable. More...
 
#define AST_VECTOR_RW_RDLOCK_TRY(vec)   ast_rwlock_tryrdlock(&(vec)->lock)
 Try to obtain read lock on vector failing immediately if unable. More...
 
#define AST_VECTOR_RW_UNLOCK(vec)   ast_rwlock_unlock(&(vec)->lock)
 Unlock vector. More...
 
#define AST_VECTOR_RW_WRLOCK(vec)   ast_rwlock_wrlock(&(vec)->lock)
 Obtain write lock on vector. More...
 
#define AST_VECTOR_RW_WRLOCK_TIMED(vec, timespec)   ast_rwlock_timedwrlock(&(vec)->lock, timespec)
 Try to obtain write lock on vector failing after timeout if unable. More...
 
#define AST_VECTOR_RW_WRLOCK_TRY(vec)   ast_rwlock_trywrlock(&(vec)->lock)
 Try to obtain write lock on vector failing immediately if unable. More...
 
#define AST_VECTOR_SIZE(vec)   (vec)->current
 Get the number of elements in a vector. More...
 
#define AST_VECTOR_SORT(vec, cmp)
 Sort a vector in-place. More...
 
#define AST_VECTOR_STEAL_ELEMENTS(vec)
 Steal the elements from a vector and reinitialize. More...
 

Enumerations

enum  ast_vector_string_split_flags { AST_VECTOR_STRING_SPLIT_NO_TRIM = 0x01, AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY = 0x02 }
 

Functions

 AST_VECTOR (ast_vector_int, int)
 Integer vector definition. More...
 
 AST_VECTOR (ast_vector_string, char *)
 String vector definitions. More...
 
 AST_VECTOR (ast_vector_const_string, const char *)
 
int ast_vector_string_split (struct ast_vector_string *dest, const char *input, const char *delim, int flags, int(*excludes_cmp)(const char *s1, const char *s2))
 Append a string vector by splitting a string. More...
 

Detailed Description

Vector container support.

A vector is a variable length array, with properties that can be useful when order doesn't matter.

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m
Since
12

Definition in file vector.h.

Macro Definition Documentation

◆ __make_room

#define __make_room (   idx,
  vec 
)

Definition at line 223 of file vector.h.

◆ AST_VECTOR

#define AST_VECTOR (   name,
  type 
)
Value:
struct name { \
type *elems; \
size_t max; \
size_t current; \
}
static const char name[]
Definition: cdr_mysql.c:74
#define max(a, b)
Definition: f2c.h:198

Define a vector structure.

Parameters
nameOptional vector struct name.
typeVector element type.

Definition at line 44 of file vector.h.

Referenced by AST_TEST_DEFINE(), and set_outbound_authentication_credentials().

◆ AST_VECTOR_ADD_SORTED

#define AST_VECTOR_ADD_SORTED (   vec,
  elem,
  cmp 
)

Add an element into a sorted vector.

Parameters
vecSorted vector to add to.
elemElement to insert. Must not be an array type.
cmpA strcmp compatible compare function.
Returns
0 on success.
Non-zero on failure.
Warning
Use of this macro on an unsorted vector will produce unpredictable results
'elem' must not be an array type so passing 'x' where 'x' is defined as 'char x[4]' will fail to compile. However casting 'x' as 'char *' does result in a value that CAN be used.

Definition at line 371 of file vector.h.

Referenced by alpha_module_list_create(), ast_rtp_read(), AST_TEST_DEFINE(), capture_buildopts_cb(), cli_completion_vector_add(), load_resource(), module_deps_missing_recursive(), rtp_instance_parse_transport_wide_cc(), subsystem_copy(), and vec_contact_add().

◆ AST_VECTOR_APPEND

#define AST_VECTOR_APPEND (   vec,
  elem 
)

Append an element to a vector, growing the vector if needed.

Parameters
vecVector to append to.
elemElement to append.
Returns
0 on success.
Non-zero on failure.

Definition at line 256 of file vector.h.

Referenced by __ast_bt_destroy(), __ast_bt_get_symbols(), __ast_calloc_with_stringfields(), __ast_string_field_init(), acf_curl_helper(), add_hintdevice(), app_control_move(), ast_cli_allow_at_shutdown(), ast_cli_completion_matches(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_dns_query_set_add(), ast_dns_txt_get_strings(), ast_el_strtoarr(), ast_msg_handler_register(), ast_msg_tech_register(), ast_multi_object_blob_add(), ast_optional_api_use(), ast_rtp_bundle(), ast_rtp_instance_extmap_enable(), ast_serializer_pool_create(), ast_sip_auth_vector_init(), ast_sip_retrieve_auths_vector(), ast_sip_session_media_add_read_callback(), ast_sip_session_media_stats_save(), ast_sip_transport_monitor_register_replace(), ast_stream_topology_append_stream(), ast_stream_topology_clone(), ast_stream_topology_map(), ast_stream_topology_set_stream(), AST_TEST_DEFINE(), ast_vector_string_split(), build_body_part(), build_expression_queue(), build_node_children(), cache_entry_create(), cache_udpate(), category_register(), create_artificial_endpoint(), create_virtual_subscriptions(), device_state_cb(), evaluate_history_entry(), exten_state_publisher_state_cb(), filter_history(), format_cap_framed_init(), get_or_create_subscription(), history_on_rx_msg(), history_on_tx_msg(), ident_handler(), list_item_handler(), map_source_to_destinations(), messaging_app_subscribe_endpoint(), module_deps_process_reqlist(), module_load_error(), module_reffed_deps_add(), moh_parse_options(), on_moh_file(), optional_api_create(), populate_list(), prometheus_callback_register(), prometheus_metric_register(), prometheus_metrics_provider_register(), publishers_create(), registry_message_cb(), resource_list_recursive_decline(), route_table_add(), rtp_instance_parse_transport_wide_cc(), save_response_fields_to_transport(), set_outbound_authentication_credentials(), sip_options_endpoint_compositor_add_task(), sip_outbound_registration_perform(), sip_resolve_add(), softmix_bridge_stream_topology_changed(), sorcery_memory_cache_thrash_create(), stasis_app_control_play_uri(), stasis_app_message_handler(), stasis_forward_all(), stasis_state_add_observer(), state_find_or_add_eid(), subscriptions_create(), subsystem_alert_increment(), test_files_create(), topic_add_subscription(), tree_node_alloc(), wizard_apply_handler(), and wizard_mapped_observer().

◆ AST_VECTOR_CALLBACK

#define AST_VECTOR_CALLBACK (   vec,
  callback,
  default_value,
  ... 
)

Execute a callback on every element in a vector returning the first matched.

Parameters
vecVector to operate on.
callbackA callback that takes at least 1 argument (the element) plus number of optional arguments
default_valueA default value to return if no elements matched
Returns
the first element matched before CMP_STOP was returned or the end of the vector was reached. Otherwise, default_value

Definition at line 768 of file vector.h.

Referenced by ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), AST_TEST_DEFINE(), and sorcery_object_load().

◆ AST_VECTOR_CALLBACK_MULTIPLE

#define AST_VECTOR_CALLBACK_MULTIPLE (   vec,
  callback,
  ... 
)

Execute a callback on every element in a vector returning the matching elements in a new vector.

This macro basically provides a filtered clone.

Parameters
vecVector to operate on.
callbackA callback that takes at least 1 argument (the element) plus number of optional arguments
Returns
a vector containing the elements matched before CMP_STOP was returned or the end of the vector was reached. The vector may be empty and could be NULL if there was not enough memory to allocate it's control structure.
Warning
The returned vector must have AST_VECTOR_PTR_FREE() called on it after you've finished with it.
Note
The type of the returned vector must be traceable to the original vector.

The following will resut in "error: assignment from incompatible pointer type" because these declare 2 different structures.

AST_VECTOR(, char *) vector_1;
AST_VECTOR(, char *) *vector_2;
vector_2 = AST_VECTOR_CALLBACK_MULTIPLE(&vector_1, callback);

This will work because you're using the type of the first to declare the second:

AST_VECTOR(mytype, char *) vector_1;
struct mytype *vector_2 = NULL;
vector_2 = AST_VECTOR_CALLBACK_MULTIPLE(&vector_1, callback);

This will also work because you're declaring both vector_1 and vector_2 from the same definition.

AST_VECTOR(, char *) vector_1, *vector_2 = NULL;
vector_2 = AST_VECTOR_CALLBACK_MULTIPLE(&vector_1, callback);

Definition at line 832 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_CALLBACK_VOID

#define AST_VECTOR_CALLBACK_VOID (   vec,
  callback,
  ... 
)

◆ AST_VECTOR_COMPACT

#define AST_VECTOR_COMPACT (   vec)

Resize a vector so that its capacity is the same as its size.

Parameters
vecVector to compact.
Returns
0 on success.
Non-zero on failure.

Definition at line 640 of file vector.h.

Referenced by moh_parse_options(), and moh_scan_files().

◆ AST_VECTOR_DEFAULT

#define AST_VECTOR_DEFAULT (   vec,
  size,
  value 
)

Default a vector up to size with the given value.

Note
If a size of 0 is given then all elements in the given vector are set.
The vector will grow to the given size if needed.
Parameters
vecVector to default.
sizeThe number of elements to default
valueThe default value to set each element to

Definition at line 309 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_ELEM_CLEANUP_NOOP

#define AST_VECTOR_ELEM_CLEANUP_NOOP (   elem)

◆ AST_VECTOR_ELEM_DEFAULT_CMP

#define AST_VECTOR_ELEM_DEFAULT_CMP (   elem,
  value 
)    ((elem) == (value))

Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()

Parameters
elemElement to compare against
valueValue to compare with the vector element.
Returns
0 if element does not match.
Non-zero if element matches.

Definition at line 564 of file vector.h.

Referenced by ast_stream_topology_map(), AST_TEST_DEFINE(), module_deps_missing_recursive(), module_reffed_deps_add(), optional_api_destroy(), resource_list_recursive_decline(), softmix_bridge_stream_topology_changed(), and start_resource_list().

◆ AST_VECTOR_FREE

#define AST_VECTOR_FREE (   vec)

Deallocates this vector.

If any code to free the elements of this vector needs to be run, that should be done prior to this call.

Parameters
vecVector to deallocate.

Definition at line 174 of file vector.h.

Referenced by __ast_internal_context_destroy(), __ast_string_field_free_memory(), __ast_string_field_init(), acf_curl_helper(), ast_channel_internal_cleanup(), ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_initialize(), ast_rtp_destroy(), ast_rtp_prop_set(), ast_sip_auth_vector_destroy(), ast_sip_session_media_state_free(), ast_stream_topology_map(), AST_TEST_DEFINE(), ast_update_module_list(), ast_update_module_list_condition(), ast_update_module_list_data(), bridge_channel_destroy(), build_expression_queue(), build_resource_tree(), cache_entry_dtor(), cli_completion_vector_add(), cli_subsystem_alert_report(), destroy_bridge(), destroy_hint(), destroy_subscription(), digest_create_request_with_auth(), dns_query_set_destroy(), endpoint_destructor(), evaluate_history_entry(), event_session_shutdown(), exten_state_pub_data_destroy(), filter_history(), format_cap_destroy(), free_body_parts(), instance_destructor(), internal_sip_session_media_state_alloc(), load_module(), load_modules(), load_resource_list(), message_shutdown(), message_subscription_dtor(), messaging_cleanup(), messaging_init(), module_deps_missing_recursive(), module_destroy(), moh_file_vector_destructor(), multi_object_blob_dtor(), optional_api_destroy(), playback_dtor(), publishers_destroy(), remove_excess_contacts(), resource_list_destructor(), resource_list_recursive_decline(), route_table_dtor(), safe_vector_cleanup(), session_destructor(), set_outbound_authentication_credentials(), sip_options_aor_dtor(), sip_resolve_callback(), sip_resolve_destroy(), softmix_bridge_data_destroy(), softmix_bridge_leave(), softmix_bridge_stream_topology_changed(), sorcery_memory_cache_thrash_destroy(), start_resource(), start_resource_list(), stasis_cleanup(), state_dtor(), stream_topology_destroy(), subscription_dtor(), subscriptions_destroy(), test_files_destroy(), topic_dtor(), transport_monitor_dtor(), tree_node_destroy(), unload_module(), and wizard_apply_handler().

◆ AST_VECTOR_GET

#define AST_VECTOR_GET (   vec,
  idx 
)
Value:
({ \
size_t __idx = (idx); \
ast_assert(__idx < (vec)->current); \
(vec)->elems[__idx]; \
})

Get an element from a vector.

Parameters
vecVector to query.
idxIndex of the element to get.

Definition at line 682 of file vector.h.

Referenced by __ast_context_destroy(), __ast_format_cap_get_names(), __ast_sorcery_object_type_remove_wizard(), __ast_string_fields_cmp(), __ast_string_fields_copy(), acf_curl_helper(), add_bundle_groups(), add_msid_to_stream(), allowed_on_shutdown(), append_backtrace_information(), ast_bridge_channel_queue_frame(), ast_channel_fd(), ast_cli_completion_vector(), ast_cli_display_match_list(), ast_context_ignorepats_get(), ast_context_includes_get(), ast_context_remove_ignorepat2(), ast_context_remove_include2(), ast_context_remove_switch2(), ast_context_switches_get(), ast_format_cap_append_from_cap(), ast_format_cap_empty(), ast_format_cap_get_best_by_type(), ast_format_cap_get_compatible(), ast_format_cap_get_format(), ast_format_cap_has_type(), ast_format_cap_iscompatible(), ast_format_cap_replace_from_cap(), ast_log_backtrace(), ast_moh_files_next(), ast_msg_has_destination(), ast_pjproject_get_buildopt(), ast_rtp_codecs_find_payload_code(), ast_rtp_codecs_get_payload(), ast_rtp_codecs_get_payload_format(), ast_rtp_codecs_get_stream_type(), ast_rtp_codecs_payload_code(), ast_rtp_codecs_payload_code_tx(), ast_rtp_codecs_payload_formats(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_copy(), ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_codecs_payloads_unset(), ast_rtp_codecs_payloads_xover(), ast_rtp_instance_extmap_get_id(), ast_rtp_instance_extmap_negotiate(), ast_serializer_pool_get(), ast_serializer_pool_set_alerts(), ast_sip_for_each_auth(), ast_sip_message_apply_transport(), ast_sip_retrieve_auths(), ast_sip_retrieve_auths_vector(), ast_sip_session_media_get_transport(), ast_sip_session_media_state_add(), ast_sip_session_media_state_clone(), ast_sip_session_media_stats_save(), ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_get_wizard_mapping(), ast_sorcery_is_stale(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), ast_stream_topology_clone(), ast_stream_topology_create_resolved(), ast_stream_topology_del_stream(), ast_stream_topology_get_active_count(), ast_stream_topology_get_first_stream_by_type(), ast_stream_topology_get_formats_by_type(), ast_stream_topology_get_stream(), ast_stream_topology_set_stream(), ast_stream_topology_to_str(), ast_taskprocessor_get_subsystem_alert(), AST_TEST_DEFINE(), ast_update_module_list(), ast_update_module_list_condition(), ast_update_module_list_data(), ast_walk_context_includes(), bridge_channel_handle_write(), bridge_channel_write_frame(), build_expression_queue(), build_node_children(), build_rlmi_body(), cache_entry_by_eid(), cache_entry_dtor(), cache_entry_dump(), cache_remove(), cache_udpate(), can_reuse_publish(), category_complete(), category_is_allowed(), chan_pjsip_indicate(), chan_pjsip_write_stream(), check_node(), cli_complete(), cli_print_body(), cli_subsystem_alert_report(), create_outgoing_sdp_stream(), create_virtual_subscriptions(), destroy_hint(), destroy_subscriptions(), dispatch_message(), display_entry_list(), enable_rtp_extension(), evaluate_history_entry(), event_session_shutdown(), event_session_update_websocket(), explicit_publish_cb(), exten_state_publisher_cb(), filter_history(), find_registrar_aor(), find_unused_payload_in_range(), find_wizard(), format_cap_destroy(), format_cap_replace(), format_in_format_cap(), free_body_parts(), generate_initial_notify(), generate_list_body(), get_subscription(), get_wrapper(), handle_aor(), handle_cli_moh_show_files(), handle_export_primitives(), handle_identify(), handle_msg_cb(), handle_negotiated_sdp(), handle_pjproject_show_buildopts(), handle_registrations(), has_destination_cb(), have_visited(), ident_to_str(), is_app_subscribed(), is_media_state_valid(), item_in_vector(), list_item_to_str(), load_dlopen_missing(), load_endpoint(), load_modules(), message_subscription_dtor(), module_deps_missing_recursive(), module_deps_process_reqlist(), msg_find_by_tech_name(), msg_handler_find_by_tech_name(), msg_q_cb(), multi_object_blob_dtor(), multi_object_blob_to_ami(), multi_user_event_to_json(), outbound_auths_to_var_list(), payload_mapping_rx_clear_primary(), payload_mapping_tx_is_present(), pjsip_show_history(), play_on_channel(), playback_dtor(), prometheus_callback_unregister(), prometheus_metric_register(), prometheus_metric_unregister(), publish_msg(), registration_deleted_observer(), registration_loaded_observer(), reload_module(), remb_collect_report(), remb_send_report(), remove_excess_contacts(), remove_hintdevice(), resolve_refresh_media_states(), resource_list_destructor(), resource_list_recursive_decline(), rtp_codecs_assign_payload_code_rx(), rtp_codecs_find_non_primary_dynamic_rx(), rtp_codecs_payload_replace_rx(), rtp_codecs_payloads_copy_rx(), rtp_codecs_payloads_copy_tx(), scrape_metrics(), set_channel_on_rtp_instance(), set_outbound_authentication_credentials(), set_remote_mslabel_and_stream_group(), set_state_terminated(), shutdown_subscriptions(), sip_options_endpoint_compositor_remove_task(), sip_options_notify_endpoint_state_compositors(), sip_options_publish_contact_state(), sip_options_qualify_contact(), sip_options_synchronize_aor_task(), sip_outbound_registration_perform(), sip_session_refresh(), softmix_bridge_stream_topology_changed(), sorcery_memory_cache_thrash_destroy(), sorcery_memory_cache_thrash_start(), sorcery_memory_cache_thrash_stop(), start_resource(), start_resource_list(), stasis_app_control_play_uri(), stasis_app_playback_to_json(), stasis_cache_entry_get_remote(), stasis_forward_all(), stasis_forward_cancel(), stasis_show_topic(), stasis_state_add_subscriber(), stasis_subscription_is_subscribed(), subscriber_dtor(), subscription_invoke(), subsystem_alert_decrement(), subsystem_alert_increment(), t38_reinvite_response_cb(), test_files_get_one(), test_is_media_state_equal(), topic_add_subscription(), topic_remove_subscription(), tree_node_destroy(), unload_module(), verify_bad_headers(), and verify_user_event_fields().

◆ AST_VECTOR_GET_ADDR

#define AST_VECTOR_GET_ADDR (   vec,
  idx 
)

◆ AST_VECTOR_GET_CMP

#define AST_VECTOR_GET_CMP (   vec,
  value,
  cmp 
)

Get an element from a vector that matches the given comparison.

Parameters
vecVector to get from.
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
Returns
a pointer to the element that was found or NULL

Definition at line 733 of file vector.h.

Referenced by __ast_sorcery_object_type_insert_wizard(), ast_rtcp_generate_nack(), ast_rtp_read(), AST_TEST_DEFINE(), ast_vector_string_split(), category_set_sublevel(), get_api(), module_deps_missing_recursive(), module_reffed_deps_add(), module_reffed_deps_add_dep_enhancers(), on_moh_file(), and resource_list_recursive_decline().

◆ AST_VECTOR_GET_INDEX

#define AST_VECTOR_GET_INDEX (   vec,
  value,
  cmp 
)    AST_VECTOR_GET_INDEX_NTH(vec, 1, value, cmp)

Get the 1st index from a vector that matches the given comparison.

Parameters
vecVector to get from.
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
Returns
a pointer to the element that was found or NULL

Definition at line 721 of file vector.h.

Referenced by ast_taskprocessor_get_subsystem_alert(), AST_TEST_DEFINE(), category_register(), subsystem_alert_decrement(), and subsystem_alert_increment().

◆ AST_VECTOR_GET_INDEX_NTH

#define AST_VECTOR_GET_INDEX_NTH (   vec,
  nth,
  value,
  cmp 
)

Get the nth index from a vector that matches the given comparison.

Parameters
vecVector to get from.
nthThe nth index to find
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
Returns
a pointer to the element that was found or NULL

Definition at line 698 of file vector.h.

Referenced by ast_stream_topology_map(), AST_TEST_DEFINE(), and softmix_bridge_stream_topology_changed().

◆ AST_VECTOR_INIT

#define AST_VECTOR_INIT (   vec,
  size 
)

Initialize a vector.

If size is 0, then no space will be allocated until the vector is appended to.

Parameters
vecVector to initialize.
sizeInitial size of the vector.
Returns
0 on success.
Non-zero on failure.

Definition at line 113 of file vector.h.

Referenced by __ast_bt_destroy(), __ast_bt_get_symbols(), __ast_calloc_with_stringfields(), __ast_channel_internal_alloc(), __ast_string_field_init(), acf_curl_helper(), alpha_module_list_create(), ast_add_hint(), ast_builtins_init(), ast_context_find_or_create(), ast_dns_query_set_create(), ast_dns_txt_get_strings(), ast_module_register(), ast_msg_init(), ast_multi_object_blob_create(), ast_rtp_codecs_payloads_initialize(), ast_rtp_instance_new(), ast_rtp_new(), ast_rtp_prop_set(), ast_sip_auth_vector_init(), ast_sip_endpoint_alloc(), ast_sip_service_route_vector_alloc(), ast_sip_session_alloc(), ast_stream_topology_alloc(), ast_stream_topology_map(), AST_TEST_DEFINE(), bridge_alloc(), build_expression_queue(), build_resource_tree(), cache_entry_create(), cli_subsystem_alert_report(), control_create(), create_artificial_endpoint(), create_virtual_subscriptions(), digest_create_request_with_auth(), evaluate_history_entry(), event_session_alloc(), exten_state_pub_data_alloc(), filter_history(), format_cap_init(), generate_list_body(), internal_sip_session_media_state_alloc(), internal_stasis_subscribe(), load_module(), load_modules(), load_resource_list(), messaging_init(), module_deps_missing_recursive(), moh_file_vector_alloc(), playback_create(), publishers_create(), remove_excess_contacts(), resource_list_alloc(), resource_list_recursive_decline(), set_outbound_authentication_credentials(), sip_options_aor_alloc(), sip_outbound_registration_perform(), sip_resolve(), sip_resolve_callback(), softmix_bridge_create(), softmix_bridge_stream_topology_changed(), sorcery_memory_cache_thrash_create(), start_resource(), start_resource_list(), stasis_init(), stasis_message_router_create_internal(), stasis_topic_create_with_detail(), state_alloc(), subscriptions_create(), test_files_create(), test_init_cb(), transport_state_callback(), tree_node_alloc(), and wizard_apply_handler().

◆ AST_VECTOR_INSERT_AT

#define AST_VECTOR_INSERT_AT (   vec,
  idx,
  elem 
)

Insert an element at a specific position in a vector, growing the vector if needed.

Parameters
vecVector to insert into.
idxPosition to insert at.
elemElement to insert.
Returns
0 on success.
Non-zero on failure.
Warning
This macro will shift existing elements right to make room for the new element.
Use of this macro with the expectation that the element will remain at the provided index means you can not use the UNORDERED assortment of macros. These macros alter the ordering of the vector itself.

Definition at line 338 of file vector.h.

Referenced by __ast_sorcery_object_type_insert_wizard(), ast_cli_completion_vector(), AST_TEST_DEFINE(), and prometheus_metric_unregister().

◆ AST_VECTOR_MATCH_ALL

#define AST_VECTOR_MATCH_ALL (   element)    (CMP_MATCH)

Default callback for AST_VECTOR_CALLBACK()

Parameters
elemElement to compare against
valueValue to compare with the vector element.
Returns
CMP_MATCH always.

Definition at line 754 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_MAX_SIZE

#define AST_VECTOR_MAX_SIZE (   vec)    (vec)->max

Get the maximum number of elements the vector can currently hold.

Parameters
vecVector to query.
Returns
Maximum number of elements the vector can currently hold.

Definition at line 619 of file vector.h.

Referenced by vec_contact_add().

◆ AST_VECTOR_PTR_FREE

#define AST_VECTOR_PTR_FREE (   vec)
Value:
do { \
AST_VECTOR_FREE(vec); \
ast_free(vec); \
} while (0)

Deallocates this vector pointer.

If any code to free the elements of this vector need to be run, that should be done prior to this call.

Parameters
vecPointer to a malloc'd vector structure.

Definition at line 189 of file vector.h.

Referenced by __ast_bt_free_symbols(), ast_cli_completion_matches(), ast_cli_completion_vector(), ast_dns_txt_free_strings(), ast_el_strtoarr(), AST_TEST_DEFINE(), cli_complete(), and filter_history().

◆ AST_VECTOR_REMOVE

#define AST_VECTOR_REMOVE (   vec,
  idx,
  preserve_ordered 
)

Remove an element from a vector by index.

Note that elements in the vector may be reordered, so that the remove can happen in constant time.

Parameters
vecVector to remove from.
idxIndex of the element to remove.
preserve_orderPreserve the vector order.
Returns
The element that was removed.

Definition at line 412 of file vector.h.

Referenced by ast_cli_completion_vector(), build_expression_queue(), evaluate_history_entry(), module_deps_missing_recursive(), prometheus_callback_unregister(), prometheus_metric_unregister(), registration_deleted_observer(), registration_loaded_observer(), sip_options_endpoint_compositor_remove_task(), sip_session_refresh(), start_resource_list(), and subsystem_alert_decrement().

◆ AST_VECTOR_REMOVE_ALL_CMP_ORDERED

#define AST_VECTOR_REMOVE_ALL_CMP_ORDERED (   vec,
  value,
  cmp,
  cleanup 
)

Remove all elements from a vector that matches the given comparison while maintaining order.

Parameters
vecVector to remove from.
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
cleanupHow to cleanup a removed element macro/function.
Returns
the number of deleted elements.

Definition at line 513 of file vector.h.

◆ AST_VECTOR_REMOVE_ALL_CMP_UNORDERED

#define AST_VECTOR_REMOVE_ALL_CMP_UNORDERED (   vec,
  value,
  cmp,
  cleanup 
)

Remove all elements from a vector that matches the given comparison.

Parameters
vecVector to remove from.
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
cleanupHow to cleanup a removed element macro/function.
Returns
the number of deleted elements.

Definition at line 461 of file vector.h.

Referenced by unload_module(), and wizard_apply_handler().

◆ AST_VECTOR_REMOVE_CMP_ORDERED

#define AST_VECTOR_REMOVE_CMP_ORDERED (   vec,
  value,
  cmp,
  cleanup 
)

Remove an element from a vector that matches the given comparison while maintaining order.

Parameters
vecVector to remove from.
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
cleanupHow to cleanup a removed element macro/function.
Returns
0 if element was removed.
Non-zero if element was not in the vector.

Definition at line 540 of file vector.h.

Referenced by __ast_sorcery_remove_wizard_mapping(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), ast_rtp_read(), AST_TEST_DEFINE(), and start_resource_list().

◆ AST_VECTOR_REMOVE_CMP_UNORDERED

#define AST_VECTOR_REMOVE_CMP_UNORDERED (   vec,
  value,
  cmp,
  cleanup 
)

Remove an element from a vector that matches the given comparison.

Parameters
vecVector to remove from.
valueValue to pass into comparator.
cmpComparator function/macros (called as cmp(elem, value))
cleanupHow to cleanup a removed element macro/function.
Returns
0 if element was removed.
Non-zero if element was not in the vector.

Definition at line 488 of file vector.h.

Referenced by ast_msg_handler_unregister(), ast_msg_tech_unregister(), ast_optional_api_unuse(), ast_rtp_bundle(), ast_rtp_destroy(), ast_sip_session_media_stats_save(), category_unregister(), messaging_app_unsubscribe_endpoint(), optional_api_destroy(), and route_table_remove().

◆ AST_VECTOR_REMOVE_ELEM_ORDERED

#define AST_VECTOR_REMOVE_ELEM_ORDERED (   vec,
  elem,
  cleanup 
)
Value:
({ \
AST_VECTOR_REMOVE_CMP_ORDERED((vec), (elem), \
})
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
Definition: vector.h:564
static void * cleanup(void *unused)
Definition: pbx_realtime.c:124

Remove an element from a vector while maintaining order.

Parameters
vecVector to remove from.
elemElement to remove
cleanupHow to cleanup a removed element macro/function.
Returns
0 if element was removed.
Non-zero if element was not in the vector.

Definition at line 600 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_REMOVE_ELEM_UNORDERED

#define AST_VECTOR_REMOVE_ELEM_UNORDERED (   vec,
  elem,
  cleanup 
)
Value:
({ \
AST_VECTOR_REMOVE_CMP_UNORDERED((vec), (elem), \
})
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
Definition: vector.h:564
static void * cleanup(void *unused)
Definition: pbx_realtime.c:124

Remove an element from a vector.

Parameters
vecVector to remove from.
elemElement to remove
cleanupHow to cleanup a removed element macro/function.
Returns
0 if element was removed.
Non-zero if element was not in the vector.

Definition at line 585 of file vector.h.

Referenced by remove_shutdown_command(), stasis_forward_cancel(), stasis_state_remove_observer(), and topic_remove_subscription().

◆ AST_VECTOR_REMOVE_ORDERED

#define AST_VECTOR_REMOVE_ORDERED (   vec,
  idx 
)    AST_VECTOR_REMOVE(vec, idx, 1)

Remove an element from a vector by index while maintaining order.

Parameters
vecVector to remove from.
idxIndex of the element to remove.
Returns
The element that was removed.

Definition at line 448 of file vector.h.

Referenced by __ast_context_destroy(), __ast_sorcery_object_type_remove_wizard(), ast_context_remove_ignorepat2(), ast_context_remove_include2(), ast_context_remove_switch2(), ast_stream_topology_del_stream(), and AST_TEST_DEFINE().

◆ AST_VECTOR_REMOVE_UNORDERED

#define AST_VECTOR_REMOVE_UNORDERED (   vec,
  idx 
)    AST_VECTOR_REMOVE(vec, idx, 0)

Remove an element from an unordered vector by index.

Note that elements in the vector may be reordered, so that the remove can happen in constant time.

Parameters
vecVector to remove from.
idxIndex of the element to remove.
Returns
The element that was removed.

Definition at line 438 of file vector.h.

Referenced by ast_sip_auth_vector_destroy(), AST_TEST_DEFINE(), cache_remove(), cache_udpate(), clear_result_states(), remove_hintdevice(), state_find_and_remove_eid(), and transport_monitor_unregister_cb().

◆ AST_VECTOR_REPLACE

#define AST_VECTOR_REPLACE (   vec,
  idx,
  elem 
)

Replace an element at a specific position in a vector, growing the vector if needed.

Parameters
vecVector to replace into.
idxPosition to replace.
elemElement to replace.
Returns
0 on success.
Non-zero on failure.
Warning
This macro will overwrite anything already present at the position provided.
Use of this macro with the expectation that the element will remain at the provided index means you can not use the UNORDERED assortment of macros. These macros alter the ordering of the vector itself.

Definition at line 284 of file vector.h.

Referenced by ast_channel_fd_add(), ast_channel_internal_fd_clear(), ast_channel_internal_fd_set(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_copy(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_codecs_payloads_unset(), ast_rtp_instance_extmap_clear(), ast_rtp_instance_extmap_enable(), ast_rtp_instance_extmap_negotiate(), ast_sip_session_media_state_add(), ast_sip_session_media_state_clone(), ast_stream_topology_map(), ast_stream_topology_set_stream(), AST_TEST_DEFINE(), format_cap_framed_init(), map_source_to_destinations(), payload_mapping_rx_clear_primary(), publish_msg(), remb_enable_collection(), resolve_refresh_media_states(), rtp_codecs_payload_replace_rx(), rtp_codecs_payloads_copy_tx(), softmix_bridge_stream_topology_changed(), stasis_subscription_accept_message_type(), stasis_subscription_decline_message_type(), test_media_add(), and verify_user_event_fields().

◆ AST_VECTOR_RESET

#define AST_VECTOR_RESET (   vec,
  cleanup 
)

◆ AST_VECTOR_RW

#define AST_VECTOR_RW (   name,
  type 
)

Define a vector structure with a read/write lock.

Parameters
nameOptional vector struct name.
typeVector element type.

Definition at line 93 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_RW_FREE

#define AST_VECTOR_RW_FREE (   vec)
Value:
do { \
AST_VECTOR_FREE(vec); \
ast_rwlock_destroy(&(vec)->lock); \
} while(0)
ast_mutex_t lock
Definition: app_meetme.c:1091

Deallocates this locked vector.

If any code to free the elements of this vector need to be run, that should be done prior to this call.

Parameters
vecVector to deallocate.

Definition at line 202 of file vector.h.

Referenced by ast_logger_category_unload(), ast_serializer_pool_destroy(), AST_TEST_DEFINE(), sorcery_object_type_destructor(), state_manager_dtor(), tps_shutdown(), and unload_module().

◆ AST_VECTOR_RW_INIT

#define AST_VECTOR_RW_INIT (   vec,
  size 
)

Initialize a vector with a read/write lock.

If size is 0, then no space will be allocated until the vector is appended to.

Parameters
vecVector to initialize.
sizeInitial size of the vector.
Returns
0 on success.
Non-zero on failure.

Definition at line 158 of file vector.h.

Referenced by ast_logger_category_load(), ast_serializer_pool_create(), AST_TEST_DEFINE(), ast_tps_init(), load_module(), sorcery_object_type_alloc(), and stasis_state_manager_create().

◆ AST_VECTOR_RW_PTR_FREE

#define AST_VECTOR_RW_PTR_FREE (   vec)
Value:
do { \
AST_VECTOR_RW_FREE(vec); \
ast_free(vec); \
} while(0)

Deallocates this locked vector pointer.

If any code to free the elements of this vector need to be run, that should be done prior to this call.

Parameters
vecPointer to a malloc'd vector structure.

Definition at line 215 of file vector.h.

◆ AST_VECTOR_RW_RDLOCK

#define AST_VECTOR_RW_RDLOCK (   vec)    ast_rwlock_rdlock(&(vec)->lock)

◆ AST_VECTOR_RW_RDLOCK_TIMED

#define AST_VECTOR_RW_RDLOCK_TIMED (   vec,
  timespec 
)    ast_rwlock_timedrdlock(&(vec)->lock, timespec)

Try to obtain read lock on vector failing after timeout if unable.

Parameters
vecVector to operate on.
Returns
0 if success
Non-zero if error

Definition at line 930 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_RW_RDLOCK_TRY

#define AST_VECTOR_RW_RDLOCK_TRY (   vec)    ast_rwlock_tryrdlock(&(vec)->lock)

Try to obtain read lock on vector failing immediately if unable.

Parameters
vecVector to operate on.
Returns
0 if success
Non-zero if error

Definition at line 910 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_RW_UNLOCK

#define AST_VECTOR_RW_UNLOCK (   vec)    ast_rwlock_unlock(&(vec)->lock)

◆ AST_VECTOR_RW_WRLOCK

#define AST_VECTOR_RW_WRLOCK (   vec)    ast_rwlock_wrlock(&(vec)->lock)

◆ AST_VECTOR_RW_WRLOCK_TIMED

#define AST_VECTOR_RW_WRLOCK_TIMED (   vec,
  timespec 
)    ast_rwlock_timedwrlock(&(vec)->lock, timespec)

Try to obtain write lock on vector failing after timeout if unable.

Parameters
vecVector to operate on.
Returns
0 if success
Non-zero if error

Definition at line 940 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_RW_WRLOCK_TRY

#define AST_VECTOR_RW_WRLOCK_TRY (   vec)    ast_rwlock_trywrlock(&(vec)->lock)

Try to obtain write lock on vector failing immediately if unable.

Parameters
vecVector to operate on.
Returns
0 if success
Non-zero if error

Definition at line 920 of file vector.h.

Referenced by AST_TEST_DEFINE().

◆ AST_VECTOR_SIZE

#define AST_VECTOR_SIZE (   vec)    (vec)->current

Get the number of elements in a vector.

Parameters
vecVector to query.
Returns
Number of elements in the vector.

Definition at line 611 of file vector.h.

Referenced by __ast_format_cap_get_names(), __ast_sorcery_object_type_insert_wizard(), __ast_sorcery_object_type_remove_wizard(), __ast_string_fields_cmp(), __ast_string_fields_copy(), __rtp_find_instance_by_ssrc(), _moh_register(), acf_curl_helper(), add_bundle_groups(), allowed_on_shutdown(), append_backtrace_information(), ast_bridge_channel_queue_frame(), ast_channel_fd(), ast_channel_fd_count(), ast_channel_internal_fd_clear(), ast_channel_internal_fd_set(), ast_cli_completion_vector(), ast_cli_display_match_list(), ast_context_ignorepats_count(), ast_context_includes_count(), ast_context_switches_count(), ast_dns_query_set_get(), ast_dns_query_set_num_queries(), ast_dns_query_set_resolve_async(), ast_dns_query_set_resolve_cancel(), ast_el_strtoarr(), ast_format_cap_append_from_cap(), ast_format_cap_count(), ast_format_cap_get_best_by_type(), ast_format_cap_get_compatible(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format(), ast_format_cap_get_format_framing(), ast_format_cap_has_type(), ast_format_cap_identical(), ast_format_cap_iscompatible(), ast_format_cap_iscompatible_format(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), ast_format_cap_replace_from_cap(), ast_log_backtrace(), ast_moh_files_next(), ast_msg_has_destination(), ast_optional_api_unuse(), ast_pjproject_get_buildopt(), ast_rtcp_generate_nack(), ast_rtp_codecs_find_payload_code(), ast_rtp_codecs_get_payload(), ast_rtp_codecs_get_payload_format(), ast_rtp_codecs_get_stream_type(), ast_rtp_codecs_payload_code(), ast_rtp_codecs_payload_code_tx(), ast_rtp_codecs_payload_formats(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_copy(), ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_codecs_payloads_unset(), ast_rtp_codecs_payloads_xover(), ast_rtp_instance_extmap_clear(), ast_rtp_instance_extmap_count(), ast_rtp_instance_extmap_enable(), ast_rtp_instance_extmap_get_direction(), ast_rtp_instance_extmap_get_extension(), ast_rtp_instance_extmap_get_id(), ast_rtp_instance_extmap_negotiate(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_set_remote_ssrc(), ast_serializer_pool_get(), ast_serializer_pool_set_alerts(), ast_sip_auth_vector_destroy(), ast_sip_auth_vector_init(), ast_sip_auths_to_str(), ast_sip_for_each_auth(), ast_sip_message_apply_transport(), ast_sip_retrieve_auths(), ast_sip_retrieve_auths_vector(), ast_sip_session_media_get_transport(), ast_sip_session_media_state_add(), ast_sip_session_media_state_clone(), ast_sip_session_media_stats_save(), ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_get_wizard_mapping(), ast_sorcery_get_wizard_mapping_count(), ast_sorcery_is_stale(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), ast_stream_topology_append_stream(), ast_stream_topology_clone(), ast_stream_topology_create_resolved(), ast_stream_topology_del_stream(), ast_stream_topology_get_active_count(), ast_stream_topology_get_count(), ast_stream_topology_get_first_stream_by_type(), ast_stream_topology_get_formats_by_type(), ast_stream_topology_map(), ast_stream_topology_set_stream(), ast_stream_topology_to_str(), AST_TEST_DEFINE(), ast_update_module_list(), ast_update_module_list_condition(), ast_update_module_list_data(), bridge_channel_handle_write(), bridge_channel_write_frame(), build_expression_queue(), build_node_children(), build_resource_tree(), build_rlmi_body(), cache_entry_by_eid(), cache_entry_dtor(), cache_entry_dump(), cache_remove(), cache_udpate(), can_reuse_publish(), category_complete(), category_is_allowed(), chan_pjsip_indicate(), chan_pjsip_read_stream(), chan_pjsip_write_stream(), check_node(), clear_result_states(), cli_complete(), cli_print_body(), cli_subsystem_alert_report(), control_next_app_args_size(), create_subscription_tree(), create_virtual_subscriptions(), destroy_hint(), destroy_subscriptions(), digest_check_auth(), digest_create_request_with_auth(), digest_requires_authentication(), dispatch_message(), display_entry_list(), dns_query_set_callback(), dns_query_set_destroy(), enable_rtp_extension(), evaluate_history_entry(), event_session_dtor(), event_session_shutdown(), event_session_update_websocket(), explicit_publish_cb(), exten_state_publisher_cb(), filter_history(), find_registrar_aor(), find_unused_payload_in_range(), find_wizard(), format_cap_destroy(), format_cap_framed_init(), format_cap_replace(), format_in_format_cap(), free_body_parts(), generate_initial_notify(), generate_list_body(), generate_notify_body(), get_subscription(), get_wrapper(), handle_aor(), handle_cli_moh_show_files(), handle_export_primitives(), handle_identify(), handle_msg_cb(), handle_negotiated_sdp(), handle_pjproject_show_buildopts(), handle_registrations(), has_destination_cb(), have_visited(), ident_handler(), ident_to_str(), internal_format_cap_identical(), is_app_subscribed(), is_media_state_valid(), item_in_vector(), list_item_to_str(), load_dlopen_missing(), load_endpoint(), load_module(), load_modules(), local_ast_moh_start(), message_subscription_dtor(), messaging_app_unsubscribe_endpoint(), module_deps_missing_recursive(), module_deps_process_reqlist(), moh_files_alloc(), moh_scan_files(), msg_find_by_tech_name(), msg_handler_find_by_tech_name(), msg_q_cb(), multi_object_blob_dtor(), multi_object_blob_to_ami(), multi_user_event_to_json(), optional_api_set_impl(), outbound_auths_to_var_list(), payload_mapping_rx_clear_primary(), payload_mapping_tx_is_present(), pjsip_show_history(), play_on_channel(), playback_dtor(), playback_final_update(), prometheus_callback_unregister(), prometheus_metric_register(), prometheus_metric_registered_count(), prometheus_metric_unregister(), publish_msg(), registration_deleted_observer(), registration_loaded_observer(), reload_module(), remb_collect_report(), remb_send_report(), remove_excess_contacts(), remove_hintdevice(), resolve_refresh_media_states(), resource_list_apply_handler(), resource_list_destructor(), resource_list_recursive_decline(), route_table_dtor(), route_table_find(), rtcp_debug_test_addr(), rtp_codecs_assign_payload_code_rx(), rtp_codecs_find_non_primary_dynamic_rx(), rtp_codecs_payload_replace_rx(), rtp_codecs_payloads_copy_rx(), rtp_codecs_payloads_copy_tx(), rtp_find_rtcp_fd_position(), rtp_instance_parse_transport_wide_cc(), rtp_transport_wide_cc_feedback_produce(), scrape_metrics(), set_channel_on_rtp_instance(), set_outbound_authentication_credentials(), set_outbound_initial_authentication_credentials(), set_remote_mslabel_and_stream_group(), set_state_terminated(), shutdown_subscriptions(), sip_options_aor_dtor(), sip_options_endpoint_compositor_remove_task(), sip_options_notify_endpoint_state_compositors(), sip_options_publish_contact_state(), sip_options_qualify_contact(), sip_options_synchronize_aor_task(), sip_outbound_registration_perform(), sip_session_refresh(), softmix_bridge_stream_topology_changed(), sorcery_memory_cache_thrash_create(), sorcery_memory_cache_thrash_destroy(), sorcery_memory_cache_thrash_start(), sorcery_memory_cache_thrash_stop(), start_resource(), start_resource_list(), stasis_app_playback_to_json(), stasis_cache_entry_get_remote(), stasis_forward_all(), stasis_forward_cancel(), stasis_show_topic(), stasis_state_add_subscriber(), stasis_subscription_decline_message_type(), stasis_subscription_is_subscribed(), stasis_topic_subscribers(), state_dtor(), state_find_and_remove_eid(), state_find_or_add_eid(), statistics_show_messages(), subscriber_dtor(), subscription_invoke(), t38_reinvite_response_cb(), test_is_media_state_equal(), topic_add_subscription(), topic_dtor(), topic_remove_subscription(), transport_monitor_dtor(), transport_monitor_unregister_cb(), transport_state_do_reg_callbacks(), tree_node_destroy(), unload_module(), vec_contact_add(), verify_bad_headers(), verify_user_event_fields(), and wait_for_device_state_updates().

◆ AST_VECTOR_SORT

#define AST_VECTOR_SORT (   vec,
  cmp 
)
Value:
({ \
qsort((vec)->elems, (vec)->current, sizeof(typeof((vec)->elems[0])), cmp); \
})
typedef typeof(dummy_tv_var_for_types.tv_sec) ast_time_t

Sort a vector in-place.

Parameters
vecVector to sort
cmpA memcmp compatible compare function

Definition at line 396 of file vector.h.

Referenced by moh_scan_files().

◆ AST_VECTOR_STEAL_ELEMENTS

#define AST_VECTOR_STEAL_ELEMENTS (   vec)
Value:
({ \
typeof((vec)->elems) __elems = (vec)->elems; \
AST_VECTOR_INIT((vec), 0); \
(__elems); \
})

Steal the elements from a vector and reinitialize.

Parameters
vecVector to operate on.

This allows you to use vector.h to construct a list and use the data as a bare array.

Note
The stolen array must eventually be released using ast_free.
Warning
AST_VECTOR_SIZE and AST_VECTOR_MAX_SIZE are both reset to 0. If either are needed they must be saved to a local variable before stealing the elements.

Definition at line 140 of file vector.h.

Referenced by ast_cli_completion_matches(), control_next_app_args(), and set_outbound_authentication_credentials().

Enumeration Type Documentation

◆ ast_vector_string_split_flags

Options to override default processing of ast_vector_string_split.

Enumerator
AST_VECTOR_STRING_SPLIT_NO_TRIM 

Do not trim whitespace from values.

AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY 

Append empty strings to the vector.

Definition at line 59 of file vector.h.

59  {
60  /*! Do not trim whitespace from values. */
62  /*! Append empty strings to the vector. */
64 };

Function Documentation

◆ AST_VECTOR() [1/3]

AST_VECTOR ( ast_vector_int  ,
int   
)

Integer vector definition.

◆ AST_VECTOR() [2/3]

AST_VECTOR ( ast_vector_string  ,
char *   
)

String vector definitions.

◆ AST_VECTOR() [3/3]

AST_VECTOR ( ast_vector_const_string  ,
const char *   
)

◆ ast_vector_string_split()

int ast_vector_string_split ( struct ast_vector_string *  dest,
const char *  input,
const char *  delim,
int  flags,
int(*)(const char *s1, const char *s2)  excludes_cmp 
)

Append a string vector by splitting a string.

Parameters
destPointer to an initialized vector.
inputString buffer to split.
delimString delimeter passed to strsep.
flagsProcessing options defined by enum ast_vector_string_split_flags.
excludes_cmpNULL or a function like strcmp to exclude duplicate strings.
Return values
0Success
-1Failure
Note
All elements added to the vector are allocated. The caller is always responsible for calling ast_free on each element in the vector even after failure. It's possible for this function to successfully add some elements before failing.

Definition at line 393 of file strings.c.

References ast_assert, ast_free, ast_strdup, ast_strdupa, ast_strip(), ast_strlen_zero, AST_VECTOR_APPEND, AST_VECTOR_GET_CMP, AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY, AST_VECTOR_STRING_SPLIT_NO_TRIM, buf, NULL, and strsep().

Referenced by module_post_register().

396 {
397  char *buf;
398  char *cur;
399  int no_trim = flags & AST_VECTOR_STRING_SPLIT_NO_TRIM;
400  int allow_empty = flags & AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY;
401 
402  ast_assert(dest != NULL);
403  ast_assert(!ast_strlen_zero(delim));
404 
405  if (ast_strlen_zero(input)) {
406  return 0;
407  }
408 
409  buf = ast_strdupa(input);
410  while ((cur = strsep(&buf, delim))) {
411  if (!no_trim) {
412  cur = ast_strip(cur);
413  }
414 
415  if (!allow_empty && ast_strlen_zero(cur)) {
416  continue;
417  }
418 
419  if (excludes_cmp && AST_VECTOR_GET_CMP(dest, cur, !excludes_cmp)) {
420  continue;
421  }
422 
423  cur = ast_strdup(cur);
424  if (!cur || AST_VECTOR_APPEND(dest, cur)) {
425  ast_free(cur);
426 
427  return -1;
428  }
429  }
430 
431  return 0;
432 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
#define ast_assert(a)
Definition: utils.h:695
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
static int input(yyscan_t yyscanner)
Definition: ast_expr2f.c:1584
#define ast_strlen_zero(foo)
Definition: strings.h:52
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:219
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define ast_free(a)
Definition: astmm.h:182
#define AST_VECTOR_GET_CMP(vec, value, cmp)
Get an element from a vector that matches the given comparison.
Definition: vector.h:733
char * strsep(char **str, const char *delims)