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.

110 lines
2.2 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. m_pSchema = new WCHAR [lstrlen (pszSchema) + 1];
  32. if (m_pSchema) {
  33. lstrcpy (m_pSchema, pszSchema);
  34. bValid = TRUE;
  35. }
  36. }
  37. else
  38. bValid = TRUE;
  39. if (bValid) {
  40. // Validate the type and size
  41. BOOL bRet;
  42. switch (dwType) {
  43. case BIDI_NULL:
  44. bRet = uSize == BIDI_NULL_SIZE;
  45. break;
  46. case BIDI_INT:
  47. bRet = uSize == BIDI_INT_SIZE;
  48. break;
  49. case BIDI_FLOAT:
  50. bRet = uSize == BIDI_FLOAT_SIZE;
  51. break;
  52. case BIDI_BOOL:
  53. bRet = uSize == BIDI_BOOL_SIZE;
  54. break;
  55. case BIDI_ENUM:
  56. bRet = (uSize > 0);
  57. break;
  58. case BIDI_STRING:
  59. case BIDI_TEXT:
  60. case BIDI_BLOB:
  61. bRet = TRUE;
  62. break;
  63. default:
  64. bRet = FALSE;
  65. }
  66. if (bRet) {
  67. if (uSize) {
  68. m_pData = new BYTE [uSize];
  69. if (m_pData) {
  70. CopyMemory (m_pData, pData, uSize);
  71. m_bValid = TRUE;
  72. }
  73. }
  74. else
  75. m_bValid = TRUE;
  76. }
  77. }
  78. }
  79. TResponseData::~TResponseData ()
  80. {
  81. if (m_pData) {
  82. delete [] m_pData;
  83. m_pData = NULL;
  84. }
  85. if (m_pSchema) {
  86. delete [] m_pSchema;
  87. m_pSchema = NULL;
  88. }
  89. }