diff --git a/doc/libpkgconf-client.rst b/doc/libpkgconf-client.rst index 695365b..ccbf399 100644 --- a/doc/libpkgconf-client.rst +++ b/doc/libpkgconf-client.rst @@ -130,3 +130,33 @@ thread boundaries. :param pkgconf_client_t* client: The client object to set the prefix variable name on. :param char* prefix_varname: The prefix variable name to set. :return: nothing + +.. c:function:: pkgconf_client_get_warn_handler(const pkgconf_client_t *client) + + Returns the warning handler if one is set, else ``NULL``. + + :param pkgconf_client_t* client: The client object to get the warn handler from. + :return: a function pointer to the warn handler or ``NULL`` + +.. c:function:: pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler) + + Sets a warn handler on a client object or uninstalls one if set to ``NULL``. + + :param pkgconf_client_t* client: The client object to set the warn handler on. + :param pkgconf_error_handler_func_t warn_handler: The warn handler to set. + :return: nothing + +.. c:function:: pkgconf_client_get_error_handler(const pkgconf_client_t *client) + + Returns the warning handler if one is set, else ``NULL``. + + :param pkgconf_client_t* client: The client object to get the warn handler from. + :return: a function pointer to the warn handler or ``NULL`` + +.. c:function:: pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler) + + Sets a warn handler on a client object or uninstalls one if set to ``NULL``. + + :param pkgconf_client_t* client: The client object to set the warn handler on. + :param pkgconf_error_handler_func_t error_handler: The warn handler to set. + :return: nothing diff --git a/libpkgconf/client.c b/libpkgconf/client.c index b09c14d..8b552bd 100644 --- a/libpkgconf/client.c +++ b/libpkgconf/client.c @@ -341,3 +341,69 @@ pkgconf_client_set_prefix_varname(pkgconf_client_t *client, const char *prefix_v client->prefix_varname = strdup(prefix_varname); } + +/* + * !doc + * + * .. c:function:: pkgconf_client_get_warn_handler(const pkgconf_client_t *client) + * + * Returns the warning handler if one is set, else ``NULL``. + * + * :param pkgconf_client_t* client: The client object to get the warn handler from. + * :return: a function pointer to the warn handler or ``NULL`` + */ +pkgconf_error_handler_func_t +pkgconf_client_get_warn_handler(const pkgconf_client_t *client) +{ + return client->warn_handler; +} + +/* + * !doc + * + * .. c:function:: pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler) + * + * Sets a warn handler on a client object or uninstalls one if set to ``NULL``. + * + * :param pkgconf_client_t* client: The client object to set the warn handler on. + * :param pkgconf_error_handler_func_t warn_handler: The warn handler to set. + * :return: nothing + */ +void +pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler) +{ + client->warn_handler = warn_handler; +} + +/* + * !doc + * + * .. c:function:: pkgconf_client_get_error_handler(const pkgconf_client_t *client) + * + * Returns the warning handler if one is set, else ``NULL``. + * + * :param pkgconf_client_t* client: The client object to get the warn handler from. + * :return: a function pointer to the warn handler or ``NULL`` + */ +pkgconf_error_handler_func_t +pkgconf_client_get_error_handler(const pkgconf_client_t *client) +{ + return client->error_handler; +} + +/* + * !doc + * + * .. c:function:: pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler) + * + * Sets a warn handler on a client object or uninstalls one if set to ``NULL``. + * + * :param pkgconf_client_t* client: The client object to set the warn handler on. + * :param pkgconf_error_handler_func_t error_handler: The warn handler to set. + * :return: nothing + */ +void +pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler) +{ + client->error_handler = error_handler; +} diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 951450c..909aa4d 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -146,6 +146,7 @@ struct pkgconf_client_ { void *error_handler_data; pkgconf_error_handler_func_t error_handler; + pkgconf_error_handler_func_t warn_handler; FILE *auditf; @@ -170,6 +171,10 @@ unsigned int pkgconf_client_get_flags(const pkgconf_client_t *client); void pkgconf_client_set_flags(pkgconf_client_t *client, unsigned int flags); const char *pkgconf_client_get_prefix_varname(const pkgconf_client_t *client); void pkgconf_client_set_prefix_varname(pkgconf_client_t *client, const char *prefix_varname); +pkgconf_error_handler_func_t pkgconf_client_get_warn_handler(const pkgconf_client_t *client); +void pkgconf_client_set_warn_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t warn_handler); +pkgconf_error_handler_func_t pkgconf_client_get_error_handler(const pkgconf_client_t *client); +void pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler); #define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c))) #define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')