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.