14enum bool_tuple_state {
27static const char *parse_bool_tuple(
const char *input,
enum bool_tuple_state *state)
86static int ec_node_bool_tuple_parse(
92 enum bool_tuple_state state;
102 parse_bool_tuple(input, &state);
110static int ec_node_bool_tuple_complete(
116 struct ec_comp_item *item = NULL;
117 const char *false_str =
"false";
118 const char *true_str =
"true";
119 enum bool_tuple_state state;
120 char *comp_str = NULL;
121 char *disp_str = NULL;
122 const char *incomplete;
130 incomplete = parse_bool_tuple(input, &state);
134 if (asprintf(&comp_str,
"%s(", input) < 0)
136 if (asprintf(&disp_str,
"(") < 0)
145 if (incomplete[0] ==
'\0') {
146 if (asprintf(&comp_str,
"%s)", input) < 0)
148 if (asprintf(&disp_str,
")") < 0)
162 if (incomplete[0] ==
't' || incomplete[0] ==
'\0') {
163 if (asprintf(&comp_str,
"%s%s", input, &true_str[strlen(incomplete)]) < 0)
165 if (asprintf(&disp_str,
"true") < 0)
177 if (incomplete[0] ==
'f' || incomplete[0] ==
'\0') {
178 if (asprintf(&comp_str,
"%s%s", input, &false_str[strlen(incomplete)]) < 0)
180 if (asprintf(&disp_str,
"false") < 0)
194 if (asprintf(&comp_str,
"%s,", input) < 0)
196 if (asprintf(&disp_str,
",") < 0)
203 if (asprintf(&comp_str,
"%s)", input) < 0)
205 if (asprintf(&disp_str,
")") < 0)
235 .name =
"bool_tuple",
236 .parse = ec_node_bool_tuple_parse,
237 .complete = ec_node_bool_tuple_complete,
int ec_comp_item_set_display(struct ec_comp_item *item, const char *display)
struct ec_comp * ec_comp(void)
struct ec_comp_item * ec_comp_add_item(struct ec_comp *comp, const struct ec_node *node, enum ec_comp_type type, const char *current, const char *full)
#define EC_LOG_TYPE_REGISTER(name)
struct ec_node * ec_node(const char *typename, const char *id)
#define EC_NODE_TYPE_REGISTER(t)
struct ec_pnode * ec_pnode(const struct ec_node *node)
int ec_str_startswith(const char *s, const char *beginning)
const char * ec_strvec_val(const struct ec_strvec *strvec, size_t idx)
struct ec_strvec * ec_strvec(void)
size_t ec_strvec_len(const struct ec_strvec *strvec)