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.

111 lines
2.3 KiB

  1. /*****************************************************************************\
  2. * MODULE: respdata.cpp
  3. *
  4. * PURPOSE: Implementation of COM interface for BidiSpooler
  5. *
  6. * Copyright (C) 2000 Microsoft Corporation
  7. *
  8. * History:
  9. *
  10. * 03/08/00 Weihai Chen (weihaic) Created
  11. *
  12. \*****************************************************************************/
  13. #include "precomp.h"
  14. #include "priv.h"
  15. TResponseData::TResponseData (
  16. IN CONST LPCWSTR pszSchema,
  17. IN CONST DWORD dwType,
  18. IN CONST BYTE *pData,
  19. IN CONST ULONG uSize):
  20. m_dwType (dwType),
  21. m_pData (NULL),
  22. m_uSize (uSize),
  23. m_pSchema (NULL),
  24. m_bValid (FALSE)
  25. {
  26. BOOL bValid = FALSE;
  27. //
  28. // In the response, the schema string can be NULL for GET operation
  29. //
  30. if (pszSchema) {
  31. DWORD dwLen = lstrlen (pszSchema) + 1;
  32. m_pSchema = new WCHAR [dwLen];
  33. if (m_pSchema) {
  34. if (SUCCEEDED(StringCchCopy (m_pSchema, dwLen, pszSchema)))
  35. bValid = TRUE;
  36. }
  37. }
  38. else
  39. bValid = TRUE;
  40. if (bValid) {
  41. // Validate the type and size
  42. BOOL bRet;
  43. switch (dwType) {
  44. case BIDI_NULL:
  45. bRet = uSize == BIDI_NULL_SIZE;
  46. break;
  47. case BIDI_INT:
  48. bRet = uSize == BIDI_INT_SIZE;
  49. break;
  50. case BIDI_FLOAT:
  51. bRet = uSize == BIDI_FLOAT_SIZE;
  52. break;
  53. case BIDI_BOOL:
  54. bRet = uSize == BIDI_BOOL_SIZE;
  55. break;
  56. case BIDI_ENUM:
  57. bRet = (uSize > 0);
  58. break;
  59. case BIDI_STRING:
  60. case BIDI_TEXT:
  61. case BIDI_BLOB:
  62. bRet = TRUE;
  63. break;
  64. default:
  65. bRet = FALSE;
  66. }
  67. if (bRet) {
  68. if (uSize) {
  69. m_pData = new BYTE [uSize];
  70. if (m_pData) {
  71. CopyMemory (m_pData, pData, uSize);
  72. m_bValid = TRUE;
  73. }
  74. }
  75. else
  76. m_bValid = TRUE;
  77. }
  78. }
  79. }
  80. TResponseData::~TResponseData ()
  81. {
  82. if (m_pData) {
  83. delete [] m_pData;
  84. m_pData = NULL;
  85. }
  86. if (m_pSchema) {
  87. delete [] m_pSchema;
  88. m_pSchema = NULL;
  89. }
  90. }