X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Fecoli_config.h;h=706af79f398d5b26b81c9da14c613facdc705c80;hb=d8c60a316b5c2a8b959f6191274504d433cf64f0;hp=96e47b322cdcc2454effbcee229426e1d1cf276a;hpb=41be2fa5bc7520b4d9ba2028aa151ddfac8e62ed;p=protos%2Flibecoli.git diff --git a/lib/ecoli_config.h b/lib/ecoli_config.h index 96e47b3..706af79 100644 --- a/lib/ecoli_config.h +++ b/lib/ecoli_config.h @@ -47,11 +47,6 @@ struct ec_config_schema { /** If type is dict or list, the schema of the dict or list * elements. Else must be NULL. */ const struct ec_config_schema *subschema; - - /** The subschema array len in case of dict (> 0) or list (set - * to 1). Else must be 0. */ - size_t subschema_len; - }; TAILQ_HEAD(ec_config_list, ec_config); @@ -85,14 +80,12 @@ struct ec_config { * Validate a configuration schema array. * * @param schema - * Pointer to the first element of the schema array. - * @param schema_len - * Length of the schema array. + * Pointer to the first element of the schema array. The array + * must be terminated by a sentinel entry (type == EC_CONFIG_TYPE_NONE). * @return * 0 if the schema is valid, or -1 on error (errno is set). */ -int ec_config_schema_validate(const struct ec_config_schema *schema, - size_t schema_len); +int ec_config_schema_validate(const struct ec_config_schema *schema); /** * Dump a configuration schema array. @@ -100,12 +93,42 @@ int ec_config_schema_validate(const struct ec_config_schema *schema, * @param out * Output stream on which the dump will be sent. * @param schema - * Pointer to the first element of the schema array. - * @param schema_len - * Length of the schema array. + * Pointer to the first element of the schema array. The array + * must be terminated by a sentinel entry (type == EC_CONFIG_TYPE_NONE). + */ +void ec_config_schema_dump(FILE *out, const struct ec_config_schema *schema); + +/** + * Find a schema entry matching the key. + * + * Browse the schema array and lookup for the given key. + * + * @param schema + * Pointer to the first element of the schema array. The array + * must be terminated by a sentinel entry (type == EC_CONFIG_TYPE_NONE). + * @return + * The schema entry if it matches a key, or NULL if not found. + */ +const struct ec_config_schema * +ec_config_schema_lookup(const struct ec_config_schema *schema, + const char *key); + +/** + * Check if a key name is reserved in a config dict. + * + * Some key names are reserved and should not be used in configs. + * + * @param name + * The name of the key to test. + * @return + * True if the key name is reserved and must not be used, else false. + */ +bool ec_config_key_is_reserved(const char *name); + +/** + * Array of reserved key names. */ -void ec_config_schema_dump(FILE *out, const struct ec_config_schema *schema, - size_t schema_len); +extern const char *ec_config_reserved_keys[]; /* config */ @@ -226,15 +249,13 @@ int ec_config_list_del(struct ec_config *list, struct ec_config *config); * @param dict * A hash table configuration to validate. * @param schema - * Pointer to the first element of the schema array. - * @param schema_len - * Length of the schema array. + * Pointer to the first element of the schema array. The array + * must be terminated by a sentinel entry (type == EC_CONFIG_TYPE_NONE). * @return * 0 on success, -1 on error (errno is set). */ int ec_config_validate(const struct ec_config *dict, - const struct ec_config_schema *schema, - size_t schema_len); + const struct ec_config_schema *schema); /** * Set a value in a hash table configuration