curl: slight refactor.

db4
John Benediktsson 2014-07-22 08:40:06 -07:00
parent 917ce9f773
commit 5fd3230b2e
1 changed files with 9 additions and 5 deletions

View File

@ -11,19 +11,23 @@ DESTRUCTOR: curl_easy_cleanup
DESTRUCTOR: fclose DESTRUCTOR: fclose
: check-code ( code -- )
CURLE_OK assert= ;
: curl-init ( -- CURL ) : curl-init ( -- CURL )
curl_easy_init &curl_easy_cleanup ; curl_easy_init &curl_easy_cleanup ;
: curl-set-opt ( CURL key value -- )
curl_easy_setopt check-code ;
: curl-set-url ( CURL url -- ) : curl-set-url ( CURL url -- )
CURLOPT_URL swap present CURLOPT_URL swap present curl-set-opt ;
curl_easy_setopt CURLE_OK assert= ;
: curl-set-file ( CURL path -- ) : curl-set-file ( CURL path -- )
CURLOPT_FILE swap "wb" fopen &fclose CURLOPT_FILE swap "wb" fopen &fclose curl-set-opt ;
curl_easy_setopt CURLE_OK assert= ;
: curl-perform ( CURL -- ) : curl-perform ( CURL -- )
curl_easy_perform CURLE_OK assert= ; curl_easy_perform check-code ;
PRIVATE> PRIVATE>