From 151ad8927deea15aa364208b0a7db2f41f05e446 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Wed, 8 Oct 2014 17:14:01 +0200 Subject: [PATCH] Change client API error codes Add CYNARA_API_ACCESS_ALLOWED to be returned instead of CYNARA_API_SUCCESS from cynara check call. Renumber client API error codes - now CYNARA_API_ACCESS_DENIED is treated as answer, not as error. Change-Id: I3d64afdc3cc241de8515be507858304efd729da6 --- src/client-common/plugins/NaiveInterpreter.h | 2 +- src/include/cynara-client-error.h | 23 +++++++++++++---------- src/include/cynara-client.h | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/client-common/plugins/NaiveInterpreter.h b/src/client-common/plugins/NaiveInterpreter.h index e16f463..a541e19 100644 --- a/src/client-common/plugins/NaiveInterpreter.h +++ b/src/client-common/plugins/NaiveInterpreter.h @@ -37,7 +37,7 @@ class NaiveInterpreter : public InterpreterInterface { } int toResult(const PolicyResult &result) noexcept { if (result.policyType() == PredefinedPolicyType::ALLOW) - return CYNARA_API_SUCCESS; + return CYNARA_API_ACCESS_ALLOWED; else return CYNARA_API_ACCESS_DENIED; } diff --git a/src/include/cynara-client-error.h b/src/include/cynara-client-error.h index 36d20f4..9828942 100644 --- a/src/include/cynara-client-error.h +++ b/src/include/cynara-client-error.h @@ -27,33 +27,36 @@ /** * \name Return Codes * exported by the foundation API. - * result codes begin with the start error code and extend into negative direction. + * result codes beginning with negative codes indicate an error. * @{ */ -/*! \brief indicating the result of the one specific API is successful or access is allowed */ -#define CYNARA_API_SUCCESS 0 +/*! \brief indicating access that was checked is allowed */ +#define CYNARA_API_ACCESS_ALLOWED 2 /*! \brief indicating that access that was checked is denied */ -#define CYNARA_API_ACCESS_DENIED -1 +#define CYNARA_API_ACCESS_DENIED 1 + +/*! \brief indicating the result of the one specific API is successful */ +#define CYNARA_API_SUCCESS 0 /*! \brief indicating system is running out of memory state */ -#define CYNARA_API_OUT_OF_MEMORY -2 +#define CYNARA_API_OUT_OF_MEMORY -1 /*! \brief indicating the API's parameter is malformed */ -#define CYNARA_API_INVALID_PARAM -3 +#define CYNARA_API_INVALID_PARAM -2 /*! \brief service not available */ -#define CYNARA_API_SERVICE_NOT_AVAILABLE -4 +#define CYNARA_API_SERVICE_NOT_AVAILABLE -3 /*! \brief indicating that value is not present in cache */ -#define CYNARA_API_CACHE_MISS -5 +#define CYNARA_API_CACHE_MISS -4 /*! \brief indicating that provided method is not supported by library */ -#define CYNARA_API_METHOD_NOT_SUPPORTED -6 +#define CYNARA_API_METHOD_NOT_SUPPORTED -5 /*! \brief indicating an unknown error */ -#define CYNARA_API_UNKNOWN_ERROR -7 +#define CYNARA_API_UNKNOWN_ERROR -6 /** @}*/ #endif // CYNARA_CLIENT_ERROR_H diff --git a/src/include/cynara-client.h b/src/include/cynara-client.h index dcdab40..3f4c938 100644 --- a/src/include/cynara-client.h +++ b/src/include/cynara-client.h @@ -133,7 +133,7 @@ int cynara_finish(cynara *p_cynara); * \param[in] user User running client. * \param[in] privilege Privilege that is a subject of a check.. * - * \return CYNARA_API_SUCCESS on success (access granted), CYNARA_API_ACCESS_DENIED on access denial + * \return CYNARA_API_ACCESS_ALLOWED on access allowed, CYNARA_API_ACCESS_DENIED on access denial * or other error code on error. */ int cynara_check(cynara *p_cynara, const char *client, const char *client_session, const char *user, -- 2.7.4