diff mbox series

[21/22] tools/utils: add settings get function

Message ID d1e5795e274571a63b94148a7d371c629eefb3a5.1690990428.git.ehem+xen@m5p.com (mailing list archive)
State New, archived
Headers show
Series Cleanup and splitting of xl.cfg parsing | expand

Commit Message

Elliott Mitchell July 26, 2023, 3:11 a.m. UTC
The better to isolate the shared portion of the interface from the
low-level implementation.

Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
---
 tools/libs/util/libxlu_cfg.c      | 7 ++++++-
 tools/libs/util/libxlu_internal.h | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c
index cb99b0aab0..7bbedde8f6 100644
--- a/tools/libs/util/libxlu_cfg.c
+++ b/tools/libs/util/libxlu_cfg.c
@@ -240,7 +240,7 @@  int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...)
 static XLU_ConfigSetting *find(const XLU_Config *cfg, const char *n) {
     XLU_ConfigSetting *set;
 
-    for (set= cfg->settings;
+    for (set = xlu__cfg_get_settings(cfg);
          set;
          set= set->next)
         if (!strcmp(set->name, n))
@@ -267,6 +267,11 @@  static int find_atom(const XLU_Config *cfg, const char *n,
     return 0;
 }
 
+XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg)
+{
+    return cfg->settings;
+}
+
 
 enum XLU_ConfigValueType xlu_cfg_value_type(const XLU_ConfigValue *value)
 {
diff --git a/tools/libs/util/libxlu_internal.h b/tools/libs/util/libxlu_internal.h
index 34c6c7a443..993ff88171 100644
--- a/tools/libs/util/libxlu_internal.h
+++ b/tools/libs/util/libxlu_internal.h
@@ -45,6 +45,8 @@  extern int xlu__cfg_readfile(XLU_Config *cfg, FILE *msgfile,
 extern int xlu__cfg_readdata(XLU_Config *cfg, FILE *msgfile,
     const char *msgprefix, XLU_ConfigSetting **psettings, const char *data,
     int length);
+extern XLU_ConfigSetting *xlu__cfg_get_settings(const XLU_Config *cfg)
+    __attribute__((access(read_only, 1)));
 
 #endif /*LIBXLU_INTERNAL_H*/