#pragma module	LMF "SRH X1.0-000"
#pragma builtins

/*
** COPYRIGHT (c) 1992 BY
** DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS.
** ALL RIGHTS RESERVED.
**
** THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
** ONLY  IN  ACCORDANCE  OF  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
** INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR  ANY  OTHER
** COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
** OTHER PERSON.  NO TITLE TO AND  OWNERSHIP OF THE  SOFTWARE IS  HEREBY
** TRANSFERRED.
**
** THE INFORMATION IN THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT NOTICE
** AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
** CORPORATION.
**
** DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE  OR  RELIABILITY OF ITS
** SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
*/

/*
**++
**  Facility:
**
**	Examples
**
**  Version: V1.0
**
**  Abstract:
**
**	Example of working with the DEC LMF calls
**
**  Author:
**	Steve Hoffman
**
**  Creation Date:  1-Jan-1990
**
**  Modification History:
**--
*/
/*
/* lmf.c
/* this subroutine is used to check for a hardwired product license.
/* If the license is not installed the soubroutine signals the error.
*/
/*
/* The following four definitions allow any product to be checked:
*/
#define	PRODUCT		"MYPROGRAM"
#define	PRODUCER	"FREEWARE"
#define	PROD_VERSION	0x010000
#define PROD_DATE	"1-JAN-1988"

/*
/* Definitions required to get off the ground:  (note the LMF stuff
/* does not yet have a C header file...) */ 
#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 "sys$share:ssdef.h"
#include "sys$share:descrip.h"

/* #define LMF$M_RETURN_FAILURES	    0x01
#define LMF$M_BROADCAST_FAILURES    0x02 */

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

lmf()
    {
    int retstat;
/*
/* the following may eventually be needed for full SYS$GRANT_LICENSE()
/* support.  Right now they're just extra baggage.
/*
/*    int context = 0;
/*    int flags = LMF$M_RETURN_FAILURES | LMF$M_BROADCAST_FAILURES;
*/
    int SYS$GRANT_LICENSE();
    $DESCRIPTOR( product, PRODUCT );
    $DESCRIPTOR( producer, PRODUCER );
    $DESCRIPTOR( prod_date, PROD_DATE );
    int prod_version = PROD_VERSION;
    char bintim[8];
    struct itmlst_3
	{
	short buflen;
	short itmcod;
	int bufadr;
	int bufrla;
	} itmlst[3];

    /*
    /* Fill in the item list required by the call.  Includes the
    /* required final, zero-filled, block.
    */
    itmlst[0].buflen = 8;
    itmlst[0].itmcod = LMF$_PROD_DATE;
    itmlst[0].bufadr = bintim;
    itmlst[0].bufrla = 0;

    itmlst[1].buflen = 4;
    itmlst[1].itmcod = LMF$_PROD_VERSION;
    itmlst[1].bufadr = &prod_version;
    itmlst[1].bufrla = 0;

    itmlst[2].buflen = itmlst[2].itmcod = 0;
    itmlst[2].bufadr = itmlst[2].bufrla = 0;

    /*
    /* convert the time from ASCII to the internal quadword format.
    */
    retstat = SYS$BINTIM( &prod_date, &bintim );
    if ( retstat != SS$_NORMAL )
	LIB$SIGNAL( retstat );

    /*
    /* The LMF signals on errors.
    */
    retstat = SYS$GRANT_LICENSE( &product, &producer, 0, &itmlst );

    return( SS$_NORMAL );
    }

/*
/* Here's what a really bogus main program looks like:
/*
*/

main()
    {
    int lmf();
    lmf();
    return ( SS$_NORMAL );
    }

