35 {
"kilobyte", 1<<10 },
36 {
"kilobytes", 1<<10 },
45 {
"megabyte", 1<<20 },
46 {
"megabytes", 1<<20 },
47 {
"megabits", 1<<17 },
54 {
"gigabyte", 1<<30 },
55 {
"gigabytes", 1<<30 },
56 {
"gigabits", 1<<27 },
60 {
"tb", UINT64_C(1)<<40 },
61 {
"tbyte", UINT64_C(1)<<40 },
62 {
"tbytes", UINT64_C(1)<<40 },
63 {
"terabyte", UINT64_C(1)<<40 },
64 {
"terabytes", UINT64_C(1)<<40 },
65 {
"terabits", UINT64_C(1)<<37 },
66 {
"terabit", UINT64_C(1)<<37 },
67 {
"tbits", UINT64_C(1)<<37 },
68 {
"tbit", UINT64_C(1)<<37 },
86 {
"week", 7*24*60*60 },
87 {
"weeks", 7*24*60*60 },
88 {
"month", 2629728, },
89 {
"months", 2629728, },
100 {
"millisecond", 1 },
101 {
"milliseconds", 1 },
104 {
"minute", 60*1000 },
105 {
"minutes", 60*1000 },
106 {
"hour", 60*60*1000 },
107 {
"hours", 60*60*1000 },
108 {
"day", 24*60*60*1000 },
109 {
"days", 24*60*60*1000 },
110 {
"week", 7*24*60*60*1000 },
111 {
"weeks", 7*24*60*60*1000 },
139 if (!*ok || (cp && *cp ==
'.')) {
142 tor_asprintf(&errmsg,
"Unable to parse %s as a number", val);
153 v = use_float ? ((uint64_t)d) : v;
160 for ( ;u->
unit;++u) {
161 if (!strcasecmp(u->
unit, cp)) {
166 tor_asprintf(&errmsg,
"Got a negative value while parsing %s %s",
174 if (d >= 0 && (d > (
double)INT64_MAX || (uint64_t)d > INT64_MAX)) {
202 tor_assert_nonfatal(!*ok);
204 *errmsg_out = errmsg;
238 log_warn(
LD_CONFIG,
"Msec interval '%s' is too long", s);
255 log_warn(
LD_CONFIG,
"Interval '%s' is too long", s);
Headers for util_malloc.c.
uint64_t tor_mul_u64_nowrap(uint64_t a, uint64_t b)
uint64_t tor_parse_uint64(const char *s, int base, uint64_t min, uint64_t max, int *ok, char **next)
double tor_parse_double(const char *s, double min, double max, int *ok, char **next)
int tor_asprintf(char **strp, const char *fmt,...)
const struct unit_table_t time_units[]
const struct unit_table_t time_msec_units[]
int config_parse_interval(const char *s, int *ok)
const struct unit_table_t memory_units[]
uint64_t config_parse_memunit(const char *s, int *ok)
uint64_t config_parse_units(const char *val, const unit_table_t *u, int *ok, char **errmsg_out)
int config_parse_msec_interval(const char *s, int *ok)
Header for lib/confmgt/unitparse.c.
Macros to manage assertions, fatal and non-fatal.
const char * eat_whitespace(const char *s)
Header for util_string.c.