db_result.c File Reference
`#include "db_result.h"`
`#include "db_error.h"`

Go to the source code of this file.

## Functions

db_result_t * | db_result_new (void)
db_result_t * | db_result_new_copy (const db_result_t *from_result)
void | db_result_free (db_result_t *result)
int | db_result_copy (db_result_t *result, const db_result_t *from_result)
const db_value_set_t * | db_result_value_set (const db_result_t *result)
int | db_result_set_value_set (db_result_t *result, db_value_set_t *value_set)
int | db_result_not_empty (const db_result_t *result)
db_result_list_t * | db_result_list_new (void)
db_result_list_t * | db_result_list_new_copy (const db_result_list_t *from_result_list)
void | db_result_list_free (db_result_list_t *result_list)
int | db_result_list_copy (db_result_list_t *result_list, const db_result_list_t *from_result_list)
int | db_result_list_set_next (db_result_list_t *result_list, db_result_list_next_t next_function, void *next_data, size_t size)
int | db_result_list_add (db_result_list_t *result_list, db_result_t *result)
const db_result_t * | db_result_list_begin (db_result_list_t *result_list)
const db_result_t * | db_result_list_next (db_result_list_t *result_list)
size_t | db_result_list_size (const db_result_list_t *result_list)
int | db_result_list_fetch_all (db_result_list_t *result_list)

## Function Documentation

## db_result_copy()

int db_result_copy | ( | db_result_t * | result,
|  | const db_result_t * | from_result
| ) |  |

Copy the content of another database result.

Parameters

  [in] | result | a db_result_t pointer.
  [in] | from_result | a db_result_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 73 of file db_result.c.

## db_result_free()

void db_result_free | ( | db_result_t * | result | ) |

Delete a database result and the backend meta data list if set.

Parameters

  [in] | result | a db_result_t pointer.

Definition at line 63 of file db_result.c.

Referenced by clean_suite_classes(), and test_class_end().

## db_result_list_add()

int db_result_list_add | ( | db_result_list_t * | result_list,
|  | db_result_t * | result
| ) |  |

Add a database result to a database result list, this will takes over the ownership of the database result.

Parameters

  [in] | result_list | a db_result_list_t pointer.
  [in] | result | a db_result_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 257 of file db_result.c.

## db_result_list_begin()

const db_result_t* db_result_list_begin | ( | db_result_list_t * | result_list | ) |

Return the first database result in a database result list and reset the position of the list.

Parameters

  [in] | result_list | a db_result_list_t pointer.

Returns
  a db_result_t pointer or NULL on error or if the list is empty.

Definition at line 290 of file db_result.c.

## db_result_list_copy()

int db_result_list_copy | ( | db_result_list_t * | result_list,
|  | const db_result_list_t * | from_result_list
| ) |  |

free global allocator. db_result_list_free MUST be called for all its contents. Copy the content of another database result list.

Parameters

  [in] | result_list | a db_result_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 183 of file db_result.c.

## db_result_list_fetch_all()

int db_result_list_fetch_all | ( | db_result_list_t * | result_list | ) |

Make sure that all objects in this database result list is loaded into memory so that db_result_list_begin() can be used to iterate over the list multiple times.

Parameters

  [in] | result_list | a db_result_list_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 341 of file db_result.c.

Referenced by database_version_list_get(), key_data_list_get(), policy_list_get(), and zone_list_db_get().

## db_result_list_free()

void db_result_list_free | ( | db_result_list_t * | result_list | ) |

Delete a database result list and all database results within the list.

Parameters

  [in] | result_list | a db_result_list_t pointer.

Definition at line 160 of file db_result.c.

Referenced by clean_suite_classes(), database_version_list_free(), database_version_list_get(), hsm_key_list_copy(), hsm_key_list_free(), key_data_list_copy(), key_data_list_free(), key_data_list_get(), key_dependency_list_copy(), key_dependency_list_free(), key_state_list_copy(), key_state_list_free(), policy_key_list_copy(), policy_key_list_free(), policy_list_copy(), policy_list_free(), policy_list_get(), test_list_free(), test_list_get(), zone_list_db_copy(), zone_list_db_free(), and zone_list_db_get().

## db_result_list_new()

db_result_list_t* db_result_list_new | ( | void |  | ) |

Create a new database result list.

Returns
  a db_result_list_t pointer or NULL on error.

Definition at line 134 of file db_result.c.

## db_result_list_new_copy()

db_result_list_t* db_result_list_new_copy | ( | const db_result_list_t * | from_result_list | ) |

Create a new database result list that is a copy of another.

Parameters

  [in] | from_result_list | a db_result_list_t pointer.

Returns
  a db_result_list_t pointer or NULL on error.

Definition at line 142 of file db_result.c.

Referenced by hsm_key_list_copy(), key_data_list_copy(), key_dependency_list_copy(), key_state_list_copy(), policy_key_list_copy(), policy_list_copy(), and zone_list_db_copy().

## db_result_list_next()

const db_result_t* db_result_list_next | ( | db_result_list_t * | result_list | ) |

Return the next database result in a database result list.

Parameters

  [in] | result_list | a db_result_list_t pointer.

Returns
  a db_result_t pointer or NULL on error or if the end of the list has been reached.

Definition at line 310 of file db_result.c.

## db_result_list_set_next()

int db_result_list_set_next | ( | db_result_list_t * | result_list,
|  | db_result_list_next_t | next_function,
|  | void * | next_data,
|  | size_t | size
| ) |  |

Set the function pointer for fetching the next database result for a database result list. The backend handle specific data is supplied in `next_data` along with the total size of the result list in `size`.

Parameters

  [in] | result_list | a db_result_list_t pointer.
  [in] | next_function | a db_result_list_next_t function pointer.
  [in] | next_data | a void pointer.
  [in] | size | a size_t.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 234 of file db_result.c.

## db_result_list_size()

size_t db_result_list_size | ( | const db_result_list_t * | result_list | ) |

Return the size of the database result list.

Parameters

  [in] | result_list | a db_result_list_t pointer.

Returns
  a size_t with the size of the database result list or zero on error , if the database result list is empty or if the backend does not support returning the size.

Definition at line 333 of file db_result.c.

Referenced by key_data_list_size(), key_dependency_list_size(), policy_key_list_size(), and zone_list_db_size().

## db_result_new()

db_result_t* db_result_new | ( | void |  | ) |

Create a new database result.

Returns
  a db_result_t pointer or NULL on error.

Definition at line 38 of file db_result.c.

## db_result_new_copy()

db_result_t* db_result_new_copy | ( | const db_result_t * | from_result | ) |

Create a new database result that is a copy of another.

Parameters

  [in] | from_result | a db_result_t pointer.

Returns
  a db_result_t pointer or NULL on error.

Definition at line 46 of file db_result.c.

## db_result_not_empty()

int db_result_not_empty | ( | const db_result_t * | result | ) |

Check if a database result is not empty.

Parameters

  [in] | result | a db_result_t pointer.

Returns
  DB_ERROR_* if empty, otherwise DB_OK.

Definition at line 120 of file db_result.c.

## db_result_set_value_set()

int db_result_set_value_set | ( | db_result_t * | result,
|  | db_value_set_t * | value_set
| ) |  |

Set the value set of a database result.

Parameters

  [in] | result | a db_result_t pointer.
  [in] | value_set | a db_value_set_t pointer.

Returns
  DB_ERROR_* on failure, otherwise DB_OK.

Definition at line 105 of file db_result.c.

## db_result_value_set()

const db_value_set_t* db_result_value_set | ( | const db_result_t * | result | ) |

Get the value set of a database result.

Parameters

  [in] | result | a db_result_t pointer.

Returns
  a db_value_set_t pointer or NULL on error or if no value set has been set.

Definition at line 97 of file db_result.c.