
/* These segments of examples use the license authorization system service call
for a product. The examples are written in VAX C.
*/

/* This is an example of a license authorization system service call for a product
licensed with an availability license. The SYS$GRANT_LICENSE checks
whether enough units are available to use the product and returns the
success status SS$_NORMAL if successful. If there are not enough units on
the particular system and the product is installed and authorized for use in a
VAXcluster setting the system determines whether enough units are available
across the VAXcluster setting. It returns the success status SS$_NORMAL if
successful.
*/

#include <descrip.h>
#include <lib$routines.h>
#include <lmfdef.h>
#include <ssdef.h>
#include <starlet.h>
#include <stddef.h>
#include <stdio.h>
#include <stsdef.h>

#include descrip

#define LMF$_PROD_VERSION 3
#define LMF$_PROD_DATE 4
#define LMF$_PROD_TOKEN 1

typedef struct _quad_word {
	long int upper_long;
	long int lower_long;
} quad_word;

typedef struct _long_word {
	short int upper_word;
	short int lower_word;
} long_word;

main()

{
long status;
quad_word product_date;
long_word product_vers = {6,4};
short *tokenlen;
char prtoken[31];

struct {
	short itm$w_buflen ;
	short itm$w_code ;
	char *itm$a_addr ;
	short *itm$a_lenaddr ;
} grant_license_items[] = {
	sizeof (quad_word), LMF$_PROD_DATE, (char *)&product_date, 0,
	sizeof (long_word), LMF$_PROD_VERSION, (char *)&product_vers, 0,
	31, LMF$_PROD_TOKEN, prtoken, &tokenlen,
	0, 0, 0, 0
	};

static $DESCRIPTOR (product_name, "FORTRAN");
static $DESCRIPTOR (product_owner, "DEC");
static $DESCRIPTOR (product_date_string, "1-APR-1998 0:0:0.0");

	/* Use the VMS System Service SYS$BINTIM to convert the ASCII
	representation of the release date to an absolute or delta
	time version. */

status = SYS$BINTIM(&product_date_string, &product_date);
if ((status & 1) != 1) return (status);

/* Call the SYS$GRANT_LICENSE system service and store
the return status. */

status = SYS$GRANT_LICENSE(&product_name, &product_owner, 0,
	&grant_license_items);

if ((status & 1) != 1) return (status); /* not authorized */

/* otherwise, it is authorized, use the product token... */

}


