From 568e5bfd1bff01bb593523d63683337edc8a61e5 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 15 Dec 2016 22:33:01 -0600 Subject: [PATCH] libpkgconf: client: move pkgconf_error() and pkgconf_default_error_handler() here --- libpkgconf/client.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ libpkgconf/pkg.c | 23 ---------------------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/libpkgconf/client.c b/libpkgconf/client.c index 6f26c3a..666675d 100644 --- a/libpkgconf/client.c +++ b/libpkgconf/client.c @@ -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; +} diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index 53dae53..d00fd31 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -16,29 +16,6 @@ #include #include -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