libpkgconf: client: add warn handler and getter/setter for both warn handler and error handler

feature/tap-sh
William Pitcock 2017-02-04 18:37:58 -06:00
parent badcd8d2ef
commit c0b6a62c40
3 changed files with 101 additions and 0 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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) == '=')