From: CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP 5-FEB-1988 16:48 To: ARISIA::EVERHART Subj: Translating logical names from C Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Thu 21 Jan 88 09:00:24-PST Received: from TAMSIGMA.BITNET by CUNYVM.CUNY.EDU ; Thu, 21 Jan 88 12:00:23 EST Date: Thu, 21 Jan 88 09:19 CST From: (Shane Davis) Subject: Translating logical names from C To: info-vax@kl.sri.com X-Original-To: info-vax@kl.sri.com I'm posting this to the entire list as there have been a couple of questions about $TRNLNM as of late... >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 >#include /* the system reurn codes */ >#include /* the descriptor definitions */ >#include /* 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} >------ Al, Here's a way to do it with an RTL routine instead of SYS$TRNLNM. It calls SYS$TRNLNM for you and you don't have to fool with item lists. { static struct dsc$descriptor_s translation_dsc={(maximum length of trans.),DSC$K_DTYPE_T,DSC$K_CLASS_S}; $DESCRIPTOR(lognam_dsc,"LOGNAME"); char *translation[(max. len. trans.)]; static int translen,ssrc; translation_dsc.dsc$a_pointer=translation; ssrc=lib$sys_trnlog(&lognam_dsc,&translen,&translation_dsc,0,0,0); printf("%s\n",translation); } translation_dsc -- descriptor for translation lognam_dsc -- descriptor for logical name to be translated translation -- character string to contain translation translen -- length of translation ssrc -- return code from system service lib$sys_trnlog -- RTL routine which calls $TRNLNM for you If you need to specify the table name (if you're translating something which is only listed in one table you won't need to), the table name can be specified following the "translation_dsc" actual parameter in this particular call. The last two arguments are for the access mode for the logical you're seeking and the mask of tables in which to search for it if they are not the same as LNM$PROCESS_DIRECTORY or you wish to disable searching in one particular table. I've never used these arguments so you'll have to look in your Run-Time Library manual if you need them. You may have a problem with extraneous characters at the end of your translation. In that case, you'd have to do a strncpy(translation,newtrans, translen) to keep only the number of characters returned from the system service by the parameter "translen". The "#include" directives you have in there will be sufficient. Good luck... --Shane Davis Texas A&M Univ. Software Systems Group ******************************************************************************** BITnet THEnet Internet XPMAINT@TAMVENUS THOR::XPMAINT xpmaint@venus.tamu.edu RSD1901@TAMSIGMA ZAC::RSD1901 -------- X222SD@TAMVM1 ------ x222sd@tamvm1.tamu.edu ------ CONS::RSD1901 rsd1901@cons.tamu.edu SPAN: UTSPAN::UTADNX::(THEnet addr) ******************************************************************************** -------