src/status_to_string.h
author Volker Birk <vb@pep-project.org>
Tue, 28 May 2019 12:09:20 +0200
branchsync
changeset 3747 82fe58af7b53
parent 3642 e0f68de8e543
child 3757 bf2916b900bf
permissions -rw-r--r--
SERVICE_ERROR_LOG
vb@3621
     1
#pragma once
vb@3621
     2
vb@3621
     3
#ifdef __cplusplus
vb@3624
     4
extern "C" {
vb@3621
     5
#endif
vb@3621
     6
vb@3747
     7
#ifndef PEP_STATUS_TO_STRING
vb@3747
     8
#define PEP_STATUS_TO_STRING
vb@3747
     9
#endif
vb@3747
    10
neal@3642
    11
static inline const char *pEp_status_to_string(PEP_STATUS status) {
vb@3621
    12
    switch (status) {
vb@3621
    13
    case PEP_STATUS_OK: return "PEP_STATUS_OK";
vb@3621
    14
vb@3621
    15
    case PEP_INIT_CANNOT_LOAD_GPGME: return "PEP_INIT_CANNOT_LOAD_GPGME";
vb@3621
    16
    case PEP_INIT_GPGME_INIT_FAILED: return "PEP_INIT_GPGME_INIT_FAILED";
vb@3621
    17
    case PEP_INIT_NO_GPG_HOME: return "PEP_INIT_NO_GPG_HOME";
vb@3621
    18
    case PEP_INIT_NETPGP_INIT_FAILED: return "PEP_INIT_NETPGP_INIT_FAILED";
vb@3621
    19
    case PEP_INIT_CANNOT_DETERMINE_GPG_VERSION: return "PEP_INIT_CANNOT_DETERMINE_GPG_VERSION";
vb@3621
    20
    case PEP_INIT_UNSUPPORTED_GPG_VERSION: return "PEP_INIT_UNSUPPORTED_GPG_VERSION";
vb@3621
    21
    case PEP_INIT_CANNOT_CONFIG_GPG_AGENT: return "PEP_INIT_CANNOT_CONFIG_GPG_AGENT";
vb@3621
    22
    case PEP_INIT_SQLITE3_WITHOUT_MUTEX: return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
vb@3621
    23
    case PEP_INIT_CANNOT_OPEN_DB: return "PEP_INIT_CANNOT_OPEN_DB";
vb@3621
    24
    case PEP_INIT_CANNOT_OPEN_SYSTEM_DB: return "PEP_INIT_CANNOT_OPEN_SYSTEM_DB";
vb@3621
    25
    case PEP_UNKNOWN_DB_ERROR: return "PEP_UNKNOWN_DB_ERROR";
vb@3621
    26
    case PEP_KEY_NOT_FOUND: return "PEP_KEY_NOT_FOUND";
vb@3621
    27
    case PEP_KEY_HAS_AMBIG_NAME: return "PEP_KEY_HAS_AMBIG_NAME";
vb@3621
    28
    case PEP_GET_KEY_FAILED: return "PEP_GET_KEY_FAILED";
vb@3621
    29
    case PEP_CANNOT_EXPORT_KEY: return "PEP_CANNOT_EXPORT_KEY";
vb@3621
    30
    case PEP_CANNOT_EDIT_KEY: return "PEP_CANNOT_EDIT_KEY";
vb@3621
    31
    case PEP_KEY_UNSUITABLE: return "PEP_KEY_UNSUITABLE";
vb@3621
    32
    case PEP_MALFORMED_KEY_RESET_MSG: return "PEP_MALFORMED_KEY_RESET_MSG";
vb@3621
    33
    case PEP_KEY_NOT_RESET: return "PEP_KEY_NOT_RESET";
vb@3621
    34
vb@3621
    35
    case PEP_KEY_IMPORTED: return "PEP_KEY_IMPORTED";
vb@3621
    36
    case PEP_NO_KEY_IMPORTED: return "PEP_NO_KEY_IMPORTED";
vb@3621
    37
    case PEP_KEY_IMPORT_STATUS_UNKNOWN: return "PEP_KEY_IMPORT_STATUS_UNKNOWN";
vb@3621
    38
    
vb@3621
    39
    case PEP_CANNOT_FIND_IDENTITY: return "PEP_CANNOT_FIND_IDENTITY";
vb@3621
    40
    case PEP_CANNOT_SET_PERSON: return "PEP_CANNOT_SET_PERSON";
vb@3621
    41
    case PEP_CANNOT_SET_PGP_KEYPAIR: return "PEP_CANNOT_SET_PGP_KEYPAIR";
vb@3621
    42
    case PEP_CANNOT_SET_IDENTITY: return "PEP_CANNOT_SET_IDENTITY";
vb@3621
    43
    case PEP_CANNOT_SET_TRUST: return "PEP_CANNOT_SET_TRUST";
vb@3621
    44
    case PEP_KEY_BLACKLISTED: return "PEP_KEY_BLACKLISTED";
vb@3621
    45
    case PEP_CANNOT_FIND_PERSON: return "PEP_CANNOT_FIND_PERSON";
vb@3621
    46
vb@3621
    47
    case PEP_CANNOT_FIND_ALIAS: return "PEP_CANNOT_FIND_ALIAS";
vb@3621
    48
    case PEP_CANNOT_SET_ALIAS: return "PEP_CANNOT_SET_ALIAS";
vb@3621
    49
vb@3621
    50
    case PEP_UNENCRYPTED: return "PEP_UNENCRYPTED";
vb@3621
    51
    case PEP_VERIFIED: return "PEP_VERIFIED";
vb@3621
    52
    case PEP_DECRYPTED: return "PEP_DECRYPTED";
vb@3621
    53
    case PEP_DECRYPTED_AND_VERIFIED: return "PEP_DECRYPTED_AND_VERIFIED";
vb@3621
    54
    case PEP_DECRYPT_WRONG_FORMAT: return "PEP_DECRYPT_WRONG_FORMAT";
vb@3621
    55
    case PEP_DECRYPT_NO_KEY: return "PEP_DECRYPT_NO_KEY";
vb@3621
    56
    case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH: return "PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH";
vb@3621
    57
    case PEP_VERIFY_NO_KEY: return "PEP_VERIFY_NO_KEY";
vb@3621
    58
    case PEP_VERIFIED_AND_TRUSTED: return "PEP_VERIFIED_AND_TRUSTED";
vb@3621
    59
    case PEP_CANNOT_REENCRYPT: return "PEP_CANNOT_REENCRYPT";
vb@3621
    60
    case PEP_CANNOT_DECRYPT_UNKNOWN: return "PEP_CANNOT_DECRYPT_UNKNOWN";
vb@3621
    61
vb@3621
    62
    case PEP_TRUSTWORD_NOT_FOUND: return "PEP_TRUSTWORD_NOT_FOUND";
vb@3621
    63
    case PEP_TRUSTWORDS_FPR_WRONG_LENGTH: return "PEP_TRUSTWORDS_FPR_WRONG_LENGTH";
vb@3621
    64
    case PEP_TRUSTWORDS_DUPLICATE_FPR: return "PEP_TRUSTWORDS_DUPLICATE_FPR";
vb@3621
    65
vb@3621
    66
    case PEP_CANNOT_CREATE_KEY: return "PEP_CANNOT_CREATE_KEY";
vb@3621
    67
    case PEP_CANNOT_SEND_KEY: return "PEP_CANNOT_SEND_KEY";
vb@3621
    68
vb@3621
    69
    case PEP_PHRASE_NOT_FOUND: return "PEP_PHRASE_NOT_FOUND";
vb@3621
    70
vb@3621
    71
    case PEP_SEND_FUNCTION_NOT_REGISTERED: return "PEP_SEND_FUNCTION_NOT_REGISTERED";
vb@3621
    72
    case PEP_CONTRAINTS_VIOLATED: return "PEP_CONTRAINTS_VIOLATED";
vb@3621
    73
    case PEP_CANNOT_ENCODE: return "PEP_CANNOT_ENCODE";
vb@3621
    74
vb@3621
    75
    case PEP_SYNC_NO_NOTIFY_CALLBACK: return "PEP_SYNC_NO_NOTIFY_CALLBACK";
vb@3621
    76
    case PEP_SYNC_ILLEGAL_MESSAGE: return "PEP_SYNC_ILLEGAL_MESSAGE";
vb@3621
    77
    case PEP_SYNC_NO_INJECT_CALLBACK: return "PEP_SYNC_NO_INJECT_CALLBACK";
vb@3621
    78
    case PEP_SYNC_NO_CHANNEL: return "PEP_SYNC_NO_CHANNEL";
vb@3621
    79
    case PEP_SYNC_CANNOT_ENCRYPT: return "PEP_SYNC_CANNOT_ENCRYPT";
vb@3621
    80
    case PEP_SYNC_NO_MESSAGE_SEND_CALLBACK: return "PEP_SYNC_NO_MESSAGE_SEND_CALLBACK";
vb@3621
    81
vb@3621
    82
    case PEP_CANNOT_INCREASE_SEQUENCE: return "PEP_CANNOT_INCREASE_SEQUENCE";
vb@3621
    83
vb@3621
    84
    case PEP_STATEMACHINE_ERROR: return "PEP_STATEMACHINE_ERROR";
vb@3621
    85
    case PEP_NO_TRUST: return "PEP_NO_TRUST";
vb@3621
    86
    case PEP_STATEMACHINE_INVALID_STATE: return "PEP_STATEMACHINE_INVALID_STATE";
vb@3621
    87
    case PEP_STATEMACHINE_INVALID_EVENT: return "PEP_STATEMACHINE_INVALID_EVENT";
vb@3621
    88
    case PEP_STATEMACHINE_INVALID_CONDITION: return "PEP_STATEMACHINE_INVALID_CONDITION";
vb@3621
    89
    case PEP_STATEMACHINE_INVALID_ACTION: return "PEP_STATEMACHINE_INVALID_ACTION";
vb@3621
    90
    case PEP_STATEMACHINE_INHIBITED_EVENT: return "PEP_STATEMACHINE_INHIBITED_EVENT";
vb@3621
    91
    case PEP_STATEMACHINE_CANNOT_SEND: return "PEP_STATEMACHINE_CANNOT_SEND";
vb@3621
    92
vb@3621
    93
    case PEP_COMMIT_FAILED: return "PEP_COMMIT_FAILED";
vb@3621
    94
    case PEP_MESSAGE_CONSUME: return "PEP_MESSAGE_CONSUME";
vb@3621
    95
    case PEP_MESSAGE_IGNORE: return "PEP_MESSAGE_IGNORE";
vb@3621
    96
vb@3621
    97
    case PEP_RECORD_NOT_FOUND: return "PEP_RECORD_NOT_FOUND";
vb@3621
    98
    case PEP_CANNOT_CREATE_TEMP_FILE: return "PEP_CANNOT_CREATE_TEMP_FILE";
vb@3621
    99
    case PEP_ILLEGAL_VALUE: return "PEP_ILLEGAL_VALUE";
vb@3621
   100
    case PEP_BUFFER_TOO_SMALL: return "PEP_BUFFER_TOO_SMALL";
vb@3621
   101
    case PEP_OUT_OF_MEMORY: return "PEP_OUT_OF_MEMORY";
vb@3621
   102
    case PEP_UNKNOWN_ERROR: return "PEP_UNKNOWN_ERROR";
vb@3621
   103
vb@3621
   104
    case PEP_VERSION_MISMATCH: return "PEP_VERSION_MISMATCH";
vb@3621
   105
vb@3621
   106
    default: return "unknown status code";
vb@3621
   107
    }
vb@3621
   108
}
vb@3621
   109
vb@3747
   110
static inline const char *pEp_comm_type_to_string(PEP_comm_type ct) {
vb@3747
   111
    switch (ct) {
vb@3747
   112
    case PEP_ct_unknown: return "unknown";
vb@3747
   113
    case PEP_ct_no_encryption: return "no_encryption";
vb@3747
   114
    case PEP_ct_no_encrypted_channel: return "no_encrypted_channel";
vb@3747
   115
    case PEP_ct_key_not_found: return "key_not_found";
vb@3747
   116
    case PEP_ct_key_expired: return "key_expired";
vb@3747
   117
    case PEP_ct_key_revoked: return "key_revoked";
vb@3747
   118
    case PEP_ct_key_b0rken: return "key_b0rken";
vb@3747
   119
    case PEP_ct_my_key_not_included: return "my_key_not_included";
vb@3747
   120
    case PEP_ct_security_by_obscurity: return "security_by_obscurity";
vb@3747
   121
    case PEP_ct_b0rken_crypto: return "b0rken_crypto";
vb@3747
   122
    case PEP_ct_key_too_short: return "key_too_short";
vb@3747
   123
    case PEP_ct_compromised: return "compromised";
vb@3747
   124
    case PEP_ct_mistrusted: return "mistrusted";
vb@3747
   125
    case PEP_ct_unconfirmed_encryption: return "unconfirmed_encryption";
vb@3747
   126
    case PEP_ct_OpenPGP_weak_unconfirmed: return "OpenPGP_weak_unconfirmed";
vb@3747
   127
    case PEP_ct_to_be_checked: return "to_be_checked";
vb@3747
   128
    case PEP_ct_SMIME_unconfirmed: return "SMIME_unconfirmed";
vb@3747
   129
    case PEP_ct_CMS_unconfirmed: return "CMS_unconfirmed";
vb@3747
   130
    case PEP_ct_strong_but_unconfirmed: return "strong_but_unconfirmed";
vb@3747
   131
    case PEP_ct_OpenPGP_unconfirmed: return "OpenPGP_unconfirmed";
vb@3747
   132
    case PEP_ct_OTR_unconfirmed: return "OTR_unconfirmed";
vb@3747
   133
    case PEP_ct_unconfirmed_enc_anon: return "unconfirmed_enc_anon";
vb@3747
   134
    case PEP_ct_pEp_unconfirmed: return "pEp_unconfirmed";
vb@3747
   135
    case PEP_ct_confirmed: return "confirmed";
vb@3747
   136
    case PEP_ct_confirmed_encryption: return "confirmed_encryption";
vb@3747
   137
    case PEP_ct_OpenPGP_weak: return "OpenPGP_weak";
vb@3747
   138
    case PEP_ct_to_be_checked_confirmed: return "to_be_checked_confirmed";
vb@3747
   139
    case PEP_ct_SMIME: return "SMIME";
vb@3747
   140
    case PEP_ct_CMS: return "CMS";
vb@3747
   141
    case PEP_ct_strong_encryption: return "strong_encryption";
vb@3747
   142
    case PEP_ct_OpenPGP: return "OpenPGP";
vb@3747
   143
    case PEP_ct_OTR: return "OTR";
vb@3747
   144
    case PEP_ct_confirmed_enc_anon: return "confirmed_enc_anon";
vb@3747
   145
    case PEP_ct_pEp: return "pEp";
vb@3747
   146
    default: return "invalid comm type";
vb@3747
   147
    }
vb@3747
   148
}
vb@3747
   149
vb@3621
   150
#ifdef __cplusplus
vb@3621
   151
} // "C"
vb@3621
   152
#endif
vb@3621
   153