globalplatform/error.h

Go to the documentation of this file.
00001 /*  Copyright (c) 2009, Karsten Ohme
00002  *  This file is part of GlobalPlatform.
00003  *
00004  *  GlobalPlatform is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  GlobalPlatform is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with GlobalPlatform.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00022 #ifndef OPGP_ERROR_H
00023 #define OPGP_ERROR_H
00024 
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029 
00030 #include "unicode.h"
00031 
00032 #ifdef _WIN32
00033 #define OPGP_ERROR_STATUS_SUCCESS ERROR_SUCCESS //!< No error occured.
00034 #else
00035 #define OPGP_ERROR_STATUS_SUCCESS 0 //!< No error occured.
00036 #endif
00037 
00038 #define OPGP_ERROR_STATUS_FAILURE 1 //!< An error occurred.
00039 
00040 #define ERROR_MESSAGE_LENGTH 256
00041 
00045 typedef struct {
00046         LONG errorStatus; 
00047         LONG errorCode; 
00048         TCHAR errorMessage[ERROR_MESSAGE_LENGTH+1]; 
00049 } OPGP_ERROR_STATUS;
00050 
00055 #define OPGP_ERROR_CHECK(status) status.errorStatus
00056 
00063 #define OPGP_ERROR_CREATE_ERROR(status, code, message) status.errorStatus = OPGP_ERROR_STATUS_FAILURE; \
00064         status.errorCode = code; \
00065         _tcsncpy(status.errorMessage, message, ERROR_MESSAGE_LENGTH); status.errorMessage[ERROR_MESSAGE_LENGTH] = _T('\0')
00066 
00071 #define OPGP_ERROR_CREATE_NO_ERROR(status) status.errorStatus = OPGP_ERROR_STATUS_SUCCESS; status.errorCode = 0; \
00072         _tcsncpy(status.errorMessage, _T("Success"), ERROR_MESSAGE_LENGTH); status.errorMessage[ERROR_MESSAGE_LENGTH] = _T('\0')
00073 
00080 #define OPGP_ERROR_CREATE_NO_ERROR_WITH_CODE(status, code, message) status.errorStatus = OPGP_ERROR_STATUS_SUCCESS; \
00081         status.errorCode = code; \
00082         _tcsncpy(status.errorMessage, message, ERROR_MESSAGE_LENGTH); status.errorMessage[ERROR_MESSAGE_LENGTH] = _T('\0')
00083 
00084 #endif
Generated on Wed Aug 11 00:24:28 2010 for GlobalPlatformLibrary by  doxygen 1.6.3