~ubuntu-branches/ubuntu/jaunty/gnupg2/jaunty

« back to all changes in this revision

Viewing changes to util/errors.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
ImportĀ upstreamĀ versionĀ 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* errors.c  -  error strings
 
2
 *      Copyright (C) 1998, 1999, 2000, 2001 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 2 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, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
#include <stdio.h>
 
23
#include <stdlib.h>
 
24
#include <stdarg.h>
 
25
 
 
26
#include "errors.h"
 
27
#include "i18n.h"
 
28
 
 
29
#ifndef HAVE_STRERROR
 
30
char *
 
31
strerror( int n )
 
32
{
 
33
    extern char *sys_errlist[];
 
34
    extern int sys_nerr;
 
35
    static char buf[15];
 
36
 
 
37
    if( n >= 0 && n < sys_nerr )
 
38
        return sys_errlist[n];
 
39
    strcpy( buf, "Unknown error" );
 
40
    return buf;
 
41
}
 
42
#endif /* !HAVE_STRERROR */
 
43
 
 
44
const char *
 
45
g10_errstr( int err )
 
46
{
 
47
    static char buf[50];
 
48
    const char *p;
 
49
 
 
50
#define X(n,s) case G10ERR_##n : p = s; break;
 
51
    switch( err ) {
 
52
      case -1:          p = "eof"; break;
 
53
      case 0:           p = "okay"; break;
 
54
      X(GENERAL,        N_("general error"))
 
55
      X(UNKNOWN_PACKET, N_("unknown packet type"))
 
56
      X(UNKNOWN_VERSION,N_("unknown version"))
 
57
      X(PUBKEY_ALGO    ,N_("unknown pubkey algorithm"))
 
58
      X(DIGEST_ALGO    ,N_("unknown digest algorithm"))
 
59
      X(BAD_PUBKEY     ,N_("bad public key"))
 
60
      X(BAD_SECKEY     ,N_("bad secret key"))
 
61
      X(BAD_SIGN       ,N_("bad signature"))
 
62
      X(CHECKSUM   ,    N_("checksum error"))
 
63
      X(BAD_PASS     ,  N_("bad passphrase"))
 
64
      X(NO_PUBKEY      ,N_("public key not found"))
 
65
      X(CIPHER_ALGO    ,N_("unknown cipher algorithm"))
 
66
      X(KEYRING_OPEN   ,N_("can't open the keyring"))
 
67
      X(INVALID_PACKET ,N_("invalid packet"))
 
68
      X(INVALID_ARMOR  ,N_("invalid armor"))
 
69
      X(NO_USER_ID     ,N_("no such user id"))
 
70
      X(NO_SECKEY      ,N_("secret key not available"))
 
71
      X(WRONG_SECKEY   ,N_("wrong secret key used"))
 
72
      X(UNSUPPORTED    ,N_("not supported"))
 
73
      X(BAD_KEY        ,N_("bad key"))
 
74
      X(READ_FILE      ,N_("file read error"))
 
75
      X(WRITE_FILE     ,N_("file write error"))
 
76
      X(COMPR_ALGO     ,N_("unknown compress algorithm"))
 
77
      X(OPEN_FILE      ,N_("file open error"))
 
78
      X(CREATE_FILE    ,N_("file create error"))
 
79
      X(PASSPHRASE     ,N_("invalid passphrase"))
 
80
      X(NI_PUBKEY      ,N_("unimplemented pubkey algorithm"))
 
81
      X(NI_CIPHER      ,N_("unimplemented cipher algorithm"))
 
82
      X(SIG_CLASS      ,N_("unknown signature class"))
 
83
      X(TRUSTDB        ,N_("trust database error"))
 
84
      X(BAD_MPI        ,N_("bad MPI"))
 
85
      X(RESOURCE_LIMIT ,N_("resource limit"))
 
86
      X(INV_KEYRING    ,N_("invalid keyring"))
 
87
      X(BAD_CERT       ,N_("bad certificate"))
 
88
      X(INV_USER_ID    ,N_("malformed user id"))
 
89
      X(CLOSE_FILE     ,N_("file close error"))
 
90
      X(RENAME_FILE    ,N_("file rename error"))
 
91
      X(DELETE_FILE    ,N_("file delete error"))
 
92
      X(UNEXPECTED     ,N_("unexpected data"))
 
93
      X(TIME_CONFLICT  ,N_("timestamp conflict"))
 
94
      X(WR_PUBKEY_ALGO ,N_("unusable pubkey algorithm"))
 
95
      X(FILE_EXISTS    ,N_("file exists"))
 
96
      X(WEAK_KEY       ,N_("weak key"))
 
97
      X(INV_ARG        ,N_("invalid argument"))
 
98
      X(BAD_URI        ,N_("bad URI"))
 
99
      X(INVALID_URI    ,N_("unsupported URI"))
 
100
      X(NETWORK        ,N_("network error"))
 
101
      X(SELFTEST_FAILED,"selftest failed")
 
102
      X(NOT_ENCRYPTED  ,N_("not encrypted"))
 
103
      X(NOT_PROCESSED  ,N_("not processed"))
 
104
      /* the key cannot be used for a specific usage */
 
105
      X(UNU_PUBKEY     ,N_("unusable public key"))
 
106
      X(UNU_SECKEY     ,N_("unusable secret key"))
 
107
      X(KEYSERVER      ,N_("keyserver error"))
 
108
      X(CANCELED       ,N_("canceled"))
 
109
      X(NO_CARD        ,N_("no card"))
 
110
      default: p = buf; sprintf(buf, "g10err=%d", err); break;
 
111
    }
 
112
#undef X
 
113
    return _(p);
 
114
}