}
break;
}
+ case SET_UINTMAX: {
+ uintmax_t num;
+
+ if (strchr(value, '%') != NULL)
+ break;
+ if (str_to_uintmax(value, &num) < 0) {
+ ctx->error = p_strdup_printf(ctx->pool,
+ "Invalid number %s: %s", value,
+ str_num_error(value));
+ return -1;
+ }
+ break;
+ }
case SET_UINT_OCT:
if (*value == '0') {
unsigned long long octal;
config_export_size(str, *val);
break;
}
+ case SET_UINTMAX: {
+ const uint64_t *val = value;
+ str_printfa(str, "%ju", *val);
+ break;
+ }
case SET_UINT:
case SET_UINT_OCT: {
const unsigned int *val = value;
case SET_FILE:
case SET_BOOL:
case SET_SIZE:
+ case SET_UINTMAX:
case SET_UINT:
case SET_UINT_OCT:
case SET_TIME:
return ret;
}
+static int
+get_uintmax(struct setting_parser_context *ctx, const char *value,
+ uintmax_t *result_r)
+{
+ if (str_to_uintmax(value, result_r) < 0) {
+ settings_parser_set_error(ctx, t_strdup_printf(
+ "Invalid number %s: %s", value,
+ str_num_error(value)));
+ return -1;
+ }
+ return 0;
+}
+
static int
get_uint(struct setting_parser_context *ctx, const char *value,
unsigned int *result_r)
if (get_bool(ctx, value, (bool *)ptr) < 0)
return -1;
break;
+ case SET_UINTMAX:
+ if (get_uintmax(ctx, value, (uintmax_t *)ptr) < 0)
+ return -1;
+ break;
case SET_UINT:
if (get_uint(ctx, value, (unsigned int *)ptr) < 0)
return -1;
crc = crc32_data_more(crc, b, sizeof(*b));
break;
}
+ case SET_UINTMAX: {
+ const uintmax_t *i = p;
+ crc = crc32_data_more(crc, i, sizeof(*i));
+ break;
+ }
case SET_UINT:
case SET_UINT_OCT:
case SET_TIME:
return FALSE;
break;
}
+ case SET_UINTMAX: {
+ const uintmax_t *i1 = p1, *i2 = p2;
+ if (*i1 != *i2)
+ return FALSE;
+ break;
+ }
case SET_UINT:
case SET_UINT_OCT:
case SET_TIME:
enum setting_type {
SET_BOOL,
+ SET_UINTMAX,
SET_UINT,
SET_UINT_OCT,
SET_TIME,
#define SETTING_DEFINE_STRUCT_BOOL(key, name, struct_name) \
SETTING_DEFINE_STRUCT_TYPE(SET_BOOL, 0, bool, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_UINTMAX(key, name, struct_name) \
+ SETTING_DEFINE_STRUCT_TYPE(SET_UINTMAX, 0, uintmax_t, key, name, struct_name)
#define SETTING_DEFINE_STRUCT_UINT(key, name, struct_name) \
SETTING_DEFINE_STRUCT_TYPE(SET_UINT, 0, unsigned int, key, name, struct_name)
#define SETTING_DEFINE_STRUCT_UINT_OCT(key, name, struct_name) \
#define SETTING_DEFINE_STRUCT_BOOL_HIDDEN(key, name, struct_name) \
SETTING_DEFINE_STRUCT_TYPE(SET_BOOL, SET_FLAG_HIDDEN, bool, key, name, struct_name)
+#define SETTING_DEFINE_STRUCT_UINTMAX_HIDDEN(key, name, struct_name) \
+ SETTING_DEFINE_STRUCT_TYPE(SET_UINTMAX, SET_FLAG_HIDDEN, uintmax_t, key, name, struct_name)
#define SETTING_DEFINE_STRUCT_UINT_HIDDEN(key, name, struct_name) \
SETTING_DEFINE_STRUCT_TYPE(SET_UINT, SET_FLAG_HIDDEN, unsigned int, key, name, struct_name)
#define SETTING_DEFINE_STRUCT_UINT_OCT_HIDDEN(key, name, struct_name) \
/* Blob 0 */
"bool_true", "yes",
"bool_false", "no",
+ "uintmax_max", "18446744073709551615",
"uint", "15",
"uint_oct", "0700",
"secs", "5s",
{
"bool_true", "",
"bool_false", "x",
+ "uintmax_max", "",
"uint", "",
"uint", "15M",
"uint_oct", "",
struct test_settings {
bool bool_true;
bool bool_false;
+ uintmax_t uintmax_max;
unsigned int uint;
unsigned int uint_oct;
unsigned int secs;
0,
0,
0,
+ 0,
"",
"",
ARRAY_INIT,
const struct setting_define defs[] = {
SETTING_DEFINE_STRUCT_BOOL("bool_true", bool_true, struct test_settings),
SETTING_DEFINE_STRUCT_BOOL("bool_false", bool_false, struct test_settings),
+ SETTING_DEFINE_STRUCT_UINTMAX("uintmax_max", uintmax_max, struct test_settings),
SETTING_DEFINE_STRUCT_UINT("uint", uint, struct test_settings),
{ .type = SET_UINT_OCT, .key = "uint_oct",
offsetof(struct test_settings, uint_oct), NULL },
test_assert(settings->bool_true == TRUE);
test_assert(settings->bool_false == FALSE);
+ test_assert(settings->uintmax_max == 18446744073709551615ULL);
test_assert(settings->uint == 15);
test_assert(settings->uint_oct == 0700);
test_assert(settings->secs == 5);