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.

129 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. SessConv.c
  5. Abstract:
  6. This file contains RxpConvertSessionInfo().
  7. Author:
  8. John Rogers (JohnRo) 17-Oct-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. 17-Oct-1991 JohnRo
  14. Created.
  15. 21-Nov-1991 JohnRo
  16. Removed NT dependencies to reduce recompiles.
  17. --*/
  18. // These must be included first:
  19. #include <windef.h> // IN, DWORD, etc.
  20. #include <lmcons.h> // NET_API_STATUS, etc.
  21. #include <lmshare.h> // Required by rxsess.h.
  22. // These may be included in any order:
  23. #include <netdebug.h> // NetpAssert(), NetpKdPrint(()), etc.
  24. #include <netlib.h> // NetpCopyStringToBuffer().
  25. #include <rxpdebug.h> // IF_DEBUG().
  26. #include <rxsess.h> // My prototype.
  27. #include <tstring.h> // STRLEN().
  28. #define DO_STRING(destField, srcField) \
  29. { \
  30. BOOL CopyOK; \
  31. CopyOK = NetpCopyStringToBuffer ( \
  32. in->srcField, \
  33. STRLEN(in->srcField), \
  34. OutFixedDataEnd, \
  35. StringLocation, \
  36. & out->destField); \
  37. NetpAssert(CopyOK); \
  38. }
  39. VOID
  40. RxpConvertSessionInfo (
  41. IN LPSESSION_SUPERSET_INFO InStructure,
  42. IN DWORD Level,
  43. OUT LPVOID OutStructure,
  44. IN LPVOID OutFixedDataEnd,
  45. IN OUT LPTSTR *StringLocation
  46. )
  47. {
  48. LPSESSION_SUPERSET_INFO in = InStructure;
  49. NetpAssert(InStructure != NULL);
  50. NetpAssert(OutStructure != NULL);
  51. NetpAssert(StringLocation != NULL);
  52. IF_DEBUG(SESSION) {
  53. NetpKdPrint(( "RxpConvertSessionInfo: converting to level "
  54. FORMAT_DWORD ".\n", Level ));
  55. }
  56. switch (Level) {
  57. // 0 is subset of 1, and 1 is subset of 2.
  58. case 0 :
  59. case 1 :
  60. case 2 :
  61. {
  62. LPSESSION_INFO_2 out = OutStructure;
  63. // Field(s) common to levels 0, 1, 2.
  64. DO_STRING( sesi2_cname, sesi2_cname );
  65. if (Level == 0) {
  66. break;
  67. }
  68. // Field(s) common to levels 1, 2.
  69. DO_STRING( sesi2_username, sesi2_username );
  70. // Note: NT doesn't have sesiX_num_conns or sesiX_num_users.
  71. out->sesi2_num_opens = in->sesi2_num_opens;
  72. out->sesi2_time = in->sesi2_time;
  73. out->sesi2_idle_time = in->sesi2_idle_time;
  74. out->sesi2_user_flags = in->sesi2_user_flags;
  75. if (Level == 1) {
  76. break;
  77. }
  78. // Field(s) unique to level 2.
  79. DO_STRING( sesi2_cltype_name, sesi2_cltype_name );
  80. }
  81. break;
  82. case 10 :
  83. {
  84. LPSESSION_INFO_10 out = OutStructure;
  85. DO_STRING( sesi10_cname, sesi2_cname);
  86. DO_STRING( sesi10_username, sesi2_username );
  87. out->sesi10_time = in->sesi2_time;
  88. out->sesi10_idle_time = in->sesi2_idle_time;
  89. }
  90. break;
  91. default :
  92. NetpAssert(FALSE);
  93. }
  94. } // RxpConvertSessionInfo