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.

54 lines
1.6 KiB

  1. #ifndef PARSE_H
  2. #define PARSE_H
  3. #define CTSTRLEN(s) (sizeof(s)/sizeof(TCHAR) - 1)
  4. #define RFC1766_KEY_SZ L"MIME\\Database\\Rfc1766"
  5. #define NAME_BUF_SIZE MAX_PATH
  6. #define VALUE_BUF_SIZE MAX_PATH
  7. // Used for generating display name.
  8. #define FLAG_QUOTE 0x1
  9. #define FLAG_DELIMIT 0x2
  10. #define PARSE_FLAGS_LCID_TO_SZ 0x1
  11. #define PARSE_FLAGS_SZ_TO_LCID 0x2
  12. // ---------------------------------------------------------------------------
  13. // CParseUtils
  14. // Generic parsing utils.
  15. // ---------------------------------------------------------------------------
  16. class CParseUtils
  17. {
  18. public:
  19. // Inline strip leading and trailing whitespace.
  20. static VOID TrimWhiteSpace(LPWSTR *psz, LPDWORD pcc);
  21. // Inline parse of delimited token.
  22. static BOOL GetDelimitedToken(LPWSTR* pszBuf, LPDWORD pccBuf,
  23. LPWSTR* pszTok, LPDWORD pccTok, WCHAR cDelim);
  24. // Inline parse of key=value token.
  25. static BOOL GetKeyValuePair(LPWSTR szB, DWORD ccB,
  26. LPWSTR* pszK, LPDWORD pccK, LPWSTR* pszV, LPDWORD pccV);
  27. // Outputs token to buffer.
  28. static HRESULT SetKey(LPWSTR szBuffer, LPDWORD pccBuffer,
  29. PCWSTR szKey, DWORD ccAlloced, DWORD dwFlags);
  30. // Outputs key=value token to buffer.
  31. static HRESULT SetKeyValuePair(LPWSTR szBuffer, LPDWORD pcbBuffer, PCWSTR szKey,
  32. PCWSTR szValue, DWORD cbAlloced, DWORD dwFlags);
  33. // Converts binary to hex encoded unicode string.
  34. static VOID BinToUnicodeHex(LPBYTE pSrc, UINT cSrc, LPWSTR pDst);
  35. // Converts hex encoded unicode string to binary.
  36. static VOID UnicodeHexToBin(LPCWSTR pSrc, UINT cSrc, LPBYTE pDest);
  37. };
  38. #endif // PARSE_H