@@ -3766,17 +3766,8 @@ int parse_config_key(const char *var,
return 0;
}
-const char *current_config_origin_type(void)
+const char *config_origin_type_name(enum config_origin_type type)
{
- enum config_origin_type type;
-
- if (current_config_kvi)
- type = current_config_kvi->origin_type;
- else if(cf)
- type = cf->origin_type;
- else
- BUG("current_config_origin_type called outside config callback");
-
switch (type) {
case CONFIG_ORIGIN_BLOB:
return "blob";
@@ -3793,6 +3784,20 @@ const char *current_config_origin_type(void)
}
}
+const char *current_config_origin_type(void)
+{
+ enum config_origin_type type;
+
+ if (current_config_kvi)
+ type = current_config_kvi->origin_type;
+ else if(cf)
+ type = cf->origin_type;
+ else
+ BUG("current_config_origin_type called outside config callback");
+
+ return config_origin_type_name(type);
+}
+
const char *config_scope_name(enum config_scope scope)
{
switch (scope) {
@@ -117,6 +117,12 @@ struct key_value_info {
enum config_scope scope;
};
+/**
+ * Given the "enum config_origin_type origin_type"
+ * (e.g. CONFIG_ORIGIN_BLOB) return a string (e.g. "blob").
+ */
+const char *config_origin_type_name(enum config_origin_type type);
+
/**
* A config callback function takes three parameters:
*
Add a config_origin_type_name() helper function. In a subsequent commit we'll want to invoke this part of current_config_origin_type() without requiring the global "current_config_kvi" or "cf" state. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- config.c | 25 +++++++++++++++---------- config.h | 6 ++++++ 2 files changed, 21 insertions(+), 10 deletions(-)