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.

59 lines
1.2 KiB

  1. #include "stdafx.h"
  2. #include "RtfParser.h"
  3. #include "Msg.h"
  4. BOOL MsgNotRtfFile()
  5. {
  6. return TRUE;
  7. }
  8. BOOL ConvertRtfFile(
  9. PBYTE pBuf, // Read buf
  10. DWORD dwSize, // File size
  11. PBYTE pWrite, // Write buf
  12. BOOL fAnsiToUnicode,
  13. PINT pnTargetFileSize)
  14. {
  15. CRtfParser* pcParser;
  16. DWORD dwVersion;
  17. DWORD dwCodepage;
  18. BOOL fRet = FALSE;
  19. pcParser = new CRtfParser(pBuf, dwSize, pWrite, dwSize*2);
  20. if (!pcParser) {
  21. MsgOverflow();
  22. goto gotoExit;
  23. }
  24. if (!pcParser->fRTFFile()) {
  25. MsgNotRtfFile();
  26. goto gotoExit;
  27. }
  28. if (ecOK != pcParser->GetVersion(&dwVersion) ||
  29. dwVersion != 1) {
  30. MsgNotRtfFile();
  31. goto gotoExit;
  32. }
  33. if (ecOK != pcParser->GetCodepage(&dwCodepage) ||
  34. dwCodepage != 936) {
  35. MsgNotRtfFile();
  36. goto gotoExit;
  37. }
  38. // Explain WordID by corresponding word text
  39. if (ecOK != pcParser->Do()) {
  40. MsgNotRtfFile();
  41. goto gotoExit;
  42. }
  43. pcParser->GetResult((PDWORD)pnTargetFileSize);
  44. fRet = TRUE;
  45. gotoExit:
  46. if (pcParser) {
  47. delete pcParser;
  48. }
  49. return fRet;
  50. }