              <<< VAXAXP::NOTES$:[NOTES$LIBRARY]VMSNOTES.NOTE;1 >>>
               -< VAX and Alpha VMS - Digital Internal Use Only >-
================================================================================
Note 207.0  SYS$LOOKUP_LICENSE finds PAK that $LICENSE LIST doesn't.  10 replies
GALVIA::DUKE "Ronan"                                157 lines  18-FEB-1997 06:32
--------------------------------------------------------------------------------
Since the Software_licensing notesfiles looks very quiet, I'm cross-posting this 
question here.   I'll delete it if there's a better place to put it...

thanks,
Ronan

        <<< YUPPIE::$1$DIA1:[NOTES$LIBRARY]SOFTWARE_LICENSING.NOTE;54 >>>
                         -< Software Licensing Issues >-
================================================================================
Note 437.0 SYS$LOOKUP_LICENSE finds PAK that $LICENSE LIST doesn't... No replies
GALVIA::DUKE "Ronan"                                145 lines  18-FEB-1997 06:28
--------------------------------------------------------------------------------
Hi,
  A customer of ours is having a problem which seems to be related to the
licenses that are/aren't on their system.   The product checks for the CDA-RT
license and if it doesn't find it it then looks for DW-MOTIF.
  I did a $ LICENSE LIST on my own system and found CDA-RT but no DW-MOTIF.  As
expected, my product worked.   I then deleted the CDA-RT license from the
system and my product continued to work !   I then took the license check code
out of the product source code and created a little test program to check 
whether it would find any of the following licenses on the system:
  CDA-RT
  DW-MOTIF
  Foo
 When I run this on my own system (VAX/VMS V6.1), it finds both CDA-RT and
DW-MOTIF even though neither show up when I do a $LICENSE LIST.
 Thinking that maybe there was some caching going on, I rebooted a test system
(VAX/VMS V7.1) and ran my test program.  Again, it finds the CDA-RT and
DW-MOTIF PAKs even though neither show up on a $ LICENSE LIST.
  Thankfully, in both cases, the PAK for the product Foo is not found.
 Anyone out there can point out the error of my ways (gently :-)  ?
 thanks in advance,
-ronan

----------check_license.c----------------------

/*
**  Include Files
*/
#include <lmfdef.h>
#include <stdio.h>
#include <descrip.h>
#include <stdlib.h>
/*
**  Type Definitions
*/
struct lmf_item {
    short int	 length;
    short int    code;
    void	*address;
    long	*ret_length;
};


/*
**  Static Data Definitions
*/

static char CdaRT_prod_name_str[] = "CDA-RT";
static char DWMotif_prod_name_str[] = "DW-MOTIF";
static char CdaRT_producer_str[] = "DEC";
static char Foo_prod_name_str[] = "Foo";
static short int CdaRT_prod_ver[2] = {1,0};
static short int DWMotif_prod_ver[2] = {0,0};
static char CdaRT_prod_datename_str[] = "28-JAN-1992 0:0:0.0";
static char DWMotif_prod_datename_str[] = "28-JAN-1992 0:0:0.0";


extern unsigned long sys$bintim
    (const struct dsc$descriptor_s *, const void *);

extern unsigned long sys$lookup_license
    (const struct dsc$descriptor_s *, const struct lmf_item *,
     const struct dsc$descriptor_s *, const long *, void *, unsigned long);

extern unsigned long sys$release_license (void *);



main (argc, argv)
int argc;
char *argv[];
    {

    unsigned int    status;
    unsigned long   license_context[4];
    int		    per_user_license;
    long int	    prod_date[2];
    struct lmf_item itm_lst[3];
    long	    flags = LMF$M_RETURN_FAILURES; /* | LMF$M_BROADCAST_FAILURES
*/


#pragma nostandard

    $DESCRIPTOR (CdaRT_prod_name, CdaRT_prod_name_str);
    $DESCRIPTOR (DWMotif_prod_name, DWMotif_prod_name_str);
    $DESCRIPTOR (Foo_prod_name, Foo_prod_name_str);
    $DESCRIPTOR (CdaRT_prod_datename, CdaRT_prod_datename_str);
    $DESCRIPTOR (DWMotif_prod_datename, DWMotif_prod_datename_str);
    $DESCRIPTOR (CdaRT_producer, CdaRT_producer_str);
#pragma standard


    /* Transform the time into binary and set up the item list */
    status = sys$bintim(&CdaRT_prod_datename, prod_date);
    if (!(status & 1))
       exit (-1);

    itm_lst[0].code = LMF$_PROD_DATE;
    itm_lst[0].length = 8;
    itm_lst[0].address = (char *)prod_date;

    itm_lst[1].code = LMF$_PROD_VERSION;
    itm_lst[1].length = 4;
    itm_lst[1].address = (char *)CdaRT_prod_ver;

    itm_lst[2].code = 0;
    itm_lst[2].length = 0;
    itm_lst[2].address = NULL;

    status = sys$lookup_license(&CdaRT_prod_name, itm_lst, &CdaRT_producer,
				&flags, license_context, 0);
    if (status & 1)
       printf ("\nCDA-RT licence found");		 
    else
       printf ("\nCDA-RT licence not found");		 

    status = sys$bintim(&DWMotif_prod_datename, prod_date);
    if (!(status & 1))
       exit (-1);

    itm_lst[0].code = LMF$_PROD_DATE;
    itm_lst[0].length = 8;
    itm_lst[0].address = (char *)prod_date;

    itm_lst[1].code = LMF$_PROD_VERSION;
    itm_lst[1].length = 4;
    itm_lst[1].address = (char *)DWMotif_prod_ver;

    status = sys$lookup_license(&DWMotif_prod_name, itm_lst, &CdaRT_producer,
				&flags, license_context, 0);
    if (status & 1)
       printf ("\nDW-MOTIF licence found");		 
    else
       printf ("\nDW-MOTIF licence not found");		 

    status = sys$lookup_license(&Foo_prod_name, itm_lst, &CdaRT_producer,
				&flags, license_context, 0);
    if (status & 1)
       printf ("\nFoo licence found");		 
    else
       printf ("\nFoo licence not found");		 

}


