Added a verbose logging system

This commit is contained in:
2024-02-29 09:50:28 +01:00
parent a02cd9fe20
commit 0373d159a2
10 changed files with 1345 additions and 1028 deletions

View File

@@ -6,82 +6,84 @@
/// @brief The maximum length of a container identifier.
#define MAX_CONTAINER_IDENTIFIER_LENGTH 64
/// @brief Checks whether the specified container identifier is valid. This call returns a failure if the identifier is invalid.
/// @param container The container identifier to check.
/// @brief Checks whether the specified container identifier is valid. This call will return an error with a message describing the problem if the identifier is invalid.
/// @param identifier The identifier to check.
/// @return The result of the operation.
result_t check_container_identifier(const char* container);
result_t check_container_identifier(const char* identifier);
/// @brief Returns the path of the container pool.
/// @param _path The pointer to where the path should be stored. The caller is responsible for freeing the path.
/// @brief Checks whether the specified container exists.
/// @param _exists The pointer to where the result should be stored.
/// @param config The program configuration to use.
/// @param identifier The identifier of the container to check.
/// @return The result of the operation.
result_t check_container_exists(bool* _exists, const config_t* config, const char* identifier);
/// @brief Returns the path of the container pool directory.
/// @param _path The pointer to where the path should be stored. The caller is responsible for freeing the memory.
/// @param config The program configuration to use.
/// @return The result of the operation.
result_t get_container_pool_path(char** _path, const config_t* config);
/// @brief Returns the path of the specified container.
/// @param _path The pointer to where the path should be stored. The caller is responsible for freeing the path.
/// @param _path The pointer to where the path should be stored. The caller is responsible for freeing the memory.
/// @param config The program configuration to use.
/// @param container The identifier of the container to get the path of.
/// @param identifier The identifier of the container.
/// @return The result of the operation.
result_t get_container_path(char** _path, const config_t* config, const char* container);
result_t get_container_path(char** _path, const config_t* config, const char* identifier);
/// @brief Checks whether the specified container exists. This call returns a failure if the container does not exist.
/// @brief Adds a new root container to the pool, with the specified identifier and size.
/// @param config The program configuration to use.
/// @param container The identifier of the container to check.
/// @return Whether the container exists.
result_t check_container_exists(const config_t* config, const char* container);
/// @brief Adds a new root container to the container pool, with the specified identifier and size.
/// @param config The program configuration to use.
/// @param container The identifier of the container to add.
/// @param identifier The identifier of the container to add.
/// @param size The size of the container to add, in bytes.
/// @return The result of the operation.
result_t add_root_container(const config_t* config, const char* container, uint64_t size);
result_t add_root_container(const config_t* config, const char* identifier, size_t size);
/// @brief Adds a new backed container to the container pool, with the specified identifier and backing.
/// @brief Adds a new backed container to the pool, with the specified identifier and backing.
/// @param config The program configuration to use.
/// @param container The identifier of the container to add.
/// @param identifier The identifier of the container to add.
/// @param backing The identifier of the backing to use.
/// @return The result of the operation.
result_t add_backed_container(const config_t* config, const char* container, const char* backing);
result_t add_backed_container(const config_t* config, const char* identifier, const char* backing);
/// @brief Removes the specified container from the container pool.
/// @brief Removes the specified container from the pool.
/// @param config The program configuration to use.
/// @param container The identifier of the container to remove.
/// @param identifier The identifier of the container to remove.
/// @return The result of the operation.
result_t remove_container(const config_t* config, const char* container);
result_t remove_container(const config_t* config, const char* identifier);
/// @brief Resets the specified container to its original state.
/// @param config The program configuration to use.
/// @param container The identifier of the container to reset.
/// @param identifier The identifier of the container to reset.
/// @return The result of the operation.
result_t reset_container(const config_t* config, const char* container);
result_t reset_container(const config_t* config, const char* identifier);
/// @brief Trims the specified container.
/// @param config The program configuration to use.
/// @param container The identifier of the container to trim.
/// @param identifier The identifier of the container to trim.
/// @return The result of the operation.
result_t trim_container(const config_t* config, const char* container);
result_t trim_container(const config_t* config, const char* identifier);
/// @brief Lists the containers in the container pool, and returns the result in a null-terminated array of strings.
/// @param _containers The pointer to where the containers array should be stored. The caller is responsible for freeing the containers array as well as the strings in the array.
/// @brief Lists the containers in the pool.
/// @param _identifiers The pointer to where the list of identifiers should be stored. The caller is responsible for freeing the strings and the array.
/// @param _count The pointer to where the count of identifiers should be stored.
/// @param config The program configuration to use.
/// @return The result of the operation.
result_t list_containers(char*** _containers, const config_t* config);
result_t list_containers(char*** _identifiers, size_t* _count, const config_t* config);
/// @brief Returns the oldest container in the container pool.
/// @param _container The pointer to where the container should be stored. The caller is responsible for freeing the container.
/// @brief Returns the available space in the pool.
/// @param _space The pointer to where the available space should be stored, in bytes.
/// @param config The program configuration to use.
/// @return The result of the operation.
result_t get_oldest_container(char** _container, const config_t* config);
result_t get_container_pool_space(size_t* _space, const config_t* config);
/// @brief Calculates the total available space in the container pool.
/// @param _size The pointer to where the size should be stored.
/// @brief Find the oldest container in the pool.
/// @param _identifier The pointer to where the identifier of the oldest container should be stored.
/// @param config The program configuration to use.
/// @return The result of the operation.
result_t get_available_space(uint64_t* _size, const config_t* config);
result_t find_oldest_container(char** _identifier, const config_t* config);
/// @brief Reserves the specified space in the container pool, by removing the oldest containers.
/// @brief Reserves the specified space in the pool by removing the oldest containers.
/// @param config The program configuration to use.
/// @param size The size to reserve, in bytes.
/// @param space The space to reserve, in bytes.
/// @return The result of the operation.
result_t reserve_space(const config_t* config, uint64_t size);
result_t reserve_container_pool_space(const config_t* config, size_t space);