libpkgconf: client: add pkgconf_warn()

feature/tap-sh
William Pitcock 2017-02-04 18:46:53 -06:00
parent eb98a1e6c3
commit a6755cd792
3 changed files with 35 additions and 0 deletions

View File

@ -88,6 +88,15 @@ thread boundaries.
:return: true if the error handler processed the message, else false.
:rtype: bool
.. c:function:: bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...)
Report an error to a client-registered warn handler.
:param pkgconf_client_t* client: The pkgconf client object to report the error to.
:param char* format: A printf-style format string to use for formatting the warning message.
:return: true if the warn handler processed the message, else false.
:rtype: bool
.. c:function:: bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data)
The default pkgconf error handler.

View File

@ -244,6 +244,31 @@ pkgconf_error(const pkgconf_client_t *client, const char *format, ...)
return client->error_handler(errbuf, client, client->error_handler_data);
}
/*
* !doc
*
* .. c:function:: bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...)
*
* Report an error to a client-registered warn handler.
*
* :param pkgconf_client_t* client: The pkgconf client object to report the error to.
* :param char* format: A printf-style format string to use for formatting the warning message.
* :return: true if the warn handler processed the message, else false.
* :rtype: bool
*/
bool
pkgconf_warn(const pkgconf_client_t *client, const char *format, ...)
{
char errbuf[PKGCONF_BUFSIZE];
va_list va;
va_start(va, format);
vsnprintf(errbuf, sizeof errbuf, format, va);
va_end(va);
return client->warn_handler(errbuf, client, client->warn_handler_data);
}
/*
* !doc
*

View File

@ -213,6 +213,7 @@ void pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_ha
#endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */
bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data);
pkgconf_pkg_t *pkgconf_pkg_ref(const pkgconf_client_t *client, pkgconf_pkg_t *pkg);