home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / lsapi.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  12KB  |  325 lines

  1. /*++
  2.  
  3. Copyright (c) 1995-1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     lsapi.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the 32-Bit Licensing API.
  12.     The Licensing API is still pre-release (i.e. beta) code.
  13.  
  14. Revision History:
  15.  
  16. --*/
  17.  
  18. #ifndef LSAPI_H
  19. #define LSAPI_H
  20.  
  21. #define LS_API_ENTRY    WINAPI
  22.  
  23. /***************************************************/
  24. /* Standard LSAPI C status codes                   */ 
  25. /***************************************************/
  26.  
  27. #define LS_SUCCESS                           ((LS_STATUS_CODE) 0x0)
  28. #define LS_BAD_HANDLE                        ((LS_STATUS_CODE) 0xC0001001)
  29. #define LS_INSUFFICIENT_UNITS                ((LS_STATUS_CODE) 0xC0001002)
  30. #define LS_SYSTEM_UNAVAILABLE                ((LS_STATUS_CODE) 0xC0001003)
  31. #define LS_LICENSE_TERMINATED                ((LS_STATUS_CODE) 0xC0001004)
  32. #define LS_AUTHORIZATION_UNAVAILABLE         ((LS_STATUS_CODE) 0xC0001005)
  33. #define LS_LICENSE_UNAVAILABLE               ((LS_STATUS_CODE) 0xC0001006)
  34. #define LS_RESOURCES_UNAVAILABLE             ((LS_STATUS_CODE) 0xC0001007)
  35. #define LS_NETWORK_UNAVAILABLE               ((LS_STATUS_CODE) 0xC0001008)
  36. #define LS_TEXT_UNAVAILABLE                  ((LS_STATUS_CODE) 0x80001009)
  37. #define LS_UNKNOWN_STATUS                    ((LS_STATUS_CODE) 0xC000100A)
  38. #define LS_BAD_INDEX                         ((LS_STATUS_CODE) 0xC000100B)
  39. #define LS_LICENSE_EXPIRED                   ((LS_STATUS_CODE) 0x8000100C)
  40. #define LS_BUFFER_TOO_SMALL                  ((LS_STATUS_CODE) 0xC000100D)
  41. #define LS_BAD_ARG                           ((LS_STATUS_CODE) 0xC000100E)
  42.  
  43. /* Microsoft provider-specific error codes */
  44.  
  45. // The name of the current user could not be retrieved.
  46. #define  LS_NO_USERNAME                  ( (LS_STATUS_CODE) 0xC0002000 )
  47.  
  48. // An unexpected error occurred in a system call.
  49. #define  LS_SYSTEM_ERROR                 ( (LS_STATUS_CODE) 0xC0002001 )
  50.  
  51. // The provider failed to properly initialize.
  52. #define  LS_SYSTEM_INIT_FAILED           ( (LS_STATUS_CODE) 0xC0002002 )
  53.  
  54. // An internal error has occurred in the Micrsoft provider.
  55. #define  LS_INTERNAL_ERROR               ( (LS_STATUS_CODE) 0xC0002002 )
  56.  
  57.  
  58. /***************************************************/
  59. /* standard LS API c datatype definitions          */
  60. /***************************************************/
  61.  
  62. typedef unsigned long    LS_STATUS_CODE;
  63. typedef unsigned long    LS_HANDLE;
  64. typedef char             LS_STR;
  65. typedef unsigned long    LS_ULONG;
  66. typedef long             LS_LONG;
  67. typedef void             LS_VOID;
  68.  
  69. typedef struct {
  70.    LS_STR        MessageDigest[16];  /* a 128-bit message digest          */
  71. } LS_MSG_DIGEST;
  72.  
  73. typedef struct {
  74.    LS_ULONG      SecretIndex;        /* index of secret, X                */
  75.    LS_ULONG      Random;             /* a random 32-bit value, R          */
  76.    LS_MSG_DIGEST MsgDigest;          /* the message digest h(in,R,S,Sx)   */
  77. } LS_CHALLDATA;
  78.  
  79. typedef struct {
  80.    LS_ULONG      Protocol;           /* Specifies the protocol            */
  81.    LS_ULONG      Size;               /* size of ChallengeData structure   */
  82.    LS_CHALLDATA  ChallengeData;      /* challenge & response              */
  83. } LS_CHALLENGE;
  84.  
  85.  
  86. /***************************************************/
  87. /* Standard LSAPI C constant definitions           */
  88. /***************************************************/
  89.  
  90. #define LS_DEFAULT_UNITS            ((LS_ULONG) 0xFFFFFFFF)
  91. #define LS_ANY                      ((LS_STR FAR *) "")
  92. #define LS_USE_LAST                 ((LS_ULONG) 0x0800FFFF)
  93. #define LS_INFO_NONE                ((LS_ULONG) 0)
  94. #define LS_INFO_SYSTEM              ((LS_ULONG) 1)
  95. #define LS_INFO_DATA                ((LS_ULONG) 2)
  96. #define LS_UPDATE_PERIOD            ((LS_ULONG) 3)
  97. #define LS_LICENSE_CONTEXT          ((LS_ULONG) 4)
  98. #define LS_BASIC_PROTOCOL           ((LS_ULONG) 0x00000001)
  99. #define LS_SQRT_PROTOCOL            ((LS_ULONG) 0x00000002)
  100. #define LS_OUT_OF_BAND_PROTOCOL     ((LS_ULONG) 0xFFFFFFFF)
  101. #define LS_NULL                     ((LS_VOID FAR *) NULL)
  102.  
  103. // maximum length of a provider name returned by LSEnumProviders()
  104. #define LS_MAX_PROVIDER_NAME  ( 255 )
  105.  
  106. // if returned by a call to LSQuery() against LS_UPDATE_PERIOD,
  107. // indicates that no interval recommendation is being made
  108. #define LS_NO_RECOMMENDATION  ( (LS_ULONG) 0xFFFFFFFF )
  109.  
  110.  
  111. /***************************************************/
  112. /* Standard LSAPI C function definitions           */
  113. /***************************************************/
  114.  
  115. LS_STATUS_CODE
  116. LS_API_ENTRY
  117. LSRequest(        LS_STR             *LicenseSystem,
  118.                   LS_STR             *PublisherName,
  119.                   LS_STR             *ProductName,
  120.                   LS_STR             *Version,
  121.                   LS_ULONG           TotUnitsReserved,
  122.                   LS_STR             *LogComment,
  123.                   LS_CHALLENGE       *Challenge,
  124.                   LS_ULONG           *TotUnitsGranted,
  125.                   LS_HANDLE          *LicenseHandle );
  126.  
  127. LS_STATUS_CODE
  128. LS_API_ENTRY
  129. LSRelease(        LS_HANDLE          LicenseHandle,
  130.                   LS_ULONG           TotUnitsConsumed,
  131.                   LS_STR             *LogComment);
  132.  
  133. LS_STATUS_CODE
  134. LS_API_ENTRY
  135. LSUpdate(         LS_HANDLE          LicenseHandle,
  136.                   LS_ULONG           TotUnitsConsumed,
  137.                   LS_ULONG           TotUnitsReserved,
  138.                   LS_STR             *LogComment,
  139.                   LS_CHALLENGE       *Challenge,
  140.                   LS_ULONG           *TotUnitsGranted);
  141.  
  142. LS_STATUS_CODE
  143. LS_API_ENTRY
  144. LSGetMessage(     LS_HANDLE          LicenseHandle,
  145.                   LS_STATUS_CODE     Value,
  146.                   LS_STR             *Buffer,
  147.                   LS_ULONG           BufferSize);
  148.  
  149. LS_STATUS_CODE
  150. LS_API_ENTRY
  151. LSQuery(          LS_HANDLE          LicenseHandle,
  152.                   LS_ULONG           Information,
  153.                   LS_VOID            *InfoBuffer,
  154.                   LS_ULONG           BufferSize,
  155.                   LS_ULONG           *ActualBufferSize);
  156.  
  157. LS_STATUS_CODE
  158. LS_API_ENTRY
  159. LSEnumProviders(  LS_ULONG           Index,
  160.                   LS_STR             *Buffer);
  161.  
  162. LS_VOID
  163. LS_API_ENTRY
  164. LSFreeHandle(     LS_HANDLE          LicenseHandle );
  165.  
  166.  
  167. /***************************************************/
  168. /* Extension LSAPI C function definitions          */
  169. /***************************************************/
  170.  
  171. LS_STATUS_CODE
  172. LS_API_ENTRY
  173. LSInstall(         LS_STR *     ProviderPath );
  174. /*++
  175.  
  176. Routine Description:
  177.  
  178.    Install the given DLL as a license system provider.
  179.  
  180.    NOTE: This API is a Microsoft extension to the LSAPI standard.
  181.  
  182. Arguments:
  183.  
  184.    ProviderPath (LS_STR *)
  185.       Path to the provider DLL to install.  This should be a full
  186.       path, and the DLL should be in the %SystemRoot%\System32
  187.       directory.
  188.    
  189. Return Value:
  190.  
  191.    (LS_STATUS_CODE)
  192.       LS_SUCCESS
  193.          Provider is already installed or was successfully added.
  194.       LS_BAD_ARG
  195.          The parameters passed to the function were invalid.
  196.       other
  197.          An error occurred while attempting to install the provider.
  198.  
  199. --*/
  200.  
  201.  
  202. /***************************************************/
  203. /* Extension LSAPI C function definitions          */
  204. /* (these will be supported only for the BETA SDK) */
  205. /***************************************************/
  206.  
  207. // license types (node assignment, user assignment, or concurrent use assignment)
  208. typedef DWORD LS_LICENSE_TYPE;
  209.  
  210. #define  LS_LICENSE_TYPE_NODE    ( 0 )
  211. #define  LS_LICENSE_TYPE_USER    ( 1 )
  212. #define  LS_LICENSE_TYPE_SERVER  ( 2 )
  213.  
  214. LS_STATUS_CODE
  215. LS_API_ENTRY
  216. LSLicenseUnitsSet( LS_STR *            LicenseSystem,
  217.                    LS_STR *            PublisherName,
  218.                    LS_STR *            ProductName,
  219.                    LS_STR *            Version,
  220.                    LS_LICENSE_TYPE     LicenseType,
  221.                    LS_STR *            UserName,
  222.                    LS_ULONG            NumUnits,
  223.                    LS_ULONG            NumSecrets,
  224.                    LS_ULONG *          Secrets );
  225. /*++
  226.  
  227. Routine Description:
  228.  
  229.    Set the number of units for the given license to the designated value.
  230.  
  231.    NOTE: This API is a Microsoft extension to the LSAPI standard, and
  232.          WILL ONLY BE SUPPORTED FOR THE BETA RELEASE OF THE LSAPI SDK.
  233.          Thereafter, licenses must be added using the common certicate
  234.          format (CCF).  APIs will be exposed to allow licenses to be
  235.          auotmatically added by an application's SETUP program.
  236.  
  237. Arguments:
  238.  
  239.    LicenseSystem (LS_STR *)
  240.       License system to which to set the license information.  If LS_ANY,
  241.       the license will be offered to each installed license system until
  242.       one returns success.
  243.    PublisherName (LS_STR *)
  244.       Publisher name for which to set the license info.
  245.    ProductName   (LS_STR *)       
  246.       Product name for which to set the license info.
  247.    Version       (LS_STR *)       
  248.       Product version for which to set the license info.
  249.    LicenseType   (LS_LICENSE_TYPE)
  250.       Type of license for which to set the license info.
  251.    UserName      (LS_STR *)
  252.       User for which to set the license info.  If LS_NULL and the the license
  253.       type is LS_LICENSE_TYPE_USER, the license info will be set for the
  254.       user corresponding to the current thread.
  255.    NumUnits      (LS_ULONG)
  256.       Units purchased for this license.
  257.    NumSecrets    (LS_ULONG)
  258.       Number of application-specific secrets corresponding to this license.
  259.    Secrets       (LS_ULONG *)
  260.       Array of application-specific secrets corresponding to this license.
  261.  
  262. Return Value:
  263.  
  264.    (LS_STATUS_CODE)
  265.       LS_SUCCESS
  266.          License successfully installed.
  267.       LS_BAD_ARG
  268.          The parameters passed to the function were invalid.
  269.       other
  270.          An error occurred whil attempting to install the license.
  271.  
  272. --*/
  273.  
  274.  
  275. LS_STATUS_CODE
  276. LS_API_ENTRY
  277. LSLicenseUnitsGet( LS_STR *            LicenseSystem,
  278.                    LS_STR *            PublisherName,
  279.                    LS_STR *            ProductName,
  280.                    LS_STR *            Version,
  281.                    LS_STR *            UserName,
  282.                    LS_ULONG *          NumUnits );
  283. /*++
  284.  
  285. Routine Description:
  286.  
  287.    Get the number of units for the given license.
  288.  
  289.    NOTE: This API is a Microsoft extension to the LSAPI standard, and
  290.          WILL ONLY BE SUPPORTED FOR THE BETA RELEASE OF THE LSAPI SDK.
  291.          Thereafter, licenses must be accessed using the common certicate
  292.          format (CCF).
  293.  
  294. Arguments:
  295.  
  296.    LicenseSystem (LS_STR *)
  297.       License system for which to get the license information.  If LS_ANY,
  298.       each installed license system will be queried until one returns success.
  299.    PublisherName (LS_STR *)
  300.       Publisher name for which to get the license info.
  301.    ProductName   (LS_STR *)       
  302.       Product name for which to get the license info.
  303.    Version       (LS_STR *)       
  304.       Product version for which to get the license info.
  305.    UserName      (LS_STR *)
  306.       User for which to get the license info.  If LS_NULL and the the license
  307.       type is LS_LICENSE_TYPE_USER, license info will be retrieved for the
  308.       user corresponding to the current thread.
  309.    NumUnits      (LS_ULONG *)
  310.       On return, the number of units purchased for this license.
  311.  
  312. Return Value:
  313.  
  314.    (LS_STATUS_CODE)
  315.       LS_SUCCESS
  316.          Success.
  317.       LS_BAD_ARG
  318.          The parameters passed to the function were invalid.
  319.       other
  320.          An error occurred whil attempting to retrieve the license.
  321.  
  322. --*/
  323.  
  324. #endif /* LSAPI_H */
  325.