Tor 0.4.9.1-alpha-dev
|
Header for util_string.c. More...
Go to the source code of this file.
Macros | |
#define | fast_digest_is_zero(d) fast_mem_is_zero((d), DIGEST_LEN) |
#define | fast_digetst256_is_zero(d) fast_mem_is_zero((d), DIGEST256_LEN) |
#define | HEX_CHARACTERS "0123456789ABCDEFabcdef" |
Functions | |
const void * | tor_memmem (const void *haystack, size_t hlen, const void *needle, size_t nlen) |
const void * | tor_memstr (const void *haystack, size_t hlen, const char *needle) |
int | fast_mem_is_zero (const char *mem, size_t len) |
int | tor_digest_is_zero (const char *digest) |
int | tor_digest256_is_zero (const char *digest) |
void | tor_strlower (char *s) |
void | tor_strupper (char *s) |
void | tor_strreplacechar (char *s, char find, char replacement) |
int | tor_strisprint (const char *s) |
int | tor_strisnonupper (const char *s) |
int | tor_strisspace (const char *s) |
int | strcmp_opt (const char *s1, const char *s2) |
int | strcmpstart (const char *s1, const char *s2) |
int | strcasecmpstart (const char *s1, const char *s2) |
int | strcmpend (const char *s1, const char *s2) |
int | strcasecmpend (const char *s1, const char *s2) |
int | fast_memcmpstart (const void *mem, size_t memlen, const char *prefix) |
void | tor_strstrip (char *s, const char *strip) |
const char * | eat_whitespace (const char *s) |
const char * | eat_whitespace_eos (const char *s, const char *eos) |
const char * | eat_whitespace_no_nl (const char *s) |
const char * | eat_whitespace_eos_no_nl (const char *s, const char *eos) |
const char * | find_whitespace (const char *s) |
const char * | find_whitespace_eos (const char *s, const char *eos) |
const char * | find_str_at_start_of_line (const char *haystack, const char *needle) |
int | string_is_C_identifier (const char *string) |
int | string_is_utf8 (const char *str, size_t len) |
int | string_is_utf8_no_bom (const char *str, size_t len) |
Header for util_string.c.
Definition in file util_string.h.
#define fast_digest_is_zero | ( | d | ) | fast_mem_is_zero((d), DIGEST_LEN) |
Definition at line 24 of file util_string.h.
#define fast_digetst256_is_zero | ( | d | ) | fast_mem_is_zero((d), DIGEST256_LEN) |
Definition at line 25 of file util_string.h.
#define HEX_CHARACTERS "0123456789ABCDEFabcdef" |
Allowable characters in a hexadecimal string.
Definition at line 31 of file util_string.h.
const char * eat_whitespace | ( | const char * | s | ) |
Return a pointer to the first char of s that is not whitespace and not a comment, or to the terminating NUL if no such character exists.
Definition at line 279 of file util_string.c.
Referenced by parse_log_severity_config(), port_cfg_line_extract_addrport(), router_parse_addr_policy_item_from_string(), router_parse_addr_policy_private(), tor_addr_port_lookup(), and tor_version_parse_platform().
const char * eat_whitespace_eos | ( | const char * | s, |
const char * | eos | ||
) |
Return a pointer to the first char of s that is not whitespace and not a comment, or to the terminating NUL if no such character exists.
Definition at line 306 of file util_string.c.
Referenced by authority_cert_parse_from_string(), find_start_of_next_microdesc(), find_start_of_next_router_or_extrainfo(), microdescs_parse_from_string(), and pem_decode().
const char * eat_whitespace_eos_no_nl | ( | const char * | s, |
const char * | eos | ||
) |
As eat_whitespace_no_nl, but stop at eos whether we have found a non-whitespace character or not.
Definition at line 344 of file util_string.c.
const char * eat_whitespace_no_nl | ( | const char * | s | ) |
Return a pointer to the first char of s that is not a space or a tab or a \r, or to the terminating NUL if no such character exists.
Definition at line 334 of file util_string.c.
Referenced by parse_http_command().
int fast_mem_is_zero | ( | const char * | mem, |
size_t | len | ||
) |
Return true iff the 'len' bytes at 'mem' are all zero.
Definition at line 76 of file util_string.c.
Referenced by build_service_desc_keys(), build_service_desc_plaintext(), check_sockaddr(), commit_has_reveal_value(), construct_ntor_key_map(), crypto_read_tagged_contents_from_file(), decrypt_descriptor_cookie(), dirauth_get_voting_schedule(), disk_state_put_commit_line(), hs_build_blinded_keypair(), hs_build_blinded_pubkey(), hs_desc_build_authorized_client(), microdesc_has_curve25519_onion_key(), and routerinfo_incompatible_with_extrainfo().
int fast_memcmpstart | ( | const void * | mem, |
size_t | memlen, | ||
const char * | prefix | ||
) |
Compare the value of the string prefix with the start of the memlen-byte memory chunk at mem. Return as for strcmp.
[As fast_memcmp(mem, prefix, strlen(prefix)) but returns -1 if memlen is less than strlen(prefix).]
Definition at line 240 of file util_string.c.
const char * find_str_at_start_of_line | ( | const char * | haystack, |
const char * | needle | ||
) |
Return the first occurrence of needle in haystack that occurs at the start of a line (that is, at the beginning of haystack or immediately after a newline). Return NULL if no such string is found.
Definition at line 402 of file util_string.c.
Referenced by get_total_system_memory_impl().
const char * find_whitespace | ( | const char * | s | ) |
Return a pointer to the first char of s that is whitespace or #, or to the terminating NUL if no such character exists.
Definition at line 355 of file util_string.c.
Referenced by parse_http_command(), tor_version_parse_platform(), and version_from_platform().
const char * find_whitespace_eos | ( | const char * | s, |
const char * | eos | ||
) |
As find_whitespace, but stop at eos whether we have found a whitespace or not.
Definition at line 377 of file util_string.c.
int strcasecmpend | ( | const char * | s1, |
const char * | s2 | ||
) |
Compares the last strlen(s2) characters of s1 with s2. Returns as for strcasecmp.
Definition at line 266 of file util_string.c.
Referenced by address_is_in_virtual_range(), addressmap_address_should_automap(), hostname_in_track_host_exits(), tor_addr_hostname_is_local(), and tor_addr_parse_PTR_name().
int strcasecmpstart | ( | const char * | s1, |
const char * | s2 | ||
) |
Compares the first strlen(s2) characters of s1 with s2. Returns as for strcasecmp.
Definition at line 227 of file util_string.c.
Referenced by circuit_purpose_from_string(), config_lines_dup_and_filter(), handle_control_hspost(), http_get_header(), parse_dirauth_dirport(), and tor_version_parse().
int strcmp_opt | ( | const char * | s1, |
const char * | s2 | ||
) |
As strcmp, except that either string may be NULL. The NULL string is considered to be before any non-NULL string.
Definition at line 199 of file util_string.c.
Referenced by bridge_resolve_conflicts(), compare_by_valid_after_(), connection_dir_list_by_purpose_and_resource(), connection_dir_list_by_purpose_resource_and_state(), opt_streq(), and proxy_needs_restart().
int strcmpend | ( | const char * | s1, |
const char * | s2 | ||
) |
Compares the last strlen(s2) characters of s1 with s2. Returns as for strcmp.
Definition at line 253 of file util_string.c.
Referenced by auth_key_filename_is_valid(), client_filename_is_valid(), crypto_read_tagged_contents_from_file(), get_onion_public_key(), and storage_dir_clean_tmpfiles().
int strcmpstart | ( | const char * | s1, |
const char * | s2 | ||
) |
Compares the first strlen(s2) characters of s1 with s2. Returns as for strcmp.
Definition at line 217 of file util_string.c.
Referenced by address_is_invalid_mapaddress_target(), body_is_plausible(), connection_dir_bridge_routerdesc_failed(), controller_get_routerdescs(), crypto_read_tagged_contents_from_file(), decode_hashed_passwords(), dirvote_get_intermediate_param_value(), evdns_log_cb(), find_start_of_next_router_or_extrainfo(), get_net_param_from_list(), get_transport_bindaddr(), getinfo_helper_dir(), getinfo_helper_downloads(), getinfo_helper_downloads_cert(), getinfo_helper_geoip(), handle_get_descriptor(), handle_get_hs_descriptor_v3(), handle_get_keys(), handle_getinfo_helper(), handle_response_fetch_desc(), list_pending_fpsk_downloads(), metrics_connection_process_inbuf(), parse_dirauth_dirport(), parse_http_command(), parse_http_url(), parse_openssl_version_str(), port_cfg_line_extract_addrport(), router_parse_addr_policy_private(), string_is_utf8_no_bom(), summarize_protover_flags(), tor_version_parse_platform(), and version_from_platform().
int string_is_C_identifier | ( | const char * | string | ) |
Returns true if string could be a C identifier. A C identifier must begin with a letter or an underscore and the rest of its characters can be letters, numbers or underscores. No length limit is imposed.
Definition at line 425 of file util_string.c.
int string_is_utf8 | ( | const char * | str, |
size_t | len | ||
) |
Returns true iff the first len bytes in str are a valid UTF-8 string.
Definition at line 518 of file util_string.c.
Referenced by string_is_utf8_no_bom().
int string_is_utf8_no_bom | ( | const char * | str, |
size_t | len | ||
) |
As string_is_utf8(), but returns false if the string begins with a UTF-8 byte order mark (BOM).
Definition at line 559 of file util_string.c.
int tor_digest256_is_zero | ( | const char * | digest | ) |
Return true iff the DIGEST256_LEN bytes in digest are all zero.
Definition at line 105 of file util_string.c.
int tor_digest_is_zero | ( | const char * | digest | ) |
Return true iff the DIGEST_LEN bytes in digest are all zero.
Definition at line 98 of file util_string.c.
Referenced by bridge_get_rsa_id_digest(), bridge_has_digest(), bridge_resolve_conflicts(), channel_dump_statistics(), circuit_get_all_pending_on_channel(), connection_ap_fail_onehop(), connection_or_client_learned_peer_id(), connection_unlink(), directory_request_dir_contact_info_specified(), entry_guard_learned_bridge_identity(), get_bridge_info_for_guard(), get_configured_bridge_by_addr_port_digest(), get_configured_bridge_by_orports_digest(), get_or_history(), learned_bridge_descriptor(), learned_router_identity(), lookup_cached_dir_by_fp(), and orconn_target_get_name().
const void * tor_memmem | ( | const void * | _haystack, |
size_t | hlen, | ||
const void * | _needle, | ||
size_t | nlen | ||
) |
Given hlen bytes at haystack and nlen bytes at needle, return a pointer to the first occurrence of the needle within the haystack, or NULL if there is no such occurrence.
This function is not timing-safe.
Requires that nlen be greater than zero.
Definition at line 29 of file util_string.c.
const void * tor_memstr | ( | const void * | haystack, |
size_t | hlen, | ||
const char * | needle | ||
) |
Definition at line 69 of file util_string.c.
int tor_strisnonupper | ( | const char * | s | ) |
Return 1 if no character in s is uppercase, else return 0.
Definition at line 173 of file util_string.c.
Referenced by assert_resolve_ok().
int tor_strisprint | ( | const char * | s | ) |
Return 1 if every character in s is printable, else return 0.
Definition at line 160 of file util_string.c.
int tor_strisspace | ( | const char * | s | ) |
Return true iff every character in s is whitespace space; else return false.
Definition at line 186 of file util_string.c.
void tor_strlower | ( | char * | s | ) |
Convert all alphabetic characters in the nul-terminated string s to lowercase.
Definition at line 129 of file util_string.c.
Referenced by clear_trackexithost_mappings().
void tor_strreplacechar | ( | char * | s, |
char | find, | ||
char | replacement | ||
) |
Replaces old with replacement in s
Definition at line 150 of file util_string.c.
void tor_strstrip | ( | char * | s, |
const char * | strip | ||
) |
Remove from the string s every character which appears in strip.
Definition at line 113 of file util_string.c.
void tor_strupper | ( | char * | s | ) |
Convert all alphabetic characters in the nul-terminated string s to lowercase.
Definition at line 140 of file util_string.c.