-
+ 2637E827D61AC5BE58C3CC88799EAF49DAED6C957ED6C6647B6D8D787E4F7FD731CDD16DB53CB1FA15E35230E918CD62DA33B4DD410CC073CA4092BC973F5AD1
mpi/errors.c
(0 . 0)(1 . 113)
685 /* errors.c - error strings
686 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
687 *
688 * This file is part of GnuPG.
689 *
690 * GnuPG is free software; you can redistribute it and/or modify
691 * it under the terms of the GNU General Public License as published by
692 * the Free Software Foundation; either version 3 of the License, or
693 * (at your option) any later version.
694 *
695 * GnuPG is distributed in the hope that it will be useful,
696 * but WITHOUT ANY WARRANTY; without even the implied warranty of
697 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
698 * GNU General Public License for more details.
699 *
700 * You should have received a copy of the GNU General Public License
701 * along with this program; if not, see <http://www.gnu.org/licenses/>.
702 */
703
704 #include <config.h>
705 #include <stdio.h>
706 #include <stdlib.h>
707 #include <stdarg.h>
708
709 #include "errors.h"
710
711 #ifndef HAVE_STRERROR
712 char *
713 strerror( int n )
714 {
715 extern char *sys_errlist[];
716 extern int sys_nerr;
717 static char buf[15];
718
719 if( n >= 0 && n < sys_nerr )
720 return sys_errlist[n];
721 strcpy( buf, "Unknown error" );
722 return buf;
723 }
724 #endif /* !HAVE_STRERROR */
725
726 const char *
727 g10_errstr( int err )
728 {
729 static char buf[50];
730 const char *p;
731
732 #define X(n,s) case G10ERR_##n : p = s; break;
733 switch( err ) {
734 case -1: p = "eof"; break;
735 case 0: p = "okay"; break;
736 X(GENERAL, N_("general error"))
737 X(UNKNOWN_PACKET, N_("unknown packet type"))
738 X(UNKNOWN_VERSION,N_("unknown version"))
739 X(PUBKEY_ALGO ,N_("unknown pubkey algorithm"))
740 X(DIGEST_ALGO ,N_("unknown digest algorithm"))
741 X(BAD_PUBKEY ,N_("bad public key"))
742 X(BAD_SECKEY ,N_("bad secret key"))
743 X(BAD_SIGN ,N_("bad signature"))
744 X(CHECKSUM , N_("checksum error"))
745 X(BAD_PASS , N_("bad passphrase"))
746 X(NO_PUBKEY ,N_("public key not found"))
747 X(CIPHER_ALGO ,N_("unknown cipher algorithm"))
748 X(KEYRING_OPEN ,N_("can't open the keyring"))
749 X(INVALID_PACKET ,N_("invalid packet"))
750 X(INVALID_ARMOR ,N_("invalid armor"))
751 X(NO_USER_ID ,N_("no such user id"))
752 X(NO_SECKEY ,N_("secret key not available"))
753 X(WRONG_SECKEY ,N_("wrong secret key used"))
754 X(UNSUPPORTED ,N_("not supported"))
755 X(BAD_KEY ,N_("bad key"))
756 X(READ_FILE ,N_("file read error"))
757 X(WRITE_FILE ,N_("file write error"))
758 X(COMPR_ALGO ,N_("unknown compress algorithm"))
759 X(OPEN_FILE ,N_("file open error"))
760 X(CREATE_FILE ,N_("file create error"))
761 X(PASSPHRASE ,N_("invalid passphrase"))
762 X(NI_PUBKEY ,N_("unimplemented pubkey algorithm"))
763 X(NI_CIPHER ,N_("unimplemented cipher algorithm"))
764 X(SIG_CLASS ,N_("unknown signature class"))
765 X(TRUSTDB ,N_("trust database error"))
766 X(BAD_MPI ,N_("bad MPI"))
767 X(RESOURCE_LIMIT ,N_("resource limit"))
768 X(INV_KEYRING ,N_("invalid keyring"))
769 X(BAD_CERT ,N_("bad certificate"))
770 X(INV_USER_ID ,N_("malformed user id"))
771 X(CLOSE_FILE ,N_("file close error"))
772 X(RENAME_FILE ,N_("file rename error"))
773 X(DELETE_FILE ,N_("file delete error"))
774 X(UNEXPECTED ,N_("unexpected data"))
775 X(TIME_CONFLICT ,N_("timestamp conflict"))
776 X(WR_PUBKEY_ALGO ,N_("unusable pubkey algorithm"))
777 X(FILE_EXISTS ,N_("file exists"))
778 X(WEAK_KEY ,N_("weak key"))
779 X(INV_ARG ,N_("invalid argument"))
780 X(BAD_URI ,N_("bad URI"))
781 X(INVALID_URI ,N_("unsupported URI"))
782 X(NETWORK ,N_("network error"))
783 X(SELFTEST_FAILED,"selftest failed")
784 X(NOT_ENCRYPTED ,N_("not encrypted"))
785 X(NOT_PROCESSED ,N_("not processed"))
786 /* the key cannot be used for a specific usage */
787 X(UNU_PUBKEY ,N_("unusable public key"))
788 X(UNU_SECKEY ,N_("unusable secret key"))
789 X(KEYSERVER ,N_("keyserver error"))
790 X(CANCELED ,N_("canceled"))
791 X(NO_CARD ,N_("no card"))
792 X(NO_DATA ,N_("no data"))
793 default: p = buf; sprintf(buf, "g10err=%d", err); break;
794 }
795 #undef X
796 return _(p);
797 }