× 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.



> From: Steve Richter
>
> 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.
>
> Am I going too far if I write a CPP routine to retrieve the value
> of errno?
> Is there an ile/rpg way to retrieve errno?
>
> Also, is there a function that can be called that converts the
> errno to text
> form?

Stole most of this code from somebody.  When an error occurs, it's saved in
a special internal location that you can get at via __errno.  In this code,
the procedure Strerror calls __errno, which returns a pointer to an integer,
and then strerror turns that integer into a pointer to a string, and %str
does the rest.


DStrerror         PR           128A   varying

C                   eval      fHandle = open( -parms- )
C                                             S_RW_R_R : CP_ASCII)
C                   if        fHandle = -1
C                   eval      error = Strerror
C                   endif

P Strerror        B
D                 Pi           128a    Varying
D sys_errno       Pr              *    ExtProc( '__errno' )
D sys_strerror    Pr              *    ExtProc( 'strerror' )
D                               10i 0  Value

D Error           s             10i 0  Based( pError )  NoOpt

C                   Eval      pError = sys_errno
C                   Return    %Str( sys_strerror( Error ))

P Strerror        E



Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.