#include <sys/types.h>
#include <sys/select.h>
#include <sys/time.h>
#include <limits.h>
#include <unistd.h>
#include <ctype.h>
#include <strings.h>
#include "config.h"
#include "dprint.h"
#include "str.h"
#include "mem/mem.h"
#include "mem/shm_mem.h"

Go to the source code of this file.
Defines | |
| #define | append_chr(_dest, _c) *((_dest)++) = _c; |
| #define | append_str(_dest, _src, _len) |
| #define | INT2STR_MAX_LEN (1+19+1+1) |
| #define | MAX(a, b) (a>b?a:b) |
| #define | MIN(a, b) (a<b?a:b) |
| #define | str_init(_string) {_string, sizeof(_string) - 1} |
| #define | translate_pointer(_new_buf, _org_buf, _p) ( (_p)?(_new_buf + (_p-_org_buf)):(0) ) |
| #define | trim_len(_len, _begin, _mystr) |
| #define | trim_r(_mystr) |
| #define | trim_spaces_lr(_s_) |
| #define | via_len(_via) |
| #define | ZSW(_c) ((_c)?(_c):"") |
Functions | |
| int | group2gid (int *gid, char *group) |
| Converts a groupname into gid value. | |
| static int | hex2int (char hex_digit) |
| static int | hexstr2int (char *c, int len, unsigned int *val) |
| static char * | int2bstr (unsigned long l, char *s, int *len) |
| static int | int2reverse_hex (char **c, int *size, int nr) |
| static char * | int2str (unsigned long l, int *len) |
| static int | pathmax (void) |
| static int | pkg_str_dup (str *dst, const str *src) |
| static int | reverse_hex2int (char *c, int len) |
| void | seed_child (unsigned int seed) |
| static int | shm_str_dup (str *dst, const str *src) |
| static char * | sint2str (long l, int *len) |
| static void | sleep_us (unsigned int nusecs) |
| static int | str2int (str *_s, unsigned int *_r) |
| static unsigned short | str2s (const char *s, unsigned int len, int *err) |
| Converts a str to an unsigned short. | |
| static int | str2sint (str *_s, int *_r) |
| static int | str_strcasecmp (const str *str1, const str *str2) |
| Compare two str's case insensitive. | |
| static int | str_strcmp (const str *str1, const str *str2) |
| Compare two str's case sensitive. | |
| static int | string2hex (unsigned char *str, int len, char *hex) |
| static void | strlower (str *_s) |
| static int | strno2int (str *val, unsigned int *mask) |
| static int | un_escape (str *user, str *new_user) |
| int | user2uid (int *uid, int *gid, char *user) |
| Converts a username into uid and gid values. | |
Variables | |
| static char | fourbits2char [16] |
| char | int2str_buf [INT2STR_MAX_LEN] |
Definition in file ut.h.
| #define append_chr | ( | _dest, | |||
| _c | ) | *((_dest)++) = _c; |
append _c char to _dest string
Definition at line 113 of file ut.h.
Referenced by assemble_msg(), check_our_gws(), encode_avp_value(), encode_branch_info(), and generate_uris().
| #define append_str | ( | _dest, | |||
| _src, | |||||
| _len | ) |
Value:
do{ \ memcpy( (_dest) , (_src) , (_len) );\ (_dest) += (_len) ;\ }while(0);
Definition at line 106 of file ut.h.
Referenced by assemble_msg(), build_dlg_ack(), build_local(), build_res_buf_from_sip_req(), build_sipping(), build_uac_cancel(), build_uac_req(), check_our_gws(), encode_avp_value(), encode_branch_info(), generate_uris(), print_callid(), print_callid_mini(), print_cseq_mini(), print_from(), print_request_uri(), print_rs(), print_to(), push_on_network(), send_as_sms(), send_error(), send_sip_msg_request(), send_sip_options_request(), and send_sms_as_sip().
| #define INT2STR_MAX_LEN (1+19+1+1) |
Definition at line 174 of file ut.h.
Referenced by calc_buf_len(), encode_branch_info(), env_set_code_status(), extra2strar(), int2bstr(), legs2strar(), print_content_length(), print_cseq_num(), tlsops_cert_version(), and tlsops_sn().
| #define MAX | ( | a, | |||
| b | ) | (a>b?a:b) |
Definition at line 120 of file ut.h.
Referenced by add_interfaces(), PoolAlloc(), sst_dialog_created_CB(), and sst_dialog_response_fwded_CB().
| #define MIN | ( | a, | |||
| b | ) | (a<b?a:b) |
Definition at line 117 of file ut.h.
Referenced by ConnRead(), ConnWriteFromFile(), insert(), SessionGetReadData(), socketWrite(), and sst_check_min().
| #define str_init | ( | _string | ) | {_string, sizeof(_string) - 1} |
str initialization
Definition at line 58 of file ut.h.
Referenced by db_table_version(), dump_fifo(), get_auid_flag(), get_from_tag(), get_from_uri(), get_media_relay(), get_p_notify_body(), get_rules_doc(), get_session_direction(), get_sl_branch(), get_sphere(), get_to_tag(), get_to_uri(), get_user_agent(), mi_cpl_get(), msg_presentity_clean(), pack_ci(), pres_htable_restore(), resolv_blacklist_init(), save_route_data_recursor(), send_reply(), supported_transport(), tlsops_check_cert(), update_route_data(), and xj_worker_process().
| #define translate_pointer | ( | _new_buf, | |||
| _org_buf, | |||||
| _p | ) | ( (_p)?(_new_buf + (_p-_org_buf)):(0) ) |
Definition at line 95 of file ut.h.
Referenced by auth_body_cloner(), sip_msg_cloner(), uri_trans(), via_body_cloner(), and xlate_pointers().
| #define trim_len | ( | _len, | |||
| _begin, | |||||
| _mystr | ) |
returns string beginning and length without insignificant chars
Definition at line 62 of file ut.h.
Referenced by check_content_type(), extract_mediainfo(), extract_mediaip(), extract_rtcp(), get_sock_hdr(), is_maxfwd_present(), MD5StringArray(), run_language_switch(), run_priority_switch(), and run_string_switch().
| #define trim_r | ( | _mystr | ) |
| #define trim_spaces_lr | ( | _s_ | ) |
Value:
do{\ for(;(_s_).s[(_s_).len-1]==' ';(_s_).s[--(_s_).len]=0);\ for(;(_s_).s[0]==' ';(_s_).s=(_s_).s+1,(_s_).len--);\ }while(0);
Definition at line 87 of file ut.h.
Referenced by add_code_to_array(), and add_profile_definitions().
| #define via_len | ( | _via | ) |
Value:
((_via)->bsize-((_via)->name.s-\
((_via)->hdr.s+(_via)->hdr.len)))
Definition at line 100 of file ut.h.
Referenced by assemble_via(), build_dlg_ack(), build_local(), build_req_buf_from_sip_req(), build_res_buf_from_sip_res(), build_uac_cancel(), and via_builder().
| #define ZSW | ( | _c | ) | ((_c)?(_c):"") |
zero-string wrapper
Definition at line 54 of file ut.h.
Referenced by after_loose(), after_strict(), bdblib_valtochar(), check_nonce(), check_rule(), check_username(), child_init(), comp_scriptvar(), db_mysql_new_connection(), db_postgres_new_connection(), db_table_version(), db_unixodbc_new_connection(), do_query(), dp_apply_policy(), dp_can_connect(), dp_can_connect_str(), dump_hdr_field(), enum_pv_query_3(), generate_avps(), get_ha1(), get_hdr_field(), hash_table_mi_print(), init(), init_tls_domains(), is_domain_local(), is_from_user_enum_2(), is_user_in(), ldap_url_search(), load_metadata_defaults(), lookup(), mi_usrloc_show_contact(), mod_init(), nodb_timer(), parse_disposition(), parse_first_line(), parse_headers(), parse_msg(), parse_orig_ruri(), parse_to(), parse_to_param(), parse_uri(), parse_via(), parse_via_param(), print_action(), print_event(), print_expires(), print_expr(), print_nameaddr(), print_ucontact(), print_udomain(), print_urecord(), pv_fetch_contacts(), register_udomain(), registered(), save_ruri(), stack_to_avp(), tls_tcpconn_init(), uri2proxy(), wb_timer(), and wt_timer().
| int group2gid | ( | int * | gid, | |
| char * | group | |||
| ) |
Converts a groupname into gid value.
| gid | group id | |
| group | group name |
Definition at line 80 of file ut.c.
Referenced by main(), and mi_mod_init().
| static int hex2int | ( | char | hex_digit | ) | [inline, static] |
Definition at line 338 of file ut.h.
References LM_ERR.
Referenced by decode_mail_url(), and un_escape().
| static int hexstr2int | ( | char * | c, | |
| int | len, | |||
| unsigned int * | val | |||
| ) | [inline, static] |
| static char* int2bstr | ( | unsigned long | l, | |
| char * | s, | |||
| int * | len | |||
| ) | [inline, static] |
Definition at line 178 of file ut.h.
References INT2STR_MAX_LEN, and LM_CRIT.
Referenced by env_set_code_status(), int2str(), legs2strar(), print_content_length(), and print_cseq_num().
| static int int2reverse_hex | ( | char ** | c, | |
| int * | size, | |||
| int | nr | |||
| ) | [inline, static] |
Definition at line 245 of file ut.h.
Referenced by add_dlg_rr_param(), assemble_msg(), branch_builder(), build_sipping(), crcitt_string_array(), id_builder(), init_sip_ping(), and init_synonym_id().
| static char* int2str | ( | unsigned long | l, | |
| int * | len | |||
| ) | [inline, static] |
Definition at line 200 of file ut.h.
References int2bstr(), and int2str_buf.
Referenced by add_mi_sdp_nodes(), add_mi_sdp_payload_nodes(), add_mi_session_nodes(), add_mi_stream_nodes(), add_retry_after(), assemble_msg(), bla_process_body(), build_contact(), build_res_buf_from_sip_req(), build_str_hdr(), check_our_gws(), clen_builder(), constr_rlmi_doc(), create_rcv_uri(), db_postgres_new_connection(), dbrow2avp(), dlg2hash(), do_load_gws(), do_uac_auth(), ds_print_mi_list(), encode_avp_value(), encode_branch_info(), fix_socket_list(), force_rtp_proxy(), get_name(), get_wi_notify_body(), imc_mi_list_members(), imc_mi_list_rooms(), init_acc_extra(), init_extra_engine(), int_str2db_val(), internal_mi_print_dlg(), mi_add_aor_node(), mi_datagram_write_tree(), mi_get_pipes(), mi_get_profile(), mi_get_queues(), mi_print_blacklists(), mi_print_gws(), mi_print_lcrs(), mi_ps(), mi_show_rtpproxies(), mi_stats(), mi_tm_hash(), mi_usrloc_dump(), mi_write_tree(), ops_copy_avp(), ops_pushto_avp(), parse_avp_db(), publ_build_hdr(), pv_get_dlg_count(), pv_get_dlg_lifetime(), pv_get_dlg_status(), pv_get_random_val(), pv_get_tm_branch_idx(), pv_get_tm_reply_code(), pv_get_uintval(), rl_timer(), rport_builder(), send_2XX_reply(), send_sip_options_request(), set_body_f(), sint2str(), sip_trace(), sst_dialog_mi_context_CB(), subs_build_hdr(), t_check_status(), timer_send_notify(), tlsops_bits(), tlsops_cert_version(), tlsops_sn(), trace_onreply_in(), trace_onreply_out(), trace_onreq_out(), trace_sl_onreply_out(), and use_media_proxy().
| static int pathmax | ( | void | ) | [inline, static] |
Definition at line 324 of file ut.h.
References PATH_MAX_GUESS.
Referenced by get_name(), and mi_pwd().
Definition at line 515 of file ut.h.
References _str::len, LM_ERR, NULL, pkg_malloc, and _str::s.
Referenced by parse_avp_db().
| static int reverse_hex2int | ( | char * | c, | |
| int | len | |||
| ) | [inline, static] |
Definition at line 227 of file ut.h.
Referenced by forward_reply(), parse_dlg_rr_param(), and t_reply_matching().
| void seed_child | ( | unsigned int | seed | ) |
utility function to give each children a unique seed
Definition at line 102 of file ut.c.
Referenced by internal_fork().
Definition at line 499 of file ut.h.
References _str::len, LM_ERR, _str::s, and shm_malloc().
Referenced by ac_uac_req(), add_failure_route_rule(), add_route_rule(), dlg_add_extra(), dlg_confirmed_resp_uac(), dlg_request_uas(), new_dlg_uac(), new_dlg_uas(), new_ucontact(), request2dlg(), and response2dlg().
| static char* sint2str | ( | long | l, | |
| int * | len | |||
| ) | [inline, static] |
Definition at line 208 of file ut.h.
References int2str().
Referenced by comp_strval(), mi_debug(), and pv_get_sintval().
| static void sleep_us | ( | unsigned int | nusecs | ) | [inline, static] |
Definition at line 314 of file ut.h.
References NULL.
Referenced by add_list_to_head(), check_against_rule_list(), delete_expired(), m_usleep(), mi_open_reply_pipe(), mi_print_blacklists(), pdt_load_db(), prefix2domain(), reload_permanent_list(), reload_route_data(), and wait_async_reply().
| static int str2int | ( | str * | _s, | |
| unsigned int * | _r | |||
| ) | [inline, static] |
Definition at line 437 of file ut.h.
References _str::len, and _str::s.
Referenced by ac_uac_req(), add_code_to_array(), allow_address(), bla_handle_notify(), build_dlg_t(), calc_contact_expires(), check_user_blacklist_fixup(), dbrow2avp(), decode_avp_value(), decode_branch_info(), ds_mi_set(), encode_cseq(), encode_proxy_attr(), encode_reject_attr(), extra2int(), extract_avp(), extract_sdialog_info(), fixstringloadgws(), fixup_delete_avp(), fixup_gflags(), fixup_prob(), fixup_sl_send_reply(), fixup_t_send_reply(), fixup_uint(), get_cseq_value(), get_register_expire(), load_gws_from_grp(), mi_check_msg(), mi_mod_init(), mi_pua_publish(), mi_pua_subscribe(), mi_refreshWatchers(), mi_set_prob(), mi_tm_reply(), mi_usrloc_add(), mod_init(), nathelper_add_rtpproxy_set(), ops_copy_avp(), pack_ci(), parse_avp_db(), parse_avp_name(), parse_phostport(), parse_subs_state(), pxml_add_xcap_server(), refreshXcapDoc(), stack_to_avp(), strno2int(), subs_cback_func(), update_presentity(), w_pv_t_reply(), w_rl_check_forced(), w_send_reply(), and w_sl_send_reply().
| static unsigned short str2s | ( | const char * | s, | |
| unsigned int | len, | |||
| int * | err | |||
| ) | [inline, static] |
Converts a str to an unsigned short.
Definition at line 134 of file ut.h.
References init(), and LM_DBG.
Referenced by avp2timer(), check_memory(), dp_trans_fixup(), fetchsms(), fixup_maxfwd_header(), fixup_set_id(), fixup_stat(), fixup_var_str_int(), get_nr_max(), is_maxfwd_present(), mi_translate(), parse_db_url(), parse_via(), seas_init(), set_modem_arg(), set_network_arg(), start_stats_server(), and update_sock_struct_from_via().
| static int str2sint | ( | str * | _s, | |
| int * | _r | |||
| ) | [inline, static] |
Definition at line 457 of file ut.h.
References _str::len, _str::s, and s.
Referenced by fixup_igp(), get_fifo_opts(), h350_call_preferences(), ldap_write_result(), mi_debug(), and parse_intstr_value().
Compare two str's case insensitive.
| str1 | first str | |
| str2 | second str |
Definition at line 557 of file ut.h.
References _str::len, LM_ERR, NULL, and _str::s.
Referenced by get_fifo_opts(), and load_config().
Compare two str's case sensitive.
| str1 | first str | |
| str2 | second str |
Definition at line 535 of file ut.h.
References _str::len, LM_ERR, NULL, and _str::s.
Referenced by carrier_data_fixup(), find_rule_by_host(), map_name2id(), pdt_add_to_tree(), pdt_get_domain(), pdt_get_tree(), and set_next_domain_on_rule().
| static int string2hex | ( | unsigned char * | str, | |
| int | len, | |||
| char * | hex | |||
| ) | [inline, static] |
Definition at line 287 of file ut.h.
References fourbits2char.
Referenced by calc_nonce(), compute_md5(), MD5File(), and MD5StringArray().
| static void strlower | ( | str * | _s | ) | [inline, static] |
Definition at line 424 of file ut.h.
References _str::len, and _str::s.
Referenced by cpl_init(), extract_aor(), and mi_fix_aor().
| static int strno2int | ( | str * | val, | |
| unsigned int * | mask | |||
| ) | [inline, static] |
Definition at line 485 of file ut.h.
References hexstr2int(), _str::len, _str::s, and str2int().
Referenced by flag_fixup(), mi_enable_natping(), mi_enable_rtp_proxy(), mi_is_gflag(), mi_reset_gflag(), mi_set_dbg(), mi_set_gflag(), mi_set_pipe(), mi_set_queue(), mi_terminate_dlg(), and save_fixup().
Definition at line 364 of file ut.h.
References hex2int(), _str::len, LM_CRIT, LM_ERR, and _str::s.
Referenced by authorize(), and extract_aor().
| int user2uid | ( | int * | uid, | |
| int * | gid, | |||
| char * | user | |||
| ) |
char fourbits2char[16] [static] |
Initial value:
{ '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }
Definition at line 125 of file ut.h.
Referenced by string2hex().
| char int2str_buf[INT2STR_MAX_LEN] |
1.5.6