|
Tor 0.4.9.3-alpha-dev
|
Convert strings into the integers they encode, with bounds checking. More...
#include "lib/string/parse_int.h"#include "lib/cc/compat_compiler.h"#include <errno.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | CHECK_STRTOX_RESULT() |
Functions | |
| long | tor_parse_long (const char *s, int base, long min, long max, int *ok, char **next) |
| unsigned long | tor_parse_ulong (const char *s, int base, unsigned long min, unsigned long max, int *ok, char **next) |
| double | tor_parse_double (const char *s, double min, double max, int *ok, char **next) |
| uint64_t | tor_parse_uint64 (const char *s, int base, uint64_t min, uint64_t max, int *ok, char **next) |
Convert strings into the integers they encode, with bounds checking.
Definition in file parse_int.c.
| #define CHECK_STRTOX_RESULT | ( | ) |
Definition at line 20 of file parse_int.c.
| double tor_parse_double | ( | const char * | s, |
| double | min, | ||
| double | max, | ||
| int * | ok, | ||
| char ** | next | ||
| ) |
As tor_parse_long(), but return a double.
Definition at line 97 of file parse_int.c.
Referenced by config_parse_units(), parse_dir_authority_line(), and parse_dir_fallback_line().
| long tor_parse_long | ( | const char * | s, |
| int | base, | ||
| long | min, | ||
| long | max, | ||
| int * | ok, | ||
| char ** | next | ||
| ) |
Extract a long from the start of s, in the given numeric base. If base is 0, s is parsed as a decimal, octal, or hex number in the syntax of a C integer literal. If there is unconverted data and next is provided, set *next to the first unconverted character. An error has occurred if no characters are converted; or if there are unconverted characters and next is NULL; or if the parsed value is not between min and max. When no error occurs, return the parsed value and set *ok (if provided) to
Definition at line 59 of file parse_int.c.
Referenced by accounting_parse_options(), cmp_int_strings_(), compute_consensus_method(), connection_ap_process_natd(), dirvote_compute_params(), dirvote_get_intermediate_param_value(), do_main_loop(), entry_guard_parse_from_state(), get_net_param_from_list(), handle_cmdline_passphrase_fd(), handle_control_add_onion(), handle_control_protocolinfo(), hs_parse_port_config(), measured_bw_line_parse(), metrics_parse_ports(), networkstatus_parse_vote_from_string(), parse_dir_authority_line(), parse_dir_fallback_line(), parse_port_range(), parse_possibly_bad_iso_time(), parse_process_specifier(), port_parse_config(), rep_hist_load_mtbf_data(), router_parse_entry_from_string(), and tor_addr_port_split().
| uint64_t tor_parse_uint64 | ( | const char * | s, |
| int | base, | ||
| uint64_t | min, | ||
| uint64_t | max, | ||
| int * | ok, | ||
| char ** | next | ||
| ) |
As tor_parse_long, but return a uint64_t. Only base 10 is guaranteed to work for now.
Definition at line 110 of file parse_int.c.
Referenced by buf_http_find_content_length(), bwhist_load_bwhist_state_section(), config_parse_units(), desc_decode_encrypted_v3(), desc_decode_plaintext_v3(), get_stream(), and sr_parse_srv().
| unsigned long tor_parse_ulong | ( | const char * | s, |
| int | base, | ||
| unsigned long | min, | ||
| unsigned long | max, | ||
| int * | ok, | ||
| char ** | next | ||
| ) |
As tor_parse_long(), but return an unsigned long.
Definition at line 78 of file parse_int.c.
Referenced by circuit_build_times_parse_state(), decode_create2_list(), decode_pow_params(), desc_decode_plaintext_v3(), dirserv_read_measured_bandwidths(), get_circ(), handle_control_add_onion(), handle_control_attachstream(), handle_control_closestream(), handle_control_redirectstream(), hs_desc_decode_plaintext(), parse_short_policy(), parse_version_range(), and sr_parse_commit().