📄 pgpclienterrors.c
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: pgpClientErrors.c,v 1.18 2002/08/06 20:10:16 dallen Exp $
____________________________________________________________________________*/
#include <stdio.h>
#include <string.h>
#include "pgpClientErrors.h"
#include "pgpMem.h"
#include "pgpPFLPriv.h"
typedef struct ClientErrorEntry
{
PGPError const number;
const char * const string;
} ClientErrorEntry;
#define EN(number, string) { number, string }
static const ClientErrorEntry sErrors[] =
{
/* Share errors */
EN(kPGPClientError_NotEnoughSharesInObject,
"not enough shares to split"),
EN(kPGPClientError_DifferentSplitKeys,
"shares were not split from the same key"),
EN(kPGPClientError_DifferentSharePool,
"shares were not split from the same share pool"),
EN(kPGPClientError_IdenticalShares,
"identical shares cannot be combined"),
/* SKEP errors */
EN(kPGPClientError_IncorrectSKEPVersion,
"client SKEP version different from server SKEP version"),
EN(kPGPClientError_RejectedSKEPAuthentication,
"your key was not accepted for authentication by the remote system"),
/* Pref errors */
EN(kPGPClientError_AdminPrefsNotFound,
"administrative preferences file not found"),
EN(kPGPClientError_PrefsHashBad,
"preferences corrupt"),
EN(kPGPClientError_UnsplitPrivateKeyNotFound,
"unsplit private key could not be found to authenticate the connection"),
/* PGPdisk errors */
EN(kPGPClientError_BadDiskAlgorithm,
"this PGPdisk is encrypted using an unrecognized algorithm"),
EN(kPGPClientError_BadDiskCommandLine,
"invalid command line argument or parameter"),
EN(kPGPClientError_BadDiskPassphrase,
"the passphrase is incorrect"),
EN(kPGPClientError_CorruptDiskHeader,
"this file does not appear to be a valid PGPdisk"),
EN(kPGPClientError_DiskTooNew,
"this PGPdisk was created by a newer version of PGPdisk"),
EN(kPGPClientError_DiskTooOld,
"this PGPdisk was created by a older, incompatible version of PGPdisk"),
EN(kPGPClientError_DiskUserError,
"of an error working with a PGPdisk user object"),
EN(kPGPClientError_FilesOpenOnDisk,
"this PGPdisk is currently in use. Please close all open files on and "
"views to this PGPdisk, and try again"),
EN(kPGPClientError_DiskAlreadyMounted,
"this PGPdisk is already mounted"),
EN(kPGPClientError_DiskDriverIncompat,
"an incompatible version of the PGPdisk driver is running"),
EN(kPGPClientError_DiskAdkFuncOnPersonalBuild,
"an attempt was made to call a PGPdisk ADK function using a personal "
"privacy build of PGP"),
EN(kPGPClientError_DiskDiskIsWriteProtected,
"this PGPdisk file is either write-protected or opened for "
"read-only access only"),
EN(kPGPClientError_DiskDiskUsersAreWiped,
"this PGPdisk has had its non-public-key users wiped. It can now "
"only be mounted by the holder of the private key associated with "
"one or more of the public keys on the PGPdisk"),
EN(kPGPClientError_DiskDiskIsBeingReEncrypted,
"this PGPdisk is in the process of being re-encrypted from one "
"algorithm to another"),
EN(kPGPClientError_DiskReEncryptWithBadADK,
"you are attempting to reencrypt a PGPdisk with one or more ADK "
"user(s) whose associated public key(s) are not present on the "
"local keyring. Please import these keys to your keyring and try "
"again"),
EN(kPGPClientError_BadDiskPassKeyNotInRing,
"the passphrase you entered is not a valid passphrase for this "
"PGPdisk. (Note that there were users with public keys that could "
"not be checked, either because the private keys aren't on the local "
"keyring, the token has not been inserted, or because the local keyring could not be opened.) Please "
"try again"),
EN(kPGPClientError_DiskEngineIncompat,
"an incompatible version of PGPdiskEngine.dll is present"),
EN(kPGPClientError_DiskDriverNotInstalled,
"the PGPdisk driver is either not installed or has not been loaded"),
EN(kPGPClientError_DiskDriverCommFailed,
"there was an error communicating with the PGPdisk driver"),
EN(kPGPClientError_DiskTriedNTFSOnWin95,
"this PGPdisk was formatted using the NTFS filesystem, which is not "
"compatible with your version of Windows. Additionally, PGPdisk has not "
"detected the presence of any 3rd-party driver on your system capable of "
"reading NTFS volumes"),
EN(kPGPClientError_DiskTriedReadOnlyNTFS,
"this PGPdisk was formatted using the NTFS filesystem, which cannot "
"be used in read-only mode"),
EN(kPGPClientError_DiskDiskAlreadyInUse,
"this PGPdisk is already opened with exclusive access by another user "
"or application"),
EN(kPGPClientError_DiskCantRemoveCompression,
"PGPdisk was unable to remove the compression attribute from the "
"specified PGPdisk. You will not be allowed to mount this PGPdisk "
"until the compression has been removed"),
EN(kPGPClientError_DiskNoDrivesFree,
"there are no free drive letters remaining"),
EN(kPGPClientError_DiskDirNotFound,
"the specified directory does not exist or could not be found"),
EN(kPGPClientError_DiskDirWriteProtected,
"the specified directory is write-protected"),
EN(kPGPClientError_InvalidCmdLine,
"invalid commands or options were specified"),
EN(kPGPClientError_DiskNotMounted,
"the specified file is not a mounted PGPdisk"),
EN(kPGPClientError_MaxDisksMounted,
"the maximum number of PGPdisks are already mounted"),
EN(kPGPClientError_NeedPubKeyToWipeDisk,
"an attempt was made to wipe a PGPdisk with no public key users. Only "
"PGPdisks with public key users can be wiped"),
EN(kPGPClientError_DiskTriedFAT32OnNT4,
"this PGPdisk was formatted using the FAT32 filesystem, which is not "
"compatible your version of Windows. Additionally, PGPdisk has not "
"detected the presence of any 3rd-party driver on your system capable of "
"reading FAT32 volumes")
};
#define kPGPClientErrors_NumErrorTableEntries \
( sizeof( sErrors ) / sizeof( sErrors[ 0 ] ) )
#undef EN
PGPError
PGPGetClientErrorString(
PGPError theError,
PGPSize bufferSize,
char * theString )
{
PGPUInt32 idx;
char temp[ 256 ];
char const * errStr = NULL;
PGPSize len = 0;
PGPBoolean bufferBigEnough = FALSE;
if (theError >= kPGPPFLErrorBase && theError <= kPGPError_Last )
return PGPGetErrorString(theError, bufferSize, theString);
PGPValidateParam( bufferSize >= 1 );
PGPValidatePtr( theString );
*theString = '\0';
for( idx = 0; idx < kPGPClientErrors_NumErrorTableEntries; ++idx )
{
const ClientErrorEntry * entry;
entry = &sErrors[ idx ];
if ( entry->number == theError )
{
errStr = entry->string;
break;
}
}
if ( IsNull( errStr ) )
{
/* Produce something for missing errors */
sprintf( temp, "PGPClientError #%ld", (long)theError );
errStr = temp;
}
len = strlen( errStr );
bufferBigEnough = ( len + 1 <= bufferSize );
if ( bufferBigEnough )
{
strcpy( theString, errStr );
}
else
{
pgpCopyMemory( errStr, theString, bufferSize - 1 );
theString[ bufferSize - 1 ] = '\0';
}
return( bufferBigEnough ? kPGPError_NoErr : kPGPError_BufferTooSmall );
}
/*__Editor_settings____
Local Variables:
tab-width: 4
End:
vi: ts=4 sw=4
vim: si
_____________________*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -