[comp.os.vms] using the $trnlnm system service from c

saganich%frodo.DECnet@MGHCCC.HARVARD.EDU ("FRODO::SAGANICH") (01/16/88)

Dear InfoVaxers,
    This is my third try at this so my apologys is it comes thru
more then once.  My mailer is somewhat braindead and keeps coming
back and telling me it doesn't know where to send messages if it can't 
find send my message.  Ow well, here goes nothing.

 
    Its friday and maybe thats why I can't figure this out but maybe 
someone else can help.  I am trying to use the system service sys$trnlnm
to translate a logical name.  However, how to define the struct for the 
itemlst eludes me.  All I want to do is have in my hot little hands a
pointer to a string containing the translated logical.  Can anyone 
help?

    	Thanks

   	Al Saganich, Systems Analyst, Mass General Hosp.
    	Saganich%frodo.decnet@mghccc.harvard.edu


heres what I'm trying to do.

#include <STDIO.h>
#include <SSdef.h>   /* the system reurn codes */
#include <Descrip.h> /* the descriptor definitions */
#include <Llndef.h>  /* the attributes to $trnlnm */

/* translate the give logical name and print the translation */
main()
{
int sys$trnlnm();

$DESCRIPTOR(Log_nam,"EDTINI");
$DESCRIPTOR(Tab_nam,"PROCESS");

sys$trnlnm(NULL,&Tab_nam,$Log_nam,NULL,&itemlst)

printf("%s\n",somestringpointer}
------

mm5l+@ANDREW.CMU.EDU (Matthew Mashyna) (01/20/88)

[An Andrew/BE2 view (ctextview) was included here,
but could not be displayed.]


This is the C code I use to translate logical names. This only works for the 
first logical symbol

defined. There are ways to specify what table to use; you can find it in the 
SYS$ manuals.



------------------------------ Cut Here-----------------------------


struct	descriptor {

	short	len,

		code;

	char	*address;

	long	junk;

	};


trnlnm(log,tran)

char *log,*tran;

{

struct	descriptor lname,trans;

char *p;

unsigned status;

strupr(log);


lname.len=strlen(log);

lname.code=1;

lname.address=log;

lname.junk=0;


trans.len=15;

trans.code=1;

trans.address=tran;

trans.junk=0;


status=LIB$SYS_TRNLOG(&lname,0,&trans,0,0,0);


p=strchr(tran,32);

if(p) *p=0;

}

------------------------------ Cut Here-----------------------------

rrk@byuvax.bitnet (01/20/88)

You may wish to try lib$trnlog (or is it lib$sys_trnlog), which only requires
you to build a VMS descriptor.

sshurr@lucy.wellesley.EDU (Scott) (01/20/88)

>     Its friday and maybe thats why I can't figure this out but maybe 
> someone else can help.  I am trying to use the system service sys$trnlnm
> to translate a logical name.  However, how to define the struct for the 
> itemlst eludes me.  All I want to do is have in my hot little hands a
> pointer to a string containing the translated logical.  Can anyone 
> help?
 
Try the program as follows:

#include stdio
#include ssdef   /* the system reurn codes */
#include descrip /* the descriptor definitions */
#include lnmdef

struct itm
  {
  short buffer_length;
  short item_code;
  long  buffer_address;
  long  r_len_address;
  };

struct itmlist
  {
  struct itm itemname;
  long       terminator;
  };
 
/* translate the give logical name and print the translation */
main()
{
int sys$trnlnm();
 
$DESCRIPTOR(Log_nam,"EDTINI");
$DESCRIPTOR(Tab_nam,"LNM$PROCESS_TABLE");
char somestringpointer[80];
int stringsize;
long status;
struct itmlist itemlst =
  {79, LNM$_STRING, somestringpointer, &stringsize, 0};
 
status = sys$trnlnm(NULL,&Tab_nam,&Log_nam,NULL,&itemlst);
if (status!=SS$_NORMAL)
  exit(status);
somestringpointer[stringsize] = '\0'; 
printf("%s\n",somestringpointer);
}