× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 21/01/2006, at 1:06 PM, qsrvbas@xxxxxxxxxxxx wrote:

Maybe Simon did it correctly in the first place, using Qp0zGetEnv()/Qp0zPutEnv() rather than getenv()/putenv() in which case he ~possibly~ wouldn't have seen the behavior I saw. I recall that Qp0zGetEnv()/Qp0zPutEnv() did ~not~ change as getenv()/putenv(), hence, probably no problem with them.

We were using the putenv/getenv calls because they were being done from C. putenv/getenv are more natural from C than the actual IBM implementation functions--hence being part of stdlib.h.

Note that I said these were mapped to Qp0zGetEnvNoCCSID() and Qp0zPutEnvNoCCSID(). Both the Qp0zGetEnv() and Qp0zPutEnv() require a CCSID value and are an IBM extension to the standard interfaces. These were introduced in 360 (according to the documentation) so were probably part of the original migration from the CPA toolkit to the base OS.

Maybe my previous point wasn't clear enough. According to the C includes there never was a function named putenv() prior to 510. There was a getenv() in QC2UTIL2. The function prototypes exist on 440 but they are mapped to the real functions as follows:

        #pragma map ( putenv, "Qp0zPutEnvNoCCSID" )
        #pragma map ( getenv, "Qp0zGetEnvNoCCSID" )

On 510 (and I presume 520) when TGTRLS is specified for earlier than 510 this remapping also occurs. If no TGTRLS is specified or compiling occurs on 520 or 530 the remapping no longer happens and IBM have provided direct implementations of getenv() and putenv(). I have no idea why they added these new direct implementations--the previous Qp0z variants seem fine.

It comes down to the best protection for backwards/forwards compatibility. If I can track down what APIs were involved, I'll have one more solid data point. If someone with V4Rx can actually look for them, it will help.

I do have 440 on one of my systems and I did check the service programs. The Qp0z variants are exposed from the QP0ZCPA. There is no putenv or getenv exposed in this service program until 510. Further I wrote some code to list the procedure exports from every service program in QSYS on 440 and none of them export putenv(). I did find that QC2UTIL exported getenv() but given what I say above about the remapping this export would not have been called by anything compiled on 440. It appears that getenv() has been available since 230 but putenv was not provided until much later expect as part of the CPA tookit. The only other related exports I found are the Qp0z variants.

So what this means is that if you compiled C code on 440 the precompiler would have remapped the putenv and getenv calls to the correct implementation function. This compiled object would have continued to run on all later releases with no changes. If you compiled C code on 510 or later (and did not specify a previous target release earlier than 510) the program object would invoke putenv() and getenv() functions directly. This object would continue to work on 520 and later releases.

If you tried this from RPG IV on 440 then you could not possibly have been calling putenv() directly because it did not exist--unless you were binding to the old CPA service program and Bruce has already explained where that went. You may have been calling getenv() and binding to QC2UTIL2 and this may have failed to compile at 510 because getenv() is no longer in QC2UTIL2. It would have had to be removed or renamed to avoid duplicate procedure export errors caused by collision with the new getenv() exported from QP0ZCPA.

Perhaps it is this getenv() change you recall?

Now this is a perfect example of the backwards-compatibility IBM is justly famous for: Instead of simply removing getenv() from QC2UTIL2 they renamed it to getenv_a(). This means that any C code that was originally bound to QC2UTIL2 will continue to work due to the fact that procedures are invoked by address (via their ordinal position in the export list). They will actually invoke getenv_a() but will behave exactly as expected.

Any RPG IV programs that were also bound to QC2UTIL2 should behave the same way so again even if this is the change you recall it should not have caused your program to fail to run. It may have caused failure to compile but that is a different issue.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.