key_state.c File Reference
`#include "key_state.h"`
`#include "db_error.h"`
`#include <string.h>`

Go to the source code of this file.

## Functions

key_state_t * | key_state_new (const db_connection_t *connection)
key_state_t * | key_state_new_copy (const key_state_t *key_state)
void | key_state_free (key_state_t *key_state)
int | key_state_copy (key_state_t *key_state, const key_state_t *key_state_copy)
int | key_state_from_result (key_state_t *key_state, const db_result_t *result)
const db_value_t * | key_state_key_data_id (const key_state_t *key_state)
key_state_type_t | key_state_type (const key_state_t *key_state)
const char * | key_state_type_text (const key_state_t *key_state)
key_state_state_t | key_state_state (const key_state_t *key_state)
const char * | key_state_state_text (const key_state_t *key_state)
unsigned int | key_state_last_change (const key_state_t *key_state)
unsigned int | key_state_minimize (const key_state_t *key_state)
unsigned int | key_state_ttl (const key_state_t *key_state)
int | key_state_set_key_data_id (key_state_t *key_state, const db_value_t *key_data_id)
int | key_state_set_type (key_state_t *key_state, key_state_type_t type)
int | key_state_set_state (key_state_t *key_state, key_state_state_t state)
int | key_state_set_last_change (key_state_t *key_state, unsigned int last_change)
int | key_state_set_minimize (key_state_t *key_state, unsigned int minimize)
int | key_state_set_ttl (key_state_t *key_state, unsigned int ttl)
db_clause_t * | key_state_key_data_id_clause (db_clause_list_t *clause_list, const db_value_t *key_data_id)
int | key_state_create (key_state_t *key_state)
int | key_state_get_by_id (key_state_t *key_state, const db_value_t *id)
int | key_state_update (key_state_t *key_state)
int | key_state_delete (const key_state_t *key_state)
key_state_list_t * | key_state_list_new (const db_connection_t *connection)
key_state_list_t * | key_state_list_new_copy (const key_state_list_t *from_key_state_list)
int | key_state_list_object_store (key_state_list_t *key_state_list)
void | key_state_list_free (key_state_list_t *key_state_list)
int | key_state_list_copy (key_state_list_t *key_state_list, const key_state_list_t *from_key_state_list)
int | key_state_list_get_by_clauses (key_state_list_t *key_state_list, const db_clause_list_t *clause_list)
int | key_state_list_get_by_key_data_id (key_state_list_t *key_state_list, const db_value_t *key_data_id)
key_state_list_t * | key_state_list_new_get_by_key_data_id (const db_connection_t *connection, const db_value_t *key_data_id)
const key_state_t * | key_state_list_begin (key_state_list_t *key_state_list)
key_state_t * | key_state_list_get_begin (key_state_list_t *key_state_list)
const key_state_t * | key_state_list_next (key_state_list_t *key_state_list)
key_state_t * | key_state_list_get_next (key_state_list_t *key_state_list)

## Variables

const db_enum_t | key_state_enum_set_type []
const db_enum_t | key_state_enum_set_state []

## Function Documentation

## key_state_copy()

int key_state_copy | ( | key_state_t * | key_state,
|  | const key_state_t * | key_state_copy
| ) |  |

Copy the content of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | key_state_copy | a key_state_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 229 of file key_state.c.

References key_state::associated_key_data_id, DB_ERROR_UNKNOWN, DB_OK, db_value_copy(), key_state::id, key_data_free(), key_state::key_data_id, key_data_new_copy(), key_state::last_change, key_state::minimize, key_state::private_key_data_id, key_state::rev, key_state::state, key_state::ttl, and key_state::type.

Referenced by key_state_new_copy().

## key_state_create()

int key_state_create | ( | key_state_t * | key_state | ) |

Create a key state object in the database.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 519 of file key_state.c.

## key_state_delete()

int key_state_delete | ( | const key_state_t * | key_state | ) |

Delete a key state object from the database.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 831 of file key_state.c.

## key_state_free()

void key_state_free | ( | key_state_t * | key_state | ) |

Delete a key state object, this does not delete it from the database.

Parameters

  [in] | key_state | a key_state_t pointer.

Definition at line 214 of file key_state.c.

References db_object_free(), db_value_reset(), key_state::dbo, key_state::id, key_data_free(), key_state::key_data_id, key_state::private_key_data_id, and key_state::rev.

Referenced by key_state_list_copy(), key_state_list_free(), and key_state_new_copy().

## key_state_from_result()

