cURL / Mailing Lists / curl-library / Single Mail

curl-library

Progress function callback for perl

From: Forrest Cahoon <forrest_at_pconline.com>
Date: Sun, 01 Apr 2001 00:43:20 -0600

Hello, all.

I've made some mods to Curl::easy so that you can now write a progress
function in perl. The code is available for now at
http://www.pconline.com/~forrest/Curl_easy_progress.tar.gz

I made some cosmetic changes to the code which I hope don't offend
Georg Horn: basically I changed Curl::easy::curl_easy_init() into
Curl::easy::init() and so on. I don't want to fight over details like
that, but it looked better to me that way.

After looking at the code some more, I came to the conclusion that
Sander van Zoest is correct in suggesting that the OOifying is best
done in perl, and that the XS code should be as simple as possible a
wrapper around the C functions (something Georg Horn has done an
excellent job at ... getting these callbacks to work is just the last
little bit).

This is very much an experimental change at this point; I'm very happy
I got it to work, but any number of design decisions I made could be
stupid.

Two things are worth noting here:

The perl progress callback expects 4 values, not 5. I decided not to
pass the initial void *clientp, because there's no telling what it is,
and any persistent data needed can be kept around in the perl world.

I also decided that a perl "TRUE" value returned from the progress
function was an "everything is OK" value, and a perl "FALSE" value
would cause a CURLE_ABORTED_BY_CALLBACK, because that seemed more in
keeping with perl idiom. (It's still disturbingly easy to return a
FALSE value by mistake, because if you forget to specify a return
value, it's just value returned by the last thing you called. It
might be better to not allow the callback to cause the transfer to
abort at all.)

To see how to use the callback, look at the test.pl file; I've
implemented one there.

I have more studying to do before I can get the input/output callbacks
working. I may not understand these, but at the moment I'm thinking
the output callback is the key to writing data into a perl variable
instead of to a file.

Forrest Cahoon (from home this time, where he _still_ doesn't speak
for Merrill Corporation)

| Forrest Cahoon | forrest_at_pconline.com |------------------------------|
| 850 21st Ave SE |----------------------| Only unbalanced people |
| Mpls MN 55414-2514 | | can tip the scales... |

_______________________________________________
Curl-library mailing list
Curl-library_at_lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/curl-library
Received on 2001-04-01