/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#ifndef _CKM_ERROR_H_
#define _CKM_ERROR_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <ckm/ckm-type.h>
/**
* \name Return Codes
#define CKM_API_ERROR_UNKNOWN -255
/** @}*/
-#ifdef __cplusplus
-}
-#endif
+namespace CKM {
+
+/*! \brief returns stringified name of return code/status constant */
+KEY_MANAGER_API const char * APICodeToString(int error);
+
+} // namespace CKM
#endif
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file ckm-zero-memory.cpp
+ * @author Tomasz Swierczek (t.swierczek@samsung.com)
+ * @version 1.0
+ */
+
+#include <ckm/ckm-error.h>
+
+namespace CKM {
+
+#define CKM_CODE_DESCRIBE(name) case name: return #name
+const char * APICodeToString(int error) {
+ switch (error) {
+ CKM_CODE_DESCRIBE(CKM_API_SUCCESS);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_SOCKET);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_BAD_REQUEST);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_BAD_RESPONSE);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_SEND_FAILED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_RECV_FAILED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_AUTHENTICATION_FAILED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_INPUT_PARAM);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_BUFFER_TOO_SMALL);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_OUT_OF_MEMORY);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_ACCESS_DENIED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_SERVER_ERROR);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_DB_LOCKED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_DB_ERROR);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_DB_ALIAS_EXISTS);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_DB_ALIAS_UNKNOWN);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_VERIFICATION_FAILED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_INVALID_FORMAT);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_FILE_ACCESS_DENIED);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_NOT_EXPORTABLE);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_FILE_SYSTEM);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_NOT_SUPPORTED);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_GOOD);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_UNSUPPORTED);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_UNKNOWN);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_REVOKED);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_NET_ERROR);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_INVALID_URL);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_INVALID_RESPONSE);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_REMOTE_ERROR);
+ CKM_CODE_DESCRIBE(CKM_API_OCSP_STATUS_INTERNAL_ERROR);
+ CKM_CODE_DESCRIBE(CKM_API_ERROR_UNKNOWN);
+ default: return "Code not defined";
+ }
+}
+#undef CKM_CODE_DESCRIBE
+
+} // namespace CKM