Leaked source code of windows server 2003
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.

44 lines
996 B

  1. #define MAXOVERFLOWBYTES 16
  2. class CINetCodeConverter
  3. {
  4. public:
  5. CINetCodeConverter();
  6. ~CINetCodeConverter() {}
  7. HRESULT GetStringSizeA(BYTE const* pbySource, long lSourceSize, long* plDestSize);
  8. HRESULT ConvertStringA(BYTE const* pbySource, long lSourceSize, BYTE* pbyDest, long lDestSize, long* lConvertedSize = NULL);
  9. private:
  10. BOOL fOutputMode;
  11. BYTE* pbyOutput;
  12. long lOutputLimit;
  13. long lNumOutputBytes;
  14. int nNumOverflowBytes;
  15. BYTE OverflowBuffer[MAXOVERFLOWBYTES];
  16. HRESULT WalkString(BYTE const* pbySource, long lSourceSize, long* lConvertedSize);
  17. HRESULT EndOfDest(BYTE by);
  18. HRESULT OutputOverflowBuffer();
  19. protected:
  20. virtual HRESULT ConvertByte(BYTE by) = 0;
  21. virtual HRESULT CleanUp() {return S_OK;}
  22. protected:
  23. inline HRESULT Output(BYTE by)
  24. {
  25. HRESULT hr = S_OK;
  26. if (fOutputMode) {
  27. if (lNumOutputBytes < lOutputLimit)
  28. *pbyOutput++ = by;
  29. else
  30. hr = EndOfDest(by);
  31. }
  32. lNumOutputBytes++;
  33. return hr;
  34. }
  35. };