Tor 0.4.9.3-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
printf.h File Reference

Header for printf.c. More...

#include "orconfig.h"
#include "lib/cc/compat_compiler.h"
#include <stdarg.h>
#include <stddef.h>

Go to the source code of this file.

Functions

int tor_snprintf (char *str, size_t size, const char *format,...)
 
int tor_vsnprintf (char *str, size_t size, const char *format, va_list args)
 
int tor_asprintf (char **strp, const char *fmt,...)
 
int tor_vasprintf (char **strp, const char *fmt, va_list args)
 

Detailed Description

Header for printf.c.

Definition in file printf.h.

Function Documentation

◆ tor_asprintf()

int tor_asprintf ( char **  strp,
const char *  fmt,
  ... 
)

Portable asprintf implementation. Does a printf() into a newly malloc'd string. Sets *strp to this string, and returns its length (not including the terminating NUL character).

You can treat this function as if its implementation were something like

  char buf[_INFINITY_];
  tor_snprintf(buf, sizeof(buf), fmt, args);
  *strp = tor_strdup(buf);
  return strlen(*strp):

Where INFINITY is an imaginary constant so big that any string can fit into it.

Definition at line 75 of file printf.c.

Referenced by addressmap_rewrite_reverse(), authority_certs_fetch_missing(), bridge_resolve_conflicts(), bridgeauth_dump_bridge_status_to_file(), bytes_to_usage(), channel_tls_describe_transport_method(), check_and_create_data_directory(), check_descriptor_ipaddress_changed(), check_one_family_cert(), circuit_build_times_update_state(), circuit_log_ancient_one_hop_circuits(), clear_trackexithost_mappings(), client_dns_set_addressmap_impl(), client_dns_set_reverse_addressmap(), clock_skew_warning(), compute_frac_paths_available(), compute_nth_protocol_set(), config_assign_line(), config_check_immutable_flags(), config_ensure_bandwidth_cap(), config_load_geoip_file_(), config_parse_units(), congestion_control_get_control_port_fields(), conn_stats_format(), consider_recording_trackhost(), control_cmd_parse_args(), control_event_address_mapped(), control_event_bootstrap_problem(), control_event_descriptors_changed(), control_event_hs_descriptor_created(), control_event_hs_descriptor_requested(), control_event_hs_descriptor_upload(), control_event_hs_descriptor_upload_end(), control_event_hsv3_descriptor_failed(), control_event_stream_status(), correct_tm(), desc_decode_encrypted_v3(), dir_server_new(), directory_get_consensus_url(), directory_send_command(), dirserv_get_flag_thresholds_line(), dirvote_compute_consensuses(), disk_state_put_commit_line(), disk_state_put_srv_line(), disk_state_save_to_disk(), do_keygen_family(), download_status_to_string(), dump_desc(), dump_desc_populate_one_file(), ed_key_init_from_file(), encode_enc_key(), encode_legacy_key(), encode_onion_key(), esc_router_info(), event_hs_descriptor_receive_end(), expand_filename(), extrainfo_dump_to_string_header_helper(), format_client_stats_heartbeat(), format_networkstatus_vote(), format_protocols_lines_for_vote(), geoip_format_bridge_stats(), geoip_format_dirreq_stats(), geoip_format_entry_stats(), get_auth_client_str(), get_client_auth_creds_filename(), get_first_listener_addrport_string(), get_glob_paths(), get_pt_proxy_uri(), get_srv_element_from_commit(), get_stored_bindaddr_for_server_transport(), get_transport_bindaddr(), get_vote_line_from_commit(), getinfo_helper_accounting(), getinfo_helper_dir(), getinfo_helper_events(), getinfo_helper_format_single_entry_guard(), getinfo_helper_geoip(), getinfo_helper_misc(), getinfo_helper_rephist(), guard_selection_get_err_str_if_dir_info_missing(), handle_control_extendcircuit(), have_enough_mem_for_dircache(), hs_lookup_last_hid_serv_request(), hs_parse_port_config(), hs_path_from_filename(), initiate_descriptor_downloads(), kvline_check_keyword_args(), learned_router_identity(), make_path_absolute(), metrics_parse_ports(), networkstatus_check_required_protocols(), networkstatus_compute_consensus(), node_log_dup_ed_id(), normalize_nickname_list(), options_get_dir_fname2_suffix(), options_init_from_string(), options_validate_cb(), options_validate_publish_server(), options_validate_relay_bandwidth(), options_validate_relay_info(), options_validate_relay_mode(), or_state_save(), or_state_save_broken(), parse_http_url(), parse_virtual_addr_network(), pem_decode(), policy_summarize(), pt_get_extra_info_descriptor_string(), pt_update_bridge_lines(), rate_limit_log(), reachability_warnings_callback(), rep_hist_format_buffer_stats(), rep_hist_format_desc_stats(), rep_hist_format_exit_stats(), rep_hist_format_hs_stats(), rep_hist_get_overload_general_line(), rep_hist_get_padding_count_lines(), rep_hist_log_link_protocol_counts(), router_dump_router_to_string(), router_write_fingerprint(), save_transport_to_state(), secs_to_uptime(), should_service_upload_descriptor(), sr_get_string_for_vote(), srv_to_control_string(), srv_to_ns_string(), start_writing_to_file(), storage_dir_clean_tmpfiles(), storage_dir_get_usage(), storage_dir_map(), storage_dir_read(), storage_dir_register_with_sandbox(), storage_dir_remove_file(), storage_dir_save_chunks_to_file(), storage_dir_shrink(), store_permanent_client_auth_credentials(), tor_assertion_failed_(), tor_bug_occurred_(), tor_listdir(), tor_sockaddr_to_str(), typed_var_kvassign(), validate_data_directories(), validate_ports_csv(), warn_early_consensus(), write_address_to_file(), write_configuration_file(), and write_short_http_response().

