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



Re #pragma argument(QtmmSendMail, OS, NOWIDEN), I don't think it's the widening that's the issue here.

I'd mistakenly used my existing prototype for QtmmSendMail as the starting point for a new prototype for QtmsCreateSendEmail because the parameters were roughly similar. But I think the presence or absence of #pragma argument(QtmmSendMail, OS, NOWIDEN) makes a significant difference to the way the parameters are passed and this is why I needed to change things from CONST to VALUE.

The manual says:
"OS indicates that arguments are passed, or received (if the pragma directive is in the same compilation unit as the procedure definition), using the OS-Linkage argument method. Non-address arguments are copied to temporary locations and widened (unless nowiden has been specified), and the address of the copy is passed to the called procedure. Arguments that are addresses or pointers are passed directly to the called procedure."

Isn't this what makes it possible to use CONST with QtmmSendMail but not with QtmsCreateSendEmail? I somehow don't think I'll be the last person to make this mistake...

Pete

"Simon Coulter" <shc@xxxxxxxxxxxxxxxxx> wrote in message news:mailman.2920.1224361686.30674.midrange-l@xxxxxxxxxxxxxxx

On 19/10/2008, at 3:32 AM, Peter Clifford wrote:

This should probably now be on the RPG forum, but just in case anyone is
interested, I managed to get the call to the API from RPG working by
changing my prototype to:

D CrtSndMail PR EXTPROC(*CWIDEN:

You are using 4-byte integers so they are already widened. *CWIDEN should not be needed.

D 'QtmsCreateSendEmail')
D ipRecipients * VALUE

A pointer by VALUE is EXACTLY the same as a variable by REFERENCE so your previous definition should be OK.

D iuRcvCount 10U 0 VALUE

This should be 10I 0. However, if the integers are being passed by VALUE then the API documentation should state that. For C and Unix APIs (so-called industry-standard APIs--don't make me laugh) it is expected that the caller "knows" parameters are passed by value because, of course, that's the only way to do it and certainly the "natural" way for a C weenie to approach things.

Normal OS/400 APIs accept all parameters by reference. Since this API appears to be documented as a normal API it should either be changed to accept parameters by reference or the documentation should be corrected to state passing by VALUE is required.


D ipRcvFormat * VALUE
D iaNote * VALUE
D iaNoteFormat * VALUE
D ipAttachments...
D * VALUE OPTIONS(*NOPASS)
D iuAtcCount 10U 0 VALUE OPTIONS(*NOPASS)
D ipAtcFormat * VALUE OPTIONS(*NOPASS)
D baAPIError OPTIONS(*NOPASS)
D LIKEDS(APIError)

I think the main issue was that I needed to pass the parameters by VALUE.
I'd copid the prototype I use for QtmmSendMail as the starting point for the
prototype for QtmsCreateSendEmail),

When coding prototypes for procedures I find you always have to check the C include definitions just to be sure.

However VALUE doesn't really explain the problem you were experiencing. The error message indicated a problem with the Recipients structure (because the substitution text contained the first 4 bytes of the e-mail address). There is no difference between passing that structure by reference and passing a pointer to that structure by value.

I can understand that VALUE missing from the recipient count field would give an incorrect value therefore the API may have been attempting to process more values than you provided. Perhaps it was simply bad luck that caused the error to appear to be related to the contents of the recipient structure? Random acts of storage?

but looking at the C header files for
these two APIs, the first has

#pragma argument(QtmmSendMail, OS, NOWIDEN)

while the second doesn't.

Shouldn't matter because you are passing wide values anyway.

Is this yet another example of the rot apparent in OS/400? APIs written with the presumption that they will only be called from C. APIs that require PASE to function. Utilities that require PASE to function. Program products that require PASE to function or QSHELL to install and manage. HMC that is Unix. Soon it seems XPF will be nothing more than a thin veneer over a Unix system. Excuse me while I puke.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------





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.