[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [open-cobol-list] C$LIST-DIRECTORY requires 'USAGE HANDLE'
From: |
Joakim Jalap |
Subject: |
Re: [open-cobol-list] C$LIST-DIRECTORY requires 'USAGE HANDLE' |
Date: |
Sun, 14 Feb 2016 11:31:05 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.90 (gnu/linux) |
Brian Tiffin <address@hidden> writes:
>>
>> But it seems I hit a little snag while looking in to the
>> C$LIST-DIRECTORY-request. The API for that function requires a variable
>> with USAGE HANDLE, but if I understand correctly GNU Cobol does not yet
>> have that. There is a wishlist item #77 about it.
>
> Equivalent of USAGE POINTER
>
> Or should be. If there is more to the structure than that, still no
> problem, just build an 01 record with a couple of sub-fields. (When
> mapping C struct to COBOL record, adding SYNCHRONIZED (or short as
> SYNCH) the compile will take care that COBOL has the same implicit
> padding between fields as what C would use).
>
I'm sorry, I don't follow. I think we might have misunderstood each
other. What I meant was that any code calling C$LIST-DIRECTORY will have
to do so using a parameter of type HANDLE. This is the example that is
presented on Microfocus' website
(http://supportline.microfocus.com/Documentation/AcucorpProducts/docs/v6_online_doc/gtman4/gt4i38.htm):
WORKING-STORAGE SECTION.
copy "def/acucobol.def".
01 pattern pic x(5) value "*.vbs".
01 directory pic x(20) value "/virusscan".
01 filename pic x(128).
01 mydir usage handle.
PROCEDURE DIVISION.
MAIN.
* Call LISTDIR-OPEN to get a directory handle.
call "C$LIST-DIRECTORY"
using listdir-open, directory, pattern.
move return-code to mydir.
if mydir = 0
stop run
end-if.
* Call LISTDIR-NEXT to get the names of the files.
* Repeat this operation until a filename containing only
* spaces is returned. The filenames are not necessarily
* returned in any particular order. Filenames may be
* sorted on some machines and not on others.
perform with test after until filename = spaces
call "C$LIST-DIRECTORY"
using listdir-next, mydir, filename
end-perform.
* Call LISTDIR-CLOSE to close the directory and deallocate
* memory. Omitting this call will result in memory leaks.
call "C$LIST-DIRECTORY" using listdir-close, mydir.
stop run.
But this wont compile with GNU Cobol right? Because of the "usage
handle".
> Equivalent of USAGE POINTER
Hm, it says in wishlist #77 that a HANDLE should be 4 bytes and aligned
on 4 byte boundaries, so I don't really see how it can be equivalent to a
pointer, at least not in a portable way.
Sorry for the terse mail, I'm trying to learn dvorak, so it took me like
40 minutes to write this :)
Joakim