     **
     ** Program summary
     ** ---------------
     **
     ** C library functions:
     **
     **   fopen       Open stream file      Opens or creates the streamfile
     **                                     specified. The access level required
     **                                     is defined by the mode parameter and
     **                                     is followed by an optional keyword
     **                                     parameter allowing you to specify
     **                                     various file attributes.
     **
     **               AS/400 name:          _C_IFS_fopen
     **
     **   fgets       Read stream           Reads characters from current stream
     **                                     position for the number of bytes
     **                                     specified by the second parameter or
     **                                     until new-line character or end-of-
     **                                     stream is encountered. The new-line
     **                                     character (x'25) is included in the
     **                                     retrieved string.
     **
     **               AS/400 name:          _C_IFS_fgets
     **
     **   fputs       Write stream          Appends the string parameter to the
     **                                     current stream position. The actual
     **                                     number of bytes written is returned.
     **
     **               AS/400 name:          _C_IFS_fputs
     **
     **   fclose      Close stream          Closes the stream pointed to by the
     **                                     FILE structure.
     **
     **               AS/400 name:          _C_IFS_fclose
     **
     **   remove      Delete stream file    Deletes the stream file specified.
     **
     **               AS/400 name:          _C_IFS_remove
     **
     **
     **   errno       Get error number      Retrieves the current value of the
     **                                     C runtime error number variable.
     **                                     The errno function simply returns
     **                                     a pointer to a 4-byte integer.
     **
     **   strerror    Map error number      Converts the error number variable
     **                                     to an error message string.
     **
     **
     ** Sequence of events:
     **
     **   1. The output stream file is created   - failure returns a null pointer
     **      with the IBM PC Ascii codepage -
     **      and is subsequentially closed
     **
     **   2. The output stream file is opened    - failure returns a null pointer
     **      for write access with the current
     **      job's codepage (implicit)
     **
     **   3. The first input stream file is      - failure returns a null pointer
     **      opened for read access with the
     **      current job's codepage (implicit)
     **
     **   4. Open failure checked and error
     **      identification performed if
     **      necessary.
     **
     **   5. The input stream file is read       - failure and end-of-stream is
     **      one line at a time until end-         indicated by null pointer
     **      of-stream occurs.
     **
     **   6. Each line read is appended to       - failure indicated by -1
     **      the output stream file.
     **
     **   7. The input stream file is closed     - failure indicated by -1
     **
     **   8. Step 3, 4, 5, 6 & 7 are repeated
     **      for the second input stream file
     **
     **   9. The output stream file is closed    - failure indicated by -1
     **
     **
     ** Compile options:
     **
     **   CRTBNDRPG ...  DBGVIEW(*LIST)
     **
     **
     **-- Control spec:  -----------------------------------------------------**
     H Option( *SrcStmt )  DftActGrp( *No )  BndDir( 'QC2LE' )
     **-- Global variables:  -------------------------------------------------**
     D FILE_i          s               *
     D FILE_o          s               *
     D ErrTxt          s            128a
     D String          s            512a
     D rc              s             10i 0
     **-- Global constants:  -------------------------------------------------**
     D FilNam_1        c                   '/QOpenSys/access001.log'
     D FilNam_2        c                   '/QOpenSys/access002.log'
     D FilNam_o        c                   '/QOpenSys/access00x.log'
     **-- Error identification:  ---------------------------------------------**
     D errno           Pr            10i 0
     **
     D strerror        Pr           128a   Varying
     **-- IFS stream file functions:  ----------------------------------------**
     D fopen           Pr              *   ExtProc( '_C_IFS_fopen' )
     D                                 *   Value  Options( *String )
     D                                 *   Value  Options( *String )
     **
     D fgets           Pr              *   ExtProc( '_C_IFS_fgets' )
     D                                 *   Value
     D                               10i 0 Value
     D                                 *   Value
     **
     D fputs           Pr            10i 0 ExtProc( '_C_IFS_fputs' )
     D                                 *   Value  Options( *String )
     D                                 *   Value
     **
     D fclose          Pr            10i 0 ExtProc( '_C_IFS_fclose' )
     D                                 *   Value
     **
     **-- Mainline:  ---------------------------------------------------------**
     **
     **-- create file, set codepage (pc):
     C                   Eval      FILE_o     =  fopen( %TrimR( FilNam_o )
     C                                                : 'w, codepage=850'
     C                                                )
     **
     C                   Eval      rc         =  fclose( FILE_o )
     **
     **-- open files, implicit conversion to job codepage:
     C                   Eval      FILE_o     =  fopen( %TrimR( FilNam_o )
     C                                                : 'w'
     C                                                )
     **
     C                   Eval      FILE_i     =  fopen( %TrimR( FilNam_1 )
     C                                                : 'r'
     C                                                )
     **
     C                   If        FILE_i     =  *Null
     C                   Eval      ErrTxt     =  %Char( Errno ) + ': ' +
     C                                           Strerror
     C                   Else
     **
     C                   Dow       fgets( %Addr( String )
     C                                  : %Size( String )
     C                                  : FILE_i
     C                                  )    <>  *Null
     **-- copy file 1 to new file...
     C                   Eval      rc         =  fputs( %Str( %Addr( String ))
     C                                                : FILE_o
     C                                                )
     C                   EndDo
     **
     C                   Eval      rc         =  fclose( FILE_i )
     C                   EndIf
     **
     C                   Eval      FILE_i     =  fopen( %TrimR( FilNam_2 )
     C                                                : 'r'
     C                                                )
     **
     C                   If        FILE_i     =  *Null
     C                   Eval      ErrTxt     =  %Char( Errno ) + ': ' +
     C                                           Strerror
     C                   Else
     **
     C                   Dow       fgets( %Addr( String )
     C                                  : %Size( String )
     C                                  : FILE_i
     C                                  )    <>  *Null
     **-- copy file 2 to new file...
     C                   Eval      rc         =  fputs( %Str( %Addr( String ))
     C                                                : FILE_o
     C                                                )
     C                   EndDo
     **
     C                   Eval      rc         =  fclose( FILE_i )
     C                   EndIf
     C                   Eval      rc         =  fclose( FILE_o )
     **
     C                   Eval      *InLr      =  *On
     C                   Return
     **
     **-- Get runtime error number:  -----------------------------------------**
     P Errno           B
     D                 Pi            10i 0
     D sys_errno       Pr              *    ExtProc( '__errno' )
     **
     D Error           s             10i 0  Based( pError )  NoOpt
     **
     C                   Eval      pError     =  sys_errno
     C                   Return    Error
     **
     P Errno           E
     **-- Get runtime error text:  -------------------------------------------**
     P Strerror        B
     D                 Pi           128a    Varying
     D sys_strerror    Pr              *    ExtProc( 'strerror' )
     D                               10i 0  Value
     **
     C                   Return    %Str( sys_strerror( Errno ))
     **
     P Strerror        E
