Line data Source code
1 : /* status.c - status code helper functions
2 : * Copyright (C) 2007 Free Software Foundation, Inc.
3 : *
4 : * This file is part of GnuPG.
5 : *
6 : * GnuPG is free software; you can redistribute it and/or modify
7 : * it under the terms of the GNU General Public License as published by
8 : * the Free Software Foundation; either version 3 of the License, or
9 : * (at your option) any later version.
10 : *
11 : * GnuPG is distributed in the hope that it will be useful,
12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : * GNU General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU General Public License
17 : * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 : */
19 :
20 : #include <config.h>
21 : #include <stdlib.h>
22 :
23 : #include "util.h"
24 : #include "status.h"
25 : #include "status-codes.h"
26 :
27 :
28 : /* Return the status string for code NO. */
29 : const char *
30 0 : get_status_string ( int no )
31 : {
32 0 : int idx = statusstr_msgidxof (no);
33 0 : if (idx == -1)
34 0 : return "?";
35 : else
36 0 : return statusstr_msgstr + statusstr_msgidx[idx];
37 : }
38 :
39 :
40 : const char *
41 0 : get_inv_recpsgnr_code (gpg_error_t err)
42 : {
43 : const char *errstr;
44 :
45 0 : switch (gpg_err_code (err))
46 : {
47 0 : case GPG_ERR_NO_PUBKEY: errstr = "1"; break;
48 0 : case GPG_ERR_AMBIGUOUS_NAME: errstr = "2"; break;
49 0 : case GPG_ERR_WRONG_KEY_USAGE: errstr = "3"; break;
50 0 : case GPG_ERR_CERT_REVOKED: errstr = "4"; break;
51 0 : case GPG_ERR_CERT_EXPIRED: errstr = "5"; break;
52 0 : case GPG_ERR_NO_CRL_KNOWN: errstr = "6"; break;
53 0 : case GPG_ERR_CRL_TOO_OLD: errstr = "7"; break;
54 0 : case GPG_ERR_NO_POLICY_MATCH: errstr = "8"; break;
55 :
56 : case GPG_ERR_UNUSABLE_SECKEY:
57 0 : case GPG_ERR_NO_SECKEY: errstr = "9"; break;
58 :
59 0 : case GPG_ERR_NOT_TRUSTED: errstr = "10"; break;
60 0 : case GPG_ERR_MISSING_CERT: errstr = "11"; break;
61 0 : case GPG_ERR_MISSING_ISSUER_CERT: errstr = "12"; break;
62 0 : default: errstr = "0"; break;
63 : }
64 :
65 0 : return errstr;
66 : }
|