Commit 3e6f017b authored by Jan Včelák's avatar Jan Včelák 🚀

KASP: const specifier for entities serialization

parent 873c8c4d
......@@ -177,7 +177,7 @@ int dnssec_kasp_zone_load(dnssec_kasp_t *kasp, const char *name,
* \param kasp KASP instance.
* \param zone Zone to be saved.
*/
int dnssec_kasp_zone_save(dnssec_kasp_t *kasp, dnssec_kasp_zone_t *zone);
int dnssec_kasp_zone_save(dnssec_kasp_t *kasp, const dnssec_kasp_zone_t *zone);
/*!
* Remove zone from KASP.
......@@ -339,7 +339,7 @@ int dnssec_kasp_policy_load(dnssec_kasp_t *kasp, const char *name,
* \param kasp KASP instance.
* \param policy Policy to be saved.
*/
int dnssec_kasp_policy_save(dnssec_kasp_t *kasp, dnssec_kasp_policy_t *policy);
int dnssec_kasp_policy_save(dnssec_kasp_t *kasp, const dnssec_kasp_policy_t *policy);
/*!
* Remove a policy from the KASP.
......@@ -379,7 +379,7 @@ dnssec_kasp_keystore_t *dnssec_kasp_keystore_new(const char *name);
void dnssec_kasp_keystore_free(dnssec_kasp_keystore_t *keystore);
int dnssec_kasp_keystore_load(dnssec_kasp_t *kasp, const char *name, dnssec_kasp_keystore_t **keystore);
int dnssec_kasp_keystore_save(dnssec_kasp_t *kasp, dnssec_kasp_keystore_t *keystore);
int dnssec_kasp_keystore_save(dnssec_kasp_t *kasp, const dnssec_kasp_keystore_t *keystore);
int dnssec_kasp_keystore_remove(dnssec_kasp_t *kasp, const char *name);
int dnssec_kasp_keystore_list(dnssec_kasp_t *kasp, dnssec_list_t **names);
int dnssec_kasp_keystore_exists(dnssec_kasp_t *kasp, const char *name);
......
......@@ -198,7 +198,7 @@ static int kasp_dir_zone_load(void *ctx, dnssec_kasp_zone_t *zone)
return entity_io(ENTITY_ZONE, ctx, zone, load_zone_config);
}
static int kasp_dir_zone_save(void *ctx, dnssec_kasp_zone_t *zone)
static int kasp_dir_zone_save(void *ctx, const dnssec_kasp_zone_t *zone)
{
return entity_io(ENTITY_ZONE, ctx, zone, save_zone_config);
}
......@@ -225,7 +225,7 @@ static int kasp_dir_policy_load(void *ctx, dnssec_kasp_policy_t *policy)
return entity_io(ENTITY_POLICY, ctx, policy, load_policy_config);
}
static int kasp_dir_policy_save(void *ctx, dnssec_kasp_policy_t *policy)
static int kasp_dir_policy_save(void *ctx, const dnssec_kasp_policy_t *policy)
{
return entity_io(ENTITY_POLICY, ctx, policy, save_policy_config);
}
......@@ -252,7 +252,7 @@ static int kasp_dir_keystore_load(void *ctx, dnssec_kasp_keystore_t *keystore)
return entity_io(ENTITY_KEYSTORE, ctx, keystore, load_keystore_config);
}
static int kasp_dir_keystore_save(void *ctx, dnssec_kasp_keystore_t *keystore)
static int kasp_dir_keystore_save(void *ctx, const dnssec_kasp_keystore_t *keystore)
{
return entity_io(ENTITY_KEYSTORE, ctx, keystore, save_keystore_config);
}
......
......@@ -29,7 +29,7 @@ static const encode_attr_t ATTRIBUTES[] = {
{ NULL }
};
static bool keystore_valid(dnssec_kasp_keystore_t *keystore)
static bool keystore_valid(const dnssec_kasp_keystore_t *keystore)
{
assert(keystore);
return keystore->backend && keystore->config;
......@@ -54,7 +54,7 @@ static int import_keystore(dnssec_kasp_keystore_t *keystore, const json_t *json)
return DNSSEC_EOK;
}
static int export_keystore(dnssec_kasp_keystore_t *keystore, json_t **json)
static int export_keystore(const dnssec_kasp_keystore_t *keystore, json_t **json)
{
assert(keystore);
assert(json);
......@@ -87,7 +87,7 @@ int load_keystore_config(dnssec_kasp_keystore_t *keystore, const char *filename)
return import_keystore(keystore, json);
}
int save_keystore_config(dnssec_kasp_keystore_t *keystore, const char *filename)
int save_keystore_config(const dnssec_kasp_keystore_t *keystore, const char *filename)
{
assert(keystore);
assert(filename);
......
......@@ -20,4 +20,4 @@
int load_keystore_config(dnssec_kasp_keystore_t *keystore, const char *filename);
int save_keystore_config(dnssec_kasp_keystore_t *keystore, const char *filename);
int save_keystore_config(const dnssec_kasp_keystore_t *keystore, const char *filename);
......@@ -60,7 +60,7 @@ int load_policy_config(dnssec_kasp_policy_t *policy, const char *filename)
return decode_object(POLICY_ATTRS, config, policy);
}
int save_policy_config(dnssec_kasp_policy_t *policy, const char *filename)
int save_policy_config(const dnssec_kasp_policy_t *policy, const char *filename)
{
assert(policy);
assert(filename);
......
......@@ -20,4 +20,4 @@
int load_policy_config(dnssec_kasp_policy_t *policy, const char *filename);
int save_policy_config(dnssec_kasp_policy_t *policy, const char *filename);
int save_policy_config(const dnssec_kasp_policy_t *policy, const char *filename);
......@@ -239,7 +239,7 @@ static void key_to_params(dnssec_kasp_key_t *key, key_params_t *params)
/*!
* Convert KASP keys to JSON array.
*/
static int export_zone_keys(dnssec_kasp_zone_t *zone, json_t **keys_ptr)
static int export_zone_keys(const dnssec_kasp_zone_t *zone, json_t **keys_ptr)
{
json_t *keys = json_array();
if (!keys) {
......@@ -270,7 +270,7 @@ static int export_zone_keys(dnssec_kasp_zone_t *zone, json_t **keys_ptr)
return DNSSEC_EOK;
}
static int export_zone_config(dnssec_kasp_zone_t *zone, json_t **config_ptr)
static int export_zone_config(const dnssec_kasp_zone_t *zone, json_t **config_ptr)
{
assert(zone);
assert(config_ptr);
......@@ -357,7 +357,7 @@ int load_zone_config(dnssec_kasp_zone_t *zone, const char *filename)
/*!
* Save zone configuration.
*/
int save_zone_config(dnssec_kasp_zone_t *zone, const char *filename)
int save_zone_config(const dnssec_kasp_zone_t *zone, const char *filename)
{
assert(zone);
assert(filename);
......
......@@ -20,4 +20,4 @@
int load_zone_config(dnssec_kasp_zone_t *zone, const char *filename);
int save_zone_config(dnssec_kasp_zone_t *zone, const char *filename);
int save_zone_config(const dnssec_kasp_zone_t *zone, const char *filename);
......@@ -31,19 +31,19 @@ typedef struct dnssec_kasp_store_functions {
const char *(*base_path)(void *ctx);
// zone serialization/deserialization
int (*zone_load)(void *ctx, dnssec_kasp_zone_t *zone);
int (*zone_save)(void *ctx, dnssec_kasp_zone_t *zone);
int (*zone_save)(void *ctx, const dnssec_kasp_zone_t *zone);
int (*zone_remove)(void *ctx, const char *zone_name);
int (*zone_list)(void *ctx, dnssec_list_t *zone_names);
int (*zone_exists)(void *ctx, const char *zone_name);
// policy serialization/deserialization
int (*policy_load)(void *ctx, dnssec_kasp_policy_t *policy);
int (*policy_save)(void *ctx, dnssec_kasp_policy_t *policy);
int (*policy_save)(void *ctx, const dnssec_kasp_policy_t *policy);
int (*policy_remove)(void *ctx, const char *name);
int (*policy_list)(void *ctx, dnssec_list_t *policy_names);
int (*policy_exists)(void *ctx, const char *name);
// keystore serialization/deserialization
int (*keystore_load)(void *ctx, dnssec_kasp_keystore_t *keystore);
int (*keystore_save)(void *ctx, dnssec_kasp_keystore_t *keystore);
int (*keystore_save)(void *ctx, const dnssec_kasp_keystore_t *keystore);
int (*keystore_remove)(void *ctx, const char *name);
int (*keystore_list)(void *ctx, dnssec_list_t *names);
int (*keystore_exists)(void *ctx, const char *name);
......
......@@ -137,7 +137,7 @@ int dnssec_kasp_zone_load(dnssec_kasp_t *kasp, const char *zone_name,
}
_public_
int dnssec_kasp_zone_save(dnssec_kasp_t *kasp, dnssec_kasp_zone_t *zone)
int dnssec_kasp_zone_save(dnssec_kasp_t *kasp, const dnssec_kasp_zone_t *zone)
{
if (!kasp || !zone || !zone_valid(zone)) {
return DNSSEC_EINVAL;
......@@ -218,7 +218,7 @@ int dnssec_kasp_policy_load(dnssec_kasp_t *kasp, const char *name,
}
_public_
int dnssec_kasp_policy_save(dnssec_kasp_t *kasp, dnssec_kasp_policy_t *policy)
int dnssec_kasp_policy_save(dnssec_kasp_t *kasp, const dnssec_kasp_policy_t *policy)
{
if (!kasp || !policy) {
return DNSSEC_EINVAL;
......@@ -295,7 +295,7 @@ int dnssec_kasp_keystore_load(dnssec_kasp_t *kasp, const char *name,
}
_public_
int dnssec_kasp_keystore_save(dnssec_kasp_t *kasp, dnssec_kasp_keystore_t *keystore)
int dnssec_kasp_keystore_save(dnssec_kasp_t *kasp, const dnssec_kasp_keystore_t *keystore)
{
if (!kasp || !keystore) {
return DNSSEC_EINVAL;
......
......@@ -63,7 +63,7 @@ static int mock_zone_load(void *ctx, dnssec_kasp_zone_t *zone)
}
static bool mock_zone_save_ok = false;
static int mock_zone_save(void *ctx, dnssec_kasp_zone_t *zone)
static int mock_zone_save(void *ctx, const dnssec_kasp_zone_t *zone)
{
mock_zone_save_ok = ctx == MOCK_CTX && zone &&
streq(zone->policy, "cuttingedge");
......@@ -110,7 +110,7 @@ static int mock_policy_load(void *ctx, dnssec_kasp_policy_t *policy)
}
static bool mock_policy_save_ok = false;
static int mock_policy_save(void *ctx, dnssec_kasp_policy_t *policy)
static int mock_policy_save(void *ctx, const dnssec_kasp_policy_t *policy)
{
mock_policy_save_ok = ctx == MOCK_CTX && policy &&
streq(policy->name, "happy") &&
......@@ -159,7 +159,7 @@ static int mock_keystore_load(void *ctx, dnssec_kasp_keystore_t *keystore)
}
static bool mock_keystore_save_ok = false;
static int mock_keystore_save(void *ctx, dnssec_kasp_keystore_t *keystore)
static int mock_keystore_save(void *ctx, const dnssec_kasp_keystore_t *keystore)
{
mock_keystore_save_ok = ctx == MOCK_CTX && keystore &&
streq(keystore->name, "foobar") &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment