curl

Execute curl functions.

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL
X X X X X

Syntax

expr curl(option[,parm[,...]])
int       option
expr      parm

Description

Creates and executes a curl command. The option values are defined in trim.h:
curl_initAllocate the curl environment
curl_freeRelease the curl environment
curl_resetReset curl options
curl_headerReturn header from curl request
curl_execurlSet a URL and execute the request
curl_setoptSet one or more curl options. curl options are specified in pairs: CURLOPT_nnnn,value. See trimcurl.h for a list of CURLOPT_nnnn values. CURLOPT_HTTPHEADER can set multiple comma-delimited header options.
curl_execExecute the curl request
curl_versionReturn the curl version as a string
Data is returned into the clipboard.

Notes

The curl function uses a shared library cexcurl.so. If is not available, then curl() returns an error.

Examples

Execute a curl session to return the contents of a web page:
#include trimcurl.h                         /* contains CURLOPT_xxx values    */
{
list LL;

curl(curl_init);
curl(curl_header);                          /* include header in output       */

#ifdef use_setopt
curl(curl_setopt,CURLOPT_PORT,80,
                 CURLOPT_URL,"www.trifox.com");
curl(curl_exec);
#else
curl(curl_execurl,"www.trifox.com");        /* same as above 2 calls          */
#endif

LL = list_open("clipboard!",9999);          /* output is in the clipboard     */
list_view(LL,0);
}