summaryrefslogtreecommitdiffstats
path: root/agents/virt/include/simpleconfig.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 06:50:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 06:50:17 +0000
commit86ed03f8adee56c050c73018537371c230a664a6 (patch)
treeeae3d04cdf1c49848e5a671327ab38297f4acb0d /agents/virt/include/simpleconfig.h
parentInitial commit. (diff)
downloadfence-agents-upstream.tar.xz
fence-agents-upstream.zip
Adding upstream version 4.12.1.upstream/4.12.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'agents/virt/include/simpleconfig.h')
-rw-r--r--agents/virt/include/simpleconfig.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/agents/virt/include/simpleconfig.h b/agents/virt/include/simpleconfig.h
new file mode 100644
index 0000000..6aba85f
--- /dev/null
+++ b/agents/virt/include/simpleconfig.h
@@ -0,0 +1,56 @@
+#ifndef _SIMPLECONFIG_H
+#define _SIMPLECONFIG_H
+
+typedef int (*config_get_t)(void *config, const char *key,
+ char *value, size_t valuesz);
+typedef int (*config_set_t)(void *config, const char *key,
+ const char *value);
+typedef int (*config_parse_t)(const char *filename, void **config);
+typedef int (*config_free_t)(void *config);
+typedef void (*config_dump_t)(void *config, FILE *fp);
+
+/*
+ * We use an abstract object here so we do not have to link loadable
+ * modules against the configuration library.
+ */
+
+typedef struct {
+ config_get_t get;
+ config_set_t set;
+ config_parse_t parse;
+ config_free_t free;
+ config_dump_t dump;
+ void *info;
+} config_object_t;
+
+/*
+ * These macros may be called from within a loadable module
+ */
+#define sc_get(obj, key, value, valuesz) \
+ obj->get(obj->info, key, value, valuesz)
+#define sc_set(obj, key, value) \
+ obj->set(obj->info, key, value)
+#define sc_parse(obj, filename) \
+ obj->parse(filename, &obj->info)
+#define sc_free(obj) \
+ obj->free(obj->info)
+#define sc_dump(obj, fp) \
+ obj->dump(obj->info, fp)
+
+/*
+ * Do not call the below functions from loadable modules. Doing so
+ * requires linking the configuration library in to the modules, which
+ * is what we want to avoid.
+ */
+
+/* Returns a copy of our simple config object */
+config_object_t *sc_init(void);
+
+/* Frees a previously-allocated copy of our simple config object */
+void sc_release(config_object_t *c);
+
+int check_file_permissions(const char *fname);
+
+int do_configure(config_object_t *config, const char *filename);
+
+#endif