/*
 * Module c_trnlog V1.0
 *
 * Keyphrase: Simulate TRNLOG using the new trnlnm function 
 *
 */
#include    "stcdefs.h"
#include    descrip
#include    lnmdef

struct trnlnm_element {
	    short	buffer_len;
	    short	item_code;
	    int		*buffer_addr;
	    int		*rtn_len_addr;
		    };

typedef struct trnlnm_element TRNLNM_ELEMENT,*TRNLNM_ELEMENT_PTR;

typedef struct dsc$descriptor DESCRIPTOR, *DESCRIPTOR_PTR;


int    c_trnlog(logical_name, equivalent_name)
    
	DESCRIPTOR_PTR	    logical_name;	/* Name to be translated */
	DESCRIPTOR_PTR	    equivalent_name;	/* Buffer to receive trans */
{
    TRNLNM_ELEMENT	list[2];
    int			status;
    int			rtn_length;
    char		internal_buffer[255];

    $DESCRIPTOR( table_name, "LNM$FILE_DEV");

    globalvalue int SS$_NORMAL;


    int			str$copy_r();
    int			sys$trnlnm();

    /* Search for the logical name within the LNM$FILE_DEV table */

   
    list[0].item_code = LNM$_STRING;
    list[0].buffer_len = sizeof( internal_buffer );
    list[0].buffer_addr = internal_buffer;
    list[0].rtn_len_addr = &rtn_length;

    list[1].item_code = 0;
    list[1].buffer_len = 0;

    status = sys$trnlnm(0, &table_name, logical_name, 0, list );

    IF /* the translation is successful */
       status EQ SS$_NORMAL
        THEN
            str$copy_r( equivalent_name, &rtn_length, internal_buffer );
    ENDIF

    return status;

}
