|
Hello Steve,
You wrote:
>The return value I am getting from a call to open( ) is -1. My non ibm
>documentation of the C standard says that -1 indicates an error and to look
>to the "errno" global variable for the error code.
That is generally how C and Unix functions behave (but in typical Unix
fashion you can't presume that is how they will work).
>Am I going too far if I write a CPP routine to retrieve the value of errno?
Yes --- way too far, unless you need to access errno from CL.
>Is there an ile/rpg way to retrieve errno?
Yes. See example code below.
>Also, is there a function that can be called that converts the errno to
>text form?
Prototype the strerror() and perror() functions. You can also use DSPMSGD
CPEnnnn where nnnn is the errno value.
Accessing errno from RPG
=========================
Include the following definitions in your code
* Error number returned
D errno S LIKE(int_t) BASED(@errno)
D @errno S *
D getErrno PR * Extproc('__errno')
Somewhere in your initialisation code do:
C EVAL @errno = getErrno
Then whenever you need to test errno you can do:
C IF errno = $EWOULDBLOCK
* do something about it
C ENDIF
presuming that you have defined constants for each of the various errno
values.
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 mailto: shc@xxxxxxxxxxxxxxxxx \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.