raw
mpi-genesis~            1 /* errors.c  -	error strings
mpi-genesis~ 2 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
mpi-genesis~ 3 *
mpi-genesis~ 4 * This file is part of GnuPG.
mpi-genesis~ 5 *
mpi-genesis~ 6 * GnuPG is free software; you can redistribute it and/or modify
mpi-genesis~ 7 * it under the terms of the GNU General Public License as published by
mpi-genesis~ 8 * the Free Software Foundation; either version 3 of the License, or
mpi-genesis~ 9 * (at your option) any later version.
mpi-genesis~ 10 *
mpi-genesis~ 11 * GnuPG is distributed in the hope that it will be useful,
mpi-genesis~ 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mpi-genesis~ 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
mpi-genesis~ 14 * GNU General Public License for more details.
mpi-genesis~ 15 *
mpi-genesis~ 16 * You should have received a copy of the GNU General Public License
mpi-genesis~ 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
mpi-genesis~ 18 */
mpi-genesis~ 19
mpi-genesis~ 20 #include <config.h>
mpi-genesis~ 21 #include <stdio.h>
mpi-genesis~ 22 #include <stdlib.h>
mpi-genesis~ 23 #include <stdarg.h>
mpi-genesis~ 24
mpi-genesis~ 25 #include "errors.h"
mpi-genesis~ 26
mpi-genesis~ 27 #ifndef HAVE_STRERROR
mpi-genesis~ 28 char *
mpi-genesis~ 29 strerror( int n )
mpi-genesis~ 30 {
mpi-genesis~ 31 extern char *sys_errlist[];
mpi-genesis~ 32 extern int sys_nerr;
mpi-genesis~ 33 static char buf[15];
mpi-genesis~ 34
mpi-genesis~ 35 if( n >= 0 && n < sys_nerr )
mpi-genesis~ 36 return sys_errlist[n];
mpi-genesis~ 37 strcpy( buf, "Unknown error" );
mpi-genesis~ 38 return buf;
mpi-genesis~ 39 }
mpi-genesis~ 40 #endif /* !HAVE_STRERROR */
mpi-genesis~ 41
mpi-genesis~ 42 const char *
mpi-genesis~ 43 g10_errstr( int err )
mpi-genesis~ 44 {
mpi-genesis~ 45 static char buf[50];
mpi-genesis~ 46 const char *p;
mpi-genesis~ 47
mpi-genesis~ 48 #define X(n,s) case G10ERR_##n : p = s; break;
mpi-genesis~ 49 switch( err ) {
mpi-genesis~ 50 case -1: p = "eof"; break;
mpi-genesis~ 51 case 0: p = "okay"; break;
mpi-genesis~ 52 X(GENERAL, N_("general error"))
mpi-genesis~ 53 X(UNKNOWN_PACKET, N_("unknown packet type"))
mpi-genesis~ 54 X(UNKNOWN_VERSION,N_("unknown version"))
mpi-genesis~ 55 X(PUBKEY_ALGO ,N_("unknown pubkey algorithm"))
mpi-genesis~ 56 X(DIGEST_ALGO ,N_("unknown digest algorithm"))
mpi-genesis~ 57 X(BAD_PUBKEY ,N_("bad public key"))
mpi-genesis~ 58 X(BAD_SECKEY ,N_("bad secret key"))
mpi-genesis~ 59 X(BAD_SIGN ,N_("bad signature"))
mpi-genesis~ 60 X(CHECKSUM , N_("checksum error"))
mpi-genesis~ 61 X(BAD_PASS , N_("bad passphrase"))
mpi-genesis~ 62 X(NO_PUBKEY ,N_("public key not found"))
mpi-genesis~ 63 X(CIPHER_ALGO ,N_("unknown cipher algorithm"))
mpi-genesis~ 64 X(KEYRING_OPEN ,N_("can't open the keyring"))
mpi-genesis~ 65 X(INVALID_PACKET ,N_("invalid packet"))
mpi-genesis~ 66 X(INVALID_ARMOR ,N_("invalid armor"))
mpi-genesis~ 67 X(NO_USER_ID ,N_("no such user id"))
mpi-genesis~ 68 X(NO_SECKEY ,N_("secret key not available"))
mpi-genesis~ 69 X(WRONG_SECKEY ,N_("wrong secret key used"))
mpi-genesis~ 70 X(UNSUPPORTED ,N_("not supported"))
mpi-genesis~ 71 X(BAD_KEY ,N_("bad key"))
mpi-genesis~ 72 X(READ_FILE ,N_("file read error"))
mpi-genesis~ 73 X(WRITE_FILE ,N_("file write error"))
mpi-genesis~ 74 X(COMPR_ALGO ,N_("unknown compress algorithm"))
mpi-genesis~ 75 X(OPEN_FILE ,N_("file open error"))
mpi-genesis~ 76 X(CREATE_FILE ,N_("file create error"))
mpi-genesis~ 77 X(PASSPHRASE ,N_("invalid passphrase"))
mpi-genesis~ 78 X(NI_PUBKEY ,N_("unimplemented pubkey algorithm"))
mpi-genesis~ 79 X(NI_CIPHER ,N_("unimplemented cipher algorithm"))
mpi-genesis~ 80 X(SIG_CLASS ,N_("unknown signature class"))
mpi-genesis~ 81 X(TRUSTDB ,N_("trust database error"))
mpi-genesis~ 82 X(BAD_MPI ,N_("bad MPI"))
mpi-genesis~ 83 X(RESOURCE_LIMIT ,N_("resource limit"))
mpi-genesis~ 84 X(INV_KEYRING ,N_("invalid keyring"))
mpi-genesis~ 85 X(BAD_CERT ,N_("bad certificate"))
mpi-genesis~ 86 X(INV_USER_ID ,N_("malformed user id"))
mpi-genesis~ 87 X(CLOSE_FILE ,N_("file close error"))
mpi-genesis~ 88 X(RENAME_FILE ,N_("file rename error"))
mpi-genesis~ 89 X(DELETE_FILE ,N_("file delete error"))
mpi-genesis~ 90 X(UNEXPECTED ,N_("unexpected data"))
mpi-genesis~ 91 X(TIME_CONFLICT ,N_("timestamp conflict"))
mpi-genesis~ 92 X(WR_PUBKEY_ALGO ,N_("unusable pubkey algorithm"))
mpi-genesis~ 93 X(FILE_EXISTS ,N_("file exists"))
mpi-genesis~ 94 X(WEAK_KEY ,N_("weak key"))
mpi-genesis~ 95 X(INV_ARG ,N_("invalid argument"))
mpi-genesis~ 96 X(BAD_URI ,N_("bad URI"))
mpi-genesis~ 97 X(INVALID_URI ,N_("unsupported URI"))
mpi-genesis~ 98 X(NETWORK ,N_("network error"))
mpi-genesis~ 99 X(SELFTEST_FAILED,"selftest failed")
mpi-genesis~ 100 X(NOT_ENCRYPTED ,N_("not encrypted"))
mpi-genesis~ 101 X(NOT_PROCESSED ,N_("not processed"))
mpi-genesis~ 102 /* the key cannot be used for a specific usage */
mpi-genesis~ 103 X(UNU_PUBKEY ,N_("unusable public key"))
mpi-genesis~ 104 X(UNU_SECKEY ,N_("unusable secret key"))
mpi-genesis~ 105 X(KEYSERVER ,N_("keyserver error"))
mpi-genesis~ 106 X(CANCELED ,N_("canceled"))
mpi-genesis~ 107 X(NO_CARD ,N_("no card"))
mpi-genesis~ 108 X(NO_DATA ,N_("no data"))
mpi-genesis~ 109 default: p = buf; sprintf(buf, "g10err=%d", err); break;
mpi-genesis~ 110 }
mpi-genesis~ 111 #undef X
mpi-genesis~ 112 return _(p);
mpi-genesis~ 113 }