Thu Apr 8 01:23:59 2010

Asterisk developer's documentation


ast_str Struct Reference

The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field to indicate the type of storage. Three special constants indicate malloc, alloca() or static variables, all other values indicate a struct ast_threadstorage pointer. More...

#include <strings.h>

Collaboration diagram for ast_str:
Collaboration graph
[legend]

Data Fields

size_t len
char str [0]
struct ast_threadstoragets
size_t used

Detailed Description

The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field to indicate the type of storage. Three special constants indicate malloc, alloca() or static variables, all other values indicate a struct ast_threadstorage pointer.

Support for dynamic strings.

A dynamic string is just a C string prefixed by a few control fields that help setting/appending/extending it using a printf-like syntax.

One should never declare a variable with this type, but only a pointer to it, e.g.

struct ast_str *ds;

The pointer can be initialized with the following:

ds = ast_str_create(init_len); creates a malloc()'ed dynamic string;

ds = ast_str_alloca(init_len); creates a string on the stack (not very dynamic!).

ds = ast_str_thread_get(ts, init_len) creates a malloc()'ed dynamic string associated to the thread-local storage key ts

Finally, the string can be manipulated with the following:

ast_str_set(&buf, max_len, fmt, ...) ast_str_append(&buf, max_len, fmt, ...)

and their varargs variant

ast_str_set_va(&buf, max_len, ap) ast_str_append_va(&buf, max_len, ap)

Parameters:
max_len The maximum allowed capacity of the ast_str. Note that if the value of max_len is less than the current capacity of the ast_str (as returned by ast_str_size), then the parameter is effectively ignored. 0 means unlimited, -1 means "at most the available space"
Returns:
All the functions return <0 in case of error, or the length of the string added to the buffer otherwise. Note that in most cases where an error is returned, characters ARE written to the ast_str.

Definition at line 345 of file strings.h.


Field Documentation

size_t len

The current maximum length of the string

Definition at line 346 of file strings.h.

Referenced by acf_odbc_read(), acf_odbc_write(), add_sdp(), ast_str_thread_get(), cli_prompt(), copy_request(), handle_dbget(), load_config(), pbx_find_extension(), and pgsql_reconnect().

char str[0]

The string buffer

Definition at line 352 of file strings.h.

Referenced by __ast_verbose_ap(), __manager_event(), __queues_show(), __sip_pretend_ack(), __sip_reliable_xmit(), __sip_semi_ack(), __sip_xmit(), _sip_show_peer(), acf_curl_exec(), acf_odbc_read(), acf_odbc_write(), action_createconfig(), action_status(), action_userevent(), add_sdp(), ALLOC_COMMENT(), ast_agi_send(), ast_cli(), ast_eivr_getvariable(), ast_log(), astman_append(), build_peer(), cdr_handler(), chanavail_exec(), check_auth(), cli_match_char_tree(), cli_prompt(), config_curl(), config_text_file_load(), copy_request(), dahdi_new(), destroy_curl(), destroy_pgsql(), determine_firstline_parts(), dumpchan_exec(), eivr_comm(), find_table(), function_sippeer(), handle_dbget(), handle_request_do(), handle_show_chanvar(), handle_showchan(), http_post_callback(), httpd_helper_thread(), iax_parse_ies(), initreqprep(), load_column_config(), log_jack_status(), log_match_char_tree(), manager_log(), meetme_cmd(), odbc_log(), parse_request(), pbx_find_extension(), pgsql_reconnect(), print_uptimestr(), process_sdp(), realtime_curl(), realtime_ldap_base_ap(), realtime_multi_curl(), require_curl(), require_pgsql(), retrans_pkt(), run_station(), say_periodic_announcement(), send_eivr_event(), send_request(), send_response(), show_channels_cb(), sip_hangup(), sip_send_mwi_to_peer(), sip_show_sched(), sqlite3_log(), store_curl(), store_pgsql(), substitute_escapes(), transmit_fake_auth_response(), transmit_notify_with_mwi(), transmit_state_notify(), update_curl(), update_ldap(), update_pgsql(), userevent_exec(), and vars2manager().

struct ast_threadstorage* ts [read]

What kind of storage is this ?

Definition at line 348 of file strings.h.

Referenced by ast_str_thread_get().

size_t used

The documentation for this struct was generated from the following file:

Generated on 8 Apr 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1