#module	GETDVI "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 $GETJPIW call
**
**  Author:
**	Steve Hoffman
**
**  Creation Date:  17-Aug-1993
**
**  Modification History:
**--
*/

#include    jpidef
#include    ssdef
#include    stsdef
#include    descrip
#include    lib$routines
#include    starlet

main()
    {
    unsigned long int retstat;
    unsigned long int rsiz, *rbuf;
    unsigned short int iosb[4];
    struct il3def
	{
	unsigned short int buflen;
	unsigned short int itmcod;
	unsigned char *bufadr;
	unsigned char *bufrla;
	};
    struct il3def jpi_rsiz[] =
	    {
	    4, JPI$_RIGHTS_SIZE, &rsiz, 0,
	    0, 0, 0, 0,
	    };
    struct il3def jpi_rlis[] =
	    {
	    0, JPI$_PROCESS_RIGHTS, 0, 0,
	    0, 0, 0, 0,
	    };

    /*
    **	Go get the size of the rightslist
    */
    retstat = sys$getjpiw( 0, 0, 0,
	jpi_rsiz, iosb, 0, 0, 0 );
    if ( !( $VMS_STATUS_SUCCESS( retstat )) )
	return( retstat );
    if ( !( $VMS_STATUS_SUCCESS( iosb[0] )) )
	return( iosb[0] );

    /*
    **	Add a fudge factor and allocate a buffer for the rightslist
    */
    jpi_rlis[0].buflen = rsiz + (rsiz >> 2);
    rbuf = (void *) calloc( jpi_rlis[0].buflen );
    jpi_rlis[0].bufadr = rbuf;

    /*
    **	Ask sys$getjpiw() to place the process rightslist in rbuf...
    */
    retstat = sys$getjpiw( 0, 0, 0,
	jpi_rlis, iosb, 0, 0, 0 );
    if ( !( $VMS_STATUS_SUCCESS( retstat )) )
	goto main_exit;
    if ( !( $VMS_STATUS_SUCCESS( (retstat = iosb[0]) )) )
	goto main_exit;

    /*
    **	Add the code to perform an $ASCTOID call here -- this gets
    **	the binary value for the specified identifier.
    */

    /*
    **	Add the code to search the rightslist buffer here...  (Each
    **	entry in the buffer is comprised of two adjacent longwords.
    **	The first is the binary value of an identifier.  The second
    **	contains the attributes for that identifier.)
    */

main_exit:
    free( rbuf );
    
    return retstat;
    }
