xpanew.3 | xpanew.3 | |||
---|---|---|---|---|
skipping to change at line 71 | skipping to change at line 71 | |||
key value default explanation | key value default explanation | |||
------ -------- -------- ----------- | ------ -------- -------- ----------- | |||
acl true/false true enable access contro l | acl true/false true enable access contro l | |||
freebuf true/false true free buf after callb ack completes | freebuf true/false true free buf after callb ack completes | |||
The call_data should be recast to the XPA struct as shown. In addi‐ | The call_data should be recast to the XPA struct as shown. In addi‐ | |||
tion, client-specific data can be passed to the callback in send_dat a. | tion, client-specific data can be passed to the callback in send_dat a. | |||
The paramlist will be supplied by the client as qualifying parameter s | The paramlist will be supplied by the client as qualifying parameter s | |||
for the callback. There are two ways in which the receive_callback( | for the callback. There are two ways in which the send_callback() r | |||
) | ou‐ | |||
routine can send data back to the client: | tine can send data back to the client: | |||
1. The receive_callback() routine can fill in a buffer and pass back a | 1. The send_callback() routine can fill in a buffer and pass back a | |||
pointer to this buffer. An integer len also is returned to specify t he | pointer to this buffer. An integer len also is returned to specify t he | |||
number of bytes of data in buf. XPA will send this buffer to the | number of bytes of data in buf. XPA will send this buffer to the | |||
client after the callback is complete. | client after the callback is complete. | |||
2. The receive_callback can send data directly to the client by writ | 2. The send_callback can send data directly to the client by writing | |||
ing | to | |||
to the fd pointed by the macro: | the fd pointed by the macro: | |||
xpa_datafd(xpa) | xpa_datafd(xpa) | |||
Note that this fd is of the kind returned by socket() or open(). | Note that this fd is of the kind returned by socket() or open(). | |||
If a buf has been allocated, filled, and returned to XPA, then freeb | If a buf has been allocated by a standard malloc routine, filled, an | |||
uf | d | |||
generally is set so that it will be freed automatically when the cal | returned to XPA, then freebuf generally is set so that the buffer wi | |||
l‐ | ll | |||
back is completed and data has been sent to the client. If a static | be freed automatically when the callback is completed and data has b | |||
buf is returned, freebuf should be false to avoid a system error whe | een | |||
n | sent to the client. If a static buf is returned, freebuf should be | |||
freeing static storage. Note that default value for freebuf implies | set | |||
that the callback will allocate a buffer rather than use static stor | to false to avoid a system error when freeing static storage. Note | |||
‐ | that default value for freebuf implies that the callback will alloca | |||
age. | te | |||
a buffer rather than use static storage. | ||||
On the other hand, if buf is dynamically allocated using a method ot | ||||
her | ||||
than a standard malloc/calloc/realloc routine (e.g. using Perl's mem | ||||
ory | ||||
allocation and garbage collection scheme), then it is necessary to t | ||||
ell | ||||
XPA how to free the allocated buffer. To do this, use the XPASetFree | ||||
() | ||||
routine within your callback: | ||||
void XPASetFree(XPA xpa, void (*myfree)(void *), void *myfree_ptr) | ||||
; | ||||
The first argument is the usual XPA handle. The second argument is t | ||||
he | ||||
special routine to call to free your allocated memory. The third arg | ||||
u‐ | ||||
ment is an optional pointer. If not NULL, the specified free routin | ||||
e | ||||
is called with that pointer as its sole argument. If NULL, the free | ||||
routine is called with the standard buf pointer as its sole argument | ||||
. | ||||
This is useful in cases where there is a mapping between the buffer | ||||
pointer and the actual allocated memory location, and the special ro | ||||
u‐ | ||||
tine is expecting to be passed the former. | ||||
If, while the callback performs its processing, an error occurs that | If, while the callback performs its processing, an error occurs that | |||
should be communicated to the client, then the routine XPAError shou ld | should be communicated to the client, then the routine XPAError shou ld | |||
be called: | be called: | |||
XPAError(XPA xpa, char *s); | XPAError(XPA xpa, char *s); | |||
where s is an arbitrary error message. The returned error message | where s is an arbitrary error message. The returned error message | |||
string will be of the form: | string will be of the form: | |||
skipping to change at line 172 | skipping to change at line 189 | |||
XPAError(XPA xpa, char *s); | XPAError(XPA xpa, char *s); | |||
where s is an arbitrary error message. | where s is an arbitrary error message. | |||
The callback routine should return 0 if no error occurs, or -1 to si g‐ | The callback routine should return 0 if no error occurs, or -1 to si g‐ | |||
nal an error. | nal an error. | |||
SEE ALSO | SEE ALSO | |||
See xpa(n) for a list of XPA help pages | See xpa(n) for a list of XPA help pages | |||
version 2.1.8 November 1, 2007 xpanew (3) | version 2.1.10 September 1, 2009 xpanew (3) | |||
End of changes. 5 change blocks. | ||||
18 lines changed or deleted | 46 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |