libpkgconf: client: move pkgconf_error() and pkgconf_default_error_handler() here

feature/tap-sh
William Pitcock 2016-12-15 22:33:01 -06:00
parent c7e505fe44
commit 568e5bfd1b
2 changed files with 48 additions and 23 deletions

View File

@ -196,3 +196,51 @@ pkgconf_client_set_buildroot_dir(pkgconf_client_t *client, const char *buildroot
pkgconf_tuple_add_global(client, "pc_top_builddir", client->buildroot_dir != NULL ? client->buildroot_dir : "$(top_builddir)");
}
/*
* !doc
*
* .. c:function:: bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...)
*
* Report an error to a client-registered error 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 error message.
* :return: true if the error handler processed the message, else false.
* :rtype: bool
*/
bool
pkgconf_error(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->error_handler(errbuf, client, client->error_handler_data);
}
/*
* !doc
*
* .. c:function:: bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data)
*
* The default pkgconf error handler.
*
* :param char* msg: The error message to handle.
* :param pkgconf_client_t* client: The client object the error originated from.
* :param void* data: An opaque pointer to extra data associated with the client for error handling.
* :return: true (the function does nothing to process the message)
* :rtype: bool
*/
bool
pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data)
{
(void) msg;
(void) client;
(void) data;
return true;
}

View File

@ -16,29 +16,6 @@
#include <libpkgconf/config.h>
#include <libpkgconf/libpkgconf.h>
bool
pkgconf_error(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->error_handler(errbuf, client, client->error_handler_data);
}
bool
pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data)
{
(void) msg;
(void) client;
(void) data;
return true;
}
#ifdef _WIN32
# define PKG_CONFIG_REG_KEY "Software\\pkgconfig\\PKG_CONFIG_PATH"
# undef PKG_DEFAULT_PATH