From: Arne Vajhj [Arne.Vajhoej@gtech.com]
Sent: Thursday, December 09, 1999 3:28 AM
To: Info-VAX@Mvb.Saic.Com
Subject: Re: translate a logical

Jerry Alan Braga wrote:
> Does anyone have the source code 'C' for the system service to translate a
> logical.  I need to enable logging in some of our applications but I cannot
> seem to get the system service call correctly.  I have used lib$ functions
> with success but there is not one for get_logical but there is one for
> set_logical.

1) C RTL getenv
2) VMS RTL LIB$SYS_TRNLOG (LIB$GET_LOGICAL is said to be coming !)
3) system service SYS$TRNLNM

Below are an example of all 3 methods (please add some checks
on return value before putting in production code !).

Arne

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <descrip.h>
#include <lnmdef.h>

long LIB$SYS_TRNLOG();
long SYS$TRNLNM();

short l;
char lnm[257];
char xlt[257];
struct { short buflen,code; long bufadr,retlenadr; } itmlst[2] =
   { { sizeof(xlt), LNM$_STRING, (long)&xlt, (long)&l }, { 0, 0, 0, 0 }
};
$DESCRIPTOR(lnmdes,lnm);
$DESCRIPTOR(xltdes,xlt);
$DESCRIPTOR(tabdes,"LNM$FILE_DEV");

int main(int argc,char *argv[])
{
   strcpy(lnm,"SYS$LOGIN");
   lnmdes.dsc$w_length = strlen(lnm);
   printf("%s\n",getenv(lnm));
   LIB$SYS_TRNLOG(&lnmdes,&l,&xltdes);
   xlt[l] = '\0';
   printf("%s\n",xlt);
   strcpy(xlt,"garbage");
   SYS$TRNLNM(0,&tabdes,&lnmdes,0,itmlst);
   xlt[l] = '\0';
   printf("%s\n",xlt);
}
