[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which procedure for non-XML document



On Thu, Oct 30, 2008 at 5:23 PM, Sturgeoff, Lorne
<lorne.sturgeoff@xxxxxxxxxxx> wrote:
>
>
>   What is a 'callback'?
>

Callback means one of the parameters you pass to a given procedure,
is a pointer to some other procedure.  This allows the initially
called procedure to call a user written procedure to some work.

In EXAMPLE5:

     c                   eval      rc=http_url_post_raw(
     c                             'https://wwwcie.ups.com/ups.app' +
     c                             '/xml/Track':
     c                              %addr(data): %len(%trimr(data)):
     c                              1: %paddr('INCOMING'))

When you call http_url_post_raw() a procedure pointer to the INCOMING
procedure, %PADDR('INCOMING') is passed in.  INCOMING is considered
the 'callback'.

It's quite a useful technique, one catch if you want to make use of it
yourself is that the interface, ie. number and types of parameters, of
any procedure used as a callback must be the same and match what the
procedure doing the callback was told to expect at compile time.  In
other words, when Scott wrote HTTPAPI, he told http_url_post_raw()* to
call, via the procedure pointer, a procedure:
     D Callback        PR            10I 0 extproc(pePostProc)
     D   fd                          10I 0 value
     D   data                      8192A
     D   size                        10I 0 value


Thus the interface for INCOMING must be defined like so:
     D incoming        PR            10I 0
     D   descriptor                  10I 0 value
     D   data                      8192A   options(*varsize)
     D   datalen                     10I 0 value

*Note: Actually http_url_post_raw() doesn't make the callback itself,
it passes the procedure pointer to another procedure, which passes it
to another procedure, and so on till finally in the SendRaw()
procedure the call back is made..  But it's easier to grasp the
concept if you think of http_url_post_raw() making the call back
itself.

HTH,
Charles
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------