[OpenVMS, DECC, CRTL] No longer bothered by DECC logicals user settings

SYMPTOM/SOLUTION:
PRODUCT: HP/OpenVMS CRTL All Versions
OP/SYS: OpenVMS IA64 and Alpha All Versions
COMPONENT: DECC features and logicals
SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY SUPPORT: http://vouters.dyndns.org
AUDIENCE: OpenVMS C and C++ developers OpenVMS language support staffs
SYMPTOM(S) or PROBLEM(S): Who hasn't been bothered by an end-user proving you your code is buggy and that you can't reproduce. The explanation often origins itself into DECC logicals settings by the end-user that your C code isn't ready to handle despite all the care you have brought to its coding.
SOLUTION or RESPONSE: At the program startup on an OpenVMS operating system, include the following code in the PROGRAM EXTRACT section. It will reset all DECC features set by outside DECC logicals settings to their default values. Although also tested by the author, such code extract is NOT applicable inside a LIB$INITIALIZE section which is activated before program's main entry code. As a summary, the author has strictly been unable to guess the rules which govern the DECC features when in a LIB$INITIALIZE section. This code extract has been successfully used as code included inside a program. For those willing to find the non found solution within a LIB$INITIALIZE section, they may download ../zip/envvars.zip To use this code: $ cc [/define=(CURRENT, IMPLIED, BUGGY)] set_feature_default $ cc envvars $ link envvars, set_feature_default $ run envvars You simply run envvars with and without DECC$UNIX_LEVEL logical set to 90. The goal is to display the HOME and PATH environment variables with Unix style pathnames whichever the way the DECC$ logicals have been initially set. You can compile set_feature_default with or without the /define or any combination of CURRENT, IMPLIED, BUGGY. As an additional information for your correct understanding, either of the two: $ DEFINE DECC$FILENAME_UNIX_ONLY ENABLE $ link envvars $ run envvars or: $ cc set_feature_default $ link envvars, set_feature_default $ run envvars produce the correct expected result. However this does not address the objective of the code not being influenced by external DECC$ logical settings.
PROGRAM EXTRACT: #ifdef __DECC #include <unixlib.h> #endif #ifdef __DECC { char *decc_feature; int index=0; int value; while (decc_feature = decc$feature_get_name(index)){ value = decc$feature_get_value(index,__FEATURE_MODE_DEFVAL); decc$feature_set_value(index++,1,value); } } /* * Add in after your own DECC features that are needed for a correct runtime * behavior of your code as you designed it. */ #endif
PROGRAM EXTRACT USAGE: Refer to this URL below containing a simple usage example and its correct ouptut despite the setting of the DECC$UNIX_LEVEL logical to 90 when injecting a VMS directory pathname to chdir. Only coded this way, this program is able to indifferently handle a Unix or a VMS pathname as its user input argument. ../tima/OpenVMS-C-chdir-Changing_default_directory_the_Unix_way.html Another more complex code sample also using such a technic is the ls program described at this URL: ../tima/OpenVMS-ls-utility-pre-study-smtp-utility.html Setting DECC$UNIX_LEVEL to 90 is what the author uses as the test of the death for numerous HP or non HP C RTL based VMS codes.
REFERENCE(S): Getting the list of DECC logicals that the VMS/CRTL recognizes: ../tima/OpenVMS-DECC-Getting_the_logicals_DECC_list.html
Did you find this helpful?