]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/networkd/config.h
config: Rename "data" to "value" as it holds a reference to it
[people/ms/network.git] / src / networkd / config.h
index e17c0167fa32dfca2c1c0ef433b28ff475601916..71850387cf17343d90674ad635e2bc0b05cb87aa 100644 (file)
@@ -34,6 +34,7 @@ nw_config* nw_config_ref(nw_config* config);
 nw_config* nw_config_unref(nw_config* config);
 
 int nw_config_destroy(nw_config* config);
+int nw_config_copy(nw_config* config, nw_config** copy);
 
 const char* nw_config_path(nw_config* config);
 
@@ -53,4 +54,41 @@ int nw_config_set_int(nw_config* config, const char* key, const int value);
 int nw_config_get_bool(nw_config* config, const char* key);
 int nw_config_set_bool(nw_config* config, const char* key, const int value);
 
+/*
+       Options
+*/
+
+int nw_config_options_read(nw_config* config);
+int nw_config_options_write(nw_config* config);
+
+typedef int (*nw_config_option_read_callback_t)
+       (nw_config* config, const char* key, void* value);
+typedef int (*nw_config_option_write_callback_t)
+       (nw_config* config, const char* key, const void* value);
+
+int nw_config_option_add(nw_config* config, const char* key, void* value,
+       nw_config_option_read_callback_t read_callback,
+       nw_config_option_write_callback_t write_callback);
+
+#define NW_CONFIG_OPTION(config, key, data, read_callback, write_callback) \
+       nw_config_option_add(config, key, data, read_callback, write_callback)
+
+#define NW_CONFIG_OPTION_STRING(config, key, value) \
+       nw_config_option_add(config, key, value, nw_config_read_string, nw_config_write_string)
+
+int nw_config_read_string(nw_config* config, const char* key, void* value);
+int nw_config_write_string(nw_config* config, const char* key, const void* value);
+
+#define NW_CONFIG_OPTION_INT(config, key, value) \
+       nw_config_option_add(config, key, value, nw_config_read_int, nw_config_write_int)
+
+int nw_config_read_int(nw_config* config, const char* key, void* value);
+int nw_config_write_int(nw_config* config, const char* key, const void* value);
+
+#define NW_CONFIG_OPTION_ADDRESS(config, key, value) \
+       nw_config_option_add(config, key, value, nw_config_read_address, nw_config_write_address)
+
+int nw_config_read_address(nw_config* config, const char* key, void* value);
+int nw_config_write_address(nw_config* config, const char* key, const void* value);
+
 #endif /* NETWORKD_CONFIG_H */