MySQL 8.0.39
Source Code Documentation
s_mysql_keyring_keys_metadata_iterator Struct Reference

Keyring keys metadata iterator service provides APIs to create and use iterator to access metadata associated with all keys stored in keyring. More...

#include <keyring_keys_metadata_iterator.h>

Public Attributes

mysql_service_status_t(* init )(my_h_keyring_keys_metadata_iterator *forward_iterator)
 Forward iterator initialization. More...
 
mysql_service_status_t(* deinit )(my_h_keyring_keys_metadata_iterator forward_iterator)
 Iterator deinitialization. More...
 
mysql_service_status_t(* is_valid )(my_h_keyring_keys_metadata_iterator forward_iterator)
 Check validity of the iterator. More...
 
mysql_service_status_t(* next )(my_h_keyring_keys_metadata_iterator forward_iterator)
 Move iterator forward. More...
 
mysql_service_status_t(* get_length )(my_h_keyring_keys_metadata_iterator forward_iterator, size_t *data_id_length, size_t *auth_id_length)
 Fetch length metadata for current key pointed by iterator. More...
 
mysql_service_status_t(* get )(my_h_keyring_keys_metadata_iterator forward_iterator, char *data_id, size_t data_id_length, char *auth_id, size_t auth_id_length)
 Fetch metadata for current key pointed by iterator. More...
 

Detailed Description

Keyring keys metadata iterator service provides APIs to create and use iterator to access metadata associated with all keys stored in keyring.

bool print_keys_metadata() {
char data_id[KEYRING_ITEM_BUFFER_SIZE] = "\0";
char auth_id[KEYRING_ITEM_BUFFER_SIZE] = "\0";
my_h_keyring_keys_metadata_iterator forward_iterator = nullptr;
my_service<SERVICE_TYPE(keyring_keys_metadata_iterator)>
keys_metadata_iterator("keyring_keys_metadata_iterator", m_reg_srv);
if (!keys_metadata_iterator.is_valid()) {
return true;
}
if (keys_metadata_iterator->init(&forward_iterator) == true) {
return true;
}
bool ok = false;
bool move_next = false;
for (; keys_metadata_iterator->is_valid(forward_iterator) && move_next;
move_next = !keys_metadata_iterator->next(forward_iterator)) {
if (keys_metadata_iterator->get(
forward_iterator, data_id, KEYRING_ITEM_BUFFER_SIZE, auth_id,
ok = true;
break;
}
std::cout << "Key name: " << data_id << ". User name: " << auth_id << "."
<< std::endl;
memset(data_id, 0, KEYRING_ITEM_BUFFER_SIZE);
memset(auth_id, 0, KEYRING_ITEM_BUFFER_SIZE);
}
if (keys_metadata_iterator->deinit(forward_iterator)) {
return true;
}
return ok;
}
Wraps my_h_service struct conforming ABI into RAII C++ object with ability to cast to desired service...
Definition: my_service.h:35
struct my_h_keyring_keys_metadata_iterator_imp * my_h_keyring_keys_metadata_iterator
Definition: keyring_keys_metadata_iterator.h:29
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
constexpr auto KEYRING_ITEM_BUFFER_SIZE
Definition: table_keyring_keys.cc:46

Member Data Documentation

◆ deinit

mysql_service_status_t(* s_mysql_keyring_keys_metadata_iterator::deinit) (my_h_keyring_keys_metadata_iterator forward_iterator)

Iterator deinitialization.

Note
forward_iterator should not be used after call to deinit
Parameters
[in,out]forward_iteratormetadata iterator
Returns
Status of the operation
Return values
falseSuccess
trueFailure

◆ get

mysql_service_status_t(* s_mysql_keyring_keys_metadata_iterator::get) (my_h_keyring_keys_metadata_iterator forward_iterator, char *data_id, size_t data_id_length, char *auth_id, size_t auth_id_length)

Fetch metadata for current key pointed by iterator.

Out buffers should be big enough to accommodate data + null terminating character

Parameters
[in]forward_iteratorforward_iterator metadata iterator
[out]data_idID information of current data. Byte string.
[in]data_id_lengthLength of data_id buffer
[out]auth_idOwner of the key. Byte string.
[in]auth_id_lengthLength of auth_id buffer
Returns
Status of the operation
Return values
falseSuccess
trueFailure

◆ get_length

mysql_service_status_t(* s_mysql_keyring_keys_metadata_iterator::get_length) (my_h_keyring_keys_metadata_iterator forward_iterator, size_t *data_id_length, size_t *auth_id_length)

Fetch length metadata for current key pointed by iterator.

Parameters
[in]forward_iteratorforward_iterator metadata iterator
[out]data_id_lengthLength of data_id buffer
[out]auth_id_lengthLength of auth_id buffer
Returns
Status of the operation
Return values
falseSuccess
trueFailure

◆ init

mysql_service_status_t(* s_mysql_keyring_keys_metadata_iterator::init) (my_h_keyring_keys_metadata_iterator *forward_iterator)

Forward iterator initialization.

This function allocates required memory for forward_iterator and initializes it. Caller should use deinit() to perform clean-up.

An iterator may become invalid if content of keyring is changed.

Parameters
[out]forward_iteratormetadata iterator
Returns
Status of the operation
Return values
falseSuccess
trueFailure

◆ is_valid

mysql_service_status_t(* s_mysql_keyring_keys_metadata_iterator::is_valid) (my_h_keyring_keys_metadata_iterator forward_iterator)

Check validity of the iterator.

Parameters
[in]forward_iteratormetadata iterator
Returns
Validty of the iterator
Return values
trueSuccess
falseFailure

◆ next

mysql_service_status_t(* s_mysql_keyring_keys_metadata_iterator::next) (my_h_keyring_keys_metadata_iterator forward_iterator)

Move iterator forward.

Parameters
[in,out]forward_iteratormetadata iterator
Returns
Status of the operation
Return values
falseSuccess - indicates that iterator is pointing to next entry
trueFailure - Failure in moving iterator forward or next was called after iterator reached the end.

The documentation for this struct was generated from the following file: