Operating System - OpenVMS
1752777 Members
6152 Online
108789 Solutions
New Discussion юеВ

Re: translate_lnm() example

 
YE LIU_1
Frequent Advisor

translate_lnm() example

Hi, VMS users

I am tweaking some a legacy system and I want to define some logicals as input. I wrote a test_command_count.c to get the value of "TEST_COMMAND_COUNT" which I defined using:

define/job TEST_COMMAND_COUNT 1000

somehow translate_lnm() always fails. Can someone review my code and give some pointers?

Thanks,

YE LIU


#define STR_SS( dsc, carr ) struct dsc$descriptor_s dsc = {sizeof( carr ), DSC$K_DTYPE_T, DSC$K_CLASS_S, carr}
#define SD_SET_P( dscp, strp )\
{\
*(DESC_t *) (dscp) = c$str_sd;\
(dscp)->dsc$a_pointer = strp; (dscp)->dsc$w_length = 65535-_LOCC(0,65535,strp );\
}

int main()
{
int sts;
int test_command_count;
char czLclTestCmdCntName[64];
char czLclTestCmdCntValue[64];

STR_SS (dscLclTestCmdCntName, czLclTestCmdCntName);
STR_SS (dscLclTestCmdCntValue, czLclTestCmdCntValue);

/* translate test_command_count to its value */
sprintf(czLclTestCmdCntName, "%s", "test_command_count");
SD_SET_P(&dscLclTestCmdCntName, czLclTestCmdCntName);
dscLclTestCmdCntValue.dsc$w_length = sizeof(czLclTestCmdCntValue);
sts = translate_lnm(&dscLclTestCmdCntName, LNT_ANY, &dscLclTestCmdCntValue);
if ( sts == SS$_NORMAL )
{
czLclTestCmdCntValue[dscLclTestCmdCntValue.dsc$w_length] = '\0';
} /* if sts == SS$_NORMAL */
else
{
printf("translate_lnm failed\n");
czLclTestCmdCntValue[0] = '\0';
} /* else sts == SS$_NORMAL */

test_command_count=atoi(czLclTestCmdCntValue);
printf("test_command_count=%d", test_command_count);
}
6 REPLIES 6
Ian Miller.
Honored Contributor

Re: translate_lnm() example

The length you are setting in the descriptor is wrong.

Try

dscLclTestCmdCntValue.dsc$w_length = strlen(czLclTestCmdCntValue);

What status value does translate_lnm return?
____________________
Purely Personal Opinion
YE LIU_1
Frequent Advisor

Re: translate_lnm() example

translate_lnm() returns 444.
Hoff
Honored Contributor

Re: translate_lnm() example

Ok, translate_lnm() is not OpenVMS code. It's local code.

As for the error, that's a missing or misspelled logical name, or you might conceivably have some case-sensitivity going on here depending on your specific process settings.

$ x=f$message(444)
$ sho symbol x
X = "%SYSTEM-F-NOLOGNAM, no logical name match"
$

As for the underlying call, there is a library of routines at http://eight-cubed.com, and I and many others have posted up examples of sys$trnlnm and of lib$get_logical.

The site:mvb.saic.com keyword added to a Google search can get you directly into a massive collection of OpenVMS source code at that site.

And given this is C code and presumably fairly recent OpenVMS version, the C call getenv("logicalname") works nicely.

This is not a valid test for success:

if ( sts == SS$_NORMAL )...

That statement tests for exactly one successful status, and misses any other successful conditions that might be returned. It treats other successful returns as failures. Details on the stsdef.h include module and on the low-bit tests and other such are in the OpenVMS FAQ at HL, and elsewhere, and in modules elsewhere.

http://www.hoffmanlabs.com/vmsfaq/

If you look at the stuff I have posted over at the HL web site (other than the FAQ), I'm pretty sure I have this same sequence for a debugging logical name. Tere's a big wad of example C code available for download if you search for newuser or such over at http://64.223.189.234/



YE LIU_1
Frequent Advisor

Re: translate_lnm() example

getenv() works great!!!

Thanks,

YE LIU
YE LIU_1
Frequent Advisor

Re: translate_lnm() example

closed
Hein van den Heuvel
Honored Contributor

Re: translate_lnm() example

Ye,... please consider saying thanks with "points".

That way we will know later which answers helped a little, and which helped a lot.

http://forums11.itrc.hp.com/service/forums/helptips.do?#28

Regards,
Hein (0 points for that!)