Nix 2.32.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
59enum nix_err {
60
67 NIX_OK = 0,
68
76
84
103
111
112};
113
114typedef enum nix_err nix_err;
115
122 NIX_LVL_ERROR = 0,
123 NIX_LVL_WARN,
124 NIX_LVL_NOTICE,
125 NIX_LVL_INFO,
126 NIX_LVL_TALKATIVE,
127 NIX_LVL_CHATTY,
128 NIX_LVL_DEBUG,
129 NIX_LVL_VOMIT,
130};
131
132typedef enum nix_verbosity nix_verbosity;
133
153typedef struct nix_c_context nix_c_context;
154
162typedef void (*nix_get_string_callback)(const char * start, unsigned int n, void * user_data);
163
164// Function prototypes
165
181
193
211nix_err nix_setting_get(nix_c_context * context, const char * key, nix_get_string_callback callback, void * user_data);
212
227nix_err nix_setting_set(nix_c_context * context, const char * key, const char * value);
228
232// todo: nix_plugins_init()
233
240const char * nix_version_get();
241
261const char * nix_err_msg(nix_c_context * context, const nix_c_context * ctx, unsigned int * n);
262
280 nix_c_context * context, const nix_c_context * read_context, nix_get_string_callback callback, void * user_data);
281
299 nix_c_context * context, const nix_c_context * read_context, nix_get_string_callback callback, void * user_data);
300
311nix_err nix_err_code(const nix_c_context * read_context);
312
325nix_err nix_set_err_msg(nix_c_context * context, nix_err err, const char * msg);
326
347
355
359
360// cffi end
361#ifdef __cplusplus
362}
363#endif
364
366#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:162
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:121
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_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.