mirror of
https://github.com/NixOS/nix.git
synced 2025-11-18 16:29:36 +01:00
Merge pull request #14579 from obsidiansystems/store-c-header-split
libstore-c: Organize API into separate headers
This commit is contained in:
commit
d5b6e1a0fc
4 changed files with 96 additions and 36 deletions
|
|
@ -35,6 +35,8 @@ include_dirs = [ include_directories('.') ]
|
||||||
|
|
||||||
headers = files(
|
headers = files(
|
||||||
'nix_api_store.h',
|
'nix_api_store.h',
|
||||||
|
'nix_api_store/derivation.h',
|
||||||
|
'nix_api_store/store_path.h',
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO don't install this once tests don't use it and/or move the header into `libstore`, non-`c`
|
# TODO don't install this once tests don't use it and/or move the header into `libstore`, non-`c`
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nix_api_util.h"
|
#include "nix_api_util.h"
|
||||||
|
#include "nix_api_store/store_path.h"
|
||||||
|
#include "nix_api_store/derivation.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
@ -21,10 +23,6 @@ extern "C" {
|
||||||
|
|
||||||
/** @brief Reference to a Nix store */
|
/** @brief Reference to a Nix store */
|
||||||
typedef struct Store Store;
|
typedef struct Store Store;
|
||||||
/** @brief Nix store path */
|
|
||||||
typedef struct StorePath StorePath;
|
|
||||||
/** @brief Nix Derivation */
|
|
||||||
typedef struct nix_derivation nix_derivation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the Nix store library
|
* @brief Initializes the Nix store library
|
||||||
|
|
@ -118,30 +116,6 @@ nix_store_get_storedir(nix_c_context * context, Store * store, nix_get_string_ca
|
||||||
*/
|
*/
|
||||||
StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const char * path);
|
StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const char * path);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the path name (e.g. "name" in /nix/store/...-name)
|
|
||||||
*
|
|
||||||
* @param[in] store_path the path to get the name from
|
|
||||||
* @param[in] callback called with the name
|
|
||||||
* @param[in] user_data arbitrary data, passed to the callback when it's called.
|
|
||||||
*/
|
|
||||||
void nix_store_path_name(const StorePath * store_path, nix_get_string_callback callback, void * user_data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy a StorePath
|
|
||||||
*
|
|
||||||
* @param[in] p the path to copy
|
|
||||||
* @return a new StorePath
|
|
||||||
*/
|
|
||||||
StorePath * nix_store_path_clone(const StorePath * p);
|
|
||||||
|
|
||||||
/** @brief Deallocate a StorePath
|
|
||||||
*
|
|
||||||
* Does not fail.
|
|
||||||
* @param[in] p the path to free
|
|
||||||
*/
|
|
||||||
void nix_store_path_free(StorePath * p);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if a StorePath is valid (i.e. that corresponding store object and its closure of references exists in
|
* @brief Check if a StorePath is valid (i.e. that corresponding store object and its closure of references exists in
|
||||||
* the store)
|
* the store)
|
||||||
|
|
@ -229,14 +203,6 @@ nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store
|
||||||
*/
|
*/
|
||||||
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation);
|
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Deallocate a `nix_derivation`
|
|
||||||
*
|
|
||||||
* Does not fail.
|
|
||||||
* @param[in] drv the derivation to free
|
|
||||||
*/
|
|
||||||
void nix_derivation_free(nix_derivation * drv);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy the closure of `path` from `srcStore` to `dstStore`.
|
* @brief Copy the closure of `path` from `srcStore` to `dstStore`.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
38
src/libstore-c/nix_api_store/derivation.h
Normal file
38
src/libstore-c/nix_api_store/derivation.h
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef NIX_API_STORE_DERIVATION_H
|
||||||
|
#define NIX_API_STORE_DERIVATION_H
|
||||||
|
/**
|
||||||
|
* @defgroup libstore_derivation Derivation
|
||||||
|
* @ingroup libstore
|
||||||
|
* @brief Derivation operations that don't require a Store
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** @file
|
||||||
|
* @brief Derivation operations
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nix_api_util.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
// cffi start
|
||||||
|
|
||||||
|
/** @brief Nix Derivation */
|
||||||
|
typedef struct nix_derivation nix_derivation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deallocate a `nix_derivation`
|
||||||
|
*
|
||||||
|
* Does not fail.
|
||||||
|
* @param[in] drv the derivation to free
|
||||||
|
*/
|
||||||
|
void nix_derivation_free(nix_derivation * drv);
|
||||||
|
|
||||||
|
// cffi end
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif // NIX_API_STORE_DERIVATION_H
|
||||||
54
src/libstore-c/nix_api_store/store_path.h
Normal file
54
src/libstore-c/nix_api_store/store_path.h
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef NIX_API_STORE_STORE_PATH_H
|
||||||
|
#define NIX_API_STORE_STORE_PATH_H
|
||||||
|
/**
|
||||||
|
* @defgroup libstore_storepath StorePath
|
||||||
|
* @ingroup libstore
|
||||||
|
* @brief Store path operations that don't require a Store
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** @file
|
||||||
|
* @brief Store path operations
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nix_api_util.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
// cffi start
|
||||||
|
|
||||||
|
/** @brief Nix store path */
|
||||||
|
typedef struct StorePath StorePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Copy a StorePath
|
||||||
|
*
|
||||||
|
* @param[in] p the path to copy
|
||||||
|
* @return a new StorePath
|
||||||
|
*/
|
||||||
|
StorePath * nix_store_path_clone(const StorePath * p);
|
||||||
|
|
||||||
|
/** @brief Deallocate a StorePath
|
||||||
|
*
|
||||||
|
* Does not fail.
|
||||||
|
* @param[in] p the path to free
|
||||||
|
*/
|
||||||
|
void nix_store_path_free(StorePath * p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the path name (e.g. "<name>" in /nix/store/<hash>-<name>)
|
||||||
|
*
|
||||||
|
* @param[in] store_path the path to get the name from
|
||||||
|
* @param[in] callback called with the name
|
||||||
|
* @param[in] user_data arbitrary data, passed to the callback when it's called.
|
||||||
|
*/
|
||||||
|
void nix_store_path_name(const StorePath * store_path, nix_get_string_callback callback, void * user_data);
|
||||||
|
|
||||||
|
// cffi end
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif // NIX_API_STORE_STORE_PATH_H
|
||||||
Loading…
Add table
Add a link
Reference in a new issue