commit ed50dc81dc0ddb5417d5e9a03ad349e3f0a1ea1a Author: Paul W. Date: Tue Sep 16 18:42:43 2025 -0400 init diff --git a/curl.odin b/curl.odin new file mode 100644 index 0000000..cf18a59 --- /dev/null +++ b/curl.odin @@ -0,0 +1,1975 @@ +package libcurl +when (ODIN_OS == .Windows) { + // nmake /f Makefile.vc mode=static DEBUG=no RTLIBCFG=static + foreign import libcurl {"./lib/libcurl_a.lib", "system:Crypt32.lib", "system:Wldap32.lib", "system:Advapi32.lib", "system:Shlwapi.lib", "system:Ws2_32.lib", "system:Normaliz.lib"} +} else do foreign import libcurl "system:curl" + +long :: i32 when (ODIN_OS == .Windows || size_of(rawptr) == 4) else i64 +when (ODIN_OS != .Windows) do socket_t :: i32 + +Handle :: distinct rawptr +Multi_Handle :: distinct rawptr +Sh_Handle :: distinct rawptr + +@(default_calling_convention = "cdecl", link_prefix = "curl_") +foreign libcurl { + // free an easy handle + easy_cleanup :: proc(handle: Handle) --- + // clone an easy handle + easy_duphandle :: proc(curl: Handle) -> Handle --- + // URL encode a string + easy_escape :: proc(curl: Handle, str: cstring, length: i32) -> cstring --- + // extract information from a curl handle + easy_getinfo :: proc(curl: Handle, info: Info, #c_vararg args: ..any) -> Code --- + // get an HTTP header + easy_header :: proc(easy: Handle, name: cstring, index: uint, origin: u32, request: i32, hout: ^^Header) -> Header_Code --- + // create an easy handle + easy_init :: proc() -> Handle --- + // get the next HTTP header + easy_nextheader :: proc(easy: Handle, origin: u32, request: i32, prev: ^Header) -> ^Header --- + // find an easy setopt option by id + easy_option_by_id :: proc(id: ^Option) -> ^Easy_Option --- + // find an easy setopt option by name + easy_option_by_name :: proc(name: cstring) -> ^Easy_Option --- + // iterate over easy setopt options + easy_option_next :: proc(prev: ^Easy_Option) -> ^Easy_Option --- + // pause and unpause a connection + easy_pause :: proc(handle: Handle, bitmask: Pause_State) -> Code --- + // perform a blocking network transfer + easy_perform :: proc(easy_handle: Handle) -> Code --- + // receives raw data on an "easy" connection + easy_recv :: proc(curl: Handle, buffer: rawptr, buflen: uint, n: ^uint) -> Code --- + // reset all options of a libcurl session handle + easy_reset :: proc(handle: Handle) --- + // sends raw data over an "easy" connection + easy_send :: proc(curl: Handle, buffer: rawptr, buflen: uint, n: ^uint) -> Code --- + // set options for a curl easy handle + easy_setopt :: proc(handle: Handle, option: Option, #c_vararg args: ..any) -> Code --- + // return string describing error code + easy_strerror :: proc(errornum: Code) -> cstring --- + // URL decode a string + easy_unescape :: proc(curl: Handle, input: cstring, inlength: i32, outlength: ^i32) -> cstring --- + // keep existing connections alive + easy_upkeep :: proc(handle: Handle) -> Code --- + // URL encode a string + @(deprecated = "Obsolete function. Use easy_escape instead.") + escape :: proc(str: cstring, length: i32) -> cstring --- + // add a section to a multipart form POST + @(deprecated = "This function is deprecated. Use mime_init instead.") + formadd :: proc(firstitem: ^^Http_Post, lastitem: ^^Http_Post, #c_vararg args: ..any) -> Form_Code --- + // free a previously build multipart form post chain + @(deprecated = "This function is deprecated. Use mime_free instead.") + formfree :: proc(form: ^Http_Post) --- + // serialize a multipart form POST chain + // function returns false on success + @(deprecated = "This function is deprecated.") + formget :: proc(form: ^Http_Post, userp: rawptr, append: formget_callback) -> b32 --- + // reclaim memory that has been obtained through a libcurl call + free :: proc(ptr: rawptr) --- + // convert date string to number of seconds + getdate :: proc(datestring: cstring, now: ^i64) -> i64 --- + // return value for environment name + getenv :: proc(name: cstring) -> cstring --- + // global libcurl cleanup + global_cleanup :: proc() --- + // global libcurl initialization + global_init :: proc(flags: Global_Flags) -> Code --- + // global libcurl initialization with memory callbacks + global_init_mem :: proc(flags: Global_Flags, m: malloc_callback, f: free_callback, r: realloc_callback, s: strdup_callback, c: calloc_callback) -> Code --- + // select SSL backend to use + global_sslset :: proc(id: Ssl_Backend, name: cstring, avail: ^^^ssl_backend) -> Ssl_Set_Code --- + // log configuration + global_trace :: proc(config: cstring) -> Code --- + // formatted output conversion + @(disabled = true) + maprintf :: proc() --- + // formatted output conversion + @(disabled = true) + mfprintf :: proc() --- + // append a new empty part to a mime structure + mime_addpart :: proc(mime: ^mime) -> ^Mime_Part --- + // set a mime part's body data from memory + mime_data :: proc(part: ^Mime_Part, data: cstring, datasize: uint) -> Code --- + // set a callback-based data source for a mime part's body + mime_data_cb :: proc(part: ^Mime_Part, datasize: i64, readproc: read_callback, seekproc: seek_callback, freeproc: free_callback, arg: rawptr) -> Code --- + // set a mime part's encoder and content transfer encoding + mime_encoder :: proc(part: ^Mime_Part, encoding: cstring) -> Code --- + // set a mime part's body data from a file contents + mime_filedata :: proc(part: ^Mime_Part, filename: cstring) -> Code --- + // set a mime part's remote filename + mime_filename :: proc(part: ^Mime_Part, filename: cstring) -> Code --- + // free a previously built mime structure + mime_free :: proc(mime: ^mime) --- + // set a mime part's custom headers + mime_headers :: proc(part: ^Mime_Part, headers: ^Slist, take_ownership: i32) -> Code --- + // create a mime handle + mime_init :: proc(easy_handle: Handle) -> ^mime --- + // set a mime part's name + mime_name :: proc(part: ^Mime_Part, name: cstring) -> Code --- + // set sub-parts of a multipart mime part + mime_subparts :: proc(part: ^Mime_Part, subparts: ^mime) -> Code --- + // set a mime part's content type + mime_type :: proc(part: ^Mime_Part, mimetype: cstring) -> Code --- + // formatted output conversion + @(disabled = true) + mprintf :: proc() --- + // formatted output conversion + @(disabled = true) + msnprintf :: proc() --- + // formatted output conversion + @(disabled = true) + msprintf :: proc() --- + // add an easy handle to a multi session + multi_add_handle :: proc(multi_handle: Multi_Handle, easy_handle: Handle) -> Multi_Code --- + // set data to associate with an internal socket + multi_assign :: proc(multi_handle: Multi_Handle, sockfd: socket_t, sockptr: rawptr) -> Multi_Code --- + // close down a multi session + multi_cleanup :: proc() -> Multi_Code --- + // extract file descriptor information from a multi handle + multi_fdset :: proc(multi_handle: Multi_Handle, read_fd_set: ^fd_set, write_fd_set: ^fd_set, exc_fd_set: ^fd_set, max_fd: ^i32) --- + // return all added easy handles + multi_get_handles :: proc(multi_handle: Multi_Handle) -> ^Handle --- + // read multi stack information + multi_info_read :: proc(multi_handle: Multi_Handle, msgs_in_queue: ^i32) -> ^Msg --- + // create a multi handle + multi_init :: proc() -> Multi_Handle --- + // run all transfers until it would block + multi_perform :: proc(multi_handle: Multi_Handle, running_handles: ^i32) -> Multi_Code --- + // poll on all easy handles in a multi handle + multi_poll :: proc(multi_handle: Multi_Handle, extra_fds: []waitfd, extra_nfds: u32, timeout_ms: i32, numfds: ^i32) -> Multi_Code --- + // remove an easy handle from a multi session + multi_remove_handle :: proc(multi_handle: Multi_Handle, curl_handle: Handle) -> Multi_Code --- + // set options for a curl multi handle + multi_setopt :: proc(multi: Multi_Handle, option: Multi_Option, #c_vararg arg: ..any) -> Multi_Code --- + // read/write available data + @(deprecated = "This function is deprecated. Do not use. See multi_socket_action instead.") + multi_socket :: proc(multi_handle: Multi_Handle, sockfd: socket_t, running_handles: ^i32) -> Multi_Code --- + // read/write available data given an action + multi_socket_action :: proc(multi_handle: Multi_Handle, sockfd: socket_t, ev_bitmask: i32, running_handles: ^i32) -> Multi_Code --- + // reads/writes available data for all easy handles + @(deprecated = "This function is deprecated. Do not use. See multi_socket_action instead.") + multi_socket_all :: proc(multi_handle: Multi_Handle, running_handles: ^i32) -> Multi_Code --- + // return string describing error code + multi_strerror :: proc(errornum: Multi_Code) -> cstring --- + // how long to wait for action before proceeding + multi_timeout :: proc(multi_handle: Multi_Handle, timeout: ^long) -> Multi_Code --- + // poll on all easy handles in a multi handle + multi_wait :: proc(multi_handle: Multi_Handle, extra_fds: []waitfd, extra_nfds: u32, timeout_ms: i32, numfds: ^i32) -> Multi_Code --- + // extract file descriptor information from a multi handle + multi_waitfds :: proc(multi: Multi_Handle, ufds: ^waitfd, size: u32, fd_count: ^u32) -> Multi_Code --- + // wake up a sleeping curl_multi_poll call + multi_wakeup :: proc(multi_handle: Multi_Handle) -> Multi_Code --- + // formatted output conversion + @(disabled = true) + mvaprintf :: proc() --- + // formatted output conversion + @(disabled = true) + mvfprintf :: proc() --- + // formatted output conversion + @(disabled = true) + mvprintf :: proc() --- + // formatted output conversion + @(disabled = true) + mvsnprintf :: proc() --- + // formatted output conversion + @(disabled = true) + mvsprintf :: proc() --- + // get a push header by name + pushheader_byname :: proc(h: ^Push_Headers, name: cstring) -> cstring --- + // get a push header by index + pushheader_bynum :: proc(h: ^Push_Headers, num: uint) -> cstring --- + // close a shared object + share_cleanup :: proc(share_handle: Sh_Handle) --- + // create a share object + share_init :: proc() -> Sh_Handle --- + // set options for a shared object + share_setopt :: proc(share: Sh_Handle, option: Sh_Option, #c_vararg arg: ..any) -> Sh_Code --- + // return string describing error code + share_strerror :: proc(errornum: Sh_Code) -> cstring --- + // add a string to an slist + slist_append :: proc(list: ^Slist, str: cstring) -> ^Slist --- + // free an entire curl_slist list + slist_free_all :: proc(list: ^Slist) --- + // compare two strings ignoring case + strequal :: proc(str1: cstring, str2: cstring) -> b32 --- + // compare two strings ignoring case + strnequal :: proc(str1: cstring, str2: cstring, length: uint) -> b32 --- + // URL decode a string + @(deprecated = "Deprecated. Use easy_unescape instead.") + unescape :: proc() --- + // create a URL handle + url :: proc() -> ^Url --- + // free the URL handle + url_cleanup :: proc(handle: ^Url) --- + // duplicate a URL handle + url_dup :: proc(inhandle: ^Url) -> ^Url --- + // extract a part from a URL + url_get :: proc(url: ^Url, part: Url_Part, content: [^]cstring, flags: Url_Flags) -> Url_Code --- + // set a URL part + url_set :: proc(url: ^Url, part: Url_Part, content: cstring, flags: Url_Flags) -> Url_Code --- + // return string describing error code + url_strerror :: proc(errornum: Url_Code) -> cstring --- + // returns the libcurl version string + version :: proc() -> cstring --- + // returns runtime libcurl version info + version_info :: proc(age: Version) -> ^Version_Info_Data --- + // meta data WebSocket information + ws_meta :: proc(curl: Handle) -> ^Ws_Frame --- + // receive WebSocket data + ws_recv :: proc(curl: Handle, buffer: rawptr, buflen: uint, recv: ^uint, meta: ^^Ws_Frame) -> Code --- + // send WebSocket data + ws_send :: proc(curl: Handle, buffer: rawptr, buflen: uint, sent: ^uint, fragsize: i64, flags: u32) -> Code --- +} + +INFO_STRING :: 0x100000 +INFO_LONG :: 0x200000 +INFO_DOUBLE :: 0x300000 +INFO_SLIST :: 0x400000 +INFO_PTR :: 0x400000 +INFO_SOCKET :: 0x500000 +INFO_OFF_T :: 0x600000 +INFO_MASK :: 0x0fffff +INFO_TYPEMASK :: 0xf00000 + +Info :: enum i32 { + NONE, /* first, never use this */ + EFFECTIVE_URL = INFO_STRING + 1, + RESPONSE_CODE = INFO_LONG + 2, + TOTAL_TIME = INFO_DOUBLE + 3, + NAMELOOKUP_TIME = INFO_DOUBLE + 4, + CONNECT_TIME = INFO_DOUBLE + 5, + PRETRANSFER_TIME = INFO_DOUBLE + 6, + // @(deprecated="Use SIZE_UPLOAD_T") + // SIZE_UPLOAD = INFO_DOUBLE + 7, + SIZE_UPLOAD_T = INFO_OFF_T + 7, + // @(deprecated="Use SIZE_DOWNLOAD_T") + // SIZE_DOWNLOAD= INFO_DOUBLE + 8, + SIZE_DOWNLOAD_T = INFO_OFF_T + 8, + // @(deprecated="Use SPEED_DOWNLOAD_T") + // SPEED_DOWNLOAD = INFO_DOUBLE + 9, + SPEED_DOWNLOAD_T = INFO_OFF_T + 9, + // @(deprecated="Use SPEED_UPLOAD_T") + SPEED_UPLOAD = INFO_DOUBLE + 10, + SPEED_UPLOAD_T = INFO_OFF_T + 10, + HEADER_SIZE = INFO_LONG + 11, + REQUEST_SIZE = INFO_LONG + 12, + SSL_VERIFYRESULT = INFO_LONG + 13, + FILETIME = INFO_LONG + 14, + FILETIME_T = INFO_OFF_T + 14, + // @(deprecated= "Use CONTENT_LENGTH_DOWNLOAD_T") + // CONTENT_LENGTH_DOWNLOAD = INFO_DOUBLE + 15, + CONTENT_LENGTH_DOWNLOAD_T = INFO_OFF_T + 15, + // @(deprecated="Use CONTENT_LENGTH_UPLOAD_T") + // CONTENT_LENGTH_UPLOAD = INFO_DOUBLE + 16, + CONTENT_LENGTH_UPLOAD_T = INFO_OFF_T + 16, + STARTTRANSFER_TIME = INFO_DOUBLE + 17, + CONTENT_TYPE = INFO_STRING + 18, + REDIRECT_TIME = INFO_DOUBLE + 19, + REDIRECT_COUNT = INFO_LONG + 20, + PRIVATE = INFO_STRING + 21, + HTTP_CONNECTCODE = INFO_LONG + 22, + HTTPAUTH_AVAIL = INFO_LONG + 23, + PROXYAUTH_AVAIL = INFO_LONG + 24, + OS_ERRNO = INFO_LONG + 25, + NUM_CONNECTS = INFO_LONG + 26, + SSL_ENGINES = INFO_SLIST + 27, + COOKIELIST = INFO_SLIST + 28, + // @(deprecated="Use ACTIVESOCKET") + // LASTSOCKET = INFO_LONG + 29, + FTP_ENTRY_PATH = INFO_STRING + 30, + REDIRECT_URL = INFO_STRING + 31, + PRIMARY_IP = INFO_STRING + 32, + APPCONNECT_TIME = INFO_DOUBLE + 33, + CERTINFO = INFO_PTR + 34, + CONDITION_UNMET = INFO_LONG + 35, + RTSP_SESSION_ID = INFO_STRING + 36, + RTSP_CLIENT_CSEQ = INFO_LONG + 37, + RTSP_SERVER_CSEQ = INFO_LONG + 38, + RTSP_CSEQ_RECV = INFO_LONG + 39, + PRIMARY_PORT = INFO_LONG + 40, + LOCAL_IP = INFO_STRING + 41, + LOCAL_PORT = INFO_LONG + 42, + // @(deprecated="Use TLS_SSL_PTR") + // TLS_SESSION = PTR + 43, + ACTIVESOCKET = INFO_SOCKET + 44, + TLS_SSL_PTR = INFO_PTR + 45, + HTTP_VERSION = INFO_LONG + 46, + PROXY_SSL_VERIFYRESULT = INFO_LONG + 47, + // @(deprecated="Use SCHEME") + // PROTOCOL = INFO_LONG + 48, + SCHEME = INFO_STRING + 49, + TOTAL_TIME_T = INFO_OFF_T + 50, + NAMELOOKUP_TIME_T = INFO_OFF_T + 51, + CONNECT_TIME_T = INFO_OFF_T + 52, + PRETRANSFER_TIME_T = INFO_OFF_T + 53, + STARTTRANSFER_TIME_T = INFO_OFF_T + 54, + REDIRECT_TIME_T = INFO_OFF_T + 55, + APPCONNECT_TIME_T = INFO_OFF_T + 56, + RETRY_AFTER = INFO_OFF_T + 57, + EFFECTIVE_METHOD = INFO_STRING + 58, + PROXY_ERROR = INFO_LONG + 59, + REFERER = INFO_STRING + 60, + CAINFO = INFO_STRING + 61, + CAPATH = INFO_STRING + 62, + XFER_ID = INFO_OFF_T + 63, + CONN_ID = INFO_OFF_T + 64, + QUEUE_TIME_T = INFO_OFF_T + 65, + USED_PROXY = INFO_LONG + 66, + POSTTRANSFER_TIME_T = INFO_OFF_T + 67, +} + +Header :: struct {} +Header_Code :: enum i32 { + OK, + BADINDEX, /* header exists but not with this index */ + MISSING, /* no such header exists */ + NOHEADERS, /* no headers at all exist (yet) */ + NOREQUEST, /* no request with this number was used */ + OUT_OF_MEMORY, /* out of memory while processing */ + BAD_ARGUMENT, /* a function argument was not okay */ + NOT_BUILT_IN, /* if API was disabled in the build */ +} + +Easy_Option :: struct {} + +OPTTYPE_LONG :: 0 +OPTTYPE_OBJECTPOINT :: 10000 +OPTTYPE_FUNCTIONPOINT :: 20000 +OPTTYPE_OFF_T :: 30000 +OPTTYPE_BLOB :: 40000 +/* 'char *' argument to a string with a trailing zero */ +OPTTYPE_STRINGPOINT :: OPTTYPE_OBJECTPOINT +/* 'struct curl_slist *' argument */ +OPTTYPE_SLISTPOINT :: OPTTYPE_OBJECTPOINT +/* 'void *' argument passed untouched to callback */ +OPTTYPE_CBPOINT :: OPTTYPE_OBJECTPOINT +/* 'long' argument with a set of values/bitmask */ +OPTTYPE_VALUES :: OPTTYPE_LONG + +Option :: enum i32 { + /* This is the FILE * or void * the regular output should be written to. */ + WRITEDATA = OPTTYPE_CBPOINT + 1, + + /* The full URL to get/put */ + URL = OPTTYPE_STRINGPOINT + 2, + + /* Port number to connect to, if other than default. */ + PORT = OPTTYPE_LONG + 3, + + /* Name of proxy to use. */ + PROXY = OPTTYPE_STRINGPOINT + 4, + + /* "user:password;options" to use when fetching. */ + USERPWD = OPTTYPE_STRINGPOINT + 5, + + /* "user:password" to use with proxy. */ + PROXYUSERPWD = OPTTYPE_STRINGPOINT + 6, + + /* Range to get, specified as an ASCII string. */ + RANGE = OPTTYPE_STRINGPOINT + 7, + + /* not used */ + + /* Specified file stream to upload from (use as input): */ + READDATA = OPTTYPE_CBPOINT + 9, + + /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE + * bytes big. */ + ERRORBUFFER = OPTTYPE_OBJECTPOINT + 10, + + /* Function that will be called to store the output (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + WRITEFUNCTION = OPTTYPE_FUNCTIONPOINT + 11, + + /* Function that will be called to read the input (instead of fread). The + * parameters will use fread() syntax, make sure to follow them. */ + READFUNCTION = OPTTYPE_FUNCTIONPOINT + 12, + + /* Time-out the read operation after this amount of seconds */ + TIMEOUT = OPTTYPE_LONG + 13, + + /* If READDATA is used, this can be used to inform libcurl about + * how large the file being sent really is. That allows better error + * checking and better verifies that the upload was successful. -1 means + * unknown size. + * + * For large file support, there is also a _LARGE version of the key + * which takes an off_t type, allowing platforms with larger off_t + * sizes to handle larger files. See below for INFILESIZE_LARGE. + */ + INFILESIZE = OPTTYPE_LONG + 14, + + /* POST static input fields. */ + POSTFIELDS = OPTTYPE_OBJECTPOINT + 15, + + /* Set the referrer page (needed by some CGIs) */ + REFERER = OPTTYPE_STRINGPOINT + 16, + + /* Set the FTP PORT string (interface name, named or numerical IP address) + Use i.e '-' to use default address. */ + FTPPORT = OPTTYPE_STRINGPOINT + 17, + + /* Set the User-Agent string (examined by some CGIs) */ + USERAGENT = OPTTYPE_STRINGPOINT + 18, + + /* If the download receives less than "low speed limit" bytes/second + * during "low speed time" seconds, the operations is aborted. + * You could i.e if you have a pretty high speed connection, abort if + * it is less than 2000 bytes/sec during 20 seconds. + */ + + /* Set the "low speed limit" */ + LOW_SPEED_LIMIT = OPTTYPE_LONG + 19, + + /* Set the "low speed time" */ + LOW_SPEED_TIME = OPTTYPE_LONG + 20, + + /* Set the continuation offset. + * + * Note there is also a _LARGE version of this key which uses + * off_t types, allowing for large file offsets on platforms which + * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. + */ + RESUME_FROM = OPTTYPE_LONG + 21, + + /* Set cookie in request: */ + COOKIE = OPTTYPE_STRINGPOINT + 22, + + /* This points to a linked list of headers, struct curl_slist kind. This + list is also used for RTSP (in spite of its name) */ + HTTPHEADER = OPTTYPE_SLISTPOINT + 23, + + /* This points to a linked list of post entries, struct curl_httppost */ + // @(deprecated="Use MIMEPOST") + // HTTPPOST = OPTTYPE_OBJECTPOINT + 24, + + /* name of the file keeping your private SSL-certificate */ + SSLCERT = OPTTYPE_STRINGPOINT + 25, + + /* password for the SSL or SSH private key */ + KEYPASSWD = OPTTYPE_STRINGPOINT + 26, + + /* send TYPE parameter? */ + CRLF = OPTTYPE_LONG + 27, + + /* send linked-list of QUOTE commands */ + QUOTE = OPTTYPE_SLISTPOINT + 28, + + /* send FILE * or void * to store headers to, if you use a callback it + is simply passed to the callback unmodified */ + HEADERDATA = OPTTYPE_CBPOINT + 29, + + /* point to a file to read the initial cookies from, also enables + "cookie awareness" */ + COOKIEFILE = OPTTYPE_STRINGPOINT + 31, + + /* What version to specifically try to use. + See CURL_SSLVERSION defines below. */ + SSLVERSION = OPTTYPE_VALUES + 32, + + /* What kind of HTTP time condition to use, see defines */ + TIMECONDITION = OPTTYPE_VALUES + 33, + + /* Time to use with the above condition. Specified in number of seconds + since 1 Jan 1970 */ + TIMEVALUE = OPTTYPE_LONG + 34, + + /* 35 = OBSOLETE */ + + /* Custom request, for customizing the get command like + HTTP: DELETE, TRACE and others + FTP: to use a different list command + */ + CUSTOMREQUEST = OPTTYPE_STRINGPOINT + 36, + + /* FILE handle to use instead of stderr */ + STDERR = OPTTYPE_OBJECTPOINT + 37, + + /* 38 is not used */ + + /* send linked-list of post-transfer QUOTE commands */ + POSTQUOTE = OPTTYPE_SLISTPOINT + 39, + + /* 40 is not used */ + + /* talk a lot */ + VERBOSE = OPTTYPE_LONG + 41, + + /* throw the header out too */ + HEADER = OPTTYPE_LONG + 42, + + /* shut off the progress meter */ + NOPROGRESS = OPTTYPE_LONG + 43, + + /* use HEAD to get http document */ + NOBODY = OPTTYPE_LONG + 44, + + /* no output on http error codes >= 400 */ + FAILONERROR = OPTTYPE_LONG + 45, + + /* this is an upload */ + UPLOAD = OPTTYPE_LONG + 46, + + /* HTTP POST method */ + POST = OPTTYPE_LONG + 47, + + /* bare names when listing directories */ + DIRLISTONLY = OPTTYPE_LONG + 48, + + /* Append instead of overwrite on upload! */ + APPEND = OPTTYPE_LONG + 50, + + /* Specify whether to read the user+password from the .netrc or the URL. + * This must be one of the CURL_NETRC_* enums below. */ + NETRC = OPTTYPE_VALUES + 51, + + /* use Location: Luke! */ + FOLLOWLOCATION = OPTTYPE_LONG + 52, + + /* transfer data in text/ASCII format */ + TRANSFERTEXT = OPTTYPE_LONG + 53, + + /* HTTP PUT */ + // @(deprecated="Use UPLOAD") + // PUT = OPTTYPE_LONG + 54, + + /* 55 = OBSOLETE */ + + /* DEPRECATED + * Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_progress_callback + * prototype defines. */ + // @(deprecated="Use XFERINFOFUNCTION") + // PROGRESSFUNCTION = OPTTYPE_FUNCTIONPOINT + 56, + + /* Data passed to the PROGRESSFUNCTION and XFERINFOFUNCTION + callbacks */ + XFERINFODATA = OPTTYPE_CBPOINT + 57, + PROGRESSDATA = XFERINFODATA, + + /* We want the referrer field set automatically when following locations */ + AUTOREFERER = OPTTYPE_LONG + 58, + + /* Port of the proxy, can be set in the proxy string as well with: + "[host]:[port]" */ + PROXYPORT = OPTTYPE_LONG + 59, + + /* size of the POST input data, if strlen() is not good to use */ + POSTFIELDSIZE = OPTTYPE_LONG + 60, + + /* tunnel non-http operations through an HTTP proxy */ + HTTPPROXYTUNNEL = OPTTYPE_LONG + 61, + + /* Set the interface string to use as outgoing network interface */ + INTERFACE = OPTTYPE_STRINGPOINT + 62, + + /* Set the krb4/5 security level, this also enables krb4/5 awareness. This + * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string + * is set but does not match one of these, 'private' will be used. */ + KRBLEVEL = OPTTYPE_STRINGPOINT + 63, + + /* Set if we should verify the peer in ssl handshake, set 1 to verify. */ + SSL_VERIFYPEER = OPTTYPE_LONG + 64, + + /* The CApath or CAfile used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CAINFO = OPTTYPE_STRINGPOINT + 65, + + /* 66 = OBSOLETE */ + /* 67 = OBSOLETE */ + + /* Maximum number of http redirects to follow */ + MAXREDIRS = OPTTYPE_LONG + 68, + + /* Pass a long set to 1 to get the date of the requested document (if + possible)! Pass a zero to shut it off. */ + FILETIME = OPTTYPE_LONG + 69, + + /* This points to a linked list of telnet options */ + TELNETOPTIONS = OPTTYPE_SLISTPOINT + 70, + + /* Max amount of cached alive connections */ + MAXCONNECTS = OPTTYPE_LONG + 71, + + /* 72 = OBSOLETE */ + /* 73 = OBSOLETE */ + + /* Set to explicitly use a new connection for the upcoming transfer. + Do not use this unless you are absolutely sure of this, as it makes the + operation slower and is less friendly for the network. */ + FRESH_CONNECT = OPTTYPE_LONG + 74, + + /* Set to explicitly forbid the upcoming transfer's connection to be reused + when done. Do not use this unless you are absolutely sure of this, as it + makes the operation slower and is less friendly for the network. */ + FORBID_REUSE = OPTTYPE_LONG + 75, + + /* Set to a filename that contains random data for libcurl to use to + seed the random engine when doing SSL connects. */ + // @(deprecated="Serves no purpose anymore") + // RANDOM_FILE = OPTTYPE_STRINGPOINT + 76, + + /* Set to the Entropy Gathering Daemon socket pathname */ + // @(deprecated="Serves no purpose anymore") + // EGDSOCKET = OPTTYPE_STRINGPOINT + 77, + + /* Time-out connect operations after this amount of seconds, if connects are + OK within this time, then fine... This only aborts the connect phase. */ + CONNECTTIMEOUT = OPTTYPE_LONG + 78, + + /* Function that will be called to store headers (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + HEADERFUNCTION = OPTTYPE_FUNCTIONPOINT + 79, + + /* Set this to force the HTTP request to get back to GET. Only really usable + if POST, PUT or a custom request have been used first. + */ + HTTPGET = OPTTYPE_LONG + 80, + + /* Set if we should verify the Common name from the peer certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches the + * provided hostname. */ + SSL_VERIFYHOST = OPTTYPE_LONG + 81, + + /* Specify which filename to write all known cookies in after completed + operation. Set filename to "-" (dash) to make it go to stdout. */ + COOKIEJAR = OPTTYPE_STRINGPOINT + 82, + + /* Specify which TLS 1.2 (1.1, 1.0) ciphers to use */ + SSL_CIPHER_LIST = OPTTYPE_STRINGPOINT + 83, + + /* Specify which HTTP version to use! This must be set to one of the + CURL_HTTP_VERSION* enums set below. */ + HTTP_VERSION = OPTTYPE_VALUES + 84, + + /* Specifically switch on or off the FTP engine's use of the EPSV command. By + default, that one will always be attempted before the more traditional + PASV command. */ + FTP_USE_EPSV = OPTTYPE_LONG + 85, + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ + SSLCERTTYPE = OPTTYPE_STRINGPOINT + 86, + + /* name of the file keeping your private SSL-key */ + SSLKEY = OPTTYPE_STRINGPOINT + 87, + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ + SSLKEYTYPE = OPTTYPE_STRINGPOINT + 88, + + /* crypto engine for the SSL-sub system */ + SSLENGINE = OPTTYPE_STRINGPOINT + 89, + + /* set the crypto engine for the SSL-sub system as default + the param has no meaning... + */ + SSLENGINE_DEFAULT = OPTTYPE_LONG + 90, + + /* Non-zero value means to use the global dns cache */ + /* DEPRECATED, do not use! */ + // @(deprecated="Use SHARE") + // DNS_USE_GLOBAL_CACHE = OPTTYPE_LONG + 91, + + /* DNS cache timeout */ + DNS_CACHE_TIMEOUT = OPTTYPE_LONG + 92, + + /* send linked-list of pre-transfer QUOTE commands */ + PREQUOTE = OPTTYPE_SLISTPOINT + 93, + + /* set the debug function */ + DEBUGFUNCTION = OPTTYPE_FUNCTIONPOINT + 94, + + /* set the data for the debug function */ + DEBUGDATA = OPTTYPE_CBPOINT + 95, + + /* mark this as start of a cookie session */ + COOKIESESSION = OPTTYPE_LONG + 96, + + /* The CApath directory used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CAPATH = OPTTYPE_STRINGPOINT + 97, + + /* Instruct libcurl to use a smaller receive buffer */ + BUFFERSIZE = OPTTYPE_LONG + 98, + + /* Instruct libcurl to not use any signal/alarm handlers, even when using + timeouts. This option is useful for multi-threaded applications. + See libcurl-the-guide for more background information. */ + NOSIGNAL = OPTTYPE_LONG + 99, + + /* Provide a CURLShare for mutexing non-ts data */ + SHARE = OPTTYPE_OBJECTPOINT + 100, + + /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), + CURLPROXY_HTTPS, CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and + CURLPROXY_SOCKS5. */ + PROXYTYPE = OPTTYPE_VALUES + 101, + + /* Set the Accept-Encoding string. Use this to tell a server you would like + the response to be compressed. Before 7.21.6, this was known as + ENCODING */ + ACCEPT_ENCODING = OPTTYPE_STRINGPOINT + 102, + + /* Set pointer to private data */ + PRIVATE = OPTTYPE_OBJECTPOINT + 103, + + /* Set aliases for HTTP 200 in the HTTP Response header */ + HTTP200ALIASES = OPTTYPE_SLISTPOINT + 104, + + /* Continue to send authentication (user+password) when following locations, + even when hostname changed. This can potentially send off the name + and password to whatever host the server decides. */ + UNRESTRICTED_AUTH = OPTTYPE_LONG + 105, + + /* Specifically switch on or off the FTP engine's use of the EPRT command ( + it also disables the LPRT attempt). By default, those ones will always be + attempted before the good old traditional PORT command. */ + FTP_USE_EPRT = OPTTYPE_LONG + 106, + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with USERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + HTTPAUTH = OPTTYPE_VALUES + 107, + + /* Set the ssl context callback function, currently only for OpenSSL or + wolfSSL ssl_ctx, or mbedTLS mbedtls_ssl_config in the second argument. + The function must match the curl_ssl_ctx_callback prototype. */ + SSL_CTX_FUNCTION = OPTTYPE_FUNCTIONPOINT + 108, + + /* Set the userdata for the ssl context callback function's third + argument */ + SSL_CTX_DATA = OPTTYPE_CBPOINT + 109, + + /* FTP Option that causes missing dirs to be created on the remote server. + In 7.19.4 we introduced the convenience enums for this option using the + CURLFTP_CREATE_DIR prefix. + */ + FTP_CREATE_MISSING_DIRS = OPTTYPE_LONG + 110, + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with PROXYUSERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + PROXYAUTH = OPTTYPE_VALUES + 111, + + /* Option that changes the timeout, in seconds, associated with getting a + response. This is different from transfer timeout time and essentially + places a demand on the server to acknowledge commands in a timely + manner. For FTP, SMTP, IMAP and POP3. */ + SERVER_RESPONSE_TIMEOUT = OPTTYPE_LONG + 112, + + /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to + tell libcurl to use those IP versions only. This only has effect on + systems with support for more than one, i.e IPv4 _and_ IPv6. */ + IPRESOLVE = OPTTYPE_VALUES + 113, + + /* Set this option to limit the size of a file that will be downloaded from + an HTTP or FTP server. + + Note there is also _LARGE version which adds large file support for + platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */ + MAXFILESIZE = OPTTYPE_LONG + 114, + + /* See the comment for INFILESIZE above, but in short, specifies + * the size of the file being uploaded. -1 means unknown. + */ + INFILESIZE_LARGE = OPTTYPE_OFF_T + 115, + + /* Sets the continuation offset. There is also a OPTTYPE_LONG version + * of this; look above for RESUME_FROM. + */ + RESUME_FROM_LARGE = OPTTYPE_OFF_T + 116, + + /* Sets the maximum size of data that will be downloaded from + * an HTTP or FTP server. See MAXFILESIZE above for the LONG version. + */ + MAXFILESIZE_LARGE = OPTTYPE_OFF_T + 117, + + /* Set this option to the filename of your .netrc file you want libcurl + to parse (using the NETRC option). If not set, libcurl will do + a poor attempt to find the user's home directory and check for a .netrc + file in there. */ + NETRC_FILE = OPTTYPE_STRINGPOINT + 118, + + /* Enable SSL/TLS for FTP, pick one of: + CURLUSESSL_TRY - try using SSL, proceed anyway otherwise + CURLUSESSL_CONTROL - SSL for the control connection or fail + CURLUSESSL_ALL - SSL for all communication or fail + */ + USE_SSL = OPTTYPE_VALUES + 119, + + /* The _LARGE version of the standard POSTFIELDSIZE option */ + POSTFIELDSIZE_LARGE = OPTTYPE_OFF_T + 120, + + /* Enable/disable the TCP Nagle algorithm */ + TCP_NODELAY = OPTTYPE_LONG + 121, + + /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 123 OBSOLETE. Gone in 7.16.0 */ + /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 127 OBSOLETE. Gone in 7.16.0 */ + /* 128 OBSOLETE. Gone in 7.16.0 */ + + /* When FTP over SSL/TLS is selected (with USE_SSL), this option + can be used to change libcurl's default action which is to first try + "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK + response has been received. + + Available parameters are: + CURLFTPAUTH_DEFAULT - let libcurl decide + CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS + CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL + */ + FTPSSLAUTH = OPTTYPE_VALUES + 129, + + // @(deprecated="Use SEEKFUNCTION") + // IOCTLFUNCTION = OPTTYPE_FUNCTIONPOINT + 130, + // @(deprecated="Use SEEKDATA") + // IOCTLDATA = OPTTYPE_CBPOINT + 131, + + /* 132 OBSOLETE. Gone in 7.16.0 */ + /* 133 OBSOLETE. Gone in 7.16.0 */ + + /* null-terminated string for pass on to the FTP server when asked for + "account" info */ + FTP_ACCOUNT = OPTTYPE_STRINGPOINT + 134, + + /* feed cookie into cookie engine */ + COOKIELIST = OPTTYPE_STRINGPOINT + 135, + + /* ignore Content-Length */ + IGNORE_CONTENT_LENGTH = OPTTYPE_LONG + 136, + + /* Set to non-zero to skip the IP address received in a 227 PASV FTP server + response. Typically used for FTP-SSL purposes but is not restricted to + that. libcurl will then instead use the same IP address it used for the + control connection. */ + FTP_SKIP_PASV_IP = OPTTYPE_LONG + 137, + + /* Select "file method" to use when doing FTP, see the curl_ftpmethod + above. */ + FTP_FILEMETHOD = OPTTYPE_VALUES + 138, + + /* Local port number to bind the socket to */ + LOCALPORT = OPTTYPE_LONG + 139, + + /* Number of ports to try, including the first one set with LOCALPORT. + Thus, setting it to 1 will make no additional attempts but the first. + */ + LOCALPORTRANGE = OPTTYPE_LONG + 140, + + /* no transfer, set up connection and let application use the socket by + extracting it with INFO_LASTSOCKET */ + CONNECT_ONLY = OPTTYPE_LONG + 141, + + /* Function that will be called to convert from the + network encoding (instead of using the iconv calls in libcurl) */ + + // @(deprecated="Serves no purpose anymore"),) + // CONV_FROM_NETWORK_FUNCTION = OPTTYPE_FUNCTIONPOINT + 142, + + /* Function that will be called to convert to the + network encoding (instead of using the iconv calls in libcurl) */ + + // @(deprecated="Serves no purpose anymore"),) + // CONV_TO_NETWORK_FUNCTION = OPTTYPE_FUNCTIONPOINT + 143, + + /* Function that will be called to convert from UTF8 + (instead of using the iconv calls in libcurl) + Note that this is used only for SSL certificate processing */ + + // @(deprecated="Serves no purpose anymore"),) + // CONV_FROM_UTF8_FUNCTION = OPTTYPE_FUNCTIONPOINT + 144, + + /* if the connection proceeds too quickly then need to slow it down */ + /* limit-rate: maximum number of bytes per second to send or receive */ + MAX_SEND_SPEED_LARGE = OPTTYPE_OFF_T + 145, + MAX_RECV_SPEED_LARGE = OPTTYPE_OFF_T + 146, + + /* Pointer to command string to send if USER/PASS fails. */ + FTP_ALTERNATIVE_TO_USER = OPTTYPE_STRINGPOINT + 147, + + /* callback function for setting socket options */ + SOCKOPTFUNCTION = OPTTYPE_FUNCTIONPOINT + 148, + SOCKOPTDATA = OPTTYPE_CBPOINT + 149, + + /* set to 0 to disable session ID reuse for this transfer, default is + enabled (== 1) */ + SSL_SESSIONID_CACHE = OPTTYPE_LONG + 150, + + /* allowed SSH authentication methods */ + SSH_AUTH_TYPES = OPTTYPE_VALUES + 151, + + /* Used by scp/sftp to do public/private key authentication */ + SSH_PUBLIC_KEYFILE = OPTTYPE_STRINGPOINT + 152, + SSH_PRIVATE_KEYFILE = OPTTYPE_STRINGPOINT + 153, + + /* Send CCC (Clear Command Channel) after authentication */ + FTP_SSL_CCC = OPTTYPE_LONG + 154, + + /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */ + TIMEOUT_MS = OPTTYPE_LONG + 155, + CONNECTTIMEOUT_MS = OPTTYPE_LONG + 156, + + /* set to zero to disable the libcurl's decoding and thus pass the raw body + data to the application even when it is encoded/compressed */ + HTTP_TRANSFER_DECODING = OPTTYPE_LONG + 157, + HTTP_CONTENT_DECODING = OPTTYPE_LONG + 158, + + /* Permission used when creating new files and directories on the remote + server for protocols that support it, SFTP/SCP/FILE */ + NEW_FILE_PERMS = OPTTYPE_LONG + 159, + NEW_DIRECTORY_PERMS = OPTTYPE_LONG + 160, + + /* Set the behavior of POST when redirecting. Values must be set to one + of CURL_REDIR* defines below. This used to be called POST301 */ + POSTREDIR = OPTTYPE_VALUES + 161, + + /* used by scp/sftp to verify the host's public key */ + SSH_HOST_PUBLIC_KEY_MD5 = OPTTYPE_STRINGPOINT + 162, + + /* Callback function for opening socket (instead of socket(2)). Optionally, + callback is able change the address or refuse to connect returning + CURL_SOCKET_BAD. The callback should have type + curl_opensocket_callback */ + OPENSOCKETFUNCTION = OPTTYPE_FUNCTIONPOINT + 163, + OPENSOCKETDATA = OPTTYPE_CBPOINT + 164, + + /* POST volatile input fields. */ + COPYPOSTFIELDS = OPTTYPE_OBJECTPOINT + 165, + + /* set transfer mode (;type=) when doing FTP via an HTTP proxy */ + PROXY_TRANSFER_MODE = OPTTYPE_LONG + 166, + + /* Callback function for seeking in the input stream */ + SEEKFUNCTION = OPTTYPE_FUNCTIONPOINT + 167, + SEEKDATA = OPTTYPE_CBPOINT + 168, + + /* CRL file */ + CRLFILE = OPTTYPE_STRINGPOINT + 169, + + /* Issuer certificate */ + ISSUERCERT = OPTTYPE_STRINGPOINT + 170, + + /* (IPv6) Address scope */ + ADDRESS_SCOPE = OPTTYPE_LONG + 171, + + /* Collect certificate chain info and allow it to get retrievable with + INFO_CERTINFO after the transfer is complete. */ + CERTINFO = OPTTYPE_LONG + 172, + + /* "name" and "pwd" to use when fetching. */ + USERNAME = OPTTYPE_STRINGPOINT + 173, + PASSWORD = OPTTYPE_STRINGPOINT + 174, + + /* "name" and "pwd" to use with Proxy when fetching. */ + PROXYUSERNAME = OPTTYPE_STRINGPOINT + 175, + PROXYPASSWORD = OPTTYPE_STRINGPOINT + 176, + + /* Comma separated list of hostnames defining no-proxy zones. These should + match both hostnames directly, and hostnames within a domain. For + example, local.com will match local.com and www.local.com, but NOT + notlocal.com or www.notlocal.com. For compatibility with other + implementations of this, .local.com will be considered to be the same as + local.com. A single * is the only valid wildcard, and effectively + disables the use of proxy. */ + NOPROXY = OPTTYPE_STRINGPOINT + 177, + + /* block size for TFTP transfers */ + TFTP_BLKSIZE = OPTTYPE_LONG + 178, + + /* Socks Service */ + /* DEPRECATED, do not use! */ + // @(deprecated="Use PROXY_SERVICE_NAME"),) + // SOCKS5_GSSAPI_SERVICE = OPTTYPE_STRINGPOINT + 179, + + /* Socks Service */ + SOCKS5_GSSAPI_NEC = OPTTYPE_LONG + 180, + + /* set the bitmask for the protocols that are allowed to be used for the + transfer, which thus helps the app which takes URLs from users or other + external inputs and want to restrict what protocol(s) to deal + with. Defaults to CURLPROTO_ALL. */ + // @(deprecated="Use PROTOCOLS_STR") + // PROTOCOLS = OPTTYPE_LONG + 181, + + /* set the bitmask for the protocols that libcurl is allowed to follow to, + as a subset of the PROTOCOLS ones. That means the protocol needs + to be set in both bitmasks to be allowed to get redirected to. */ + // @(deprecated="Use REDIR_PROTOCOLS_STR") + // REDIR_PROTOCOLS = OPTTYPE_LONG + 182, + + /* set the SSH knownhost filename to use */ + SSH_KNOWNHOSTS = OPTTYPE_STRINGPOINT + 183, + + /* set the SSH host key callback, must point to a curl_sshkeycallback + function */ + SSH_KEYFUNCTION = OPTTYPE_FUNCTIONPOINT + 184, + + /* set the SSH host key callback custom pointer */ + SSH_KEYDATA = OPTTYPE_CBPOINT + 185, + + /* set the SMTP mail originator */ + MAIL_FROM = OPTTYPE_STRINGPOINT + 186, + + /* set the list of SMTP mail receiver(s) */ + MAIL_RCPT = OPTTYPE_SLISTPOINT + 187, + + /* FTP: send PRET before PASV */ + FTP_USE_PRET = OPTTYPE_LONG + 188, + + /* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */ + RTSP_REQUEST = OPTTYPE_VALUES + 189, + + /* The RTSP session identifier */ + RTSP_SESSION_ID = OPTTYPE_STRINGPOINT + 190, + + /* The RTSP stream URI */ + RTSP_STREAM_URI = OPTTYPE_STRINGPOINT + 191, + + /* The Transport: header to use in RTSP requests */ + RTSP_TRANSPORT = OPTTYPE_STRINGPOINT + 192, + + /* Manually initialize the client RTSP CSeq for this handle */ + RTSP_CLIENT_CSEQ = OPTTYPE_LONG + 193, + + /* Manually initialize the server RTSP CSeq for this handle */ + RTSP_SERVER_CSEQ = OPTTYPE_LONG + 194, + + /* The stream to pass to INTERLEAVEFUNCTION. */ + INTERLEAVEDATA = OPTTYPE_CBPOINT + 195, + + /* Let the application define a custom write method for RTP data */ + INTERLEAVEFUNCTION = OPTTYPE_FUNCTIONPOINT + 196, + + /* Turn on wildcard matching */ + WILDCARDMATCH = OPTTYPE_LONG + 197, + + /* Directory matching callback called before downloading of an + individual file (chunk) started */ + CHUNK_BGN_FUNCTION = OPTTYPE_FUNCTIONPOINT + 198, + + /* Directory matching callback called after the file (chunk) + was downloaded, or skipped */ + CHUNK_END_FUNCTION = OPTTYPE_FUNCTIONPOINT + 199, + + /* Change match (fnmatch-like) callback for wildcard matching */ + FNMATCH_FUNCTION = OPTTYPE_FUNCTIONPOINT + 200, + + /* Let the application define custom chunk data pointer */ + CHUNK_DATA = OPTTYPE_CBPOINT + 201, + + /* FNMATCH_FUNCTION user pointer */ + FNMATCH_DATA = OPTTYPE_CBPOINT + 202, + + /* send linked-list of name:port:address sets */ + RESOLVE = OPTTYPE_SLISTPOINT + 203, + + /* Set a username for authenticated TLS */ + TLSAUTH_USERNAME = OPTTYPE_STRINGPOINT + 204, + + /* Set a password for authenticated TLS */ + TLSAUTH_PASSWORD = OPTTYPE_STRINGPOINT + 205, + + /* Set authentication type for authenticated TLS */ + TLSAUTH_TYPE = OPTTYPE_STRINGPOINT + 206, + + /* Set to 1 to enable the "TE:" header in HTTP requests to ask for + compressed transfer-encoded responses. Set to 0 to disable the use of TE: + in outgoing requests. The current default is 0, but it might change in a + future libcurl release. + + libcurl will ask for the compressed methods it knows of, and if that + is not any, it will not ask for transfer-encoding at all even if this + option is set to 1. + + */ + TRANSFER_ENCODING = OPTTYPE_LONG + 207, + + /* Callback function for closing socket (instead of close(2)). The callback + should have type curl_closesocket_callback */ + CLOSESOCKETFUNCTION = OPTTYPE_FUNCTIONPOINT + 208, + CLOSESOCKETDATA = OPTTYPE_CBPOINT + 209, + + /* allow GSSAPI credential delegation */ + GSSAPI_DELEGATION = OPTTYPE_VALUES + 210, + + /* Set the name servers to use for DNS resolution. + * Only supported by the c-ares DNS backend */ + DNS_SERVERS = OPTTYPE_STRINGPOINT + 211, + + /* Time-out accept operations (currently for FTP only) after this amount + of milliseconds. */ + ACCEPTTIMEOUT_MS = OPTTYPE_LONG + 212, + + /* Set TCP keepalive */ + TCP_KEEPALIVE = OPTTYPE_LONG + 213, + + /* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */ + TCP_KEEPIDLE = OPTTYPE_LONG + 214, + TCP_KEEPINTVL = OPTTYPE_LONG + 215, + + /* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */ + SSL_OPTIONS = OPTTYPE_VALUES + 216, + + /* Set the SMTP auth originator */ + MAIL_AUTH = OPTTYPE_STRINGPOINT + 217, + + /* Enable/disable SASL initial response */ + SASL_IR = OPTTYPE_LONG + 218, + + /* Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_xferinfo_callback + * prototype defines. (Deprecates PROGRESSFUNCTION) */ + XFERINFOFUNCTION = OPTTYPE_FUNCTIONPOINT + 219, + + /* The XOAUTH2 bearer token */ + XOAUTH2_BEARER = OPTTYPE_STRINGPOINT + 220, + + /* Set the interface string to use as outgoing network + * interface for DNS requests. + * Only supported by the c-ares DNS backend */ + DNS_INTERFACE = OPTTYPE_STRINGPOINT + 221, + + /* Set the local IPv4 address to use for outgoing DNS requests. + * Only supported by the c-ares DNS backend */ + DNS_LOCAL_IP4 = OPTTYPE_STRINGPOINT + 222, + + /* Set the local IPv6 address to use for outgoing DNS requests. + * Only supported by the c-ares DNS backend */ + DNS_LOCAL_IP6 = OPTTYPE_STRINGPOINT + 223, + + /* Set authentication options directly */ + LOGIN_OPTIONS = OPTTYPE_STRINGPOINT + 224, + + /* Enable/disable TLS NPN extension (http2 over ssl might fail without) */ + // @(deprecated="Has no function") + // SSL_ENABLE_NPN = OPTTYPE_LONG + 225, + + /* Enable/disable TLS ALPN extension (http2 over ssl might fail without) */ + SSL_ENABLE_ALPN = OPTTYPE_LONG + 226, + + /* Time to wait for a response to an HTTP request containing an + * Expect: 100-continue header before sending the data anyway. */ + EXPECT_100_TIMEOUT_MS = OPTTYPE_LONG + 227, + + /* This points to a linked list of headers used for proxy requests only, + struct curl_slist kind */ + PROXYHEADER = OPTTYPE_SLISTPOINT + 228, + + /* Pass in a bitmask of "header options" */ + HEADEROPT = OPTTYPE_VALUES + 229, + + /* The public key in DER form used to validate the peer public key + this option is used only if SSL_VERIFYPEER is true */ + PINNEDPUBLICKEY = OPTTYPE_STRINGPOINT + 230, + + /* Path to Unix domain socket */ + UNIX_SOCKET_PATH = OPTTYPE_STRINGPOINT + 231, + + /* Set if we should verify the certificate status. */ + SSL_VERIFYSTATUS = OPTTYPE_LONG + 232, + + /* Set if we should enable TLS false start. */ + SSL_FALSESTART = OPTTYPE_LONG + 233, + + /* Do not squash dot-dot sequences */ + PATH_AS_IS = OPTTYPE_LONG + 234, + + /* Proxy Service Name */ + PROXY_SERVICE_NAME = OPTTYPE_STRINGPOINT + 235, + + /* Service Name */ + SERVICE_NAME = OPTTYPE_STRINGPOINT + 236, + + /* Wait/do not wait for pipe/mutex to clarify */ + PIPEWAIT = OPTTYPE_LONG + 237, + + /* Set the protocol used when curl is given a URL without a protocol */ + DEFAULT_PROTOCOL = OPTTYPE_STRINGPOINT + 238, + + /* Set stream weight, 1 - 256 (default is 16) */ + STREAM_WEIGHT = OPTTYPE_LONG + 239, + + /* Set stream dependency on another CURL handle */ + STREAM_DEPENDS = OPTTYPE_OBJECTPOINT + 240, + + /* Set E-xclusive stream dependency on another CURL handle */ + STREAM_DEPENDS_E = OPTTYPE_OBJECTPOINT + 241, + + /* Do not send any tftp option requests to the server */ + TFTP_NO_OPTIONS = OPTTYPE_LONG + 242, + + /* Linked-list of host:port:connect-to-host:connect-to-port, + overrides the URL's host:port (only for the network layer) */ + CONNECT_TO = OPTTYPE_SLISTPOINT + 243, + + /* Set TCP Fast Open */ + TCP_FASTOPEN = OPTTYPE_LONG + 244, + + /* Continue to send data if the server responds early with an + * HTTP status code >= 300 */ + KEEP_SENDING_ON_ERROR = OPTTYPE_LONG + 245, + + /* The CApath or CAfile used to validate the proxy certificate + this option is used only if PROXY_SSL_VERIFYPEER is true */ + PROXY_CAINFO = OPTTYPE_STRINGPOINT + 246, + + /* The CApath directory used to validate the proxy certificate + this option is used only if PROXY_SSL_VERIFYPEER is true */ + PROXY_CAPATH = OPTTYPE_STRINGPOINT + 247, + + /* Set if we should verify the proxy in ssl handshake, + set 1 to verify. */ + PROXY_SSL_VERIFYPEER = OPTTYPE_LONG + 248, + + /* Set if we should verify the Common name from the proxy certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches + * the provided hostname. */ + PROXY_SSL_VERIFYHOST = OPTTYPE_LONG + 249, + + /* What version to specifically try to use for proxy. + See CURL_SSLVERSION defines below. */ + PROXY_SSLVERSION = OPTTYPE_VALUES + 250, + + /* Set a username for authenticated TLS for proxy */ + PROXY_TLSAUTH_USERNAME = OPTTYPE_STRINGPOINT + 251, + + /* Set a password for authenticated TLS for proxy */ + PROXY_TLSAUTH_PASSWORD = OPTTYPE_STRINGPOINT + 252, + + /* Set authentication type for authenticated TLS for proxy */ + PROXY_TLSAUTH_TYPE = OPTTYPE_STRINGPOINT + 253, + + /* name of the file keeping your private SSL-certificate for proxy */ + PROXY_SSLCERT = OPTTYPE_STRINGPOINT + 254, + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") for + proxy */ + PROXY_SSLCERTTYPE = OPTTYPE_STRINGPOINT + 255, + + /* name of the file keeping your private SSL-key for proxy */ + PROXY_SSLKEY = OPTTYPE_STRINGPOINT + 256, + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") for + proxy */ + PROXY_SSLKEYTYPE = OPTTYPE_STRINGPOINT + 257, + + /* password for the SSL private key for proxy */ + PROXY_KEYPASSWD = OPTTYPE_STRINGPOINT + 258, + + /* Specify which TLS 1.2 (1.1, 1.0) ciphers to use for proxy */ + PROXY_SSL_CIPHER_LIST = OPTTYPE_STRINGPOINT + 259, + + /* CRL file for proxy */ + PROXY_CRLFILE = OPTTYPE_STRINGPOINT + 260, + + /* Enable/disable specific SSL features with a bitmask for proxy, see + CURLSSLOPT_* */ + PROXY_SSL_OPTIONS = OPTTYPE_LONG + 261, + + /* Name of pre proxy to use. */ + PRE_PROXY = OPTTYPE_STRINGPOINT + 262, + + /* The public key in DER form used to validate the proxy public key + this option is used only if PROXY_SSL_VERIFYPEER is true */ + PROXY_PINNEDPUBLICKEY = OPTTYPE_STRINGPOINT + 263, + + /* Path to an abstract Unix domain socket */ + ABSTRACT_UNIX_SOCKET = OPTTYPE_STRINGPOINT + 264, + + /* Suppress proxy CONNECT response headers from user callbacks */ + SUPPRESS_CONNECT_HEADERS = OPTTYPE_LONG + 265, + + /* The request target, instead of extracted from the URL */ + REQUEST_TARGET = OPTTYPE_STRINGPOINT + 266, + + /* bitmask of allowed auth methods for connections to SOCKS5 proxies */ + SOCKS5_AUTH = OPTTYPE_LONG + 267, + + /* Enable/disable SSH compression */ + SSH_COMPRESSION = OPTTYPE_LONG + 268, + + /* Post MIME data. */ + MIMEPOST = OPTTYPE_OBJECTPOINT + 269, + + /* Time to use with the TIMECONDITION. Specified in number of + seconds since 1 Jan 1970. */ + TIMEVALUE_LARGE = OPTTYPE_OFF_T + 270, + + /* Head start in milliseconds to give happy eyeballs. */ + HAPPY_EYEBALLS_TIMEOUT_MS = OPTTYPE_LONG + 271, + + /* Function that will be called before a resolver request is made */ + RESOLVER_START_FUNCTION = OPTTYPE_FUNCTIONPOINT + 272, + + /* User data to pass to the resolver start callback. */ + RESOLVER_START_DATA = OPTTYPE_CBPOINT + 273, + + /* send HAProxy PROXY protocol header? */ + HAPROXYPROTOCOL = OPTTYPE_LONG + 274, + + /* shuffle addresses before use when DNS returns multiple */ + DNS_SHUFFLE_ADDRESSES = OPTTYPE_LONG + 275, + + /* Specify which TLS 1.3 ciphers suites to use */ + TLS13_CIPHERS = OPTTYPE_STRINGPOINT + 276, + PROXY_TLS13_CIPHERS = OPTTYPE_STRINGPOINT + 277, + + /* Disallow specifying username/login in URL. */ + DISALLOW_USERNAME_IN_URL = OPTTYPE_LONG + 278, + + /* DNS-over-HTTPS URL */ + DOH_URL = OPTTYPE_STRINGPOINT + 279, + + /* Preferred buffer size to use for uploads */ + UPLOAD_BUFFERSIZE = OPTTYPE_LONG + 280, + + /* Time in ms between connection upkeep calls for long-lived connections. */ + UPKEEP_INTERVAL_MS = OPTTYPE_LONG + 281, + + /* Specify URL using CURL URL API. */ + CURLU = OPTTYPE_OBJECTPOINT + 282, + + /* add trailing data just after no more data is available */ + TRAILERFUNCTION = OPTTYPE_FUNCTIONPOINT + 283, + + /* pointer to be passed to HTTP_TRAILER_FUNCTION */ + TRAILERDATA = OPTTYPE_CBPOINT + 284, + + /* set this to 1L to allow HTTP/0.9 responses or 0L to disallow */ + HTTP09_ALLOWED = OPTTYPE_LONG + 285, + + /* alt-svc control bitmask */ + ALTSVC_CTRL = OPTTYPE_LONG + 286, + + /* alt-svc cache filename to possibly read from/write to */ + ALTSVC = OPTTYPE_STRINGPOINT + 287, + + /* maximum age (idle time) of a connection to consider it for reuse + * (in seconds) */ + MAXAGE_CONN = OPTTYPE_LONG + 288, + + /* SASL authorization identity */ + SASL_AUTHZID = OPTTYPE_STRINGPOINT + 289, + + /* allow RCPT TO command to fail for some recipients */ + MAIL_RCPT_ALLOWFAILS = OPTTYPE_LONG + 290, + + /* the private SSL-certificate as a "blob" */ + SSLCERT_BLOB = OPTTYPE_BLOB + 291, + SSLKEY_BLOB = OPTTYPE_BLOB + 292, + PROXY_SSLCERT_BLOB = OPTTYPE_BLOB + 293, + PROXY_SSLKEY_BLOB = OPTTYPE_BLOB + 294, + ISSUERCERT_BLOB = OPTTYPE_BLOB + 295, + + /* Issuer certificate for proxy */ + PROXY_ISSUERCERT = OPTTYPE_STRINGPOINT + 296, + PROXY_ISSUERCERT_BLOB = OPTTYPE_BLOB + 297, + + /* the EC curves requested by the TLS client (RFC 8422, 5.1); + * OpenSSL support via 'set_groups'/'set_curves': + * https://docs.openssl.org/master/man3/SSL_CTX_set1_curves/ + */ + SSL_EC_CURVES = OPTTYPE_STRINGPOINT + 298, + + /* HSTS bitmask */ + HSTS_CTRL = OPTTYPE_LONG + 299, + /* HSTS filename */ + HSTS = OPTTYPE_STRINGPOINT + 300, + + /* HSTS read callback */ + HSTSREADFUNCTION = OPTTYPE_FUNCTIONPOINT + 301, + HSTSREADDATA = OPTTYPE_CBPOINT + 302, + + /* HSTS write callback */ + HSTSWRITEFUNCTION = OPTTYPE_FUNCTIONPOINT + 303, + HSTSWRITEDATA = OPTTYPE_CBPOINT + 304, + + /* Parameters for V4 signature */ + AWS_SIGV4 = OPTTYPE_STRINGPOINT + 305, + + /* Same as SSL_VERIFYPEER but for DoH (DNS-over-HTTPS) servers. */ + DOH_SSL_VERIFYPEER = OPTTYPE_LONG + 306, + + /* Same as SSL_VERIFYHOST but for DoH (DNS-over-HTTPS) servers. */ + DOH_SSL_VERIFYHOST = OPTTYPE_LONG + 307, + + /* Same as SSL_VERIFYSTATUS but for DoH (DNS-over-HTTPS) servers. */ + DOH_SSL_VERIFYSTATUS = OPTTYPE_LONG + 308, + + /* The CA certificates as "blob" used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CAINFO_BLOB = OPTTYPE_BLOB + 309, + + /* The CA certificates as "blob" used to validate the proxy certificate + this option is used only if PROXY_SSL_VERIFYPEER is true */ + PROXY_CAINFO_BLOB = OPTTYPE_BLOB + 310, + + /* used by scp/sftp to verify the host's public key */ + SSH_HOST_PUBLIC_KEY_SHA256 = OPTTYPE_STRINGPOINT + 311, + + /* Function that will be called immediately before the initial request + is made on a connection (after any protocol negotiation step). */ + PREREQFUNCTION = OPTTYPE_FUNCTIONPOINT + 312, + + /* Data passed to the PREREQFUNCTION callback */ + PREREQDATA = OPTTYPE_CBPOINT + 313, + + /* maximum age (since creation) of a connection to consider it for reuse + * (in seconds) */ + MAXLIFETIME_CONN = OPTTYPE_LONG + 314, + + /* Set MIME option flags. */ + MIME_OPTIONS = OPTTYPE_LONG + 315, + + /* set the SSH host key callback, must point to a curl_sshkeycallback + function */ + SSH_HOSTKEYFUNCTION = OPTTYPE_FUNCTIONPOINT + 316, + + /* set the SSH host key callback custom pointer */ + SSH_HOSTKEYDATA = OPTTYPE_CBPOINT + 317, + + /* specify which protocols that are allowed to be used for the transfer, + which thus helps the app which takes URLs from users or other external + inputs and want to restrict what protocol(s) to deal with. Defaults to + all built-in protocols. */ + PROTOCOLS_STR = OPTTYPE_STRINGPOINT + 318, + + /* specify which protocols that libcurl is allowed to follow directs to */ + REDIR_PROTOCOLS_STR = OPTTYPE_STRINGPOINT + 319, + + /* WebSockets options */ + WS_OPTIONS = OPTTYPE_LONG + 320, + + /* CA cache timeout */ + CA_CACHE_TIMEOUT = OPTTYPE_LONG + 321, + + /* Can leak things, gonna exit() soon */ + QUICK_EXIT = OPTTYPE_LONG + 322, + + /* set a specific client IP for HAProxy PROXY protocol header? */ + HAPROXY_CLIENT_IP = OPTTYPE_STRINGPOINT + 323, + + /* millisecond version */ + SERVER_RESPONSE_TIMEOUT_MS = OPTTYPE_LONG + 324, + + /* set ECH configuration */ + ECH = OPTTYPE_STRINGPOINT + 325, + + /* maximum number of keepalive probes (Linux, *BSD, macOS, etc.) */ + TCP_KEEPCNT = OPTTYPE_LONG + 326, +} + +Code :: enum i32 { + OK = 0, + UNSUPPORTED_PROTOCOL, /* 1 */ + FAILED_INIT, /* 2 */ + URL_MALFORMAT, /* 3 */ + NOT_BUILT_IN, /* 4 - [was obsoleted in August 2007 for + 7.17.0, reused in April 2011 for 7.21.5] */ + COULDNT_RESOLVE_PROXY, /* 5 */ + COULDNT_RESOLVE_HOST, /* 6 */ + COULDNT_CONNECT, /* 7 */ + WEIRD_SERVER_REPLY, /* 8 */ + REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server + due to lack of access - when login fails + this is not returned. */ + FTP_ACCEPT_FAILED, /* 10 - [was obsoleted in April 2006 for + 7.15.4, reused in Dec 2011 for 7.24.0]*/ + FTP_WEIRD_PASS_REPLY, /* 11 */ + FTP_ACCEPT_TIMEOUT, /* 12 - timeout occurred accepting server + [was obsoleted in August 2007 for 7.17.0, + reused in Dec 2011 for 7.24.0]*/ + FTP_WEIRD_PASV_REPLY, /* 13 */ + FTP_WEIRD_227_FORMAT, /* 14 */ + FTP_CANT_GET_HOST, /* 15 */ + HTTP2, /* 16 - A problem in the http2 framing layer. + [was obsoleted in August 2007 for 7.17.0, + reused in July 2014 for 7.38.0] */ + FTP_COULDNT_SET_TYPE, /* 17 */ + PARTIAL_FILE, /* 18 */ + FTP_COULDNT_RETR_FILE, /* 19 */ + OBSOLETE20, /* 20 - NOT USED */ + QUOTE_ERROR, /* 21 - quote command failure */ + HTTP_RETURNED_ERROR, /* 22 */ + WRITE_ERROR, /* 23 */ + OBSOLETE24, /* 24 - NOT USED */ + UPLOAD_FAILED, /* 25 - failed upload "command" */ + READ_ERROR, /* 26 - could not open/read from file */ + OUT_OF_MEMORY, /* 27 */ + OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ + OBSOLETE29, /* 29 - NOT USED */ + FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ + FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ + OBSOLETE32, /* 32 - NOT USED */ + RANGE_ERROR, /* 33 - RANGE "command" did not work */ + HTTP_POST_ERROR, /* 34 */ + SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ + BAD_DOWNLOAD_RESUME, /* 36 - could not resume download */ + FILE_COULDNT_READ_FILE, /* 37 */ + LDAP_CANNOT_BIND, /* 38 */ + LDAP_SEARCH_FAILED, /* 39 */ + OBSOLETE40, /* 40 - NOT USED */ + FUNCTION_NOT_FOUND, /* 41 - NOT USED starting with 7.53.0 */ + ABORTED_BY_CALLBACK, /* 42 */ + BAD_FUNCTION_ARGUMENT, /* 43 */ + OBSOLETE44, /* 44 - NOT USED */ + INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ + OBSOLETE46, /* 46 - NOT USED */ + TOO_MANY_REDIRECTS, /* 47 - catch endless re-direct loops */ + UNKNOWN_OPTION, /* 48 - User specified an unknown option */ + SETOPT_OPTION_SYNTAX, /* 49 - Malformed setopt option */ + OBSOLETE50, /* 50 - NOT USED */ + OBSOLETE51, /* 51 - NOT USED */ + GOT_NOTHING, /* 52 - when this is a specific error */ + SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ + SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as + default */ + SEND_ERROR, /* 55 - failed sending network data */ + RECV_ERROR, /* 56 - failure in receiving network data */ + OBSOLETE57, /* 57 - NOT IN USE */ + SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ + SSL_CIPHER, /* 59 - could not use specified cipher */ + PEER_FAILED_VERIFICATION, /* 60 - peer's certificate or fingerprint + was not verified fine */ + BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */ + OBSOLETE62, /* 62 - NOT IN USE since 7.82.0 */ + FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ + USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ + SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind + that failed */ + SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ + LOGIN_DENIED, /* 67 - user, password or similar was not + accepted and we failed to login */ + TFTP_NOTFOUND, /* 68 - file not found on server */ + TFTP_PERM, /* 69 - permission problem on server */ + REMOTE_DISK_FULL, /* 70 - out of disk space on server */ + TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ + TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ + REMOTE_FILE_EXISTS, /* 73 - File already exists */ + TFTP_NOSUCHUSER, /* 74 - No such user */ + OBSOLETE75, /* 75 - NOT IN USE since 7.82.0 */ + OBSOLETE76, /* 76 - NOT IN USE since 7.82.0 */ + SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing + or wrong format */ + REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ + SSH, /* 79 - error from the SSH layer, somewhat + generic so the error message will be of + interest when this has happened */ + SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL + connection */ + AGAIN, /* 81 - socket is not ready for send/recv, + wait till it is ready and try again (Added + in 7.18.2) */ + SSL_CRL_BADFILE, /* 82 - could not load CRL file, missing or + wrong format (Added in 7.19.0) */ + SSL_ISSUER_ERROR, /* 83 - Issuer check failed. (Added in + 7.19.0) */ + FTP_PRET_FAILED, /* 84 - a PRET command failed */ + RTSP_CSEQ_ERROR, /* 85 - mismatch of RTSP CSeq numbers */ + RTSP_SESSION_ERROR, /* 86 - mismatch of RTSP Session Ids */ + FTP_BAD_FILE_LIST, /* 87 - unable to parse FTP file list */ + CHUNK_FAILED, /* 88 - chunk callback reported error */ + NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the + session will be queued */ + SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not + match */ + SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */ + HTTP2_STREAM, /* 92 - stream error in HTTP/2 framing layer + */ + RECURSIVE_API_CALL, /* 93 - an api function was called from + inside a callback */ + AUTH_ERROR, /* 94 - an authentication function returned an + error */ + HTTP3, /* 95 - An HTTP/3 layer problem */ + QUIC_CONNECT_ERROR, /* 96 - QUIC connection error */ + PROXY, /* 97 - proxy handshake error */ + SSL_CLIENTCERT, /* 98 - client-side certificate required */ + UNRECOVERABLE_POLL, /* 99 - poll/select returned fatal error */ + TOO_LARGE, /* 100 - a value/data met its maximum */ + ECH_REQUIRED, /* 101 - ECH tried but failed */ +} + + +malloc_callback :: proc(size: uint) -> rawptr +free_callback :: proc(ptr: rawptr) +realloc_callback :: proc(ptr: rawptr, size: uint) -> rawptr +strdup_callback :: proc(str: cstring) -> cstring +calloc_callback :: proc(nmemb: uint, size: uint) -> rawptr +read_callback :: proc(buffer: cstring, size: uint, nitems: uint, arg: rawptr) -> uint +seek_callback :: proc(arg: rawptr, offset: i64, origin: i32) -> i32 + +Ssl_Set_Code :: enum i32 { + OK = 0, + UNKNOWN_BACKEND, + TOO_LATE, + NO_BACKENDS, /* libcurl was built without any SSL support */ +} + +Ssl_Backend :: enum i32 { + NONE = 0, + OPENSSL = 1, + GNUTLS = 2, + NSS = 3, // CURL_DEPRECATED(8.3.0, "") + OBSOLETE4 = 4, /* Was QSOSSL. */ + GSKIT = 5, // CURL_DEPRECATED(8.3.0, "") + POLARSSL = 6, // CURL_DEPRECATED(7.69.0, "") + WOLFSSL = 7, + SCHANNEL = 8, + SECURETRANSPORT = 9, + AXTLS = 10, // CURL_DEPRECATED(7.61.0, "") + MBEDTLS = 11, + MESALINK = 12, // CURL_DEPRECATED(7.82.0, "") + BEARSSL = 13, + RUSTLS = 14, +} + +ssl_backend :: struct { + id: Ssl_Backend, + name: cstring, +} + +Mime_Part :: struct {} +mime :: struct {} +Slist :: struct {} + +Multi_Code :: enum { + CALL_MULTI_PERFORM = -1, + /* please call curl_multi_perform() or + curl_multi_socket*() soon */ + OK, + BAD_HANDLE, + /* the passed-in handle is not a valid CURLM handle */ + BAD_EASY_HANDLE, + /* an easy handle was not good/valid */ + OUT_OF_MEMORY, + /* if you ever get this, you are in deep sh*t */ + INTERNAL_ERROR, + /* this is a libcurl bug */ + BAD_SOCKET, + /* the passed in socket argument did not match */ + UNKNOWN_OPTION, + /* curl_multi_setopt() with unsupported option */ + ADDED_ALREADY, + /* an easy handle already added to a multi handle was + attempted to get added - again */ + RECURSIVE_API_CALL, + /* an api function was called from inside a + callback */ + WAKEUP_FAILURE, + /* wakeup is unavailable or failed */ + BAD_FUNCTION_ARGUMENT, + /* function called with a bad parameter */ + ABORTED_BY_CALLBACK, + UNRECOVERABLE_POLL, +} + +Msg :: struct { + msg: MSG, /* what this message means */ + easy_handle: Handle, /* the handle it concerns */ + data: struct #raw_union { + whatever: rawptr, /* message-specific data */ + result: Code, /* return code for transfer */ + }, +} + +MSG :: enum i32 { + NONE, /* first, not used */ + DONE, /* This easy handle has completed. 'result' contains + the CURLcode of the transfer */ +} + +Url :: struct {} + +waitfd :: struct { + fd: socket_t, + events: i16, + revents: i16, +} + +Multi_Option :: enum i32 { + /* This is the socket callback function pointer */ + SOCKETFUNCTION = OPTTYPE_FUNCTIONPOINT + 1, + + /* This is the argument passed to the socket callback */ + SOCKETDATA = OPTTYPE_OBJECTPOINT + 2, + + /* set to 1 to enable pipelining for this multi handle */ + PIPELINING = OPTTYPE_LONG + 3, + + /* This is the timer callback function pointer */ + TIMERFUNCTION = OPTTYPE_FUNCTIONPOINT + 4, + + /* This is the argument passed to the timer callback */ + TIMERDATA = OPTTYPE_OBJECTPOINT + 5, + + /* maximum number of entries in the connection cache */ + MAXCONNECTS = OPTTYPE_LONG + 6, + + /* maximum number of (pipelining) connections to one host */ + MAX_HOST_CONNECTIONS = OPTTYPE_LONG + 7, + + /* maximum number of requests in a pipeline */ + MAX_PIPELINE_LENGTH = OPTTYPE_LONG + 8, + + /* a connection with a content-length longer than this + will not be considered for pipelining */ + CONTENT_LENGTH_PENALTY_SIZE = OPTTYPE_OFF_T + 9, + + /* a connection with a chunk length longer than this + will not be considered for pipelining */ + CHUNK_LENGTH_PENALTY_SIZE = OPTTYPE_OFF_T + 10, + + /* a list of site names(+port) that are blocked from pipelining */ + PIPELINING_SITE_BL = OPTTYPE_OBJECTPOINT + 11, + + /* a list of server types that are blocked from pipelining */ + PIPELINING_SERVER_BL = OPTTYPE_OBJECTPOINT + 12, + + /* maximum number of open connections in total */ + MAX_TOTAL_CONNECTIONS = OPTTYPE_LONG + 13, + + /* This is the server push callback function pointer */ + PUSHFUNCTION = OPTTYPE_FUNCTIONPOINT + 14, + + /* This is the argument passed to the server push callback */ + PUSHDATA = OPTTYPE_OBJECTPOINT + 15, + + /* maximum number of concurrent streams to support on a connection */ + MAX_CONCURRENT_STREAMS = OPTTYPE_LONG + 16, +} + +Sh_Option :: enum i32 { + NONE, /* do not use */ + SHARE, /* specify a data type to share */ + UNSHARE, /* specify which data type to stop sharing */ + LOCKFUNC, /* pass in a 'curl_lock_function' pointer */ + UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */ + USERDATA, /* pass in a user data pointer used in the lock/unlock + callback functions */ +} + +Sh_Code :: enum i32 { + OK, /* all is fine */ + BAD_OPTION, /* 1 */ + IN_USE, /* 2 */ + INVALID, /* 3 */ + NOMEM, /* 4 out of memory */ + NOT_BUILT_IN, /* 5 feature not present in lib */ +} + +Push_Headers :: struct {} + +Url_Code :: enum i32 { + OK, + BAD_HANDLE, /* 1 */ + BAD_PARTPOINTER, /* 2 */ + MALFORMED_INPUT, /* 3 */ + BAD_PORT_NUMBER, /* 4 */ + UNSUPPORTED_SCHEME, /* 5 */ + URLDECODE, /* 6 */ + OUT_OF_MEMORY, /* 7 */ + USER_NOT_ALLOWED, /* 8 */ + UNKNOWN_PART, /* 9 */ + NO_SCHEME, /* 10 */ + NO_USER, /* 11 */ + NO_PASSWORD, /* 12 */ + NO_OPTIONS, /* 13 */ + NO_HOST, /* 14 */ + NO_PORT, /* 15 */ + NO_QUERY, /* 16 */ + NO_FRAGMENT, /* 17 */ + NO_ZONEID, /* 18 */ + BAD_FILE_URL, /* 19 */ + BAD_FRAGMENT, /* 20 */ + BAD_HOSTNAME, /* 21 */ + BAD_IPV6, /* 22 */ + BAD_LOGIN, /* 23 */ + BAD_PASSWORD, /* 24 */ + BAD_PATH, /* 25 */ + BAD_QUERY, /* 26 */ + BAD_SCHEME, /* 27 */ + BAD_SLASHES, /* 28 */ + BAD_USER, /* 29 */ + LACKS_IDN, /* 30 */ + TOO_LARGE, /* 31 */ +} + +Url_Flags :: bit_set[enum u32 { + DEFAULT_PORT = 0, /* return default port number */ + NO_DEFAULT_PORT = 1, /* act as if no port number was set, + if the port number matches the + default for the scheme */ + DEFAULT_SCHEME = 2, /* return default scheme if + missing */ + NON_SUPPORT_SCHEME = 3, /* allow non-supported scheme */ + PATH_AS_IS = 4, /* leave dot sequences */ + DISALLOW_USER = 5, /* no user+password allowed */ + URLDECODE = 6, /* URL decode on get */ + URLENCODE = 7, /* URL encode on set */ + APPENDQUERY = 8, /* append a form style part */ + GUESS_SCHEME = 9, /* legacy curl-style guessing */ + NO_AUTHORITY = 10, /* Allow empty authority when the + scheme is unknown. */ + ALLOW_SPACE = 11, /* Allow spaces in the URL */ + PUNYCODE = 12, /* get the hostname in punycode */ + PUNY2IDN = 13, /* punycode => IDN conversion */ + GET_EMPTY = 14, /* allow empty queries and fragments + when extracting the URL or the + components */ + NO_GUESS_SCHEME = 15, /* for get, do not accept a guess */ +}] + +Url_Part :: enum i32 { + URL, + SCHEME, + USER, + PASSWORD, + OPTIONS, + HOST, + PORT, + PATH, + QUERY, + FRAGMENT, + ZONEID, /* added in 7.65.0 */ +} + +Version :: enum i32 { + FIRST, /* 7.10 */ + SECOND, /* 7.11.1 */ + THIRD, /* 7.12.0 */ + FOURTH, /* 7.16.1 */ + FIFTH, /* 7.57.0 */ + SIXTH, /* 7.66.0 */ + SEVENTH, /* 7.70.0 */ + EIGHTH, /* 7.72.0 */ + NINTH, /* 7.75.0 */ + TENTH, /* 7.77.0 */ + ELEVENTH, /* 7.87.0 */ + TWELFTH, /* 8.8.0 */ +} + +Version_Info_Data :: struct { + age: Version, /* age of the returned struct */ + version: cstring, /* LIBCURL_VERSION */ + version_num: u32, /* LIBCURL_VERSION_NUM */ + host: cstring, /* OS/host/cpu/machine when configured */ + features: i32, /* bitmask, see defines below */ + ssl_version: cstring, /* human readable string */ + ssl_version_num: long, /* not used anymore, always 0 */ + libz_version: cstring, /* human readable string */ + /* protocols is terminated by an entry with a NULL protoname */ + protocols: [^]cstring, + + /* The fields below this were added in CURLVERSION_SECOND */ + ares: cstring, + ares_num: i32, + + /* This field was added in CURLVERSION_THIRD */ + libidn: cstring, + + /* These field were added in CURLVERSION_FOURTH */ + + /* Same as '_libiconv_version' if built with HAVE_ICONV */ + iconv_ver_num: i32, + libssh_version: cstring, /* human readable string */ + + /* These fields were added in CURLVERSION_FIFTH */ + brotli_ver_num: u32, /* Numeric Brotli version + (MAJOR << 24) | (MINOR << 12) | PATCH */ + brotli_version: cstring, /* human readable string. */ + + /* These fields were added in CURLVERSION_SIXTH */ + nghttp2_ver_num: u32, /* Numeric nghttp2 version + (MAJOR << 16) | (MINOR << 8) | PATCH */ + nghttp2_version: cstring, /* human readable string. */ + quic_version: cstring, /* human readable quic (+ HTTP/3) library + + version or NULL */ + + /* These fields were added in CURLVERSION_SEVENTH */ + cainfo: cstring, /* the built-in default CURLOPT_CAINFO, might + be NULL */ + capath: cstring, /* the built-in default CURLOPT_CAPATH, might + be NULL */ + + /* These fields were added in CURLVERSION_EIGHTH */ + zstd_ver_num: u32, /* Numeric Zstd version + (MAJOR << 24) | (MINOR << 12) | PATCH */ + zstd_version: cstring, /* human readable string. */ + + /* These fields were added in CURLVERSION_NINTH */ + hyper_version: cstring, /* human readable string. */ + + /* These fields were added in CURLVERSION_TENTH */ + gsasl_version: cstring, /* human readable string. */ + + /* These fields were added in CURLVERSION_ELEVENTH */ + /* feature_names is terminated by an entry with a NULL feature name */ + feature_names: [^]cstring, + + /* These fields were added in CURLVERSION_TWELFTH */ + rtmp_version: cstring, /* human readable string. */ +} + +Ws :: enum i32 { + TEXT = 1 << 0, + BINARY = 1 << 1, + CONT = 1 << 2, + CLOSE = 1 << 3, + PING = 1 << 4, + OFFSET = 1 << 5, + PONG = 1 << 6, +} + +Ws_Frame :: struct { + age: i32, /* zero */ + flags: Ws, + offset: i64, /* the offset of this data into the frame */ + bytesleft: i64, /* number of pending bytes left of the payload */ + len: uint, /* size of the current data chunk */ +} + +Global_Flags :: enum long { + NOTHING = 0, + SSL = (1 << 0), /* no purpose since 7.57.0 */ + WIN32 = (1 << 1), + ACK_EINTR = (1 << 2), + ALL = (SSL | WIN32), + DEFAULT = ALL, +} + +Info_Type :: enum i32 { + TEXT = 0, + HEADER_IN, /* 1 */ + HEADER_OUT, /* 2 */ + DATA_IN, /* 3 */ + DATA_OUT, /* 4 */ + SSL_DATA_IN, /* 5 */ + SSL_DATA_OUT, /* 6 */ +} + +Pause_State :: enum i32 { + RECV = (1 << 0), + RECV_CONT = 0, + SEND = (1 << 2), + SEND_CONT = 0, + ALL = (RECV | SEND), + CONT = (RECV_CONT | SEND_CONT), +} + +Http_Post :: struct {} +formget_callback :: proc(userp: rawptr, buf: cstring, len: uint) -> uint + +Form_Code :: enum i32 { + OK, // Deprecated since 7.56.0 + MEMORY, // Deprecated since 7.56.0 + OPTION_TWICE, // Deprecated since 7.56.0 + NULL, // Deprecated since 7.56.0 + UNKNOWN_OPTION, // Deprecated since 7.56.0 + INCOMPLETE, // Deprecated since 7.56.0 + ILLEGAL_ARRAY, // Deprecated since 7.56.0 + /* libcurl was built with form api disabled */ + DISABLED, // Deprecated since 7.56.0 + LAST, /* last */ +} diff --git a/curl_darwin.odin b/curl_darwin.odin new file mode 100644 index 0000000..2556e76 --- /dev/null +++ b/curl_darwin.odin @@ -0,0 +1,2 @@ +package libcurl +fd_set :: struct {} diff --git a/curl_linux.odin b/curl_linux.odin new file mode 100644 index 0000000..2556e76 --- /dev/null +++ b/curl_linux.odin @@ -0,0 +1,2 @@ +package libcurl +fd_set :: struct {} diff --git a/curl_windows.odin b/curl_windows.odin new file mode 100644 index 0000000..4457c20 --- /dev/null +++ b/curl_windows.odin @@ -0,0 +1,4 @@ +package libcurl +import "core:sys/windows" +fd_set :: windows.fd_set +socket_t :: windows.SOCKET \ No newline at end of file diff --git a/examples/basic.odin b/examples/basic.odin new file mode 100644 index 0000000..8700a35 --- /dev/null +++ b/examples/basic.odin @@ -0,0 +1,17 @@ +package examples + +import "core:fmt" +import curl "../" + +main :: proc() { + hCurl := curl.easy_init() + defer curl.easy_cleanup(hCurl) + if hCurl != nil { + curl.easy_setopt(hCurl, .URL, "https://example.com") + curl.easy_setopt(hCurl, .FOLLOWLOCATION, true) + res := curl.easy_perform(hCurl) + if res != .OK { + fmt.eprintln(curl.easy_strerror(res)) + } + } +} diff --git a/examples/debug.c b/examples/debug.c new file mode 100644 index 0000000..f86f884 --- /dev/null +++ b/examples/debug.c @@ -0,0 +1,155 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +/* + * Show how CURLOPT_DEBUGFUNCTION can be used. + * + */ +#include +#include + +struct data { + char trace_ascii; /* 1 or 0 */ +}; + +static +void dump(const char *text, + FILE *stream, unsigned char *ptr, size_t size, + char nohex) +{ + size_t i; + size_t c; + + unsigned int width = 0x40; + + if(nohex) + /* without the hex output, we can fit more on screen */ + width = 0x80; + + fprintf(stream, "%s, %10.10lu bytes (0x%8.8lx)\n", + text, (unsigned long)size, (unsigned long)size); + + for(i = 0; i < size; i += width) { + + fprintf(stream, "%4.4lx: ", (unsigned long)i); + + if(!nohex) { + /* hex not disabled, show it */ + for(c = 0; c < width; c++) + if(i + c < size) + fprintf(stream, "%02x ", ptr[i + c]); + else + fputs(" ", stream); + } + + for(c = 0; (c < width) && (i + c < size); c++) { + /* check for 0D0A; if found, skip past and start a new line of output */ + if(nohex && (i + c + 1 < size) && ptr[i + c] == 0x0D && + ptr[i + c + 1] == 0x0A) { + i += (c + 2 - width); + break; + } + fprintf(stream, "%c", + (ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80) ? ptr[i + c] : '.'); + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if(nohex && (i + c + 2 < size) && ptr[i + c + 1] == 0x0D && + ptr[i + c + 2] == 0x0A) { + i += (c + 3 - width); + break; + } + } + fputc('\n', stream); /* newline */ + } + fflush(stream); +} + +static +int my_trace(CURL *handle, curl_infotype type, + char *data, size_t size, + void *userp) +{ + struct data *config = (struct data *)userp; + const char *text; + (void)handle; /* prevent compiler warning */ + + switch(type) { + case CURLINFO_TEXT: + fprintf(stderr, "== Info: %s", data); + return 0; + case CURLINFO_HEADER_OUT: + text = "=> Send header"; + break; + case CURLINFO_DATA_OUT: + text = "=> Send data"; + break; + case CURLINFO_SSL_DATA_OUT: + text = "=> Send SSL data"; + break; + case CURLINFO_HEADER_IN: + text = "<= Recv header"; + break; + case CURLINFO_DATA_IN: + text = "<= Recv data"; + break; + case CURLINFO_SSL_DATA_IN: + text = "<= Recv SSL data"; + break; + default: /* in case a new one is introduced to shock us */ + return 0; + } + + dump(text, stderr, (unsigned char *)data, size, config->trace_ascii); + return 0; +} + +int main(void) +{ + CURL *curl; + CURLcode res; + struct data config; + + config.trace_ascii = 1; /* enable ASCII tracing */ + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace); + curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &config); + + /* the DEBUGFUNCTION has no effect until we enable VERBOSE */ + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + + /* example.com is redirected, so we tell libcurl to follow redirection */ + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); + res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/examples/debug.odin b/examples/debug.odin new file mode 100644 index 0000000..705d724 --- /dev/null +++ b/examples/debug.odin @@ -0,0 +1,113 @@ +package examples + +import "base:runtime" +import "core:fmt" +import "core:os" +import "core:testing" + +import curl "../" + +data :: struct { + trace_ascii: b8, +} + +dump :: proc "c" (text: cstring, stream: os.Handle, ptr: [^]u8, size: uint, nohex: b8) { + context = runtime.default_context() + width: uint = 0x80 if nohex else 0x40 + + fmt.fprintf(stream, "%s, %10.10d bytes (0x%8.8x)\n", text, u64(size), u64(size)) + + for i: uint = 0; i < size; i += width { + + fmt.fprintf(stream, "%4.4x: ", u64(i)) + + if !nohex { + /* hex not disabled, show it */ + for c: uint = 0; c < width; c += 1 { + if i + c < size do fmt.fprintf(stream, "%02x ", ptr[i + c]) + else do fmt.fprintf(stream, " ") + } + } + + for c: uint = 0; (c < width) && (i + c < size); c += 1 { + /* check for 0D0A; if found, skip past and start a new line of output */ + if nohex && (i + c + 1 < size) && ptr[i + c] == 0x0D && ptr[i + c + 1] == 0x0A { + i += (c + 2 - width) + break + } + fmt.fprintf( + stream, + "%c", + (ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80) ? ptr[i + c] : '.', + ) + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if nohex && (i + c + 2 < size) && ptr[i + c + 1] == 0x0D && ptr[i + c + 2] == 0x0A { + i += (c + 3 - width) + break + } + } + fmt.fprintf(stream, "\n") + } + fmt.fprintf(stream, "", true) +} + +my_trace :: proc "c" ( + handle: curl.Handle, + type: curl.Info_Type, + sdata: cstring, + size: uint, + userp: rawptr, +) -> i32 { + context = runtime.default_context() + + config := cast(^data)userp + text: cstring + + switch type { + case .TEXT: + fmt.fprintf(os.stderr, "== Info: %s", sdata) + return 0 + case .HEADER_OUT: + text = "=> Send header" + case .DATA_OUT: + text = "=> Send data" + case .SSL_DATA_OUT: + text = "=> Send SSL data" + case .HEADER_IN: + text = "<= Recv header" + case .DATA_IN: + text = "<= Recv data" + case .SSL_DATA_IN: + text = "<= Recv SSL data" + case: + return 0 + } + + dump(text, os.stderr, cast([^]u8)sdata, size, config.trace_ascii) + return 0 +} + +@(test) +debug :: proc(t: ^testing.T) { + config: data + + config.trace_ascii = true + + hCurl := curl.easy_init() + if hCurl == nil { + testing.fail_now(t, "failed to init curl") + } + + defer curl.easy_cleanup(hCurl) + + curl.easy_setopt(hCurl, .DEBUGFUNCTION, my_trace) + curl.easy_setopt(hCurl, .DEBUGDATA, &config) + curl.easy_setopt(hCurl, .VERBOSE, 1) + curl.easy_setopt(hCurl, .FOLLOWLOCATION, 1) + curl.easy_setopt(hCurl, .URL, "https://example.com/") + + res := curl.easy_perform(hCurl) + out := fmt.tprintf("curl.easy_perform() failed: %s\n", string(curl.easy_strerror(res))) + // test requires a network connection cuz duh + testing.expect(t, res == .OK, out) +} diff --git a/examples/getinfo.c b/examples/getinfo.c new file mode 100644 index 0000000..9c178c2 --- /dev/null +++ b/examples/getinfo.c @@ -0,0 +1,54 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +/* + * Use getinfo to get content-type after completed transfer. + * + */ +#include +#include + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/"); + res = curl_easy_perform(curl); + + if(CURLE_OK == res) { + char *ct; + /* ask for the content-type */ + res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); + + if((CURLE_OK == res) && ct) + printf("We received Content-Type: %s\n", ct); + } + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} diff --git a/examples/getinfo.odin b/examples/getinfo.odin new file mode 100644 index 0000000..2b90980 --- /dev/null +++ b/examples/getinfo.odin @@ -0,0 +1,24 @@ +package examples + +import "core:fmt" +import "core:testing" + +import curl "../" + +@(test) +getinfo :: proc(t: ^testing.T) { + res: curl.Code + hCurl := curl.easy_init() + if hCurl == nil do testing.fail_now(t, "failed to init curl") + defer curl.easy_cleanup(hCurl); + + curl.easy_setopt(hCurl, .URL, "https://www.example.com/") + res = curl.easy_perform(hCurl); + if res != .OK do testing.fail_now(t, fmt.tprintf("got non-OK response for URL: %v", res)) + + ct: cstring + res = curl.easy_getinfo(hCurl, .CONTENT_TYPE, &ct); + if res != .OK || ct == nil do testing.fail_now(t, "could not read Content-Type") + + testing.expectf(t, true, "Content-Type: %s\n", ct) +} diff --git a/lib/libcurl_a.lib b/lib/libcurl_a.lib new file mode 100644 index 0000000..8e6736f Binary files /dev/null and b/lib/libcurl_a.lib differ