29 for (
size_t i = 0; i < len; i++)
49 static void update_flags(
cfg_field_t *param,
const char *value,
ap_t *
self)
52 const char *start = value;
53 const char *end = value;
59 size_t len = end - start;
64 bool negate = *flag ==
'-';
80 bool negate = *start ==
'-';
96 apply_callbacks(scan, param, value, callbacks);
114 update_flags(param, value,
self);
118 CT_NEVER(
"unknown config type %d", type);
128 apply_callbacks(scan, param, &value, callbacks);
140 apply_callbacks(scan, param, value, callbacks);
142 int v = mpz_get_si(value);
153 apply_callbacks(scan, NULL, value, self->posarg_callbacks);
161 ap_add_error(
self,
"invalid ascii character: `%s`", value);
CT_NODISCARD CT_PUREFN CT_SCAN_API void * scan_get_context(const scan_t *scan)
get the context of a scanner
CT_PUREFN CT_CONFIG_API cfg_type_t cfg_get_type(const cfg_field_t *field)
get the type of a configuration field
CT_CONFIG_API void cfg_vector_push(cfg_field_t *field, char *value)
push a new value onto an array field
CT_NODISCARD CT_CONFIG_API bool cfg_set_int(cfg_field_t *field, int value)
set the current value of an int field
CT_NODISCARD CT_CONFIG_API bool cfg_set_flag(cfg_field_t *field, const char *choice, bool set)
set the current value of a flags field set the value via a string name
CT_CONFIG_API void cfg_set_string(cfg_field_t *field, char *value)
set the current value of a string field
CT_CONFIG_API bool cfg_set_enum(cfg_field_t *field, const char *choice)
set the current value of an enum field set the value via a string name
CT_CONFIG_API void cfg_set_bool(cfg_field_t *field, bool value)
set the current value of a bool field
cfg_type_t
the type of a configuration field
CT_NODISCARD CT_PUREFN CT_STD_API void * map_get(const map_t *map, const void *key)
get a value from a map
#define CT_UNUSED(x)
mark a variable as unused
CT_NODISCARD CT_ARENA_API char * arena_strdup(const char *str, arena_t *arena)
allocate a copy of a string from a custom allocator
CT_NODISCARD CT_ARENA_API char * arena_strndup(STA_READS(len) const char *str, size_t len, arena_t *arena)
allocate a copy of a string with a maximum length from a custom allocator
#define CT_NEVER(...)
assert that a code path is never reached
#define CTASSERT(expr)
assert a condition, prints the condition as a message
CT_NODISCARD STA_FORMAT_STRING const char * fmt
CT_NODISCARD STA_FORMAT_STRING const char CT_NODISCARD CT_STD_API char * str_vformat(arena_t *arena, const char *fmt, va_list args)
format a string
CT_NODISCARD CT_PUREFN CT_STD_API void * vector_get(const vector_t *vector, size_t index)
get a value from a vector
CT_STD_API void vector_push(vector_t **vector, void *value)
push a value onto the end of a vector
CT_NODISCARD CT_PUREFN CT_STD_API size_t vector_len(const vector_t *vector)
get the length of a vector
a generic vector of pointers
a location inside a scanner locations are inclusive and 0-based
void ap_on_bool(scan_t *scan, cfg_field_t *param, bool value)
void ap_on_string(scan_t *scan, cfg_field_t *param, char *value)
void ap_add_error(ap_t *self, const char *fmt,...)
void ap_on_int(scan_t *scan, cfg_field_t *param, mpz_t value)
void ap_on_invalid(scan_t *scan, char *value)
void aperror(where_t *where, void *state, scan_t *scan, const char *msg)
void ap_on_posarg(scan_t *scan, char *value)