#pragma once #include "utils.h" #include "config.h" /// @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. /// @return The result of the operation. result_t check_container_identifier(const char* container); /// @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. /// @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 config The program configuration to use. /// @param container The identifier of the container to get the path of. /// @return The result of the operation. result_t get_container_path(char** _path, const config_t* config, const char* container); /// @brief Checks whether the specified container exists. This call returns a failure if the container does not exist. /// @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 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); /// @brief Adds a new backed container to the container pool, with the specified identifier and backing. /// @param config The program configuration to use. /// @param container 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); /// @brief Removes the specified container from the container pool. /// @param config The program configuration to use. /// @param container The identifier of the container to remove. /// @return The result of the operation. result_t remove_container(const config_t* config, const char* container); /// @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. /// @return The result of the operation. result_t reset_container(const config_t* config, const char* container); /// @brief Trims the specified container. /// @param config The program configuration to use. /// @param container The identifier of the container to trim. /// @return The result of the operation. result_t trim_container(const config_t* config, const char* container); /// @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. /// @param config The program configuration to use. /// @return The result of the operation. result_t list_containers(char*** _containers, 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. /// @param config The program configuration to use. /// @return The result of the operation. result_t get_oldest_container(char** _container, 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. /// @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); /// @brief Reserves the specified space in the container pool, by removing the oldest containers. /// @param config The program configuration to use. /// @param size The size to reserve, in bytes. /// @return The result of the operation. result_t reserve_space(const config_t* config, uint64_t size);