John.Thur_at_frontiercoop.com wrote:
> Mr Monnerat:
> Many thanks to you for your ongoing work in porting curllib to the
as400.
You're welcome. I would also say it would not have been feasible without
the help of the libcurl developer's community. Oh, by the way, the
product is called libcurl (http://curl.haxx.se/libcurl/) ;-)
> Following your "readme" instructions I successfully compiled the
library, and am able to do a curl_easy_perform to request data via http
from a website within an RPGLE Program using h bnddir('CURL/CURL'),
d/copy curl/h,curl.inc
Fine !
> The data appears to be sent to standard out.
This is the normal default behavior.
> I would like to pull the data into the variable which I can use in the
RPG program.
> If you have RPG LE examples of doing this I would appreciate it.
There are no RPG examples available, but plenty of C example programs on
the curl web site:
http://curl.haxx.se/libcurl/c/example.html. I have made an RPG example
specially for you. Please find it in attachment.
> I have tried use easy_recv:
> curl_easy_setopt_ccsid($ch : CURLOPT_CONNECT_ONLY:'1');
> curl_easy_recv($chP:%addr($info):%size($info):$bytes);
> But no data appears to be returned. I added a 3 second sleep before
just it case the data wasn't there yet.
1) If you use curl_easy_setopt_ccsid(), you should specify that CCSID !
2) Option CURLOPT_CONNECT_ONLY requires a long parameter. You should
then use curl_easy_setopt_long($ch: CURLOPT_CONNECT_ONLY: 1);
3) The regular way of passing data to libcurl is via callbacks. This is
illustrated in the attached example program and in
http://curl.haxx.se/libcurl/c/getinmemory.html that you've already found
! I've never used curl_easy_recv() and I don't think it's very much used
in general.
> I have looked at: /docs/examples/getinmemory.c I could create a c
program that could call with RPG to return the information, but am not
sure if the ASCII to EBCDIC conversion would be done.
As you know, OS400 is stuck in the EBCDIC ghetto ! The *_ccsid()
wrappers do the conversion job for procedure parameters and return
values, but not for callbacks. You then have to convert the data
encoding yourself, in the target code of your choice. The attached
example shows a conversion to job's CCSID from ISO-8859-1 (although this
conversion is outside of libcurl's scope). You may inspire your own RPG
code from this example, but I can't take data conversion into account in
my wrappers since nowadays, many data are in UTF-8 and thus prevent me
to make any assumption about the remote encoding. In addition, there are
a lot of UTF-8 characters that cannnot be converted to some EBCDIC code.
Please, subscribe to the curl-library mailing list
(http://cool.haxx.se/mailman/listinfo/curl-library) and post your
libcurl questions there instead of sending them directly to me: I read
this list and would see your posts there, but in addition, there will be
plenty of libcurl gurus that can help you better than I would never be
able to do, and this may help other user's through the list archive. I
don't know if there are some other RPGists there, but this is the main
place for libcurl programming and functionality. Since it may help
others, I cc this answer to this list.
Have a good fun with libcurl !
Regards,
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-12