◆ tor_snprintf()

int tor_snprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

Replacement for snprintf. Differs from platform snprintf in two ways: First, always NUL-terminates its output. Second, always returns -1 if the result is truncated. (Note that this return behavior does not conform to C99; it just happens to be easier to emulate "return -1" with conformant implementations than it is to emulate "return number that would be written" with non-conformant implementations.)

Definition at line 27 of file printf.c.

Referenced by bwhist_fill_bandwidth_history(), circuit_purpose_to_controller_string(), circuit_purpose_to_string(), circuit_state_to_string(), conn_state_to_string(), conn_type_to_string(), connection_ap_handshake_send_begin(), connection_describe(), connection_describe_peer_internal(), connection_https_proxy_connect(), connection_or_compute_authenticate_cell_body(), connection_or_get_state_description(), consdiff_gen_diff(), consensus_diff_worker_replyfn(), control_event_bootstrap_core(), control_event_bootstrap_problem(), control_event_circuit_status(), control_event_circuit_status_minor(), control_event_guard(), control_event_or_conn_status(), control_event_status(), control_event_stream_status(), copy_ipv6_address(), crypto_write_tagged_contents_to_file(), describe_portnum(), describe_relay_port(), directory_send_command(), dirserv_add_multiple_descriptors(), dirvote_compute_params(), dirvote_format_microdesc_vote_line(), domain_to_string(), dump_microdescriptor(), ed_key_init_from_file(), entry_guard_describe(), esc_for_log(), find_unused_fname(), fmt_addrport(), format_iso_time_nospace_usec(), format_labels(), format_msg(), format_time_interval(), gen_ed_diff(), get_consensus_param_exit_dns_attempts(), get_consensus_param_exit_dns_timeout(), get_default_conf_file(), get_next_token(), get_platform_str(), get_uname(), hibernate_state_to_string(), hs_service_upload_desc_to_dir(), keypin_open_journal(), load_downloaded_routers(), log_ed_cert_expiration(), log_prefix_(), log_tor_version(), metrics_format_label(), namemap_fmt_name(), networkstatus_get_cache_fname(), orconn_target_get_name(), pathbias_send_usable_probe(), pem_encode(), policy_summarize(), policy_write_item(), port_to_str(), preprocess_consensus(), relay_command_to_string(), router_load_single_router(), router_parse_addr_policy_item_from_string(), service_add_fnames_to_list(), smartlist_contains_int_as_string(), storage_dir_save_labeled_to_file(), tls_log_errors(), token_check_object(), tor_addr_to_PTR_name(), tor_addr_to_str(), tor_get_approx_release_date(), tor_inet_ntoa(), tor_inet_ntop(), tor_init(), update_router_have_minimum_dir_info(), vote_routerstatus_find_microdesc_hash(), and write_stream_target_to_buf().

◆ tor_vasprintf()

int tor_vasprintf ( char **  strp,
const char *  fmt,
va_list  args 
)

Portable vasprintf implementation. Does a printf() into a newly malloc'd string. Differs from regular vasprintf in the same ways that tor_asprintf() differs from regular asprintf.

Definition at line 96 of file printf.c.

Referenced by buf_add_vprintf(), connection_printf_to_buf(), control_event_status(), control_reply_add_printf(), control_vprintf_reply(), process_vprintf(), send_control_event_impl(), smartlist_add_vasprintf(), tor_asprintf(), tor_assertion_failed_(), and tor_bug_occurred_().

◆ tor_vsnprintf()

int tor_vsnprintf ( char *  str,
size_t  size,
const char *  format,
va_list  args 
)

Replacement for vsnprintf; behavior differs as tor_snprintf differs from snprintf.

Definition at line 41 of file printf.c.

Referenced by format_msg(), tor_snprintf(), and tor_vasprintf().