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



Neill

The documentation for iconv is where to start when determining whether to use const or value. It is a C-type function, so the docs are different from callable APIs. The docs here say that the first parameter is input-only, the 2nd, 3rd, and 5th are input and output, and the 4th is output only. Any parameter that involves output means it could be changed and is meant to be changed. Therefore, it can't be "constant" - so you can't use CONST on anything that involves output.

I suspect the first parameter is an integer but I don't know for sure - it's called a conversion descriptor and in the docs has a data type of iconv_t, so I'd have to go to the QSYSINC/H source file to find what that is.

Well, it turns out to be a struct - comprising 1 integer and an array of 12 integers. This has to be by VALUE, because C-structs are passed that way.

Hope that helps
Vern

Neill Harper wrote:
Thanks Scott.
I really need to sit down and get the difference between CONST, VALUE and
leaving it blank, sorted in my head.
It doesn't help that I have the c#isum in my head the primitives are passed
by value and object are passed by reference. That clearly doesn't apply in
RPG!!!

To be really honest I was trial and erroring the prototype because of the
receiver too small to receive result problem I was getting, but the 10u 0
for the return field sorted that. I'll go back and revisit the prototype in
the morning and hopefully that will fix it.
All that said the values of iiInpLen and iiOutLen after the call do have the
values i'd expect.
For example on a call converting 1024 bytes of ccsid 285 to ccsid 1200

Before iiInpLen = 1024 and iiOutLen = 1024

After iiInpLen = 512 and iiOutLen = 0

cheers

Neill
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: 03 February 2010 21:42
To: Midrange Systems Technical Discussion
Subject: Re: iconv query

Your iiInpLen and iiOutLen fields should NOT be defined with 'const'. The API changes those fields to reflect the space left in each of the buffers as it translates the data.

On 2/3/2010 3:34 PM, Neill Harper wrote:
I have a call to iconv in my program as follows:



D iconvU PR 10U 0 EXTPROC('iconv')
D iaHandle LIKE(ConvHandle) VALUE
D iaInpBuff *
D iiInpLen 10u 0 const
D iaOutBuff *
D iiOutLen 10u 0 const



wrkResult = iconvU(wrkHandle:wrkFrom:wrkFromDataLength:
wrkTo:wrkToDataLength);



When the call happens if there is not enough room in the output buffer
then
the wrkResult has 0xFFFFFFFF in it. (-1)





And errorno is 3491 - Argument list too long.



The thing is the conversion has worked fine up to that point, I would be
expecting E2BIG?



Also I originally had the wrkResult coded as 10i 0, but this was causing
the
dreaded receiver to small to hold result error.



Does anybody have a any idea whats happening here?



Regards



Neill



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.