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.

42 lines
1.8 KiB

  1. #include <objbase.h>
  2. // Review 500?
  3. #define E_BUFFERTOOSMALL MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 500)
  4. #define E_SOURCEBUFFERTOOSMALL MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 501)
  5. // SafeStrCpyN & SafeStrCatN return values:
  6. // S_OK: Success and guaranteed NULL terminated.
  7. // E_INVALIDARG: If any ptr is NULL, or cchDest <= 0.
  8. // E_BUFFERTOOSMALL: If cchDest is too small. Content of pszDest is
  9. // undefined.
  10. HRESULT SafeStrCpyN(LPWSTR pszDest, LPCWSTR pszSrc, DWORD cchDest);
  11. HRESULT SafeStrCatN(LPWSTR pszDest, LPCWSTR pszSrc, DWORD cchDest);
  12. // Same return values as for the corresponding SafeStrCxxN, and
  13. // FAILED(hres): *ppchLeft and *ppszEnd are undefined.
  14. //
  15. // *pcchLeft = nb char left in pszDest including the '\0\ just put there
  16. // *ppszEnd = points to the '\0' just put there
  17. //
  18. HRESULT SafeStrCpyNEx(LPWSTR pszDest, LPCWSTR pszSrc, DWORD cchDest,
  19. LPWSTR* ppszEnd, DWORD* pcchLeft);
  20. HRESULT SafeStrCatNEx(LPWSTR pszDest, LPCWSTR pszSrc, DWORD cchDest,
  21. LPWSTR* ppszEnd, DWORD* pcchLeft);
  22. // Comment: Do not use to copy only N first char of a string. Will return
  23. // failure if does not encounter '\0' in source.
  24. HRESULT SafeStrCpyNReq(LPWSTR pszDest, LPWSTR pszSrc, DWORD cchDest,
  25. DWORD* pcchRequired);
  26. // SafeStrCpyNExact & SafeStrCpyNExactEx return values:
  27. // Same as SaStrCpyN, plus:
  28. // E_SOURCEBUFFERTOOSMALL: The source buffer did not contain at least
  29. // cchExact chars
  30. //
  31. // cchExact has to include the NULL terminator
  32. HRESULT SafeStrCpyNExact(LPWSTR pszDest, LPCWSTR pszSrc, DWORD cchDest,
  33. DWORD cchExact);
  34. HRESULT SafeStrCpyNExactEx(LPWSTR pszDest, LPCWSTR pszSrc, DWORD cchDest,
  35. DWORD cchExact, LPWSTR* ppszEnd, DWORD* pcchLeft);