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