Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.8 KiB

  1. // Base64Coder.h: interface for the Base64Coder class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_BASE64CODER_H__B2E45717_0625_11D2_A80A_00C04FB6794C__INCLUDED_)
  5. #define AFX_BASE64CODER_H__B2E45717_0625_11D2_A80A_00C04FB6794C__INCLUDED_
  6. #if _MSC_VER >= 1000
  7. #pragma once
  8. #endif // _MSC_VER >= 1000
  9. #ifdef _AFXDLL
  10. #include <afx.h>
  11. typedef CString String;
  12. #else
  13. #include <windows.h>
  14. #include <string>
  15. typedef std::string String;
  16. #endif
  17. class Base64Coder
  18. {
  19. // Internal bucket class.
  20. class TempBucket
  21. {
  22. public:
  23. BYTE nData[4];
  24. BYTE nSize;
  25. void Clear() { ::ZeroMemory(nData, 4); nSize = 0; };
  26. };
  27. PBYTE m_pDBuffer;
  28. PBYTE m_pEBuffer;
  29. DWORD m_nDBufLen;
  30. DWORD m_nEBufLen;
  31. DWORD m_nDDataLen;
  32. DWORD m_nEDataLen;
  33. public:
  34. Base64Coder();
  35. virtual ~Base64Coder();
  36. public:
  37. virtual void Encode(const PBYTE, DWORD);
  38. virtual void Decode(const PBYTE, DWORD);
  39. virtual void Encode(LPCSTR sMessage);
  40. virtual void Decode(LPCSTR sMessage);
  41. virtual LPCSTR DecodedMessage() const;
  42. virtual void DecodedMessage(PBYTE* ppBuffer, DWORD* nBufLen) const;
  43. virtual LPCSTR EncodedMessage() const;
  44. virtual void AllocEncode(DWORD);
  45. virtual void AllocDecode(DWORD);
  46. virtual void SetEncodeBuffer(const PBYTE pBuffer, DWORD nBufLen);
  47. virtual void SetDecodeBuffer(const PBYTE pBuffer, DWORD nBufLen);
  48. protected:
  49. virtual void _EncodeToBuffer(const TempBucket &Decode, PBYTE pBuffer);
  50. virtual ULONG _DecodeToBuffer(const TempBucket &Decode, PBYTE pBuffer);
  51. virtual void _EncodeRaw(TempBucket &, const TempBucket &);
  52. virtual void _DecodeRaw(TempBucket &, const TempBucket &);
  53. virtual BOOL _IsBadMimeChar(BYTE);
  54. static char m_DecodeTable[256];
  55. static BOOL m_Init;
  56. void _Init();
  57. };
  58. #endif // !defined(AFX_BASE64CODER_H__B2E45717_0625_11D2_A80A_00C04FB6794C__INCLUDED_)