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.

165 lines
5.2 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1998-2000 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: Utils.h
  6. * Content: serial service provider utilitiy functions
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 11/25/98 jtk Created
  12. ***************************************************************************/
  13. #ifndef __UTILS_H__
  14. #define __UTILS_H__
  15. #undef DPF_SUBCOMP
  16. #define DPF_SUBCOMP DN_SUBCOMP_MODEM
  17. //**********************************************************************
  18. // Constant definitions
  19. //**********************************************************************
  20. //
  21. // type definition for values in StringToValue and ValueToString
  22. //
  23. #define VALUE_ENUM_TYPE DWORD
  24. //**********************************************************************
  25. // Macro definitions
  26. //**********************************************************************
  27. //**********************************************************************
  28. // Structure definitions
  29. //**********************************************************************
  30. //
  31. // forward strucutre references
  32. //
  33. class CModemSPData;
  34. typedef struct _BUFFERDESC BUFFERDESC;
  35. typedef struct _MESSAGE_HEADER MESSAGE_HEADER;
  36. //
  37. // structure for relating a string to an enum value
  38. //
  39. typedef struct _STRING_BLOCK
  40. {
  41. DWORD dwEnumValue;
  42. const WCHAR *pWCHARKey;
  43. DWORD dwWCHARKeyLength;
  44. const char *pASCIIKey;
  45. DWORD dwASCIIKeyLength;
  46. TCHAR szLocalizedKey[256];
  47. } STRING_BLOCK;
  48. //
  49. // structure to generate list of modems
  50. //
  51. typedef struct _MODEM_NAME_DATA
  52. {
  53. DWORD dwModemID; // modem ID
  54. DWORD dwModemNameSize; // size of name (including NULL)
  55. const TCHAR *pModemName; // modem name
  56. } MODEM_NAME_DATA;
  57. //**********************************************************************
  58. // Variable definitions
  59. //**********************************************************************
  60. //**********************************************************************
  61. // Function prototypes
  62. //**********************************************************************
  63. BOOL ModemInitProcessGlobals( void );
  64. void ModemDeinitProcessGlobals( void );
  65. HRESULT InitializeInterfaceGlobals( CModemSPData *const pSPData );
  66. void DeinitializeInterfaceGlobals( CModemSPData *const pSPData );
  67. HRESULT LoadTAPILibrary( void );
  68. void UnloadTAPILibrary( void );
  69. BOOL IsSerialGUID( const GUID *const pGuid );
  70. BOOL StringToValue( const WCHAR *const pString,
  71. const DWORD dwStringLength,
  72. VALUE_ENUM_TYPE *const pEnum,
  73. const STRING_BLOCK *const pPairs,
  74. const DWORD dwPairCount );
  75. BOOL ValueToString( const WCHAR **const ppString,
  76. DWORD *const pdwStringLength,
  77. const DWORD Enum,
  78. const STRING_BLOCK *const pPairs,
  79. const DWORD dwPairCount );
  80. void DeviceIDToGuid( GUID *const pGuid, const UINT_PTR DeviceID, const GUID *const pEncryptionGuid );
  81. DWORD GuidToDeviceID( const GUID *const pGuid, const GUID *const pEncryptionGuid );
  82. void ComDeviceIDToString( TCHAR *const pString, const UINT_PTR DeviceID );
  83. HRESULT WideToAnsi( const WCHAR *const pWCHARString,
  84. const DWORD dwWCHARStringLength,
  85. char *const pString,
  86. DWORD *const pdwStringLength );
  87. HRESULT AnsiToWide( const char *const pString,
  88. const DWORD dwStringLength,
  89. WCHAR *const pWCHARString,
  90. DWORD *const pdwWCHARStringLength );
  91. HRESULT CreateSPData( CModemSPData **const ppSPData,
  92. const SP_TYPE SPType,
  93. IDP8ServiceProviderVtbl *const pVtbl );
  94. HRESULT InitializeInterfaceGlobals( CModemSPData *const pSPData );
  95. void DeinitializeInterfaceGlobals( CModemSPData *const pSPData );
  96. HRESULT GenerateAvailableComPortList( BOOL *const pfPortAvailable,
  97. const UINT_PTR uMaxDeviceIndex,
  98. DWORD *const pdwPortCount );
  99. HRESULT GenerateAvailableModemList( const TAPI_INFO *const pTAPIInfo,
  100. DWORD *const pdwModemCount,
  101. MODEM_NAME_DATA *const pModemNameData,
  102. DWORD *const pdwModemNameDataSize );
  103. _inline DWORD ModemIDFromTAPIID( const DWORD dwTAPIID ) { return ( dwTAPIID + 1 ); }
  104. #undef DPF_MODNAME
  105. #define DPF_MODNAME "TAPIIDFromModemID"
  106. _inline DWORD TAPIIDFromModemID( const DWORD dwModemID )
  107. {
  108. DNASSERT( dwModemID != 0 );
  109. return ( dwModemID - 1 );
  110. }
  111. #undef DPF_MODNAME
  112. #ifndef UNICODE
  113. HRESULT PhoneNumberToWCHAR( const char *const pPhoneNumber,
  114. WCHAR *const pWCHARPhoneNumber,
  115. DWORD *const pdwWCHARPhoneNumberSize );
  116. HRESULT PhoneNumberFromWCHAR( const WCHAR *const pWCHARPhoneNumber,
  117. char *const pPhoneNumber,
  118. DWORD *const pdwPhoneNumberSize );
  119. #endif
  120. //
  121. // GUID encryption/decription code. Note that it's presently an XOR function
  122. // so map the decryption code to the encryption function.
  123. //
  124. void ModemEncryptGuid( const GUID *const pSourceGuid,
  125. GUID *const pDestinationGuid,
  126. const GUID *const pEncrpytionKey );
  127. inline void ModemDecryptGuid( const GUID *const pSourceGuid,
  128. GUID *const pDestinationGuid,
  129. const GUID *const pEncryptionKey ) { ModemEncryptGuid( pSourceGuid, pDestinationGuid, pEncryptionKey ); }
  130. #endif // __UTILS_H__