bqn-curl/ffi.bqn

107 lines
2.8 KiB
BQN

easyInit,
easyCleanup,
easyReset,
easySetoptStr,
easySetoptPtr,
easySetoptLong,
easyPerform,
easyGetinfoStr,
easyGetinfoLong,
easyGetinfoDouble,
slistAppend,
slistFreeAll,
fopen,
fclose,
curlOptions,
curlInfo
Hex2Num•Import"utils.bqn"
libcurlPath•Import"config.bqn"
CurlFFIlibcurlPath•FFI
curlPtr"*:i8"
curlOption"i32"
curlCode"i32"
easyInitCurlFFI curlPtr"curl_easy_init"
easyCleanupCurlFFI """curl_easy_cleanup"(">"curlPtr)
easyResetCurlFFI """curl_easy_reset"(">"curlPtr)
easySetoptStrCurlFFI curlCode"curl_easy_setopt"curlPtrcurlOption"*u8:c8"
easySetoptPtrCurlFFI curlCode"curl_easy_setopt"curlPtrcurlOption"*:i8"
easySetoptLongCurlFFI curlCode"curl_easy_setopt"curlPtrcurlOption"i32"
easyPerformCurlFFI curlCode"curl_easy_perform"curlPtr
easyGetinfoStrCurlFFI curlCode"curl_easy_getinfo"curlPtrcurlOption"&u8:c8"
easyGetinfoLongCurlFFI curlCode"curl_easy_getinfo"curlPtrcurlOption"&i32"
easyGetinfoDoubleCurlFFI curlCode"curl_easy_getinfo"curlPtrcurlOption"&f64"
slistAppendCurlFFI "*:i8""curl_slist_append""*:i8""*u8:c8"
slistFreeAllCurlFFI """curl_slist_free_all"">*:i8"
fopen@•FFI "*:i8""fopen""*u8:c8""*u8:c8"
fclose@•FFI """fclose"">*:i8"
curlOptions{
strOffset10000
slistOffset10000
ptrOffset10000
# boolean options
verbose41
header42
noprogress43
post47
followlocation52
httpget80
# long integer options
postfieldsize60 # size of the POST input data
timeout78 # timeout in seconds
timeoutms155 # timeout in milliseconds
# string options, null-terminated
urlstrOffset+2
userpwdstrOffset+5 # user:password
useragentstrOffset+18
# pointer options
writedataptrOffset+1 # FILE* in which to write response content
postfieldsptrOffset+15 # pointer to POST input data
headerdataptrOffset+29 # FILE* in which to write response headers
# linked list options
httpHeaderslistOffset+23 # HTTP headers as a list of strings
}
curlInfo{
strOffsetHex2Num"100000"
longOffsetHex2Num"200000"
doubleOffsetHex2Num"300000"
slistOffsetHex2Num"400000"
ptrOffsetHex2Num"400000"
# long integer info
responseCodelongOffset+2
headerSizelongOffset+11 # in bytes
requestSizelongOffset+12 # in bytes
redirectCountlongOffset+20
httpVersionlongOffset+46
# double info
totalTimedoubleOffset+3 # in seconds
nameLookupTimedoubleOffset+4 # in seconds
connectTimedoubleOffset+5 # in seconds
# string info
effectiveUrlstrOffset+1
contentTypestrOffset+18
primaryIPstrOffset+32
httpSchemestrOffset+49
effectiveMethodstrOffset+58
}