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



Hi Ian,

> I have created data in a User Space that can get up to 10 Meg. I need to
> transfer this (programatically if possible) into a stream file on the IFS.
> I can easily create/ extend /write data to/ etc the stream file within my
> program, its just the transfer of a large amount of data that I can't get my
> head round.
>
> Obviously field size limitations precludes an easy approach (I think).

If you're using the open/write/close APIs to create your stream file,
you'll note that the write() API takes the following three parameters:

    descriptor = tells write() which open file to write to

       pointer = points to a spot in memory where the data you want
                 written desides

          size = the number of bytes to write from that area of memory.

The QUSPTRUS API retrieves a pointer to a user space. Exactly what the
doctor ordered for the 2nd parameter to write()!

The QUSRUSAT API can retrieve the current size of the user space, which
works for the 3rd parameter. (Though, if you already know how big your
data is, you won't need this API.)

The following program is a trivial example.  (I used IFSIO_H from LIBHTTP,
since I know you have access to HTTPAPI...)

     H DFTACTGRP(*NO)

      /copy libhttp/qrpglesrc,ifsio_h

     D QUSRUSAT        PR                  ExtPgm('QUSRUSAT')
     D   RcvVar                   32767A   options(*varsize)
     D   RcvVarLen                   10I 0 const
     D   Format                       8A   const
     D   UsrSpc                      20A   const
     D   ErrorCode                32767A   options(*varsize)

     D QUSPTRUS        PR                  ExtPgm('QUSPTRUS')
     D   UsrSpc                      20A   CONST
     D   Pointer                       *

     D dsAttr          ds
     D   dsAttr_Rtn                  10I 0
     D   dsAttr_Avl                  10I 0
     D   dsAttr_Size                 10I 0
     D   dsAttr_AE                    1A
     D   dsAttr_Init                  1A
     D   dsAttr_Lib                  10A

     D NullError       ds
     D   BytesProv                   10I 0 inz(0)
     D   BytesAvail                  10I 0 inz(0)

     D fd              s             10I 0
     D p_UsrSpc        s               *

     c                   callp     QUSRUSAT( dsAttr
     c                                     : %size(dsAttr)
     c                                     : 'SPCA0100'
     c                                     : 'MYUSRSPC  QTEMP'
     c                                     : NullError )

     c                   callp     QUSPTRUS( 'MYUSRSPC  QTEMP'
     c                                     : p_UsrSpc )

     c                   eval      fd = open( '/tmp/myStreamFile.dat'
     c                                      : O_WRONLY + O_CREAT + O_TRUNC
     c                                      : 511 )

     c                   if        fd < 0
     c***  OPENING STREAM FILE FAILED, NOTIFY USER HERE
     c                   endif

     c                   callp     write(fd: p_UsrSpc: dsAttr_Size)
     c                   callp     close(fd)

     c                   eval      *inlr = *on

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.