Eneboo - Documentación para desarrolladores
src/libdigidoc/DigiDocError.h
Ir a la documentación de este archivo.
00001 #ifndef __DIGI_DOC_ERROR_H__
00002 #define __DIGI_DOC_ERROR_H__
00003 //==================================================
00004 // FILE:        DigiDocError.h
00005 // PROJECT: Digi Doc
00006 // DESCRIPTION: Digi Doc error codes and functions 
00007 // AUTHOR:  Veiko Sinivee, S|E|B IT Partner Estonia
00008 //==================================================
00009 // Copyright (C) AS Sertifitseerimiskeskus
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.ode
00018 // GNU Lesser General Public Licence is available at
00019 // http://www.gnu.org/copyleft/lesser.html
00020 //==========< HISTORY >=============================
00021 //==================================================
00022 
00023 #ifdef WIN32
00024         #include <windows.h>
00025 #endif
00026 
00027 #ifdef  __cplusplus
00028 extern "C" {
00029 #endif
00030         
00031 //==========< error codes >=======================
00032 
00033 #define ERR_OK                                          0
00034 #define ERR_UNSUPPORTED_DIGEST          1
00035 #define ERR_FILE_READ                           2
00036 #define ERR_FILE_WRITE                          3
00037 #define ERR_DIGEST_LEN                          4
00038 #define ERR_BUF_LEN                                     5
00039 #define ERR_SIGNATURE_LEN                       6
00040 #define ERR_PRIVKEY_READ                        7
00041 #define ERR_PUBKEY_READ                         8
00042 #define ERR_CERT_READ                           9
00043 #define ERR_SIGNEDINFO_CREATE           10
00044 #define ERR_SIGNEDINFO_DATA                     11
00045 #define ERR_SIGNEDINFO_FINAL            12
00046 #define ERR_UNSUPPORTED_FORMAT          13
00047 #define ERR_BAD_INDEX                           14
00048 #define ERR_TIMESTAMP_DECODE            15
00049 #define ERR_DIGIDOC_PARSE                       16
00050 #define ERR_UNSUPPORTED_SIGNATURE       17
00051 #define ERR_CERT_STORE_READ                     18
00052 #define ERR_SIGPROP_DIGEST                      19
00053 #define ERR_COMPARE                                     20
00054 #define ERR_DOC_DIGEST                          21
00055 #define ERR_MIME_DIGEST                         22
00056 #define ERR_SIGNATURE                           23
00057 #define ERR_CERT_INVALID                        24
00058 #define ERR_OCSP_UNSUCCESSFUL           25
00059 #define ERR_OCSP_UNKNOWN_TYPE           26
00060 #define ERR_OCSP_NO_BASIC_RESP          27
00061 #define ERR_OCSP_WRONG_VERSION          28
00062 #define ERR_OCSP_WRONG_RESPID           29
00063 #define ERR_OCSP_ONE_RESPONSE           30
00064 #define ERR_OCSP_RESP_STATUS            31
00065 #define ERR_OCSP_NO_SINGLE_EXT          32
00066 #define ERR_OCSP_NO_NONCE                       33
00067 #define ERR_NOTARY_NO_SIGNATURE         34
00068 #define ERR_NOTARY_SIG_MATCH            35
00069 #define ERR_SIGNERS_CERT_NOT_TRUSTED   36
00070 
00071 #define ERR_WRONG_CERT                          37
00072 #define ERR_NULL_POINTER            38
00073 #define ERR_NULL_CERT_POINTER       39
00074 #define ERR_NULL_SER_NUM_POINTER    40
00075 #define ERR_NULL_KEY_POINTER        41
00076 #define ERR_EMPTY_STRING            42
00077 #define ERR_BAD_DATAFILE_INDEX      43
00078 #define ERR_BAD_DATAFILE_COUNT      44
00079 #define ERR_BAD_ATTR_COUNT          45
00080 #define ERR_BAD_ATTR_INDEX          46
00081 #define ERR_BAD_SIG_INDEX           47
00082 #define ERR_BAD_SIG_COUNT           48
00083 #define ERR_BAD_ROLE_INDEX          49
00084 #define ERR_BAD_DOCINFO_COUNT       50
00085 #define ERR_BAD_DOCINFO_INDEX       51
00086 #define ERR_BAD_NOTARY_INDEX        52
00087 #define ERR_BAD_NOTARY_ID                       53
00088 #define ERR_BAD_NOTARY_COUNT            54
00089 #define ERR_X509_DIGEST             55
00090 #define ERR_CERT_LENGTH             56
00091 #define ERR_PKCS_LIB_LOAD           57
00092 #define ERR_PKCS_SLOT_LIST          58
00093 #define ERR_PKCS_WRONG_SLOT         59
00094 #define ERR_PKCS_LOGIN              60
00095 #define ERR_PKCS_PK                 61
00096 #define ERR_PKCS_CERT_LOC           62
00097 #define ERR_PKCS_CERT_DECODE        63
00098 #define ERR_PKCS_SIGN_DATA          64
00099 #define ERR_PKCS_CARD_READ          65
00100 #define ERR_CSP_NO_CARD_DATA        66
00101 #define ERR_CSP_OPEN_STORE                      67
00102 #define ERR_CSP_CERT_FOUND                      68
00103 #define ERR_CSP_SIGN                            69
00104 #define ERR_CSP_NO_HASH_START   70
00105 #define ERR_CSP_NO_HASH                 71
00106 #define ERR_CSP_NO_HASH_RESULT          72
00107 #define ERR_CSP_OPEN_KEY                73
00108 #define ERR_CSP_READ_KEY                74
00109 #define ERR_OCSP_SIGN_NOT_SUPPORTED             75
00110 #define ERR_OCSP_SIGN_CSP_NAME                  76
00111 #define ERR_CSP_CERT_DECODE                             77
00112 #define ERR_OCSP_SIGN_PKCS_NAME                 78
00113 #define ERR_OCSP_SIGN_OSLL_CERT                 79
00114 #define ERR_OCSP_SIGN                                   80
00115 #define ERR_CERT_ISSUER                                 81
00116 #define ERR_OCSP_PKCS12_CONTAINER               82
00117 #define ERR_MODIFY_SIGNED_DOC       83
00118 #define ERR_NOTARY_EXISTS                       84
00119 #define ERR_UNSUPPORTED_CERT_SEARCH     85
00120 #define ERR_INCORRECT_CERT_SEARCH       86
00121 #define ERR_BAD_OCSP_RESPONSE_DIGEST 87
00122 #define ERR_LAST_ESTID_CACHED           88
00123 #define ERR_BAD_DATAFILE_XML            89
00124 #define ERR_UNSUPPORTED_VERSION         90
00125 #define ERR_UNSUPPORTED_CHARSET         91
00126 #define ERR_PKCS12_EXPIRED                      92
00127 #define ERR_CSP_USER_CANCEL         93
00128 #define ERR_CSP_NODEFKEY_CONTAINER  94
00129 #define ERR_CONNECTION_FAILURE      95
00130 #define ERR_WRONG_URL_OR_PROXY      96
00131 #define ERR_NULL_PARAM                          97
00132 #define ERR_BAD_ALLOC                           98
00133 #define ERR_CONF_FILE                           99
00134 #define ERR_CONF_LINE                      100
00135 #define ERR_OCSP_CERT_REVOKED              101
00136 #define ERR_OCSP_CERT_UNKNOWN              102
00137 #define ERR_OCSP_PKCS12_NO_FILE            103
00138 #define ERR_OCSP_PKCS12_NO_PASSWD          104
00139 #define ERR_BAD_DATAFILE_CONTENT_TYPE      105
00140 #define ERR_OCSP_WRONG_URL                                      106
00141 #define ERR_OCSP_MALFORMED                      107
00142 #define ERR_OCSP_INTERNALERR            108
00143 #define ERR_OCSP_TRYLATER                       109
00144 #define ERR_OCSP_SIGREQUIRED            110
00145 #define ERR_OCSP_UNAUTHORIZED           111
00146 #define ERR_UNKNOWN_CA                  112
00147 // DigiDocEnc errors
00148 #define ERR_DENC_ENC_METHOD             113
00149 #define ERR_DENC_ENC_XMLNS              114
00150 #define ERR_DENC_BAD_PROP_IDX           115
00151 #define ERR_DENC_BAD_KEY_IDX           116
00152 #define ERR_DENC_KEY_STATUS            117
00153 #define ERR_DENC_DATA_STATUS            118
00154 #define ERR_DENC_DECRYPT               119
00155 #define ERR_CHARSET_CONVERT            120
00156 #define ERR_COMPRESS                121
00157 #define ERR_DECOMPRESS              122
00158 #define ERR_OCSP_CERT_NOTFOUND      123
00159 #define ERR_INVALID_CONTENT         124
00160 #define ERR_DENC_NO_KEY_FOUND       125
00161 #define ERR_OCSP_RESP_NOT_TRUSTED   126
00162 #define ERR_PRIV_CERT_NOT_FOUND     127
00163 #define ERR_NO_OCSP                 128
00164 #define ERR_OCSP_WRONG_SIGNATURE    129
00165 #define ERR_BAD_PARAM                           130
00166 #define ERR_GENERIC_SOAP_ERR            131
00167 
00168 #define ERR_TS_TIMESTAMPINFO_TYPE      132
00169 #define ERR_TS_BAD_INCLUDEINFO_IDX    133
00170 #define ERR_TS_BAD_TIMESTAMPINFO_IDX    134
00171 #define ERR_TS_CREATE_TS_REQ            135
00172 #define ERR_CREATE_NONCE                136
00173 #define ERR_TXT2OID                     137
00174 #define ERR_HTTP_ERR                    138
00175 
00176 #define ERR_BAD_CERTID_IDX              139
00177 #define ERR_BAD_CERTVALUE_IDX           140
00178 #define ERR_TS_VERIFY                   141
00179 #define ERR_TS_REQUEST                  142
00180 #define ERR_TSA_NOT_TRUSTED             143
00181 #define ERR_ORPHONED_SIGNATURE          144
00182 
00183 #define ERR_WPKI_UNKNOWN_USER           145
00184 #define ERR_WPKI_INVALID_PHONE_NO       146
00185 #define ERR_WPKI_UNTRUSTED_SRVICE       147
00186 #define ERR_WPKI_UNTRUSTED_USER         148
00187 
00188 #define ERR_WPKI_UNUSABLE_PHONE    149
00189 #define ERR_WPKI_TIMEOUT                   150
00190 #define ERR_WPKI_CANCELLED                 151
00191 #define ERR_WPKI_MID_NOT_READY     152
00192 #define ERR_WPKI_PHONE_NOT_REACHABLE  153
00193 #define ERR_WPKI_SENDING_ERROR     154
00194 #define ERR_WPKI_SIM_ERROR                 155
00195 #define ERR_WPKI_SERVICE_ERR       156
00196 
00197 #define ERR_MAX                    158  //number of error codes. Increment, if you add a new error code
00198 
00199 
00200 #define ERROR_BUF_LENGTH            20
00201 
00202 
00203 typedef struct ErrorMessage_st {
00204                 char    *errorMessage;
00205                 int     errorClass;
00206 } ErrorMessage;
00207 
00208 typedef int ErrorClass;
00209 
00210 // Error classes 
00211 
00212 // Wasn't an error at all, no reaction neccessary
00213 #define NO_ERRORS       0       
00214 // Various problems of technical nature
00215 #define TECHNICAL       1
00216 // User-repairable errors
00217 #define USER            2
00218 // Bug in DigiDoc library (?)
00219 #define LIBRARY         3
00220 
00221 //==========< error info structure >==============
00222 
00223 typedef struct ErrorInfo_st {
00224         int code;
00225         char *fileName;
00226         int line;
00227         char *assertion;
00228 } ErrorInfo;
00229 
00230 #ifdef WIN32
00231 extern  CRITICAL_SECTION cs_ddocErrors;
00232 #endif
00233 
00234 // checks and prints errors
00235 EXP_OPTION long checkErrors();
00236 
00237 //returns textual explanation of the error code
00238 EXP_OPTION char* getErrorString(int code);
00239 
00240 //returns the classification for the error code 
00241 EXP_OPTION ErrorClass getErrorClass(int code);
00242 
00243 //returns the code of the error that occurred in the library
00244 EXP_OPTION ErrorInfo* getErrorInfo(void);
00245 
00246 //returns 1, if all errors are read and 0 otherwise
00247 EXP_OPTION int hasUnreadErrors(void);
00248 
00249 //resets error information
00250 EXP_OPTION void clearErrors(void);
00251 
00252 EXP_OPTION void addError(int code, char *fileName, int line, char *assertion);
00253 
00254 EXP_OPTION int checkDigiDocErrors(void);
00255 
00256 EXP_OPTION int getLastError();
00257 
00258 //==========< macros >====================
00259 
00260 #define SET_LAST_ERROR(code)                (addError((code), __FILE__, __LINE__, ""))
00261 #define SET_LAST_ERROR_IF_NOT(expr, code)   { if(!(expr)) addError((code), __FILE__, __LINE__, #expr); }
00262 #define SET_LAST_ERROR_RETURN(code, retVal) { SET_LAST_ERROR(code); return (retVal); }
00263 #define SET_LAST_ERROR_RETURN_IF_NOT(expr, code, retVal) { if(!(expr)) { addError((code), __FILE__, __LINE__, #expr); return (retVal); } }
00264 #define SET_LAST_ERROR_RETURN_VOID_IF_NOT(expr, code) { if(!(expr)) { addError((code), __FILE__, __LINE__, #expr); return; } }
00265 #define SET_LAST_ERROR_RETURN_VOID_IF(expr, code) { if(expr) { addError((code), __FILE__, __LINE__, #expr); return; } }
00266 #define RETURN_IF_NOT(expr, code) SET_LAST_ERROR_RETURN_IF_NOT((expr), (code), (code));
00267 #define RETURN_IF_NULL(p)                   RETURN_IF_NOT((p), ERR_NULL_POINTER);
00268 #define RETURN_VOID_IF_NULL(p)              SET_LAST_ERROR_RETURN_VOID_IF_NOT((p), ERR_NULL_POINTER);
00269 #define RETURN_OBJ_IF_NULL(p, obj)          SET_LAST_ERROR_RETURN_IF_NOT((p), ERR_NULL_POINTER, (obj));
00270 #define SET_LAST_ERROR_RETURN_CODE(code)    { SET_LAST_ERROR(code); return (code); }
00271 #define RETURN_IF_NULL_PARAM(p)                         RETURN_IF_NOT((p), ERR_NULL_PARAM);
00272 #define RETURN_IF_BAD_ALLOC(p)                          RETURN_IF_NOT((p), ERR_BAD_ALLOC)
00273 #define RETURN_VOID_IF_BAD_ALLOC(p)         SET_LAST_ERROR_RETURN_VOID_IF_NOT((p), ERR_BAD_ALLOC);
00274 
00275 //========================================
00276 
00277 #ifdef  __cplusplus
00278 }
00279 #endif
00280 
00281 #endif 
00282 
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'