ARSA Language  2.8
(Encryption, GPU and Web 3.0)
curl Class Reference

#include <curl.h>

Public Member Functions

int curl (const char *cmd)
 Add and execute the given curl command line. More...
 
int thread (const char *cmd)
 Add and execute the given curl command line in another thread. More...
 
void clear ()
 Clear, free and kill thread in all commands. More...
 
int addcmd (const string *cmd)
 
bool freecmd (int id)
 Free all memory, remove command, break and kill thread in this command by id from curl manager. More...
 
bool execmd (int id)
 Execute curl command by id. More...
 
bool execmdthread (int id)
 Execute curl command by id in another thread. More...
 
bool killthread (int id)
 Kill curl thread call. (!!!thread supported only!!!, same curl.break()) More...
 
bool isidok (int id)
 Query this id is ok. Thread safe. More...
 
int isend (int id)
 Query this id is stopped process. Thread safe. More...
 
bool isempty ()
 Query have a command line in curl manager. Thread safe. More...
 
int getcount ()
 Query have number of command line in curl manager. Thread safe. More...
 
int getreturn (int id)
 Get return value from curl. Thread safe. More...
 
int getstate (int id)
 Get state of curl process. Thread safe. More...
 
const char * getresult (int id)
 
int getresultsize (int id)
 Get size of string result from curl execute after. Thread safe. More...
 
const char * getcmd (int id)
 Get a command line in this id. Thread safe. More...
 
int getdownloadpercent (int id)
 Get percent of download file. More...
 
int getuploadpercent (int id)
 Get percent of upload file. More...
 
void break (int id)
 Break the curl command when download or upload to server (!!!thread supported only!!!, same curl.killthread()) More...
 
const char * log (int id)
 Log curl command all details to string buffer. More...
 

Detailed Description

Definition at line 15 of file curl.h.

Constructor & Destructor Documentation

◆ curl()

int curl::curl ( const char *  cmd)

Add and execute the given curl command line.

Parameters
cmdCommand line curl.
Returns
id >= 0 is successed, -1 is failed.
Must call curl.freecmd() for free memory.

Member Function Documentation

◆ addcmd()

int curl::addcmd ( const string cmd)

Add the given curl command line, not call any things.
Execute the command call curl.execmd() or curl.execmdthread()

Parameters
cmdCommand line curl.
Returns
id >= 0 is successed, -1 is failed.
Must call curl.freecmd() for free memory.

◆ break()

void curl::break ( int  id)

Break the curl command when download or upload to server (!!!thread supported only!!!, same curl.killthread())

Parameters
idCommand line id.
See also
curl.killthread()

◆ clear()

void curl::clear ( )

Clear, free and kill thread in all commands.

◆ execmd()

bool curl::execmd ( int  id)

Execute curl command by id.

Parameters
idCommand line id.
Returns
true is successed, false is failed.

◆ execmdthread()

bool curl::execmdthread ( int  id)

Execute curl command by id in another thread.

Parameters
idCommand line id.
Returns
true is successed, false is failed.

◆ freecmd()

bool curl::freecmd ( int  id)

Free all memory, remove command, break and kill thread in this command by id from curl manager.

Parameters
idCommand line id.
Returns
true is successed, false is failed.

◆ getcmd()

const char* curl::getcmd ( int  id)

Get a command line in this id. Thread safe.

Parameters
idCommand line id.
Returns
result command line.

◆ getcount()

int curl::getcount ( )

Query have number of command line in curl manager. Thread safe.

Returns
command line count

◆ getdownloadpercent()

int curl::getdownloadpercent ( int  id)

Get percent of download file.

Parameters
idCommand line id.
Returns
percent (0-100).

◆ getresult()

const char* curl::getresult ( int  id)

Get string result from curl execute after. !!!NOT a thread safe!!! MUST call after isEnd() return true or state is CURL_STATE_END

See also
curl.getState()
curl.isEnd()
Parameters
idCommand line id.
Returns
result as string.

◆ getresultsize()

int curl::getresultsize ( int  id)

Get size of string result from curl execute after. Thread safe.

Parameters
idCommand line id.
Returns
size of string (kilobyte).

◆ getreturn()

int curl::getreturn ( int  id)

Get return value from curl. Thread safe.

Parameters
idCommand line id.
Returns
0 is ok, otherwise is failed
May use get definition of id from https://curl.haxx.se/libcurl/c/libcurl-errors.html

◆ getstate()

int curl::getstate ( int  id)

Get state of curl process. Thread safe.

Parameters
idCommand line id.
Returns
id of process
0 = CURL_STATE_SPAWN
1 = CURL_STATE_STARTED
2 = CURL_STATE_END

◆ getuploadpercent()

int curl::getuploadpercent ( int  id)

Get percent of upload file.

Parameters
idCommand line id.
Returns
percent (0-100).

◆ isempty()

bool curl::isempty ( )

Query have a command line in curl manager. Thread safe.

Returns
true is empty, false have commands.

◆ isend()

int curl::isend ( int  id)

Query this id is stopped process. Thread safe.

Parameters
idCommand line id.
Returns
-1 = invalid id, 2 = end first, 3 = end forever, otherwise is still work in progress.

◆ isidok()

bool curl::isidok ( int  id)

Query this id is ok. Thread safe.

Parameters
idCommand line id.
Returns
true is id ok, false is failed.

◆ killthread()

bool curl::killthread ( int  id)

Kill curl thread call. (!!!thread supported only!!!, same curl.break())

Parameters
idCommand line id.
Returns
true is successed, false is failed.
See also
curl.break()

◆ log()

const char* curl::log ( int  id)

Log curl command all details to string buffer.

Parameters
idCommand line id.
Returns
log result as string.

◆ thread()

int curl::thread ( const char *  cmd)

Add and execute the given curl command line in another thread.

Parameters
cmdCommand line curl.
Returns
id >= 0 is successed, -1 is failed.
Must call curl.freecmd() for free memory.

The documentation for this class was generated from the following file: