db_result.h File Reference
`#include "db_value.h"`
`#include "db_backend.h"`

Go to the source code of this file.

## Data Structures

struct | db_result
struct | db_result_list

## Typedefs

typedef struct db_result | db_result_t
typedef struct db_result_list | db_result_list_t
typedef db_result_t *(* | db_result_list_next_t) (void *data, int finish)

## 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)

## Typedef Documentation

## db_result_list_next_t

typedef db_result_t *(* db_result_list_next_t) (void *data, int finish)

Function pointer for walking a db_result_list. The backend handle specific data is supplied in `data` and setting `finish` to non-zero tells the backend that we are finished with the db_result_list.

Parameters

  [in] | data | a void pointer for the backend specific data.
  [in] | finish | an integer that if non-zero will tell the backend that we are finished with the result list.

Returns
  A pointer to the next db_result_t or NULL on error.

Definition at line 47 of file db_result.h.

## db_result_list_t

typedef struct db_result_list db_result_list_t

Definition at line 36 of file db_result.h.

## db_result_t

typedef struct db_result db_result_t

Definition at line 35 of file db_result.h.

## Function Documentation

## db_result_copy()

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

extern

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.

References DB_ERROR_UNKNOWN, DB_OK, db_value_set_free(), db_value_set_new_copy(), and db_result::value_set.

Referenced by db_result_new_copy().

## db_result_free()

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

extern

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.

References db_value_set_free(), and db_result::value_set.

Referenced by clean_suite_classes(), db_result_list_fetch_all(), db_result_list_free(), db_result_list_next(), db_result_new_copy(), and test_class_end().

## db_result_list_add()

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

extern

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.

References db_result_list::begin, DB_ERROR_UNKNOWN, DB_OK, db_result_not_empty(), db_result_list::end, db_result::next, db_result_list::next_function, and db_result_list::size.

Referenced by db_result_list_copy(), db_result_list_fetch_all(), and test_class_db_result_list().

## db_result_list_begin()

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

extern

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.

References db_result_list::begin, db_result_list::begun, db_result_list::current, db_result_list::next_data, and db_result_list::next_function.

Referenced by hsm_key_list_begin(), hsm_key_list_get_begin(), key_data_list_begin(), key_data_list_get_begin(), key_dependency_list_begin(), key_dependency_list_get_begin(), key_state_list_begin(), key_state_list_get_begin(), policy_key_list_begin(), policy_list_begin(), test_class_db_result_list(), and zone_list_db_begin().

## db_result_list_copy()

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

extern

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.

References db_result_list::begin, db_result_list::current, DB_ERROR_UNKNOWN, DB_OK, db_result_list_add(), db_result_new_copy(), db_result_list::end, db_result::next, db_result_list::next_function, and db_result_list::size.

Referenced by db_result_list_new_copy().

## db_result_list_fetch_all()

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

extern

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.

References db_result_list::current, DB_ERROR_UNKNOWN, DB_OK, db_result_free(), db_result_list_add(), db_result_list::next_data, db_result_list::next_function, and db_result_list::size.

Referenced by database_version_list_get(), hsm_key_list_get_by_clauses(), hsm_key_list_get_by_policy_id(), key_data_list_get(), key_data_list_get_by_clauses(), key_data_list_get_by_zone_id(), key_dependency_list_get_by_clauses(), key_dependency_list_get_by_zone_id(), key_state_list_get_by_clauses(), key_state_list_get_by_key_data_id(), policy_key_list_get_by_clauses(), policy_key_list_get_by_policy_id(), policy_list_get(), policy_list_get_by_clauses(), zone_list_db_get(), zone_list_db_get_by_clauses(), and zone_list_db_get_by_policy_id().

## db_result_list_free()

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

extern

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.

References db_result_list::begin, db_result_list::current, db_result_free(), db_result_list::next_data, and db_result_list::next_function.

Referenced by clean_suite_classes(), database_version_list_free(), database_version_list_get(), db_result_list_new_copy(), hsm_key_get_by_id(), hsm_key_get_by_locator(), hsm_key_list_copy(), hsm_key_list_free(), hsm_key_list_get_by_clauses(), hsm_key_list_get_by_policy_id(), key_data_get_by_hsm_key_id(), key_data_get_by_id(), key_data_list_copy(), key_data_list_free(), key_data_list_get(), key_data_list_get_by_clauses(), key_data_list_get_by_zone_id(), key_dependency_get_by_id(), key_dependency_list_copy(), key_dependency_list_free(), key_dependency_list_get_by_clauses(), key_dependency_list_get_by_zone_id(), key_state_get_by_id(), key_state_list_copy(), key_state_list_free(), key_state_list_get_by_clauses(), key_state_list_get_by_key_data_id(), policy_get_by_id(), policy_get_by_name(), policy_key_get_by_id(), policy_key_get_by_policyid_and_role(), policy_key_list_copy(), policy_key_list_free(), policy_key_list_get_by_clauses(), policy_key_list_get_by_policy_id(), policy_list_copy(), policy_list_free(), policy_list_get(), policy_list_get_by_clauses(), test2_get_by_id(), test2_get_by_name(), test_class_db_result_list(), test_get_by_id(), test_get_by_name(), test_list_free(), test_list_get(), zone_db_get_by_id(), zone_db_get_by_name(), zone_list_db_copy(), zone_list_db_free(), zone_list_db_get(), zone_list_db_get_by_clauses(), and zone_list_db_get_by_policy_id().

## db_result_list_new()

db_result_list_t * db_result_list_new | ( | void |  | ) |

extern

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.

Referenced by test_class_db_result_list().

## db_result_list_new_copy()

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

extern

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.

References db_result_list_copy(), and db_result_list_free().

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 | ) |

extern

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.

References db_result_list::begin, db_result_list::begun, db_result_list::current, db_result_free(), db_result::next, db_result_list::next_data, and db_result_list::next_function.

Referenced by database_version_list_next(), hsm_key_get_by_id(), hsm_key_get_by_locator(), hsm_key_list_get_next(), hsm_key_list_next(), key_data_get_by_hsm_key_id(), key_data_get_by_id(), key_data_list_get_next(), key_data_list_next(), key_dependency_get_by_id(), key_dependency_list_get_next(), key_dependency_list_next(), key_state_get_by_id(), key_state_list_get_next(), key_state_list_next(), policy_get_by_id(), policy_get_by_name(), policy_key_get_by_id(), policy_key_get_by_policyid_and_role(), policy_key_list_get_next(), policy_key_list_next(), policy_list_get_next(), policy_list_next(), test2_get_by_id(), test2_get_by_name(), test_class_db_result_list(), test_get_by_id(), test_get_by_name(), test_list_begin(), test_list_next(), zone_db_get_by_id(), zone_db_get_by_name(), zone_list_db_get_next(), and zone_list_db_next().

## 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
| ) |  |

extern

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.

References db_result_list::begin, DB_ERROR_UNKNOWN, db_result_list::next_data, db_result_list::next_function, and db_result_list::size.

Referenced by test_class_db_result_list().

## db_result_list_size()

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

extern

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.

References db_result_list::size.

Referenced by database_version_list_next(), hsm_key_list_begin(), hsm_key_list_next(), key_data_list_begin(), key_data_list_next(), key_data_list_size(), key_dependency_list_begin(), key_dependency_list_next(), key_dependency_list_size(), key_state_list_begin(), key_state_list_next(), policy_key_list_begin(), policy_key_list_next(), policy_key_list_size(), policy_list_begin(), policy_list_next(), test_class_db_result_list(), zone_list_db_begin(), zone_list_db_next(), and zone_list_db_size().

## db_result_new()

db_result_t * db_result_new | ( | void |  | ) |

extern

Create a new database result.

Returns
  a db_result_t pointer or NULL on error.

Definition at line 38 of file db_result.c.

Referenced by __db_result_list_next(), db_result_new_copy(), and test_class_db_result().

## db_result_new_copy()

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

extern

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.

References db_result_copy(), db_result_free(), and db_result_new().

Referenced by db_result_list_copy().

## db_result_not_empty()

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

extern

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.

References DB_ERROR_UNKNOWN, DB_OK, and db_result::value_set.

Referenced by __db_result_list_next(), db_result_list_add(), and test_class_db_result().

## db_result_set_value_set()

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

extern

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.

References DB_ERROR_UNKNOWN, DB_OK, and db_result::value_set.

Referenced by __db_result_list_next(), and test_class_db_result().

## db_result_value_set()

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

extern

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.

References db_result::value_set.

Referenced by database_version_from_result(), hsm_key_from_result(), key_data_from_result(), key_dependency_from_result(), key_state_from_result(), policy_from_result(), policy_key_from_result(), test2_from_result(), test_class_db_result(), test_from_result(), and zone_db_from_result().