Ejemplo n.º 1
0
bool CheckPGPError(PGPError err)
{
	if (IsPGPError(err)) {
		PGPSize ErrMsgLen = pgpErrMsgLen;
		PGPGetErrorString(err, ErrMsgLen, pgpErrMsg);
		return 1;
	}
	else {
		*pgpErrMsg = '\0';
		return 0;
	}
}
Ejemplo n.º 2
0
	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 ( NULL==(int)( 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 );
}
Ejemplo n.º 3
0
static PGPError
PGPsdkUIErrorBox(PGPError error) 
{
	PGPError	err				= kPGPError_NoErr;
	char		szMessage[512];
	
	if (IsPGPError (error) && (error!=kPGPError_UserAbort)) {
		PGPGetErrorString (error, sizeof(szMessage), szMessage);
		printf("%s: PGP Error", szMessage);
	}

	return err;
}
Ejemplo n.º 4
0
void 
GetExternalErrorString(
	ExternalErrorType	exErrType, 
	PGPUInt32			exErr, 
	PGPUInt32			sizeErrString, 
	LPSTR				errString)
{
	static char	tempString[kMaxStringSize];

	pgpAssertAddrValid(errString, char);

	switch (exErrType)
	{

	case kEET_Win32Error:

#if defined(PGPDISK_MFC)

		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS |
			FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, exErr, 
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), errString, 
			sizeErrString, NULL);

#else	// !PGPDISK_MFC
		strcpy(errString, kEmptyString);
#endif	// PGPDISK_MFC

		break;

#if !defined(PGPDISK_NOSDK)

	case kEET_PGPSdkError:

		PGPGetErrorString((PGPError) exErr, sizeErrString, errString);

		sprintf(tempString, GetCommonString(kPGPdiskErrorWasString), 
			errString);
		SmartStringCopy(errString, tempString, sizeErrString);

		break;

#endif	// !PGPDISK_NOSDK

	default:
		strcpy(errString, kEmptyString);
		break;
	}
}
PGPError
PGPsdkUIErrorBox (
		HWND hWnd,
		PGPError error) 
{
	PGPError	err				= kPGPError_NoErr;
	CHAR		szMessage[512];
	char		StrRes[500];

	if (IsPGPError (error) && (error!=kPGPError_UserAbort)) 
	{
		PGPGetErrorString (error, sizeof(szMessage), szMessage);

		LoadString (gPGPsdkUILibInst, IDS_PGPERROR, StrRes, sizeof(StrRes));

		MessageBox (hWnd, szMessage, StrRes, 
			MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
	}

	return err;
}