Hello,
here comes a first try of the patch (unified against HEAD, see
attachment). It adds a single callback to main/rfc1867.c and a function
to register a callback function. The callback looks like this:
void *php_rfc1867_callback(void *tracking, int event, int bytes,
char *param, char *value)
tracking is just a pointer to connect different callback function calls.
The callback function can return a pointer to some internal structure
and this pointer is passed back to the callback function on the next
callback.
The callback function is called on the following events:
MULTIPART_EVENT_START: This event is fired if a multipart upload has
just begun. tracking is NULL, bytes is set to Content-length, param and
value is NULL. A PECL extension can initialize a progress structure if
this event is received and return a pointer to that structure which will
then be passed with all following callbacks.
MULTIPART_EVENT_FORMDATA: This event is fired if a normal form-data
variable was found. bytes is the current progress, param is set to the
form field variable name and value to the field value. A PECL extension
can use this event to intercept an UPLOAD_ID or a session id or
whatever. After the PECL extension has the upload id it can start saving
the file upload progress to a database or a temporary file or whatever.
MULTIPART_EVENT_FILE: This event is fired if a new file upload was
found. bytes is the current progress, param is the name of the file
upload, value is the filename on the client machine. A PECL extension
can use these informations to increase a file counter and to display the
filename of the currently uploaded file to the user.
MULTIPART_EVENT_UPDATE: This event is fired if a file a still being
received. bytes is the current progress. Param and value is NULL. A PECL
extension can use it to just update the upload progress data.
MULTIPART_EVENT_END: This event is fired if the multipart upload is
finished or canceled. bytes is the current progress or 0 if the upload
is complete. param and value is NULL. A PECL extension can use it to
free the structure passed with the tracking pointer and to trigger the
closing of a progress popup window or something like this.
The patch is very similiar to the one of pdoro.from.ro but it has the
advantage that is not "progress meter" specific. It's just a universal
callback which may be useful in other scenarios, too. So there is no
need to process the UPLOAD_ID inside rfc1867.c. With my patch this task
is now the responsibility of the PECL extension.
I don't know the internals of PHP very well. I have not used any of
these TSRMLS macros because I don't understand them. So if these macros
are needed here then tell me.
Even if this patch is not going to make it into PHP I would be glad
about some comments on it.
--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger k@ailis.de to get public key)