diff --git a/doc/libpkgconf-client.rst b/doc/libpkgconf-client.rst index 9f131e3..5ec7d62 100644 --- a/doc/libpkgconf-client.rst +++ b/doc/libpkgconf-client.rst @@ -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. diff --git a/libpkgconf/client.c b/libpkgconf/client.c index 463acff..ad617fd 100644 --- a/libpkgconf/client.c +++ b/libpkgconf/client.c @@ -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 * diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 1e3fa06..bf7e940 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -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);