Nix 2.34.6
Nix, the purely functional package manager: C API (experimental)
Loading...
Searching...
No Matches
nix_api_util.h
Go to the documentation of this file.
1#ifndef NIX_API_UTIL_H
2#define NIX_API_UTIL_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20// cffi start
21
48// Error codes
120
121typedef enum nix_err nix_err;
122
129 NIX_LVL_ERROR = 0,
130 NIX_LVL_WARN,
131 NIX_LVL_NOTICE,
132 NIX_LVL_INFO,
133 NIX_LVL_TALKATIVE,
134 NIX_LVL_CHATTY,
135 NIX_LVL_DEBUG,
136 NIX_LVL_VOMIT,
137};
138
139typedef enum nix_verbosity nix_verbosity;
140
160typedef struct nix_c_context nix_c_context;
161
171typedef void (*nix_get_string_callback)(const char * start, unsigned int n, void * user_data);
172
173// Function prototypes
174
190
202
220nix_err nix_setting_get(nix_c_context * context, const char * key, nix_get_string_callback callback, void * user_data);
221
236nix_err nix_setting_set(nix_c_context * context, const char * key, const char * value);
237
241// todo: nix_plugins_init()
242
249const char * nix_version_get();
250
270const char * nix_err_msg(nix_c_context * context, const nix_c_context * ctx, unsigned int * n);
271
289 nix_c_context * context, const nix_c_context * read_context, nix_get_string_callback callback, void * user_data);
290
308 nix_c_context * context, const nix_c_context * read_context, nix_get_string_callback callback, void * user_data);
309
320nix_err nix_err_code(const nix_c_context * read_context);
321
334nix_err nix_set_err_msg(nix_c_context * context, nix_err err, const char * msg);
335
356
364
368
369// cffi end
370#ifdef __cplusplus
371}
372#endif
373
375#endif // NIX_API_UTIL_H
nix_err nix_set_err_msg(nix_c_context *context, nix_err err, const char *msg)
Set an error message on a nix context.
void nix_clear_err(nix_c_context *context)
Clear the error message from a nix context.
nix_c_context * nix_c_context_create()
Allocate a new nix_c_context.
nix_err nix_err_name(nix_c_context *context, const nix_c_context *read_context, nix_get_string_callback callback, void *user_data)
Retrieves the error name from a context.
void nix_c_context_free(nix_c_context *context)
Free a nix_c_context. Does not fail.
nix_err nix_set_verbosity(nix_c_context *context, nix_verbosity level)
Sets the verbosity level.
nix_err nix_err_info_msg(nix_c_context *context, const nix_c_context *read_context, nix_get_string_callback callback, void *user_data)
Retrieves the error message from errorInfo in a context.
void(* nix_get_string_callback)(const char *start, unsigned int n, void *user_data)
Called to get the value of a string owned by Nix.
Definition nix_api_util.h:171
const char * nix_err_msg(nix_c_context *context, const nix_c_context *ctx, unsigned int *n)
Retrieves the most recent error message from a context.
nix_verbosity
Verbosity level.
Definition nix_api_util.h:128
nix_err nix_err_code(const nix_c_context *read_context)
Retrieves the most recent error code from a nix_c_context.
nix_err
Type for error codes in the Nix system.
Definition nix_api_util.h:59
@ NIX_ERR_OVERFLOW
An overflow error occurred.
Definition nix_api_util.h:83
@ NIX_ERR_UNKNOWN
An unknown error occurred.
Definition nix_api_util.h:75
@ NIX_OK
No error occurred.
Definition nix_api_util.h:67
@ NIX_ERR_NIX_ERROR
A generic Nix error occurred.
Definition nix_api_util.h:110
@ NIX_ERR_RECOVERABLE
A recoverable error occurred.
Definition nix_api_util.h:118
@ NIX_ERR_KEY
A key/index access error occurred in C API functions.
Definition nix_api_util.h:102
const char * nix_version_get()
Retrieves the nix library version.
nix_err nix_libutil_init(nix_c_context *context)
Initializes nix_libutil and its dependencies.
nix_err nix_setting_set(nix_c_context *context, const char *key, const char *value)
Sets a setting in the nix global configuration.
nix_err nix_setting_get(nix_c_context *context, const char *key, nix_get_string_callback callback, void *user_data)
Retrieves a setting from the nix global configuration.
This object stores error state.