mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
C API: rename nix_observe_string -> nix_get_string_callback
This commit is contained in:
parent
061140fc8f
commit
2bb609bce2
5 changed files with 17 additions and 17 deletions
|
@ -62,7 +62,7 @@ nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callbac
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto res = store->ptr->getUri();
|
auto res = store->ptr->getUri();
|
||||||
return call_nix_observe_string(res, callback, user_data);
|
return call_nix_get_string_callback(res, callback, user_data);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ nix_err nix_store_get_version(nix_c_context * context, Store * store, void * cal
|
||||||
context->last_err_code = NIX_OK;
|
context->last_err_code = NIX_OK;
|
||||||
try {
|
try {
|
||||||
auto res = store->ptr->getVersion();
|
auto res = store->ptr->getVersion();
|
||||||
return call_nix_observe_string(res.value_or(""), callback, user_data);
|
return call_nix_get_string_callback(res.value_or(""), callback, user_data);
|
||||||
}
|
}
|
||||||
NIXC_CATCH_ERRS
|
NIXC_CATCH_ERRS
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ void nix_store_free(Store * store);
|
||||||
* @param[in] store nix store reference
|
* @param[in] store nix store reference
|
||||||
* @param[in] callback Called with the URI.
|
* @param[in] callback Called with the URI.
|
||||||
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
||||||
* @see nix_observe_string
|
* @see nix_get_string_callback
|
||||||
* @return error code, NIX_OK on success.
|
* @return error code, NIX_OK on success.
|
||||||
*/
|
*/
|
||||||
nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callback, void * user_data);
|
nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callback, void * user_data);
|
||||||
|
@ -133,7 +133,7 @@ nix_err nix_store_realise(
|
||||||
* @param[in] store nix store reference
|
* @param[in] store nix store reference
|
||||||
* @param[in] callback Called with the version.
|
* @param[in] callback Called with the version.
|
||||||
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
||||||
* @see nix_observe_string
|
* @see nix_get_string_callback
|
||||||
* @return error code, NIX_OK on success.
|
* @return error code, NIX_OK on success.
|
||||||
*/
|
*/
|
||||||
nix_err nix_store_get_version(nix_c_context * context, Store * store, void * callback, void * user_data);
|
nix_err nix_store_get_version(nix_c_context * context, Store * store, void * callback, void * user_data);
|
||||||
|
|
|
@ -72,7 +72,7 @@ nix_err nix_setting_get(nix_c_context * context, const char * key, void * callba
|
||||||
std::map<std::string, nix::AbstractConfig::SettingInfo> settings;
|
std::map<std::string, nix::AbstractConfig::SettingInfo> settings;
|
||||||
nix::globalConfig.getSettings(settings);
|
nix::globalConfig.getSettings(settings);
|
||||||
if (settings.contains(key)) {
|
if (settings.contains(key)) {
|
||||||
return call_nix_observe_string(settings[key].value, callback, user_data);
|
return call_nix_get_string_callback(settings[key].value, callback, user_data);
|
||||||
} else {
|
} else {
|
||||||
return nix_set_err_msg(context, NIX_ERR_KEY, "Setting not found");
|
return nix_set_err_msg(context, NIX_ERR_KEY, "Setting not found");
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ nix_err nix_err_name(nix_c_context * context, const nix_c_context * read_context
|
||||||
if (read_context->last_err_code != NIX_ERR_NIX_ERROR) {
|
if (read_context->last_err_code != NIX_ERR_NIX_ERROR) {
|
||||||
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Last error was not a nix error");
|
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Last error was not a nix error");
|
||||||
}
|
}
|
||||||
return call_nix_observe_string(read_context->name, callback, user_data);
|
return call_nix_get_string_callback(read_context->name, callback, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_err nix_err_info_msg(nix_c_context * context, const nix_c_context * read_context, void * callback, void * user_data)
|
nix_err nix_err_info_msg(nix_c_context * context, const nix_c_context * read_context, void * callback, void * user_data)
|
||||||
|
@ -132,7 +132,7 @@ nix_err nix_err_info_msg(nix_c_context * context, const nix_c_context * read_con
|
||||||
if (read_context->last_err_code != NIX_ERR_NIX_ERROR) {
|
if (read_context->last_err_code != NIX_ERR_NIX_ERROR) {
|
||||||
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Last error was not a nix error");
|
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, "Last error was not a nix error");
|
||||||
}
|
}
|
||||||
return call_nix_observe_string(read_context->info->msg.str(), callback, user_data);
|
return call_nix_get_string_callback(read_context->info->msg.str(), callback, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_err nix_err_code(const nix_c_context * read_context)
|
nix_err nix_err_code(const nix_c_context * read_context)
|
||||||
|
@ -141,8 +141,8 @@ nix_err nix_err_code(const nix_c_context * read_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
nix_err call_nix_observe_string(const std::string str, void * callback, void * user_data)
|
nix_err call_nix_get_string_callback(const std::string str, void * callback, void * user_data)
|
||||||
{
|
{
|
||||||
((nix_observe_string) callback)(str.c_str(), str.size(), user_data);
|
((nix_get_string_callback) callback)(str.c_str(), str.size(), user_data);
|
||||||
return NIX_OK;
|
return NIX_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,9 +124,9 @@ typedef struct nix_c_context nix_c_context;
|
||||||
*
|
*
|
||||||
* @param[in] start the string to copy.
|
* @param[in] start the string to copy.
|
||||||
* @param[in] n the string length.
|
* @param[in] n the string length.
|
||||||
* @param[in] user_data optional, arbitrary data, passed to the nix_observe_string when it's called.
|
* @param[in] user_data optional, arbitrary data, passed to the nix_get_string_callback when it's called.
|
||||||
*/
|
*/
|
||||||
typedef void (*nix_observe_string)(const char * start, unsigned int n, void * user_data);
|
typedef void (*nix_get_string_callback)(const char * start, unsigned int n, void * user_data);
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ nix_err nix_libutil_init(nix_c_context * context);
|
||||||
* @param[in] key The key of the setting to retrieve.
|
* @param[in] key The key of the setting to retrieve.
|
||||||
* @param[in] callback Called with the setting value.
|
* @param[in] callback Called with the setting value.
|
||||||
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
||||||
* @see nix_observe_string
|
* @see nix_get_string_callback
|
||||||
* @return NIX_ERR_KEY if the setting is unknown, or NIX_OK if the setting was retrieved
|
* @return NIX_ERR_KEY if the setting is unknown, or NIX_OK if the setting was retrieved
|
||||||
* successfully.
|
* successfully.
|
||||||
*/
|
*/
|
||||||
|
@ -238,7 +238,7 @@ const char * nix_err_msg(nix_c_context * context, const nix_c_context * ctx, uns
|
||||||
* @param[in] read_context the context to retrieve the error message from.
|
* @param[in] read_context the context to retrieve the error message from.
|
||||||
* @param[in] callback Called with the error message.
|
* @param[in] callback Called with the error message.
|
||||||
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
||||||
* @see nix_observe_string
|
* @see nix_get_string_callback
|
||||||
* @return NIX_OK if there were no errors, an error code otherwise.
|
* @return NIX_OK if there were no errors, an error code otherwise.
|
||||||
*/
|
*/
|
||||||
nix_err
|
nix_err
|
||||||
|
@ -257,7 +257,7 @@ nix_err_info_msg(nix_c_context * context, const nix_c_context * read_context, vo
|
||||||
* @param[in] read_context the context to retrieve the error message from
|
* @param[in] read_context the context to retrieve the error message from
|
||||||
* @param[in] callback Called with the error name.
|
* @param[in] callback Called with the error name.
|
||||||
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
* @param[in] user_data optional, arbitrary data, passed to the callback when it's called.
|
||||||
* @see nix_observe_string
|
* @see nix_get_string_callback
|
||||||
* @return NIX_OK if there were no errors, an error code otherwise.
|
* @return NIX_OK if there were no errors, an error code otherwise.
|
||||||
*/
|
*/
|
||||||
nix_err nix_err_name(nix_c_context * context, const nix_c_context * read_context, void * callback, void * user_data);
|
nix_err nix_err_name(nix_c_context * context, const nix_c_context * read_context, void * callback, void * user_data);
|
||||||
|
|
|
@ -20,16 +20,16 @@ nix_err nix_context_error(nix_c_context * context);
|
||||||
/**
|
/**
|
||||||
* Internal use only.
|
* Internal use only.
|
||||||
*
|
*
|
||||||
* Helper to invoke nix_observe_string
|
* Helper to invoke nix_get_string_callback
|
||||||
* @param context optional, the context to store errors in if this function
|
* @param context optional, the context to store errors in if this function
|
||||||
* fails
|
* fails
|
||||||
* @param str The string to observe
|
* @param str The string to observe
|
||||||
* @param callback Called with the observed string.
|
* @param callback Called with the observed string.
|
||||||
* @param user_data optional, arbitrary data, passed to the callback when it's called.
|
* @param user_data optional, arbitrary data, passed to the callback when it's called.
|
||||||
* @return NIX_OK if there were no errors.
|
* @return NIX_OK if there were no errors.
|
||||||
* @see nix_observe_string
|
* @see nix_get_string_callback
|
||||||
*/
|
*/
|
||||||
nix_err call_nix_observe_string(const std::string str, void * callback, void * user_data);
|
nix_err call_nix_get_string_callback(const std::string str, void * callback, void * user_data);
|
||||||
|
|
||||||
#define NIXC_CATCH_ERRS \
|
#define NIXC_CATCH_ERRS \
|
||||||
catch (...) \
|
catch (...) \
|
||||||
|
|
Loading…
Reference in a new issue