From: Mark Buda [buda@tabasco.zko.dec.no.spam.com] Sent: Tuesday, May 20, 2003 7:59 PM To: Info-VAX@Mvb.Saic.Com Subject: A couple examples of how SYS$GRANT_LICNESE is used For those who asked in email, here are a couple examples of how to use SYS$GRANT_LICENSE() along with one example for SYS$RELEASE_LICENSE(). If you would like to get a copy of the PDF file that has this information, send me an email and I will forward it to you. Sincerely, Mark Buda Hewlett-Packard Company VMS Engineering 110 Spitbrook Road MS: ZK3-4/X57 Nashua, NH 03062 Voice: (603) 884-1969 FAX: (603) 884-3451 Example These segments of examples use the license authorization system service call for a product. The examples are written in C. #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-1988 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) exit (status); /* Call the SYS$GRANT_LICENSE system service and store the return status. */ status = SYS$GRANT_LICENSE( &product_name, &product_owner, , &grant_license_items); if ((status & 1) != 1) exit (status); /* not authorized */ /* otherwise, it is authorized, use the product token... */ } 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 VMSCluster setting the system determines whether enough units are available across the VMSCluster setting. It returns the success status SS$_NORMAL if successful. #include descrip #define LMF$_PROD_DATE 4 #define LMF$_PROD_TOKEN 1 typedef struct _quad_word { long int upper_long; long int lower_long; } quad_word; main() { long status; quad_word product_date; 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, 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-1988 0:0:0.0"); /* Use SYS$BINTIM to convert the ASCII string representing the the date to an absolute or delta time value. */ status = SYS$BINTIM(&product_date_string, &product_date); if ((status & 1) != 1) exit (status); /* Call the SYS$GRANT_LICENSE system service and store the return status. */ status = SYS$GRANT_LICENSE(&product_name, &product_owner,, &grant_license_items); /* Test whether the current number of license users in the system is greater than the license units. */ if (status == LICENSE$_EXCEEDED) { /* process the busy condition */ /* if desired */ } else if (!status) return (status); /* otherwise it is authorized, use product token... */ } This is an example of a license authorization system service call for a product licensed with an activity license. The SYS$GRANT_LICENSE checks whether the current users of the license in the system number more than the license units. If the current number of users is less than the license units, the system returns the success status SS$_NORMAL. If the current number of users of the license in the system is greater than the license units, the system returns the error status LICENSE$_EXCEEDED. If the license is not authorized, the system returns the error status LICENSE$_NOLICENSE. ************************************************************************ *************** SYS$RELEASE_LICENSE() Example This example shows a license release system service call for a product licensed with an N-user license. #include descrip #define LMF$_PROD_DATE 4 #define LMF$_PROD_TOKEN 1 typedef struct _quad_word { long int upper_long; long int lower_long; } quad_word; main() { long status; quad_word product_date; short *tokenlen; char prtoken[31]; long int license_context; 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, 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-1988 0:0:0.0"); /* Use SYS$BINTIM to convert the ASCII string representing the the date to an absolute or delta time value. */ status = SYS$BINTIM(&product_date_string, &product_date); if ((status & 1) != 1) exit (status); /* Call the SYS$GRANT_LICENSE system service and store the return status. */ status = SYS$GRANT_LICENSE( &product_name, &product_owner, &license_context, &grant_license_items); /* Test whether the current number of license users in the system is greater than the license units. */ if (status == LICENSE$_EXCEEDED) { /* process the busy condition */ /* if desired */ } else if (!status) return (status); /* otherwise it is authorized, use product */ /* at end of use... */ status = SYS$RELEASE_LICENSE(&license_context); } The system attempts to release the license units when the user finishes using the product. If it is successful, the system returns the success status SS$_NORMAL.