May 16, 2011
3000 gains new function via migration work
Keven Miller of 3kRanger is doing migration work for a customer, but his labors have delivered a new function for the 3000 namespace of the HP 3000. HP added many useful functions for the server after the Posix introduction of the mid-1990s. But since some programs don't run from the Posix namespace, Miller needed to make a faithful replication of the putenv() for the 3000 namespace. putenv() changes or adds a value to an environment's variables.
You can download Miller's work for use on your 3000 at his website. "I found that the provided LIBC.LIB.SYS (MPE/iX 6.0) does not provide a putenv() function. So to whomever it may be useful, you can get one under MPE Software, in the MPE issues in libc section. Now this can work in the MPE programming environment as well. Besides putenv(), there are also a couple fixes for sleep() and abort()." Miller explains further.
"The CI already provides SETVAR to set and change variables," Miller said "similar to the export command in Posix or other Unix-type shells. putenv() is a library function to give programs access to the environment variables." He cited the ANSI-C specification.
HP's Cathlene McRae noted that putenv() is a Posix function. In Posix, the environment is part of each process. In MPE, the environment is part of the job or session which allows all your processes access to the variables.
ANSI-C describes a getenv() function that retrieves environment variable values and is included in the MPE C library. It uses the HPCIGETVAR intrinsic to do so. However the putenv() function is not part of ANSI-C** and so I suppose that is one reason why it was left out.
A large part of migration projects I'm involved in is testing, to make sure the new environment works the same as on MPE. Therefore I attempt to make my code run on both environments. In this case, some built in runtime debugging code used putenv() which I happened to put back onto MPE for testing. I need to do this in the MPE environment, not Posix, since I'm working with MPE programs for migration.
So I put together a putenv() that uses the HPCIPUTVAR intrinsic; making a good match for the exiting getenv() function.
The definition of getenv is designed to accommodate both implementations that have all in-memory read-only environment strings and those that may have to read an environment string into a static buffer. Hence the pointer returned by the getenv function points to a string not modifiable by the caller. If an attempt is made to change this string, the behavior of future calls to getenv is undefined.
A corresponding putenv function was omitted from the Standard, since its utility outside a multi-process environment is questionable, and since its definition is properly the domain of an operating system standard
Use our search engine to find 20 years
of HP 3000 news and articles
The comments to this entry are closed.