-
+ 2637E827D61AC5BE58C3CC88799EAF49DAED6C957ED6C6647B6D8D787E4F7FD731CDD16DB53CB1FA15E35230E918CD62DA33B4DD410CC073CA4092BC973F5AD1mpi/errors.c(0 . 0)(1 . 113)
789 /* errors.c - error strings
790 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
791 *
792 * This file is part of GnuPG.
793 *
794 * GnuPG is free software; you can redistribute it and/or modify
795 * it under the terms of the GNU General Public License as published by
796 * the Free Software Foundation; either version 3 of the License, or
797 * (at your option) any later version.
798 *
799 * GnuPG is distributed in the hope that it will be useful,
800 * but WITHOUT ANY WARRANTY; without even the implied warranty of
801 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
802 * GNU General Public License for more details.
803 *
804 * You should have received a copy of the GNU General Public License
805 * along with this program; if not, see <http://www.gnu.org/licenses/>.
806 */
807
808 #include <config.h>
809 #include <stdio.h>
810 #include <stdlib.h>
811 #include <stdarg.h>
812
813 #include "errors.h"
814
815 #ifndef HAVE_STRERROR
816 char *
817 strerror( int n )
818 {
819 extern char *sys_errlist[];
820 extern int sys_nerr;
821 static char buf[15];
822
823 if( n >= 0 && n < sys_nerr )
824 return sys_errlist[n];
825 strcpy( buf, "Unknown error" );
826 return buf;
827 }
828 #endif /* !HAVE_STRERROR */
829
830 const char *
831 g10_errstr( int err )
832 {
833 static char buf[50];
834 const char *p;
835
836 #define X(n,s) case G10ERR_##n : p = s; break;
837 switch( err ) {
838 case -1: p = "eof"; break;
839 case 0: p = "okay"; break;
840 X(GENERAL, N_("general error"))
841 X(UNKNOWN_PACKET, N_("unknown packet type"))
842 X(UNKNOWN_VERSION,N_("unknown version"))
843 X(PUBKEY_ALGO ,N_("unknown pubkey algorithm"))
844 X(DIGEST_ALGO ,N_("unknown digest algorithm"))
845 X(BAD_PUBKEY ,N_("bad public key"))
846 X(BAD_SECKEY ,N_("bad secret key"))
847 X(BAD_SIGN ,N_("bad signature"))
848 X(CHECKSUM , N_("checksum error"))
849 X(BAD_PASS , N_("bad passphrase"))
850 X(NO_PUBKEY ,N_("public key not found"))
851 X(CIPHER_ALGO ,N_("unknown cipher algorithm"))
852 X(KEYRING_OPEN ,N_("can't open the keyring"))
853 X(INVALID_PACKET ,N_("invalid packet"))
854 X(INVALID_ARMOR ,N_("invalid armor"))
855 X(NO_USER_ID ,N_("no such user id"))
856 X(NO_SECKEY ,N_("secret key not available"))
857 X(WRONG_SECKEY ,N_("wrong secret key used"))
858 X(UNSUPPORTED ,N_("not supported"))
859 X(BAD_KEY ,N_("bad key"))
860 X(READ_FILE ,N_("file read error"))
861 X(WRITE_FILE ,N_("file write error"))
862 X(COMPR_ALGO ,N_("unknown compress algorithm"))
863 X(OPEN_FILE ,N_("file open error"))
864 X(CREATE_FILE ,N_("file create error"))
865 X(PASSPHRASE ,N_("invalid passphrase"))
866 X(NI_PUBKEY ,N_("unimplemented pubkey algorithm"))
867 X(NI_CIPHER ,N_("unimplemented cipher algorithm"))
868 X(SIG_CLASS ,N_("unknown signature class"))
869 X(TRUSTDB ,N_("trust database error"))
870 X(BAD_MPI ,N_("bad MPI"))
871 X(RESOURCE_LIMIT ,N_("resource limit"))
872 X(INV_KEYRING ,N_("invalid keyring"))
873 X(BAD_CERT ,N_("bad certificate"))
874 X(INV_USER_ID ,N_("malformed user id"))
875 X(CLOSE_FILE ,N_("file close error"))
876 X(RENAME_FILE ,N_("file rename error"))
877 X(DELETE_FILE ,N_("file delete error"))
878 X(UNEXPECTED ,N_("unexpected data"))
879 X(TIME_CONFLICT ,N_("timestamp conflict"))
880 X(WR_PUBKEY_ALGO ,N_("unusable pubkey algorithm"))
881 X(FILE_EXISTS ,N_("file exists"))
882 X(WEAK_KEY ,N_("weak key"))
883 X(INV_ARG ,N_("invalid argument"))
884 X(BAD_URI ,N_("bad URI"))
885 X(INVALID_URI ,N_("unsupported URI"))
886 X(NETWORK ,N_("network error"))
887 X(SELFTEST_FAILED,"selftest failed")
888 X(NOT_ENCRYPTED ,N_("not encrypted"))
889 X(NOT_PROCESSED ,N_("not processed"))
890 /* the key cannot be used for a specific usage */
891 X(UNU_PUBKEY ,N_("unusable public key"))
892 X(UNU_SECKEY ,N_("unusable secret key"))
893 X(KEYSERVER ,N_("keyserver error"))
894 X(CANCELED ,N_("canceled"))
895 X(NO_CARD ,N_("no card"))
896 X(NO_DATA ,N_("no data"))
897 default: p = buf; sprintf(buf, "g10err=%d", err); break;
898 }
899 #undef X
900 return _(p);
901 }