89 lines
4.6 KiB
C
89 lines
4.6 KiB
C
#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 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* identifier);
|
|
|
|
/// @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 memory.
|
|
/// @param config The program configuration to use.
|
|
/// @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* identifier);
|
|
|
|
/// @brief Adds a new root container to the pool, with the specified identifier and size.
|
|
/// @param config The program configuration to use.
|
|
/// @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* identifier, size_t size);
|
|
|
|
/// @brief Adds a new backed container to the pool, with the specified identifier and image.
|
|
/// @param config The program configuration to use.
|
|
/// @param identifier The identifier of the container to add.
|
|
/// @param image The identifier of the image to use.
|
|
/// @return The result of the operation.
|
|
result_t add_backed_container(const config_t* config, const char* identifier, const char* image);
|
|
|
|
/// @brief Removes the specified container from the pool.
|
|
/// @param config The program configuration to use.
|
|
/// @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* identifier);
|
|
|
|
/// @brief Resets the specified container to its original state.
|
|
/// @param config The program configuration to use.
|
|
/// @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* identifier);
|
|
|
|
/// @brief Trims the specified container.
|
|
/// @param config The program configuration to use.
|
|
/// @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* identifier);
|
|
|
|
/// @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*** _identifiers, size_t* _count, const config_t* config);
|
|
|
|
/// @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_container_pool_space(size_t* _space, const config_t* config);
|
|
|
|
/// @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 find_oldest_container(char** _identifier, const config_t* config);
|
|
|
|
/// @brief Reserves the specified space in the pool by removing the oldest containers.
|
|
/// @param config The program configuration to use.
|
|
/// @param space The space to reserve, in bytes.
|
|
/// @return The result of the operation.
|
|
result_t reserve_container_pool_space(const config_t* config, size_t space); |