int key_state_from_result | ( | key_state_t * | key_state,
|  | const db_result_t * | result
| ) |  |

Set the content of a key state object based on a database result.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | result | a db_result_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 270 of file key_state.c.

## key_state_get_by_id()

int key_state_get_by_id | ( | key_state_t * | key_state,
|  | const db_value_t * | id
| ) |  |

Get a key state object from the database by a id specified in `id`.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | id | a db_value_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 631 of file key_state.c.

## key_state_key_data_id()

const db_value_t* key_state_key_data_id | ( | const key_state_t * | key_state | ) |

Get the key_data_id of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  a db_value_t pointer or NULL on error.

Definition at line 337 of file key_state.c.

References key_state::key_data_id.

## key_state_key_data_id_clause()

db_clause_t* key_state_key_data_id_clause | ( | db_clause_list_t * | clause_list,
|  | const db_value_t * | key_data_id
| ) |  |

Create a clause for key_data_id of a key state object and add it to a database clause list. The clause operator is set to DB_CLAUSE_OPERATOR_AND and the clause type is set to DB_CLAUSE_EQUAL, if you want to change these you can do it with the returned db_clause_t pointer.

Parameters

  [in] | clause_list | db_clause_list_t pointer.
  [in] | key_data_id | a db_value_t pointer.

Returns
  a db_clause_t pointer to the added clause or NULL on error.

Definition at line 492 of file key_state.c.

## key_state_last_change()

unsigned int key_state_last_change | ( | const key_state_t * | key_state | ) |

Get the last_change of a key state object. Undefined behavior if `key_state` is NULL.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  an unsigned integer.

Definition at line 393 of file key_state.c.

References key_state::last_change.

## key_state_list_begin()

const key_state_t* key_state_list_begin | ( | key_state_list_t * | key_state_list | ) |

Get the first key state object in a key state object list and reset the position of the list.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Returns
  a key_state_t pointer or NULL on error or if there are no key state objects in the key state object list.

Definition at line 1240 of file key_state.c.

## key_state_list_copy()

int key_state_list_copy | ( | key_state_list_t * | key_state_list,
|  | const key_state_list_t * | from_key_state_list
| ) |  |

Copy the content of another key state object list.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.
  [in] | from_key_state_list | a key_state_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 952 of file key_state.c.

References key_state_list::associated_fetch, DB_ERROR_UNKNOWN, DB_OK, db_result_list_free(), db_result_list_new_copy(), key_state_list::key_data_id_list, key_data_list_new_copy(), key_state_free(), key_state_new_copy(), key_state_list::object_list, key_state_list::object_list_first, key_state_list::object_list_position, key_state_list::object_list_size, key_state_list::object_store, and key_state_list::result_list.

Referenced by key_state_list_new_copy().

## key_state_list_free()

void key_state_list_free | ( | key_state_list_t * | key_state_list | ) |

Delete a key state object list.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Definition at line 924 of file key_state.c.

References db_object_free(), db_result_list_free(), key_state_list::dbo, key_state_list::key_data_id_list, key_data_list_free(), key_state_list::key_state, key_state_free(), key_state_list::object_list, key_state_list::object_list_size, and key_state_list::result_list.

Referenced by key_data_copy(), key_data_free(), key_state_list_new_copy(), and key_state_list_new_get_by_key_data_id().

## key_state_list_get_begin()

key_state_t* key_state_list_get_begin | ( | key_state_list_t * | key_state_list | ) |

Get the first key state object in a key state object list and reset the position of the list. The caller will be given ownership of this object and is responsible for freeing it.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Returns
  a key_state_t pointer or NULL on error or if there are no key state objects in the key state object list.

Definition at line 1296 of file key_state.c.

## key_state_list_get_by_clauses()

int key_state_list_get_by_clauses | ( | key_state_list_t * | key_state_list,
|  | const db_clause_list_t * | clause_list
| ) |  |

Get key state objects from the database by a clause list.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.
  [in] | clause_list | a db_clause_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1112 of file key_state.c.

## key_state_list_get_by_key_data_id()

int key_state_list_get_by_key_data_id | ( | key_state_list_t * | key_state_list,
|  | const db_value_t * | key_data_id
| ) |  |

Get key state objects from the database by a key_data_id specified in `key_data_id`.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.
  [in] | key_data_id | a db_value_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 1154 of file key_state.c.

Referenced by key_state_list_new_get_by_key_data_id().

## key_state_list_get_next()

key_state_t* key_state_list_get_next | ( | key_state_list_t * | key_state_list | ) |

Get the next key state object in a key state object list. The caller will be given ownership of this object and is responsible for freeing it.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Returns
  a key_state_t pointer or NULL on error or if there are no more key state objects in the key state object list.

Definition at line 1398 of file key_state.c.

## key_state_list_new()

key_state_list_t* key_state_list_new | ( | const db_connection_t * | connection | ) |

Create a new key state object list.

Parameters

  [in] | connection | a db_connection_t pointer.

Returns
  a key_state_list_t pointer or NULL on error.

Definition at line 881 of file key_state.c.

References key_state_list::dbo.

Referenced by key_state_list_new_copy(), and key_state_list_new_get_by_key_data_id().

## key_state_list_new_copy()

key_state_list_t* key_state_list_new_copy | ( | const key_state_list_t * | key_state_copy | ) |

Create a new key state object list that is a copy of another.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Returns
  a key_state_list_t pointer or NULL on error.

Definition at line 895 of file key_state.c.

References db_object_connection(), key_state_list::dbo, key_state_list_copy(), key_state_list_free(), and key_state_list_new().

Referenced by key_data_copy().

## key_state_list_new_get_by_key_data_id()

key_state_list_t* key_state_list_new_get_by_key_data_id | ( | const db_connection_t * | connection,
|  | const db_value_t * | key_data_id
| ) |  |

Get a new list of key state objects from the database by a key_data_id specified in `key_data_id`.

Parameters

  [in] | connection | a db_connection_t pointer.
  [in] | key_data_id | a db_value_t pointer.

Returns
  a key_state_list_t pointer or NULL on error.

Definition at line 1217 of file key_state.c.

References db_value_not_empty(), key_state_list_free(), key_state_list_get_by_key_data_id(), and key_state_list_new().

## key_state_list_next()

const key_state_t* key_state_list_next | ( | key_state_list_t * | key_state_list | ) |

Get the next key state object in a key state object list. Ownership of this object is retained within the list and the object is only valid until the next call to this function.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Returns
  a key_state_t pointer or NULL on error or if there are no more key state objects in the key state object list.

Definition at line 1332 of file key_state.c.

## key_state_list_object_store()

int key_state_list_object_store | ( | key_state_list_t * | key_state_list | ) |

Specify that objects should be stored within the list as they are fetch, this is optimal if the list is to be iterated over more then once.

Parameters

  [in] | key_state_list | a key_state_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 914 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, and key_state_list::object_store.

## key_state_minimize()

unsigned int key_state_minimize | ( | const key_state_t * | key_state | ) |

Get the minimize of a key state object. Undefined behavior if `key_state` is NULL.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  an unsigned integer.

Definition at line 401 of file key_state.c.

References key_state::minimize.

## key_state_new()

key_state_t* key_state_new | ( | const db_connection_t * | connection | ) |

Create a new key state object.

Parameters

  [in] | connection | a db_connection_t pointer.

Returns
  a key_state_t pointer or NULL on error.

Definition at line 176 of file key_state.c.

References key_state::dbo.

Referenced by key_state_new_copy().

## key_state_new_copy()

key_state_t* key_state_new_copy | ( | const key_state_t * | key_state | ) |

Create a new key state object that is a copy of another key state object.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  a key_state_t pointer or NULL on error.

Definition at line 195 of file key_state.c.

References db_object_connection(), key_state::dbo, key_state_copy(), key_state_free(), and key_state_new().

Referenced by key_data_get_cached_dnskey(), key_data_get_cached_ds(), key_data_get_cached_rrsig(), key_data_get_cached_rrsigdnskey(), and key_state_list_copy().

## key_state_set_key_data_id()

int key_state_set_key_data_id | ( | key_state_t * | key_state,
|  | const db_value_t * | key_data_id
| ) |  |

Set the key_data_id of a key state object. If this fails the original value may have been lost.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | key_data_id | a db_value_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 417 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, db_value_copy(), db_value_not_empty(), db_value_reset(), and key_state::key_data_id.

## key_state_set_last_change()

int key_state_set_last_change | ( | key_state_t * | key_state,
|  | unsigned int | last_change
| ) |  |

Set the last_change of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | last_change | an unsigned integer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 462 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, and key_state::last_change.

## key_state_set_minimize()

int key_state_set_minimize | ( | key_state_t * | key_state,
|  | unsigned int | minimize
| ) |  |

Set the minimize of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | minimize | an unsigned integer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 472 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, and key_state::minimize.

## key_state_set_state()

int key_state_set_state | ( | key_state_t * | key_state,
|  | key_state_state_t | state
| ) |  |

Set the state of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | state | a key_state_state_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 449 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, KEY_STATE_STATE_INVALID, and key_state::state.

## key_state_set_ttl()

int key_state_set_ttl | ( | key_state_t * | key_state,
|  | unsigned int | ttl
| ) |  |

Set the ttl of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | ttl | an unsigned integer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 482 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, and key_state::ttl.

## key_state_set_type()

int key_state_set_type | ( | key_state_t * | key_state,
|  | key_state_type_t | type
| ) |  |

Set the type of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.
  [in] | type | a key_state_type_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 436 of file key_state.c.

References DB_ERROR_UNKNOWN, DB_OK, KEY_STATE_TYPE_INVALID, and key_state::type.

## key_state_state()

key_state_state_t key_state_state | ( | const key_state_t * | key_state | ) |

Get the state of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  a key_state_state_t which may be KEY_STATE_STATE_INVALID on error or if no state has been set.

Definition at line 369 of file key_state.c.

References KEY_STATE_STATE_INVALID, and key_state::state.

## key_state_state_text()

const char* key_state_state_text | ( | const key_state_t * | key_state | ) |

Get the state as text of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  a character pointer or NULL on error or if no state has been set.

Definition at line 377 of file key_state.c.

## key_state_ttl()

unsigned int key_state_ttl | ( | const key_state_t * | key_state | ) |

Get the ttl of a key state object. Undefined behavior if `key_state` is NULL.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  an unsigned integer.

Definition at line 409 of file key_state.c.

References key_state::ttl.

## key_state_type()

key_state_type_t key_state_type | ( | const key_state_t * | key_state | ) |

Get the type of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  a key_state_type_t which may be KEY_STATE_TYPE_INVALID on error or if no type has been set.

Definition at line 345 of file key_state.c.

References KEY_STATE_TYPE_INVALID, and key_state::type.

## key_state_type_text()

const char* key_state_type_text | ( | const key_state_t * | key_state | ) |

Get the type as text of a key state object.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  a character pointer or NULL on error or if no type has been set.

Definition at line 353 of file key_state.c.

## key_state_update()

int key_state_update | ( | key_state_t * | key_state | ) |

Update a key state object in the database.

Parameters

  [in] | key_state | a key_state_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 684 of file key_state.c.

## Variable Documentation

## key_state_enum_set_state

const db_enum_t key_state_enum_set_state[]

Initial value:
= {
{ "hidden", (key_state_state_t)KEY_STATE_STATE_HIDDEN },
{ "rumoured", (key_state_state_t)KEY_STATE_STATE_RUMOURED },
{ "omnipresent", (key_state_state_t)KEY_STATE_STATE_OMNIPRESENT },
{ "unretentive", (key_state_state_t)KEY_STATE_STATE_UNRETENTIVE },
{ "NA", (key_state_state_t)KEY_STATE_STATE_NA },
{ NULL, 0 }
}
key_state_state_t
enum key_state_state key_state_state_t
KEY_STATE_STATE_OMNIPRESENT
Definition: key_state.h:53
KEY_STATE_STATE_UNRETENTIVE
Definition: key_state.h:54
KEY_STATE_STATE_NA
Definition: key_state.h:55
KEY_STATE_STATE_HIDDEN
Definition: key_state.h:51
KEY_STATE_STATE_RUMOURED
Definition: key_state.h:52

Definition at line 44 of file key_state.c.

## key_state_enum_set_type

const db_enum_t key_state_enum_set_type[]

Initial value:
= {
{ "DS", (key_state_type_t)KEY_STATE_TYPE_DS },
{ "RRSIG", (key_state_type_t)KEY_STATE_TYPE_RRSIG },
{ "DNSKEY", (key_state_type_t)KEY_STATE_TYPE_DNSKEY },
{ "RRSIGDNSKEY", (key_state_type_t)KEY_STATE_TYPE_RRSIGDNSKEY },
{ NULL, 0 }
}
KEY_STATE_TYPE_DS
Definition: key_state.h:42
KEY_STATE_TYPE_DNSKEY
Definition: key_state.h:44
key_state_type_t
enum key_state_type key_state_type_t
KEY_STATE_TYPE_RRSIG
Definition: key_state.h:43
KEY_STATE_TYPE_RRSIGDNSKEY
Definition: key_state.h:45

Definition at line 36 of file key_state.c.