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.

142 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1987-1992 Microsoft Corporation
  3. Module Name:
  4. FieldSiz.c
  5. Abstract:
  6. RAP (remote admin protocol) utility code.
  7. Author:
  8. John Rogers (JohnRo) 05-Mar-1991
  9. Environment:
  10. Portable to any flat, 32-bit environment. (Uses Win32 typedefs.)
  11. Requires ANSI C extensions: slash-slash comments, long external names.
  12. Revision History:
  13. (various NBU people)
  14. LanMan 2.x code
  15. 05-Mar-1991 JohnRo
  16. Created portable version from LanMan 2.x sources.
  17. 14-Apr-1991 JohnRo
  18. Reduce recompiles. Got rid of tabs in source file, per NT standards.
  19. 17-Apr-1991 JohnRo
  20. Added support for REM_IGNORE.
  21. Added debug msg when unexpected desc char found.
  22. 07-Sep-1991 JohnRo
  23. Move toward possibility of descs being in UNICODE.
  24. 21-Nov-1991 JohnRo
  25. Removed NT dependencies to reduce recompiles.
  26. 16-Aug-1992 JohnRo
  27. RAID 2920: Support UTC timezone in net code.
  28. Use PREFIX_ equates.
  29. --*/
  30. // These must be included first:
  31. #include <windef.h> // IN, LPDWORD, NULL, OPTIONAL, DWORD, etc.
  32. #include <lmcons.h> // NET_API_STATUS
  33. // These may be included in any order:
  34. #include <netdebug.h> // NetpBreakPoint().
  35. #include <prefix.h> // PREFIX_ equates.
  36. #include <rap.h> // My prototype, FORMAT_LPDESC_CHAR, LPDESC.
  37. #include <remtypes.h> // REM_WORD, etc.
  38. DWORD
  39. RapGetFieldSize(
  40. IN LPDESC TypePointer,
  41. IN OUT LPDESC * TypePointerAddress,
  42. IN RAP_TRANSMISSION_MODE TransmissionMode
  43. )
  44. /*++
  45. Routine Description:
  46. RapGetFieldSize gets the length of a field described by a type descriptor
  47. element. It calculates the length of an field described by an element of
  48. a descriptor string and updates the descriptor string pointer to point
  49. to the last char in the element of the descriptor string.
  50. Arguments:
  51. TypePointer - Points to first character in the descriptor element to be
  52. processed.
  53. TypePointerAddress - The address of the pointer passed as TypePointer. On
  54. exit, *TypePointerAddress points to last character in descriptor
  55. element.
  56. Transmission Mode - Indicates whether this array is part of a response,
  57. a request, or both.
  58. Return Value:
  59. Length in bytes of the field described by the descriptor string element.
  60. --*/
  61. {
  62. DESC_CHAR c;
  63. c = *TypePointer; /* Get descriptor type char */
  64. if ( (RapIsPointer(c)) || (c == REM_NULL_PTR) ) { // All pointers same size.
  65. while ( ++TypePointer, DESC_CHAR_IS_DIGIT( *TypePointer ) ) {
  66. (*TypePointerAddress)++; /* Move ptr to end of field size */
  67. }
  68. return (sizeof(LPVOID));
  69. }
  70. // Here if descriptor was not a pointer type so have to find the field
  71. // length specifically.
  72. switch ( c ) {
  73. case (REM_WORD):
  74. case (REM_BYTE):
  75. case (REM_DWORD):
  76. case (REM_SIGNED_DWORD):
  77. return (RapArrayLength(TypePointer,
  78. TypePointerAddress,
  79. TransmissionMode));
  80. case (REM_AUX_NUM):
  81. case (REM_PARMNUM):
  82. case (REM_RCV_BUF_LEN):
  83. case (REM_SEND_BUF_LEN):
  84. return (sizeof(unsigned short));
  85. case (REM_DATA_BLOCK):
  86. return (0); /* No structure for this */
  87. case (REM_DATE_TIME):
  88. case (REM_AUX_NUM_DWORD):
  89. return (sizeof(unsigned long));
  90. case (REM_IGNORE):
  91. return (0);
  92. case REM_EPOCH_TIME_GMT: /*FALLTHROUGH*/
  93. case REM_EPOCH_TIME_LOCAL:
  94. return (sizeof(DWORD));
  95. default:
  96. NetpKdPrint(( PREFIX_NETRAP
  97. "RapGetFieldSize: unexpected desc '" FORMAT_LPDESC_CHAR
  98. "'.\n", c));
  99. NetpBreakPoint();
  100. return (0);
  101. }
  102. /*NOTREACHED*/
  103. } // RapGetFieldSize