From 76e6470a626dd58ed08d38ab5b8f7627ab8b334f Mon Sep 17 00:00:00 2001 From: wyf <763257820@qq.com> Date: Tue, 6 Dec 2022 16:01:17 +0800 Subject: [PATCH 1/2] add pub func --- rust/rust_ffi/src/ffi_fun/fun_call.rs | 5087 +++++++++++++------------ 1 file changed, 2549 insertions(+), 2538 deletions(-) diff --git a/rust/rust_ffi/src/ffi_fun/fun_call.rs b/rust/rust_ffi/src/ffi_fun/fun_call.rs index 2e8cf78..2c37106 100644 --- a/rust/rust_ffi/src/ffi_fun/fun_call.rs +++ b/rust/rust_ffi/src/ffi_fun/fun_call.rs @@ -12,2541 +12,2552 @@ * Create: 2022-10-31 * Description: extern C function declarations that ffi needed ******************************************************************************/ -use crate::src::ffi_alias::type_alias::*; -use crate::src::ffi_struct::struct_define::*; - -extern "C" { - // keylog.rs - pub fn curl_getenv(variable: *const libc::c_char) -> *mut libc::c_char; - pub fn fclose(__stream: *mut FILE) -> libc::c_int; - pub fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; - pub fn setvbuf( - __stream: *mut FILE, - __buf: *mut libc::c_char, - __modes: libc::c_int, - __n: size_t, - ) -> libc::c_int; - pub fn fputs(__s: *const libc::c_char, __stream: *mut FILE) -> libc::c_int; - pub fn memcpy( - _: *mut libc::c_void, - _: *const libc::c_void, - _: libc::c_ulong, - ) -> *mut libc::c_void; - pub fn strlen(_: *const libc::c_char) -> libc::c_ulong; - - // vtls.rs - pub fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int; - pub fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; - pub fn Curl_safe_strcasecompare( - first: *const libc::c_char, - second: *const libc::c_char, - ) -> libc::c_int; - - // ftp.rs - pub fn Curl_sec_read_msg( - data: *mut Curl_easy, - conn: *mut connectdata, - _: *mut libc::c_char, - _: protection_level, - ) -> libc::c_int; - pub fn Curl_sec_end(_: *mut connectdata); - pub fn Curl_sec_login(_: *mut Curl_easy, _: *mut connectdata) -> CURLcode; - pub fn Curl_sec_request_prot(conn: *mut connectdata, level: *const libc::c_char) - -> libc::c_int; - pub fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - pub fn strncpy( - _: *mut libc::c_char, - _: *const libc::c_char, - _: libc::c_ulong, - ) -> *mut libc::c_char; - pub fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) - -> libc::c_int; - pub fn bind(__fd: libc::c_int, __addr: *const sockaddr, __len: socklen_t) -> libc::c_int; - pub fn getsockname( - __fd: libc::c_int, - __addr: *mut sockaddr, - __len: *mut socklen_t, - ) -> libc::c_int; - pub fn listen(__fd: libc::c_int, __n: libc::c_int) -> libc::c_int; - pub fn accept( - __fd: libc::c_int, - __addr: *mut sockaddr, - __addr_len: *mut socklen_t, - ) -> libc::c_int; - pub fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int; - pub fn Curl_isdigit(c: libc::c_int) -> libc::c_int; - pub fn __errno_location() -> *mut libc::c_int; - pub fn strtol( - _: *const libc::c_char, - _: *mut *mut libc::c_char, - _: libc::c_int, - ) -> libc::c_long; - pub fn strtoul( - _: *const libc::c_char, - _: *mut *mut libc::c_char, - _: libc::c_int, - ) -> libc::c_ulong; - pub fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - pub fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; - pub fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - pub fn curl_easy_strerror(_: CURLcode) -> *const libc::c_char; - pub fn inet_pton( - __af: libc::c_int, - __cp: *const libc::c_char, - __buf: *mut libc::c_void, - ) -> libc::c_int; - pub fn inet_ntop( - __af: libc::c_int, - __cp: *const libc::c_void, - __buf: *mut libc::c_char, - __len: socklen_t, - ) -> *const libc::c_char; - pub fn Curl_now() -> curltime; - pub fn Curl_timediff(t1: curltime, t2: curltime) -> timediff_t; - pub fn Curl_llist_remove(_: *mut Curl_llist, _: *mut Curl_llist_element, _: *mut libc::c_void); - pub fn Curl_resolver_wait_resolv( - data: *mut Curl_easy, - dnsentry: *mut *mut Curl_dns_entry, - ) -> CURLcode; - pub fn Curl_resolv( - data: *mut Curl_easy, - hostname: *const libc::c_char, - port: libc::c_int, - allowDOH: bool, - dnsentry: *mut *mut Curl_dns_entry, - ) -> resolve_t; - pub fn Curl_resolv_unlock(data: *mut Curl_easy, dns: *mut Curl_dns_entry); - pub fn Curl_printable_address( - ip: *const Curl_addrinfo, - buf: *mut libc::c_char, - bufsize: size_t, - ); - pub fn Curl_pp_statemach( - data: *mut Curl_easy, - pp: *mut pingpong, - block: bool, - disconnecting: bool, - ) -> CURLcode; - pub fn Curl_pp_init(data: *mut Curl_easy, pp: *mut pingpong); - pub fn Curl_pp_setup(pp: *mut pingpong); - pub fn Curl_pp_state_timeout( - data: *mut Curl_easy, - pp: *mut pingpong, - disconnecting: bool, - ) -> timediff_t; - pub fn Curl_pp_sendf( - data: *mut Curl_easy, - pp: *mut pingpong, - fmt: *const libc::c_char, - _: ... - ) -> CURLcode; - pub fn Curl_pp_readresp( - data: *mut Curl_easy, - sockfd: curl_socket_t, - pp: *mut pingpong, - code: *mut libc::c_int, - size: *mut size_t, - ) -> CURLcode; - pub fn Curl_pp_flushsend(data: *mut Curl_easy, pp: *mut pingpong) -> CURLcode; - pub fn Curl_pp_disconnect(pp: *mut pingpong) -> CURLcode; - pub fn Curl_pp_getsock( - data: *mut Curl_easy, - pp: *mut pingpong, - socks: *mut curl_socket_t, - ) -> libc::c_int; - pub fn Curl_infof(_: *mut Curl_easy, fmt: *const libc::c_char, _: ...); - pub fn Curl_failf(_: *mut Curl_easy, fmt: *const libc::c_char, _: ...); - pub fn Curl_client_write( - data: *mut Curl_easy, - type_0: libc::c_int, - ptr: *mut libc::c_char, - len: size_t, - ) -> CURLcode; - pub fn Curl_ipv6_scope(sa: *const sockaddr) -> libc::c_uint; - pub fn Curl_if2ip( - af: libc::c_int, - remote_scope: libc::c_uint, - local_scope_id: libc::c_uint, - interf: *const libc::c_char, - buf: *mut libc::c_char, - buf_size: libc::c_int, - ) -> if2ip_result_t; - pub fn Curl_pgrsSetDownloadSize(data: *mut Curl_easy, size: curl_off_t); - pub fn Curl_pgrsSetUploadSize(data: *mut Curl_easy, size: curl_off_t); - pub fn Curl_pgrsSetDownloadCounter(data: *mut Curl_easy, size: curl_off_t); - pub fn Curl_pgrsSetUploadCounter(data: *mut Curl_easy, size: curl_off_t); - pub fn Curl_pgrsUpdate(data: *mut Curl_easy) -> libc::c_int; - pub fn Curl_pgrsTime(data: *mut Curl_easy, timer: timerid) -> curltime; - pub fn Curl_setup_transfer( - data: *mut Curl_easy, - sockindex: libc::c_int, - size: curl_off_t, - getheader: bool, - writesockindex: libc::c_int, - ); - pub fn Curl_urldecode( - data: *mut Curl_easy, - string: *const libc::c_char, - length: size_t, - ostring: *mut *mut libc::c_char, - olen: *mut size_t, - ctrl: urlreject, - ) -> CURLcode; - // definitions in ftplistparser.rs - pub fn Curl_ftp_parselist( - buffer: *mut libc::c_char, - size: size_t, - nmemb: size_t, - connptr: *mut libc::c_void, - ) -> size_t; - pub fn Curl_ftp_parselist_geterror(pl_data: *mut ftp_parselist_data) -> CURLcode; - pub fn Curl_ftp_parselist_data_alloc() -> *mut ftp_parselist_data; - pub fn Curl_ftp_parselist_data_free(pl_data: *mut *mut ftp_parselist_data); - pub fn Curl_range(data: *mut Curl_easy) -> CURLcode; - pub fn curlx_strtoofft( - str: *const libc::c_char, - endp: *mut *mut libc::c_char, - base: libc::c_int, - num: *mut curl_off_t, - ) -> CURLofft; - pub fn Curl_strcasecompare( - first: *const libc::c_char, - second: *const libc::c_char, - ) -> libc::c_int; - pub fn Curl_raw_toupper(in_0: libc::c_char) -> libc::c_char; - pub fn Curl_is_connected( - data: *mut Curl_easy, - conn: *mut connectdata, - sockindex: libc::c_int, - connected: *mut bool, - ) -> CURLcode; - pub fn Curl_connecthost( - data: *mut Curl_easy, - conn: *mut connectdata, - host: *const Curl_dns_entry, - ) -> CURLcode; - pub fn Curl_timeleft( - data: *mut Curl_easy, - nowp: *mut curltime, - duringconnect: bool, - ) -> timediff_t; - pub fn Curl_socket( - data: *mut Curl_easy, - ai: *const Curl_addrinfo, - addr: *mut Curl_sockaddr_ex, - sockfd: *mut curl_socket_t, - ) -> CURLcode; - pub fn curlx_nonblock(sockfd: curl_socket_t, nonblock: libc::c_int) -> libc::c_int; - pub fn Curl_conninfo_remote( - data: *mut Curl_easy, - conn: *mut connectdata, - sockfd: curl_socket_t, - ); - pub fn Curl_closesocket( - data: *mut Curl_easy, - conn: *mut connectdata, - sock: curl_socket_t, - ) -> libc::c_int; - #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] - pub fn Curl_conncontrol(conn: *mut connectdata, closeit: libc::c_int); - #[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] - pub fn Curl_conncontrol( - conn: *mut connectdata, - closeit: libc::c_int, - reason: *const libc::c_char, - ); - pub fn Curl_conn_data_pending(conn: *mut connectdata, sockindex: libc::c_int) -> bool; - pub fn Curl_strerror( - err: libc::c_int, - buf: *mut libc::c_char, - buflen: size_t, - ) -> *const libc::c_char; - pub fn Curl_socket_check( - readfd: curl_socket_t, - readfd2: curl_socket_t, - writefd: curl_socket_t, - timeout_ms: timediff_t, - ) -> libc::c_int; - pub fn Curl_gmtime(intime: time_t, store: *mut tm) -> CURLcode; - pub fn Curl_getdate_capped(p: *const libc::c_char) -> time_t; - pub fn Curl_expire(data: *mut Curl_easy, milli: timediff_t, _: expire_id); - pub fn Curl_set_in_callback(data: *mut Curl_easy, value: bool); - pub fn curlx_ultous(ulnum: libc::c_ulong) -> libc::c_ushort; - pub fn curlx_sltosi(slnum: libc::c_long) -> libc::c_int; - pub fn curlx_sotouz(sonum: curl_off_t) -> size_t; - pub fn Curl_proxyCONNECT( - data: *mut Curl_easy, - tunnelsocket: libc::c_int, - hostname: *const libc::c_char, - remote_port: libc::c_int, - ) -> CURLcode; - pub fn Curl_proxy_connect(data: *mut Curl_easy, sockindex: libc::c_int) -> CURLcode; - pub fn Curl_connect_ongoing(conn: *mut connectdata) -> bool; - pub fn Curl_SOCKS_getsock( - conn: *mut connectdata, - sock: *mut curl_socket_t, - sockindex: libc::c_int, - ) -> libc::c_int; - pub fn curl_msnprintf( - buffer: *mut libc::c_char, - maxlength: size_t, - format: *const libc::c_char, - _: ... - ) -> libc::c_int; - pub fn curl_maprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; - pub fn Curl_isalnum(c: libc::c_int) -> libc::c_int; - pub fn Curl_isspace(c: libc::c_int) -> libc::c_int; - pub fn Curl_llist_insert_next( - _: *mut Curl_llist, - _: *mut Curl_llist_element, - _: *const libc::c_void, - node: *mut Curl_llist_element, - ); - pub fn Curl_fileinfo_alloc() -> *mut fileinfo; - pub fn Curl_fileinfo_cleanup(finfo: *mut fileinfo); - pub fn Curl_fnmatch( - ptr: *mut libc::c_void, - pattern: *const libc::c_char, - string: *const libc::c_char, - ) -> libc::c_int; - // http_aws_sigv4.rs - pub fn time(__timer: *mut time_t) -> time_t; - pub fn strftime( - __s: *mut libc::c_char, - __maxsize: size_t, - __format: *const libc::c_char, - __tp: *const tm, - ) -> size_t; - pub fn Curl_http_method( - data: *mut Curl_easy, - conn: *mut connectdata, - method: *mut *const libc::c_char, - _: *mut Curl_HttpReq, - ); - pub fn Curl_strntoupper(dest: *mut libc::c_char, src: *const libc::c_char, n: size_t); - pub fn Curl_strntolower(dest: *mut libc::c_char, src: *const libc::c_char, n: size_t); - pub fn Curl_memdup(src: *const libc::c_void, buffer_length: size_t) -> *mut libc::c_void; - pub fn Curl_sha256it(outbuffer: *mut libc::c_uchar, input: *const libc::c_uchar, len: size_t); - pub fn Curl_hmacit( - hashparams: *const HMAC_params, - key: *const libc::c_uchar, - keylen: size_t, - data: *const libc::c_uchar, - datalen: size_t, - output: *mut libc::c_uchar, - ) -> CURLcode; - pub fn Curl_checkheaders( - data: *const Curl_easy, - thisheader: *const libc::c_char, - ) -> *mut libc::c_char; - // http_proxy.rs - pub fn curl_strnequal( - s1: *const libc::c_char, - s2: *const libc::c_char, - n: size_t, - ) -> libc::c_int; - pub fn Curl_httpchunk_init(data: *mut Curl_easy); - pub fn Curl_httpchunk_read( - data: *mut Curl_easy, - datap: *mut libc::c_char, - length: ssize_t, - wrote: *mut ssize_t, - passthru: *mut CURLcode, - ) -> CHUNKcode; - pub fn Curl_dyn_init(s: *mut dynbuf, toobig: size_t); - pub fn Curl_dyn_free(s: *mut dynbuf); - pub fn Curl_dyn_addn(s: *mut dynbuf, mem: *const libc::c_void, len: size_t) -> CURLcode; - pub fn Curl_dyn_add(s: *mut dynbuf, str: *const libc::c_char) -> CURLcode; - pub fn Curl_dyn_addf(s: *mut dynbuf, fmt: *const libc::c_char, _: ...) -> CURLcode; - pub fn Curl_dyn_reset(s: *mut dynbuf); - pub fn Curl_dyn_ptr(s: *const dynbuf) -> *mut libc::c_char; - pub fn Curl_dyn_len(s: *const dynbuf) -> size_t; - pub fn Curl_compareheader( - headerline: *const libc::c_char, - header: *const libc::c_char, - content: *const libc::c_char, - ) -> bool; - pub fn Curl_copy_header_value(header: *const libc::c_char) -> *mut libc::c_char; - pub fn Curl_checkProxyheaders( - data: *mut Curl_easy, - conn: *const connectdata, - thisheader: *const libc::c_char, - ) -> *mut libc::c_char; - pub fn Curl_buffer_send( - in_0: *mut dynbuf, - data: *mut Curl_easy, - bytes_written: *mut curl_off_t, - included_body_bytes: curl_off_t, - socketindex: libc::c_int, - ) -> CURLcode; - pub fn Curl_http_input_auth( - data: *mut Curl_easy, - proxy: bool, - auth: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_http_auth_act(data: *mut Curl_easy) -> CURLcode; - pub fn Curl_http_output_auth( - data: *mut Curl_easy, - conn: *mut connectdata, - request: *const libc::c_char, - httpreq: Curl_HttpReq, - path: *const libc::c_char, - proxytunnel: bool, - ) -> CURLcode; - pub fn Curl_read( - data: *mut Curl_easy, - sockfd: curl_socket_t, - buf: *mut libc::c_char, - buffersize: size_t, - n: *mut ssize_t, - ) -> CURLcode; - pub fn Curl_write( - data: *mut Curl_easy, - sockfd: curl_socket_t, - mem: *const libc::c_void, - len: size_t, - written: *mut ssize_t, - ) -> CURLcode; - pub fn Curl_debug( - data: *mut Curl_easy, - type_0: curl_infotype, - ptr: *mut libc::c_char, - size: size_t, - ) -> libc::c_int; - pub fn Curl_fillreadbuffer( - data: *mut Curl_easy, - bytes: size_t, - nreadp: *mut size_t, - ) -> CURLcode; - pub fn Curl_get_upload_buffer(data: *mut Curl_easy) -> CURLcode; - pub fn Curl_isxdigit(c: libc::c_int) -> libc::c_int; - pub fn Curl_unencode_write( - data: *mut Curl_easy, - writer: *mut contenc_writer, - buf: *const libc::c_char, - nbytes: size_t, - ) -> CURLcode; - - // http.rs - pub fn curl_url_cleanup(handle: *mut CURLU); - pub fn curl_url_dup(in_0: *mut CURLU) -> *mut CURLU; - pub fn curl_url_get( - handle: *mut CURLU, - what: CURLUPart, - part: *mut *mut libc::c_char, - flags: libc::c_uint, - ) -> CURLUcode; - pub fn curl_url_set( - handle: *mut CURLU, - what: CURLUPart, - part: *const libc::c_char, - flags: libc::c_uint, - ) -> CURLUcode; - pub fn memmove( - _: *mut libc::c_void, - _: *const libc::c_void, - _: libc::c_ulong, - ) -> *mut libc::c_void; - pub fn memchr(_: *const libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - pub fn curl_mime_headers( - part: *mut curl_mimepart, - headers: *mut curl_slist, - take_ownership: libc::c_int, - ) -> CURLcode; - pub fn Curl_mime_initpart(part: *mut curl_mimepart, easy: *mut Curl_easy); - pub fn Curl_mime_cleanpart(part: *mut curl_mimepart); - pub fn Curl_mime_prepare_headers( - part: *mut curl_mimepart, - contenttype: *const libc::c_char, - disposition: *const libc::c_char, - strategy: mimestrategy, - ) -> CURLcode; - pub fn Curl_mime_size(part: *mut curl_mimepart) -> curl_off_t; - pub fn Curl_mime_read( - buffer: *mut libc::c_char, - size: size_t, - nitems: size_t, - instream: *mut libc::c_void, - ) -> size_t; - pub fn Curl_mime_rewind(part: *mut curl_mimepart) -> CURLcode; - pub fn Curl_cookie_freelist(cookies: *mut Cookie); - pub fn Curl_cookie_getlist( - c: *mut CookieInfo, - host: *const libc::c_char, - path: *const libc::c_char, - secure: bool, - ) -> *mut Cookie; - pub fn Curl_cookie_add( - data: *mut Curl_easy, - c: *mut CookieInfo, - header: bool, - noexpiry: bool, - lineptr: *mut libc::c_char, - domain: *const libc::c_char, - path: *const libc::c_char, - secure: bool, - ) -> *mut Cookie; - pub fn Curl_getformdata( - data: *mut Curl_easy, - _: *mut curl_mimepart, - post: *mut curl_httppost, - fread_func: curl_read_callback, - ) -> CURLcode; - pub fn Curl_rtsp_parseheader(data: *mut Curl_easy, header: *mut libc::c_char) -> CURLcode; - pub fn Curl_readrewind(data: *mut Curl_easy) -> CURLcode; - pub fn Curl_meets_timecondition(data: *mut Curl_easy, timeofdoc: time_t) -> bool; - pub fn Curl_done_sending(data: *mut Curl_easy, k: *mut SingleRequest) -> CURLcode; - pub fn Curl_base64_encode( - data: *mut Curl_easy, - inputbuff: *const libc::c_char, - insize: size_t, - outptr: *mut *mut libc::c_char, - outlen: *mut size_t, - ) -> CURLcode; - pub fn Curl_auth_is_digest_supported() -> bool; - pub fn Curl_input_digest( - data: *mut Curl_easy, - proxy: bool, - header: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_output_digest( - data: *mut Curl_easy, - proxy: bool, - request: *const libc::c_uchar, - uripath: *const libc::c_uchar, - ) -> CURLcode; - pub fn Curl_output_aws_sigv4(data: *mut Curl_easy, proxy: bool) -> CURLcode; - pub fn Curl_share_lock(_: *mut Curl_easy, _: curl_lock_data, _: curl_lock_access) - -> CURLSHcode; - pub fn Curl_share_unlock(_: *mut Curl_easy, _: curl_lock_data) -> CURLSHcode; - pub fn Curl_expire_done(data: *mut Curl_easy, id: expire_id); - pub fn Curl_strncasecompare( - first: *const libc::c_char, - second: *const libc::c_char, - max: size_t, - ) -> libc::c_int; - pub fn Curl_build_unencoding_stack( - data: *mut Curl_easy, - enclist: *const libc::c_char, - maybechunked: libc::c_int, - ) -> CURLcode; - pub fn Curl_unencode_cleanup(data: *mut Curl_easy); - pub fn curlx_uitous(uinum: libc::c_uint) -> libc::c_ushort; - pub fn Curl_http2_request_upgrade(req: *mut dynbuf, data: *mut Curl_easy) -> CURLcode; - pub fn Curl_http2_setup(data: *mut Curl_easy, conn: *mut connectdata) -> CURLcode; - pub fn Curl_http2_switched( - data: *mut Curl_easy, - ptr: *const libc::c_char, - nread: size_t, - ) -> CURLcode; - pub fn Curl_http2_setup_conn(conn: *mut connectdata); - pub fn Curl_http2_setup_req(data: *mut Curl_easy); - pub fn Curl_http2_done(data: *mut Curl_easy, premature: bool); - pub fn Curl_altsvc_parse( - data: *mut Curl_easy, - altsvc: *mut altsvcinfo, - value: *const libc::c_char, - srcalpn: alpnid, - srchost: *const libc::c_char, - srcport: libc::c_ushort, - ) -> CURLcode; - // http_digest.rs - pub fn Curl_auth_decode_digest_http_message( - chlg: *const libc::c_char, - digest: *mut digestdata, - ) -> CURLcode; - pub fn Curl_auth_create_digest_http_message( - data: *mut Curl_easy, - userp: *const libc::c_char, - passwdp: *const libc::c_char, - request: *const libc::c_uchar, - uri: *const libc::c_uchar, - digest: *mut digestdata, - outptr: *mut *mut libc::c_char, - outlen: *mut size_t, - ) -> CURLcode; - pub fn Curl_auth_digest_cleanup(digest: *mut digestdata); - - // http2.rs - pub fn curl_easy_duphandle(curl: *mut CURL) -> *mut CURL; - pub fn curl_url() -> *mut CURLU; - pub fn nghttp2_session_callbacks_new( - callbacks_ptr: *mut *mut nghttp2_session_callbacks, - ) -> libc::c_int; - pub fn nghttp2_session_callbacks_del(callbacks: *mut nghttp2_session_callbacks); - pub fn nghttp2_session_callbacks_set_send_callback( - cbs: *mut nghttp2_session_callbacks, - send_callback_0: nghttp2_send_callback, - ); - pub fn nghttp2_session_callbacks_set_on_frame_recv_callback( - cbs: *mut nghttp2_session_callbacks, - on_frame_recv_callback: nghttp2_on_frame_recv_callback, - ); - pub fn nghttp2_session_callbacks_set_on_data_chunk_recv_callback( - cbs: *mut nghttp2_session_callbacks, - on_data_chunk_recv_callback: nghttp2_on_data_chunk_recv_callback, - ); - pub fn nghttp2_session_callbacks_set_on_stream_close_callback( - cbs: *mut nghttp2_session_callbacks, - on_stream_close_callback: nghttp2_on_stream_close_callback, - ); - pub fn nghttp2_session_callbacks_set_on_begin_headers_callback( - cbs: *mut nghttp2_session_callbacks, - on_begin_headers_callback: nghttp2_on_begin_headers_callback, - ); - pub fn nghttp2_session_callbacks_set_on_header_callback( - cbs: *mut nghttp2_session_callbacks, - on_header_callback: nghttp2_on_header_callback, - ); - pub fn nghttp2_session_callbacks_set_error_callback( - cbs: *mut nghttp2_session_callbacks, - error_callback_0: nghttp2_error_callback, - ); - pub fn nghttp2_session_client_new( - session_ptr: *mut *mut nghttp2_session, - callbacks: *const nghttp2_session_callbacks, - user_data: *mut libc::c_void, - ) -> libc::c_int; - pub fn nghttp2_session_del(session: *mut nghttp2_session); - pub fn nghttp2_session_send(session: *mut nghttp2_session) -> libc::c_int; - pub fn nghttp2_session_mem_recv( - session: *mut nghttp2_session, - in_0: *const uint8_t, - inlen: size_t, - ) -> ssize_t; - pub fn nghttp2_session_resume_data( - session: *mut nghttp2_session, - stream_id: int32_t, - ) -> libc::c_int; - pub fn nghttp2_session_want_read(session: *mut nghttp2_session) -> libc::c_int; - pub fn nghttp2_session_want_write(session: *mut nghttp2_session) -> libc::c_int; - pub fn nghttp2_session_get_stream_user_data( - session: *mut nghttp2_session, - stream_id: int32_t, - ) -> *mut libc::c_void; - pub fn nghttp2_session_set_stream_user_data( - session: *mut nghttp2_session, - stream_id: int32_t, - stream_user_data: *mut libc::c_void, - ) -> libc::c_int; - pub fn nghttp2_session_get_remote_settings( - session: *mut nghttp2_session, - id: nghttp2_settings_id, - ) -> uint32_t; - pub fn nghttp2_session_upgrade2( - session: *mut nghttp2_session, - settings_payload: *const uint8_t, - settings_payloadlen: size_t, - head_request: libc::c_int, - stream_user_data: *mut libc::c_void, - ) -> libc::c_int; - pub fn nghttp2_pack_settings_payload( - buf: *mut uint8_t, - buflen: size_t, - iv: *const nghttp2_settings_entry, - niv: size_t, - ) -> ssize_t; - pub fn nghttp2_strerror(lib_error_code: libc::c_int) -> *const libc::c_char; - pub fn nghttp2_http2_strerror(error_code: uint32_t) -> *const libc::c_char; - pub fn nghttp2_priority_spec_init( - pri_spec: *mut nghttp2_priority_spec, - stream_id: int32_t, - weight: int32_t, - exclusive: libc::c_int, - ); - pub fn nghttp2_submit_request( - session: *mut nghttp2_session, - pri_spec: *const nghttp2_priority_spec, - nva: *const nghttp2_nv, - nvlen: size_t, - data_prd: *const nghttp2_data_provider, - stream_user_data: *mut libc::c_void, - ) -> int32_t; - pub fn nghttp2_submit_priority( - session: *mut nghttp2_session, - flags: uint8_t, - stream_id: int32_t, - pri_spec: *const nghttp2_priority_spec, - ) -> libc::c_int; - pub fn nghttp2_submit_rst_stream( - session: *mut nghttp2_session, - flags: uint8_t, - stream_id: int32_t, - error_code: uint32_t, - ) -> libc::c_int; - pub fn nghttp2_submit_settings( - session: *mut nghttp2_session, - flags: uint8_t, - iv: *const nghttp2_settings_entry, - niv: size_t, - ) -> libc::c_int; - pub fn nghttp2_submit_ping( - session: *mut nghttp2_session, - flags: uint8_t, - opaque_data: *const uint8_t, - ) -> libc::c_int; - pub fn nghttp2_session_check_request_allowed(session: *mut nghttp2_session) -> libc::c_int; - pub fn nghttp2_session_set_local_window_size( - session: *mut nghttp2_session, - flags: uint8_t, - stream_id: int32_t, - window_size: int32_t, - ) -> libc::c_int; - pub fn nghttp2_is_fatal(lib_error_code: libc::c_int) -> libc::c_int; - pub fn nghttp2_version(least_version: libc::c_int) -> *mut nghttp2_info; - pub fn Curl_http(data: *mut Curl_easy, done: *mut bool) -> CURLcode; - pub fn Curl_http_done(data: *mut Curl_easy, _: CURLcode, premature: bool) -> CURLcode; - pub fn Curl_base64url_encode( - data: *mut Curl_easy, - inputbuff: *const libc::c_char, - insize: size_t, - outptr: *mut *mut libc::c_char, - outlen: *mut size_t, - ) -> CURLcode; - pub fn Curl_multi_add_perform( - multi: *mut Curl_multi, - data: *mut Curl_easy, - conn: *mut connectdata, - ) -> CURLMcode; - pub fn Curl_multi_max_concurrent_streams(multi: *mut Curl_multi) -> libc::c_uint; - pub fn Curl_close(datap: *mut *mut Curl_easy) -> CURLcode; - pub fn Curl_connalive(conn: *mut connectdata) -> bool; - pub fn Curl_saferealloc(ptr: *mut libc::c_void, size: size_t) -> *mut libc::c_void; - - // mbedtls ftp - - pub fn Curl_ssl_connect( - data: *mut Curl_easy, - conn: *mut connectdata, - sockindex: libc::c_int, - ) -> CURLcode; - pub fn Curl_ssl_close(data: *mut Curl_easy, conn: *mut connectdata, sockindex: libc::c_int); - pub fn Curl_ssl_shutdown( - data: *mut Curl_easy, - conn: *mut connectdata, - sockindex: libc::c_int, - ) -> CURLcode; - - // http_ntlm.rs - pub fn curl_free(p: *mut libc::c_void); - pub fn Curl_http_auth_cleanup_ntlm_wb(conn: *mut connectdata); - pub fn Curl_base64_decode( - src: *const libc::c_char, - outptr: *mut *mut libc::c_uchar, - outlen: *mut size_t, - ) -> CURLcode; - pub fn Curl_bufref_init(br: *mut bufref); - pub fn Curl_bufref_set( - br: *mut bufref, - ptr: *const libc::c_void, - len: size_t, - dtor: Option ()>, - ); - pub fn Curl_bufref_ptr(br: *const bufref) -> *const libc::c_uchar; - pub fn Curl_bufref_len(br: *const bufref) -> size_t; - pub fn Curl_bufref_free(br: *mut bufref); - #[cfg(USE_NTLM)] - pub fn Curl_auth_create_ntlm_type1_message( - data: *mut Curl_easy, - userp: *const libc::c_char, - passwdp: *const libc::c_char, - service: *const libc::c_char, - host: *const libc::c_char, - ntlm: *mut ntlmdata, - out: *mut bufref, - ) -> CURLcode; - #[cfg(USE_NTLM)] - pub fn Curl_auth_decode_ntlm_type2_message( - data: *mut Curl_easy, - type2: *const bufref, - ntlm: *mut ntlmdata, - ) -> CURLcode; - #[cfg(USE_NTLM)] - pub fn Curl_auth_create_ntlm_type3_message( - data: *mut Curl_easy, - userp: *const libc::c_char, - passwdp: *const libc::c_char, - ntlm: *mut ntlmdata, - out: *mut bufref, - ) -> CURLcode; - #[cfg(USE_NTLM)] - pub fn Curl_auth_cleanup_ntlm(ntlm: *mut ntlmdata); - - // new http_proxy.rs - pub fn Curl_ssl_connect_nonblocking( - data: *mut Curl_easy, - conn: *mut connectdata, - isproxy: bool, - sockindex: libc::c_int, - done: *mut bool, - ) -> CURLcode; - - // http.rs - pub fn Curl_auth_is_ntlm_supported() -> bool; - pub fn Curl_input_ntlm( - data: *mut Curl_easy, - proxy: bool, - header: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_output_ntlm(data: *mut Curl_easy, proxy: bool) -> CURLcode; - pub fn Curl_input_ntlm_wb( - data: *mut Curl_easy, - conn: *mut connectdata, - proxy: bool, - header: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_output_ntlm_wb( - data: *mut Curl_easy, - conn: *mut connectdata, - proxy: bool, - ) -> CURLcode; - pub fn Curl_hsts_parse( - h: *mut hsts, - hostname: *const libc::c_char, - sts: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_auth_is_spnego_supported() -> bool; - pub fn Curl_input_negotiate( - data: *mut Curl_easy, - conn: *mut connectdata, - proxy: bool, - header: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_output_negotiate( - data: *mut Curl_easy, - conn: *mut connectdata, - proxy: bool, - ) -> CURLcode; - - // mbedtls vtls.rs - pub fn fread( - _: *mut libc::c_void, - _: libc::c_ulong, - _: libc::c_ulong, - _: *mut FILE, - ) -> libc::c_ulong; - pub fn fseek(__stream: *mut FILE, __off: libc::c_long, __whence: libc::c_int) -> libc::c_int; - pub fn ftell(__stream: *mut FILE) -> libc::c_long; - - pub fn curl_slist_free_all(_: *mut curl_slist); - pub fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; - - pub fn Curl_slist_append_nodup( - list: *mut curl_slist, - data: *mut libc::c_char, - ) -> *mut curl_slist; - pub fn Curl_recv_plain( - data: *mut Curl_easy, - num: libc::c_int, - buf: *mut libc::c_char, - len: size_t, - code: *mut CURLcode, - ) -> ssize_t; - pub fn Curl_send_plain( - data: *mut Curl_easy, - num: libc::c_int, - mem: *const libc::c_void, - len: size_t, - code: *mut CURLcode, - ) -> ssize_t; - - // mbedtls_threadlock.rs - pub fn pthread_mutex_init( - __mutex: *mut pthread_mutex_t, - __mutexattr: *const pthread_mutexattr_t, - ) -> libc::c_int; - pub fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> libc::c_int; - pub fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; - pub fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; - - // mbedtls.rs - pub fn mbedtls_version_get_number() -> libc::c_uint; - pub fn mbedtls_net_send( - ctx: *mut libc::c_void, - buf: *const libc::c_uchar, - len: size_t, - ) -> libc::c_int; - pub fn mbedtls_net_recv( - ctx: *mut libc::c_void, - buf: *mut libc::c_uchar, - len: size_t, - ) -> libc::c_int; - pub fn mbedtls_ssl_session_free(session: *mut mbedtls_ssl_session); - pub fn mbedtls_ssl_session_init(session: *mut mbedtls_ssl_session); - pub fn mbedtls_ssl_config_free(conf: *mut mbedtls_ssl_config); - pub fn mbedtls_ssl_config_defaults( - conf: *mut mbedtls_ssl_config, - endpoint: libc::c_int, - transport: libc::c_int, - preset: libc::c_int, - ) -> libc::c_int; - pub fn mbedtls_ssl_config_init(conf: *mut mbedtls_ssl_config); - pub fn mbedtls_ssl_free(ssl: *mut mbedtls_ssl_context); - pub fn mbedtls_ssl_write( - ssl: *mut mbedtls_ssl_context, - buf: *const libc::c_uchar, - len: size_t, - ) -> libc::c_int; - pub fn mbedtls_ssl_read( - ssl: *mut mbedtls_ssl_context, - buf: *mut libc::c_uchar, - len: size_t, - ) -> libc::c_int; - pub fn mbedtls_ssl_handshake(ssl: *mut mbedtls_ssl_context) -> libc::c_int; - pub fn mbedtls_ssl_get_session( - ssl: *const mbedtls_ssl_context, - session: *mut mbedtls_ssl_session, - ) -> libc::c_int; - pub fn mbedtls_ssl_get_peer_cert(ssl: *const mbedtls_ssl_context) -> *const mbedtls_x509_crt; - pub fn mbedtls_ssl_get_ciphersuite(ssl: *const mbedtls_ssl_context) -> *const libc::c_char; - pub fn mbedtls_ssl_get_verify_result(ssl: *const mbedtls_ssl_context) -> uint32_t; - pub fn mbedtls_ssl_get_bytes_avail(ssl: *const mbedtls_ssl_context) -> size_t; - pub fn mbedtls_ssl_conf_renegotiation( - conf: *mut mbedtls_ssl_config, - renegotiation: libc::c_int, - ); - pub fn mbedtls_ssl_conf_session_tickets( - conf: *mut mbedtls_ssl_config, - use_tickets: libc::c_int, - ); - pub fn mbedtls_ssl_conf_min_version( - conf: *mut mbedtls_ssl_config, - major: libc::c_int, - minor: libc::c_int, - ); - pub fn mbedtls_ssl_conf_max_version( - conf: *mut mbedtls_ssl_config, - major: libc::c_int, - minor: libc::c_int, - ); - pub fn mbedtls_ssl_get_alpn_protocol(ssl: *const mbedtls_ssl_context) -> *const libc::c_char; - pub fn mbedtls_ssl_conf_alpn_protocols( - conf: *mut mbedtls_ssl_config, - protos: *mut *const libc::c_char, - ) -> libc::c_int; - pub fn mbedtls_ssl_set_hostname( - ssl: *mut mbedtls_ssl_context, - hostname: *const libc::c_char, - ) -> libc::c_int; - pub fn mbedtls_ssl_conf_own_cert( - conf: *mut mbedtls_ssl_config, - own_cert: *mut mbedtls_x509_crt, - pk_key: *mut mbedtls_pk_context, - ) -> libc::c_int; - pub fn mbedtls_ssl_conf_ca_chain( - conf: *mut mbedtls_ssl_config, - ca_chain: *mut mbedtls_x509_crt, - ca_crl: *mut mbedtls_x509_crl, - ); - pub fn mbedtls_ssl_conf_cert_profile( - conf: *mut mbedtls_ssl_config, - profile: *const mbedtls_x509_crt_profile, - ); - pub fn mbedtls_ssl_conf_ciphersuites( - conf: *mut mbedtls_ssl_config, - ciphersuites: *const libc::c_int, - ); - pub fn mbedtls_ssl_set_session( - ssl: *mut mbedtls_ssl_context, - session: *const mbedtls_ssl_session, - ) -> libc::c_int; - pub fn mbedtls_ssl_set_bio( - ssl: *mut mbedtls_ssl_context, - p_bio: *mut libc::c_void, - f_send: Option, - f_recv: Option, - f_recv_timeout: Option, - ); - pub fn mbedtls_ssl_conf_rng( - conf: *mut mbedtls_ssl_config, - f_rng: Option< - unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_uchar, size_t) -> libc::c_int, - >, - p_rng: *mut libc::c_void, - ); - pub fn mbedtls_ssl_conf_authmode(conf: *mut mbedtls_ssl_config, authmode: libc::c_int); - pub fn mbedtls_ssl_setup( - ssl: *mut mbedtls_ssl_context, - conf: *const mbedtls_ssl_config, - ) -> libc::c_int; - pub fn mbedtls_ssl_init(ssl: *mut mbedtls_ssl_context); - pub fn mbedtls_pk_init(ctx: *mut mbedtls_pk_context); - pub fn mbedtls_pk_free(ctx: *mut mbedtls_pk_context); - pub fn mbedtls_pk_can_do( - ctx: *const mbedtls_pk_context, - type_0: mbedtls_pk_type_t, - ) -> libc::c_int; - pub fn mbedtls_pk_parse_key( - ctx: *mut mbedtls_pk_context, - key: *const libc::c_uchar, - keylen: size_t, - pwd: *const libc::c_uchar, - pwdlen: size_t, - ) -> libc::c_int; - pub fn mbedtls_pk_parse_keyfile( - ctx: *mut mbedtls_pk_context, - path: *const libc::c_char, - password: *const libc::c_char, - ) -> libc::c_int; - pub fn mbedtls_pk_write_pubkey_der( - ctx: *mut mbedtls_pk_context, - buf: *mut libc::c_uchar, - size: size_t, - ) -> libc::c_int; - pub fn mbedtls_ssl_list_ciphersuites() -> *const libc::c_int; - pub fn mbedtls_x509_crl_parse_file( - chain: *mut mbedtls_x509_crl, - path: *const libc::c_char, - ) -> libc::c_int; - pub fn mbedtls_x509_crl_init(crl: *mut mbedtls_x509_crl); - pub fn mbedtls_x509_crl_free(crl: *mut mbedtls_x509_crl); - pub fn mbedtls_x509_crt_parse_der( - chain: *mut mbedtls_x509_crt, - buf: *const libc::c_uchar, - buflen: size_t, - ) -> libc::c_int; - pub fn mbedtls_x509_crt_parse( - chain: *mut mbedtls_x509_crt, - buf: *const libc::c_uchar, - buflen: size_t, - ) -> libc::c_int; - pub fn mbedtls_x509_crt_parse_file( - chain: *mut mbedtls_x509_crt, - path: *const libc::c_char, - ) -> libc::c_int; - pub fn mbedtls_x509_crt_parse_path( - chain: *mut mbedtls_x509_crt, - path: *const libc::c_char, - ) -> libc::c_int; - pub fn mbedtls_x509_crt_info( - buf: *mut libc::c_char, - size: size_t, - prefix: *const libc::c_char, - crt: *const mbedtls_x509_crt, - ) -> libc::c_int; - pub fn mbedtls_x509_crt_init(crt: *mut mbedtls_x509_crt); - pub fn mbedtls_x509_crt_free(crt: *mut mbedtls_x509_crt); - pub fn mbedtls_strerror(errnum: libc::c_int, buffer: *mut libc::c_char, buflen: size_t); - pub fn mbedtls_entropy_init(ctx: *mut mbedtls_entropy_context); - pub fn mbedtls_entropy_free(ctx: *mut mbedtls_entropy_context); - pub fn mbedtls_entropy_func( - data: *mut libc::c_void, - output: *mut libc::c_uchar, - len: size_t, - ) -> libc::c_int; - pub fn mbedtls_ctr_drbg_init(ctx: *mut mbedtls_ctr_drbg_context); - pub fn mbedtls_ctr_drbg_seed( - ctx: *mut mbedtls_ctr_drbg_context, - f_entropy: Option< - unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_uchar, size_t) -> libc::c_int, - >, - p_entropy: *mut libc::c_void, - custom: *const libc::c_uchar, - len: size_t, - ) -> libc::c_int; - pub fn mbedtls_ctr_drbg_free(ctx: *mut mbedtls_ctr_drbg_context); - pub fn mbedtls_ctr_drbg_random( - p_rng: *mut libc::c_void, - output: *mut libc::c_uchar, - output_len: size_t, - ) -> libc::c_int; - pub fn mbedtls_sha256_ret( - input: *const libc::c_uchar, - ilen: size_t, - output: *mut libc::c_uchar, - is224: libc::c_int, - ) -> libc::c_int; - pub fn Curl_multiuse_state(data: *mut Curl_easy, bundlestate: libc::c_int); - pub fn Curl_mbedtlsthreadlock_thread_setup() -> libc::c_int; - pub fn Curl_mbedtlsthreadlock_thread_cleanup() -> libc::c_int; - pub fn Curl_mbedtlsthreadlock_lock_function(n: libc::c_int) -> libc::c_int; - pub fn Curl_mbedtlsthreadlock_unlock_function(n: libc::c_int) -> libc::c_int; - - // gnutls gnutls.rs - pub fn send( - __fd: libc::c_int, - __buf: *const libc::c_void, - __n: size_t, - __flags: libc::c_int, - ) -> ssize_t; - pub fn recv( - __fd: libc::c_int, - __buf: *mut libc::c_void, - __n: size_t, - __flags: libc::c_int, - ) -> ssize_t; - pub fn gnutls_pk_algorithm_get_name(algorithm: gnutls_pk_algorithm_t) -> *const libc::c_char; - pub fn gnutls_init(session: *mut gnutls_session_t, flags: libc::c_uint) -> libc::c_int; - pub fn gnutls_deinit(session: gnutls_session_t); - pub fn gnutls_bye(session: gnutls_session_t, how: gnutls_close_request_t) -> libc::c_int; - pub fn gnutls_handshake(session: gnutls_session_t) -> libc::c_int; - pub fn gnutls_alert_get(session: gnutls_session_t) -> gnutls_alert_description_t; - pub fn gnutls_alert_get_name(alert: gnutls_alert_description_t) -> *const libc::c_char; - pub fn gnutls_cipher_get(session: gnutls_session_t) -> gnutls_cipher_algorithm_t; - pub fn gnutls_kx_get(session: gnutls_session_t) -> gnutls_kx_algorithm_t; - pub fn gnutls_mac_get(session: gnutls_session_t) -> gnutls_mac_algorithm_t; - pub fn gnutls_error_is_fatal(error: libc::c_int) -> libc::c_int; - pub fn gnutls_strerror(error: libc::c_int) -> *const libc::c_char; - pub fn gnutls_record_send( - session: gnutls_session_t, - data: *const libc::c_void, - data_size: size_t, - ) -> ssize_t; - pub fn gnutls_record_recv( - session: gnutls_session_t, - data: *mut libc::c_void, - data_size: size_t, - ) -> ssize_t; - pub fn gnutls_record_get_direction(session: gnutls_session_t) -> libc::c_int; - pub fn gnutls_record_check_pending(session: gnutls_session_t) -> size_t; - pub fn gnutls_server_name_set( - session: gnutls_session_t, - type_0: gnutls_server_name_type_t, - name: *const libc::c_void, - name_length: size_t, - ) -> libc::c_int; - pub fn gnutls_alpn_get_selected_protocol( - session: gnutls_session_t, - protocol: *mut gnutls_datum_t, - ) -> libc::c_int; - pub fn gnutls_alpn_set_protocols( - session: gnutls_session_t, - protocols: *const gnutls_datum_t, - protocols_size: libc::c_uint, - flags: libc::c_uint, - ) -> libc::c_int; - pub fn gnutls_priority_set_direct( - session: gnutls_session_t, - priorities: *const libc::c_char, - err_pos: *mut *const libc::c_char, - ) -> libc::c_int; - pub fn gnutls_set_default_priority(session: gnutls_session_t) -> libc::c_int; - pub fn gnutls_cipher_suite_get_name( - kx_algorithm: gnutls_kx_algorithm_t, - cipher_algorithm: gnutls_cipher_algorithm_t, - mac_algorithm: gnutls_mac_algorithm_t, - ) -> *const libc::c_char; - pub fn gnutls_protocol_get_version(session: gnutls_session_t) -> gnutls_protocol_t; - pub fn gnutls_protocol_get_name(version: gnutls_protocol_t) -> *const libc::c_char; - pub fn gnutls_session_set_data( - session: gnutls_session_t, - session_data: *const libc::c_void, - session_data_size: size_t, - ) -> libc::c_int; - pub fn gnutls_session_get_data( - session: gnutls_session_t, - session_data: *mut libc::c_void, - session_data_size: *mut size_t, - ) -> libc::c_int; - pub fn gnutls_check_version(req_version: *const libc::c_char) -> *const libc::c_char; - pub fn gnutls_credentials_set( - session: gnutls_session_t, - type_0: gnutls_credentials_type_t, - cred: *mut libc::c_void, - ) -> libc::c_int; - pub fn gnutls_certificate_free_credentials(sc: gnutls_certificate_credentials_t); - pub fn gnutls_certificate_allocate_credentials( - res: *mut gnutls_certificate_credentials_t, - ) -> libc::c_int; - pub fn gnutls_certificate_set_verify_flags( - res: gnutls_certificate_credentials_t, - flags: libc::c_uint, - ); - pub fn gnutls_certificate_set_x509_trust_file( - cred: gnutls_certificate_credentials_t, - cafile: *const libc::c_char, - type_0: gnutls_x509_crt_fmt_t, - ) -> libc::c_int; - pub fn gnutls_certificate_set_x509_trust_dir( - cred: gnutls_certificate_credentials_t, - ca_dir: *const libc::c_char, - type_0: gnutls_x509_crt_fmt_t, - ) -> libc::c_int; - pub fn gnutls_certificate_set_x509_crl_file( - res: gnutls_certificate_credentials_t, - crlfile: *const libc::c_char, - type_0: gnutls_x509_crt_fmt_t, - ) -> libc::c_int; - pub fn gnutls_certificate_set_x509_key_file( - res: gnutls_certificate_credentials_t, - certfile: *const libc::c_char, - keyfile: *const libc::c_char, - type_0: gnutls_x509_crt_fmt_t, - ) -> libc::c_int; - pub fn gnutls_certificate_set_x509_key_file2( - res: gnutls_certificate_credentials_t, - certfile: *const libc::c_char, - keyfile: *const libc::c_char, - type_0: gnutls_x509_crt_fmt_t, - pass: *const libc::c_char, - flags: libc::c_uint, - ) -> libc::c_int; - pub fn gnutls_ocsp_status_request_enable_client( - session: gnutls_session_t, - responder_id: *mut gnutls_datum_t, - responder_id_size: size_t, - request_extensions: *mut gnutls_datum_t, - ) -> libc::c_int; - pub fn gnutls_ocsp_status_request_get( - session: gnutls_session_t, - response: *mut gnutls_datum_t, - ) -> libc::c_int; - pub fn gnutls_ocsp_status_request_is_checked( - session: gnutls_session_t, - flags: libc::c_uint, - ) -> libc::c_uint; - pub fn gnutls_global_init() -> libc::c_int; - pub fn gnutls_global_deinit(); - static mut gnutls_free: gnutls_free_function; - pub fn gnutls_transport_set_ptr(session: gnutls_session_t, ptr: gnutls_transport_ptr_t); - pub fn gnutls_transport_set_push_function( - session: gnutls_session_t, - push_func: gnutls_push_func, - ); - pub fn gnutls_transport_set_pull_function( - session: gnutls_session_t, - pull_func: gnutls_pull_func, - ); - pub fn gnutls_srp_free_client_credentials(sc: gnutls_srp_client_credentials_t); - pub fn gnutls_srp_allocate_client_credentials( - sc: *mut gnutls_srp_client_credentials_t, - ) -> libc::c_int; - pub fn gnutls_srp_set_client_credentials( - res: gnutls_srp_client_credentials_t, - username: *const libc::c_char, - password: *const libc::c_char, - ) -> libc::c_int; - pub fn gnutls_certificate_get_peers( - session: gnutls_session_t, - list_size: *mut libc::c_uint, - ) -> *const gnutls_datum_t; - pub fn gnutls_certificate_verify_peers2( - session: gnutls_session_t, - status: *mut libc::c_uint, - ) -> libc::c_int; - pub fn gnutls_pubkey_export( - key: gnutls_pubkey_t, - format: gnutls_x509_crt_fmt_t, - output_data: *mut libc::c_void, - output_data_size: *mut size_t, - ) -> libc::c_int; - pub fn gnutls_x509_crt_init(cert: *mut gnutls_x509_crt_t) -> libc::c_int; - pub fn gnutls_x509_crt_deinit(cert: gnutls_x509_crt_t); - pub fn gnutls_x509_crt_import( - cert: gnutls_x509_crt_t, - data: *const gnutls_datum_t, - format: gnutls_x509_crt_fmt_t, - ) -> libc::c_int; - pub fn gnutls_x509_crt_get_issuer_dn2( - cert: gnutls_x509_crt_t, - dn: *mut gnutls_datum_t, - ) -> libc::c_int; - pub fn gnutls_x509_crt_get_dn2(cert: gnutls_x509_crt_t, dn: *mut gnutls_datum_t) - -> libc::c_int; - pub fn gnutls_x509_crt_get_dn_by_oid( - cert: gnutls_x509_crt_t, - oid: *const libc::c_char, - indx: libc::c_uint, - raw_flag: libc::c_uint, - buf: *mut libc::c_void, - buf_size: *mut size_t, - ) -> libc::c_int; - pub fn gnutls_x509_crt_check_hostname( - cert: gnutls_x509_crt_t, - hostname: *const libc::c_char, - ) -> libc::c_uint; - pub fn gnutls_x509_crt_get_version(cert: gnutls_x509_crt_t) -> libc::c_int; - pub fn gnutls_x509_crt_get_activation_time(cert: gnutls_x509_crt_t) -> time_t; - pub fn gnutls_x509_crt_get_expiration_time(cert: gnutls_x509_crt_t) -> time_t; - pub fn gnutls_x509_crt_get_pk_algorithm( - cert: gnutls_x509_crt_t, - bits: *mut libc::c_uint, - ) -> libc::c_int; - pub fn gnutls_x509_crt_check_issuer( - cert: gnutls_x509_crt_t, - issuer: gnutls_x509_crt_t, - ) -> libc::c_uint; - pub fn gnutls_pubkey_import_x509( - key: gnutls_pubkey_t, - crt: gnutls_x509_crt_t, - flags: libc::c_uint, - ) -> libc::c_int; - pub fn gnutls_pubkey_deinit(key: gnutls_pubkey_t); - pub fn gnutls_pubkey_init(key: *mut gnutls_pubkey_t) -> libc::c_int; - pub fn gnutls_rnd( - level: gnutls_rnd_level_t, - data: *mut libc::c_void, - len: size_t, - ) -> libc::c_int; - pub fn nettle_sha256_digest(ctx: *mut sha256_ctx, length: size_t, digest: *mut uint8_t); - pub fn nettle_sha256_update(ctx: *mut sha256_ctx, length: size_t, data: *const uint8_t); - pub fn nettle_sha256_init(ctx: *mut sha256_ctx); - pub fn Curl_extract_certinfo( - data: *mut Curl_easy, - certnum: libc::c_int, - beg: *const libc::c_char, - end: *const libc::c_char, - ) -> CURLcode; - - pub fn gnutls_ocsp_resp_init(resp: *mut gnutls_ocsp_resp_t) -> libc::c_int; - pub fn gnutls_ocsp_resp_deinit(resp: gnutls_ocsp_resp_t); - pub fn gnutls_ocsp_resp_import( - resp: gnutls_ocsp_resp_t, - data: *const gnutls_datum_t, - ) -> libc::c_int; - pub fn gnutls_ocsp_resp_get_single( - resp: gnutls_ocsp_resp_const_t, - indx: libc::c_uint, - digest: *mut gnutls_digest_algorithm_t, - issuer_name_hash: *mut gnutls_datum_t, - issuer_key_hash: *mut gnutls_datum_t, - serial_number: *mut gnutls_datum_t, - cert_status: *mut libc::c_uint, - this_update: *mut time_t, - next_update: *mut time_t, - revocation_time: *mut time_t, - revocation_reason: *mut libc::c_uint, - ) -> libc::c_int; - - // wolfssl.rs - - // pub fn Curl_none_check_cxn(conn: *mut connectdata) -> libc::c_int; - // pub fn Curl_none_close_all(data: *mut Curl_easy); - // pub fn Curl_none_set_engine( - // data: *mut Curl_easy, - // engine: *const libc::c_char, - // ) -> CURLcode; - // pub fn Curl_none_set_engine_default(data: *mut Curl_easy) -> CURLcode; - // pub fn Curl_none_engines_list(data: *mut Curl_easy) -> *mut curl_slist; - // pub fn Curl_none_false_start() -> bool; - // pub fn Curl_ssl_getsock( - // conn: *mut connectdata, - // socks: *mut curl_socket_t, - // ) -> libc::c_int; - // pub fn Curl_ssl_sessionid_lock(data: *mut Curl_easy); - // pub fn Curl_ssl_sessionid_unlock(data: *mut Curl_easy); - // pub fn Curl_ssl_getsessionid( - // data: *mut Curl_easy, - // conn: *mut connectdata, - // isProxy: bool, - // ssl_sessionid: *mut *mut libc::c_void, - // idsize: *mut size_t, - // sockindex: libc::c_int, - // ) -> bool; - // pub fn Curl_ssl_addsessionid( - // data: *mut Curl_easy, - // conn: *mut connectdata, - // isProxy: bool, - // ssl_sessionid: *mut libc::c_void, - // idsize: size_t, - // sockindex: libc::c_int, - // ) -> CURLcode; - // pub fn Curl_ssl_delsessionid(data: *mut Curl_easy, ssl_sessionid: *mut libc::c_void); - // pub fn Curl_pin_peer_pubkey( - // data: *mut Curl_easy, - // pinnedpubkey: *const libc::c_char, - // pubkey: *const libc::c_uchar, - // pubkeylen: size_t, - // ) -> CURLcode; - // pub fn Curl_tls_keylog_open(); - // pub fn Curl_tls_keylog_close(); - // pub fn Curl_tls_keylog_enabled() -> bool; - // pub fn Curl_tls_keylog_write( - // label: *const libc::c_char, - // client_random: *const libc::c_uchar, - // secret: *const libc::c_uchar, - // secretlen: size_t, - // ) -> bool; - pub fn Curl_parseX509( - cert: *mut Curl_X509certificate, - beg: *const libc::c_char, - end: *const libc::c_char, - ) -> libc::c_int; - pub fn wolfSSL_CTX_set_verify( - _: *mut WOLFSSL_CTX, - _: libc::c_int, - verify_callback: VerifyCallback, - ); - pub fn wolfSSL_CTX_use_PrivateKey_file( - _: *mut WOLFSSL_CTX, - _: *const libc::c_char, - _: libc::c_int, - ) -> libc::c_int; - pub fn wolfSSL_CTX_use_certificate_file( - _: *mut WOLFSSL_CTX, - _: *const libc::c_char, - _: libc::c_int, - ) -> libc::c_int; - pub fn wolfSSL_CTX_load_verify_locations( - _: *mut WOLFSSL_CTX, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> libc::c_int; - pub fn wolfSSL_CTX_set_cipher_list(_: *mut WOLFSSL_CTX, _: *const libc::c_char) -> libc::c_int; - pub fn wolfSSL_CTX_SetMinVersion(ctx: *mut WOLFSSL_CTX, version: libc::c_int) -> libc::c_int; - pub fn wolfSSL_CTX_new(_: *mut WOLFSSL_METHOD) -> *mut WOLFSSL_CTX; - pub fn wolfTLSv1_2_client_method() -> *mut WOLFSSL_METHOD; - pub fn wolfTLSv1_1_client_method() -> *mut WOLFSSL_METHOD; - pub fn wolfSSLv23_client_method() -> *mut WOLFSSL_METHOD; - pub fn wc_FreeRng(_: *mut WC_RNG) -> libc::c_int; - pub fn wc_RNG_GenerateBlock(_: *mut WC_RNG, _: *mut byte, sz: word32) -> libc::c_int; - pub fn wc_InitRng(_: *mut WC_RNG) -> libc::c_int; - pub fn wolfSSL_pending(_: *mut WOLFSSL) -> libc::c_int; - pub fn wolfSSL_lib_version() -> *const libc::c_char; - pub fn wolfSSL_Cleanup() -> libc::c_int; - pub fn wolfSSL_Init() -> libc::c_int; - pub fn wolfSSL_check_domain_name(ssl: *mut WOLFSSL, dn: *const libc::c_char) -> libc::c_int; - pub fn wolfSSL_new(_: *mut WOLFSSL_CTX) -> *mut WOLFSSL; - pub fn wolfSSL_KeepArrays(_: *mut WOLFSSL); - pub fn wolfSSL_set_session(ssl: *mut WOLFSSL, session: *mut WOLFSSL_SESSION) -> libc::c_int; - pub fn wolfSSL_set_fd(_: *mut WOLFSSL, _: libc::c_int) -> libc::c_int; - pub fn wolfSSL_connect(_: *mut WOLFSSL) -> libc::c_int; - pub fn wolfSSL_want_read(_: *mut WOLFSSL) -> libc::c_int; - pub fn wolfSSL_want_write(_: *mut WOLFSSL) -> libc::c_int; - pub fn wolfSSL_GetVersion(ssl: *mut WOLFSSL) -> libc::c_int; - pub fn wolfSSL_get_keys( - _: *mut WOLFSSL, - ms: *mut *mut libc::c_uchar, - msLen: *mut libc::c_uint, - sr: *mut *mut libc::c_uchar, - srLen: *mut libc::c_uint, - cr: *mut *mut libc::c_uchar, - crLen: *mut libc::c_uint, - ) -> libc::c_int; - pub fn wolfSSL_FreeArrays(_: *mut WOLFSSL); - pub fn wolfSSL_get_peer_certificate(ssl: *mut WOLFSSL) -> *mut WOLFSSL_X509; - pub fn wolfSSL_X509_get_der(_: *mut WOLFSSL_X509, _: *mut libc::c_int) -> *const libc::c_uchar; - pub fn wolfSSL_get_version(_: *mut WOLFSSL) -> *const libc::c_char; - pub fn wolfSSL_get_cipher_name(ssl: *mut WOLFSSL) -> *const libc::c_char; - pub fn wolfSSL_get_session(ssl: *mut WOLFSSL) -> *mut WOLFSSL_SESSION; - pub fn wolfSSL_ERR_clear_error(); - pub fn wolfSSL_write(_: *mut WOLFSSL, _: *const libc::c_void, _: libc::c_int) -> libc::c_int; - pub fn wolfSSL_ERR_error_string(_: libc::c_ulong, _: *mut libc::c_char) -> *mut libc::c_char; - pub fn wolfSSL_get_error(_: *mut WOLFSSL, _: libc::c_int) -> libc::c_int; - pub fn wolfSSL_read(_: *mut WOLFSSL, _: *mut libc::c_void, _: libc::c_int) -> libc::c_int; - pub fn wolfSSL_shutdown(_: *mut WOLFSSL) -> libc::c_int; - pub fn wolfSSL_free(_: *mut WOLFSSL); - pub fn wolfSSL_CTX_free(_: *mut WOLFSSL_CTX); - pub fn wc_InitSha256(_: *mut wc_Sha256) -> libc::c_int; - pub fn wc_Sha256Update(_: *mut wc_Sha256, _: *const byte, _: word32) -> libc::c_int; - pub fn wc_Sha256Final(_: *mut wc_Sha256, _: *mut byte) -> libc::c_int; - - // nss.rs - pub fn __xstat( - __ver: libc::c_int, - __filename: *const libc::c_char, - __stat_buf: *mut stat, - ) -> libc::c_int; - pub fn getenv(__name: *const libc::c_char) -> *mut libc::c_char; - pub fn Curl_llist_destroy(_: *mut Curl_llist, _: *mut libc::c_void); - // pub fn Curl_ssl_init_certinfo(data: *mut Curl_easy, num: libc::c_int) -> CURLcode; - // pub fn Curl_pin_peer_pubkey( - // data: *mut Curl_easy, - // pinnedpubkey: *const libc::c_char, - // pubkey: *const libc::c_uchar, - // pubkeylen: size_t, - // ) -> CURLcode; - pub fn PR_ErrorToName(code: PRErrorCode) -> *const libc::c_char; - pub fn PR_GetError() -> PRErrorCode; - pub fn PR_Lock(lock: *mut PRLock); - pub fn PR_ErrorToString(code: PRErrorCode, language: PRLanguageCode) -> *const libc::c_char; - pub fn PR_Now() -> PRTime; - pub fn PR_Free(ptr: *mut libc::c_void); - pub fn PR_FormatTime( - buf: *mut libc::c_char, - buflen: libc::c_int, - fmt: *const libc::c_char, - time: *const PRExplodedTime, - ) -> PRUint32; - pub fn PR_GMTParameters(gmt: *const PRExplodedTime) -> PRTimeParameters; - pub fn PR_ExplodeTime(usecs: PRTime, params: PRTimeParamFn, exploded: *mut PRExplodedTime); - pub fn PR_Unlock(lock: *mut PRLock) -> PRStatus; - pub fn PR_MillisecondsToInterval(milli: PRUint32) -> PRIntervalTime; - pub fn PR_Init(type_0: PRThreadType, priority: PRThreadPriority, maxPTDs: PRUintn); - pub fn PR_SetError(errorCode: PRErrorCode, oserr: PRInt32); - pub fn PR_NewLock() -> *mut PRLock; - pub fn PR_DestroyLock(lock: *mut PRLock); - pub fn PR_SecondsToInterval(seconds: PRUint32) -> PRIntervalTime; - pub fn PR_GetOpenFileInfo(fd: *mut PRFileDesc, info: *mut PRFileInfo) -> PRStatus; - pub fn PR_OpenDir(name: *const libc::c_char) -> *mut PRDir; - pub fn PR_CloseDir(dir: *mut PRDir) -> PRStatus; - pub fn PR_Read(fd: *mut PRFileDesc, buf: *mut libc::c_void, amount: PRInt32) -> PRInt32; - pub fn PR_ReadDir(dir: *mut PRDir, flags: PRDirFlags) -> *mut PRDirEntry; - pub fn PR_GetDefaultIOMethods() -> *const PRIOMethods; - pub fn PR_Close(fd: *mut PRFileDesc) -> PRStatus; - pub fn PR_PushIOLayer( - fd_stack: *mut PRFileDesc, - id: PRDescIdentity, - layer: *mut PRFileDesc, - ) -> PRStatus; - pub fn PR_CreateIOLayerStub( - ident: PRDescIdentity, - methods: *const PRIOMethods, - ) -> *mut PRFileDesc; - pub fn PR_GetUniqueIdentity(layer_name: *const libc::c_char) -> PRDescIdentity; - pub fn PR_Open(name: *const libc::c_char, flags: PRIntn, mode: PRIntn) -> *mut PRFileDesc; - pub fn PR_NewTCPSocket() -> *mut PRFileDesc; - pub fn PR_Recv( - fd: *mut PRFileDesc, - buf: *mut libc::c_void, - amount: PRInt32, - flags: PRIntn, - timeout: PRIntervalTime, - ) -> PRInt32; - pub fn PR_Send( - fd: *mut PRFileDesc, - buf: *const libc::c_void, - amount: PRInt32, - flags: PRIntn, - timeout: PRIntervalTime, - ) -> PRInt32; - pub fn PR_SetSocketOption(fd: *mut PRFileDesc, data: *const PRSocketOptionData) -> PRStatus; - pub fn NSS_ShutdownContext(_: *mut NSSInitContext) -> SECStatus; - pub fn NSS_GetVersion() -> *const libc::c_char; - pub fn PORT_Strdup(s: *const libc::c_char) -> *mut libc::c_char; - pub fn NSS_InitContext( - configdir: *const libc::c_char, - certPrefix: *const libc::c_char, - keyPrefix: *const libc::c_char, - secmodName: *const libc::c_char, - initParams: *mut NSSInitParameters, - flags: PRUint32, - ) -> *mut NSSInitContext; - pub fn SSL_VersionRangeGetDefault( - protocolVariant: SSLProtocolVariant, - vrange: *mut SSLVersionRange, - ) -> SECStatus; - pub fn SSL_VersionRangeGetSupported( - protocolVariant: SSLProtocolVariant, - vrange: *mut SSLVersionRange, - ) -> SECStatus; - pub fn SSL_VersionRangeSet(fd: *mut PRFileDesc, vrange: *const SSLVersionRange) -> SECStatus; - pub fn SSL_GetNumImplementedCiphers() -> PRUint16; - pub fn SSL_GetImplementedCiphers() -> *const PRUint16; - pub fn SSL_CipherPrefSet(fd: *mut PRFileDesc, cipher: PRInt32, enabled: PRBool) -> SECStatus; - pub fn SSL_AuthCertificateHook( - fd: *mut PRFileDesc, - f: SSLAuthCertificate, - arg: *mut libc::c_void, - ) -> SECStatus; - pub fn SSL_PeerStapledOCSPResponses(fd: *mut PRFileDesc) -> *const SECItemArray; - pub fn SSL_AuthCertificate( - arg: *mut libc::c_void, - fd: *mut PRFileDesc, - checkSig: PRBool, - isServer: PRBool, - ) -> SECStatus; - pub fn SSL_BadCertHook( - fd: *mut PRFileDesc, - f: SSLBadCertHandler, - arg: *mut libc::c_void, - ) -> SECStatus; - pub fn SSL_GetNextProto( - fd: *mut PRFileDesc, - state: *mut SSLNextProtoState, - buf: *mut libc::c_uchar, - bufLen: *mut libc::c_uint, - bufLenMax: libc::c_uint, - ) -> SECStatus; - pub fn SECITEM_AllocItem( - arena: *mut PLArenaPool, - item: *mut SECItem, - len: libc::c_uint, - ) -> *mut SECItem; - pub fn CERT_CacheCRL(dbhandle: *mut CERTCertDBHandle, newcrl: *mut SECItem) -> SECStatus; - pub fn CERT_UncacheCRL(dbhandle: *mut CERTCertDBHandle, oldcrl: *mut SECItem) -> SECStatus; - pub fn CERT_GetDefaultCertDB() -> *mut CERTCertDBHandle; - pub fn SSL_ClearSessionCache(); - pub fn SSL_GetClientAuthDataHook( - fd: *mut PRFileDesc, - f: SSLGetClientAuthData, - a: *mut libc::c_void, - ) -> SECStatus; - pub fn SSL_SetSockPeerID(fd: *mut PRFileDesc, peerID: *const libc::c_char) -> SECStatus; - pub fn NSS_GetClientAuthData( - arg: *mut libc::c_void, - socket: *mut PRFileDesc, - caNames: *mut CERTDistNamesStr, - pRetCert: *mut *mut CERTCertificateStr, - pRetKey: *mut *mut SECKEYPrivateKeyStr, - ) -> SECStatus; - pub fn SSL_ImportFD(model: *mut PRFileDesc, fd: *mut PRFileDesc) -> *mut PRFileDesc; - pub fn SSL_SetPKCS11PinArg(fd: *mut PRFileDesc, a: *mut libc::c_void) -> SECStatus; - pub fn SSL_OptionSet(fd: *mut PRFileDesc, option: PRInt32, val: PRIntn) -> SECStatus; - pub fn SSL_SetCanFalseStartCallback( - fd: *mut PRFileDesc, - callback: SSLCanFalseStartCallback, - arg: *mut libc::c_void, - ) -> SECStatus; - pub fn SSL_HandshakeNegotiatedExtension( - socket: *mut PRFileDesc, - extId: SSLExtensionType, - yes: *mut PRBool, - ) -> SECStatus; - pub fn SSL_SetNextProtoNego( - fd: *mut PRFileDesc, - data: *const libc::c_uchar, - length: libc::c_uint, - ) -> SECStatus; - pub fn SSL_ResetHandshake(fd: *mut PRFileDesc, asServer: PRBool) -> SECStatus; - pub fn SSL_SetURL(fd: *mut PRFileDesc, url: *const libc::c_char) -> SECStatus; - pub fn SSL_ForceHandshakeWithTimeout(fd: *mut PRFileDesc, timeout: PRIntervalTime) - -> SECStatus; - pub fn SSL_GetChannelInfo( - fd: *mut PRFileDesc, - info: *mut SSLChannelInfo, - len: PRUintn, - ) -> SECStatus; - pub fn SSL_GetCipherSuiteInfo( - cipherSuite: PRUint16, - info: *mut SSLCipherSuiteInfo, - len: PRUintn, - ) -> SECStatus; - pub fn CERT_NameToAscii(name: *mut CERTName) -> *mut libc::c_char; - pub fn CERT_GetCommonName(name: *const CERTName) -> *mut libc::c_char; - pub fn CERT_GetCertTimes( - c: *const CERTCertificate, - notBefore: *mut PRTime, - notAfter: *mut PRTime, - ) -> SECStatus; - pub fn CERT_FindCertIssuer( - cert: *mut CERTCertificate, - validTime: PRTime, - usage: SECCertUsage, - ) -> *mut CERTCertificate; - pub fn SSL_RevealPinArg(socket: *mut PRFileDesc) -> *mut libc::c_void; - pub fn SECITEM_CompareItem(a: *const SECItem, b: *const SECItem) -> SECComparison; - pub fn SSL_PeerCertificate(fd: *mut PRFileDesc) -> *mut CERTCertificate; - pub fn SECKEY_DestroyPublicKey(key: *mut SECKEYPublicKey); - pub fn CERT_ExtractPublicKey(cert: *mut CERTCertificate) -> *mut SECKEYPublicKey; - pub fn CERT_DestroyCertificate(cert: *mut CERTCertificate); - pub fn SSL_InvalidateSession(fd: *mut PRFileDesc) -> SECStatus; - pub fn SECITEM_FreeItem(zap: *mut SECItem, freeit: PRBool); - pub fn SSL_CipherPolicyGet(cipher: PRInt32, policy: *mut PRInt32) -> SECStatus; - pub fn NSS_SetDomesticPolicy() -> SECStatus; - pub fn SSL_HandshakeCallback( - fd: *mut PRFileDesc, - cb: SSLHandshakeCallback, - client_data: *mut libc::c_void, - ) -> SECStatus; - pub fn SECMOD_LoadUserModule( - moduleSpec: *mut libc::c_char, - parent: *mut SECMODModule, - recurse: PRBool, - ) -> *mut SECMODModule; - pub fn SECMOD_UnloadUserModule(mod_0: *mut SECMODModule) -> SECStatus; - pub fn SECMOD_DestroyModule(module: *mut SECMODModule); - pub fn SECMOD_WaitForAnyTokenEvent( - mod_0: *mut SECMODModule, - flags: libc::c_ulong, - latency: PRIntervalTime, - ) -> *mut PK11SlotInfo; - pub fn PK11_FreeSlot(slot: *mut PK11SlotInfo); - pub fn PK11_SetPasswordFunc(func: PK11PasswordFunc); - pub fn PK11_Authenticate( - slot: *mut PK11SlotInfo, - loadCerts: PRBool, - wincx: *mut libc::c_void, - ) -> SECStatus; - pub fn PK11_FindSlotByName(name: *const libc::c_char) -> *mut PK11SlotInfo; - pub fn PK11_IsPresent(slot: *mut PK11SlotInfo) -> PRBool; - pub fn PK11_GenerateRandom(data: *mut libc::c_uchar, len: libc::c_int) -> SECStatus; - pub fn PK11_FindPrivateKeyFromCert( - slot: *mut PK11SlotInfo, - cert: *mut CERTCertificate, - wincx: *mut libc::c_void, - ) -> *mut SECKEYPrivateKey; - pub fn PK11_DEREncodePublicKey(pubk: *const SECKEYPublicKey) -> *mut SECItem; - pub fn PK11_FindCertFromNickname( - nickname: *const libc::c_char, - wincx: *mut libc::c_void, - ) -> *mut CERTCertificate; - pub fn PK11_FindCertFromDERCertItem( - slot: *mut PK11SlotInfo, - derCert: *const SECItem, - wincx: *mut libc::c_void, - ) -> *mut CERTCertificate; - pub fn PK11_DestroyContext(context: *mut PK11Context, freeit: PRBool); - pub fn PK11_CreateDigestContext(hashAlg: SECOidTag) -> *mut PK11Context; - pub fn PK11_DigestOp( - context: *mut PK11Context, - in_0: *const libc::c_uchar, - len: libc::c_uint, - ) -> SECStatus; - pub fn PK11_DigestFinal( - context: *mut PK11Context, - data: *mut libc::c_uchar, - outLen: *mut libc::c_uint, - length: libc::c_uint, - ) -> SECStatus; - pub fn PK11_ReadRawAttribute( - type_0: PK11ObjectType, - object: *mut libc::c_void, - attr: CK_ATTRIBUTE_TYPE, - item: *mut SECItem, - ) -> SECStatus; - pub fn PK11_DestroyGenericObject(object: *mut PK11GenericObject) -> SECStatus; - pub fn PK11_CreateManagedGenericObject( - slot: *mut PK11SlotInfo, - pTemplate: *const CK_ATTRIBUTE, - count: libc::c_int, - token: PRBool, - ) -> *mut PK11GenericObject; - pub fn SEC_FindCrlByDERCert( - handle: *mut CERTCertDBHandle, - derCrl: *mut SECItem, - type_0: libc::c_int, - ) -> *mut CERTSignedCrl; - pub fn SEC_DestroyCrl(crl: *mut CERTSignedCrl) -> SECStatus; - pub fn ATOB_ConvertAsciiToItem( - binary_item: *mut SECItem, - ascii: *const libc::c_char, - ) -> SECStatus; - pub fn PR_ImportTCPSocket(osfd: PROsfd) -> *mut PRFileDesc; - pub fn CERT_CacheOCSPResponseFromSideChannel( - handle: *mut CERTCertDBHandle, - cert: *mut CERTCertificate, - time: PRTime, - encodedResponse: *const SECItem, - pwArg: *mut libc::c_void, - ) -> SECStatus; - pub fn curlx_uztosi(uznum: size_t) -> libc::c_int; - pub fn curlx_uztoui(uznum: size_t) -> libc::c_uint; - pub fn strpbrk(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; - pub fn Curl_llist_init(_: *mut Curl_llist, _: Curl_llist_dtor); - // rustls.rs - pub fn rustls_client_config_builder_dangerous_set_certificate_verifier( - config: *mut rustls_client_config_builder, - callback: rustls_verify_server_cert_callback, - ); - pub fn rustls_client_config_builder_load_roots_from_file( - config: *mut rustls_client_config_builder, - filename: *const libc::c_char, - ) -> rustls_result; - pub fn rustls_client_config_builder_set_protocols( - builder: *mut rustls_client_config_builder, - protocols: *const rustls_slice_bytes, - len: size_t, - ) -> rustls_result; - pub fn rustls_client_config_builder_set_enable_sni( - config: *mut rustls_client_config_builder, - enable: bool, - ); - pub fn rustls_client_config_free(config: *const rustls_client_config); - pub fn rustls_client_connection_new( - config: *const rustls_client_config, - hostname: *const libc::c_char, - conn_out: *mut *mut rustls_connection, - ) -> rustls_result; - pub fn rustls_connection_set_userdata( - conn: *mut rustls_connection, - userdata: *mut libc::c_void, - ); - pub fn rustls_connection_read_tls( - conn: *mut rustls_connection, - callback: rustls_read_callback, - userdata: *mut libc::c_void, - out_n: *mut size_t, - ) -> rustls_io_result; - pub fn rustls_connection_write_tls( - conn: *mut rustls_connection, - callback: rustls_write_callback, - userdata: *mut libc::c_void, - out_n: *mut size_t, - ) -> rustls_io_result; - pub fn rustls_connection_process_new_packets(conn: *mut rustls_connection) -> rustls_result; - pub fn rustls_connection_wants_read(conn: *const rustls_connection) -> bool; - pub fn rustls_connection_wants_write(conn: *const rustls_connection) -> bool; - pub fn rustls_connection_is_handshaking(conn: *const rustls_connection) -> bool; - pub fn rustls_version(buf: *mut libc::c_char, len: size_t) -> size_t; - pub fn rustls_connection_send_close_notify(conn: *mut rustls_connection); - pub fn rustls_connection_get_alpn_protocol( - conn: *const rustls_connection, - protocol_out: *mut *const uint8_t, - protocol_out_len: *mut size_t, - ); - pub fn rustls_connection_write( - conn: *mut rustls_connection, - buf: *const uint8_t, - count: size_t, - out_n: *mut size_t, - ) -> rustls_result; - pub fn rustls_connection_read( - conn: *mut rustls_connection, - buf: *mut uint8_t, - count: size_t, - out_n: *mut size_t, - ) -> rustls_result; - pub fn rustls_connection_free(conn: *mut rustls_connection); - pub fn rustls_error( - result: rustls_result, - buf: *mut libc::c_char, - len: size_t, - out_n: *mut size_t, - ); - pub fn rustls_result_is_cert_error(result: rustls_result) -> bool; - pub fn rustls_client_config_builder_build( - builder: *mut rustls_client_config_builder, - ) -> *const rustls_client_config; - pub fn rustls_client_config_builder_new() -> *mut rustls_client_config_builder; - // pub fn Curl_none_init() -> libc::c_int; - // pub fn Curl_none_cleanup(); - // pub fn Curl_none_check_cxn(conn: *mut connectdata) -> libc::c_int; - // pub fn Curl_none_random( - // data: *mut Curl_easy, - // entropy: *mut libc::c_uchar, - // length: size_t, - // ) -> CURLcode; - // pub fn Curl_none_close_all(data: *mut Curl_easy); - // pub fn Curl_none_session_free(ptr: *mut libc::c_void); - // pub fn Curl_none_cert_status_request() -> bool; - // pub fn Curl_none_set_engine( - // data: *mut Curl_easy, - // engine: *const libc::c_char, - // ) -> CURLcode; - // pub fn Curl_none_set_engine_default(data: *mut Curl_easy) -> CURLcode; - // pub fn Curl_none_engines_list(data: *mut Curl_easy) -> *mut curl_slist; - // pub fn Curl_none_false_start() -> bool; - - // mesalink.rs - pub fn mesalink_SSL_CTX_use_PrivateKey_file( - _: *mut MESALINK_CTX, - _: *const libc::c_char, - _: libc::c_int, - ) -> libc::c_int; - pub fn mesalink_library_init() -> libc::c_int; - pub fn mesalink_TLSv1_2_client_method() -> *mut MESALINK_METHOD; - pub fn mesalink_TLSv1_3_client_method() -> *mut MESALINK_METHOD; - pub fn mesalink_SSL_CTX_new(_: *mut MESALINK_METHOD) -> *mut MESALINK_CTX; - pub fn mesalink_SSL_CTX_load_verify_locations( - _: *mut MESALINK_CTX, - _: *const libc::c_char, - _: *const libc::c_char, - ) -> libc::c_int; - pub fn mesalink_SSL_CTX_use_certificate_chain_file( - _: *mut MESALINK_CTX, - _: *const libc::c_char, - _: libc::c_int, - ) -> libc::c_int; - pub fn mesalink_SSL_CTX_set_verify( - _: *mut MESALINK_CTX, - _: libc::c_int, - cb: Option libc::c_int>, - ) -> libc::c_int; - pub fn mesalink_SSL_new(_: *mut MESALINK_CTX) -> *mut MESALINK_SSL; - pub fn mesalink_SSL_set_tlsext_host_name( - _: *mut MESALINK_SSL, - _: *const libc::c_char, - ) -> libc::c_int; - pub fn mesalink_SSL_set_fd(_: *mut MESALINK_SSL, _: libc::c_int) -> libc::c_int; - pub fn mesalink_SSL_CTX_free(_: *mut MESALINK_CTX); - pub fn mesalink_SSL_connect(_: *mut MESALINK_SSL) -> libc::c_int; - pub fn mesalink_SSL_write( - _: *mut MESALINK_SSL, - _: *const libc::c_void, - _: libc::c_int, - ) -> libc::c_int; - pub fn mesalink_SSL_get_cipher_name(_: *mut MESALINK_SSL) -> *const libc::c_char; - pub fn mesalink_SSL_read( - _: *mut MESALINK_SSL, - _: *mut libc::c_void, - _: libc::c_int, - ) -> libc::c_int; - pub fn mesalink_SSL_shutdown(_: *mut MESALINK_SSL) -> libc::c_int; - pub fn mesalink_SSL_get_version(_: *const MESALINK_SSL) -> *const libc::c_char; - pub fn mesalink_SSL_free(_: *mut MESALINK_SSL); - pub fn mesalink_SSL_get_error(_: *const MESALINK_SSL, _: libc::c_int) -> libc::c_int; - pub fn mesalink_ERR_error_string_n( - e: libc::c_ulong, - buf: *mut libc::c_char, - len: size_t, - ) -> *const libc::c_char; - pub fn mesalink_ERR_print_errors_fp(_: *const FILE); - // openssl.rs - pub fn Curl_wait_ms(timeout_ms: timediff_t) -> libc::c_int; - // pub fn Curl_none_false_start() -> bool; - pub fn curl_slist_append(_: *mut curl_slist, _: *const libc::c_char) -> *mut curl_slist; - // pub fn Curl_ssl_push_certinfo_len( - // data: *mut Curl_easy, - // certnum: libc::c_int, - // label: *const libc::c_char, - // value: *const libc::c_char, - // valuelen: size_t, - // ) -> CURLcode; - // pub fn Curl_ssl_sessionid_lock(data: *mut Curl_easy); - // pub fn Curl_ssl_sessionid_unlock(data: *mut Curl_easy); - // pub fn Curl_ssl_getsessionid( - // data: *mut Curl_easy, - // conn: *mut connectdata, - // isProxy: bool, - // ssl_sessionid: *mut *mut libc::c_void, - // idsize: *mut size_t, - // sockindex: libc::c_int, - // ) -> bool; - // pub fn Curl_ssl_addsessionid( - // data: *mut Curl_easy, - // conn: *mut connectdata, - // isProxy: bool, - // ssl_sessionid: *mut libc::c_void, - // idsize: size_t, - // sockindex: libc::c_int, - // ) -> CURLcode; - // pub fn Curl_ssl_delsessionid(data: *mut Curl_easy, ssl_sessionid: *mut libc::c_void); - pub fn Curl_cert_hostcheck( - match_pattern: *const libc::c_char, - hostname: *const libc::c_char, - ) -> libc::c_int; - pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX; - pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX); - pub fn EVP_DigestUpdate( - ctx: *mut EVP_MD_CTX, - d: *const libc::c_void, - cnt: size_t, - ) -> libc::c_int; - pub fn EVP_DigestFinal_ex( - ctx: *mut EVP_MD_CTX, - md: *mut libc::c_uchar, - s: *mut libc::c_uint, - ) -> libc::c_int; - pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, type_0: *const EVP_MD) -> libc::c_int; - pub fn EVP_sha1() -> *const EVP_MD; - pub fn EVP_sha256() -> *const EVP_MD; - pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> libc::c_int; - pub fn EVP_PKEY_get0_RSA(pkey: *mut EVP_PKEY) -> *mut rsa_st; - pub fn EVP_PKEY_get1_RSA(pkey: *mut EVP_PKEY) -> *mut rsa_st; - pub fn EVP_PKEY_get0_DSA(pkey: *mut EVP_PKEY) -> *mut dsa_st; - pub fn EVP_PKEY_get0_DH(pkey: *mut EVP_PKEY) -> *mut dh_st; - pub fn EVP_PKEY_free(pkey: *mut EVP_PKEY); - pub fn EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> libc::c_int; - pub fn OPENSSL_init_ssl(opts: uint64_t, settings: *const OPENSSL_INIT_SETTINGS) -> libc::c_int; - pub fn SSL_get_shutdown(ssl: *const SSL) -> libc::c_int; - pub fn SSL_pending(s: *const SSL) -> libc::c_int; - pub fn TLS_client_method() -> *const SSL_METHOD; - pub fn SSL_CTX_new(meth: *const SSL_METHOD) -> *mut SSL_CTX; - pub fn SSL_CTX_set_msg_callback( - ctx: *mut SSL_CTX, - cb: Option< - unsafe extern "C" fn( - libc::c_int, - libc::c_int, - libc::c_int, - *const libc::c_void, - size_t, - *mut SSL, - *mut libc::c_void, - ) -> (), - >, - ); - pub fn SSL_alert_desc_string_long(value: libc::c_int) -> *const libc::c_char; - pub fn SSL_CTX_set_options(ctx: *mut SSL_CTX, op: libc::c_ulong) -> libc::c_ulong; - pub fn SSL_CTX_set_next_proto_select_cb( - s: *mut SSL_CTX, - cb: SSL_CTX_npn_select_cb_func, - arg: *mut libc::c_void, - ); - pub fn SSL_CTX_set_alpn_protos( - ctx: *mut SSL_CTX, - protos: *const libc::c_uchar, - protos_len: libc::c_uint, - ) -> libc::c_int; - pub fn SSL_CTX_set_default_passwd_cb_userdata(ctx: *mut SSL_CTX, u: *mut libc::c_void); - pub fn SSL_CTX_set_default_passwd_cb(ctx: *mut SSL_CTX, cb: Option); - pub fn PEM_read_bio_X509_AUX( - bp: *mut BIO, - x: *mut *mut X509, - cb: Option, - u: *mut libc::c_void, - ) -> *mut X509; - pub fn SSL_CTX_use_certificate_chain_file( - ctx: *mut SSL_CTX, - file: *const libc::c_char, - ) -> libc::c_int; - pub fn d2i_X509_bio(bp: *mut BIO, x509: *mut *mut X509) -> *mut X509; - pub fn SSL_CTX_use_certificate_file( - ctx: *mut SSL_CTX, - file: *const libc::c_char, - type_0: libc::c_int, - ) -> libc::c_int; - pub fn SSL_CTX_use_certificate(ctx: *mut SSL_CTX, x: *mut X509) -> libc::c_int; - pub fn SSL_CTX_add_client_CA(ctx: *mut SSL_CTX, x: *mut X509) -> libc::c_int; - pub fn OPENSSL_sk_pop(st: *mut OPENSSL_STACK) -> *mut libc::c_void; - pub fn PEM_read_bio_PrivateKey( - bp: *mut BIO, - x: *mut *mut EVP_PKEY, - cb: Option, - u: *mut libc::c_void, - ) -> *mut EVP_PKEY; - pub fn d2i_PrivateKey_bio(bp: *mut BIO, a: *mut *mut EVP_PKEY) -> *mut EVP_PKEY; - pub fn SSL_CTX_use_PrivateKey_file( - ctx: *mut SSL_CTX, - file: *const libc::c_char, - type_0: libc::c_int, - ) -> libc::c_int; - pub fn SSL_CTX_use_PrivateKey(ctx: *mut SSL_CTX, pkey: *mut EVP_PKEY) -> libc::c_int; - pub fn SSL_get_certificate(ssl: *const SSL) -> *mut X509; - pub fn RSA_flags(r: *const RSA) -> libc::c_int; - pub fn RSA_free(r: *mut RSA); - pub fn SSL_get_privatekey(ssl: *const SSL) -> *mut evp_pkey_st; - pub fn SSL_CTX_check_private_key(ctx: *const SSL_CTX) -> libc::c_int; - pub fn SSL_CTX_set_ciphersuites(ctx: *mut SSL_CTX, str: *const libc::c_char) -> libc::c_int; - pub fn SSL_CTX_set_post_handshake_auth(ctx: *mut SSL_CTX, val: libc::c_int); - pub fn SSL_CTX_set_srp_username(ctx: *mut SSL_CTX, name: *mut libc::c_char) -> libc::c_int; - pub fn SSL_CTX_set_srp_password(ctx: *mut SSL_CTX, password: *mut libc::c_char) -> libc::c_int; - pub fn SSL_CTX_set_cipher_list(_: *mut SSL_CTX, str: *const libc::c_char) -> libc::c_int; - pub fn PEM_X509_INFO_read_bio( - bp: *mut BIO, - sk: *mut stack_st_X509_INFO, - cb: Option, - u: *mut libc::c_void, - ) -> *mut stack_st_X509_INFO; - pub fn X509_STORE_add_cert(ctx: *mut X509_STORE, x: *mut X509) -> libc::c_int; - pub fn X509_STORE_add_crl(ctx: *mut X509_STORE, x: *mut X509_CRL) -> libc::c_int; - pub fn OPENSSL_sk_pop_free( - st: *mut OPENSSL_STACK, - func: Option ()>, - ); - pub fn X509_INFO_free(a: *mut X509_INFO); - pub fn SSL_CTX_load_verify_locations( - ctx: *mut SSL_CTX, - CAfile: *const libc::c_char, - CApath: *const libc::c_char, - ) -> libc::c_int; - pub fn X509_STORE_add_lookup( - v: *mut X509_STORE, - m: *mut X509_LOOKUP_METHOD, - ) -> *mut X509_LOOKUP; - pub fn X509_LOOKUP_file() -> *mut X509_LOOKUP_METHOD; - pub fn X509_load_crl_file( - ctx: *mut X509_LOOKUP, - file: *const libc::c_char, - type_0: libc::c_int, - ) -> libc::c_int; - pub fn X509_STORE_set_flags(ctx: *mut X509_STORE, flags: libc::c_ulong) -> libc::c_int; - pub fn SSL_CTX_set_verify(ctx: *mut SSL_CTX, mode: libc::c_int, callback: SSL_verify_cb); - pub fn SSL_CTX_set_keylog_callback(ctx: *mut SSL_CTX, cb: SSL_CTX_keylog_cb_func); - pub fn SSL_CTX_ctrl( - ctx: *mut SSL_CTX, - cmd: libc::c_int, - larg: libc::c_long, - parg: *mut libc::c_void, - ) -> libc::c_long; - pub fn SSL_CTX_sess_set_new_cb( - ctx: *mut SSL_CTX, - new_session_cb: Option libc::c_int>, - ); - pub fn SSL_get_ex_data(ssl: *const SSL, idx: libc::c_int) -> *mut libc::c_void; - pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL; - pub fn SSL_set_session(to: *mut SSL, session: *mut SSL_SESSION) -> libc::c_int; - pub fn SSL_set_bio(s: *mut SSL, rbio: *mut BIO, wbio: *mut BIO); - pub fn BIO_f_ssl() -> *const BIO_METHOD; - pub fn SSL_set_fd(s: *mut SSL, fd: libc::c_int) -> libc::c_int; - pub fn SSL_connect(ssl: *mut SSL) -> libc::c_int; - pub fn X509_get0_extensions(x: *const X509) -> *const stack_st_X509_EXTENSION; - pub fn SSL_get_version(s: *const SSL) -> *const libc::c_char; - pub fn SSL_CIPHER_get_name(c: *const SSL_CIPHER) -> *const libc::c_char; - pub fn SSL_get_current_cipher(s: *const SSL) -> *const SSL_CIPHER; - pub fn SSL_get0_alpn_selected( - ssl: *const SSL, - data: *mut *const libc::c_uchar, - len: *mut libc::c_uint, - ); - pub fn X509_get_version(x: *const X509) -> libc::c_long; - pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER; - pub fn BIO_puts(bp: *mut BIO, buf: *const libc::c_char) -> libc::c_int; - pub fn X509_get0_signature( - psig: *mut *const ASN1_BIT_STRING, - palg: *mut *const X509_ALGOR, - x: *const X509, - ); - pub fn X509_PUBKEY_get0_param( - ppkalg: *mut *mut ASN1_OBJECT, - pk: *mut *const libc::c_uchar, - ppklen: *mut libc::c_int, - pa: *mut *mut X509_ALGOR, - pub_0: *mut X509_PUBKEY, - ) -> libc::c_int; - pub fn i2a_ASN1_OBJECT(bp: *mut BIO, a: *const ASN1_OBJECT) -> libc::c_int; - pub fn X509_EXTENSION_get_object(ex: *mut X509_EXTENSION) -> *mut ASN1_OBJECT; - pub fn i2t_ASN1_OBJECT( - buf: *mut libc::c_char, - buf_len: libc::c_int, - a: *const ASN1_OBJECT, - ) -> libc::c_int; - pub fn ASN1_STRING_print(bp: *mut BIO, v: *const ASN1_STRING) -> libc::c_int; - pub fn X509_EXTENSION_get_data(ne: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING; - pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; - pub fn RSA_get0_key( - r: *const RSA, - n: *mut *const BIGNUM, - e: *mut *const BIGNUM, - d: *mut *const BIGNUM, - ); - pub fn BN_num_bits(a: *const BIGNUM) -> libc::c_int; - pub fn DSA_get0_pqg( - d: *const DSA, - p: *mut *const BIGNUM, - q: *mut *const BIGNUM, - g: *mut *const BIGNUM, - ); - pub fn DSA_get0_key(d: *const DSA, pub_key: *mut *const BIGNUM, priv_key: *mut *const BIGNUM); - pub fn DH_get0_pqg( - dh: *const DH, - p: *mut *const BIGNUM, - q: *mut *const BIGNUM, - g: *mut *const BIGNUM, - ); - pub fn DH_get0_key(dh: *const DH, pub_key: *mut *const BIGNUM, priv_key: *mut *const BIGNUM); - pub fn BN_print(bio: *mut BIO, a: *const BIGNUM) -> libc::c_int; - pub fn BIO_printf(bio: *mut BIO, format: *const libc::c_char, _: ...) -> libc::c_int; - pub fn PEM_write_bio_X509(bp: *mut BIO, x: *mut X509) -> libc::c_int; - pub fn X509_get0_notBefore(x: *const X509) -> *const ASN1_TIME; - pub fn ASN1_TIME_print(fp: *mut BIO, a: *const ASN1_TIME) -> libc::c_int; - pub fn X509_get0_notAfter(x: *const X509) -> *const ASN1_TIME; - pub fn X509_get_ext_d2i( - x: *const X509, - nid: libc::c_int, - crit: *mut libc::c_int, - idx: *mut libc::c_int, - ) -> *mut libc::c_void; - pub fn X509_NAME_get_index_by_NID( - name: *mut X509_NAME, - nid: libc::c_int, - lastpos: libc::c_int, - ) -> libc::c_int; - pub fn ASN1_STRING_type(x: *const ASN1_STRING) -> libc::c_int; - pub fn ASN1_STRING_length(x: *const ASN1_STRING) -> libc::c_int; - pub fn CRYPTO_malloc( - num: size_t, - file: *const libc::c_char, - line: libc::c_int, - ) -> *mut libc::c_void; - pub fn ASN1_STRING_get0_data(x: *const ASN1_STRING) -> *const libc::c_uchar; - pub fn ASN1_STRING_to_UTF8( - out: *mut *mut libc::c_uchar, - in_0: *const ASN1_STRING, - ) -> libc::c_int; - pub fn X509_NAME_ENTRY_get_data(ne: *const X509_NAME_ENTRY) -> *mut ASN1_STRING; - pub fn X509_NAME_get_entry(name: *const X509_NAME, loc: libc::c_int) -> *mut X509_NAME_ENTRY; - pub fn X509_get_subject_name(a: *const X509) -> *mut X509_NAME; - pub fn CRYPTO_free(ptr: *mut libc::c_void, file: *const libc::c_char, line: libc::c_int); - pub fn X509_NAME_print_ex( - out: *mut BIO, - nm: *const X509_NAME, - indent: libc::c_int, - flags: libc::c_ulong, - ) -> libc::c_int; - pub fn BIO_s_mem() -> *const BIO_METHOD; - pub fn X509_get_issuer_name(a: *const X509) -> *mut X509_NAME; - pub fn BIO_new_mem_buf(buf: *const libc::c_void, len: libc::c_int) -> *mut BIO; - pub fn BIO_new(type_0: *const BIO_METHOD) -> *mut BIO; - pub fn BIO_s_file() -> *const BIO_METHOD; - pub fn BIO_ctrl( - bp: *mut BIO, - cmd: libc::c_int, - larg: libc::c_long, - parg: *mut libc::c_void, - ) -> libc::c_long; - pub fn PEM_read_bio_X509( - bp: *mut BIO, - x: *mut *mut X509, - cb: Option, - u: *mut libc::c_void, - ) -> *mut X509; - pub fn BIO_free(a: *mut BIO) -> libc::c_int; - pub fn SSL_get_verify_result(ssl: *const SSL) -> libc::c_long; - pub fn X509_verify_cert_error_string(n: libc::c_long) -> *const libc::c_char; - pub fn SSL_ctrl( - ssl: *mut SSL, - cmd: libc::c_int, - larg: libc::c_long, - parg: *mut libc::c_void, - ) -> libc::c_long; - pub fn SSL_get_peer_cert_chain(s: *const SSL) -> *mut stack_st_X509; - pub fn SSL_CTX_get_cert_store(_: *const SSL_CTX) -> *mut X509_STORE; - pub fn SSL_get_peer_certificate(s: *const SSL) -> *mut X509; - pub fn OPENSSL_sk_num(_: *const OPENSSL_STACK) -> libc::c_int; - pub fn OPENSSL_sk_value(_: *const OPENSSL_STACK, _: libc::c_int) -> *mut libc::c_void; - pub fn i2d_X509_PUBKEY(a: *mut X509_PUBKEY, out: *mut *mut libc::c_uchar) -> libc::c_int; - pub fn X509_get_X509_PUBKEY(x: *const X509) -> *mut X509_PUBKEY; - pub fn X509_free(a: *mut X509); - pub fn SSL_write(ssl: *mut SSL, buf: *const libc::c_void, num: libc::c_int) -> libc::c_int; - pub fn SSL_get_error(s: *const SSL, ret_code: libc::c_int) -> libc::c_int; - pub fn OpenSSL_version_num() -> libc::c_ulong; - pub fn SSL_read(ssl: *mut SSL, buf: *mut libc::c_void, num: libc::c_int) -> libc::c_int; - pub fn SSL_shutdown(s: *mut SSL) -> libc::c_int; - pub fn SSL_set_connect_state(s: *mut SSL); - pub fn SSL_free(ssl: *mut SSL); - pub fn SSL_CTX_free(_: *mut SSL_CTX); - pub fn SSL_SESSION_free(ses: *mut SSL_SESSION); - pub fn SSL_set_ex_data(ssl: *mut SSL, idx: libc::c_int, data: *mut libc::c_void) - -> libc::c_int; - pub fn CRYPTO_get_ex_new_index( - class_index: libc::c_int, - argl: libc::c_long, - argp: *mut libc::c_void, - new_func: Option, - dup_func: Option, - free_func: Option, - ) -> libc::c_int; - pub fn RAND_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; - pub fn RAND_add(buf: *const libc::c_void, num: libc::c_int, randomness: libc::c_double); - pub fn RAND_load_file(file: *const libc::c_char, max_bytes: libc::c_long) -> libc::c_int; - pub fn RAND_file_name(file: *mut libc::c_char, num: size_t) -> *const libc::c_char; - pub fn RAND_status() -> libc::c_int; - pub fn GENERAL_NAMES_free(a: *mut GENERAL_NAMES); - pub fn X509V3_EXT_print( - out: *mut BIO, - ext: *mut X509_EXTENSION, - flag: libc::c_ulong, - indent: libc::c_int, - ) -> libc::c_int; - pub fn X509_check_issued(issuer: *mut X509, subject: *mut X509) -> libc::c_int; - pub fn ERR_get_error() -> libc::c_ulong; - pub fn ERR_peek_error() -> libc::c_ulong; - pub fn ERR_peek_last_error() -> libc::c_ulong; - pub fn ERR_clear_error(); - pub fn ERR_error_string_n(e: libc::c_ulong, buf: *mut libc::c_char, len: size_t); - pub fn PKCS12_free(a: *mut PKCS12); - pub fn PKCS12_PBE_add(); - pub fn PKCS12_parse( - p12: *mut PKCS12, - pass: *const libc::c_char, - pkey: *mut *mut EVP_PKEY, - cert: *mut *mut X509, - ca: *mut *mut stack_st_X509, - ) -> libc::c_int; - pub fn d2i_PKCS12_bio(bp: *mut BIO, p12: *mut *mut PKCS12) -> *mut PKCS12; - pub fn OCSP_cert_to_id( - dgst: *const EVP_MD, - subject: *const X509, - issuer: *const X509, - ) -> *mut OCSP_CERTID; - pub fn OCSP_response_status(resp: *mut OCSP_RESPONSE) -> libc::c_int; - pub fn OCSP_response_get1_basic(resp: *mut OCSP_RESPONSE) -> *mut OCSP_BASICRESP; - pub fn OCSP_resp_find_status( - bs: *mut OCSP_BASICRESP, - id: *mut OCSP_CERTID, - status: *mut libc::c_int, - reason: *mut libc::c_int, - revtime: *mut *mut ASN1_GENERALIZEDTIME, - thisupd: *mut *mut ASN1_GENERALIZEDTIME, - nextupd: *mut *mut ASN1_GENERALIZEDTIME, - ) -> libc::c_int; - pub fn OCSP_check_validity( - thisupd: *mut ASN1_GENERALIZEDTIME, - nextupd: *mut ASN1_GENERALIZEDTIME, - sec: libc::c_long, - maxsec: libc::c_long, - ) -> libc::c_int; - pub fn OCSP_BASICRESP_free(a: *mut OCSP_BASICRESP); - pub fn OCSP_RESPONSE_free(a: *mut OCSP_RESPONSE); - pub fn d2i_OCSP_RESPONSE( - a: *mut *mut OCSP_RESPONSE, - in_0: *mut *const libc::c_uchar, - len: libc::c_long, - ) -> *mut OCSP_RESPONSE; - pub fn OCSP_CERTID_free(a: *mut OCSP_CERTID); - pub fn OCSP_response_status_str(s: libc::c_long) -> *const libc::c_char; - pub fn OCSP_basic_verify( - bs: *mut OCSP_BASICRESP, - certs: *mut stack_st_X509, - st: *mut X509_STORE, - flags: libc::c_ulong, - ) -> libc::c_int; - pub fn OCSP_cert_status_str(s: libc::c_long) -> *const libc::c_char; - pub fn OCSP_crl_reason_str(s: libc::c_long) -> *const libc::c_char; - pub fn ENGINE_get_first() -> *mut ENGINE; - pub fn ENGINE_get_next(e: *mut ENGINE) -> *mut ENGINE; - pub fn ENGINE_by_id(id: *const libc::c_char) -> *mut ENGINE; - pub fn ENGINE_ctrl( - e: *mut ENGINE, - cmd: libc::c_int, - i: libc::c_long, - p: *mut libc::c_void, - f: Option ()>, - ) -> libc::c_int; - pub fn ENGINE_ctrl_cmd( - e: *mut ENGINE, - cmd_name: *const libc::c_char, - i: libc::c_long, - p: *mut libc::c_void, - f: Option ()>, - cmd_optional: libc::c_int, - ) -> libc::c_int; - pub fn ENGINE_free(e: *mut ENGINE) -> libc::c_int; - pub fn ENGINE_get_id(e: *const ENGINE) -> *const libc::c_char; - pub fn UI_OpenSSL() -> *mut UI_METHOD; - pub fn ENGINE_load_private_key( - e: *mut ENGINE, - key_id: *const libc::c_char, - ui_method: *mut UI_METHOD, - callback_data: *mut libc::c_void, - ) -> *mut EVP_PKEY; - pub fn ENGINE_set_default(e: *mut ENGINE, flags: libc::c_uint) -> libc::c_int; - pub fn ENGINE_init(e: *mut ENGINE) -> libc::c_int; - pub fn ENGINE_finish(e: *mut ENGINE) -> libc::c_int; - pub fn UI_get0_user_data(ui: *mut UI) -> *mut libc::c_void; - pub fn UI_method_set_opener( - method: *mut UI_METHOD, - opener: Option libc::c_int>, - ) -> libc::c_int; - pub fn UI_method_get_opener( - method: *const UI_METHOD, - ) -> Option libc::c_int>; - pub fn UI_method_set_closer( - method: *mut UI_METHOD, - closer: Option libc::c_int>, - ) -> libc::c_int; - pub fn UI_method_get_closer( - method: *const UI_METHOD, - ) -> Option libc::c_int>; - pub fn UI_create_method(name: *const libc::c_char) -> *mut UI_METHOD; - pub fn UI_destroy_method(ui_method: *mut UI_METHOD); - pub fn UI_method_get_writer( - method: *const UI_METHOD, - ) -> Option libc::c_int>; - pub fn UI_method_set_writer( - method: *mut UI_METHOD, - writer: Option libc::c_int>, - ) -> libc::c_int; - pub fn UI_method_get_reader( - method: *const UI_METHOD, - ) -> Option libc::c_int>; - pub fn UI_method_set_reader( - method: *mut UI_METHOD, - reader: Option libc::c_int>, - ) -> libc::c_int; - pub fn UI_set_result( - ui: *mut UI, - uis: *mut UI_STRING, - result: *const libc::c_char, - ) -> libc::c_int; - pub fn UI_get_string_type(uis: *mut UI_STRING) -> UI_string_types; - pub fn UI_get_input_flags(uis: *mut UI_STRING) -> libc::c_int; - - // http_negotiate.rs - pub fn Curl_auth_decode_spnego_message( - data: *mut Curl_easy, - user: *const libc::c_char, - passwood: *const libc::c_char, - service: *const libc::c_char, - host: *const libc::c_char, - chlg64: *const libc::c_char, - nego: *mut negotiatedata, - ) -> CURLcode; - pub fn Curl_auth_create_spnego_message( - data: *mut Curl_easy, - nego: *mut negotiatedata, - outptr: *mut *mut libc::c_char, - outlen: *mut size_t, - ) -> CURLcode; - pub fn Curl_auth_cleanup_spnego(nego: *mut negotiatedata); - // bearssl.rs - pub fn br_ssl_engine_sendapp_ack(cc: *mut br_ssl_engine_context, len: size_t); - pub fn br_ssl_engine_sendapp_buf( - cc: *const br_ssl_engine_context, - len: *mut size_t, - ) -> *mut libc::c_uchar; - pub fn br_ssl_engine_current_state(cc: *const br_ssl_engine_context) -> libc::c_uint; - pub fn br_ssl_engine_set_buffer( - cc: *mut br_ssl_engine_context, - iobuf: *mut libc::c_void, - iobuf_len: size_t, - bidi: libc::c_int, - ); - pub fn br_pem_decoder_event(ctx: *mut br_pem_decoder_context) -> libc::c_int; - pub fn br_pem_decoder_push( - ctx: *mut br_pem_decoder_context, - data: *const libc::c_void, - len: size_t, - ) -> size_t; - pub fn br_pem_decoder_init(ctx: *mut br_pem_decoder_context); - pub fn br_ssl_client_reset( - cc: *mut br_ssl_client_context, - server_name: *const libc::c_char, - resume_session: libc::c_int, - ) -> libc::c_int; - pub fn br_ssl_client_init_full( - cc: *mut br_ssl_client_context, - xc: *mut br_x509_minimal_context, - trust_anchors: *const br_x509_trust_anchor, - trust_anchors_num: size_t, - ); - pub fn br_ssl_engine_close(cc: *mut br_ssl_engine_context); - pub fn br_ssl_engine_flush(cc: *mut br_ssl_engine_context, force: libc::c_int); - pub fn br_ssl_engine_recvrec_ack(cc: *mut br_ssl_engine_context, len: size_t); - pub fn br_ssl_engine_recvrec_buf( - cc: *const br_ssl_engine_context, - len: *mut size_t, - ) -> *mut libc::c_uchar; - pub fn br_ssl_engine_sendrec_ack(cc: *mut br_ssl_engine_context, len: size_t); - pub fn br_ssl_engine_sendrec_buf( - cc: *const br_ssl_engine_context, - len: *mut size_t, - ) -> *mut libc::c_uchar; - pub fn br_ssl_engine_recvapp_ack(cc: *mut br_ssl_engine_context, len: size_t); - pub fn br_sha224_update(ctx: *mut br_sha224_context, data: *const libc::c_void, len: size_t); - pub fn br_sha256_init(ctx: *mut br_sha256_context); - pub fn br_sha256_out(ctx: *const br_sha256_context, out: *mut libc::c_void); - pub fn br_ssl_engine_recvapp_buf( - cc: *const br_ssl_engine_context, - len: *mut size_t, - ) -> *mut libc::c_uchar; - pub fn br_x509_decoder_push( - ctx: *mut br_x509_decoder_context, - data: *const libc::c_void, - len: size_t, - ); - pub fn br_x509_decoder_init( - ctx: *mut br_x509_decoder_context, - append_dn_0: Option< - unsafe extern "C" fn(*mut libc::c_void, *const libc::c_void, size_t) -> (), - >, - append_dn_ctx: *mut libc::c_void, - ); - pub fn br_hmac_drbg_init( - ctx: *mut br_hmac_drbg_context, - digest_class: *const br_hash_class, - seed: *const libc::c_void, - seed_len: size_t, - ); - pub fn br_hmac_drbg_generate( - ctx: *mut br_hmac_drbg_context, - out: *mut libc::c_void, - len: size_t, - ); - pub fn br_prng_seeder_system(name: *mut *const libc::c_char) -> br_prng_seeder; - pub fn ferror(__stream: *mut FILE) -> libc::c_int; - - // option hyper - pub fn hyper_clientconn_handshake( - io: *mut hyper_io, - options: *mut hyper_clientconn_options, - ) -> *mut hyper_task; - pub fn hyper_clientconn_send( - conn: *mut hyper_clientconn, - req: *mut hyper_request, - ) -> *mut hyper_task; - pub fn hyper_clientconn_free(conn: *mut hyper_clientconn); - pub fn hyper_clientconn_options_new() -> *mut hyper_clientconn_options; - pub fn hyper_clientconn_options_free(opts: *mut hyper_clientconn_options); - pub fn hyper_clientconn_options_exec( - opts: *mut hyper_clientconn_options, - exec: *const hyper_executor, - ); - pub fn hyper_error_free(err: *mut hyper_error); - pub fn hyper_error_print(err: *const hyper_error, dst: *mut uint8_t, dst_len: size_t) - -> size_t; - pub fn hyper_request_new() -> *mut hyper_request; - pub fn hyper_request_set_method( - req: *mut hyper_request, - method: *const uint8_t, - method_len: size_t, - ) -> hyper_code; - pub fn hyper_request_set_uri( - req: *mut hyper_request, - uri: *const uint8_t, - uri_len: size_t, - ) -> hyper_code; - pub fn hyper_request_set_version(req: *mut hyper_request, version: libc::c_int) -> hyper_code; - pub fn hyper_request_headers(req: *mut hyper_request) -> *mut hyper_headers; - pub fn hyper_io_new() -> *mut hyper_io; - pub fn hyper_io_free(io: *mut hyper_io); - pub fn hyper_io_set_userdata(io: *mut hyper_io, data: *mut libc::c_void); - pub fn hyper_io_set_read(io: *mut hyper_io, func: hyper_io_read_callback); - pub fn hyper_io_set_write(io: *mut hyper_io, func: hyper_io_write_callback); - pub fn hyper_executor_new() -> *const hyper_executor; - pub fn hyper_executor_free(exec: *const hyper_executor); - pub fn hyper_executor_push(exec: *const hyper_executor, task: *mut hyper_task) -> hyper_code; - pub fn hyper_executor_poll(exec: *const hyper_executor) -> *mut hyper_task; - pub fn hyper_task_free(task: *mut hyper_task); - pub fn hyper_task_value(task: *mut hyper_task) -> *mut libc::c_void; - pub fn hyper_task_type(task: *mut hyper_task) -> hyper_task_return_type; - pub fn hyper_waker_free(waker: *mut hyper_waker); - pub fn Curl_hyper_recv( - userp: *mut libc::c_void, - ctx: *mut hyper_context, - buf: *mut uint8_t, - buflen: size_t, - ) -> size_t; - pub fn Curl_hyper_send( - userp: *mut libc::c_void, - ctx: *mut hyper_context, - buf: *const uint8_t, - buflen: size_t, - ) -> size_t; - pub fn Curl_hyper_stream( - data: *mut Curl_easy, - conn: *mut connectdata, - didwhat: *mut libc::c_int, - done: *mut bool, - select_res: libc::c_int, - ) -> CURLcode; - pub fn Curl_hyper_header( - data: *mut Curl_easy, - headers: *mut hyper_headers, - line: *const libc::c_char, - ) -> CURLcode; - pub fn Curl_hyper_done(_: *mut Curl_easy); - - // in http.rs, remove in future - #[cfg(USE_HYPER)] - pub fn Curl_add_custom_headers( - data: *mut Curl_easy, - is_connect: bool, - headers: *mut libc::c_void, - ) -> CURLcode; - - // http.rs function without hyper - #[cfg(not(USE_HYPER))] - pub fn Curl_add_custom_headers( - data: *mut Curl_easy, - is_connect: bool, - req: *mut dynbuf, - ) -> CURLcode; - - - //debug - pub fn __assert_fail( - __assertion: *const libc::c_char, - __file: *const libc::c_char, - __line: libc::c_uint, - __function: *const libc::c_char, - ) -> !; - pub fn curl_dbg_free(ptr: *mut libc::c_void, line: libc::c_int, source: *const libc::c_char); - pub fn curl_dbg_strdup( - str: *const libc::c_char, - line: libc::c_int, - src: *const libc::c_char, - ) -> *mut libc::c_char; - pub fn curl_dbg_calloc( - elements: size_t, - size: size_t, - line: libc::c_int, - source: *const libc::c_char, - ) -> *mut libc::c_void; - pub fn curl_dbg_malloc( - size: size_t, - line: libc::c_int, - source: *const libc::c_char, - ) -> *mut libc::c_void; - pub fn curl_dbg_fopen( - file: *const libc::c_char, - mode: *const libc::c_char, - line: libc::c_int, - source: *const libc::c_char, - ) -> *mut FILE; - pub fn curl_dbg_fclose( - file: *mut FILE, - line: libc::c_int, - source: *const libc::c_char, - ) -> libc::c_int; - pub fn curl_dbg_recv( - sockfd: libc::c_int, - buf: *mut libc::c_void, - len: size_t, - flags: libc::c_int, - line: libc::c_int, - source: *const libc::c_char, - ) -> ssize_t; -} + use crate::src::ffi_alias::type_alias::*; + use crate::src::ffi_struct::struct_define::*; + + extern "C" { + // keylog.rs + pub fn curl_getenv(variable: *const libc::c_char) -> *mut libc::c_char; + pub fn fclose(__stream: *mut FILE) -> libc::c_int; + pub fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE; + pub fn setvbuf( + __stream: *mut FILE, + __buf: *mut libc::c_char, + __modes: libc::c_int, + __n: size_t, + ) -> libc::c_int; + pub fn fputs(__s: *const libc::c_char, __stream: *mut FILE) -> libc::c_int; + pub fn memcpy( + _: *mut libc::c_void, + _: *const libc::c_void, + _: libc::c_ulong, + ) -> *mut libc::c_void; + pub fn strlen(_: *const libc::c_char) -> libc::c_ulong; + + // vtls.rs + pub fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> libc::c_int; + pub fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int; + pub fn Curl_safe_strcasecompare( + first: *const libc::c_char, + second: *const libc::c_char, + ) -> libc::c_int; + + // ftp.rs + pub fn Curl_sec_read_msg( + data: *mut Curl_easy, + conn: *mut connectdata, + _: *mut libc::c_char, + _: protection_level, + ) -> libc::c_int; + pub fn Curl_sec_end(_: *mut connectdata); + pub fn Curl_sec_login(_: *mut Curl_easy, _: *mut connectdata) -> CURLcode; + pub fn Curl_sec_request_prot(conn: *mut connectdata, level: *const libc::c_char) + -> libc::c_int; + pub fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; + pub fn strncpy( + _: *mut libc::c_char, + _: *const libc::c_char, + _: libc::c_ulong, + ) -> *mut libc::c_char; + pub fn strncmp(_: *const libc::c_char, _: *const libc::c_char, _: libc::c_ulong) + -> libc::c_int; + pub fn bind(__fd: libc::c_int, __addr: *const sockaddr, __len: socklen_t) -> libc::c_int; + pub fn getsockname( + __fd: libc::c_int, + __addr: *mut sockaddr, + __len: *mut socklen_t, + ) -> libc::c_int; + pub fn listen(__fd: libc::c_int, __n: libc::c_int) -> libc::c_int; + pub fn accept( + __fd: libc::c_int, + __addr: *mut sockaddr, + __addr_len: *mut socklen_t, + ) -> libc::c_int; + pub fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int; + pub fn Curl_isdigit(c: libc::c_int) -> libc::c_int; + pub fn __errno_location() -> *mut libc::c_int; + pub fn strtol( + _: *const libc::c_char, + _: *mut *mut libc::c_char, + _: libc::c_int, + ) -> libc::c_long; + pub fn strtoul( + _: *const libc::c_char, + _: *mut *mut libc::c_char, + _: libc::c_int, + ) -> libc::c_ulong; + pub fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + pub fn strrchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char; + pub fn strstr(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; + pub fn curl_easy_strerror(_: CURLcode) -> *const libc::c_char; + pub fn inet_pton( + __af: libc::c_int, + __cp: *const libc::c_char, + __buf: *mut libc::c_void, + ) -> libc::c_int; + pub fn inet_ntop( + __af: libc::c_int, + __cp: *const libc::c_void, + __buf: *mut libc::c_char, + __len: socklen_t, + ) -> *const libc::c_char; + pub fn Curl_now() -> curltime; + pub fn Curl_timediff(t1: curltime, t2: curltime) -> timediff_t; + pub fn Curl_llist_remove(_: *mut Curl_llist, _: *mut Curl_llist_element, _: *mut libc::c_void); + pub fn Curl_resolver_wait_resolv( + data: *mut Curl_easy, + dnsentry: *mut *mut Curl_dns_entry, + ) -> CURLcode; + pub fn Curl_resolv( + data: *mut Curl_easy, + hostname: *const libc::c_char, + port: libc::c_int, + allowDOH: bool, + dnsentry: *mut *mut Curl_dns_entry, + ) -> resolve_t; + pub fn Curl_resolv_unlock(data: *mut Curl_easy, dns: *mut Curl_dns_entry); + pub fn Curl_printable_address( + ip: *const Curl_addrinfo, + buf: *mut libc::c_char, + bufsize: size_t, + ); + pub fn Curl_pp_statemach( + data: *mut Curl_easy, + pp: *mut pingpong, + block: bool, + disconnecting: bool, + ) -> CURLcode; + pub fn Curl_pp_init(data: *mut Curl_easy, pp: *mut pingpong); + pub fn Curl_pp_setup(pp: *mut pingpong); + pub fn Curl_pp_state_timeout( + data: *mut Curl_easy, + pp: *mut pingpong, + disconnecting: bool, + ) -> timediff_t; + pub fn Curl_pp_sendf( + data: *mut Curl_easy, + pp: *mut pingpong, + fmt: *const libc::c_char, + _: ... + ) -> CURLcode; + pub fn Curl_pp_readresp( + data: *mut Curl_easy, + sockfd: curl_socket_t, + pp: *mut pingpong, + code: *mut libc::c_int, + size: *mut size_t, + ) -> CURLcode; + pub fn Curl_pp_flushsend(data: *mut Curl_easy, pp: *mut pingpong) -> CURLcode; + pub fn Curl_pp_disconnect(pp: *mut pingpong) -> CURLcode; + pub fn Curl_pp_getsock( + data: *mut Curl_easy, + pp: *mut pingpong, + socks: *mut curl_socket_t, + ) -> libc::c_int; + pub fn Curl_infof(_: *mut Curl_easy, fmt: *const libc::c_char, _: ...); + pub fn Curl_failf(_: *mut Curl_easy, fmt: *const libc::c_char, _: ...); + pub fn Curl_client_write( + data: *mut Curl_easy, + type_0: libc::c_int, + ptr: *mut libc::c_char, + len: size_t, + ) -> CURLcode; + pub fn Curl_ipv6_scope(sa: *const sockaddr) -> libc::c_uint; + pub fn Curl_if2ip( + af: libc::c_int, + remote_scope: libc::c_uint, + local_scope_id: libc::c_uint, + interf: *const libc::c_char, + buf: *mut libc::c_char, + buf_size: libc::c_int, + ) -> if2ip_result_t; + pub fn Curl_pgrsSetDownloadSize(data: *mut Curl_easy, size: curl_off_t); + pub fn Curl_pgrsSetUploadSize(data: *mut Curl_easy, size: curl_off_t); + pub fn Curl_pgrsSetDownloadCounter(data: *mut Curl_easy, size: curl_off_t); + pub fn Curl_pgrsSetUploadCounter(data: *mut Curl_easy, size: curl_off_t); + pub fn Curl_pgrsUpdate(data: *mut Curl_easy) -> libc::c_int; + pub fn Curl_pgrsTime(data: *mut Curl_easy, timer: timerid) -> curltime; + pub fn Curl_setup_transfer( + data: *mut Curl_easy, + sockindex: libc::c_int, + size: curl_off_t, + getheader: bool, + writesockindex: libc::c_int, + ); + pub fn Curl_urldecode( + data: *mut Curl_easy, + string: *const libc::c_char, + length: size_t, + ostring: *mut *mut libc::c_char, + olen: *mut size_t, + ctrl: urlreject, + ) -> CURLcode; + // definitions in ftplistparser.rs + pub fn Curl_ftp_parselist( + buffer: *mut libc::c_char, + size: size_t, + nmemb: size_t, + connptr: *mut libc::c_void, + ) -> size_t; + pub fn Curl_ftp_parselist_geterror(pl_data: *mut ftp_parselist_data) -> CURLcode; + pub fn Curl_ftp_parselist_data_alloc() -> *mut ftp_parselist_data; + pub fn Curl_ftp_parselist_data_free(pl_data: *mut *mut ftp_parselist_data); + pub fn Curl_range(data: *mut Curl_easy) -> CURLcode; + pub fn curlx_strtoofft( + str: *const libc::c_char, + endp: *mut *mut libc::c_char, + base: libc::c_int, + num: *mut curl_off_t, + ) -> CURLofft; + pub fn Curl_strcasecompare( + first: *const libc::c_char, + second: *const libc::c_char, + ) -> libc::c_int; + pub fn Curl_raw_toupper(in_0: libc::c_char) -> libc::c_char; + pub fn Curl_is_connected( + data: *mut Curl_easy, + conn: *mut connectdata, + sockindex: libc::c_int, + connected: *mut bool, + ) -> CURLcode; + pub fn Curl_connecthost( + data: *mut Curl_easy, + conn: *mut connectdata, + host: *const Curl_dns_entry, + ) -> CURLcode; + pub fn Curl_timeleft( + data: *mut Curl_easy, + nowp: *mut curltime, + duringconnect: bool, + ) -> timediff_t; + pub fn Curl_socket( + data: *mut Curl_easy, + ai: *const Curl_addrinfo, + addr: *mut Curl_sockaddr_ex, + sockfd: *mut curl_socket_t, + ) -> CURLcode; + pub fn curlx_nonblock(sockfd: curl_socket_t, nonblock: libc::c_int) -> libc::c_int; + pub fn Curl_conninfo_remote( + data: *mut Curl_easy, + conn: *mut connectdata, + sockfd: curl_socket_t, + ); + pub fn Curl_closesocket( + data: *mut Curl_easy, + conn: *mut connectdata, + sock: curl_socket_t, + ) -> libc::c_int; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + pub fn Curl_conncontrol(conn: *mut connectdata, closeit: libc::c_int); + #[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + pub fn Curl_conncontrol( + conn: *mut connectdata, + closeit: libc::c_int, + reason: *const libc::c_char, + ); + pub fn Curl_conn_data_pending(conn: *mut connectdata, sockindex: libc::c_int) -> bool; + pub fn Curl_strerror( + err: libc::c_int, + buf: *mut libc::c_char, + buflen: size_t, + ) -> *const libc::c_char; + pub fn Curl_socket_check( + readfd: curl_socket_t, + readfd2: curl_socket_t, + writefd: curl_socket_t, + timeout_ms: timediff_t, + ) -> libc::c_int; + pub fn Curl_gmtime(intime: time_t, store: *mut tm) -> CURLcode; + pub fn Curl_getdate_capped(p: *const libc::c_char) -> time_t; + pub fn Curl_expire(data: *mut Curl_easy, milli: timediff_t, _: expire_id); + pub fn Curl_set_in_callback(data: *mut Curl_easy, value: bool); + pub fn curlx_ultous(ulnum: libc::c_ulong) -> libc::c_ushort; + pub fn curlx_sltosi(slnum: libc::c_long) -> libc::c_int; + pub fn curlx_sotouz(sonum: curl_off_t) -> size_t; + pub fn Curl_proxyCONNECT( + data: *mut Curl_easy, + tunnelsocket: libc::c_int, + hostname: *const libc::c_char, + remote_port: libc::c_int, + ) -> CURLcode; + pub fn Curl_proxy_connect(data: *mut Curl_easy, sockindex: libc::c_int) -> CURLcode; + pub fn Curl_connect_ongoing(conn: *mut connectdata) -> bool; + pub fn Curl_SOCKS_getsock( + conn: *mut connectdata, + sock: *mut curl_socket_t, + sockindex: libc::c_int, + ) -> libc::c_int; + pub fn curl_msnprintf( + buffer: *mut libc::c_char, + maxlength: size_t, + format: *const libc::c_char, + _: ... + ) -> libc::c_int; + pub fn curl_maprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; + pub fn Curl_isalnum(c: libc::c_int) -> libc::c_int; + pub fn Curl_isspace(c: libc::c_int) -> libc::c_int; + pub fn Curl_llist_insert_next( + _: *mut Curl_llist, + _: *mut Curl_llist_element, + _: *const libc::c_void, + node: *mut Curl_llist_element, + ); + pub fn Curl_fileinfo_alloc() -> *mut fileinfo; + pub fn Curl_fileinfo_cleanup(finfo: *mut fileinfo); + pub fn Curl_fnmatch( + ptr: *mut libc::c_void, + pattern: *const libc::c_char, + string: *const libc::c_char, + ) -> libc::c_int; + // http_aws_sigv4.rs + pub fn time(__timer: *mut time_t) -> time_t; + pub fn strftime( + __s: *mut libc::c_char, + __maxsize: size_t, + __format: *const libc::c_char, + __tp: *const tm, + ) -> size_t; + pub fn Curl_http_method( + data: *mut Curl_easy, + conn: *mut connectdata, + method: *mut *const libc::c_char, + _: *mut Curl_HttpReq, + ); + pub fn Curl_strntoupper(dest: *mut libc::c_char, src: *const libc::c_char, n: size_t); + pub fn Curl_strntolower(dest: *mut libc::c_char, src: *const libc::c_char, n: size_t); + pub fn Curl_memdup(src: *const libc::c_void, buffer_length: size_t) -> *mut libc::c_void; + pub fn Curl_sha256it(outbuffer: *mut libc::c_uchar, input: *const libc::c_uchar, len: size_t); + pub fn Curl_hmacit( + hashparams: *const HMAC_params, + key: *const libc::c_uchar, + keylen: size_t, + data: *const libc::c_uchar, + datalen: size_t, + output: *mut libc::c_uchar, + ) -> CURLcode; + pub fn Curl_checkheaders( + data: *const Curl_easy, + thisheader: *const libc::c_char, + ) -> *mut libc::c_char; + // http_proxy.rs + pub fn curl_strnequal( + s1: *const libc::c_char, + s2: *const libc::c_char, + n: size_t, + ) -> libc::c_int; + pub fn Curl_httpchunk_init(data: *mut Curl_easy); + pub fn Curl_httpchunk_read( + data: *mut Curl_easy, + datap: *mut libc::c_char, + length: ssize_t, + wrote: *mut ssize_t, + passthru: *mut CURLcode, + ) -> CHUNKcode; + pub fn Curl_dyn_init(s: *mut dynbuf, toobig: size_t); + pub fn Curl_dyn_free(s: *mut dynbuf); + pub fn Curl_dyn_addn(s: *mut dynbuf, mem: *const libc::c_void, len: size_t) -> CURLcode; + pub fn Curl_dyn_add(s: *mut dynbuf, str: *const libc::c_char) -> CURLcode; + pub fn Curl_dyn_addf(s: *mut dynbuf, fmt: *const libc::c_char, _: ...) -> CURLcode; + pub fn Curl_dyn_reset(s: *mut dynbuf); + pub fn Curl_dyn_ptr(s: *const dynbuf) -> *mut libc::c_char; + pub fn Curl_dyn_len(s: *const dynbuf) -> size_t; + pub fn Curl_compareheader( + headerline: *const libc::c_char, + header: *const libc::c_char, + content: *const libc::c_char, + ) -> bool; + pub fn Curl_copy_header_value(header: *const libc::c_char) -> *mut libc::c_char; + pub fn Curl_checkProxyheaders( + data: *mut Curl_easy, + conn: *const connectdata, + thisheader: *const libc::c_char, + ) -> *mut libc::c_char; + pub fn Curl_buffer_send( + in_0: *mut dynbuf, + data: *mut Curl_easy, + bytes_written: *mut curl_off_t, + included_body_bytes: curl_off_t, + socketindex: libc::c_int, + ) -> CURLcode; + pub fn Curl_http_input_auth( + data: *mut Curl_easy, + proxy: bool, + auth: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_http_auth_act(data: *mut Curl_easy) -> CURLcode; + pub fn Curl_http_output_auth( + data: *mut Curl_easy, + conn: *mut connectdata, + request: *const libc::c_char, + httpreq: Curl_HttpReq, + path: *const libc::c_char, + proxytunnel: bool, + ) -> CURLcode; + pub fn Curl_read( + data: *mut Curl_easy, + sockfd: curl_socket_t, + buf: *mut libc::c_char, + buffersize: size_t, + n: *mut ssize_t, + ) -> CURLcode; + pub fn Curl_write( + data: *mut Curl_easy, + sockfd: curl_socket_t, + mem: *const libc::c_void, + len: size_t, + written: *mut ssize_t, + ) -> CURLcode; + pub fn Curl_debug( + data: *mut Curl_easy, + type_0: curl_infotype, + ptr: *mut libc::c_char, + size: size_t, + ) -> libc::c_int; + pub fn Curl_fillreadbuffer( + data: *mut Curl_easy, + bytes: size_t, + nreadp: *mut size_t, + ) -> CURLcode; + pub fn Curl_get_upload_buffer(data: *mut Curl_easy) -> CURLcode; + pub fn Curl_isxdigit(c: libc::c_int) -> libc::c_int; + pub fn Curl_unencode_write( + data: *mut Curl_easy, + writer: *mut contenc_writer, + buf: *const libc::c_char, + nbytes: size_t, + ) -> CURLcode; + + // http.rs + pub fn curl_url_cleanup(handle: *mut CURLU); + pub fn curl_url_dup(in_0: *mut CURLU) -> *mut CURLU; + pub fn curl_url_get( + handle: *mut CURLU, + what: CURLUPart, + part: *mut *mut libc::c_char, + flags: libc::c_uint, + ) -> CURLUcode; + pub fn curl_url_set( + handle: *mut CURLU, + what: CURLUPart, + part: *const libc::c_char, + flags: libc::c_uint, + ) -> CURLUcode; + pub fn memmove( + _: *mut libc::c_void, + _: *const libc::c_void, + _: libc::c_ulong, + ) -> *mut libc::c_void; + pub fn memchr(_: *const libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; + pub fn curl_mime_headers( + part: *mut curl_mimepart, + headers: *mut curl_slist, + take_ownership: libc::c_int, + ) -> CURLcode; + pub fn Curl_mime_initpart(part: *mut curl_mimepart, easy: *mut Curl_easy); + pub fn Curl_mime_cleanpart(part: *mut curl_mimepart); + pub fn Curl_mime_prepare_headers( + part: *mut curl_mimepart, + contenttype: *const libc::c_char, + disposition: *const libc::c_char, + strategy: mimestrategy, + ) -> CURLcode; + pub fn Curl_mime_size(part: *mut curl_mimepart) -> curl_off_t; + pub fn Curl_mime_read( + buffer: *mut libc::c_char, + size: size_t, + nitems: size_t, + instream: *mut libc::c_void, + ) -> size_t; + pub fn Curl_mime_rewind(part: *mut curl_mimepart) -> CURLcode; + pub fn Curl_cookie_freelist(cookies: *mut Cookie); + pub fn Curl_cookie_getlist( + c: *mut CookieInfo, + host: *const libc::c_char, + path: *const libc::c_char, + secure: bool, + ) -> *mut Cookie; + pub fn Curl_cookie_add( + data: *mut Curl_easy, + c: *mut CookieInfo, + header: bool, + noexpiry: bool, + lineptr: *mut libc::c_char, + domain: *const libc::c_char, + path: *const libc::c_char, + secure: bool, + ) -> *mut Cookie; + pub fn Curl_getformdata( + data: *mut Curl_easy, + _: *mut curl_mimepart, + post: *mut curl_httppost, + fread_func: curl_read_callback, + ) -> CURLcode; + pub fn Curl_rtsp_parseheader(data: *mut Curl_easy, header: *mut libc::c_char) -> CURLcode; + pub fn Curl_readrewind(data: *mut Curl_easy) -> CURLcode; + pub fn Curl_meets_timecondition(data: *mut Curl_easy, timeofdoc: time_t) -> bool; + pub fn Curl_done_sending(data: *mut Curl_easy, k: *mut SingleRequest) -> CURLcode; + pub fn Curl_base64_encode( + data: *mut Curl_easy, + inputbuff: *const libc::c_char, + insize: size_t, + outptr: *mut *mut libc::c_char, + outlen: *mut size_t, + ) -> CURLcode; + pub fn Curl_auth_is_digest_supported() -> bool; + pub fn Curl_input_digest( + data: *mut Curl_easy, + proxy: bool, + header: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_output_digest( + data: *mut Curl_easy, + proxy: bool, + request: *const libc::c_uchar, + uripath: *const libc::c_uchar, + ) -> CURLcode; + pub fn Curl_output_aws_sigv4(data: *mut Curl_easy, proxy: bool) -> CURLcode; + pub fn Curl_share_lock(_: *mut Curl_easy, _: curl_lock_data, _: curl_lock_access) + -> CURLSHcode; + pub fn Curl_share_unlock(_: *mut Curl_easy, _: curl_lock_data) -> CURLSHcode; + pub fn Curl_expire_done(data: *mut Curl_easy, id: expire_id); + pub fn Curl_strncasecompare( + first: *const libc::c_char, + second: *const libc::c_char, + max: size_t, + ) -> libc::c_int; + pub fn Curl_build_unencoding_stack( + data: *mut Curl_easy, + enclist: *const libc::c_char, + maybechunked: libc::c_int, + ) -> CURLcode; + pub fn Curl_unencode_cleanup(data: *mut Curl_easy); + pub fn curlx_uitous(uinum: libc::c_uint) -> libc::c_ushort; + pub fn Curl_http2_request_upgrade(req: *mut dynbuf, data: *mut Curl_easy) -> CURLcode; + pub fn Curl_http2_setup(data: *mut Curl_easy, conn: *mut connectdata) -> CURLcode; + pub fn Curl_http2_switched( + data: *mut Curl_easy, + ptr: *const libc::c_char, + nread: size_t, + ) -> CURLcode; + pub fn Curl_http2_setup_conn(conn: *mut connectdata); + pub fn Curl_http2_setup_req(data: *mut Curl_easy); + pub fn Curl_http2_done(data: *mut Curl_easy, premature: bool); + pub fn Curl_altsvc_parse( + data: *mut Curl_easy, + altsvc: *mut altsvcinfo, + value: *const libc::c_char, + srcalpn: alpnid, + srchost: *const libc::c_char, + srcport: libc::c_ushort, + ) -> CURLcode; + // http_digest.rs + pub fn Curl_auth_decode_digest_http_message( + chlg: *const libc::c_char, + digest: *mut digestdata, + ) -> CURLcode; + pub fn Curl_auth_create_digest_http_message( + data: *mut Curl_easy, + userp: *const libc::c_char, + passwdp: *const libc::c_char, + request: *const libc::c_uchar, + uri: *const libc::c_uchar, + digest: *mut digestdata, + outptr: *mut *mut libc::c_char, + outlen: *mut size_t, + ) -> CURLcode; + pub fn Curl_auth_digest_cleanup(digest: *mut digestdata); + + // http2.rs + pub fn curl_easy_duphandle(curl: *mut CURL) -> *mut CURL; + pub fn curl_url() -> *mut CURLU; + pub fn nghttp2_session_callbacks_new( + callbacks_ptr: *mut *mut nghttp2_session_callbacks, + ) -> libc::c_int; + pub fn nghttp2_session_callbacks_del(callbacks: *mut nghttp2_session_callbacks); + pub fn nghttp2_session_callbacks_set_send_callback( + cbs: *mut nghttp2_session_callbacks, + send_callback_0: nghttp2_send_callback, + ); + pub fn nghttp2_session_callbacks_set_on_frame_recv_callback( + cbs: *mut nghttp2_session_callbacks, + on_frame_recv_callback: nghttp2_on_frame_recv_callback, + ); + pub fn nghttp2_session_callbacks_set_on_data_chunk_recv_callback( + cbs: *mut nghttp2_session_callbacks, + on_data_chunk_recv_callback: nghttp2_on_data_chunk_recv_callback, + ); + pub fn nghttp2_session_callbacks_set_on_stream_close_callback( + cbs: *mut nghttp2_session_callbacks, + on_stream_close_callback: nghttp2_on_stream_close_callback, + ); + pub fn nghttp2_session_callbacks_set_on_begin_headers_callback( + cbs: *mut nghttp2_session_callbacks, + on_begin_headers_callback: nghttp2_on_begin_headers_callback, + ); + pub fn nghttp2_session_callbacks_set_on_header_callback( + cbs: *mut nghttp2_session_callbacks, + on_header_callback: nghttp2_on_header_callback, + ); + pub fn nghttp2_session_callbacks_set_error_callback( + cbs: *mut nghttp2_session_callbacks, + error_callback_0: nghttp2_error_callback, + ); + pub fn nghttp2_session_client_new( + session_ptr: *mut *mut nghttp2_session, + callbacks: *const nghttp2_session_callbacks, + user_data: *mut libc::c_void, + ) -> libc::c_int; + pub fn nghttp2_session_del(session: *mut nghttp2_session); + pub fn nghttp2_session_send(session: *mut nghttp2_session) -> libc::c_int; + pub fn nghttp2_session_mem_recv( + session: *mut nghttp2_session, + in_0: *const uint8_t, + inlen: size_t, + ) -> ssize_t; + pub fn nghttp2_session_resume_data( + session: *mut nghttp2_session, + stream_id: int32_t, + ) -> libc::c_int; + pub fn nghttp2_session_want_read(session: *mut nghttp2_session) -> libc::c_int; + pub fn nghttp2_session_want_write(session: *mut nghttp2_session) -> libc::c_int; + pub fn nghttp2_session_get_stream_user_data( + session: *mut nghttp2_session, + stream_id: int32_t, + ) -> *mut libc::c_void; + pub fn nghttp2_session_set_stream_user_data( + session: *mut nghttp2_session, + stream_id: int32_t, + stream_user_data: *mut libc::c_void, + ) -> libc::c_int; + pub fn nghttp2_session_get_remote_settings( + session: *mut nghttp2_session, + id: nghttp2_settings_id, + ) -> uint32_t; + pub fn nghttp2_session_upgrade2( + session: *mut nghttp2_session, + settings_payload: *const uint8_t, + settings_payloadlen: size_t, + head_request: libc::c_int, + stream_user_data: *mut libc::c_void, + ) -> libc::c_int; + pub fn nghttp2_pack_settings_payload( + buf: *mut uint8_t, + buflen: size_t, + iv: *const nghttp2_settings_entry, + niv: size_t, + ) -> ssize_t; + pub fn nghttp2_strerror(lib_error_code: libc::c_int) -> *const libc::c_char; + pub fn nghttp2_http2_strerror(error_code: uint32_t) -> *const libc::c_char; + pub fn nghttp2_priority_spec_init( + pri_spec: *mut nghttp2_priority_spec, + stream_id: int32_t, + weight: int32_t, + exclusive: libc::c_int, + ); + pub fn nghttp2_submit_request( + session: *mut nghttp2_session, + pri_spec: *const nghttp2_priority_spec, + nva: *const nghttp2_nv, + nvlen: size_t, + data_prd: *const nghttp2_data_provider, + stream_user_data: *mut libc::c_void, + ) -> int32_t; + pub fn nghttp2_submit_priority( + session: *mut nghttp2_session, + flags: uint8_t, + stream_id: int32_t, + pri_spec: *const nghttp2_priority_spec, + ) -> libc::c_int; + pub fn nghttp2_submit_rst_stream( + session: *mut nghttp2_session, + flags: uint8_t, + stream_id: int32_t, + error_code: uint32_t, + ) -> libc::c_int; + pub fn nghttp2_submit_settings( + session: *mut nghttp2_session, + flags: uint8_t, + iv: *const nghttp2_settings_entry, + niv: size_t, + ) -> libc::c_int; + pub fn nghttp2_submit_ping( + session: *mut nghttp2_session, + flags: uint8_t, + opaque_data: *const uint8_t, + ) -> libc::c_int; + pub fn nghttp2_session_check_request_allowed(session: *mut nghttp2_session) -> libc::c_int; + pub fn nghttp2_session_set_local_window_size( + session: *mut nghttp2_session, + flags: uint8_t, + stream_id: int32_t, + window_size: int32_t, + ) -> libc::c_int; + pub fn nghttp2_is_fatal(lib_error_code: libc::c_int) -> libc::c_int; + pub fn nghttp2_version(least_version: libc::c_int) -> *mut nghttp2_info; + pub fn Curl_http(data: *mut Curl_easy, done: *mut bool) -> CURLcode; + pub fn Curl_http_done(data: *mut Curl_easy, _: CURLcode, premature: bool) -> CURLcode; + pub fn Curl_base64url_encode( + data: *mut Curl_easy, + inputbuff: *const libc::c_char, + insize: size_t, + outptr: *mut *mut libc::c_char, + outlen: *mut size_t, + ) -> CURLcode; + pub fn Curl_multi_add_perform( + multi: *mut Curl_multi, + data: *mut Curl_easy, + conn: *mut connectdata, + ) -> CURLMcode; + pub fn Curl_multi_max_concurrent_streams(multi: *mut Curl_multi) -> libc::c_uint; + pub fn Curl_close(datap: *mut *mut Curl_easy) -> CURLcode; + pub fn Curl_connalive(conn: *mut connectdata) -> bool; + pub fn Curl_saferealloc(ptr: *mut libc::c_void, size: size_t) -> *mut libc::c_void; + + // mbedtls ftp + + pub fn Curl_ssl_connect( + data: *mut Curl_easy, + conn: *mut connectdata, + sockindex: libc::c_int, + ) -> CURLcode; + pub fn Curl_ssl_close(data: *mut Curl_easy, conn: *mut connectdata, sockindex: libc::c_int); + pub fn Curl_ssl_shutdown( + data: *mut Curl_easy, + conn: *mut connectdata, + sockindex: libc::c_int, + ) -> CURLcode; + + // http_ntlm.rs + pub fn curl_free(p: *mut libc::c_void); + pub fn Curl_http_auth_cleanup_ntlm_wb(conn: *mut connectdata); + pub fn Curl_base64_decode( + src: *const libc::c_char, + outptr: *mut *mut libc::c_uchar, + outlen: *mut size_t, + ) -> CURLcode; + pub fn Curl_bufref_init(br: *mut bufref); + pub fn Curl_bufref_set( + br: *mut bufref, + ptr: *const libc::c_void, + len: size_t, + dtor: Option ()>, + ); + pub fn Curl_bufref_ptr(br: *const bufref) -> *const libc::c_uchar; + pub fn Curl_bufref_len(br: *const bufref) -> size_t; + pub fn Curl_bufref_free(br: *mut bufref); + #[cfg(USE_NTLM)] + pub fn Curl_auth_create_ntlm_type1_message( + data: *mut Curl_easy, + userp: *const libc::c_char, + passwdp: *const libc::c_char, + service: *const libc::c_char, + host: *const libc::c_char, + ntlm: *mut ntlmdata, + out: *mut bufref, + ) -> CURLcode; + #[cfg(USE_NTLM)] + pub fn Curl_auth_decode_ntlm_type2_message( + data: *mut Curl_easy, + type2: *const bufref, + ntlm: *mut ntlmdata, + ) -> CURLcode; + #[cfg(USE_NTLM)] + pub fn Curl_auth_create_ntlm_type3_message( + data: *mut Curl_easy, + userp: *const libc::c_char, + passwdp: *const libc::c_char, + ntlm: *mut ntlmdata, + out: *mut bufref, + ) -> CURLcode; + #[cfg(USE_NTLM)] + pub fn Curl_auth_cleanup_ntlm(ntlm: *mut ntlmdata); + + // new http_proxy.rs + pub fn Curl_ssl_connect_nonblocking( + data: *mut Curl_easy, + conn: *mut connectdata, + isproxy: bool, + sockindex: libc::c_int, + done: *mut bool, + ) -> CURLcode; + + // http.rs + pub fn Curl_auth_is_ntlm_supported() -> bool; + pub fn Curl_input_ntlm( + data: *mut Curl_easy, + proxy: bool, + header: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_output_ntlm(data: *mut Curl_easy, proxy: bool) -> CURLcode; + pub fn Curl_input_ntlm_wb( + data: *mut Curl_easy, + conn: *mut connectdata, + proxy: bool, + header: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_output_ntlm_wb( + data: *mut Curl_easy, + conn: *mut connectdata, + proxy: bool, + ) -> CURLcode; + pub fn Curl_hsts_parse( + h: *mut hsts, + hostname: *const libc::c_char, + sts: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_auth_is_spnego_supported() -> bool; + pub fn Curl_input_negotiate( + data: *mut Curl_easy, + conn: *mut connectdata, + proxy: bool, + header: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_output_negotiate( + data: *mut Curl_easy, + conn: *mut connectdata, + proxy: bool, + ) -> CURLcode; + + // mbedtls vtls.rs + pub fn fread( + _: *mut libc::c_void, + _: libc::c_ulong, + _: libc::c_ulong, + _: *mut FILE, + ) -> libc::c_ulong; + pub fn fseek(__stream: *mut FILE, __off: libc::c_long, __whence: libc::c_int) -> libc::c_int; + pub fn ftell(__stream: *mut FILE) -> libc::c_long; + + pub fn curl_slist_free_all(_: *mut curl_slist); + pub fn memset(_: *mut libc::c_void, _: libc::c_int, _: libc::c_ulong) -> *mut libc::c_void; + + pub fn Curl_slist_append_nodup( + list: *mut curl_slist, + data: *mut libc::c_char, + ) -> *mut curl_slist; + pub fn Curl_recv_plain( + data: *mut Curl_easy, + num: libc::c_int, + buf: *mut libc::c_char, + len: size_t, + code: *mut CURLcode, + ) -> ssize_t; + pub fn Curl_send_plain( + data: *mut Curl_easy, + num: libc::c_int, + mem: *const libc::c_void, + len: size_t, + code: *mut CURLcode, + ) -> ssize_t; + + // mbedtls_threadlock.rs + pub fn pthread_mutex_init( + __mutex: *mut pthread_mutex_t, + __mutexattr: *const pthread_mutexattr_t, + ) -> libc::c_int; + pub fn pthread_mutex_destroy(__mutex: *mut pthread_mutex_t) -> libc::c_int; + pub fn pthread_mutex_lock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + pub fn pthread_mutex_unlock(__mutex: *mut pthread_mutex_t) -> libc::c_int; + + // mbedtls.rs + pub fn mbedtls_version_get_number() -> libc::c_uint; + pub fn mbedtls_net_send( + ctx: *mut libc::c_void, + buf: *const libc::c_uchar, + len: size_t, + ) -> libc::c_int; + pub fn mbedtls_net_recv( + ctx: *mut libc::c_void, + buf: *mut libc::c_uchar, + len: size_t, + ) -> libc::c_int; + pub fn mbedtls_ssl_session_free(session: *mut mbedtls_ssl_session); + pub fn mbedtls_ssl_session_init(session: *mut mbedtls_ssl_session); + pub fn mbedtls_ssl_config_free(conf: *mut mbedtls_ssl_config); + pub fn mbedtls_ssl_config_defaults( + conf: *mut mbedtls_ssl_config, + endpoint: libc::c_int, + transport: libc::c_int, + preset: libc::c_int, + ) -> libc::c_int; + pub fn mbedtls_ssl_config_init(conf: *mut mbedtls_ssl_config); + pub fn mbedtls_ssl_free(ssl: *mut mbedtls_ssl_context); + pub fn mbedtls_ssl_write( + ssl: *mut mbedtls_ssl_context, + buf: *const libc::c_uchar, + len: size_t, + ) -> libc::c_int; + pub fn mbedtls_ssl_read( + ssl: *mut mbedtls_ssl_context, + buf: *mut libc::c_uchar, + len: size_t, + ) -> libc::c_int; + pub fn mbedtls_ssl_handshake(ssl: *mut mbedtls_ssl_context) -> libc::c_int; + pub fn mbedtls_ssl_get_session( + ssl: *const mbedtls_ssl_context, + session: *mut mbedtls_ssl_session, + ) -> libc::c_int; + pub fn mbedtls_ssl_get_peer_cert(ssl: *const mbedtls_ssl_context) -> *const mbedtls_x509_crt; + pub fn mbedtls_ssl_get_ciphersuite(ssl: *const mbedtls_ssl_context) -> *const libc::c_char; + pub fn mbedtls_ssl_get_verify_result(ssl: *const mbedtls_ssl_context) -> uint32_t; + pub fn mbedtls_ssl_get_bytes_avail(ssl: *const mbedtls_ssl_context) -> size_t; + pub fn mbedtls_ssl_conf_renegotiation( + conf: *mut mbedtls_ssl_config, + renegotiation: libc::c_int, + ); + pub fn mbedtls_ssl_conf_session_tickets( + conf: *mut mbedtls_ssl_config, + use_tickets: libc::c_int, + ); + pub fn mbedtls_ssl_conf_min_version( + conf: *mut mbedtls_ssl_config, + major: libc::c_int, + minor: libc::c_int, + ); + pub fn mbedtls_ssl_conf_max_version( + conf: *mut mbedtls_ssl_config, + major: libc::c_int, + minor: libc::c_int, + ); + pub fn mbedtls_ssl_get_alpn_protocol(ssl: *const mbedtls_ssl_context) -> *const libc::c_char; + pub fn mbedtls_ssl_conf_alpn_protocols( + conf: *mut mbedtls_ssl_config, + protos: *mut *const libc::c_char, + ) -> libc::c_int; + pub fn mbedtls_ssl_set_hostname( + ssl: *mut mbedtls_ssl_context, + hostname: *const libc::c_char, + ) -> libc::c_int; + pub fn mbedtls_ssl_conf_own_cert( + conf: *mut mbedtls_ssl_config, + own_cert: *mut mbedtls_x509_crt, + pk_key: *mut mbedtls_pk_context, + ) -> libc::c_int; + pub fn mbedtls_ssl_conf_ca_chain( + conf: *mut mbedtls_ssl_config, + ca_chain: *mut mbedtls_x509_crt, + ca_crl: *mut mbedtls_x509_crl, + ); + pub fn mbedtls_ssl_conf_cert_profile( + conf: *mut mbedtls_ssl_config, + profile: *const mbedtls_x509_crt_profile, + ); + pub fn mbedtls_ssl_conf_ciphersuites( + conf: *mut mbedtls_ssl_config, + ciphersuites: *const libc::c_int, + ); + pub fn mbedtls_ssl_set_session( + ssl: *mut mbedtls_ssl_context, + session: *const mbedtls_ssl_session, + ) -> libc::c_int; + pub fn mbedtls_ssl_set_bio( + ssl: *mut mbedtls_ssl_context, + p_bio: *mut libc::c_void, + f_send: Option, + f_recv: Option, + f_recv_timeout: Option, + ); + pub fn mbedtls_ssl_conf_rng( + conf: *mut mbedtls_ssl_config, + f_rng: Option< + unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_uchar, size_t) -> libc::c_int, + >, + p_rng: *mut libc::c_void, + ); + pub fn mbedtls_ssl_conf_authmode(conf: *mut mbedtls_ssl_config, authmode: libc::c_int); + pub fn mbedtls_ssl_setup( + ssl: *mut mbedtls_ssl_context, + conf: *const mbedtls_ssl_config, + ) -> libc::c_int; + pub fn mbedtls_ssl_init(ssl: *mut mbedtls_ssl_context); + pub fn mbedtls_pk_init(ctx: *mut mbedtls_pk_context); + pub fn mbedtls_pk_free(ctx: *mut mbedtls_pk_context); + pub fn mbedtls_pk_can_do( + ctx: *const mbedtls_pk_context, + type_0: mbedtls_pk_type_t, + ) -> libc::c_int; + pub fn mbedtls_pk_parse_key( + ctx: *mut mbedtls_pk_context, + key: *const libc::c_uchar, + keylen: size_t, + pwd: *const libc::c_uchar, + pwdlen: size_t, + ) -> libc::c_int; + pub fn mbedtls_pk_parse_keyfile( + ctx: *mut mbedtls_pk_context, + path: *const libc::c_char, + password: *const libc::c_char, + ) -> libc::c_int; + pub fn mbedtls_pk_write_pubkey_der( + ctx: *mut mbedtls_pk_context, + buf: *mut libc::c_uchar, + size: size_t, + ) -> libc::c_int; + pub fn mbedtls_ssl_list_ciphersuites() -> *const libc::c_int; + pub fn mbedtls_x509_crl_parse_file( + chain: *mut mbedtls_x509_crl, + path: *const libc::c_char, + ) -> libc::c_int; + pub fn mbedtls_x509_crl_init(crl: *mut mbedtls_x509_crl); + pub fn mbedtls_x509_crl_free(crl: *mut mbedtls_x509_crl); + pub fn mbedtls_x509_crt_parse_der( + chain: *mut mbedtls_x509_crt, + buf: *const libc::c_uchar, + buflen: size_t, + ) -> libc::c_int; + pub fn mbedtls_x509_crt_parse( + chain: *mut mbedtls_x509_crt, + buf: *const libc::c_uchar, + buflen: size_t, + ) -> libc::c_int; + pub fn mbedtls_x509_crt_parse_file( + chain: *mut mbedtls_x509_crt, + path: *const libc::c_char, + ) -> libc::c_int; + pub fn mbedtls_x509_crt_parse_path( + chain: *mut mbedtls_x509_crt, + path: *const libc::c_char, + ) -> libc::c_int; + pub fn mbedtls_x509_crt_info( + buf: *mut libc::c_char, + size: size_t, + prefix: *const libc::c_char, + crt: *const mbedtls_x509_crt, + ) -> libc::c_int; + pub fn mbedtls_x509_crt_init(crt: *mut mbedtls_x509_crt); + pub fn mbedtls_x509_crt_free(crt: *mut mbedtls_x509_crt); + pub fn mbedtls_strerror(errnum: libc::c_int, buffer: *mut libc::c_char, buflen: size_t); + pub fn mbedtls_entropy_init(ctx: *mut mbedtls_entropy_context); + pub fn mbedtls_entropy_free(ctx: *mut mbedtls_entropy_context); + pub fn mbedtls_entropy_func( + data: *mut libc::c_void, + output: *mut libc::c_uchar, + len: size_t, + ) -> libc::c_int; + pub fn mbedtls_ctr_drbg_init(ctx: *mut mbedtls_ctr_drbg_context); + pub fn mbedtls_ctr_drbg_seed( + ctx: *mut mbedtls_ctr_drbg_context, + f_entropy: Option< + unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_uchar, size_t) -> libc::c_int, + >, + p_entropy: *mut libc::c_void, + custom: *const libc::c_uchar, + len: size_t, + ) -> libc::c_int; + pub fn mbedtls_ctr_drbg_free(ctx: *mut mbedtls_ctr_drbg_context); + pub fn mbedtls_ctr_drbg_random( + p_rng: *mut libc::c_void, + output: *mut libc::c_uchar, + output_len: size_t, + ) -> libc::c_int; + pub fn mbedtls_sha256_ret( + input: *const libc::c_uchar, + ilen: size_t, + output: *mut libc::c_uchar, + is224: libc::c_int, + ) -> libc::c_int; + pub fn Curl_multiuse_state(data: *mut Curl_easy, bundlestate: libc::c_int); + pub fn Curl_mbedtlsthreadlock_thread_setup() -> libc::c_int; + pub fn Curl_mbedtlsthreadlock_thread_cleanup() -> libc::c_int; + pub fn Curl_mbedtlsthreadlock_lock_function(n: libc::c_int) -> libc::c_int; + pub fn Curl_mbedtlsthreadlock_unlock_function(n: libc::c_int) -> libc::c_int; + + // gnutls gnutls.rs + pub fn send( + __fd: libc::c_int, + __buf: *const libc::c_void, + __n: size_t, + __flags: libc::c_int, + ) -> ssize_t; + pub fn recv( + __fd: libc::c_int, + __buf: *mut libc::c_void, + __n: size_t, + __flags: libc::c_int, + ) -> ssize_t; + pub fn gnutls_pk_algorithm_get_name(algorithm: gnutls_pk_algorithm_t) -> *const libc::c_char; + pub fn gnutls_init(session: *mut gnutls_session_t, flags: libc::c_uint) -> libc::c_int; + pub fn gnutls_deinit(session: gnutls_session_t); + pub fn gnutls_bye(session: gnutls_session_t, how: gnutls_close_request_t) -> libc::c_int; + pub fn gnutls_handshake(session: gnutls_session_t) -> libc::c_int; + pub fn gnutls_alert_get(session: gnutls_session_t) -> gnutls_alert_description_t; + pub fn gnutls_alert_get_name(alert: gnutls_alert_description_t) -> *const libc::c_char; + pub fn gnutls_cipher_get(session: gnutls_session_t) -> gnutls_cipher_algorithm_t; + pub fn gnutls_kx_get(session: gnutls_session_t) -> gnutls_kx_algorithm_t; + pub fn gnutls_mac_get(session: gnutls_session_t) -> gnutls_mac_algorithm_t; + pub fn gnutls_error_is_fatal(error: libc::c_int) -> libc::c_int; + pub fn gnutls_strerror(error: libc::c_int) -> *const libc::c_char; + pub fn gnutls_record_send( + session: gnutls_session_t, + data: *const libc::c_void, + data_size: size_t, + ) -> ssize_t; + pub fn gnutls_record_recv( + session: gnutls_session_t, + data: *mut libc::c_void, + data_size: size_t, + ) -> ssize_t; + pub fn gnutls_record_get_direction(session: gnutls_session_t) -> libc::c_int; + pub fn gnutls_record_check_pending(session: gnutls_session_t) -> size_t; + pub fn gnutls_server_name_set( + session: gnutls_session_t, + type_0: gnutls_server_name_type_t, + name: *const libc::c_void, + name_length: size_t, + ) -> libc::c_int; + pub fn gnutls_alpn_get_selected_protocol( + session: gnutls_session_t, + protocol: *mut gnutls_datum_t, + ) -> libc::c_int; + pub fn gnutls_alpn_set_protocols( + session: gnutls_session_t, + protocols: *const gnutls_datum_t, + protocols_size: libc::c_uint, + flags: libc::c_uint, + ) -> libc::c_int; + pub fn gnutls_priority_set_direct( + session: gnutls_session_t, + priorities: *const libc::c_char, + err_pos: *mut *const libc::c_char, + ) -> libc::c_int; + pub fn gnutls_set_default_priority(session: gnutls_session_t) -> libc::c_int; + pub fn gnutls_cipher_suite_get_name( + kx_algorithm: gnutls_kx_algorithm_t, + cipher_algorithm: gnutls_cipher_algorithm_t, + mac_algorithm: gnutls_mac_algorithm_t, + ) -> *const libc::c_char; + pub fn gnutls_protocol_get_version(session: gnutls_session_t) -> gnutls_protocol_t; + pub fn gnutls_protocol_get_name(version: gnutls_protocol_t) -> *const libc::c_char; + pub fn gnutls_session_set_data( + session: gnutls_session_t, + session_data: *const libc::c_void, + session_data_size: size_t, + ) -> libc::c_int; + pub fn gnutls_session_get_data( + session: gnutls_session_t, + session_data: *mut libc::c_void, + session_data_size: *mut size_t, + ) -> libc::c_int; + pub fn gnutls_check_version(req_version: *const libc::c_char) -> *const libc::c_char; + pub fn gnutls_credentials_set( + session: gnutls_session_t, + type_0: gnutls_credentials_type_t, + cred: *mut libc::c_void, + ) -> libc::c_int; + pub fn gnutls_certificate_free_credentials(sc: gnutls_certificate_credentials_t); + pub fn gnutls_certificate_allocate_credentials( + res: *mut gnutls_certificate_credentials_t, + ) -> libc::c_int; + pub fn gnutls_certificate_set_verify_flags( + res: gnutls_certificate_credentials_t, + flags: libc::c_uint, + ); + pub fn gnutls_certificate_set_x509_trust_file( + cred: gnutls_certificate_credentials_t, + cafile: *const libc::c_char, + type_0: gnutls_x509_crt_fmt_t, + ) -> libc::c_int; + pub fn gnutls_certificate_set_x509_trust_dir( + cred: gnutls_certificate_credentials_t, + ca_dir: *const libc::c_char, + type_0: gnutls_x509_crt_fmt_t, + ) -> libc::c_int; + pub fn gnutls_certificate_set_x509_crl_file( + res: gnutls_certificate_credentials_t, + crlfile: *const libc::c_char, + type_0: gnutls_x509_crt_fmt_t, + ) -> libc::c_int; + pub fn gnutls_certificate_set_x509_key_file( + res: gnutls_certificate_credentials_t, + certfile: *const libc::c_char, + keyfile: *const libc::c_char, + type_0: gnutls_x509_crt_fmt_t, + ) -> libc::c_int; + pub fn gnutls_certificate_set_x509_key_file2( + res: gnutls_certificate_credentials_t, + certfile: *const libc::c_char, + keyfile: *const libc::c_char, + type_0: gnutls_x509_crt_fmt_t, + pass: *const libc::c_char, + flags: libc::c_uint, + ) -> libc::c_int; + pub fn gnutls_ocsp_status_request_enable_client( + session: gnutls_session_t, + responder_id: *mut gnutls_datum_t, + responder_id_size: size_t, + request_extensions: *mut gnutls_datum_t, + ) -> libc::c_int; + pub fn gnutls_ocsp_status_request_get( + session: gnutls_session_t, + response: *mut gnutls_datum_t, + ) -> libc::c_int; + pub fn gnutls_ocsp_status_request_is_checked( + session: gnutls_session_t, + flags: libc::c_uint, + ) -> libc::c_uint; + pub fn gnutls_global_init() -> libc::c_int; + pub fn gnutls_global_deinit(); + static mut gnutls_free: gnutls_free_function; + pub fn gnutls_transport_set_ptr(session: gnutls_session_t, ptr: gnutls_transport_ptr_t); + pub fn gnutls_transport_set_push_function( + session: gnutls_session_t, + push_func: gnutls_push_func, + ); + pub fn gnutls_transport_set_pull_function( + session: gnutls_session_t, + pull_func: gnutls_pull_func, + ); + pub fn gnutls_srp_free_client_credentials(sc: gnutls_srp_client_credentials_t); + pub fn gnutls_srp_allocate_client_credentials( + sc: *mut gnutls_srp_client_credentials_t, + ) -> libc::c_int; + pub fn gnutls_srp_set_client_credentials( + res: gnutls_srp_client_credentials_t, + username: *const libc::c_char, + password: *const libc::c_char, + ) -> libc::c_int; + pub fn gnutls_certificate_get_peers( + session: gnutls_session_t, + list_size: *mut libc::c_uint, + ) -> *const gnutls_datum_t; + pub fn gnutls_certificate_verify_peers2( + session: gnutls_session_t, + status: *mut libc::c_uint, + ) -> libc::c_int; + pub fn gnutls_pubkey_export( + key: gnutls_pubkey_t, + format: gnutls_x509_crt_fmt_t, + output_data: *mut libc::c_void, + output_data_size: *mut size_t, + ) -> libc::c_int; + pub fn gnutls_x509_crt_init(cert: *mut gnutls_x509_crt_t) -> libc::c_int; + pub fn gnutls_x509_crt_deinit(cert: gnutls_x509_crt_t); + pub fn gnutls_x509_crt_import( + cert: gnutls_x509_crt_t, + data: *const gnutls_datum_t, + format: gnutls_x509_crt_fmt_t, + ) -> libc::c_int; + pub fn gnutls_x509_crt_get_issuer_dn2( + cert: gnutls_x509_crt_t, + dn: *mut gnutls_datum_t, + ) -> libc::c_int; + pub fn gnutls_x509_crt_get_dn2(cert: gnutls_x509_crt_t, dn: *mut gnutls_datum_t) + -> libc::c_int; + pub fn gnutls_x509_crt_get_dn_by_oid( + cert: gnutls_x509_crt_t, + oid: *const libc::c_char, + indx: libc::c_uint, + raw_flag: libc::c_uint, + buf: *mut libc::c_void, + buf_size: *mut size_t, + ) -> libc::c_int; + pub fn gnutls_x509_crt_check_hostname( + cert: gnutls_x509_crt_t, + hostname: *const libc::c_char, + ) -> libc::c_uint; + pub fn gnutls_x509_crt_get_version(cert: gnutls_x509_crt_t) -> libc::c_int; + pub fn gnutls_x509_crt_get_activation_time(cert: gnutls_x509_crt_t) -> time_t; + pub fn gnutls_x509_crt_get_expiration_time(cert: gnutls_x509_crt_t) -> time_t; + pub fn gnutls_x509_crt_get_pk_algorithm( + cert: gnutls_x509_crt_t, + bits: *mut libc::c_uint, + ) -> libc::c_int; + pub fn gnutls_x509_crt_check_issuer( + cert: gnutls_x509_crt_t, + issuer: gnutls_x509_crt_t, + ) -> libc::c_uint; + pub fn gnutls_pubkey_import_x509( + key: gnutls_pubkey_t, + crt: gnutls_x509_crt_t, + flags: libc::c_uint, + ) -> libc::c_int; + pub fn gnutls_pubkey_deinit(key: gnutls_pubkey_t); + pub fn gnutls_pubkey_init(key: *mut gnutls_pubkey_t) -> libc::c_int; + pub fn gnutls_rnd( + level: gnutls_rnd_level_t, + data: *mut libc::c_void, + len: size_t, + ) -> libc::c_int; + pub fn nettle_sha256_digest(ctx: *mut sha256_ctx, length: size_t, digest: *mut uint8_t); + pub fn nettle_sha256_update(ctx: *mut sha256_ctx, length: size_t, data: *const uint8_t); + pub fn nettle_sha256_init(ctx: *mut sha256_ctx); + pub fn Curl_extract_certinfo( + data: *mut Curl_easy, + certnum: libc::c_int, + beg: *const libc::c_char, + end: *const libc::c_char, + ) -> CURLcode; + + pub fn gnutls_ocsp_resp_init(resp: *mut gnutls_ocsp_resp_t) -> libc::c_int; + pub fn gnutls_ocsp_resp_deinit(resp: gnutls_ocsp_resp_t); + pub fn gnutls_ocsp_resp_import( + resp: gnutls_ocsp_resp_t, + data: *const gnutls_datum_t, + ) -> libc::c_int; + pub fn gnutls_ocsp_resp_get_single( + resp: gnutls_ocsp_resp_const_t, + indx: libc::c_uint, + digest: *mut gnutls_digest_algorithm_t, + issuer_name_hash: *mut gnutls_datum_t, + issuer_key_hash: *mut gnutls_datum_t, + serial_number: *mut gnutls_datum_t, + cert_status: *mut libc::c_uint, + this_update: *mut time_t, + next_update: *mut time_t, + revocation_time: *mut time_t, + revocation_reason: *mut libc::c_uint, + ) -> libc::c_int; + + // wolfssl.rs + + // pub fn Curl_none_check_cxn(conn: *mut connectdata) -> libc::c_int; + // pub fn Curl_none_close_all(data: *mut Curl_easy); + // pub fn Curl_none_set_engine( + // data: *mut Curl_easy, + // engine: *const libc::c_char, + // ) -> CURLcode; + // pub fn Curl_none_set_engine_default(data: *mut Curl_easy) -> CURLcode; + // pub fn Curl_none_engines_list(data: *mut Curl_easy) -> *mut curl_slist; + // pub fn Curl_none_false_start() -> bool; + // pub fn Curl_ssl_getsock( + // conn: *mut connectdata, + // socks: *mut curl_socket_t, + // ) -> libc::c_int; + // pub fn Curl_ssl_sessionid_lock(data: *mut Curl_easy); + // pub fn Curl_ssl_sessionid_unlock(data: *mut Curl_easy); + // pub fn Curl_ssl_getsessionid( + // data: *mut Curl_easy, + // conn: *mut connectdata, + // isProxy: bool, + // ssl_sessionid: *mut *mut libc::c_void, + // idsize: *mut size_t, + // sockindex: libc::c_int, + // ) -> bool; + // pub fn Curl_ssl_addsessionid( + // data: *mut Curl_easy, + // conn: *mut connectdata, + // isProxy: bool, + // ssl_sessionid: *mut libc::c_void, + // idsize: size_t, + // sockindex: libc::c_int, + // ) -> CURLcode; + // pub fn Curl_ssl_delsessionid(data: *mut Curl_easy, ssl_sessionid: *mut libc::c_void); + // pub fn Curl_pin_peer_pubkey( + // data: *mut Curl_easy, + // pinnedpubkey: *const libc::c_char, + // pubkey: *const libc::c_uchar, + // pubkeylen: size_t, + // ) -> CURLcode; + // pub fn Curl_tls_keylog_open(); + // pub fn Curl_tls_keylog_close(); + // pub fn Curl_tls_keylog_enabled() -> bool; + // pub fn Curl_tls_keylog_write( + // label: *const libc::c_char, + // client_random: *const libc::c_uchar, + // secret: *const libc::c_uchar, + // secretlen: size_t, + // ) -> bool; + pub fn Curl_parseX509( + cert: *mut Curl_X509certificate, + beg: *const libc::c_char, + end: *const libc::c_char, + ) -> libc::c_int; + pub fn wolfSSL_CTX_set_verify( + _: *mut WOLFSSL_CTX, + _: libc::c_int, + verify_callback: VerifyCallback, + ); + pub fn wolfSSL_CTX_use_PrivateKey_file( + _: *mut WOLFSSL_CTX, + _: *const libc::c_char, + _: libc::c_int, + ) -> libc::c_int; + pub fn wolfSSL_CTX_use_certificate_file( + _: *mut WOLFSSL_CTX, + _: *const libc::c_char, + _: libc::c_int, + ) -> libc::c_int; + pub fn wolfSSL_CTX_load_verify_locations( + _: *mut WOLFSSL_CTX, + _: *const libc::c_char, + _: *const libc::c_char, + ) -> libc::c_int; + pub fn wolfSSL_CTX_set_cipher_list(_: *mut WOLFSSL_CTX, _: *const libc::c_char) -> libc::c_int; + pub fn wolfSSL_CTX_SetMinVersion(ctx: *mut WOLFSSL_CTX, version: libc::c_int) -> libc::c_int; + pub fn wolfSSL_CTX_new(_: *mut WOLFSSL_METHOD) -> *mut WOLFSSL_CTX; + pub fn wolfTLSv1_2_client_method() -> *mut WOLFSSL_METHOD; + pub fn wolfTLSv1_1_client_method() -> *mut WOLFSSL_METHOD; + pub fn wolfSSLv23_client_method() -> *mut WOLFSSL_METHOD; + pub fn wc_FreeRng(_: *mut WC_RNG) -> libc::c_int; + pub fn wc_RNG_GenerateBlock(_: *mut WC_RNG, _: *mut byte, sz: word32) -> libc::c_int; + pub fn wc_InitRng(_: *mut WC_RNG) -> libc::c_int; + pub fn wolfSSL_pending(_: *mut WOLFSSL) -> libc::c_int; + pub fn wolfSSL_lib_version() -> *const libc::c_char; + pub fn wolfSSL_Cleanup() -> libc::c_int; + pub fn wolfSSL_Init() -> libc::c_int; + pub fn wolfSSL_check_domain_name(ssl: *mut WOLFSSL, dn: *const libc::c_char) -> libc::c_int; + pub fn wolfSSL_new(_: *mut WOLFSSL_CTX) -> *mut WOLFSSL; + pub fn wolfSSL_KeepArrays(_: *mut WOLFSSL); + pub fn wolfSSL_set_session(ssl: *mut WOLFSSL, session: *mut WOLFSSL_SESSION) -> libc::c_int; + pub fn wolfSSL_set_fd(_: *mut WOLFSSL, _: libc::c_int) -> libc::c_int; + pub fn wolfSSL_connect(_: *mut WOLFSSL) -> libc::c_int; + pub fn wolfSSL_want_read(_: *mut WOLFSSL) -> libc::c_int; + pub fn wolfSSL_want_write(_: *mut WOLFSSL) -> libc::c_int; + pub fn wolfSSL_GetVersion(ssl: *mut WOLFSSL) -> libc::c_int; + pub fn wolfSSL_get_keys( + _: *mut WOLFSSL, + ms: *mut *mut libc::c_uchar, + msLen: *mut libc::c_uint, + sr: *mut *mut libc::c_uchar, + srLen: *mut libc::c_uint, + cr: *mut *mut libc::c_uchar, + crLen: *mut libc::c_uint, + ) -> libc::c_int; + pub fn wolfSSL_FreeArrays(_: *mut WOLFSSL); + pub fn wolfSSL_get_peer_certificate(ssl: *mut WOLFSSL) -> *mut WOLFSSL_X509; + pub fn wolfSSL_X509_get_der(_: *mut WOLFSSL_X509, _: *mut libc::c_int) -> *const libc::c_uchar; + pub fn wolfSSL_get_version(_: *mut WOLFSSL) -> *const libc::c_char; + pub fn wolfSSL_get_cipher_name(ssl: *mut WOLFSSL) -> *const libc::c_char; + pub fn wolfSSL_get_session(ssl: *mut WOLFSSL) -> *mut WOLFSSL_SESSION; + pub fn wolfSSL_ERR_clear_error(); + pub fn wolfSSL_write(_: *mut WOLFSSL, _: *const libc::c_void, _: libc::c_int) -> libc::c_int; + pub fn wolfSSL_ERR_error_string(_: libc::c_ulong, _: *mut libc::c_char) -> *mut libc::c_char; + pub fn wolfSSL_get_error(_: *mut WOLFSSL, _: libc::c_int) -> libc::c_int; + pub fn wolfSSL_read(_: *mut WOLFSSL, _: *mut libc::c_void, _: libc::c_int) -> libc::c_int; + pub fn wolfSSL_shutdown(_: *mut WOLFSSL) -> libc::c_int; + pub fn wolfSSL_free(_: *mut WOLFSSL); + pub fn wolfSSL_CTX_free(_: *mut WOLFSSL_CTX); + pub fn wc_InitSha256(_: *mut wc_Sha256) -> libc::c_int; + pub fn wc_Sha256Update(_: *mut wc_Sha256, _: *const byte, _: word32) -> libc::c_int; + pub fn wc_Sha256Final(_: *mut wc_Sha256, _: *mut byte) -> libc::c_int; + + // nss.rs + pub fn __xstat( + __ver: libc::c_int, + __filename: *const libc::c_char, + __stat_buf: *mut stat, + ) -> libc::c_int; + pub fn getenv(__name: *const libc::c_char) -> *mut libc::c_char; + pub fn Curl_llist_destroy(_: *mut Curl_llist, _: *mut libc::c_void); + // pub fn Curl_ssl_init_certinfo(data: *mut Curl_easy, num: libc::c_int) -> CURLcode; + // pub fn Curl_pin_peer_pubkey( + // data: *mut Curl_easy, + // pinnedpubkey: *const libc::c_char, + // pubkey: *const libc::c_uchar, + // pubkeylen: size_t, + // ) -> CURLcode; + pub fn PR_ErrorToName(code: PRErrorCode) -> *const libc::c_char; + pub fn PR_GetError() -> PRErrorCode; + pub fn PR_Lock(lock: *mut PRLock); + pub fn PR_ErrorToString(code: PRErrorCode, language: PRLanguageCode) -> *const libc::c_char; + pub fn PR_Now() -> PRTime; + pub fn PR_Free(ptr: *mut libc::c_void); + pub fn PR_FormatTime( + buf: *mut libc::c_char, + buflen: libc::c_int, + fmt: *const libc::c_char, + time: *const PRExplodedTime, + ) -> PRUint32; + pub fn PR_GMTParameters(gmt: *const PRExplodedTime) -> PRTimeParameters; + pub fn PR_ExplodeTime(usecs: PRTime, params: PRTimeParamFn, exploded: *mut PRExplodedTime); + pub fn PR_Unlock(lock: *mut PRLock) -> PRStatus; + pub fn PR_MillisecondsToInterval(milli: PRUint32) -> PRIntervalTime; + pub fn PR_Init(type_0: PRThreadType, priority: PRThreadPriority, maxPTDs: PRUintn); + pub fn PR_SetError(errorCode: PRErrorCode, oserr: PRInt32); + pub fn PR_NewLock() -> *mut PRLock; + pub fn PR_DestroyLock(lock: *mut PRLock); + pub fn PR_SecondsToInterval(seconds: PRUint32) -> PRIntervalTime; + pub fn PR_GetOpenFileInfo(fd: *mut PRFileDesc, info: *mut PRFileInfo) -> PRStatus; + pub fn PR_OpenDir(name: *const libc::c_char) -> *mut PRDir; + pub fn PR_CloseDir(dir: *mut PRDir) -> PRStatus; + pub fn PR_Read(fd: *mut PRFileDesc, buf: *mut libc::c_void, amount: PRInt32) -> PRInt32; + pub fn PR_ReadDir(dir: *mut PRDir, flags: PRDirFlags) -> *mut PRDirEntry; + pub fn PR_GetDefaultIOMethods() -> *const PRIOMethods; + pub fn PR_Close(fd: *mut PRFileDesc) -> PRStatus; + pub fn PR_PushIOLayer( + fd_stack: *mut PRFileDesc, + id: PRDescIdentity, + layer: *mut PRFileDesc, + ) -> PRStatus; + pub fn PR_CreateIOLayerStub( + ident: PRDescIdentity, + methods: *const PRIOMethods, + ) -> *mut PRFileDesc; + pub fn PR_GetUniqueIdentity(layer_name: *const libc::c_char) -> PRDescIdentity; + pub fn PR_Open(name: *const libc::c_char, flags: PRIntn, mode: PRIntn) -> *mut PRFileDesc; + pub fn PR_NewTCPSocket() -> *mut PRFileDesc; + pub fn PR_Recv( + fd: *mut PRFileDesc, + buf: *mut libc::c_void, + amount: PRInt32, + flags: PRIntn, + timeout: PRIntervalTime, + ) -> PRInt32; + pub fn PR_Send( + fd: *mut PRFileDesc, + buf: *const libc::c_void, + amount: PRInt32, + flags: PRIntn, + timeout: PRIntervalTime, + ) -> PRInt32; + pub fn PR_SetSocketOption(fd: *mut PRFileDesc, data: *const PRSocketOptionData) -> PRStatus; + pub fn NSS_ShutdownContext(_: *mut NSSInitContext) -> SECStatus; + pub fn NSS_GetVersion() -> *const libc::c_char; + pub fn PORT_Strdup(s: *const libc::c_char) -> *mut libc::c_char; + pub fn NSS_InitContext( + configdir: *const libc::c_char, + certPrefix: *const libc::c_char, + keyPrefix: *const libc::c_char, + secmodName: *const libc::c_char, + initParams: *mut NSSInitParameters, + flags: PRUint32, + ) -> *mut NSSInitContext; + pub fn SSL_VersionRangeGetDefault( + protocolVariant: SSLProtocolVariant, + vrange: *mut SSLVersionRange, + ) -> SECStatus; + pub fn SSL_VersionRangeGetSupported( + protocolVariant: SSLProtocolVariant, + vrange: *mut SSLVersionRange, + ) -> SECStatus; + pub fn SSL_VersionRangeSet(fd: *mut PRFileDesc, vrange: *const SSLVersionRange) -> SECStatus; + pub fn SSL_GetNumImplementedCiphers() -> PRUint16; + pub fn SSL_GetImplementedCiphers() -> *const PRUint16; + pub fn SSL_CipherPrefSet(fd: *mut PRFileDesc, cipher: PRInt32, enabled: PRBool) -> SECStatus; + pub fn SSL_AuthCertificateHook( + fd: *mut PRFileDesc, + f: SSLAuthCertificate, + arg: *mut libc::c_void, + ) -> SECStatus; + pub fn SSL_PeerStapledOCSPResponses(fd: *mut PRFileDesc) -> *const SECItemArray; + pub fn SSL_AuthCertificate( + arg: *mut libc::c_void, + fd: *mut PRFileDesc, + checkSig: PRBool, + isServer: PRBool, + ) -> SECStatus; + pub fn SSL_BadCertHook( + fd: *mut PRFileDesc, + f: SSLBadCertHandler, + arg: *mut libc::c_void, + ) -> SECStatus; + pub fn SSL_GetNextProto( + fd: *mut PRFileDesc, + state: *mut SSLNextProtoState, + buf: *mut libc::c_uchar, + bufLen: *mut libc::c_uint, + bufLenMax: libc::c_uint, + ) -> SECStatus; + pub fn SECITEM_AllocItem( + arena: *mut PLArenaPool, + item: *mut SECItem, + len: libc::c_uint, + ) -> *mut SECItem; + pub fn CERT_CacheCRL(dbhandle: *mut CERTCertDBHandle, newcrl: *mut SECItem) -> SECStatus; + pub fn CERT_UncacheCRL(dbhandle: *mut CERTCertDBHandle, oldcrl: *mut SECItem) -> SECStatus; + pub fn CERT_GetDefaultCertDB() -> *mut CERTCertDBHandle; + pub fn SSL_ClearSessionCache(); + pub fn SSL_GetClientAuthDataHook( + fd: *mut PRFileDesc, + f: SSLGetClientAuthData, + a: *mut libc::c_void, + ) -> SECStatus; + pub fn SSL_SetSockPeerID(fd: *mut PRFileDesc, peerID: *const libc::c_char) -> SECStatus; + pub fn NSS_GetClientAuthData( + arg: *mut libc::c_void, + socket: *mut PRFileDesc, + caNames: *mut CERTDistNamesStr, + pRetCert: *mut *mut CERTCertificateStr, + pRetKey: *mut *mut SECKEYPrivateKeyStr, + ) -> SECStatus; + pub fn SSL_ImportFD(model: *mut PRFileDesc, fd: *mut PRFileDesc) -> *mut PRFileDesc; + pub fn SSL_SetPKCS11PinArg(fd: *mut PRFileDesc, a: *mut libc::c_void) -> SECStatus; + pub fn SSL_OptionSet(fd: *mut PRFileDesc, option: PRInt32, val: PRIntn) -> SECStatus; + pub fn SSL_SetCanFalseStartCallback( + fd: *mut PRFileDesc, + callback: SSLCanFalseStartCallback, + arg: *mut libc::c_void, + ) -> SECStatus; + pub fn SSL_HandshakeNegotiatedExtension( + socket: *mut PRFileDesc, + extId: SSLExtensionType, + yes: *mut PRBool, + ) -> SECStatus; + pub fn SSL_SetNextProtoNego( + fd: *mut PRFileDesc, + data: *const libc::c_uchar, + length: libc::c_uint, + ) -> SECStatus; + pub fn SSL_ResetHandshake(fd: *mut PRFileDesc, asServer: PRBool) -> SECStatus; + pub fn SSL_SetURL(fd: *mut PRFileDesc, url: *const libc::c_char) -> SECStatus; + pub fn SSL_ForceHandshakeWithTimeout(fd: *mut PRFileDesc, timeout: PRIntervalTime) + -> SECStatus; + pub fn SSL_GetChannelInfo( + fd: *mut PRFileDesc, + info: *mut SSLChannelInfo, + len: PRUintn, + ) -> SECStatus; + pub fn SSL_GetCipherSuiteInfo( + cipherSuite: PRUint16, + info: *mut SSLCipherSuiteInfo, + len: PRUintn, + ) -> SECStatus; + pub fn CERT_NameToAscii(name: *mut CERTName) -> *mut libc::c_char; + pub fn CERT_GetCommonName(name: *const CERTName) -> *mut libc::c_char; + pub fn CERT_GetCertTimes( + c: *const CERTCertificate, + notBefore: *mut PRTime, + notAfter: *mut PRTime, + ) -> SECStatus; + pub fn CERT_FindCertIssuer( + cert: *mut CERTCertificate, + validTime: PRTime, + usage: SECCertUsage, + ) -> *mut CERTCertificate; + pub fn SSL_RevealPinArg(socket: *mut PRFileDesc) -> *mut libc::c_void; + pub fn SECITEM_CompareItem(a: *const SECItem, b: *const SECItem) -> SECComparison; + pub fn SSL_PeerCertificate(fd: *mut PRFileDesc) -> *mut CERTCertificate; + pub fn SECKEY_DestroyPublicKey(key: *mut SECKEYPublicKey); + pub fn CERT_ExtractPublicKey(cert: *mut CERTCertificate) -> *mut SECKEYPublicKey; + pub fn CERT_DestroyCertificate(cert: *mut CERTCertificate); + pub fn SSL_InvalidateSession(fd: *mut PRFileDesc) -> SECStatus; + pub fn SECITEM_FreeItem(zap: *mut SECItem, freeit: PRBool); + pub fn SSL_CipherPolicyGet(cipher: PRInt32, policy: *mut PRInt32) -> SECStatus; + pub fn NSS_SetDomesticPolicy() -> SECStatus; + pub fn SSL_HandshakeCallback( + fd: *mut PRFileDesc, + cb: SSLHandshakeCallback, + client_data: *mut libc::c_void, + ) -> SECStatus; + pub fn SECMOD_LoadUserModule( + moduleSpec: *mut libc::c_char, + parent: *mut SECMODModule, + recurse: PRBool, + ) -> *mut SECMODModule; + pub fn SECMOD_UnloadUserModule(mod_0: *mut SECMODModule) -> SECStatus; + pub fn SECMOD_DestroyModule(module: *mut SECMODModule); + pub fn SECMOD_WaitForAnyTokenEvent( + mod_0: *mut SECMODModule, + flags: libc::c_ulong, + latency: PRIntervalTime, + ) -> *mut PK11SlotInfo; + pub fn PK11_FreeSlot(slot: *mut PK11SlotInfo); + pub fn PK11_SetPasswordFunc(func: PK11PasswordFunc); + pub fn PK11_Authenticate( + slot: *mut PK11SlotInfo, + loadCerts: PRBool, + wincx: *mut libc::c_void, + ) -> SECStatus; + pub fn PK11_FindSlotByName(name: *const libc::c_char) -> *mut PK11SlotInfo; + pub fn PK11_IsPresent(slot: *mut PK11SlotInfo) -> PRBool; + pub fn PK11_GenerateRandom(data: *mut libc::c_uchar, len: libc::c_int) -> SECStatus; + pub fn PK11_FindPrivateKeyFromCert( + slot: *mut PK11SlotInfo, + cert: *mut CERTCertificate, + wincx: *mut libc::c_void, + ) -> *mut SECKEYPrivateKey; + pub fn PK11_DEREncodePublicKey(pubk: *const SECKEYPublicKey) -> *mut SECItem; + pub fn PK11_FindCertFromNickname( + nickname: *const libc::c_char, + wincx: *mut libc::c_void, + ) -> *mut CERTCertificate; + pub fn PK11_FindCertFromDERCertItem( + slot: *mut PK11SlotInfo, + derCert: *const SECItem, + wincx: *mut libc::c_void, + ) -> *mut CERTCertificate; + pub fn PK11_DestroyContext(context: *mut PK11Context, freeit: PRBool); + pub fn PK11_CreateDigestContext(hashAlg: SECOidTag) -> *mut PK11Context; + pub fn PK11_DigestOp( + context: *mut PK11Context, + in_0: *const libc::c_uchar, + len: libc::c_uint, + ) -> SECStatus; + pub fn PK11_DigestFinal( + context: *mut PK11Context, + data: *mut libc::c_uchar, + outLen: *mut libc::c_uint, + length: libc::c_uint, + ) -> SECStatus; + pub fn PK11_ReadRawAttribute( + type_0: PK11ObjectType, + object: *mut libc::c_void, + attr: CK_ATTRIBUTE_TYPE, + item: *mut SECItem, + ) -> SECStatus; + pub fn PK11_DestroyGenericObject(object: *mut PK11GenericObject) -> SECStatus; + pub fn PK11_CreateManagedGenericObject( + slot: *mut PK11SlotInfo, + pTemplate: *const CK_ATTRIBUTE, + count: libc::c_int, + token: PRBool, + ) -> *mut PK11GenericObject; + pub fn SEC_FindCrlByDERCert( + handle: *mut CERTCertDBHandle, + derCrl: *mut SECItem, + type_0: libc::c_int, + ) -> *mut CERTSignedCrl; + pub fn SEC_DestroyCrl(crl: *mut CERTSignedCrl) -> SECStatus; + pub fn ATOB_ConvertAsciiToItem( + binary_item: *mut SECItem, + ascii: *const libc::c_char, + ) -> SECStatus; + pub fn PR_ImportTCPSocket(osfd: PROsfd) -> *mut PRFileDesc; + pub fn CERT_CacheOCSPResponseFromSideChannel( + handle: *mut CERTCertDBHandle, + cert: *mut CERTCertificate, + time: PRTime, + encodedResponse: *const SECItem, + pwArg: *mut libc::c_void, + ) -> SECStatus; + pub fn curlx_uztosi(uznum: size_t) -> libc::c_int; + pub fn curlx_uztoui(uznum: size_t) -> libc::c_uint; + pub fn strpbrk(_: *const libc::c_char, _: *const libc::c_char) -> *mut libc::c_char; + pub fn Curl_llist_init(_: *mut Curl_llist, _: Curl_llist_dtor); + // rustls.rs + pub fn rustls_client_config_builder_dangerous_set_certificate_verifier( + config: *mut rustls_client_config_builder, + callback: rustls_verify_server_cert_callback, + ); + pub fn rustls_client_config_builder_load_roots_from_file( + config: *mut rustls_client_config_builder, + filename: *const libc::c_char, + ) -> rustls_result; + pub fn rustls_client_config_builder_set_protocols( + builder: *mut rustls_client_config_builder, + protocols: *const rustls_slice_bytes, + len: size_t, + ) -> rustls_result; + pub fn rustls_client_config_builder_set_enable_sni( + config: *mut rustls_client_config_builder, + enable: bool, + ); + pub fn rustls_client_config_free(config: *const rustls_client_config); + pub fn rustls_client_connection_new( + config: *const rustls_client_config, + hostname: *const libc::c_char, + conn_out: *mut *mut rustls_connection, + ) -> rustls_result; + pub fn rustls_connection_set_userdata( + conn: *mut rustls_connection, + userdata: *mut libc::c_void, + ); + pub fn rustls_connection_read_tls( + conn: *mut rustls_connection, + callback: rustls_read_callback, + userdata: *mut libc::c_void, + out_n: *mut size_t, + ) -> rustls_io_result; + pub fn rustls_connection_write_tls( + conn: *mut rustls_connection, + callback: rustls_write_callback, + userdata: *mut libc::c_void, + out_n: *mut size_t, + ) -> rustls_io_result; + pub fn rustls_connection_process_new_packets(conn: *mut rustls_connection) -> rustls_result; + pub fn rustls_connection_wants_read(conn: *const rustls_connection) -> bool; + pub fn rustls_connection_wants_write(conn: *const rustls_connection) -> bool; + pub fn rustls_connection_is_handshaking(conn: *const rustls_connection) -> bool; + pub fn rustls_version(buf: *mut libc::c_char, len: size_t) -> size_t; + pub fn rustls_connection_send_close_notify(conn: *mut rustls_connection); + pub fn rustls_connection_get_alpn_protocol( + conn: *const rustls_connection, + protocol_out: *mut *const uint8_t, + protocol_out_len: *mut size_t, + ); + pub fn rustls_connection_write( + conn: *mut rustls_connection, + buf: *const uint8_t, + count: size_t, + out_n: *mut size_t, + ) -> rustls_result; + pub fn rustls_connection_read( + conn: *mut rustls_connection, + buf: *mut uint8_t, + count: size_t, + out_n: *mut size_t, + ) -> rustls_result; + pub fn rustls_connection_free(conn: *mut rustls_connection); + pub fn rustls_error( + result: rustls_result, + buf: *mut libc::c_char, + len: size_t, + out_n: *mut size_t, + ); + pub fn rustls_result_is_cert_error(result: rustls_result) -> bool; + pub fn rustls_client_config_builder_build( + builder: *mut rustls_client_config_builder, + ) -> *const rustls_client_config; + pub fn rustls_client_config_builder_new() -> *mut rustls_client_config_builder; + // pub fn Curl_none_init() -> libc::c_int; + // pub fn Curl_none_cleanup(); + // pub fn Curl_none_check_cxn(conn: *mut connectdata) -> libc::c_int; + // pub fn Curl_none_random( + // data: *mut Curl_easy, + // entropy: *mut libc::c_uchar, + // length: size_t, + // ) -> CURLcode; + // pub fn Curl_none_close_all(data: *mut Curl_easy); + // pub fn Curl_none_session_free(ptr: *mut libc::c_void); + // pub fn Curl_none_cert_status_request() -> bool; + // pub fn Curl_none_set_engine( + // data: *mut Curl_easy, + // engine: *const libc::c_char, + // ) -> CURLcode; + // pub fn Curl_none_set_engine_default(data: *mut Curl_easy) -> CURLcode; + // pub fn Curl_none_engines_list(data: *mut Curl_easy) -> *mut curl_slist; + // pub fn Curl_none_false_start() -> bool; + + // mesalink.rs + pub fn mesalink_SSL_CTX_use_PrivateKey_file( + _: *mut MESALINK_CTX, + _: *const libc::c_char, + _: libc::c_int, + ) -> libc::c_int; + pub fn mesalink_library_init() -> libc::c_int; + pub fn mesalink_TLSv1_2_client_method() -> *mut MESALINK_METHOD; + pub fn mesalink_TLSv1_3_client_method() -> *mut MESALINK_METHOD; + pub fn mesalink_SSL_CTX_new(_: *mut MESALINK_METHOD) -> *mut MESALINK_CTX; + pub fn mesalink_SSL_CTX_load_verify_locations( + _: *mut MESALINK_CTX, + _: *const libc::c_char, + _: *const libc::c_char, + ) -> libc::c_int; + pub fn mesalink_SSL_CTX_use_certificate_chain_file( + _: *mut MESALINK_CTX, + _: *const libc::c_char, + _: libc::c_int, + ) -> libc::c_int; + pub fn mesalink_SSL_CTX_set_verify( + _: *mut MESALINK_CTX, + _: libc::c_int, + cb: Option libc::c_int>, + ) -> libc::c_int; + pub fn mesalink_SSL_new(_: *mut MESALINK_CTX) -> *mut MESALINK_SSL; + pub fn mesalink_SSL_set_tlsext_host_name( + _: *mut MESALINK_SSL, + _: *const libc::c_char, + ) -> libc::c_int; + pub fn mesalink_SSL_set_fd(_: *mut MESALINK_SSL, _: libc::c_int) -> libc::c_int; + pub fn mesalink_SSL_CTX_free(_: *mut MESALINK_CTX); + pub fn mesalink_SSL_connect(_: *mut MESALINK_SSL) -> libc::c_int; + pub fn mesalink_SSL_write( + _: *mut MESALINK_SSL, + _: *const libc::c_void, + _: libc::c_int, + ) -> libc::c_int; + pub fn mesalink_SSL_get_cipher_name(_: *mut MESALINK_SSL) -> *const libc::c_char; + pub fn mesalink_SSL_read( + _: *mut MESALINK_SSL, + _: *mut libc::c_void, + _: libc::c_int, + ) -> libc::c_int; + pub fn mesalink_SSL_shutdown(_: *mut MESALINK_SSL) -> libc::c_int; + pub fn mesalink_SSL_get_version(_: *const MESALINK_SSL) -> *const libc::c_char; + pub fn mesalink_SSL_free(_: *mut MESALINK_SSL); + pub fn mesalink_SSL_get_error(_: *const MESALINK_SSL, _: libc::c_int) -> libc::c_int; + pub fn mesalink_ERR_error_string_n( + e: libc::c_ulong, + buf: *mut libc::c_char, + len: size_t, + ) -> *const libc::c_char; + pub fn mesalink_ERR_print_errors_fp(_: *const FILE); + // openssl.rs + pub fn Curl_wait_ms(timeout_ms: timediff_t) -> libc::c_int; + // pub fn Curl_none_false_start() -> bool; + pub fn curl_slist_append(_: *mut curl_slist, _: *const libc::c_char) -> *mut curl_slist; + // pub fn Curl_ssl_push_certinfo_len( + // data: *mut Curl_easy, + // certnum: libc::c_int, + // label: *const libc::c_char, + // value: *const libc::c_char, + // valuelen: size_t, + // ) -> CURLcode; + // pub fn Curl_ssl_sessionid_lock(data: *mut Curl_easy); + // pub fn Curl_ssl_sessionid_unlock(data: *mut Curl_easy); + // pub fn Curl_ssl_getsessionid( + // data: *mut Curl_easy, + // conn: *mut connectdata, + // isProxy: bool, + // ssl_sessionid: *mut *mut libc::c_void, + // idsize: *mut size_t, + // sockindex: libc::c_int, + // ) -> bool; + // pub fn Curl_ssl_addsessionid( + // data: *mut Curl_easy, + // conn: *mut connectdata, + // isProxy: bool, + // ssl_sessionid: *mut libc::c_void, + // idsize: size_t, + // sockindex: libc::c_int, + // ) -> CURLcode; + // pub fn Curl_ssl_delsessionid(data: *mut Curl_easy, ssl_sessionid: *mut libc::c_void); + pub fn Curl_cert_hostcheck( + match_pattern: *const libc::c_char, + hostname: *const libc::c_char, + ) -> libc::c_int; + pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX; + pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX); + pub fn EVP_DigestUpdate( + ctx: *mut EVP_MD_CTX, + d: *const libc::c_void, + cnt: size_t, + ) -> libc::c_int; + pub fn EVP_DigestFinal_ex( + ctx: *mut EVP_MD_CTX, + md: *mut libc::c_uchar, + s: *mut libc::c_uint, + ) -> libc::c_int; + pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, type_0: *const EVP_MD) -> libc::c_int; + pub fn EVP_sha1() -> *const EVP_MD; + pub fn EVP_sha256() -> *const EVP_MD; + pub fn EVP_PKEY_id(pkey: *const EVP_PKEY) -> libc::c_int; + pub fn EVP_PKEY_get0_RSA(pkey: *mut EVP_PKEY) -> *mut rsa_st; + pub fn EVP_PKEY_get1_RSA(pkey: *mut EVP_PKEY) -> *mut rsa_st; + pub fn EVP_PKEY_get0_DSA(pkey: *mut EVP_PKEY) -> *mut dsa_st; + pub fn EVP_PKEY_get0_DH(pkey: *mut EVP_PKEY) -> *mut dh_st; + pub fn EVP_PKEY_free(pkey: *mut EVP_PKEY); + pub fn EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> libc::c_int; + pub fn OPENSSL_init_ssl(opts: uint64_t, settings: *const OPENSSL_INIT_SETTINGS) -> libc::c_int; + pub fn SSL_get_shutdown(ssl: *const SSL) -> libc::c_int; + pub fn SSL_pending(s: *const SSL) -> libc::c_int; + pub fn TLS_client_method() -> *const SSL_METHOD; + pub fn SSL_CTX_new(meth: *const SSL_METHOD) -> *mut SSL_CTX; + pub fn SSL_CTX_set_msg_callback( + ctx: *mut SSL_CTX, + cb: Option< + unsafe extern "C" fn( + libc::c_int, + libc::c_int, + libc::c_int, + *const libc::c_void, + size_t, + *mut SSL, + *mut libc::c_void, + ) -> (), + >, + ); + pub fn SSL_alert_desc_string_long(value: libc::c_int) -> *const libc::c_char; + pub fn SSL_CTX_set_options(ctx: *mut SSL_CTX, op: libc::c_ulong) -> libc::c_ulong; + pub fn SSL_CTX_set_next_proto_select_cb( + s: *mut SSL_CTX, + cb: SSL_CTX_npn_select_cb_func, + arg: *mut libc::c_void, + ); + pub fn SSL_CTX_set_alpn_protos( + ctx: *mut SSL_CTX, + protos: *const libc::c_uchar, + protos_len: libc::c_uint, + ) -> libc::c_int; + pub fn SSL_CTX_set_default_passwd_cb_userdata(ctx: *mut SSL_CTX, u: *mut libc::c_void); + pub fn SSL_CTX_set_default_passwd_cb(ctx: *mut SSL_CTX, cb: Option); + pub fn PEM_read_bio_X509_AUX( + bp: *mut BIO, + x: *mut *mut X509, + cb: Option, + u: *mut libc::c_void, + ) -> *mut X509; + pub fn SSL_CTX_use_certificate_chain_file( + ctx: *mut SSL_CTX, + file: *const libc::c_char, + ) -> libc::c_int; + pub fn d2i_X509_bio(bp: *mut BIO, x509: *mut *mut X509) -> *mut X509; + pub fn SSL_CTX_use_certificate_file( + ctx: *mut SSL_CTX, + file: *const libc::c_char, + type_0: libc::c_int, + ) -> libc::c_int; + pub fn SSL_CTX_use_certificate(ctx: *mut SSL_CTX, x: *mut X509) -> libc::c_int; + pub fn SSL_CTX_add_client_CA(ctx: *mut SSL_CTX, x: *mut X509) -> libc::c_int; + pub fn OPENSSL_sk_pop(st: *mut OPENSSL_STACK) -> *mut libc::c_void; + pub fn PEM_read_bio_PrivateKey( + bp: *mut BIO, + x: *mut *mut EVP_PKEY, + cb: Option, + u: *mut libc::c_void, + ) -> *mut EVP_PKEY; + pub fn d2i_PrivateKey_bio(bp: *mut BIO, a: *mut *mut EVP_PKEY) -> *mut EVP_PKEY; + pub fn SSL_CTX_use_PrivateKey_file( + ctx: *mut SSL_CTX, + file: *const libc::c_char, + type_0: libc::c_int, + ) -> libc::c_int; + pub fn SSL_CTX_use_PrivateKey(ctx: *mut SSL_CTX, pkey: *mut EVP_PKEY) -> libc::c_int; + pub fn SSL_get_certificate(ssl: *const SSL) -> *mut X509; + pub fn RSA_flags(r: *const RSA) -> libc::c_int; + pub fn RSA_free(r: *mut RSA); + pub fn SSL_get_privatekey(ssl: *const SSL) -> *mut evp_pkey_st; + pub fn SSL_CTX_check_private_key(ctx: *const SSL_CTX) -> libc::c_int; + pub fn SSL_CTX_set_ciphersuites(ctx: *mut SSL_CTX, str: *const libc::c_char) -> libc::c_int; + pub fn SSL_CTX_set_post_handshake_auth(ctx: *mut SSL_CTX, val: libc::c_int); + pub fn SSL_CTX_set_srp_username(ctx: *mut SSL_CTX, name: *mut libc::c_char) -> libc::c_int; + pub fn SSL_CTX_set_srp_password(ctx: *mut SSL_CTX, password: *mut libc::c_char) -> libc::c_int; + pub fn SSL_CTX_set_cipher_list(_: *mut SSL_CTX, str: *const libc::c_char) -> libc::c_int; + pub fn PEM_X509_INFO_read_bio( + bp: *mut BIO, + sk: *mut stack_st_X509_INFO, + cb: Option, + u: *mut libc::c_void, + ) -> *mut stack_st_X509_INFO; + pub fn X509_STORE_add_cert(ctx: *mut X509_STORE, x: *mut X509) -> libc::c_int; + pub fn X509_STORE_add_crl(ctx: *mut X509_STORE, x: *mut X509_CRL) -> libc::c_int; + pub fn OPENSSL_sk_pop_free( + st: *mut OPENSSL_STACK, + func: Option ()>, + ); + pub fn X509_INFO_free(a: *mut X509_INFO); + pub fn SSL_CTX_load_verify_locations( + ctx: *mut SSL_CTX, + CAfile: *const libc::c_char, + CApath: *const libc::c_char, + ) -> libc::c_int; + pub fn X509_STORE_add_lookup( + v: *mut X509_STORE, + m: *mut X509_LOOKUP_METHOD, + ) -> *mut X509_LOOKUP; + pub fn X509_LOOKUP_file() -> *mut X509_LOOKUP_METHOD; + pub fn X509_load_crl_file( + ctx: *mut X509_LOOKUP, + file: *const libc::c_char, + type_0: libc::c_int, + ) -> libc::c_int; + pub fn X509_STORE_set_flags(ctx: *mut X509_STORE, flags: libc::c_ulong) -> libc::c_int; + pub fn SSL_CTX_set_verify(ctx: *mut SSL_CTX, mode: libc::c_int, callback: SSL_verify_cb); + pub fn SSL_CTX_set_keylog_callback(ctx: *mut SSL_CTX, cb: SSL_CTX_keylog_cb_func); + pub fn SSL_CTX_ctrl( + ctx: *mut SSL_CTX, + cmd: libc::c_int, + larg: libc::c_long, + parg: *mut libc::c_void, + ) -> libc::c_long; + pub fn SSL_CTX_sess_set_new_cb( + ctx: *mut SSL_CTX, + new_session_cb: Option libc::c_int>, + ); + pub fn SSL_get_ex_data(ssl: *const SSL, idx: libc::c_int) -> *mut libc::c_void; + pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL; + pub fn SSL_set_session(to: *mut SSL, session: *mut SSL_SESSION) -> libc::c_int; + pub fn SSL_set_bio(s: *mut SSL, rbio: *mut BIO, wbio: *mut BIO); + pub fn BIO_f_ssl() -> *const BIO_METHOD; + pub fn SSL_set_fd(s: *mut SSL, fd: libc::c_int) -> libc::c_int; + pub fn SSL_connect(ssl: *mut SSL) -> libc::c_int; + pub fn X509_get0_extensions(x: *const X509) -> *const stack_st_X509_EXTENSION; + pub fn SSL_get_version(s: *const SSL) -> *const libc::c_char; + pub fn SSL_CIPHER_get_name(c: *const SSL_CIPHER) -> *const libc::c_char; + pub fn SSL_get_current_cipher(s: *const SSL) -> *const SSL_CIPHER; + pub fn SSL_get0_alpn_selected( + ssl: *const SSL, + data: *mut *const libc::c_uchar, + len: *mut libc::c_uint, + ); + pub fn X509_get_version(x: *const X509) -> libc::c_long; + pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER; + pub fn BIO_puts(bp: *mut BIO, buf: *const libc::c_char) -> libc::c_int; + pub fn X509_get0_signature( + psig: *mut *const ASN1_BIT_STRING, + palg: *mut *const X509_ALGOR, + x: *const X509, + ); + pub fn X509_PUBKEY_get0_param( + ppkalg: *mut *mut ASN1_OBJECT, + pk: *mut *const libc::c_uchar, + ppklen: *mut libc::c_int, + pa: *mut *mut X509_ALGOR, + pub_0: *mut X509_PUBKEY, + ) -> libc::c_int; + pub fn i2a_ASN1_OBJECT(bp: *mut BIO, a: *const ASN1_OBJECT) -> libc::c_int; + pub fn X509_EXTENSION_get_object(ex: *mut X509_EXTENSION) -> *mut ASN1_OBJECT; + pub fn i2t_ASN1_OBJECT( + buf: *mut libc::c_char, + buf_len: libc::c_int, + a: *const ASN1_OBJECT, + ) -> libc::c_int; + pub fn ASN1_STRING_print(bp: *mut BIO, v: *const ASN1_STRING) -> libc::c_int; + pub fn X509_EXTENSION_get_data(ne: *mut X509_EXTENSION) -> *mut ASN1_OCTET_STRING; + pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; + pub fn RSA_get0_key( + r: *const RSA, + n: *mut *const BIGNUM, + e: *mut *const BIGNUM, + d: *mut *const BIGNUM, + ); + pub fn BN_num_bits(a: *const BIGNUM) -> libc::c_int; + pub fn DSA_get0_pqg( + d: *const DSA, + p: *mut *const BIGNUM, + q: *mut *const BIGNUM, + g: *mut *const BIGNUM, + ); + pub fn DSA_get0_key(d: *const DSA, pub_key: *mut *const BIGNUM, priv_key: *mut *const BIGNUM); + pub fn DH_get0_pqg( + dh: *const DH, + p: *mut *const BIGNUM, + q: *mut *const BIGNUM, + g: *mut *const BIGNUM, + ); + pub fn DH_get0_key(dh: *const DH, pub_key: *mut *const BIGNUM, priv_key: *mut *const BIGNUM); + pub fn BN_print(bio: *mut BIO, a: *const BIGNUM) -> libc::c_int; + pub fn BIO_printf(bio: *mut BIO, format: *const libc::c_char, _: ...) -> libc::c_int; + pub fn PEM_write_bio_X509(bp: *mut BIO, x: *mut X509) -> libc::c_int; + pub fn X509_get0_notBefore(x: *const X509) -> *const ASN1_TIME; + pub fn ASN1_TIME_print(fp: *mut BIO, a: *const ASN1_TIME) -> libc::c_int; + pub fn X509_get0_notAfter(x: *const X509) -> *const ASN1_TIME; + pub fn X509_get_ext_d2i( + x: *const X509, + nid: libc::c_int, + crit: *mut libc::c_int, + idx: *mut libc::c_int, + ) -> *mut libc::c_void; + pub fn X509_NAME_get_index_by_NID( + name: *mut X509_NAME, + nid: libc::c_int, + lastpos: libc::c_int, + ) -> libc::c_int; + pub fn ASN1_STRING_type(x: *const ASN1_STRING) -> libc::c_int; + pub fn ASN1_STRING_length(x: *const ASN1_STRING) -> libc::c_int; + pub fn CRYPTO_malloc( + num: size_t, + file: *const libc::c_char, + line: libc::c_int, + ) -> *mut libc::c_void; + pub fn ASN1_STRING_get0_data(x: *const ASN1_STRING) -> *const libc::c_uchar; + pub fn ASN1_STRING_to_UTF8( + out: *mut *mut libc::c_uchar, + in_0: *const ASN1_STRING, + ) -> libc::c_int; + pub fn X509_NAME_ENTRY_get_data(ne: *const X509_NAME_ENTRY) -> *mut ASN1_STRING; + pub fn X509_NAME_get_entry(name: *const X509_NAME, loc: libc::c_int) -> *mut X509_NAME_ENTRY; + pub fn X509_get_subject_name(a: *const X509) -> *mut X509_NAME; + pub fn CRYPTO_free(ptr: *mut libc::c_void, file: *const libc::c_char, line: libc::c_int); + pub fn X509_NAME_print_ex( + out: *mut BIO, + nm: *const X509_NAME, + indent: libc::c_int, + flags: libc::c_ulong, + ) -> libc::c_int; + pub fn BIO_s_mem() -> *const BIO_METHOD; + pub fn X509_get_issuer_name(a: *const X509) -> *mut X509_NAME; + pub fn BIO_new_mem_buf(buf: *const libc::c_void, len: libc::c_int) -> *mut BIO; + pub fn BIO_new(type_0: *const BIO_METHOD) -> *mut BIO; + pub fn BIO_s_file() -> *const BIO_METHOD; + pub fn BIO_ctrl( + bp: *mut BIO, + cmd: libc::c_int, + larg: libc::c_long, + parg: *mut libc::c_void, + ) -> libc::c_long; + pub fn PEM_read_bio_X509( + bp: *mut BIO, + x: *mut *mut X509, + cb: Option, + u: *mut libc::c_void, + ) -> *mut X509; + pub fn BIO_free(a: *mut BIO) -> libc::c_int; + pub fn SSL_get_verify_result(ssl: *const SSL) -> libc::c_long; + pub fn X509_verify_cert_error_string(n: libc::c_long) -> *const libc::c_char; + pub fn SSL_ctrl( + ssl: *mut SSL, + cmd: libc::c_int, + larg: libc::c_long, + parg: *mut libc::c_void, + ) -> libc::c_long; + pub fn SSL_get_peer_cert_chain(s: *const SSL) -> *mut stack_st_X509; + pub fn SSL_CTX_get_cert_store(_: *const SSL_CTX) -> *mut X509_STORE; + pub fn SSL_get_peer_certificate(s: *const SSL) -> *mut X509; + pub fn OPENSSL_sk_num(_: *const OPENSSL_STACK) -> libc::c_int; + pub fn OPENSSL_sk_value(_: *const OPENSSL_STACK, _: libc::c_int) -> *mut libc::c_void; + pub fn i2d_X509_PUBKEY(a: *mut X509_PUBKEY, out: *mut *mut libc::c_uchar) -> libc::c_int; + pub fn X509_get_X509_PUBKEY(x: *const X509) -> *mut X509_PUBKEY; + pub fn X509_free(a: *mut X509); + pub fn SSL_write(ssl: *mut SSL, buf: *const libc::c_void, num: libc::c_int) -> libc::c_int; + pub fn SSL_get_error(s: *const SSL, ret_code: libc::c_int) -> libc::c_int; + pub fn OpenSSL_version_num() -> libc::c_ulong; + pub fn SSL_read(ssl: *mut SSL, buf: *mut libc::c_void, num: libc::c_int) -> libc::c_int; + pub fn SSL_shutdown(s: *mut SSL) -> libc::c_int; + pub fn SSL_set_connect_state(s: *mut SSL); + pub fn SSL_free(ssl: *mut SSL); + pub fn SSL_CTX_free(_: *mut SSL_CTX); + pub fn SSL_SESSION_free(ses: *mut SSL_SESSION); + pub fn SSL_set_ex_data(ssl: *mut SSL, idx: libc::c_int, data: *mut libc::c_void) + -> libc::c_int; + pub fn CRYPTO_get_ex_new_index( + class_index: libc::c_int, + argl: libc::c_long, + argp: *mut libc::c_void, + new_func: Option, + dup_func: Option, + free_func: Option, + ) -> libc::c_int; + pub fn RAND_bytes(buf: *mut libc::c_uchar, num: libc::c_int) -> libc::c_int; + pub fn RAND_add(buf: *const libc::c_void, num: libc::c_int, randomness: libc::c_double); + pub fn RAND_load_file(file: *const libc::c_char, max_bytes: libc::c_long) -> libc::c_int; + pub fn RAND_file_name(file: *mut libc::c_char, num: size_t) -> *const libc::c_char; + pub fn RAND_status() -> libc::c_int; + pub fn GENERAL_NAMES_free(a: *mut GENERAL_NAMES); + pub fn X509V3_EXT_print( + out: *mut BIO, + ext: *mut X509_EXTENSION, + flag: libc::c_ulong, + indent: libc::c_int, + ) -> libc::c_int; + pub fn X509_check_issued(issuer: *mut X509, subject: *mut X509) -> libc::c_int; + pub fn ERR_get_error() -> libc::c_ulong; + pub fn ERR_peek_error() -> libc::c_ulong; + pub fn ERR_peek_last_error() -> libc::c_ulong; + pub fn ERR_clear_error(); + pub fn ERR_error_string_n(e: libc::c_ulong, buf: *mut libc::c_char, len: size_t); + pub fn PKCS12_free(a: *mut PKCS12); + pub fn PKCS12_PBE_add(); + pub fn PKCS12_parse( + p12: *mut PKCS12, + pass: *const libc::c_char, + pkey: *mut *mut EVP_PKEY, + cert: *mut *mut X509, + ca: *mut *mut stack_st_X509, + ) -> libc::c_int; + pub fn d2i_PKCS12_bio(bp: *mut BIO, p12: *mut *mut PKCS12) -> *mut PKCS12; + pub fn OCSP_cert_to_id( + dgst: *const EVP_MD, + subject: *const X509, + issuer: *const X509, + ) -> *mut OCSP_CERTID; + pub fn OCSP_response_status(resp: *mut OCSP_RESPONSE) -> libc::c_int; + pub fn OCSP_response_get1_basic(resp: *mut OCSP_RESPONSE) -> *mut OCSP_BASICRESP; + pub fn OCSP_resp_find_status( + bs: *mut OCSP_BASICRESP, + id: *mut OCSP_CERTID, + status: *mut libc::c_int, + reason: *mut libc::c_int, + revtime: *mut *mut ASN1_GENERALIZEDTIME, + thisupd: *mut *mut ASN1_GENERALIZEDTIME, + nextupd: *mut *mut ASN1_GENERALIZEDTIME, + ) -> libc::c_int; + pub fn OCSP_check_validity( + thisupd: *mut ASN1_GENERALIZEDTIME, + nextupd: *mut ASN1_GENERALIZEDTIME, + sec: libc::c_long, + maxsec: libc::c_long, + ) -> libc::c_int; + pub fn OCSP_BASICRESP_free(a: *mut OCSP_BASICRESP); + pub fn OCSP_RESPONSE_free(a: *mut OCSP_RESPONSE); + pub fn d2i_OCSP_RESPONSE( + a: *mut *mut OCSP_RESPONSE, + in_0: *mut *const libc::c_uchar, + len: libc::c_long, + ) -> *mut OCSP_RESPONSE; + pub fn OCSP_CERTID_free(a: *mut OCSP_CERTID); + pub fn OCSP_response_status_str(s: libc::c_long) -> *const libc::c_char; + pub fn OCSP_basic_verify( + bs: *mut OCSP_BASICRESP, + certs: *mut stack_st_X509, + st: *mut X509_STORE, + flags: libc::c_ulong, + ) -> libc::c_int; + pub fn OCSP_cert_status_str(s: libc::c_long) -> *const libc::c_char; + pub fn OCSP_crl_reason_str(s: libc::c_long) -> *const libc::c_char; + pub fn ENGINE_get_first() -> *mut ENGINE; + pub fn ENGINE_get_next(e: *mut ENGINE) -> *mut ENGINE; + pub fn ENGINE_by_id(id: *const libc::c_char) -> *mut ENGINE; + pub fn ENGINE_ctrl( + e: *mut ENGINE, + cmd: libc::c_int, + i: libc::c_long, + p: *mut libc::c_void, + f: Option ()>, + ) -> libc::c_int; + pub fn ENGINE_ctrl_cmd( + e: *mut ENGINE, + cmd_name: *const libc::c_char, + i: libc::c_long, + p: *mut libc::c_void, + f: Option ()>, + cmd_optional: libc::c_int, + ) -> libc::c_int; + pub fn ENGINE_free(e: *mut ENGINE) -> libc::c_int; + pub fn ENGINE_get_id(e: *const ENGINE) -> *const libc::c_char; + pub fn UI_OpenSSL() -> *mut UI_METHOD; + pub fn ENGINE_load_private_key( + e: *mut ENGINE, + key_id: *const libc::c_char, + ui_method: *mut UI_METHOD, + callback_data: *mut libc::c_void, + ) -> *mut EVP_PKEY; + pub fn ENGINE_set_default(e: *mut ENGINE, flags: libc::c_uint) -> libc::c_int; + pub fn ENGINE_init(e: *mut ENGINE) -> libc::c_int; + pub fn ENGINE_finish(e: *mut ENGINE) -> libc::c_int; + pub fn UI_get0_user_data(ui: *mut UI) -> *mut libc::c_void; + pub fn UI_method_set_opener( + method: *mut UI_METHOD, + opener: Option libc::c_int>, + ) -> libc::c_int; + pub fn UI_method_get_opener( + method: *const UI_METHOD, + ) -> Option libc::c_int>; + pub fn UI_method_set_closer( + method: *mut UI_METHOD, + closer: Option libc::c_int>, + ) -> libc::c_int; + pub fn UI_method_get_closer( + method: *const UI_METHOD, + ) -> Option libc::c_int>; + pub fn UI_create_method(name: *const libc::c_char) -> *mut UI_METHOD; + pub fn UI_destroy_method(ui_method: *mut UI_METHOD); + pub fn UI_method_get_writer( + method: *const UI_METHOD, + ) -> Option libc::c_int>; + pub fn UI_method_set_writer( + method: *mut UI_METHOD, + writer: Option libc::c_int>, + ) -> libc::c_int; + pub fn UI_method_get_reader( + method: *const UI_METHOD, + ) -> Option libc::c_int>; + pub fn UI_method_set_reader( + method: *mut UI_METHOD, + reader: Option libc::c_int>, + ) -> libc::c_int; + pub fn UI_set_result( + ui: *mut UI, + uis: *mut UI_STRING, + result: *const libc::c_char, + ) -> libc::c_int; + pub fn UI_get_string_type(uis: *mut UI_STRING) -> UI_string_types; + pub fn UI_get_input_flags(uis: *mut UI_STRING) -> libc::c_int; + + // http_negotiate.rs + pub fn Curl_auth_decode_spnego_message( + data: *mut Curl_easy, + user: *const libc::c_char, + passwood: *const libc::c_char, + service: *const libc::c_char, + host: *const libc::c_char, + chlg64: *const libc::c_char, + nego: *mut negotiatedata, + ) -> CURLcode; + pub fn Curl_auth_create_spnego_message( + data: *mut Curl_easy, + nego: *mut negotiatedata, + outptr: *mut *mut libc::c_char, + outlen: *mut size_t, + ) -> CURLcode; + pub fn Curl_auth_cleanup_spnego(nego: *mut negotiatedata); + // bearssl.rs + pub fn br_ssl_engine_sendapp_ack(cc: *mut br_ssl_engine_context, len: size_t); + pub fn br_ssl_engine_sendapp_buf( + cc: *const br_ssl_engine_context, + len: *mut size_t, + ) -> *mut libc::c_uchar; + pub fn br_ssl_engine_current_state(cc: *const br_ssl_engine_context) -> libc::c_uint; + pub fn br_ssl_engine_set_buffer( + cc: *mut br_ssl_engine_context, + iobuf: *mut libc::c_void, + iobuf_len: size_t, + bidi: libc::c_int, + ); + pub fn br_pem_decoder_event(ctx: *mut br_pem_decoder_context) -> libc::c_int; + pub fn br_pem_decoder_push( + ctx: *mut br_pem_decoder_context, + data: *const libc::c_void, + len: size_t, + ) -> size_t; + pub fn br_pem_decoder_init(ctx: *mut br_pem_decoder_context); + pub fn br_ssl_client_reset( + cc: *mut br_ssl_client_context, + server_name: *const libc::c_char, + resume_session: libc::c_int, + ) -> libc::c_int; + pub fn br_ssl_client_init_full( + cc: *mut br_ssl_client_context, + xc: *mut br_x509_minimal_context, + trust_anchors: *const br_x509_trust_anchor, + trust_anchors_num: size_t, + ); + pub fn br_ssl_engine_close(cc: *mut br_ssl_engine_context); + pub fn br_ssl_engine_flush(cc: *mut br_ssl_engine_context, force: libc::c_int); + pub fn br_ssl_engine_recvrec_ack(cc: *mut br_ssl_engine_context, len: size_t); + pub fn br_ssl_engine_recvrec_buf( + cc: *const br_ssl_engine_context, + len: *mut size_t, + ) -> *mut libc::c_uchar; + pub fn br_ssl_engine_sendrec_ack(cc: *mut br_ssl_engine_context, len: size_t); + pub fn br_ssl_engine_sendrec_buf( + cc: *const br_ssl_engine_context, + len: *mut size_t, + ) -> *mut libc::c_uchar; + pub fn br_ssl_engine_recvapp_ack(cc: *mut br_ssl_engine_context, len: size_t); + pub fn br_sha224_update(ctx: *mut br_sha224_context, data: *const libc::c_void, len: size_t); + pub fn br_sha256_init(ctx: *mut br_sha256_context); + pub fn br_sha256_out(ctx: *const br_sha256_context, out: *mut libc::c_void); + pub fn br_ssl_engine_recvapp_buf( + cc: *const br_ssl_engine_context, + len: *mut size_t, + ) -> *mut libc::c_uchar; + pub fn br_x509_decoder_push( + ctx: *mut br_x509_decoder_context, + data: *const libc::c_void, + len: size_t, + ); + pub fn br_x509_decoder_init( + ctx: *mut br_x509_decoder_context, + append_dn_0: Option< + unsafe extern "C" fn(*mut libc::c_void, *const libc::c_void, size_t) -> (), + >, + append_dn_ctx: *mut libc::c_void, + ); + pub fn br_hmac_drbg_init( + ctx: *mut br_hmac_drbg_context, + digest_class: *const br_hash_class, + seed: *const libc::c_void, + seed_len: size_t, + ); + pub fn br_hmac_drbg_generate( + ctx: *mut br_hmac_drbg_context, + out: *mut libc::c_void, + len: size_t, + ); + pub fn br_prng_seeder_system(name: *mut *const libc::c_char) -> br_prng_seeder; + pub fn ferror(__stream: *mut FILE) -> libc::c_int; + + // option hyper + pub fn hyper_clientconn_handshake( + io: *mut hyper_io, + options: *mut hyper_clientconn_options, + ) -> *mut hyper_task; + pub fn hyper_clientconn_send( + conn: *mut hyper_clientconn, + req: *mut hyper_request, + ) -> *mut hyper_task; + pub fn hyper_clientconn_free(conn: *mut hyper_clientconn); + pub fn hyper_clientconn_options_new() -> *mut hyper_clientconn_options; + pub fn hyper_clientconn_options_free(opts: *mut hyper_clientconn_options); + pub fn hyper_clientconn_options_exec( + opts: *mut hyper_clientconn_options, + exec: *const hyper_executor, + ); + pub fn hyper_error_free(err: *mut hyper_error); + pub fn hyper_error_print(err: *const hyper_error, dst: *mut uint8_t, dst_len: size_t) + -> size_t; + pub fn hyper_request_new() -> *mut hyper_request; + pub fn hyper_request_set_method( + req: *mut hyper_request, + method: *const uint8_t, + method_len: size_t, + ) -> hyper_code; + pub fn hyper_request_set_uri( + req: *mut hyper_request, + uri: *const uint8_t, + uri_len: size_t, + ) -> hyper_code; + pub fn hyper_request_set_version(req: *mut hyper_request, version: libc::c_int) -> hyper_code; + pub fn hyper_request_headers(req: *mut hyper_request) -> *mut hyper_headers; + pub fn hyper_io_new() -> *mut hyper_io; + pub fn hyper_io_free(io: *mut hyper_io); + pub fn hyper_io_set_userdata(io: *mut hyper_io, data: *mut libc::c_void); + pub fn hyper_io_set_read(io: *mut hyper_io, func: hyper_io_read_callback); + pub fn hyper_io_set_write(io: *mut hyper_io, func: hyper_io_write_callback); + pub fn hyper_executor_new() -> *const hyper_executor; + pub fn hyper_executor_free(exec: *const hyper_executor); + pub fn hyper_executor_push(exec: *const hyper_executor, task: *mut hyper_task) -> hyper_code; + pub fn hyper_executor_poll(exec: *const hyper_executor) -> *mut hyper_task; + pub fn hyper_task_free(task: *mut hyper_task); + pub fn hyper_task_value(task: *mut hyper_task) -> *mut libc::c_void; + pub fn hyper_task_type(task: *mut hyper_task) -> hyper_task_return_type; + pub fn hyper_waker_free(waker: *mut hyper_waker); + pub fn Curl_hyper_recv( + userp: *mut libc::c_void, + ctx: *mut hyper_context, + buf: *mut uint8_t, + buflen: size_t, + ) -> size_t; + pub fn Curl_hyper_send( + userp: *mut libc::c_void, + ctx: *mut hyper_context, + buf: *const uint8_t, + buflen: size_t, + ) -> size_t; + pub fn Curl_hyper_stream( + data: *mut Curl_easy, + conn: *mut connectdata, + didwhat: *mut libc::c_int, + done: *mut bool, + select_res: libc::c_int, + ) -> CURLcode; + pub fn Curl_hyper_header( + data: *mut Curl_easy, + headers: *mut hyper_headers, + line: *const libc::c_char, + ) -> CURLcode; + pub fn Curl_hyper_done(_: *mut Curl_easy); + + // in http.rs, remove in future + #[cfg(USE_HYPER)] + pub fn Curl_add_custom_headers( + data: *mut Curl_easy, + is_connect: bool, + headers: *mut libc::c_void, + ) -> CURLcode; + + // http.rs function without hyper + #[cfg(not(USE_HYPER))] + pub fn Curl_add_custom_headers( + data: *mut Curl_easy, + is_connect: bool, + req: *mut dynbuf, + ) -> CURLcode; + + // ftp + pub fn htons(__hostshort: uint16_t) -> uint16_t; + pub fn ntohs(__netshort: uint16_t) -> uint16_t; + + //debug + pub fn __assert_fail( + __assertion: *const libc::c_char, + __file: *const libc::c_char, + __line: libc::c_uint, + __function: *const libc::c_char, + ) -> !; + pub fn curl_dbg_free(ptr: *mut libc::c_void, line: libc::c_int, source: *const libc::c_char); + pub fn curl_dbg_strdup( + str: *const libc::c_char, + line: libc::c_int, + src: *const libc::c_char, + ) -> *mut libc::c_char; + pub fn curl_dbg_calloc( + elements: size_t, + size: size_t, + line: libc::c_int, + source: *const libc::c_char, + ) -> *mut libc::c_void; + pub fn curl_dbg_malloc( + size: size_t, + line: libc::c_int, + source: *const libc::c_char, + ) -> *mut libc::c_void; + pub fn curl_dbg_fopen( + file: *const libc::c_char, + mode: *const libc::c_char, + line: libc::c_int, + source: *const libc::c_char, + ) -> *mut FILE; + pub fn curl_dbg_fclose( + file: *mut FILE, + line: libc::c_int, + source: *const libc::c_char, + ) -> libc::c_int; + pub fn curl_dbg_recv( + sockfd: libc::c_int, + buf: *mut libc::c_void, + len: size_t, + flags: libc::c_int, + line: libc::c_int, + source: *const libc::c_char, + ) -> ssize_t; + pub fn curl_dbg_accept( + s: curl_socket_t, + a: *mut libc::c_void, + alen: *mut libc::c_void, + line: libc::c_int, + source: *const libc::c_char, + ) -> curl_socket_t; + } + \ No newline at end of file -- Gitee From 8bb7b88ff4c32d1b6411e13642880e7b18f606ec Mon Sep 17 00:00:00 2001 From: wyf <763257820@qq.com> Date: Tue, 6 Dec 2022 17:59:29 +0800 Subject: [PATCH 2/2] ftp debug --- rust/rust_project/src/ftp.rs | 9897 +++++++++++++++++++--------------- 1 file changed, 5454 insertions(+), 4443 deletions(-) diff --git a/rust/rust_project/src/ftp.rs b/rust/rust_project/src/ftp.rs index c4f89c1..31e6f1b 100644 --- a/rust/rust_project/src/ftp.rs +++ b/rust/rust_project/src/ftp.rs @@ -8,2863 +8,3325 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. - * Author: Drug, + * Author: Drug, * Create: 2022-10-31 * Description: ftp ******************************************************************************/ -use ::libc; -use rust_ffi::src::ffi_alias::type_alias::*; -use rust_ffi::src::ffi_fun::fun_call::*; -use rust_ffi::src::ffi_struct::struct_define::*; + use ::libc; + use rust_ffi::src::ffi_alias::type_alias::*; + use rust_ffi::src::ffi_fun::fun_call::*; + use rust_ffi::src::ffi_struct::struct_define::*; + + // TODO in_addr_t类型的条件编译 + + #[inline] + unsafe extern "C" fn __bswap_16(mut __bsx: __uint16_t) -> __uint16_t { + return (__bsx as libc::c_int >> 8 as libc::c_int & 0xff as libc::c_int + | (__bsx as libc::c_int & 0xff as libc::c_int) << 8 as libc::c_int) + as __uint16_t; + } + #[no_mangle] + pub static mut Curl_handler_ftp: Curl_handler = unsafe { + { + let mut init = Curl_handler { + scheme: b"FTP\0" as *const u8 as *const libc::c_char, + setup_connection: Some( + ftp_setup_connection + as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata) -> CURLcode, + ), + do_it: Some(ftp_do as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode), + done: Some( + ftp_done as unsafe extern "C" fn(*mut Curl_easy, CURLcode, bool) -> CURLcode, + ), + do_more: Some( + ftp_do_more as unsafe extern "C" fn(*mut Curl_easy, *mut libc::c_int) -> CURLcode, + ), + connect_it: Some( + ftp_connect as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, + ), + connecting: Some( + ftp_multi_statemach as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, + ), + doing: Some(ftp_doing as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode), + proto_getsock: Some( + ftp_getsock + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut curl_socket_t, + ) -> libc::c_int, + ), + doing_getsock: Some( + ftp_getsock + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut curl_socket_t, + ) -> libc::c_int, + ), + domore_getsock: Some( + ftp_domore_getsock + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut curl_socket_t, + ) -> libc::c_int, + ), + perform_getsock: None, + disconnect: Some( + ftp_disconnect + as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata, bool) -> CURLcode, + ), + readwrite: None, + connection_check: None, + attach: None, + defport: 21 as libc::c_int, + protocol: ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_uint, + family: ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_uint, + flags: ((1 as libc::c_int) << 1 as libc::c_int + | (1 as libc::c_int) << 2 as libc::c_int + | (1 as libc::c_int) << 5 as libc::c_int + | (1 as libc::c_int) << 6 as libc::c_int + | (1 as libc::c_int) << 11 as libc::c_int + | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_uint, + }; + init + } + }; + #[cfg(USE_SSL)] + #[no_mangle] + pub static mut Curl_handler_ftps: Curl_handler = unsafe { + { + let mut init = Curl_handler { + scheme: b"FTPS\0" as *const u8 as *const libc::c_char, + setup_connection: Some( + ftp_setup_connection + as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata) -> CURLcode, + ), + do_it: Some( + ftp_do as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, + ), + done: Some( + ftp_done + as unsafe extern "C" fn(*mut Curl_easy, CURLcode, bool) -> CURLcode, + ), + do_more: Some( + ftp_do_more + as unsafe extern "C" fn(*mut Curl_easy, *mut libc::c_int) -> CURLcode, + ), + connect_it: Some( + ftp_connect + as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, + ), + connecting: Some( + ftp_multi_statemach + as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, + ), + doing: Some( + ftp_doing as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, + ), + proto_getsock: Some( + ftp_getsock + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut curl_socket_t, + ) -> libc::c_int, + ), + doing_getsock: Some( + ftp_getsock + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut curl_socket_t, + ) -> libc::c_int, + ), + domore_getsock: Some( + ftp_domore_getsock + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut curl_socket_t, + ) -> libc::c_int, + ), + perform_getsock: None, + disconnect: Some( + ftp_disconnect + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + bool, + ) -> CURLcode, + ), + readwrite: None, + connection_check: None, + attach: None, + defport: 990 as libc::c_int, + protocol: ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_uint, + family: ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_uint, + flags: ((1 as libc::c_int) << 0 as libc::c_int + | (1 as libc::c_int) << 1 as libc::c_int + | (1 as libc::c_int) << 2 as libc::c_int + | (1 as libc::c_int) << 5 as libc::c_int + | (1 as libc::c_int) << 6 as libc::c_int + | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_uint, + }; + init + } + }; + unsafe extern "C" fn close_secondarysocket(mut data: *mut Curl_easy, mut conn: *mut connectdata) { + if -(1 as libc::c_int) != (*conn).sock[1 as libc::c_int as usize] { + Curl_closesocket(data, conn, (*conn).sock[1 as libc::c_int as usize]); + (*conn).sock[1 as libc::c_int as usize] = -(1 as libc::c_int); + } + (*conn).bits.tcpconnect[1 as libc::c_int as usize] = 0 as libc::c_int != 0; + match() { + #[cfg(not(CURL_DISABLE_PROXY))] + _ => { + (*conn).bits.proxy_ssl_connected[1 as libc::c_int as usize] = 0 as libc::c_int != 0; + } + #[cfg(CURL_DISABLE_PROXY)] + _ => { } + } + } + unsafe extern "C" fn freedirs(mut ftpc: *mut ftp_conn) { + if !((*ftpc).dirs).is_null() { + let mut i: libc::c_int = 0; + i = 0 as libc::c_int; + while i < (*ftpc).dirdepth { + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")( + *((*ftpc).dirs).offset(i as isize) as *mut libc::c_void + ); + #[cfg(CURLDEBUG)] + curl_dbg_free( + *((*ftpc).dirs).offset(i as isize) as *mut libc::c_void, + 248 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh0 = *((*ftpc).dirs).offset(i as isize); + *fresh0 = 0 as *mut libc::c_char; + i += 1; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).dirs as *mut libc::c_void); + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).dirs as *mut libc::c_void, + 251 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh1 = (*ftpc).dirs; + *fresh1 = 0 as *mut *mut libc::c_char; + (*ftpc).dirdepth = 0 as libc::c_int; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).file as *mut libc::c_void); + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).file as *mut libc::c_void, + 255 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh2 = (*ftpc).file; + *fresh2 = 0 as *mut libc::c_char; + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).newhost as *mut libc::c_void, + 258 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh3 = (*ftpc).newhost; + *fresh3 = 0 as *mut libc::c_char; + } + unsafe extern "C" fn AcceptServerConnect(mut data: *mut Curl_easy) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut sock: curl_socket_t = (*conn).sock[1 as libc::c_int as usize]; + let mut s: curl_socket_t = -(1 as libc::c_int); + #[cfg(ENABLE_IPV6)] + let mut add: Curl_sockaddr_storage = Curl_sockaddr_storage { + buffer: C2RustUnnamed_9 { + sa: sockaddr { + sa_family: 0, + sa_data: [0; 14], + }, + }, + }; + #[cfg(not(ENABLE_IPV6))] + let mut add: sockaddr_in = sockaddr_in { + sin_family: 0, + sin_port: 0, + sin_addr: in_addr { s_addr: 0 }, + sin_zero: [0; 8], + }; + #[cfg(ENABLE_IPV6)] + let mut size: curl_socklen_t = + ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; + #[cfg(not(ENABLE_IPV6))] + let mut size: curl_socklen_t = ::std::mem::size_of::() as libc::c_ulong + as curl_socklen_t; + #[cfg(ENABLE_IPV6)] + if 0 as libc::c_int + == getsockname( + sock, + &mut add as *mut Curl_sockaddr_storage as *mut sockaddr, + &mut size, + ) + { + size = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + s = accept( + sock, + &mut add as *mut Curl_sockaddr_storage as *mut sockaddr, + &mut size, + ); + } + #[cfg(CURLDEBUG)] + _ => { + s = curl_dbg_accept( + sock, + &mut add as *mut Curl_sockaddr_storage as *mut sockaddr as *mut libc::c_void, + &mut size as *mut curl_socklen_t as *mut libc::c_void, + 284 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + } + #[cfg(not(ENABLE_IPV6))] + if 0 as libc::c_int + == getsockname(sock, &mut add as *mut sockaddr_in as *mut sockaddr, &mut size) + { + size = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; + s = accept(sock, &mut add as *mut sockaddr_in as *mut sockaddr, &mut size); + } + Curl_closesocket(data, conn, sock); + if -(1 as libc::c_int) == s { + Curl_failf( + data, + b"Error accept()ing server connect\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_PORT_FAILED; + } + Curl_infof( + data, + b"Connection accepted from server\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh4 = (*conn).bits; + (*fresh4).set_do_more(0 as libc::c_int as bit); + (*conn).sock[1 as libc::c_int as usize] = s; + curlx_nonblock(s, 1 as libc::c_int); + let ref mut fresh5 = (*conn).bits; + (*fresh5).set_sock_accepted(1 as libc::c_int as bit); + if ((*data).set.fsockopt).is_some() { + let mut error: libc::c_int = 0 as libc::c_int; + Curl_set_in_callback(data, 1 as libc::c_int != 0); + error = ((*data).set.fsockopt).expect("non-null function pointer")( + (*data).set.sockopt_client, + s, + CURLSOCKTYPE_ACCEPT, + ); + Curl_set_in_callback(data, 0 as libc::c_int != 0); + if error != 0 { + close_secondarysocket(data, conn); + return CURLE_ABORTED_BY_CALLBACK; + } + } + return CURLE_OK; + } + unsafe extern "C" fn ftp_timeleft_accept(mut data: *mut Curl_easy) -> timediff_t { + let mut timeout_ms: timediff_t = 60000 as libc::c_int as timediff_t; + let mut other: timediff_t = 0; + let mut now: curltime = curltime { + tv_sec: 0, + tv_usec: 0, + }; + if (*data).set.accepttimeout > 0 as libc::c_int as libc::c_long { + timeout_ms = (*data).set.accepttimeout; + } + now = Curl_now(); + other = Curl_timeleft(data, &mut now, 0 as libc::c_int != 0); + if other != 0 && other < timeout_ms { + timeout_ms = other; + } else { + timeout_ms -= Curl_timediff(now, (*data).progress.t_acceptdata); + if timeout_ms == 0 { + return -(1 as libc::c_int) as timediff_t; + } + } + return timeout_ms; + } + unsafe extern "C" fn ReceivedServerConnect( + mut data: *mut Curl_easy, + mut received: *mut bool, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ctrl_sock: curl_socket_t = (*conn).sock[0 as libc::c_int as usize]; + let mut data_sock: curl_socket_t = (*conn).sock[1 as libc::c_int as usize]; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + let mut result: libc::c_int = 0; + let mut timeout_ms: timediff_t = 0; + let mut nread: ssize_t = 0; + let mut ftpcode: libc::c_int = 0; + *received = 0 as libc::c_int != 0; + timeout_ms = ftp_timeleft_accept(data); + Curl_infof( + data, + b"Checking for server connect\0" as *const u8 as *const libc::c_char, + ); + if timeout_ms < 0 as libc::c_int as libc::c_long { + Curl_failf( + data, + b"Accept timeout occurred while waiting server connect\0" as *const u8 + as *const libc::c_char, + ); + return CURLE_FTP_ACCEPT_TIMEOUT; + } + if (*pp).cache_size != 0 + && !((*pp).cache).is_null() + && *((*pp).cache).offset(0 as libc::c_int as isize) as libc::c_int > '3' as i32 + { + Curl_infof( + data, + b"There is negative response in cache while serv connect\0" as *const u8 + as *const libc::c_char, + ); + Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); + return CURLE_FTP_ACCEPT_FAILED; + } + result = Curl_socket_check( + ctrl_sock, + data_sock, + -(1 as libc::c_int), + 0 as libc::c_int as timediff_t, + ); + match result { + -1 => { + Curl_failf( + data, + b"Error while waiting for server connect\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_ACCEPT_FAILED; + } + 0 => {} + _ => { + if result & (0x4 as libc::c_int) << 1 as libc::c_int != 0 { + Curl_infof( + data, + b"Ready to accept data connection from server\0" as *const u8 + as *const libc::c_char, + ); + *received = 1 as libc::c_int != 0; + } else if result & 0x1 as libc::c_int != 0 { + Curl_infof( + data, + b"Ctrl conn has data while waiting for data conn\0" as *const u8 + as *const libc::c_char, + ); + Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); + if ftpcode / 100 as libc::c_int > 3 as libc::c_int { + return CURLE_FTP_ACCEPT_FAILED; + } + return CURLE_WEIRD_SERVER_REPLY; + } + } + } + return CURLE_OK; + } + unsafe extern "C" fn InitiateTransfer(mut data: *mut Curl_easy) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + if ((*conn).bits).ftp_use_data_ssl() != 0 { + Curl_infof( + data, + b"Doing the SSL/TLS handshake on the data stream\0" as *const u8 as *const libc::c_char, + ); + // match () { + // #[cfg(USE_SSL)] + // _ => { + // result = Curl_ssl_connect(data, conn, 1 as libc::c_int); + // } + // #[cfg(not(USE_SSL))] + // _ => { + // result = CURLE_NOT_BUILT_IN; + // } + // } + result = Curl_ssl_connect(data, conn, 1 as libc::c_int); + if result as u64 != 0 { + return result; + } + } + if (*conn).proto.ftpc.state_saved as libc::c_uint == FTP_STOR as libc::c_int as libc::c_uint { + Curl_pgrsSetUploadSize(data, (*data).state.infilesize); + Curl_setup_transfer( + data, + -(1 as libc::c_int), + -(1 as libc::c_int) as curl_off_t, + 0 as libc::c_int != 0, + 1 as libc::c_int, + ); + } else { + Curl_setup_transfer( + data, + 1 as libc::c_int, + (*conn).proto.ftpc.retr_size_saved, + 0 as libc::c_int != 0, + -(1 as libc::c_int), + ); + } + (*conn).proto.ftpc.pp.pending_resp = 1 as libc::c_int != 0; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 470 as libc::c_int); + return CURLE_OK; + } + unsafe extern "C" fn AllowServerConnect( + mut data: *mut Curl_easy, + mut connected: *mut bool, + ) -> CURLcode { + let mut timeout_ms: timediff_t = 0; + let mut result: CURLcode = CURLE_OK; + *connected = 0 as libc::c_int != 0; + Curl_infof( + data, + b"Preparing for accepting server on data port\0" as *const u8 as *const libc::c_char, + ); + Curl_pgrsTime(data, TIMER_STARTACCEPT); + timeout_ms = ftp_timeleft_accept(data); + if timeout_ms < 0 as libc::c_int as libc::c_long { + Curl_failf( + data, + b"Accept timeout occurred while waiting server connect\0" as *const u8 + as *const libc::c_char, + ); + return CURLE_FTP_ACCEPT_TIMEOUT; + } + result = ReceivedServerConnect(data, connected); + if result as u64 != 0 { + return result; + } + if *connected { + result = AcceptServerConnect(data); + if result as u64 != 0 { + return result; + } + result = InitiateTransfer(data); + if result as u64 != 0 { + return result; + } + } else if *connected as libc::c_int == 0 as libc::c_int { + Curl_expire( + data, + if (*data).set.accepttimeout > 0 as libc::c_int as libc::c_long { + (*data).set.accepttimeout + } else { + 60000 as libc::c_int as libc::c_long + }, + EXPIRE_100_TIMEOUT, + ); + } + return result; + } + unsafe extern "C" fn ftp_endofresp( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut line: *mut libc::c_char, + mut len: size_t, + mut code: *mut libc::c_int, + ) -> bool { + if len > 3 as libc::c_int as libc::c_ulong + && (Curl_isdigit(*line.offset(0 as libc::c_int as isize) as libc::c_uchar as libc::c_int) + != 0 + && Curl_isdigit(*line.offset(1 as libc::c_int as isize) as libc::c_uchar as libc::c_int) + != 0 + && Curl_isdigit(*line.offset(2 as libc::c_int as isize) as libc::c_uchar as libc::c_int) + != 0 + && ' ' as i32 == *line.offset(3 as libc::c_int as isize) as libc::c_int) + { + *code = curlx_sltosi(strtol(line, 0 as *mut *mut libc::c_char, 10 as libc::c_int)); + return 1 as libc::c_int != 0; + } + return 0 as libc::c_int != 0; + } + unsafe extern "C" fn ftp_readresp( + mut data: *mut Curl_easy, + mut sockfd: curl_socket_t, + mut pp: *mut pingpong, + mut ftpcode: *mut libc::c_int, + mut size: *mut size_t, + ) -> CURLcode { + let mut code: libc::c_int = 0; + let mut result: CURLcode = Curl_pp_readresp(data, sockfd, pp, &mut code, size); + if cfg!(HAVE_GSSAPI) { + let mut conn: *mut connectdata = (*data).conn; + let buf: *mut libc::c_char = (*data).state.buffer; + match code { + 631 => { + code = Curl_sec_read_msg(data, conn, buf, PROT_SAFE); + } + 632 => { + code = Curl_sec_read_msg(data, conn, buf, PROT_PRIVATE); + } + 633 => { + code = Curl_sec_read_msg(data, conn, buf, PROT_CONFIDENTIAL); + } + _ => {} + } + } + (*data).info.httpcode = code; + if !ftpcode.is_null() { + *ftpcode = code; + } + if 421 as libc::c_int == code { + Curl_infof( + data, + b"We got a 421 - timeout!\0" as *const u8 as *const libc::c_char, + ); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 596 as libc::c_int); + return CURLE_OPERATION_TIMEDOUT; + } + return result; + } + #[no_mangle] + pub unsafe extern "C" fn Curl_GetFTPResponse( + mut data: *mut Curl_easy, + mut nreadp: *mut ssize_t, + mut ftpcode: *mut libc::c_int, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut sockfd: curl_socket_t = (*conn).sock[0 as libc::c_int as usize]; + let mut result: CURLcode = CURLE_OK; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + let mut nread: size_t = 0; + let mut cache_skip: libc::c_int = 0 as libc::c_int; + let mut value_to_be_ignored: libc::c_int = 0 as libc::c_int; + if !ftpcode.is_null() { + *ftpcode = 0 as libc::c_int; + } else { + ftpcode = &mut value_to_be_ignored; + } + *nreadp = 0 as libc::c_int as ssize_t; + let mut current_block_20: u64; + while *ftpcode == 0 && result as u64 == 0 { + let mut timeout: timediff_t = Curl_pp_state_timeout(data, pp, 0 as libc::c_int != 0); + let mut interval_ms: timediff_t = 0; + if timeout <= 0 as libc::c_int as libc::c_long { + Curl_failf( + data, + b"FTP response timeout\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OPERATION_TIMEDOUT; + } + interval_ms = 1000 as libc::c_int as timediff_t; + if timeout < interval_ms { + interval_ms = timeout; + } + if !(!((*pp).cache).is_null() && cache_skip < 2 as libc::c_int) { + if !Curl_conn_data_pending(conn, 0 as libc::c_int) { + match Curl_socket_check( + sockfd, + -(1 as libc::c_int), + -(1 as libc::c_int), + interval_ms, + ) { + -1 => { + current_block_20 = 3097724707645237320; + match current_block_20 { + 3097724707645237320 => { + Curl_failf( + data, + b"FTP response aborted due to select/poll error: %d\0" + as *const u8 + as *const libc::c_char, + *__errno_location(), + ); + return CURLE_RECV_ERROR; + } + _ => { + if Curl_pgrsUpdate(data) != 0 { + return CURLE_ABORTED_BY_CALLBACK; + } + continue; + } + } + } + 0 => { + current_block_20 = 16982823512181177793; + match current_block_20 { + 3097724707645237320 => { + Curl_failf( + data, + b"FTP response aborted due to select/poll error: %d\0" + as *const u8 + as *const libc::c_char, + *__errno_location(), + ); + return CURLE_RECV_ERROR; + } + _ => { + if Curl_pgrsUpdate(data) != 0 { + return CURLE_ABORTED_BY_CALLBACK; + } + continue; + } + } + } + _ => {} + } + } + } + result = ftp_readresp(data, sockfd, pp, ftpcode, &mut nread); + if result as u64 != 0 { + break; + } + if nread == 0 && !((*pp).cache).is_null() { + cache_skip += 1; + } else { + cache_skip = 0 as libc::c_int; + } + *nreadp = (*nreadp as libc::c_ulong).wrapping_add(nread) as ssize_t as ssize_t; + } + (*pp).pending_resp = 0 as libc::c_int != 0; + return result; + } + static mut ftp_state_names: [*const libc::c_char; 35] = [ + b"STOP\0" as *const u8 as *const libc::c_char, + b"WAIT220\0" as *const u8 as *const libc::c_char, + b"AUTH\0" as *const u8 as *const libc::c_char, + b"USER\0" as *const u8 as *const libc::c_char, + b"PASS\0" as *const u8 as *const libc::c_char, + b"ACCT\0" as *const u8 as *const libc::c_char, + b"PBSZ\0" as *const u8 as *const libc::c_char, + b"PROT\0" as *const u8 as *const libc::c_char, + b"CCC\0" as *const u8 as *const libc::c_char, + b"PWD\0" as *const u8 as *const libc::c_char, + b"SYST\0" as *const u8 as *const libc::c_char, + b"NAMEFMT\0" as *const u8 as *const libc::c_char, + b"QUOTE\0" as *const u8 as *const libc::c_char, + b"RETR_PREQUOTE\0" as *const u8 as *const libc::c_char, + b"STOR_PREQUOTE\0" as *const u8 as *const libc::c_char, + b"POSTQUOTE\0" as *const u8 as *const libc::c_char, + b"CWD\0" as *const u8 as *const libc::c_char, + b"MKD\0" as *const u8 as *const libc::c_char, + b"MDTM\0" as *const u8 as *const libc::c_char, + b"TYPE\0" as *const u8 as *const libc::c_char, + b"LIST_TYPE\0" as *const u8 as *const libc::c_char, + b"RETR_TYPE\0" as *const u8 as *const libc::c_char, + b"STOR_TYPE\0" as *const u8 as *const libc::c_char, + b"SIZE\0" as *const u8 as *const libc::c_char, + b"RETR_SIZE\0" as *const u8 as *const libc::c_char, + b"STOR_SIZE\0" as *const u8 as *const libc::c_char, + b"REST\0" as *const u8 as *const libc::c_char, + b"RETR_REST\0" as *const u8 as *const libc::c_char, + b"PORT\0" as *const u8 as *const libc::c_char, + b"PRET\0" as *const u8 as *const libc::c_char, + b"PASV\0" as *const u8 as *const libc::c_char, + b"LIST\0" as *const u8 as *const libc::c_char, + b"RETR\0" as *const u8 as *const libc::c_char, + b"STOR\0" as *const u8 as *const libc::c_char, + b"QUIT\0" as *const u8 as *const libc::c_char, + ]; + + #[cfg(not(DEBUGBUILD))] + unsafe extern "C" fn _state(mut data: *mut Curl_easy, mut newstate: ftpstate) { + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + (*ftpc).state = newstate; + } + #[cfg(DEBUGBUILD)] + unsafe extern "C" fn _state( + mut data: *mut Curl_easy, + mut newstate: ftpstate, + mut lineno: libc::c_int, + ) { + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (*ftpc).state as libc::c_uint != newstate as libc::c_uint { + Curl_infof( + data, + b"FTP %p (line %d) state change from %s to %s\0" as *const u8 as *const libc::c_char, + ftpc as *mut libc::c_void, + lineno, + ftp_state_names[(*ftpc).state as usize], + ftp_state_names[newstate as usize], + ); + } + (*ftpc).state = newstate; + } + unsafe extern "C" fn ftp_state_user( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = Curl_pp_sendf( + data, + &mut (*conn).proto.ftpc.pp as *mut pingpong, + b"USER %s\0" as *const u8 as *const libc::c_char, + if !((*conn).user).is_null() { + (*conn).user as *const libc::c_char + } else { + b"\0" as *const u8 as *const libc::c_char + }, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_USER); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_USER, 787 as libc::c_int); + let ref mut fresh6 = (*data).state; + (*fresh6).set_ftp_trying_alternative(0 as libc::c_int as bit); + } + return result; + } + unsafe extern "C" fn ftp_state_pwd( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = Curl_pp_sendf( + data, + &mut (*conn).proto.ftpc.pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + b"PWD\0" as *const u8 as *const libc::c_char, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_PWD); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PWD, 798 as libc::c_int); + } + return result; + } + unsafe extern "C" fn ftp_getsock( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut socks: *mut curl_socket_t, + ) -> libc::c_int { + return Curl_pp_getsock(data, &mut (*conn).proto.ftpc.pp, socks); + } + unsafe extern "C" fn ftp_domore_getsock( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut socks: *mut curl_socket_t, + ) -> libc::c_int { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (*conn).cnnct.state as libc::c_uint >= CONNECT_SOCKS_INIT as libc::c_int as libc::c_uint + && ((*conn).cnnct.state as libc::c_uint) < CONNECT_DONE as libc::c_int as libc::c_uint + { + #[cfg(not(CURL_DISABLE_PROXY))] + return Curl_SOCKS_getsock(conn, socks, 1 as libc::c_int); + #[cfg(CURL_DISABLE_PROXY)] + return 0 as libc::c_int; + } + if FTP_STOP as libc::c_int as libc::c_uint == (*ftpc).state as libc::c_uint { + let mut bits: libc::c_int = (1 as libc::c_int) << 0 as libc::c_int; + let mut any: bool = 0 as libc::c_int != 0; + *socks.offset(0 as libc::c_int as isize) = (*conn).sock[0 as libc::c_int as usize]; + if ((*data).set).ftp_use_port() == 0 { + let mut s: libc::c_int = 0; + let mut i: libc::c_int = 0; + s = 1 as libc::c_int; + i = 0 as libc::c_int; + while i < 2 as libc::c_int { + if (*conn).tempsock[i as usize] != -(1 as libc::c_int) { + *socks.offset(s as isize) = (*conn).tempsock[i as usize]; + let fresh7 = s; + s = s + 1; + bits |= (1 as libc::c_int) << 16 as libc::c_int + fresh7; + any = 1 as libc::c_int != 0; + } + i += 1; + } + } + if !any { + *socks.offset(1 as libc::c_int as isize) = (*conn).sock[1 as libc::c_int as usize]; + bits |= (1 as libc::c_int) << 16 as libc::c_int + 1 as libc::c_int + | (1 as libc::c_int) << 1 as libc::c_int; + } + return bits; + } + return Curl_pp_getsock(data, &mut (*conn).proto.ftpc.pp, socks); + } + unsafe extern "C" fn ftp_state_cwd( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (*ftpc).cwddone { + result = ftp_state_mdtm(data); + } else { + #[cfg(all(DEBUGBUILD, HAVE_ASSERT_H))] + if (*data).set.ftp_filemethod as libc::c_uint + != FTPFILE_NOCWD as libc::c_int as libc::c_uint + || !((*ftpc).dirdepth != 0 + && *(*((*ftpc).dirs).offset(0 as libc::c_int as isize)) + .offset(0 as libc::c_int as isize) as libc::c_int + == '/' as i32) + { + } else { + __assert_fail( + b"(data->set.ftp_filemethod != FTPFILE_NOCWD) || !(ftpc->dirdepth && ftpc->dirs[0][0] == '/')\0" + as *const u8 as *const libc::c_char, + b"ftp.c\0" as *const u8 as *const libc::c_char, + 875 as libc::c_int as libc::c_uint, + (*::std::mem::transmute::< + &[u8; 65], + &[libc::c_char; 65], + >(b"CURLcode ftp_state_cwd(struct Curl_easy *, struct connectdata *)\0")) + .as_ptr(), + ); + } + (*ftpc).count2 = 0 as libc::c_int; + (*ftpc).count3 = if (*data).set.ftp_create_missing_dirs == 2 as libc::c_int { + 1 as libc::c_int + } else { + 0 as libc::c_int + }; + if ((*conn).bits).reuse() as libc::c_int != 0 + && !((*ftpc).entrypath).is_null() + && !((*ftpc).dirdepth != 0 + && *(*((*ftpc).dirs).offset(0 as libc::c_int as isize)) + .offset(0 as libc::c_int as isize) as libc::c_int + == '/' as i32) + { + (*ftpc).cwdcount = 0 as libc::c_int; + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"CWD %s\0" as *const u8 as *const libc::c_char, + (*ftpc).entrypath, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_CWD); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_CWD, 894 as libc::c_int); + } + } else if (*ftpc).dirdepth != 0 { + (*ftpc).cwdcount = 1 as libc::c_int; + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"CWD %s\0" as *const u8 as *const libc::c_char, + *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_CWD); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_CWD, 904 as libc::c_int); + } + } else { + result = ftp_state_mdtm(data); + } + } + return result; + } + unsafe extern "C" fn ftp_state_use_port(mut data: *mut Curl_easy, mut fcmd: ftpport) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut portsock: curl_socket_t = -(1 as libc::c_int); + let mut myhost: [libc::c_char; 47] = *::std::mem::transmute::< + &[u8; 47], + &mut [libc::c_char; 47], + >( + b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + ); + let mut ss: Curl_sockaddr_storage = Curl_sockaddr_storage { + buffer: C2RustUnnamed_9 { + sa: sockaddr { + sa_family: 0, + sa_data: [0; 14], + }, + }, + }; + let mut res: *mut Curl_addrinfo = 0 as *mut Curl_addrinfo; + let mut ai: *mut Curl_addrinfo = 0 as *mut Curl_addrinfo; + let mut sslen: curl_socklen_t = 0; + let mut hbuf: [libc::c_char; 1025] = [0; 1025]; + let mut sa: *mut sockaddr = &mut ss as *mut Curl_sockaddr_storage as *mut sockaddr; + let sa4: *mut sockaddr_in = sa as *mut libc::c_void as *mut sockaddr_in; + #[cfg(ENABLE_IPV6)] + let sa6: *mut sockaddr_in6 = sa as *mut libc::c_void as *mut sockaddr_in6; + static mut mode: [[libc::c_char; 5]; 2] = unsafe { + [ + *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"EPRT\0"), + *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"PORT\0"), + ] + }; + let mut rc: resolve_t = CURLRESOLV_RESOLVED; + let mut error: libc::c_int = 0; + let mut host: *mut libc::c_char = 0 as *mut libc::c_char; + let mut string_ftpport: *mut libc::c_char = + (*data).set.str_0[STRING_FTPPORT as libc::c_int as usize]; + let mut h: *mut Curl_dns_entry = 0 as *mut Curl_dns_entry; + let mut port_min: libc::c_ushort = 0 as libc::c_int as libc::c_ushort; + let mut port_max: libc::c_ushort = 0 as libc::c_int as libc::c_ushort; + let mut port: libc::c_ushort = 0; + let mut possibly_non_local: bool = 1 as libc::c_int != 0; + let mut buffer: [libc::c_char; 256] = [0; 256]; + let mut addr: *mut libc::c_char = 0 as *mut libc::c_char; + if !((*data).set.str_0[STRING_FTPPORT as libc::c_int as usize]).is_null() + && strlen((*data).set.str_0[STRING_FTPPORT as libc::c_int as usize]) + > 1 as libc::c_int as libc::c_ulong + { + #[cfg(ENABLE_IPV6)] + let mut addrlen: size_t = if 46 as libc::c_int as libc::c_ulong > strlen(string_ftpport) { + 46 as libc::c_int as libc::c_ulong + } else { + strlen(string_ftpport) + }; + #[cfg(not(ENABLE_IPV6))] + let mut addrlen: size_t = if 16 as libc::c_int as libc::c_ulong + > strlen(string_ftpport) + { + 16 as libc::c_int as libc::c_ulong + } else { + strlen(string_ftpport) + }; + let mut ip_start: *mut libc::c_char = string_ftpport; + let mut ip_end: *mut libc::c_char = 0 as *mut libc::c_char; + let mut port_start: *mut libc::c_char = 0 as *mut libc::c_char; + let mut port_sep: *mut libc::c_char = 0 as *mut libc::c_char; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + addr = Curl_ccalloc.expect("non-null function pointer")( + addrlen.wrapping_add(1 as libc::c_int as libc::c_ulong), + 1 as libc::c_int as size_t, + ) as *mut libc::c_char; + } + #[cfg(CURLDEBUG)] + _ => { + addr = curl_dbg_calloc( + addrlen.wrapping_add(1 as libc::c_int as libc::c_ulong), + 1 as libc::c_int as size_t, + 972 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut libc::c_char; + } + } + + if addr.is_null() { + return CURLE_OUT_OF_MEMORY; + } + let flag: bool = if cfg!(ENABLE_IPV6) { + *string_ftpport as libc::c_int == '[' as i32 + } else { + false + }; + if flag + { + ip_start = string_ftpport.offset(1 as libc::c_int as isize); + ip_end = strchr(string_ftpport, ']' as i32); + if !ip_end.is_null() { + strncpy( + addr, + ip_start, + ip_end.offset_from(ip_start) as libc::c_long as libc::c_ulong, + ); + } + } else if *string_ftpport as libc::c_int == ':' as i32 { + ip_end = string_ftpport; + } else { + ip_end = strchr(string_ftpport, ':' as i32); + if !ip_end.is_null() { + #[cfg(ENABLE_IPV6)] + if inet_pton(10 as libc::c_int, string_ftpport, sa6 as *mut libc::c_void) + == 1 as libc::c_int + { + port_max = 0 as libc::c_int as libc::c_ushort; + port_min = port_max; + strcpy(addr, string_ftpport); + ip_end = 0 as *mut libc::c_char; + } else { + strncpy( + addr, + string_ftpport, + ip_end.offset_from(ip_start) as libc::c_long as libc::c_ulong, + ); + } + #[cfg(not(ENABLE_IPV6))] + strncpy( + addr, + string_ftpport, + ip_end.offset_from(ip_start) as libc::c_long as libc::c_ulong, + ); + } else { + strcpy(addr, string_ftpport); + } + } + if !ip_end.is_null() { + port_start = strchr(ip_end, ':' as i32); + if !port_start.is_null() { + port_min = curlx_ultous(strtoul( + port_start.offset(1 as libc::c_int as isize), + 0 as *mut *mut libc::c_char, + 10 as libc::c_int, + )); + port_sep = strchr(port_start, '-' as i32); + if !port_sep.is_null() { + port_max = curlx_ultous(strtoul( + port_sep.offset(1 as libc::c_int as isize), + 0 as *mut *mut libc::c_char, + 10 as libc::c_int, + )); + } else { + port_max = port_min; + } + } + } + if port_min as libc::c_int > port_max as libc::c_int { + port_max = 0 as libc::c_int as libc::c_ushort; + port_min = port_max; + } + if *addr as libc::c_int != '\0' as i32 { + match Curl_if2ip( + (*(*conn).ip_addr).ai_family, + Curl_ipv6_scope((*(*conn).ip_addr).ai_addr), + (*conn).scope_id, + addr, + hbuf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 1025]>() as libc::c_ulong as libc::c_int, + ) as libc::c_uint + { + 0 => { + host = addr; + } + 1 => return CURLE_FTP_PORT_FAILED, + 2 => { + host = hbuf.as_mut_ptr(); + } + _ => {} + } + } else { + host = 0 as *mut libc::c_char; + } + } + if host.is_null() { + let mut r: *const libc::c_char = 0 as *const libc::c_char; + sslen = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; + if getsockname((*conn).sock[0 as libc::c_int as usize], sa, &mut sslen) != 0 { + Curl_failf( + data, + b"getsockname() failed: %s\0" as *const u8 as *const libc::c_char, + Curl_strerror( + *__errno_location(), + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(addr as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + addr as *mut libc::c_void, + 1063 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_PORT_FAILED; + } + match (*sa).sa_family as libc::c_int { + #[cfg(ENABLE_IPV6)] + 10 => { + r = inet_ntop( + (*sa).sa_family as libc::c_int, + &mut (*sa6).sin6_addr as *mut in6_addr as *const libc::c_void, + hbuf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 1025]>() as libc::c_ulong + as curl_socklen_t, + ); + } + _ => { + r = inet_ntop( + (*sa).sa_family as libc::c_int, + &mut (*sa4).sin_addr as *mut in_addr as *const libc::c_void, + hbuf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 1025]>() as libc::c_ulong + as curl_socklen_t, + ); + } + } + if r.is_null() { + return CURLE_FTP_PORT_FAILED; + } + host = hbuf.as_mut_ptr(); + possibly_non_local = 0 as libc::c_int != 0; + } + rc = Curl_resolv(data, host, 0 as libc::c_int, 0 as libc::c_int != 0, &mut h); + if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { + Curl_resolver_wait_resolv(data, &mut h); + } + if !h.is_null() { + res = (*h).addr; + Curl_resolv_unlock(data, h); + } else { + res = 0 as *mut Curl_addrinfo; + } + if res.is_null() { + Curl_failf( + data, + b"failed to resolve the address provided to PORT: %s\0" as *const u8 + as *const libc::c_char, + host, + ); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(addr as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + addr as *mut libc::c_void, + 1097 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_PORT_FAILED; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(addr as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + addr as *mut libc::c_void, + 1101 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + host = 0 as *mut libc::c_char; + portsock = -(1 as libc::c_int); + error = 0 as libc::c_int; + ai = res; + while !ai.is_null() { + result = Curl_socket(data, ai, 0 as *mut Curl_sockaddr_ex, &mut portsock); + if !(result as u64 != 0) { + break; + } + error = *__errno_location(); + ai = (*ai).ai_next; + } + if ai.is_null() { + Curl_failf( + data, + b"socket failure: %s\0" as *const u8 as *const libc::c_char, + Curl_strerror( + error, + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + return CURLE_FTP_PORT_FAILED; + } + memcpy( + sa as *mut libc::c_void, + (*ai).ai_addr as *const libc::c_void, + (*ai).ai_addrlen as libc::c_ulong, + ); + sslen = (*ai).ai_addrlen; + port = port_min; + while port as libc::c_int <= port_max as libc::c_int { + if (*sa).sa_family as libc::c_int == 2 as libc::c_int { + (*sa4).sin_port = htons(port); + } else { + match () { + #[cfg(ENABLE_IPV6)] + _ => { + (*sa6).sin6_port = htons(port); + } + #[cfg(not(ENABLE_IPV6))] + _ => { } + } + } + if !(bind(portsock, sa, sslen) != 0) { + break; + } + error = *__errno_location(); + if possibly_non_local as libc::c_int != 0 && error == 99 as libc::c_int { + Curl_infof( + data, + b"bind(port=%hu) on non-local address failed: %s\0" as *const u8 + as *const libc::c_char, + port as libc::c_int, + Curl_strerror( + error, + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + sslen = + ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; + if getsockname((*conn).sock[0 as libc::c_int as usize], sa, &mut sslen) != 0 { + Curl_failf( + data, + b"getsockname() failed: %s\0" as *const u8 as *const libc::c_char, + Curl_strerror( + *__errno_location(), + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + Curl_closesocket(data, conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + port = port_min; + possibly_non_local = 0 as libc::c_int != 0; + } else { + if error != 98 as libc::c_int && error != 13 as libc::c_int { + Curl_failf( + data, + b"bind(port=%hu) failed: %s\0" as *const u8 as *const libc::c_char, + port as libc::c_int, + Curl_strerror( + error, + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + Curl_closesocket(data, conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + port = port.wrapping_add(1); + } + } + if port as libc::c_int > port_max as libc::c_int { + Curl_failf( + data, + b"bind() failed, we ran out of ports!\0" as *const u8 as *const libc::c_char, + ); + Curl_closesocket(data, conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + sslen = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; + if getsockname(portsock, sa, &mut sslen) != 0 { + Curl_failf( + data, + b"getsockname() failed: %s\0" as *const u8 as *const libc::c_char, + Curl_strerror( + *__errno_location(), + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + Curl_closesocket(data, conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + if listen(portsock, 1 as libc::c_int) != 0 { + Curl_failf( + data, + b"socket failure: %s\0" as *const u8 as *const libc::c_char, + Curl_strerror( + *__errno_location(), + buffer.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ), + ); + Curl_closesocket(data, conn, portsock); + return CURLE_FTP_PORT_FAILED; + } + Curl_printable_address( + ai, + myhost.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 47]>() as libc::c_ulong, + ); + #[cfg(ENABLE_IPV6)] + if ((*conn).bits).ftp_use_eprt() == 0 && ((*conn).bits).ipv6() as libc::c_int != 0 { + let ref mut fresh8 = (*conn).bits; + (*fresh8).set_ftp_use_eprt(1 as libc::c_int as bit); + } + while fcmd as libc::c_uint != DONE as libc::c_int as libc::c_uint { + if !(((*conn).bits).ftp_use_eprt() == 0 + && EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint) + { + if !(PORT as libc::c_int as libc::c_uint == fcmd as libc::c_uint + && (*sa).sa_family as libc::c_int != 2 as libc::c_int) + { + match (*sa).sa_family as libc::c_int { + 2 => { + port = __bswap_16((*sa4).sin_port); + if EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s |%d|%s|%hu|\0" as *const u8 as *const libc::c_char, + (mode[fcmd as usize]).as_ptr(), + if (*sa).sa_family as libc::c_int == 2 as libc::c_int { + 1 as libc::c_int + } else { + 2 as libc::c_int + }, + myhost.as_mut_ptr(), + port as libc::c_int, + ); + if result as u64 != 0 { + Curl_failf( + data, + b"Failure sending EPRT command: %s\0" as *const u8 + as *const libc::c_char, + curl_easy_strerror(result), + ); + Curl_closesocket(data, conn, portsock); + (*ftpc).count1 = PORT as libc::c_int; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 1250 as libc::c_int); + return result; + } + break; + } else if PORT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { + let mut target: [libc::c_char; 67] = [0; 67]; + let mut source: *mut libc::c_char = myhost.as_mut_ptr(); + let mut dest: *mut libc::c_char = target.as_mut_ptr(); + while !source.is_null() && *source as libc::c_int != 0 { + if *source as libc::c_int == '.' as i32 { + *dest = ',' as i32 as libc::c_char; + } else { + *dest = *source; + } + dest = dest.offset(1); + source = source.offset(1); + } + *dest = 0 as libc::c_int as libc::c_char; + curl_msnprintf( + dest, + 20 as libc::c_int as size_t, + b",%d,%d\0" as *const u8 as *const libc::c_char, + port as libc::c_int >> 8 as libc::c_int, + port as libc::c_int & 0xff as libc::c_int, + ); + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s %s\0" as *const u8 as *const libc::c_char, + (mode[fcmd as usize]).as_ptr(), + target.as_mut_ptr(), + ); + if result as u64 != 0 { + Curl_failf( + data, + b"Failure sending PORT command: %s\0" as *const u8 + as *const libc::c_char, + curl_easy_strerror(result), + ); + Curl_closesocket(data, conn, portsock); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 1279 as libc::c_int); + return result; + } + break; + } + } + #[cfg(ENABLE_IPV6)] + 10 => { + port = __bswap_16((*sa6).sin6_port); + if EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s |%d|%s|%hu|\0" as *const u8 as *const libc::c_char, + (mode[fcmd as usize]).as_ptr(), + if (*sa).sa_family as libc::c_int == 2 as libc::c_int { + 1 as libc::c_int + } else { + 2 as libc::c_int + }, + myhost.as_mut_ptr(), + port as libc::c_int, + ); + if result as u64 != 0 { + Curl_failf( + data, + b"Failure sending EPRT command: %s\0" as *const u8 + as *const libc::c_char, + curl_easy_strerror(result), + ); + Curl_closesocket(data, conn, portsock); + (*ftpc).count1 = PORT as libc::c_int; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 1250 as libc::c_int); + return result; + } + break; + } else if PORT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { + let mut target: [libc::c_char; 67] = [0; 67]; + let mut source: *mut libc::c_char = myhost.as_mut_ptr(); + let mut dest: *mut libc::c_char = target.as_mut_ptr(); + while !source.is_null() && *source as libc::c_int != 0 { + if *source as libc::c_int == '.' as i32 { + *dest = ',' as i32 as libc::c_char; + } else { + *dest = *source; + } + dest = dest.offset(1); + source = source.offset(1); + } + *dest = 0 as libc::c_int as libc::c_char; + curl_msnprintf( + dest, + 20 as libc::c_int as size_t, + b",%d,%d\0" as *const u8 as *const libc::c_char, + port as libc::c_int >> 8 as libc::c_int, + port as libc::c_int & 0xff as libc::c_int, + ); + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s %s\0" as *const u8 as *const libc::c_char, + (mode[fcmd as usize]).as_ptr(), + target.as_mut_ptr(), + ); + if result as u64 != 0 { + Curl_failf( + data, + b"Failure sending PORT command: %s\0" as *const u8 + as *const libc::c_char, + curl_easy_strerror(result), + ); + Curl_closesocket(data, conn, portsock); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 1279 as libc::c_int); + return result; + } + break; + } + } + _ => {} + } + } + } + fcmd += 1; + } + (*ftpc).count1 = fcmd as libc::c_int; + close_secondarysocket(data, conn); + (*conn).sock[1 as libc::c_int as usize] = portsock; + (*conn).bits.tcpconnect[1 as libc::c_int as usize] = 1 as libc::c_int != 0; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_PORT); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PORT, 1305 as libc::c_int); + return result; + } + unsafe extern "C" fn ftp_state_use_pasv( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut result: CURLcode = CURLE_OK; + static mut mode: [[libc::c_char; 5]; 2] = unsafe { + [ + *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"EPSV\0"), + *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"PASV\0"), + ] + }; + let mut modeoff: libc::c_int = 0; + #[cfg(PF_INET6)] + if ((*conn).bits).ftp_use_epsv() == 0 && ((*conn).bits).ipv6() as libc::c_int != 0 { + let ref mut fresh9 = (*conn).bits; + (*fresh9).set_ftp_use_epsv(1 as libc::c_int as bit); + } + modeoff = if ((*conn).bits).ftp_use_epsv() as libc::c_int != 0 { + 0 as libc::c_int + } else { + 1 as libc::c_int + }; + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + (mode[modeoff as usize]).as_ptr(), + ); + if result as u64 == 0 { + (*ftpc).count1 = modeoff; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_PASV); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PASV, 1343 as libc::c_int); + Curl_infof( + data, + b"Connect data stream passively\0" as *const u8 as *const libc::c_char, + ); + } + return result; + } + unsafe extern "C" fn ftp_state_prepare_transfer(mut data: *mut Curl_easy) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_RETR_PREQUOTE); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_RETR_PREQUOTE, 1366 as libc::c_int); + result = ftp_state_quote(data, 1 as libc::c_int != 0, FTP_RETR_PREQUOTE); + } else if ((*data).set).ftp_use_port() != 0 { + result = ftp_state_use_port(data, EPRT); + } else if ((*data).set).ftp_use_pret() != 0 { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if ((*conn).proto.ftpc.file).is_null() { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"PRET %s\0" as *const u8 as *const libc::c_char, + if !((*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize]).is_null() { + (*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize] + as *const libc::c_char + } else if ((*data).state).list_only() as libc::c_int != 0 { + b"NLST\0" as *const u8 as *const libc::c_char + } else { + b"LIST\0" as *const u8 as *const libc::c_char + }, + ); + } else if ((*data).set).upload() != 0 { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"PRET STOR %s\0" as *const u8 as *const libc::c_char, + (*conn).proto.ftpc.file, + ); + } else { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"PRET RETR %s\0" as *const u8 as *const libc::c_char, + (*conn).proto.ftpc.file, + ); + } + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_PRET); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PRET, 1391 as libc::c_int); + } + } else { + result = ftp_state_use_pasv(data, conn); + } + return result; + } + unsafe extern "C" fn ftp_state_rest( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint + && !((*ftpc).file).is_null() + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"REST %d\0" as *const u8 as *const libc::c_char, + 0 as libc::c_int, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_REST); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_REST, 1413 as libc::c_int); + } + } else { + result = ftp_state_prepare_transfer(data); + } + return result; + } + unsafe extern "C" fn ftp_state_size( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (*ftp).transfer as libc::c_uint == PPTRANSFER_INFO as libc::c_int as libc::c_uint + && !((*ftpc).file).is_null() + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"SIZE %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_SIZE); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_SIZE, 1434 as libc::c_int); + } + } else { + result = ftp_state_rest(data, conn); + } + return result; + } + unsafe extern "C" fn ftp_state_list(mut data: *mut Curl_easy) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + let mut lstArg: *mut libc::c_char = 0 as *mut libc::c_char; + let mut cmd: *mut libc::c_char = 0 as *mut libc::c_char; + if (*data).set.ftp_filemethod as libc::c_uint == FTPFILE_NOCWD as libc::c_int as libc::c_uint + && !((*ftp).path).is_null() + { + let mut slashPos: *const libc::c_char = 0 as *const libc::c_char; + let mut rawPath: *mut libc::c_char = 0 as *mut libc::c_char; + result = Curl_urldecode( + data, + (*ftp).path, + 0 as libc::c_int as size_t, + &mut rawPath, + 0 as *mut size_t, + REJECT_CTRL, + ); + if result as u64 != 0 { + return result; + } + slashPos = strrchr(rawPath, '/' as i32); + if !slashPos.is_null() { + let mut n: size_t = slashPos.offset_from(rawPath) as libc::c_long as size_t; + if n == 0 as libc::c_int as libc::c_ulong { + n = n.wrapping_add(1); + } + lstArg = rawPath; + *lstArg.offset(n as isize) = '\0' as i32 as libc::c_char; + } else { + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 1484 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + cmd = curl_maprintf( + b"%s%s%s\0" as *const u8 as *const libc::c_char, + if !((*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize]).is_null() { + (*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize] as *const libc::c_char + } else if ((*data).state).list_only() as libc::c_int != 0 { + b"NLST\0" as *const u8 as *const libc::c_char + } else { + b"LIST\0" as *const u8 as *const libc::c_char + }, + if !lstArg.is_null() { + b" \0" as *const u8 as *const libc::c_char + } else { + b"\0" as *const u8 as *const libc::c_char + }, + if !lstArg.is_null() { + lstArg as *const libc::c_char + } else { + b"\0" as *const u8 as *const libc::c_char + }, + ); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(lstArg as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + lstArg as *mut libc::c_void, + 1493 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + if cmd.is_null() { + return CURLE_OUT_OF_MEMORY; + } + result = Curl_pp_sendf( + data, + &mut (*conn).proto.ftpc.pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + cmd, + ); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(cmd as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + cmd as *mut libc::c_void, + 1499 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_LIST); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_LIST, 1502 as libc::c_int); + } + return result; + } + unsafe extern "C" fn ftp_state_retr_prequote(mut data: *mut Curl_easy) -> CURLcode { + return ftp_state_quote(data, 1 as libc::c_int != 0, FTP_RETR_PREQUOTE); + } + unsafe extern "C" fn ftp_state_stor_prequote(mut data: *mut Curl_easy) -> CURLcode { + return ftp_state_quote(data, 1 as libc::c_int != 0, FTP_STOR_PREQUOTE); + } + unsafe extern "C" fn ftp_state_type(mut data: *mut Curl_easy) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if ((*data).set).opt_no_body() as libc::c_int != 0 + && !((*ftpc).file).is_null() + && ftp_need_type(conn, ((*data).state).prefer_ascii() != 0) != 0 + { + (*ftp).transfer = PPTRANSFER_INFO; + result = ftp_nb_type(data, conn, ((*data).state).prefer_ascii() != 0, FTP_TYPE); + if result as u64 != 0 { + return result; + } + } else { + result = ftp_state_size(data, conn); + } + return result; + } + unsafe extern "C" fn ftp_state_mdtm(mut data: *mut Curl_easy) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (((*data).set).get_filetime() as libc::c_int != 0 + || (*data).set.timecondition as libc::c_uint != 0) + && !((*ftpc).file).is_null() + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"MDTM %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_MDTM); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_MDTM, 1566 as libc::c_int); + } + } else { + result = ftp_state_type(data); + } + return result; + } + unsafe extern "C" fn ftp_state_ul_setup( + mut data: *mut Curl_easy, + mut sizechecked: bool, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut append: bool = ((*data).set).remote_append() != 0; + if (*data).state.resume_from != 0 && !sizechecked + || (*data).state.resume_from > 0 as libc::c_int as libc::c_long + && sizechecked as libc::c_int != 0 + { + let mut seekerr: libc::c_int = 0 as libc::c_int; + if (*data).state.resume_from < 0 as libc::c_int as libc::c_long { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"SIZE %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOR_SIZE); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOR_SIZE, 1605 as libc::c_int); + } + return result; + } + append = 1 as libc::c_int != 0; + if ((*conn).seek_func).is_some() { + Curl_set_in_callback(data, 1 as libc::c_int != 0); + seekerr = ((*conn).seek_func).expect("non-null function pointer")( + (*conn).seek_client, + (*data).state.resume_from, + 0 as libc::c_int, + ); + Curl_set_in_callback(data, 0 as libc::c_int != 0); + } + if seekerr != 0 as libc::c_int { + let mut passed: curl_off_t = 0 as libc::c_int as curl_off_t; + if seekerr != 2 as libc::c_int { + Curl_failf( + data, + b"Could not seek stream\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_COULDNT_USE_REST; + } + loop { + let mut readthisamountnow: size_t = + if (*data).state.resume_from - passed > (*data).set.buffer_size { + (*data).set.buffer_size as size_t + } else { + curlx_sotouz((*data).state.resume_from - passed) + }; + let mut actuallyread: size_t = ((*data).state.fread_func) + .expect("non-null function pointer")( + (*data).state.buffer, + 1 as libc::c_int as size_t, + readthisamountnow, + (*data).state.in_0, + ); + passed = (passed as libc::c_ulong).wrapping_add(actuallyread) as curl_off_t + as curl_off_t; + if actuallyread == 0 as libc::c_int as libc::c_ulong + || actuallyread > readthisamountnow + { + Curl_failf( + data, + b"Failed to read data\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_COULDNT_USE_REST; + } + if !(passed < (*data).state.resume_from) { + break; + } + } + } + if (*data).state.infilesize > 0 as libc::c_int as libc::c_long { + let ref mut fresh10 = (*data).state.infilesize; + *fresh10 -= (*data).state.resume_from; + if (*data).state.infilesize <= 0 as libc::c_int as libc::c_long { + Curl_infof( + data, + b"File already completely uploaded\0" as *const u8 as *const libc::c_char, + ); + Curl_setup_transfer( + data, + -(1 as libc::c_int), + -(1 as libc::c_int) as curl_off_t, + 0 as libc::c_int != 0, + -(1 as libc::c_int), + ); + (*ftp).transfer = PPTRANSFER_NONE; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 1660 as libc::c_int); + return CURLE_OK; + } + } + } + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + if append as libc::c_int != 0 { + b"APPE %s\0" as *const u8 as *const libc::c_char + } else { + b"STOR %s\0" as *const u8 as *const libc::c_char + }, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOR); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOR, 1670 as libc::c_int); + } + return result; + } + unsafe extern "C" fn ftp_state_quote( + mut data: *mut Curl_easy, + mut init: bool, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut quote: bool = 0 as libc::c_int != 0; + let mut item: *mut curl_slist = 0 as *mut curl_slist; + match instate as libc::c_uint { + 13 | 14 => { + item = (*data).set.prequote; + } + 15 => { + item = (*data).set.postquote; + } + 12 | _ => { + item = (*data).set.quote; + } + } + if init { + (*ftpc).count1 = 0 as libc::c_int; + } else { + let ref mut fresh11 = (*ftpc).count1; + *fresh11 += 1; + } + if !item.is_null() { + let mut i: libc::c_int = 0 as libc::c_int; + while i < (*ftpc).count1 && !item.is_null() { + item = (*item).next; + i += 1; + } + if !item.is_null() { + let mut cmd: *mut libc::c_char = (*item).data; + if *cmd.offset(0 as libc::c_int as isize) as libc::c_int == '*' as i32 { + cmd = cmd.offset(1); + (*ftpc).count2 = 1 as libc::c_int; + } else { + (*ftpc).count2 = 0 as libc::c_int; + } + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + cmd, + ); + if result as u64 != 0 { + return result; + } + #[cfg(not(DEBUGBUILD))] + _state(data, instate); + + #[cfg(DEBUGBUILD)] + _state(data, instate, 1731 as libc::c_int); + quote = 1 as libc::c_int != 0; + } + } + if !quote { + match instate as libc::c_uint { + 13 => { + if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint + { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 1745 as libc::c_int); + } else if (*ftpc).known_filesize != -(1 as libc::c_int) as libc::c_long { + Curl_pgrsSetDownloadSize(data, (*ftpc).known_filesize); + result = ftp_state_retr(data, (*ftpc).known_filesize); + } else if ((*data).set).ignorecl() as libc::c_int != 0 + || ((*data).state).prefer_ascii() as libc::c_int != 0 + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"RETR %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_RETR); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_RETR, 1767 as libc::c_int); + } + } else { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"SIZE %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_RETR_SIZE); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_RETR_SIZE, 1772 as libc::c_int); + } + } + } + 14 => { + result = ftp_state_ul_setup(data, 0 as libc::c_int != 0); + } + 15 => {} + 12 | _ => { + result = ftp_state_cwd(data, conn); + } + } + } + return result; + } + unsafe extern "C" fn ftp_epsv_disable( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + // TODO 待验证 + #[cfg(not(CURL_DISABLE_PROXY))] + let flag: bool = ((*conn).bits).ipv6() as libc::c_int != 0 + && !(((*conn).bits).tunnel_proxy() as libc::c_int != 0 + || ((*conn).bits).socksproxy() as libc::c_int != 0); + #[cfg(CURL_DISABLE_PROXY)] + let flag: bool = ((*conn).bits).ipv6() as libc::c_int != 0; + if flag + { + Curl_failf( + data, + b"Failed EPSV attempt, exiting\0" as *const u8 as *const libc::c_char, + ); + return CURLE_WEIRD_SERVER_REPLY; + } + Curl_infof( + data, + b"Failed EPSV attempt. Disabling EPSV\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh12 = (*conn).bits; + (*fresh12).set_ftp_use_epsv(0 as libc::c_int as bit); + let ref mut fresh13 = (*data).state; + (*fresh13).set_errorbuf(0 as libc::c_int as bit); + result = Curl_pp_sendf( + data, + &mut (*conn).proto.ftpc.pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + b"PASV\0" as *const u8 as *const libc::c_char, + ); + if result as u64 == 0 { + let ref mut fresh14 = (*conn).proto.ftpc.count1; + *fresh14 += 1; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_PASV); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PASV, 1814 as libc::c_int); + } + return result; + } + unsafe extern "C" fn control_address(mut conn: *mut connectdata) -> *mut libc::c_char { + #[cfg(not(CURL_DISABLE_PROXY))] + if ((*conn).bits).tunnel_proxy() as libc::c_int != 0 + || ((*conn).bits).socksproxy() as libc::c_int != 0 + { + return (*conn).host.name; + } + return ((*conn).primary_ip).as_mut_ptr(); + } + unsafe extern "C" fn ftp_state_pasv_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut result: CURLcode = CURLE_OK; + let mut addr: *mut Curl_dns_entry = 0 as *mut Curl_dns_entry; + let mut rc: resolve_t = CURLRESOLV_RESOLVED; + let mut connectport: libc::c_ushort = 0; + let mut str: *mut libc::c_char = + &mut *((*data).state.buffer).offset(4 as libc::c_int as isize) as *mut libc::c_char; + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).newhost as *mut libc::c_void, + 1845 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh15 = (*ftpc).newhost; + *fresh15 = 0 as *mut libc::c_char; + if (*ftpc).count1 == 0 as libc::c_int && ftpcode == 229 as libc::c_int { + let mut ptr: *mut libc::c_char = strchr(str, '(' as i32); + if !ptr.is_null() { + let mut num: libc::c_uint = 0; + let mut separator: [libc::c_char; 4] = [0; 4]; + ptr = ptr.offset(1); + if 5 as libc::c_int + == sscanf( + ptr, + b"%c%c%c%u%c\0" as *const u8 as *const libc::c_char, + &mut *separator.as_mut_ptr().offset(0 as libc::c_int as isize) + as *mut libc::c_char, + &mut *separator.as_mut_ptr().offset(1 as libc::c_int as isize) + as *mut libc::c_char, + &mut *separator.as_mut_ptr().offset(2 as libc::c_int as isize) + as *mut libc::c_char, + &mut num as *mut libc::c_uint, + &mut *separator.as_mut_ptr().offset(3 as libc::c_int as isize) + as *mut libc::c_char, + ) + { + let sep1: libc::c_char = separator[0 as libc::c_int as usize]; + let mut i: libc::c_int = 0; + i = 1 as libc::c_int; + while i < 4 as libc::c_int { + if separator[i as usize] as libc::c_int != sep1 as libc::c_int { + ptr = 0 as *mut libc::c_char; + break; + } else { + i += 1; + } + } + if num > 0xffff as libc::c_int as libc::c_uint { + Curl_failf( + data, + b"Illegal port number in EPSV reply\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + if !ptr.is_null() { + (*ftpc).newport = + (num & 0xffff as libc::c_int as libc::c_uint) as libc::c_ushort; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).newhost = + Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); + } + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).newhost = curl_dbg_strdup( + control_address(conn), + 1878 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + + if ((*ftpc).newhost).is_null() { + return CURLE_OUT_OF_MEMORY; + } + } + } else { + ptr = 0 as *mut libc::c_char; + } + } + if ptr.is_null() { + Curl_failf( + data, + b"Weirdly formatted EPSV reply\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + } else if (*ftpc).count1 == 1 as libc::c_int && ftpcode == 227 as libc::c_int { + let mut ip: [libc::c_uint; 4] = [ + 0 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint, + ]; + let mut port: [libc::c_uint; 2] = [ + 0 as libc::c_int as libc::c_uint, + 0 as libc::c_int as libc::c_uint, + ]; + while *str != 0 { + if 6 as libc::c_int + == sscanf( + str, + b"%u,%u,%u,%u,%u,%u\0" as *const u8 as *const libc::c_char, + &mut *ip.as_mut_ptr().offset(0 as libc::c_int as isize) as *mut libc::c_uint, + &mut *ip.as_mut_ptr().offset(1 as libc::c_int as isize) as *mut libc::c_uint, + &mut *ip.as_mut_ptr().offset(2 as libc::c_int as isize) as *mut libc::c_uint, + &mut *ip.as_mut_ptr().offset(3 as libc::c_int as isize) as *mut libc::c_uint, + &mut *port.as_mut_ptr().offset(0 as libc::c_int as isize) as *mut libc::c_uint, + &mut *port.as_mut_ptr().offset(1 as libc::c_int as isize) as *mut libc::c_uint, + ) + { + break; + } + str = str.offset(1); + } + if *str == 0 + || ip[0 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint + || ip[1 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint + || ip[2 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint + || ip[3 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint + || port[0 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint + || port[1 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint + { + Curl_failf( + data, + b"Couldn't interpret the 227-response\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_WEIRD_227_FORMAT; + } + if ((*data).set).ftp_skip_ip() != 0 { + Curl_infof( + data, + b"Skip %u.%u.%u.%u for data connection, re-use %s instead\0" as *const u8 + as *const libc::c_char, + ip[0 as libc::c_int as usize], + ip[1 as libc::c_int as usize], + ip[2 as libc::c_int as usize], + ip[3 as libc::c_int as usize], + (*conn).host.name, + ); + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).newhost = Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); + + } + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).newhost = curl_dbg_strdup( + control_address(conn), + 1927 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + + + } else { + let ref mut fresh18 = (*ftpc).newhost; + *fresh18 = curl_maprintf( + b"%u.%u.%u.%u\0" as *const u8 as *const libc::c_char, + ip[0 as libc::c_int as usize], + ip[1 as libc::c_int as usize], + ip[2 as libc::c_int as usize], + ip[3 as libc::c_int as usize], + ); + } + if ((*ftpc).newhost).is_null() { + return CURLE_OUT_OF_MEMORY; + } + (*ftpc).newport = ((port[0 as libc::c_int as usize] << 8 as libc::c_int) + .wrapping_add(port[1 as libc::c_int as usize]) + & 0xffff as libc::c_int as libc::c_uint) as libc::c_ushort; + } else if (*ftpc).count1 == 0 as libc::c_int { + return ftp_epsv_disable(data, conn); + } else { + Curl_failf( + data, + b"Bad PASV/EPSV response: %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + return CURLE_FTP_WEIRD_PASV_REPLY; + } + match () { + #[cfg(not(CURL_DISABLE_PROXY))] + _ => { + if ((*conn).bits).proxy() != 0 { + let host_name: *const libc::c_char = if ((*conn).bits).socksproxy() as libc::c_int != 0 { + (*conn).socks_proxy.host.name + } else { + (*conn).http_proxy.host.name + }; + rc = Curl_resolv( + data, + host_name, + (*conn).port, + 0 as libc::c_int != 0, + &mut addr, + ); + if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { + Curl_resolver_wait_resolv(data, &mut addr); + } + connectport = (*conn).port as libc::c_ushort; + if addr.is_null() { + Curl_failf( + data, + b"Can't resolve proxy host %s:%hu\0" as *const u8 as *const libc::c_char, + host_name, + connectport as libc::c_int, + ); + return CURLE_COULDNT_RESOLVE_PROXY; + } + } else { + #[cfg(all(DEBUGBUILD, HAVE_ASSERT_H))] + if !((*ftpc).newhost).is_null() { + } else { + __assert_fail( + b"ftpc->newhost\0" as *const u8 as *const libc::c_char, + b"ftp.c\0" as *const u8 as *const libc::c_char, + 1973 as libc::c_int as libc::c_uint, + (*::std::mem::transmute::<&[u8; 54], &[libc::c_char; 54]>( + b"CURLcode ftp_state_pasv_resp(struct Curl_easy *, int)\0", + )) + .as_ptr(), + ); + } + if ((*conn).bits).tcp_fastopen() as libc::c_int != 0 + && ((*conn).bits).reuse() == 0 + && *((*ftpc).newhost).offset(0 as libc::c_int as isize) == 0 + { + Curl_conninfo_remote(data, conn, (*conn).sock[0 as libc::c_int as usize]); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).newhost as *mut libc::c_void, + 1978 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh19 = (*ftpc).newhost; + *fresh19 = 0 as *mut libc::c_char; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).newhost = Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); + } + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).newhost = curl_dbg_strdup( + control_address(conn), + 1979 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + + if ((*ftpc).newhost).is_null() { + return CURLE_OUT_OF_MEMORY; + } + } + rc = Curl_resolv( + data, + (*ftpc).newhost, + (*ftpc).newport as libc::c_int, + 0 as libc::c_int != 0, + &mut addr, + ); + if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { + Curl_resolver_wait_resolv(data, &mut addr); + } + connectport = (*ftpc).newport; + if addr.is_null() { + Curl_failf( + data, + b"Can't resolve new host %s:%hu\0" as *const u8 as *const libc::c_char, + (*ftpc).newhost, + connectport as libc::c_int, + ); + return CURLE_FTP_CANT_GET_HOST; + } + } + } + #[cfg(CURL_DISABLE_PROXY)] + _ => { + if ((*conn).bits).tcp_fastopen() as libc::c_int != 0 + && ((*conn).bits).reuse() == 0 + && *((*ftpc).newhost).offset(0 as libc::c_int as isize) == 0 + { + Curl_conninfo_remote(data, conn, (*conn).sock[0 as libc::c_int as usize]); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); + let ref mut fresh19 = (*ftpc).newhost; + *fresh19 = 0 as *mut libc::c_char; + let ref mut fresh20 = (*ftpc).newhost; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).newhost = Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); + } + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).newhost = curl_dbg_strdup( + control_address(conn), + 1979 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + if ((*ftpc).newhost).is_null() { + return CURLE_OUT_OF_MEMORY; + } + } + rc = Curl_resolv( + data, + (*ftpc).newhost, + (*ftpc).newport as libc::c_int, + 0 as libc::c_int != 0, + &mut addr, + ); + if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { + Curl_resolver_wait_resolv(data, &mut addr); + } + connectport = (*ftpc).newport; + if addr.is_null() { + Curl_failf( + data, + b"Can't resolve new host %s:%hu\0" as *const u8 as *const libc::c_char, + (*ftpc).newhost, + connectport as libc::c_int, + ); + return CURLE_FTP_CANT_GET_HOST; + } + } + } + (*conn).bits.tcpconnect[1 as libc::c_int as usize] = 0 as libc::c_int != 0; + result = Curl_connecthost(data, conn, addr); + if result as u64 != 0 { + Curl_resolv_unlock(data, addr); + if (*ftpc).count1 == 0 as libc::c_int && ftpcode == 229 as libc::c_int { + return ftp_epsv_disable(data, conn); + } + return result; + } + if ((*data).set).verbose() != 0 { + #[cfg(not(CURL_DISABLE_VERBOSE_STRINGS))] + ftp_pasv_verbose( + data, + (*addr).addr, + (*ftpc).newhost, + connectport as libc::c_int, + ); + } + Curl_resolv_unlock(data, addr); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*conn).secondaryhostname as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*conn).secondaryhostname as *mut libc::c_void, + 2021 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh21 = (*conn).secondaryhostname; + *fresh21 = 0 as *mut libc::c_char; + (*conn).secondary_port = (*ftpc).newport; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*conn).secondaryhostname = Curl_cstrdup.expect("non-null function pointer")((*ftpc).newhost); + + } + #[cfg(CURLDEBUG)] + _ => { + (*conn).secondaryhostname = curl_dbg_strdup( + (*ftpc).newhost, + 2023 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + } + + if ((*conn).secondaryhostname).is_null() { + return CURLE_OUT_OF_MEMORY; + } + let ref mut fresh23 = (*conn).bits; + (*fresh23).set_do_more(1 as libc::c_int as bit); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2028 as libc::c_int); + return result; + } + unsafe extern "C" fn ftp_state_port_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut fcmd: ftpport = (*ftpc).count1 as ftpport; + let mut result: CURLcode = CURLE_OK; + if ftpcode / 100 as libc::c_int != 2 as libc::c_int { + if EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { + Curl_infof( + data, + b"disabling EPRT usage\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh24 = (*conn).bits; + (*fresh24).set_ftp_use_eprt(0 as libc::c_int as bit); + } + fcmd += 1; + if fcmd as libc::c_uint == DONE as libc::c_int as libc::c_uint { + Curl_failf( + data, + b"Failed to do PORT\0" as *const u8 as *const libc::c_char, + ); + result = CURLE_FTP_PORT_FAILED; + } else { + result = ftp_state_use_port(data, fcmd); + } + } else { + Curl_infof( + data, + b"Connect data stream actively\0" as *const u8 as *const libc::c_char, + ); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); -// TODO in_addr_t类型的条件编译 - -#[inline] -unsafe extern "C" fn __bswap_16(mut __bsx: __uint16_t) -> __uint16_t { - return (__bsx as libc::c_int >> 8 as libc::c_int & 0xff as libc::c_int - | (__bsx as libc::c_int & 0xff as libc::c_int) << 8 as libc::c_int) - as __uint16_t; -} -#[no_mangle] -pub static mut Curl_handler_ftp: Curl_handler = unsafe { - { - let mut init = Curl_handler { - scheme: b"FTP\0" as *const u8 as *const libc::c_char, - setup_connection: Some( - ftp_setup_connection - as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata) -> CURLcode, - ), - do_it: Some(ftp_do as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode), - done: Some( - ftp_done as unsafe extern "C" fn(*mut Curl_easy, CURLcode, bool) -> CURLcode, - ), - do_more: Some( - ftp_do_more as unsafe extern "C" fn(*mut Curl_easy, *mut libc::c_int) -> CURLcode, - ), - connect_it: Some( - ftp_connect as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, - ), - connecting: Some( - ftp_multi_statemach as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, - ), - doing: Some(ftp_doing as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode), - proto_getsock: Some( - ftp_getsock - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut curl_socket_t, - ) -> libc::c_int, - ), - doing_getsock: Some( - ftp_getsock - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut curl_socket_t, - ) -> libc::c_int, - ), - domore_getsock: Some( - ftp_domore_getsock - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut curl_socket_t, - ) -> libc::c_int, - ), - perform_getsock: None, - disconnect: Some( - ftp_disconnect - as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata, bool) -> CURLcode, - ), - readwrite: None, - connection_check: None, - attach: None, - defport: 21 as libc::c_int, - protocol: ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_uint, - family: ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_uint, - flags: ((1 as libc::c_int) << 1 as libc::c_int - | (1 as libc::c_int) << 2 as libc::c_int - | (1 as libc::c_int) << 5 as libc::c_int - | (1 as libc::c_int) << 6 as libc::c_int - | (1 as libc::c_int) << 11 as libc::c_int - | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_uint, - }; - init - } -}; -#[cfg(USE_SSL)] -#[no_mangle] -pub static mut Curl_handler_ftps: Curl_handler = unsafe { - { - let mut init = Curl_handler { - scheme: b"FTPS\0" as *const u8 as *const libc::c_char, - setup_connection: Some( - ftp_setup_connection - as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata) -> CURLcode, - ), - do_it: Some( - ftp_do as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, - ), - done: Some( - ftp_done - as unsafe extern "C" fn(*mut Curl_easy, CURLcode, bool) -> CURLcode, - ), - do_more: Some( - ftp_do_more - as unsafe extern "C" fn(*mut Curl_easy, *mut libc::c_int) -> CURLcode, - ), - connect_it: Some( - ftp_connect - as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, - ), - connecting: Some( - ftp_multi_statemach - as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, - ), - doing: Some( - ftp_doing as unsafe extern "C" fn(*mut Curl_easy, *mut bool) -> CURLcode, - ), - proto_getsock: Some( - ftp_getsock - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut curl_socket_t, - ) -> libc::c_int, - ), - doing_getsock: Some( - ftp_getsock - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut curl_socket_t, - ) -> libc::c_int, - ), - domore_getsock: Some( - ftp_domore_getsock - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut curl_socket_t, - ) -> libc::c_int, - ), - perform_getsock: None, - disconnect: Some( - ftp_disconnect - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - bool, - ) -> CURLcode, - ), - readwrite: None, - connection_check: None, - attach: None, - defport: 990 as libc::c_int, - protocol: ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_uint, - family: ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_uint, - flags: ((1 as libc::c_int) << 0 as libc::c_int - | (1 as libc::c_int) << 1 as libc::c_int - | (1 as libc::c_int) << 2 as libc::c_int - | (1 as libc::c_int) << 5 as libc::c_int - | (1 as libc::c_int) << 6 as libc::c_int - | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_uint, - }; - init - } -}; -unsafe extern "C" fn close_secondarysocket(mut data: *mut Curl_easy, mut conn: *mut connectdata) { - if -(1 as libc::c_int) != (*conn).sock[1 as libc::c_int as usize] { - Curl_closesocket(data, conn, (*conn).sock[1 as libc::c_int as usize]); - (*conn).sock[1 as libc::c_int as usize] = -(1 as libc::c_int); - } - (*conn).bits.tcpconnect[1 as libc::c_int as usize] = 0 as libc::c_int != 0; - match() { - #[cfg(not(CURL_DISABLE_PROXY))] - _ => { - (*conn).bits.proxy_ssl_connected[1 as libc::c_int as usize] = 0 as libc::c_int != 0; - } - #[cfg(CURL_DISABLE_PROXY)] - _ => { } - } -} -unsafe extern "C" fn freedirs(mut ftpc: *mut ftp_conn) { - if !((*ftpc).dirs).is_null() { - let mut i: libc::c_int = 0; - i = 0 as libc::c_int; - while i < (*ftpc).dirdepth { - Curl_cfree.expect("non-null function pointer")( - *((*ftpc).dirs).offset(i as isize) as *mut libc::c_void - ); - let ref mut fresh0 = *((*ftpc).dirs).offset(i as isize); - *fresh0 = 0 as *mut libc::c_char; - i += 1; - } - Curl_cfree.expect("non-null function pointer")((*ftpc).dirs as *mut libc::c_void); - let ref mut fresh1 = (*ftpc).dirs; - *fresh1 = 0 as *mut *mut libc::c_char; - (*ftpc).dirdepth = 0 as libc::c_int; - } - Curl_cfree.expect("non-null function pointer")((*ftpc).file as *mut libc::c_void); - let ref mut fresh2 = (*ftpc).file; - *fresh2 = 0 as *mut libc::c_char; - Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); - let ref mut fresh3 = (*ftpc).newhost; - *fresh3 = 0 as *mut libc::c_char; -} -unsafe extern "C" fn AcceptServerConnect(mut data: *mut Curl_easy) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut sock: curl_socket_t = (*conn).sock[1 as libc::c_int as usize]; - let mut s: curl_socket_t = -(1 as libc::c_int); - #[cfg(ENABLE_IPV6)] - let mut add: Curl_sockaddr_storage = Curl_sockaddr_storage { - buffer: C2RustUnnamed_9 { - sa: sockaddr { - sa_family: 0, - sa_data: [0; 14], - }, - }, - }; - #[cfg(not(ENABLE_IPV6))] - let mut add: sockaddr_in = sockaddr_in { - sin_family: 0, - sin_port: 0, - sin_addr: in_addr { s_addr: 0 }, - sin_zero: [0; 8], - }; - #[cfg(ENABLE_IPV6)] - let mut size: curl_socklen_t = - ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; - #[cfg(not(ENABLE_IPV6))] - let mut size: curl_socklen_t = ::std::mem::size_of::() as libc::c_ulong - as curl_socklen_t; - #[cfg(ENABLE_IPV6)] - if 0 as libc::c_int - == getsockname( - sock, - &mut add as *mut Curl_sockaddr_storage as *mut sockaddr, - &mut size, - ) - { - size = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; - s = accept( - sock, - &mut add as *mut Curl_sockaddr_storage as *mut sockaddr, - &mut size, - ); - } - #[cfg(not(ENABLE_IPV6))] - if 0 as libc::c_int - == getsockname(sock, &mut add as *mut sockaddr_in as *mut sockaddr, &mut size) - { - size = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; - s = accept(sock, &mut add as *mut sockaddr_in as *mut sockaddr, &mut size); - } - Curl_closesocket(data, conn, sock); - if -(1 as libc::c_int) == s { - Curl_failf( - data, - b"Error accept()ing server connect\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_PORT_FAILED; - } - Curl_infof( - data, - b"Connection accepted from server\0" as *const u8 as *const libc::c_char, - ); - let ref mut fresh4 = (*conn).bits; - (*fresh4).set_do_more(0 as libc::c_int as bit); - (*conn).sock[1 as libc::c_int as usize] = s; - curlx_nonblock(s, 1 as libc::c_int); - let ref mut fresh5 = (*conn).bits; - (*fresh5).set_sock_accepted(1 as libc::c_int as bit); - if ((*data).set.fsockopt).is_some() { - let mut error: libc::c_int = 0 as libc::c_int; - Curl_set_in_callback(data, 1 as libc::c_int != 0); - error = ((*data).set.fsockopt).expect("non-null function pointer")( - (*data).set.sockopt_client, - s, - CURLSOCKTYPE_ACCEPT, - ); - Curl_set_in_callback(data, 0 as libc::c_int != 0); - if error != 0 { - close_secondarysocket(data, conn); - return CURLE_ABORTED_BY_CALLBACK; - } - } - return CURLE_OK; -} -unsafe extern "C" fn ftp_timeleft_accept(mut data: *mut Curl_easy) -> timediff_t { - let mut timeout_ms: timediff_t = 60000 as libc::c_int as timediff_t; - let mut other: timediff_t = 0; - let mut now: curltime = curltime { - tv_sec: 0, - tv_usec: 0, - }; - if (*data).set.accepttimeout > 0 as libc::c_int as libc::c_long { - timeout_ms = (*data).set.accepttimeout; - } - now = Curl_now(); - other = Curl_timeleft(data, &mut now, 0 as libc::c_int != 0); - if other != 0 && other < timeout_ms { - timeout_ms = other; - } else { - timeout_ms -= Curl_timediff(now, (*data).progress.t_acceptdata); - if timeout_ms == 0 { - return -(1 as libc::c_int) as timediff_t; - } - } - return timeout_ms; -} -unsafe extern "C" fn ReceivedServerConnect( - mut data: *mut Curl_easy, - mut received: *mut bool, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ctrl_sock: curl_socket_t = (*conn).sock[0 as libc::c_int as usize]; - let mut data_sock: curl_socket_t = (*conn).sock[1 as libc::c_int as usize]; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - let mut result: libc::c_int = 0; - let mut timeout_ms: timediff_t = 0; - let mut nread: ssize_t = 0; - let mut ftpcode: libc::c_int = 0; - *received = 0 as libc::c_int != 0; - timeout_ms = ftp_timeleft_accept(data); - Curl_infof( - data, - b"Checking for server connect\0" as *const u8 as *const libc::c_char, - ); - if timeout_ms < 0 as libc::c_int as libc::c_long { - Curl_failf( - data, - b"Accept timeout occurred while waiting server connect\0" as *const u8 - as *const libc::c_char, - ); - return CURLE_FTP_ACCEPT_TIMEOUT; - } - if (*pp).cache_size != 0 - && !((*pp).cache).is_null() - && *((*pp).cache).offset(0 as libc::c_int as isize) as libc::c_int > '3' as i32 - { - Curl_infof( - data, - b"There is negative response in cache while serv connect\0" as *const u8 - as *const libc::c_char, - ); - Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); - return CURLE_FTP_ACCEPT_FAILED; - } - result = Curl_socket_check( - ctrl_sock, - data_sock, - -(1 as libc::c_int), - 0 as libc::c_int as timediff_t, - ); - match result { - -1 => { - Curl_failf( - data, - b"Error while waiting for server connect\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_ACCEPT_FAILED; - } - 0 => {} - _ => { - if result & (0x4 as libc::c_int) << 1 as libc::c_int != 0 { - Curl_infof( - data, - b"Ready to accept data connection from server\0" as *const u8 - as *const libc::c_char, - ); - *received = 1 as libc::c_int != 0; - } else if result & 0x1 as libc::c_int != 0 { - Curl_infof( - data, - b"Ctrl conn has data while waiting for data conn\0" as *const u8 - as *const libc::c_char, - ); - Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); - if ftpcode / 100 as libc::c_int > 3 as libc::c_int { - return CURLE_FTP_ACCEPT_FAILED; - } - return CURLE_WEIRD_SERVER_REPLY; - } - } - } - return CURLE_OK; -} -unsafe extern "C" fn InitiateTransfer(mut data: *mut Curl_easy) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - if ((*conn).bits).ftp_use_data_ssl() != 0 { - Curl_infof( - data, - b"Doing the SSL/TLS handshake on the data stream\0" as *const u8 as *const libc::c_char, - ); - // match () { - // #[cfg(USE_SSL)] - // _ => { - // result = Curl_ssl_connect(data, conn, 1 as libc::c_int); - // } - // #[cfg(not(USE_SSL))] - // _ => { - // result = CURLE_NOT_BUILT_IN; - // } - // } - result = Curl_ssl_connect(data, conn, 1 as libc::c_int); - if result as u64 != 0 { - return result; - } - } - if (*conn).proto.ftpc.state_saved as libc::c_uint == FTP_STOR as libc::c_int as libc::c_uint { - Curl_pgrsSetUploadSize(data, (*data).state.infilesize); - Curl_setup_transfer( - data, - -(1 as libc::c_int), - -(1 as libc::c_int) as curl_off_t, - 0 as libc::c_int != 0, - 1 as libc::c_int, - ); - } else { - Curl_setup_transfer( - data, - 1 as libc::c_int, - (*conn).proto.ftpc.retr_size_saved, - 0 as libc::c_int != 0, - -(1 as libc::c_int), - ); - } - (*conn).proto.ftpc.pp.pending_resp = 1 as libc::c_int != 0; - _state(data, FTP_STOP); - return CURLE_OK; -} -unsafe extern "C" fn AllowServerConnect( - mut data: *mut Curl_easy, - mut connected: *mut bool, -) -> CURLcode { - let mut timeout_ms: timediff_t = 0; - let mut result: CURLcode = CURLE_OK; - *connected = 0 as libc::c_int != 0; - Curl_infof( - data, - b"Preparing for accepting server on data port\0" as *const u8 as *const libc::c_char, - ); - Curl_pgrsTime(data, TIMER_STARTACCEPT); - timeout_ms = ftp_timeleft_accept(data); - if timeout_ms < 0 as libc::c_int as libc::c_long { - Curl_failf( - data, - b"Accept timeout occurred while waiting server connect\0" as *const u8 - as *const libc::c_char, - ); - return CURLE_FTP_ACCEPT_TIMEOUT; - } - result = ReceivedServerConnect(data, connected); - if result as u64 != 0 { - return result; - } - if *connected { - result = AcceptServerConnect(data); - if result as u64 != 0 { - return result; - } - result = InitiateTransfer(data); - if result as u64 != 0 { - return result; - } - } else if *connected as libc::c_int == 0 as libc::c_int { - Curl_expire( - data, - if (*data).set.accepttimeout > 0 as libc::c_int as libc::c_long { - (*data).set.accepttimeout - } else { - 60000 as libc::c_int as libc::c_long - }, - EXPIRE_100_TIMEOUT, - ); - } - return result; -} -unsafe extern "C" fn ftp_endofresp( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut line: *mut libc::c_char, - mut len: size_t, - mut code: *mut libc::c_int, -) -> bool { - if len > 3 as libc::c_int as libc::c_ulong - && (Curl_isdigit(*line.offset(0 as libc::c_int as isize) as libc::c_uchar as libc::c_int) - != 0 - && Curl_isdigit(*line.offset(1 as libc::c_int as isize) as libc::c_uchar as libc::c_int) - != 0 - && Curl_isdigit(*line.offset(2 as libc::c_int as isize) as libc::c_uchar as libc::c_int) - != 0 - && ' ' as i32 == *line.offset(3 as libc::c_int as isize) as libc::c_int) - { - *code = curlx_sltosi(strtol(line, 0 as *mut *mut libc::c_char, 10 as libc::c_int)); - return 1 as libc::c_int != 0; - } - return 0 as libc::c_int != 0; -} -unsafe extern "C" fn ftp_readresp( - mut data: *mut Curl_easy, - mut sockfd: curl_socket_t, - mut pp: *mut pingpong, - mut ftpcode: *mut libc::c_int, - mut size: *mut size_t, -) -> CURLcode { - let mut code: libc::c_int = 0; - let mut result: CURLcode = Curl_pp_readresp(data, sockfd, pp, &mut code, size); - if cfg!(HAVE_GSSAPI) { - let mut conn: *mut connectdata = (*data).conn; - let buf: *mut libc::c_char = (*data).state.buffer; - match code { - 631 => { - code = Curl_sec_read_msg(data, conn, buf, PROT_SAFE); - } - 632 => { - code = Curl_sec_read_msg(data, conn, buf, PROT_PRIVATE); - } - 633 => { - code = Curl_sec_read_msg(data, conn, buf, PROT_CONFIDENTIAL); - } - _ => {} - } - } - (*data).info.httpcode = code; - if !ftpcode.is_null() { - *ftpcode = code; - } - if 421 as libc::c_int == code { - Curl_infof( - data, - b"We got a 421 - timeout!\0" as *const u8 as *const libc::c_char, - ); - _state(data, FTP_STOP); - return CURLE_OPERATION_TIMEDOUT; - } - return result; -} -#[no_mangle] -pub unsafe extern "C" fn Curl_GetFTPResponse( - mut data: *mut Curl_easy, - mut nreadp: *mut ssize_t, - mut ftpcode: *mut libc::c_int, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut sockfd: curl_socket_t = (*conn).sock[0 as libc::c_int as usize]; - let mut result: CURLcode = CURLE_OK; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - let mut nread: size_t = 0; - let mut cache_skip: libc::c_int = 0 as libc::c_int; - let mut value_to_be_ignored: libc::c_int = 0 as libc::c_int; - if !ftpcode.is_null() { - *ftpcode = 0 as libc::c_int; - } else { - ftpcode = &mut value_to_be_ignored; - } - *nreadp = 0 as libc::c_int as ssize_t; - let mut current_block_20: u64; - while *ftpcode == 0 && result as u64 == 0 { - let mut timeout: timediff_t = Curl_pp_state_timeout(data, pp, 0 as libc::c_int != 0); - let mut interval_ms: timediff_t = 0; - if timeout <= 0 as libc::c_int as libc::c_long { - Curl_failf( - data, - b"FTP response timeout\0" as *const u8 as *const libc::c_char, - ); - return CURLE_OPERATION_TIMEDOUT; - } - interval_ms = 1000 as libc::c_int as timediff_t; - if timeout < interval_ms { - interval_ms = timeout; - } - if !(!((*pp).cache).is_null() && cache_skip < 2 as libc::c_int) { - if !Curl_conn_data_pending(conn, 0 as libc::c_int) { - match Curl_socket_check( - sockfd, - -(1 as libc::c_int), - -(1 as libc::c_int), - interval_ms, - ) { - -1 => { - current_block_20 = 3097724707645237320; - match current_block_20 { - 3097724707645237320 => { - Curl_failf( - data, - b"FTP response aborted due to select/poll error: %d\0" - as *const u8 - as *const libc::c_char, - *__errno_location(), - ); - return CURLE_RECV_ERROR; - } - _ => { - if Curl_pgrsUpdate(data) != 0 { - return CURLE_ABORTED_BY_CALLBACK; - } - continue; - } - } - } - 0 => { - current_block_20 = 16982823512181177793; - match current_block_20 { - 3097724707645237320 => { - Curl_failf( - data, - b"FTP response aborted due to select/poll error: %d\0" - as *const u8 - as *const libc::c_char, - *__errno_location(), - ); - return CURLE_RECV_ERROR; - } - _ => { - if Curl_pgrsUpdate(data) != 0 { - return CURLE_ABORTED_BY_CALLBACK; - } - continue; - } - } - } - _ => {} - } - } - } - result = ftp_readresp(data, sockfd, pp, ftpcode, &mut nread); - if result as u64 != 0 { - break; - } - if nread == 0 && !((*pp).cache).is_null() { - cache_skip += 1; - } else { - cache_skip = 0 as libc::c_int; - } - *nreadp = (*nreadp as libc::c_ulong).wrapping_add(nread) as ssize_t as ssize_t; - } - (*pp).pending_resp = 0 as libc::c_int != 0; - return result; -} -unsafe extern "C" fn _state(mut data: *mut Curl_easy, mut newstate: ftpstate) { - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - (*ftpc).state = newstate; -} -unsafe extern "C" fn ftp_state_user( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = Curl_pp_sendf( - data, - &mut (*conn).proto.ftpc.pp as *mut pingpong, - b"USER %s\0" as *const u8 as *const libc::c_char, - if !((*conn).user).is_null() { - (*conn).user as *const libc::c_char - } else { - b"\0" as *const u8 as *const libc::c_char - }, - ); - if result as u64 == 0 { - _state(data, FTP_USER); - let ref mut fresh6 = (*data).state; - (*fresh6).set_ftp_trying_alternative(0 as libc::c_int as bit); - } - return result; -} -unsafe extern "C" fn ftp_state_pwd( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = Curl_pp_sendf( - data, - &mut (*conn).proto.ftpc.pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - b"PWD\0" as *const u8 as *const libc::c_char, - ); - if result as u64 == 0 { - _state(data, FTP_PWD); - } - return result; -} -unsafe extern "C" fn ftp_getsock( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut socks: *mut curl_socket_t, -) -> libc::c_int { - return Curl_pp_getsock(data, &mut (*conn).proto.ftpc.pp, socks); -} -unsafe extern "C" fn ftp_domore_getsock( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut socks: *mut curl_socket_t, -) -> libc::c_int { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if (*conn).cnnct.state as libc::c_uint >= CONNECT_SOCKS_INIT as libc::c_int as libc::c_uint - && ((*conn).cnnct.state as libc::c_uint) < CONNECT_DONE as libc::c_int as libc::c_uint - { - #[cfg(not(CURL_DISABLE_PROXY))] - return Curl_SOCKS_getsock(conn, socks, 1 as libc::c_int); - #[cfg(CURL_DISABLE_PROXY)] - return 0 as libc::c_int; - } - if FTP_STOP as libc::c_int as libc::c_uint == (*ftpc).state as libc::c_uint { - let mut bits: libc::c_int = (1 as libc::c_int) << 0 as libc::c_int; - let mut any: bool = 0 as libc::c_int != 0; - *socks.offset(0 as libc::c_int as isize) = (*conn).sock[0 as libc::c_int as usize]; - if ((*data).set).ftp_use_port() == 0 { - let mut s: libc::c_int = 0; - let mut i: libc::c_int = 0; - s = 1 as libc::c_int; - i = 0 as libc::c_int; - while i < 2 as libc::c_int { - if (*conn).tempsock[i as usize] != -(1 as libc::c_int) { - *socks.offset(s as isize) = (*conn).tempsock[i as usize]; - let fresh7 = s; - s = s + 1; - bits |= (1 as libc::c_int) << 16 as libc::c_int + fresh7; - any = 1 as libc::c_int != 0; - } - i += 1; - } - } - if !any { - *socks.offset(1 as libc::c_int as isize) = (*conn).sock[1 as libc::c_int as usize]; - bits |= (1 as libc::c_int) << 16 as libc::c_int + 1 as libc::c_int - | (1 as libc::c_int) << 1 as libc::c_int; - } - return bits; - } - return Curl_pp_getsock(data, &mut (*conn).proto.ftpc.pp, socks); -} -unsafe extern "C" fn ftp_state_cwd( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if (*ftpc).cwddone { - result = ftp_state_mdtm(data); - } else { - (*ftpc).count2 = 0 as libc::c_int; - (*ftpc).count3 = if (*data).set.ftp_create_missing_dirs == 2 as libc::c_int { - 1 as libc::c_int - } else { - 0 as libc::c_int - }; - if ((*conn).bits).reuse() as libc::c_int != 0 - && !((*ftpc).entrypath).is_null() - && !((*ftpc).dirdepth != 0 - && *(*((*ftpc).dirs).offset(0 as libc::c_int as isize)) - .offset(0 as libc::c_int as isize) as libc::c_int - == '/' as i32) - { - (*ftpc).cwdcount = 0 as libc::c_int; - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"CWD %s\0" as *const u8 as *const libc::c_char, - (*ftpc).entrypath, - ); - if result as u64 == 0 { - _state(data, FTP_CWD); - } - } else if (*ftpc).dirdepth != 0 { - (*ftpc).cwdcount = 1 as libc::c_int; - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"CWD %s\0" as *const u8 as *const libc::c_char, - *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), - ); - if result as u64 == 0 { - _state(data, FTP_CWD); - } - } else { - result = ftp_state_mdtm(data); - } - } - return result; -} -unsafe extern "C" fn ftp_state_use_port(mut data: *mut Curl_easy, mut fcmd: ftpport) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut portsock: curl_socket_t = -(1 as libc::c_int); - let mut myhost: [libc::c_char; 47] = *::std::mem::transmute::< - &[u8; 47], - &mut [libc::c_char; 47], - >( - b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", - ); - let mut ss: Curl_sockaddr_storage = Curl_sockaddr_storage { - buffer: C2RustUnnamed_9 { - sa: sockaddr { - sa_family: 0, - sa_data: [0; 14], - }, - }, - }; - let mut res: *mut Curl_addrinfo = 0 as *mut Curl_addrinfo; - let mut ai: *mut Curl_addrinfo = 0 as *mut Curl_addrinfo; - let mut sslen: curl_socklen_t = 0; - let mut hbuf: [libc::c_char; 1025] = [0; 1025]; - let mut sa: *mut sockaddr = &mut ss as *mut Curl_sockaddr_storage as *mut sockaddr; - let sa4: *mut sockaddr_in = sa as *mut libc::c_void as *mut sockaddr_in; - #[cfg(ENABLE_IPV6)] - let sa6: *mut sockaddr_in6 = sa as *mut libc::c_void as *mut sockaddr_in6; - static mut mode: [[libc::c_char; 5]; 2] = unsafe { - [ - *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"EPRT\0"), - *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"PORT\0"), - ] - }; - let mut rc: resolve_t = CURLRESOLV_RESOLVED; - let mut error: libc::c_int = 0; - let mut host: *mut libc::c_char = 0 as *mut libc::c_char; - let mut string_ftpport: *mut libc::c_char = - (*data).set.str_0[STRING_FTPPORT as libc::c_int as usize]; - let mut h: *mut Curl_dns_entry = 0 as *mut Curl_dns_entry; - let mut port_min: libc::c_ushort = 0 as libc::c_int as libc::c_ushort; - let mut port_max: libc::c_ushort = 0 as libc::c_int as libc::c_ushort; - let mut port: libc::c_ushort = 0; - let mut possibly_non_local: bool = 1 as libc::c_int != 0; - let mut buffer: [libc::c_char; 256] = [0; 256]; - let mut addr: *mut libc::c_char = 0 as *mut libc::c_char; - if !((*data).set.str_0[STRING_FTPPORT as libc::c_int as usize]).is_null() - && strlen((*data).set.str_0[STRING_FTPPORT as libc::c_int as usize]) - > 1 as libc::c_int as libc::c_ulong - { - #[cfg(ENABLE_IPV6)] - let mut addrlen: size_t = if 46 as libc::c_int as libc::c_ulong > strlen(string_ftpport) { - 46 as libc::c_int as libc::c_ulong - } else { - strlen(string_ftpport) - }; - #[cfg(not(ENABLE_IPV6))] - let mut addrlen: size_t = if 16 as libc::c_int as libc::c_ulong - > strlen(string_ftpport) - { - 16 as libc::c_int as libc::c_ulong - } else { - strlen(string_ftpport) - }; - let mut ip_start: *mut libc::c_char = string_ftpport; - let mut ip_end: *mut libc::c_char = 0 as *mut libc::c_char; - let mut port_start: *mut libc::c_char = 0 as *mut libc::c_char; - let mut port_sep: *mut libc::c_char = 0 as *mut libc::c_char; - addr = Curl_ccalloc.expect("non-null function pointer")( - addrlen.wrapping_add(1 as libc::c_int as libc::c_ulong), - 1 as libc::c_int as size_t, - ) as *mut libc::c_char; - if addr.is_null() { - return CURLE_OUT_OF_MEMORY; - } - let flag: bool = if cfg!(ENABLE_IPV6) { - *string_ftpport as libc::c_int == '[' as i32 - } else { - false - }; - if flag - { - ip_start = string_ftpport.offset(1 as libc::c_int as isize); - ip_end = strchr(string_ftpport, ']' as i32); - if !ip_end.is_null() { - strncpy( - addr, - ip_start, - ip_end.offset_from(ip_start) as libc::c_long as libc::c_ulong, - ); - } - } else if *string_ftpport as libc::c_int == ':' as i32 { - ip_end = string_ftpport; - } else { - ip_end = strchr(string_ftpport, ':' as i32); - if !ip_end.is_null() { - #[cfg(ENABLE_IPV6)] - if inet_pton(10 as libc::c_int, string_ftpport, sa6 as *mut libc::c_void) - == 1 as libc::c_int - { - port_max = 0 as libc::c_int as libc::c_ushort; - port_min = port_max; - strcpy(addr, string_ftpport); - ip_end = 0 as *mut libc::c_char; - } else { - strncpy( - addr, - string_ftpport, - ip_end.offset_from(ip_start) as libc::c_long as libc::c_ulong, - ); - } - #[cfg(not(ENABLE_IPV6))] - strncpy( - addr, - string_ftpport, - ip_end.offset_from(ip_start) as libc::c_long as libc::c_ulong, - ); - } else { - strcpy(addr, string_ftpport); - } - } - if !ip_end.is_null() { - port_start = strchr(ip_end, ':' as i32); - if !port_start.is_null() { - port_min = curlx_ultous(strtoul( - port_start.offset(1 as libc::c_int as isize), - 0 as *mut *mut libc::c_char, - 10 as libc::c_int, - )); - port_sep = strchr(port_start, '-' as i32); - if !port_sep.is_null() { - port_max = curlx_ultous(strtoul( - port_sep.offset(1 as libc::c_int as isize), - 0 as *mut *mut libc::c_char, - 10 as libc::c_int, - )); - } else { - port_max = port_min; - } - } - } - if port_min as libc::c_int > port_max as libc::c_int { - port_max = 0 as libc::c_int as libc::c_ushort; - port_min = port_max; - } - if *addr as libc::c_int != '\0' as i32 { - match Curl_if2ip( - (*(*conn).ip_addr).ai_family, - Curl_ipv6_scope((*(*conn).ip_addr).ai_addr), - (*conn).scope_id, - addr, - hbuf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 1025]>() as libc::c_ulong as libc::c_int, - ) as libc::c_uint - { - 0 => { - host = addr; - } - 1 => return CURLE_FTP_PORT_FAILED, - 2 => { - host = hbuf.as_mut_ptr(); - } - _ => {} - } - } else { - host = 0 as *mut libc::c_char; - } - } - if host.is_null() { - let mut r: *const libc::c_char = 0 as *const libc::c_char; - sslen = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; - if getsockname((*conn).sock[0 as libc::c_int as usize], sa, &mut sslen) != 0 { - Curl_failf( - data, - b"getsockname() failed: %s\0" as *const u8 as *const libc::c_char, - Curl_strerror( - *__errno_location(), - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - Curl_cfree.expect("non-null function pointer")(addr as *mut libc::c_void); - return CURLE_FTP_PORT_FAILED; - } - match (*sa).sa_family as libc::c_int { - #[cfg(ENABLE_IPV6)] - 10 => { - r = inet_ntop( - (*sa).sa_family as libc::c_int, - &mut (*sa6).sin6_addr as *mut in6_addr as *const libc::c_void, - hbuf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 1025]>() as libc::c_ulong - as curl_socklen_t, - ); - } - _ => { - r = inet_ntop( - (*sa).sa_family as libc::c_int, - &mut (*sa4).sin_addr as *mut in_addr as *const libc::c_void, - hbuf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 1025]>() as libc::c_ulong - as curl_socklen_t, - ); - } - } - if r.is_null() { - return CURLE_FTP_PORT_FAILED; - } - host = hbuf.as_mut_ptr(); - possibly_non_local = 0 as libc::c_int != 0; - } - rc = Curl_resolv(data, host, 0 as libc::c_int, 0 as libc::c_int != 0, &mut h); - if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { - Curl_resolver_wait_resolv(data, &mut h); - } - if !h.is_null() { - res = (*h).addr; - Curl_resolv_unlock(data, h); - } else { - res = 0 as *mut Curl_addrinfo; - } - if res.is_null() { - Curl_failf( - data, - b"failed to resolve the address provided to PORT: %s\0" as *const u8 - as *const libc::c_char, - host, - ); - Curl_cfree.expect("non-null function pointer")(addr as *mut libc::c_void); - return CURLE_FTP_PORT_FAILED; - } - Curl_cfree.expect("non-null function pointer")(addr as *mut libc::c_void); - host = 0 as *mut libc::c_char; - portsock = -(1 as libc::c_int); - error = 0 as libc::c_int; - ai = res; - while !ai.is_null() { - result = Curl_socket(data, ai, 0 as *mut Curl_sockaddr_ex, &mut portsock); - if !(result as u64 != 0) { - break; - } - error = *__errno_location(); - ai = (*ai).ai_next; - } - if ai.is_null() { - Curl_failf( - data, - b"socket failure: %s\0" as *const u8 as *const libc::c_char, - Curl_strerror( - error, - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - return CURLE_FTP_PORT_FAILED; - } - memcpy( - sa as *mut libc::c_void, - (*ai).ai_addr as *const libc::c_void, - (*ai).ai_addrlen as libc::c_ulong, - ); - sslen = (*ai).ai_addrlen; - port = port_min; - while port as libc::c_int <= port_max as libc::c_int { - if (*sa).sa_family as libc::c_int == 2 as libc::c_int { - (*sa4).sin_port = __bswap_16(port); - } else { - match () { - #[cfg(ENABLE_IPV6)] - _ => { - (*sa6).sin6_port = __bswap_16(port); - } - #[cfg(not(ENABLE_IPV6))] - _ => { } - } - } - if !(bind(portsock, sa, sslen) != 0) { - break; - } - error = *__errno_location(); - if possibly_non_local as libc::c_int != 0 && error == 99 as libc::c_int { - Curl_infof( - data, - b"bind(port=%hu) on non-local address failed: %s\0" as *const u8 - as *const libc::c_char, - port as libc::c_int, - Curl_strerror( - error, - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - sslen = - ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; - if getsockname((*conn).sock[0 as libc::c_int as usize], sa, &mut sslen) != 0 { - Curl_failf( - data, - b"getsockname() failed: %s\0" as *const u8 as *const libc::c_char, - Curl_strerror( - *__errno_location(), - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - Curl_closesocket(data, conn, portsock); - return CURLE_FTP_PORT_FAILED; - } - port = port_min; - possibly_non_local = 0 as libc::c_int != 0; - } else { - if error != 98 as libc::c_int && error != 13 as libc::c_int { - Curl_failf( - data, - b"bind(port=%hu) failed: %s\0" as *const u8 as *const libc::c_char, - port as libc::c_int, - Curl_strerror( - error, - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - Curl_closesocket(data, conn, portsock); - return CURLE_FTP_PORT_FAILED; - } - port = port.wrapping_add(1); - } - } - if port as libc::c_int > port_max as libc::c_int { - Curl_failf( - data, - b"bind() failed, we ran out of ports!\0" as *const u8 as *const libc::c_char, - ); - Curl_closesocket(data, conn, portsock); - return CURLE_FTP_PORT_FAILED; - } - sslen = ::std::mem::size_of::() as libc::c_ulong as curl_socklen_t; - if getsockname(portsock, sa, &mut sslen) != 0 { - Curl_failf( - data, - b"getsockname() failed: %s\0" as *const u8 as *const libc::c_char, - Curl_strerror( - *__errno_location(), - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - Curl_closesocket(data, conn, portsock); - return CURLE_FTP_PORT_FAILED; - } - if listen(portsock, 1 as libc::c_int) != 0 { - Curl_failf( - data, - b"socket failure: %s\0" as *const u8 as *const libc::c_char, - Curl_strerror( - *__errno_location(), - buffer.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ), - ); - Curl_closesocket(data, conn, portsock); - return CURLE_FTP_PORT_FAILED; - } - Curl_printable_address( - ai, - myhost.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 47]>() as libc::c_ulong, - ); - #[cfg(ENABLE_IPV6)] - if ((*conn).bits).ftp_use_eprt() == 0 && ((*conn).bits).ipv6() as libc::c_int != 0 { - let ref mut fresh8 = (*conn).bits; - (*fresh8).set_ftp_use_eprt(1 as libc::c_int as bit); - } - while fcmd as libc::c_uint != DONE as libc::c_int as libc::c_uint { - if !(((*conn).bits).ftp_use_eprt() == 0 - && EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint) - { - if !(PORT as libc::c_int as libc::c_uint == fcmd as libc::c_uint - && (*sa).sa_family as libc::c_int != 2 as libc::c_int) - { - match (*sa).sa_family as libc::c_int { - 2 => { - port = __bswap_16((*sa4).sin_port); - if EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s |%d|%s|%hu|\0" as *const u8 as *const libc::c_char, - (mode[fcmd as usize]).as_ptr(), - if (*sa).sa_family as libc::c_int == 2 as libc::c_int { - 1 as libc::c_int - } else { - 2 as libc::c_int - }, - myhost.as_mut_ptr(), - port as libc::c_int, - ); - if result as u64 != 0 { - Curl_failf( - data, - b"Failure sending EPRT command: %s\0" as *const u8 - as *const libc::c_char, - curl_easy_strerror(result), - ); - Curl_closesocket(data, conn, portsock); - (*ftpc).count1 = PORT as libc::c_int; - _state(data, FTP_STOP); - return result; - } - break; - } else if PORT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { - let mut target: [libc::c_char; 67] = [0; 67]; - let mut source: *mut libc::c_char = myhost.as_mut_ptr(); - let mut dest: *mut libc::c_char = target.as_mut_ptr(); - while !source.is_null() && *source as libc::c_int != 0 { - if *source as libc::c_int == '.' as i32 { - *dest = ',' as i32 as libc::c_char; - } else { - *dest = *source; - } - dest = dest.offset(1); - source = source.offset(1); - } - *dest = 0 as libc::c_int as libc::c_char; - curl_msnprintf( - dest, - 20 as libc::c_int as size_t, - b",%d,%d\0" as *const u8 as *const libc::c_char, - port as libc::c_int >> 8 as libc::c_int, - port as libc::c_int & 0xff as libc::c_int, - ); - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s %s\0" as *const u8 as *const libc::c_char, - (mode[fcmd as usize]).as_ptr(), - target.as_mut_ptr(), - ); - if result as u64 != 0 { - Curl_failf( - data, - b"Failure sending PORT command: %s\0" as *const u8 - as *const libc::c_char, - curl_easy_strerror(result), - ); - Curl_closesocket(data, conn, portsock); - _state(data, FTP_STOP); - return result; - } - break; - } - } - #[cfg(ENABLE_IPV6)] - 10 => { - port = __bswap_16((*sa6).sin6_port); - if EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s |%d|%s|%hu|\0" as *const u8 as *const libc::c_char, - (mode[fcmd as usize]).as_ptr(), - if (*sa).sa_family as libc::c_int == 2 as libc::c_int { - 1 as libc::c_int - } else { - 2 as libc::c_int - }, - myhost.as_mut_ptr(), - port as libc::c_int, - ); - if result as u64 != 0 { - Curl_failf( - data, - b"Failure sending EPRT command: %s\0" as *const u8 - as *const libc::c_char, - curl_easy_strerror(result), - ); - Curl_closesocket(data, conn, portsock); - (*ftpc).count1 = PORT as libc::c_int; - _state(data, FTP_STOP); - return result; - } - break; - } else if PORT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { - let mut target: [libc::c_char; 67] = [0; 67]; - let mut source: *mut libc::c_char = myhost.as_mut_ptr(); - let mut dest: *mut libc::c_char = target.as_mut_ptr(); - while !source.is_null() && *source as libc::c_int != 0 { - if *source as libc::c_int == '.' as i32 { - *dest = ',' as i32 as libc::c_char; - } else { - *dest = *source; - } - dest = dest.offset(1); - source = source.offset(1); - } - *dest = 0 as libc::c_int as libc::c_char; - curl_msnprintf( - dest, - 20 as libc::c_int as size_t, - b",%d,%d\0" as *const u8 as *const libc::c_char, - port as libc::c_int >> 8 as libc::c_int, - port as libc::c_int & 0xff as libc::c_int, - ); - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s %s\0" as *const u8 as *const libc::c_char, - (mode[fcmd as usize]).as_ptr(), - target.as_mut_ptr(), - ); - if result as u64 != 0 { - Curl_failf( - data, - b"Failure sending PORT command: %s\0" as *const u8 - as *const libc::c_char, - curl_easy_strerror(result), - ); - Curl_closesocket(data, conn, portsock); - _state(data, FTP_STOP); - return result; - } - break; - } - } - _ => {} - } - } - } - fcmd += 1; - } - (*ftpc).count1 = fcmd as libc::c_int; - close_secondarysocket(data, conn); - (*conn).sock[1 as libc::c_int as usize] = portsock; - (*conn).bits.tcpconnect[1 as libc::c_int as usize] = 1 as libc::c_int != 0; - _state(data, FTP_PORT); - return result; -} -unsafe extern "C" fn ftp_state_use_pasv( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut result: CURLcode = CURLE_OK; - static mut mode: [[libc::c_char; 5]; 2] = unsafe { - [ - *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"EPSV\0"), - *::std::mem::transmute::<&[u8; 5], &[libc::c_char; 5]>(b"PASV\0"), - ] - }; - let mut modeoff: libc::c_int = 0; - #[cfg(PF_INET6)] - if ((*conn).bits).ftp_use_epsv() == 0 && ((*conn).bits).ipv6() as libc::c_int != 0 { - let ref mut fresh9 = (*conn).bits; - (*fresh9).set_ftp_use_epsv(1 as libc::c_int as bit); - } - modeoff = if ((*conn).bits).ftp_use_epsv() as libc::c_int != 0 { - 0 as libc::c_int - } else { - 1 as libc::c_int - }; - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - (mode[modeoff as usize]).as_ptr(), - ); - if result as u64 == 0 { - (*ftpc).count1 = modeoff; - _state(data, FTP_PASV); - Curl_infof( - data, - b"Connect data stream passively\0" as *const u8 as *const libc::c_char, - ); - } - return result; -} -unsafe extern "C" fn ftp_state_prepare_transfer(mut data: *mut Curl_easy) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint { - _state(data, FTP_RETR_PREQUOTE); - result = ftp_state_quote(data, 1 as libc::c_int != 0, FTP_RETR_PREQUOTE); - } else if ((*data).set).ftp_use_port() != 0 { - result = ftp_state_use_port(data, EPRT); - } else if ((*data).set).ftp_use_pret() != 0 { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if ((*conn).proto.ftpc.file).is_null() { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"PRET %s\0" as *const u8 as *const libc::c_char, - if !((*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize]).is_null() { - (*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize] - as *const libc::c_char - } else if ((*data).state).list_only() as libc::c_int != 0 { - b"NLST\0" as *const u8 as *const libc::c_char - } else { - b"LIST\0" as *const u8 as *const libc::c_char - }, - ); - } else if ((*data).set).upload() != 0 { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"PRET STOR %s\0" as *const u8 as *const libc::c_char, - (*conn).proto.ftpc.file, - ); - } else { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"PRET RETR %s\0" as *const u8 as *const libc::c_char, - (*conn).proto.ftpc.file, - ); - } - if result as u64 == 0 { - _state(data, FTP_PRET); - } - } else { - result = ftp_state_use_pasv(data, conn); - } - return result; -} -unsafe extern "C" fn ftp_state_rest( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint - && !((*ftpc).file).is_null() - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"REST %d\0" as *const u8 as *const libc::c_char, - 0 as libc::c_int, - ); - if result as u64 == 0 { - _state(data, FTP_REST); - } - } else { - result = ftp_state_prepare_transfer(data); - } - return result; -} -unsafe extern "C" fn ftp_state_size( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if (*ftp).transfer as libc::c_uint == PPTRANSFER_INFO as libc::c_int as libc::c_uint - && !((*ftpc).file).is_null() - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"SIZE %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { - _state(data, FTP_SIZE); - } - } else { - result = ftp_state_rest(data, conn); - } - return result; -} -unsafe extern "C" fn ftp_state_list(mut data: *mut Curl_easy) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - let mut lstArg: *mut libc::c_char = 0 as *mut libc::c_char; - let mut cmd: *mut libc::c_char = 0 as *mut libc::c_char; - if (*data).set.ftp_filemethod as libc::c_uint == FTPFILE_NOCWD as libc::c_int as libc::c_uint - && !((*ftp).path).is_null() - { - let mut slashPos: *const libc::c_char = 0 as *const libc::c_char; - let mut rawPath: *mut libc::c_char = 0 as *mut libc::c_char; - result = Curl_urldecode( - data, - (*ftp).path, - 0 as libc::c_int as size_t, - &mut rawPath, - 0 as *mut size_t, - REJECT_CTRL, - ); - if result as u64 != 0 { - return result; - } - slashPos = strrchr(rawPath, '/' as i32); - if !slashPos.is_null() { - let mut n: size_t = slashPos.offset_from(rawPath) as libc::c_long as size_t; - if n == 0 as libc::c_int as libc::c_ulong { - n = n.wrapping_add(1); - } - lstArg = rawPath; - *lstArg.offset(n as isize) = '\0' as i32 as libc::c_char; - } else { - Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - } - } - cmd = curl_maprintf( - b"%s%s%s\0" as *const u8 as *const libc::c_char, - if !((*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize]).is_null() { - (*data).set.str_0[STRING_CUSTOMREQUEST as libc::c_int as usize] as *const libc::c_char - } else if ((*data).state).list_only() as libc::c_int != 0 { - b"NLST\0" as *const u8 as *const libc::c_char - } else { - b"LIST\0" as *const u8 as *const libc::c_char - }, - if !lstArg.is_null() { - b" \0" as *const u8 as *const libc::c_char - } else { - b"\0" as *const u8 as *const libc::c_char - }, - if !lstArg.is_null() { - lstArg as *const libc::c_char - } else { - b"\0" as *const u8 as *const libc::c_char - }, - ); - Curl_cfree.expect("non-null function pointer")(lstArg as *mut libc::c_void); - if cmd.is_null() { - return CURLE_OUT_OF_MEMORY; - } - result = Curl_pp_sendf( - data, - &mut (*conn).proto.ftpc.pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - cmd, - ); - Curl_cfree.expect("non-null function pointer")(cmd as *mut libc::c_void); - if result as u64 == 0 { - _state(data, FTP_LIST); - } - return result; -} -unsafe extern "C" fn ftp_state_retr_prequote(mut data: *mut Curl_easy) -> CURLcode { - return ftp_state_quote(data, 1 as libc::c_int != 0, FTP_RETR_PREQUOTE); -} -unsafe extern "C" fn ftp_state_stor_prequote(mut data: *mut Curl_easy) -> CURLcode { - return ftp_state_quote(data, 1 as libc::c_int != 0, FTP_STOR_PREQUOTE); -} -unsafe extern "C" fn ftp_state_type(mut data: *mut Curl_easy) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if ((*data).set).opt_no_body() as libc::c_int != 0 - && !((*ftpc).file).is_null() - && ftp_need_type(conn, ((*data).state).prefer_ascii() != 0) != 0 - { - (*ftp).transfer = PPTRANSFER_INFO; - result = ftp_nb_type(data, conn, ((*data).state).prefer_ascii() != 0, FTP_TYPE); - if result as u64 != 0 { - return result; - } - } else { - result = ftp_state_size(data, conn); - } - return result; -} -unsafe extern "C" fn ftp_state_mdtm(mut data: *mut Curl_easy) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if (((*data).set).get_filetime() as libc::c_int != 0 - || (*data).set.timecondition as libc::c_uint != 0) - && !((*ftpc).file).is_null() - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"MDTM %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { - _state(data, FTP_MDTM); - } - } else { - result = ftp_state_type(data); - } - return result; -} -unsafe extern "C" fn ftp_state_ul_setup( - mut data: *mut Curl_easy, - mut sizechecked: bool, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut append: bool = ((*data).set).remote_append() != 0; - if (*data).state.resume_from != 0 && !sizechecked - || (*data).state.resume_from > 0 as libc::c_int as libc::c_long - && sizechecked as libc::c_int != 0 - { - let mut seekerr: libc::c_int = 0 as libc::c_int; - if (*data).state.resume_from < 0 as libc::c_int as libc::c_long { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"SIZE %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { - _state(data, FTP_STOR_SIZE); - } - return result; - } - append = 1 as libc::c_int != 0; - if ((*conn).seek_func).is_some() { - Curl_set_in_callback(data, 1 as libc::c_int != 0); - seekerr = ((*conn).seek_func).expect("non-null function pointer")( - (*conn).seek_client, - (*data).state.resume_from, - 0 as libc::c_int, - ); - Curl_set_in_callback(data, 0 as libc::c_int != 0); - } - if seekerr != 0 as libc::c_int { - let mut passed: curl_off_t = 0 as libc::c_int as curl_off_t; - if seekerr != 2 as libc::c_int { - Curl_failf( - data, - b"Could not seek stream\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_COULDNT_USE_REST; - } - loop { - let mut readthisamountnow: size_t = - if (*data).state.resume_from - passed > (*data).set.buffer_size { - (*data).set.buffer_size as size_t - } else { - curlx_sotouz((*data).state.resume_from - passed) - }; - let mut actuallyread: size_t = ((*data).state.fread_func) - .expect("non-null function pointer")( - (*data).state.buffer, - 1 as libc::c_int as size_t, - readthisamountnow, - (*data).state.in_0, - ); - passed = (passed as libc::c_ulong).wrapping_add(actuallyread) as curl_off_t - as curl_off_t; - if actuallyread == 0 as libc::c_int as libc::c_ulong - || actuallyread > readthisamountnow - { - Curl_failf( - data, - b"Failed to read data\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_COULDNT_USE_REST; - } - if !(passed < (*data).state.resume_from) { - break; - } - } - } - if (*data).state.infilesize > 0 as libc::c_int as libc::c_long { - let ref mut fresh10 = (*data).state.infilesize; - *fresh10 -= (*data).state.resume_from; - if (*data).state.infilesize <= 0 as libc::c_int as libc::c_long { - Curl_infof( - data, - b"File already completely uploaded\0" as *const u8 as *const libc::c_char, - ); - Curl_setup_transfer( - data, - -(1 as libc::c_int), - -(1 as libc::c_int) as curl_off_t, - 0 as libc::c_int != 0, - -(1 as libc::c_int), - ); - (*ftp).transfer = PPTRANSFER_NONE; - _state(data, FTP_STOP); - return CURLE_OK; - } - } - } - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - if append as libc::c_int != 0 { - b"APPE %s\0" as *const u8 as *const libc::c_char - } else { - b"STOR %s\0" as *const u8 as *const libc::c_char - }, - (*ftpc).file, - ); - if result as u64 == 0 { - _state(data, FTP_STOR); - } - return result; -} -unsafe extern "C" fn ftp_state_quote( - mut data: *mut Curl_easy, - mut init: bool, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut quote: bool = 0 as libc::c_int != 0; - let mut item: *mut curl_slist = 0 as *mut curl_slist; - match instate as libc::c_uint { - 13 | 14 => { - item = (*data).set.prequote; - } - 15 => { - item = (*data).set.postquote; - } - 12 | _ => { - item = (*data).set.quote; - } - } - if init { - (*ftpc).count1 = 0 as libc::c_int; - } else { - let ref mut fresh11 = (*ftpc).count1; - *fresh11 += 1; - } - if !item.is_null() { - let mut i: libc::c_int = 0 as libc::c_int; - while i < (*ftpc).count1 && !item.is_null() { - item = (*item).next; - i += 1; - } - if !item.is_null() { - let mut cmd: *mut libc::c_char = (*item).data; - if *cmd.offset(0 as libc::c_int as isize) as libc::c_int == '*' as i32 { - cmd = cmd.offset(1); - (*ftpc).count2 = 1 as libc::c_int; - } else { - (*ftpc).count2 = 0 as libc::c_int; - } - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - cmd, - ); - if result as u64 != 0 { - return result; - } - _state(data, instate); - quote = 1 as libc::c_int != 0; - } - } - if !quote { - match instate as libc::c_uint { - 13 => { - if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint - { - _state(data, FTP_STOP); - } else if (*ftpc).known_filesize != -(1 as libc::c_int) as libc::c_long { - Curl_pgrsSetDownloadSize(data, (*ftpc).known_filesize); - result = ftp_state_retr(data, (*ftpc).known_filesize); - } else if ((*data).set).ignorecl() as libc::c_int != 0 - || ((*data).state).prefer_ascii() as libc::c_int != 0 - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"RETR %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { - _state(data, FTP_RETR); - } - } else { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"SIZE %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { - _state(data, FTP_RETR_SIZE); - } - } - } - 14 => { - result = ftp_state_ul_setup(data, 0 as libc::c_int != 0); - } - 15 => {} - 12 | _ => { - result = ftp_state_cwd(data, conn); - } - } - } - return result; -} -unsafe extern "C" fn ftp_epsv_disable( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - // TODO 待验证 - #[cfg(not(CURL_DISABLE_PROXY))] - let flag: bool = ((*conn).bits).ipv6() as libc::c_int != 0 - && !(((*conn).bits).tunnel_proxy() as libc::c_int != 0 - || ((*conn).bits).socksproxy() as libc::c_int != 0); - #[cfg(CURL_DISABLE_PROXY)] - let flag: bool = ((*conn).bits).ipv6() as libc::c_int != 0; - if flag - { - Curl_failf( - data, - b"Failed EPSV attempt, exiting\0" as *const u8 as *const libc::c_char, - ); - return CURLE_WEIRD_SERVER_REPLY; - } - Curl_infof( - data, - b"Failed EPSV attempt. Disabling EPSV\0" as *const u8 as *const libc::c_char, - ); - let ref mut fresh12 = (*conn).bits; - (*fresh12).set_ftp_use_epsv(0 as libc::c_int as bit); - let ref mut fresh13 = (*data).state; - (*fresh13).set_errorbuf(0 as libc::c_int as bit); - result = Curl_pp_sendf( - data, - &mut (*conn).proto.ftpc.pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - b"PASV\0" as *const u8 as *const libc::c_char, - ); - if result as u64 == 0 { - let ref mut fresh14 = (*conn).proto.ftpc.count1; - *fresh14 += 1; - _state(data, FTP_PASV); - } - return result; -} -unsafe extern "C" fn control_address(mut conn: *mut connectdata) -> *mut libc::c_char { - #[cfg(not(CURL_DISABLE_PROXY))] - if ((*conn).bits).tunnel_proxy() as libc::c_int != 0 - || ((*conn).bits).socksproxy() as libc::c_int != 0 - { - return (*conn).host.name; - } - return ((*conn).primary_ip).as_mut_ptr(); -} -unsafe extern "C" fn ftp_state_pasv_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut result: CURLcode = CURLE_OK; - let mut addr: *mut Curl_dns_entry = 0 as *mut Curl_dns_entry; - let mut rc: resolve_t = CURLRESOLV_RESOLVED; - let mut connectport: libc::c_ushort = 0; - let mut str: *mut libc::c_char = - &mut *((*data).state.buffer).offset(4 as libc::c_int as isize) as *mut libc::c_char; - Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); - let ref mut fresh15 = (*ftpc).newhost; - *fresh15 = 0 as *mut libc::c_char; - if (*ftpc).count1 == 0 as libc::c_int && ftpcode == 229 as libc::c_int { - let mut ptr: *mut libc::c_char = strchr(str, '(' as i32); - if !ptr.is_null() { - let mut num: libc::c_uint = 0; - let mut separator: [libc::c_char; 4] = [0; 4]; - ptr = ptr.offset(1); - if 5 as libc::c_int - == sscanf( - ptr, - b"%c%c%c%u%c\0" as *const u8 as *const libc::c_char, - &mut *separator.as_mut_ptr().offset(0 as libc::c_int as isize) - as *mut libc::c_char, - &mut *separator.as_mut_ptr().offset(1 as libc::c_int as isize) - as *mut libc::c_char, - &mut *separator.as_mut_ptr().offset(2 as libc::c_int as isize) - as *mut libc::c_char, - &mut num as *mut libc::c_uint, - &mut *separator.as_mut_ptr().offset(3 as libc::c_int as isize) - as *mut libc::c_char, - ) - { - let sep1: libc::c_char = separator[0 as libc::c_int as usize]; - let mut i: libc::c_int = 0; - i = 1 as libc::c_int; - while i < 4 as libc::c_int { - if separator[i as usize] as libc::c_int != sep1 as libc::c_int { - ptr = 0 as *mut libc::c_char; - break; - } else { - i += 1; - } - } - if num > 0xffff as libc::c_int as libc::c_uint { - Curl_failf( - data, - b"Illegal port number in EPSV reply\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_WEIRD_PASV_REPLY; - } - if !ptr.is_null() { - (*ftpc).newport = - (num & 0xffff as libc::c_int as libc::c_uint) as libc::c_ushort; - let ref mut fresh16 = (*ftpc).newhost; - *fresh16 = - Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); - if ((*ftpc).newhost).is_null() { - return CURLE_OUT_OF_MEMORY; - } - } - } else { - ptr = 0 as *mut libc::c_char; - } - } - if ptr.is_null() { - Curl_failf( - data, - b"Weirdly formatted EPSV reply\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_WEIRD_PASV_REPLY; - } - } else if (*ftpc).count1 == 1 as libc::c_int && ftpcode == 227 as libc::c_int { - let mut ip: [libc::c_uint; 4] = [ - 0 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; - let mut port: [libc::c_uint; 2] = [ - 0 as libc::c_int as libc::c_uint, - 0 as libc::c_int as libc::c_uint, - ]; - while *str != 0 { - if 6 as libc::c_int - == sscanf( - str, - b"%u,%u,%u,%u,%u,%u\0" as *const u8 as *const libc::c_char, - &mut *ip.as_mut_ptr().offset(0 as libc::c_int as isize) as *mut libc::c_uint, - &mut *ip.as_mut_ptr().offset(1 as libc::c_int as isize) as *mut libc::c_uint, - &mut *ip.as_mut_ptr().offset(2 as libc::c_int as isize) as *mut libc::c_uint, - &mut *ip.as_mut_ptr().offset(3 as libc::c_int as isize) as *mut libc::c_uint, - &mut *port.as_mut_ptr().offset(0 as libc::c_int as isize) as *mut libc::c_uint, - &mut *port.as_mut_ptr().offset(1 as libc::c_int as isize) as *mut libc::c_uint, - ) - { - break; - } - str = str.offset(1); - } - if *str == 0 - || ip[0 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint - || ip[1 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint - || ip[2 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint - || ip[3 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint - || port[0 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint - || port[1 as libc::c_int as usize] > 255 as libc::c_int as libc::c_uint - { - Curl_failf( - data, - b"Couldn't interpret the 227-response\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_WEIRD_227_FORMAT; - } - if ((*data).set).ftp_skip_ip() != 0 { - Curl_infof( - data, - b"Skip %u.%u.%u.%u for data connection, re-use %s instead\0" as *const u8 - as *const libc::c_char, - ip[0 as libc::c_int as usize], - ip[1 as libc::c_int as usize], - ip[2 as libc::c_int as usize], - ip[3 as libc::c_int as usize], - (*conn).host.name, - ); - let ref mut fresh17 = (*ftpc).newhost; - *fresh17 = Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); - } else { - let ref mut fresh18 = (*ftpc).newhost; - *fresh18 = curl_maprintf( - b"%u.%u.%u.%u\0" as *const u8 as *const libc::c_char, - ip[0 as libc::c_int as usize], - ip[1 as libc::c_int as usize], - ip[2 as libc::c_int as usize], - ip[3 as libc::c_int as usize], - ); - } - if ((*ftpc).newhost).is_null() { - return CURLE_OUT_OF_MEMORY; - } - (*ftpc).newport = ((port[0 as libc::c_int as usize] << 8 as libc::c_int) - .wrapping_add(port[1 as libc::c_int as usize]) - & 0xffff as libc::c_int as libc::c_uint) as libc::c_ushort; - } else if (*ftpc).count1 == 0 as libc::c_int { - return ftp_epsv_disable(data, conn); - } else { - Curl_failf( - data, - b"Bad PASV/EPSV response: %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - return CURLE_FTP_WEIRD_PASV_REPLY; - } - match () { - #[cfg(not(CURL_DISABLE_PROXY))] - _ => { - if ((*conn).bits).proxy() != 0 { - let host_name: *const libc::c_char = if ((*conn).bits).socksproxy() as libc::c_int != 0 { - (*conn).socks_proxy.host.name - } else { - (*conn).http_proxy.host.name - }; - rc = Curl_resolv( - data, - host_name, - (*conn).port, - 0 as libc::c_int != 0, - &mut addr, - ); - if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { - Curl_resolver_wait_resolv(data, &mut addr); - } - connectport = (*conn).port as libc::c_ushort; - if addr.is_null() { - Curl_failf( - data, - b"Can't resolve proxy host %s:%hu\0" as *const u8 as *const libc::c_char, - host_name, - connectport as libc::c_int, - ); - return CURLE_COULDNT_RESOLVE_PROXY; - } - } else { - if ((*conn).bits).tcp_fastopen() as libc::c_int != 0 - && ((*conn).bits).reuse() == 0 - && *((*ftpc).newhost).offset(0 as libc::c_int as isize) == 0 - { - Curl_conninfo_remote(data, conn, (*conn).sock[0 as libc::c_int as usize]); - Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); - let ref mut fresh19 = (*ftpc).newhost; - *fresh19 = 0 as *mut libc::c_char; - let ref mut fresh20 = (*ftpc).newhost; - *fresh20 = Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); - if ((*ftpc).newhost).is_null() { - return CURLE_OUT_OF_MEMORY; - } - } - rc = Curl_resolv( - data, - (*ftpc).newhost, - (*ftpc).newport as libc::c_int, - 0 as libc::c_int != 0, - &mut addr, - ); - if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { - Curl_resolver_wait_resolv(data, &mut addr); - } - connectport = (*ftpc).newport; - if addr.is_null() { - Curl_failf( - data, - b"Can't resolve new host %s:%hu\0" as *const u8 as *const libc::c_char, - (*ftpc).newhost, - connectport as libc::c_int, - ); - return CURLE_FTP_CANT_GET_HOST; - } - } - } - #[cfg(CURL_DISABLE_PROXY)] - _ => { - if ((*conn).bits).tcp_fastopen() as libc::c_int != 0 - && ((*conn).bits).reuse() == 0 - && *((*ftpc).newhost).offset(0 as libc::c_int as isize) == 0 - { - Curl_conninfo_remote(data, conn, (*conn).sock[0 as libc::c_int as usize]); - Curl_cfree.expect("non-null function pointer")((*ftpc).newhost as *mut libc::c_void); - let ref mut fresh19 = (*ftpc).newhost; - *fresh19 = 0 as *mut libc::c_char; - let ref mut fresh20 = (*ftpc).newhost; - *fresh20 = Curl_cstrdup.expect("non-null function pointer")(control_address(conn)); - if ((*ftpc).newhost).is_null() { - return CURLE_OUT_OF_MEMORY; - } - } - rc = Curl_resolv( - data, - (*ftpc).newhost, - (*ftpc).newport as libc::c_int, - 0 as libc::c_int != 0, - &mut addr, - ); - if rc as libc::c_int == CURLRESOLV_PENDING as libc::c_int { - Curl_resolver_wait_resolv(data, &mut addr); - } - connectport = (*ftpc).newport; - if addr.is_null() { - Curl_failf( - data, - b"Can't resolve new host %s:%hu\0" as *const u8 as *const libc::c_char, - (*ftpc).newhost, - connectport as libc::c_int, - ); - return CURLE_FTP_CANT_GET_HOST; - } - } - } - (*conn).bits.tcpconnect[1 as libc::c_int as usize] = 0 as libc::c_int != 0; - result = Curl_connecthost(data, conn, addr); - if result as u64 != 0 { - Curl_resolv_unlock(data, addr); - if (*ftpc).count1 == 0 as libc::c_int && ftpcode == 229 as libc::c_int { - return ftp_epsv_disable(data, conn); - } - return result; - } - if ((*data).set).verbose() != 0 { - #[cfg(not(CURL_DISABLE_VERBOSE_STRINGS))] - ftp_pasv_verbose( - data, - (*addr).addr, - (*ftpc).newhost, - connectport as libc::c_int, - ); - } - Curl_resolv_unlock(data, addr); - Curl_cfree.expect("non-null function pointer")((*conn).secondaryhostname as *mut libc::c_void); - let ref mut fresh21 = (*conn).secondaryhostname; - *fresh21 = 0 as *mut libc::c_char; - (*conn).secondary_port = (*ftpc).newport; - let ref mut fresh22 = (*conn).secondaryhostname; - *fresh22 = Curl_cstrdup.expect("non-null function pointer")((*ftpc).newhost); - if ((*conn).secondaryhostname).is_null() { - return CURLE_OUT_OF_MEMORY; - } - let ref mut fresh23 = (*conn).bits; - (*fresh23).set_do_more(1 as libc::c_int as bit); - _state(data, FTP_STOP); - return result; -} -unsafe extern "C" fn ftp_state_port_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut fcmd: ftpport = (*ftpc).count1 as ftpport; - let mut result: CURLcode = CURLE_OK; - if ftpcode / 100 as libc::c_int != 2 as libc::c_int { - if EPRT as libc::c_int as libc::c_uint == fcmd as libc::c_uint { - Curl_infof( - data, - b"disabling EPRT usage\0" as *const u8 as *const libc::c_char, - ); - let ref mut fresh24 = (*conn).bits; - (*fresh24).set_ftp_use_eprt(0 as libc::c_int as bit); - } - fcmd += 1; - if fcmd as libc::c_uint == DONE as libc::c_int as libc::c_uint { - Curl_failf( - data, - b"Failed to do PORT\0" as *const u8 as *const libc::c_char, - ); - result = CURLE_FTP_PORT_FAILED; - } else { - result = ftp_state_use_port(data, fcmd); - } - } else { - Curl_infof( - data, - b"Connect data stream actively\0" as *const u8 as *const libc::c_char, - ); - _state(data, FTP_STOP); - result = ftp_dophase_done(data, 0 as libc::c_int != 0); - } - return result; -} -unsafe extern "C" fn ftp_state_mdtm_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - match ftpcode { - 213 => { - let mut year: libc::c_int = 0; - let mut month: libc::c_int = 0; - let mut day: libc::c_int = 0; - let mut hour: libc::c_int = 0; - let mut minute: libc::c_int = 0; - let mut second: libc::c_int = 0; - if 6 as libc::c_int - == sscanf( - &mut *((*data).state.buffer).offset(4 as libc::c_int as isize) - as *mut libc::c_char, - b"%04d%02d%02d%02d%02d%02d\0" as *const u8 as *const libc::c_char, - &mut year as *mut libc::c_int, - &mut month as *mut libc::c_int, - &mut day as *mut libc::c_int, - &mut hour as *mut libc::c_int, - &mut minute as *mut libc::c_int, - &mut second as *mut libc::c_int, - ) - { - let mut timebuf: [libc::c_char; 24] = [0; 24]; - curl_msnprintf( - timebuf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 24]>() as libc::c_ulong, - b"%04d%02d%02d %02d:%02d:%02d GMT\0" as *const u8 as *const libc::c_char, - year, - month, - day, - hour, - minute, - second, - ); - (*data).info.filetime = Curl_getdate_capped(timebuf.as_mut_ptr()); - } + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2062 as libc::c_int); + result = ftp_dophase_done(data, 0 as libc::c_int != 0); + } + return result; + } + unsafe extern "C" fn ftp_state_mdtm_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + match ftpcode { + 213 => { + let mut year: libc::c_int = 0; + let mut month: libc::c_int = 0; + let mut day: libc::c_int = 0; + let mut hour: libc::c_int = 0; + let mut minute: libc::c_int = 0; + let mut second: libc::c_int = 0; + if 6 as libc::c_int + == sscanf( + &mut *((*data).state.buffer).offset(4 as libc::c_int as isize) + as *mut libc::c_char, + b"%04d%02d%02d%02d%02d%02d\0" as *const u8 as *const libc::c_char, + &mut year as *mut libc::c_int, + &mut month as *mut libc::c_int, + &mut day as *mut libc::c_int, + &mut hour as *mut libc::c_int, + &mut minute as *mut libc::c_int, + &mut second as *mut libc::c_int, + ) + { + let mut timebuf: [libc::c_char; 24] = [0; 24]; + curl_msnprintf( + timebuf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 24]>() as libc::c_ulong, + b"%04d%02d%02d %02d:%02d:%02d GMT\0" as *const u8 as *const libc::c_char, + year, + month, + day, + hour, + minute, + second, + ); + (*data).info.filetime = Curl_getdate_capped(timebuf.as_mut_ptr()); + } // #[cfg(CURL_FTP_HTTPSTYLE_HEAD)] - if ((*data).set).opt_no_body() as libc::c_int != 0 - && !((*ftpc).file).is_null() - && ((*data).set).get_filetime() as libc::c_int != 0 - && (*data).info.filetime >= 0 as libc::c_int as libc::c_long - { - let mut headerbuf: [libc::c_char; 128] = [0; 128]; - let mut headerbuflen: libc::c_int = 0; - let mut filetime: time_t = (*data).info.filetime; - let mut buffer: tm = tm { - tm_sec: 0, - tm_min: 0, - tm_hour: 0, - tm_mday: 0, - tm_mon: 0, - tm_year: 0, - tm_wday: 0, - tm_yday: 0, - tm_isdst: 0, - tm_gmtoff: 0, - tm_zone: 0 as *const libc::c_char, - }; - let mut tm: *const tm = &mut buffer; - result = Curl_gmtime(filetime, &mut buffer); - if result as u64 != 0 { - return result; - } - headerbuflen = curl_msnprintf( - headerbuf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 128]>() as libc::c_ulong, - b"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n\0" as *const u8 - as *const libc::c_char, - Curl_wkday[(if (*tm).tm_wday != 0 { - (*tm).tm_wday - 1 as libc::c_int - } else { - 6 as libc::c_int - }) as usize], - (*tm).tm_mday, - Curl_month[(*tm).tm_mon as usize], - (*tm).tm_year + 1900 as libc::c_int, - (*tm).tm_hour, - (*tm).tm_min, - (*tm).tm_sec, - ); - result = Curl_client_write( - data, - (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 1 as libc::c_int, - headerbuf.as_mut_ptr(), - headerbuflen as size_t, - ); - if result as u64 != 0 { - return result; - } - } - } - 550 => { - Curl_failf( - data, - b"Given file does not exist\0" as *const u8 as *const libc::c_char, - ); - result = CURLE_REMOTE_FILE_NOT_FOUND; - } - _ => { - Curl_infof( - data, - b"unsupported MDTM reply format\0" as *const u8 as *const libc::c_char, - ); - } - } - if (*data).set.timecondition as u64 != 0 { - if (*data).info.filetime > 0 as libc::c_int as libc::c_long - && (*data).set.timevalue > 0 as libc::c_int as libc::c_long - { - match (*data).set.timecondition as libc::c_uint { - 2 => { - if (*data).info.filetime > (*data).set.timevalue { - Curl_infof( - data, - b"The requested document is not old enough\0" as *const u8 - as *const libc::c_char, - ); - (*ftp).transfer = PPTRANSFER_NONE; - let ref mut fresh26 = (*data).info; - (*fresh26).set_timecond(1 as libc::c_int as bit); - _state(data, FTP_STOP); - return CURLE_OK; - } - } - 1 | _ => { - if (*data).info.filetime <= (*data).set.timevalue { - Curl_infof( - data, - b"The requested document is not new enough\0" as *const u8 - as *const libc::c_char, - ); - (*ftp).transfer = PPTRANSFER_NONE; - let ref mut fresh25 = (*data).info; - (*fresh25).set_timecond(1 as libc::c_int as bit); - _state(data, FTP_STOP); - return CURLE_OK; - } - } - } - } else { - Curl_infof( - data, - b"Skipping time comparison\0" as *const u8 as *const libc::c_char, - ); - } - } - if result as u64 == 0 { - result = ftp_state_type(data); - } - return result; -} -unsafe extern "C" fn ftp_state_type_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - if ftpcode / 100 as libc::c_int != 2 as libc::c_int { - Curl_failf( - data, - b"Couldn't set desired mode\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FTP_COULDNT_SET_TYPE; - } - if ftpcode != 200 as libc::c_int { - Curl_infof( - data, - b"Got a %03d response code instead of the assumed 200\0" as *const u8 - as *const libc::c_char, - ftpcode, - ); - } - if instate as libc::c_uint == FTP_TYPE as libc::c_int as libc::c_uint { - result = ftp_state_size(data, conn); - } else if instate as libc::c_uint == FTP_LIST_TYPE as libc::c_int as libc::c_uint { - result = ftp_state_list(data); - } else if instate as libc::c_uint == FTP_RETR_TYPE as libc::c_int as libc::c_uint { - result = ftp_state_retr_prequote(data); - } else if instate as libc::c_uint == FTP_STOR_TYPE as libc::c_int as libc::c_uint { - result = ftp_state_stor_prequote(data); - } - return result; -} -unsafe extern "C" fn ftp_state_retr( - mut data: *mut Curl_easy, - mut filesize: curl_off_t, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if (*data).set.max_filesize != 0 && filesize > (*data).set.max_filesize { - Curl_failf( - data, - b"Maximum file size exceeded\0" as *const u8 as *const libc::c_char, - ); - return CURLE_FILESIZE_EXCEEDED; - } - (*ftp).downloadsize = filesize; - if (*data).state.resume_from != 0 { - if filesize == -(1 as libc::c_int) as libc::c_long { - Curl_infof( - data, - b"ftp server doesn't support SIZE\0" as *const u8 as *const libc::c_char, - ); - } else if (*data).state.resume_from < 0 as libc::c_int as libc::c_long { - if filesize < -(*data).state.resume_from { - Curl_failf( - data, - b"Offset (%ld) was beyond file size (%ld)\0" as *const u8 - as *const libc::c_char, - (*data).state.resume_from, - filesize, - ); - return CURLE_BAD_DOWNLOAD_RESUME; - } - (*ftp).downloadsize = -(*data).state.resume_from; - (*data).state.resume_from = filesize - (*ftp).downloadsize; - } else { - if filesize < (*data).state.resume_from { - Curl_failf( - data, - b"Offset (%ld) was beyond file size (%ld)\0" as *const u8 - as *const libc::c_char, - (*data).state.resume_from, - filesize, - ); - return CURLE_BAD_DOWNLOAD_RESUME; - } - (*ftp).downloadsize = filesize - (*data).state.resume_from; - } - if (*ftp).downloadsize == 0 as libc::c_int as libc::c_long { - Curl_setup_transfer( - data, - -(1 as libc::c_int), - -(1 as libc::c_int) as curl_off_t, - 0 as libc::c_int != 0, - -(1 as libc::c_int), - ); - Curl_infof( - data, - b"File already completely downloaded\0" as *const u8 as *const libc::c_char, - ); - (*ftp).transfer = PPTRANSFER_NONE; - _state(data, FTP_STOP); - return CURLE_OK; - } - Curl_infof( - data, - b"Instructs server to resume from offset %ld\0" as *const u8 as *const libc::c_char, - (*data).state.resume_from, - ); - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"REST %ld\0" as *const u8 as *const libc::c_char, - (*data).state.resume_from, - ); - if result as u64 == 0 { + if ((*data).set).opt_no_body() as libc::c_int != 0 + && !((*ftpc).file).is_null() + && ((*data).set).get_filetime() as libc::c_int != 0 + && (*data).info.filetime >= 0 as libc::c_int as libc::c_long + { + let mut headerbuf: [libc::c_char; 128] = [0; 128]; + let mut headerbuflen: libc::c_int = 0; + let mut filetime: time_t = (*data).info.filetime; + let mut buffer: tm = tm { + tm_sec: 0, + tm_min: 0, + tm_hour: 0, + tm_mday: 0, + tm_mon: 0, + tm_year: 0, + tm_wday: 0, + tm_yday: 0, + tm_isdst: 0, + tm_gmtoff: 0, + tm_zone: 0 as *const libc::c_char, + }; + let mut tm: *const tm = &mut buffer; + result = Curl_gmtime(filetime, &mut buffer); + if result as u64 != 0 { + return result; + } + headerbuflen = curl_msnprintf( + headerbuf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 128]>() as libc::c_ulong, + b"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n\0" as *const u8 + as *const libc::c_char, + Curl_wkday[(if (*tm).tm_wday != 0 { + (*tm).tm_wday - 1 as libc::c_int + } else { + 6 as libc::c_int + }) as usize], + (*tm).tm_mday, + Curl_month[(*tm).tm_mon as usize], + (*tm).tm_year + 1900 as libc::c_int, + (*tm).tm_hour, + (*tm).tm_min, + (*tm).tm_sec, + ); + result = Curl_client_write( + data, + (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 1 as libc::c_int, + headerbuf.as_mut_ptr(), + headerbuflen as size_t, + ); + if result as u64 != 0 { + return result; + } + } + } + 550 => { + Curl_failf( + data, + b"Given file does not exist\0" as *const u8 as *const libc::c_char, + ); + result = CURLE_REMOTE_FILE_NOT_FOUND; + } + _ => { + Curl_infof( + data, + b"unsupported MDTM reply format\0" as *const u8 as *const libc::c_char, + ); + } + } + if (*data).set.timecondition as u64 != 0 { + if (*data).info.filetime > 0 as libc::c_int as libc::c_long + && (*data).set.timevalue > 0 as libc::c_int as libc::c_long + { + match (*data).set.timecondition as libc::c_uint { + 2 => { + if (*data).info.filetime > (*data).set.timevalue { + Curl_infof( + data, + b"The requested document is not old enough\0" as *const u8 + as *const libc::c_char, + ); + (*ftp).transfer = PPTRANSFER_NONE; + let ref mut fresh26 = (*data).info; + (*fresh26).set_timecond(1 as libc::c_int as bit); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2157 as libc::c_int); + return CURLE_OK; + } + } + 1 | _ => { + if (*data).info.filetime <= (*data).set.timevalue { + Curl_infof( + data, + b"The requested document is not new enough\0" as *const u8 + as *const libc::c_char, + ); + (*ftp).transfer = PPTRANSFER_NONE; + let ref mut fresh25 = (*data).info; + (*fresh25).set_timecond(1 as libc::c_int as bit); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2148 as libc::c_int); + return CURLE_OK; + } + } + } + } else { + Curl_infof( + data, + b"Skipping time comparison\0" as *const u8 as *const libc::c_char, + ); + } + } + if result as u64 == 0 { + result = ftp_state_type(data); + } + return result; + } + unsafe extern "C" fn ftp_state_type_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + if ftpcode / 100 as libc::c_int != 2 as libc::c_int { + Curl_failf( + data, + b"Couldn't set desired mode\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FTP_COULDNT_SET_TYPE; + } + if ftpcode != 200 as libc::c_int { + Curl_infof( + data, + b"Got a %03d response code instead of the assumed 200\0" as *const u8 + as *const libc::c_char, + ftpcode, + ); + } + if instate as libc::c_uint == FTP_TYPE as libc::c_int as libc::c_uint { + result = ftp_state_size(data, conn); + } else if instate as libc::c_uint == FTP_LIST_TYPE as libc::c_int as libc::c_uint { + result = ftp_state_list(data); + } else if instate as libc::c_uint == FTP_RETR_TYPE as libc::c_int as libc::c_uint { + result = ftp_state_retr_prequote(data); + } else if instate as libc::c_uint == FTP_STOR_TYPE as libc::c_int as libc::c_uint { + result = ftp_state_stor_prequote(data); + } + return result; + } + unsafe extern "C" fn ftp_state_retr( + mut data: *mut Curl_easy, + mut filesize: curl_off_t, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if (*data).set.max_filesize != 0 && filesize > (*data).set.max_filesize { + Curl_failf( + data, + b"Maximum file size exceeded\0" as *const u8 as *const libc::c_char, + ); + return CURLE_FILESIZE_EXCEEDED; + } + (*ftp).downloadsize = filesize; + if (*data).state.resume_from != 0 { + if filesize == -(1 as libc::c_int) as libc::c_long { + Curl_infof( + data, + b"ftp server doesn't support SIZE\0" as *const u8 as *const libc::c_char, + ); + } else if (*data).state.resume_from < 0 as libc::c_int as libc::c_long { + if filesize < -(*data).state.resume_from { + Curl_failf( + data, + b"Offset (%ld) was beyond file size (%ld)\0" as *const u8 + as *const libc::c_char, + (*data).state.resume_from, + filesize, + ); + return CURLE_BAD_DOWNLOAD_RESUME; + } + (*ftp).downloadsize = -(*data).state.resume_from; + (*data).state.resume_from = filesize - (*ftp).downloadsize; + } else { + if filesize < (*data).state.resume_from { + Curl_failf( + data, + b"Offset (%ld) was beyond file size (%ld)\0" as *const u8 + as *const libc::c_char, + (*data).state.resume_from, + filesize, + ); + return CURLE_BAD_DOWNLOAD_RESUME; + } + (*ftp).downloadsize = filesize - (*data).state.resume_from; + } + if (*ftp).downloadsize == 0 as libc::c_int as libc::c_long { + Curl_setup_transfer( + data, + -(1 as libc::c_int), + -(1 as libc::c_int) as curl_off_t, + 0 as libc::c_int != 0, + -(1 as libc::c_int), + ); + Curl_infof( + data, + b"File already completely downloaded\0" as *const u8 as *const libc::c_char, + ); + (*ftp).transfer = PPTRANSFER_NONE; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2264 as libc::c_int); + return CURLE_OK; + } + Curl_infof( + data, + b"Instructs server to resume from offset %ld\0" as *const u8 as *const libc::c_char, + (*data).state.resume_from, + ); + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"REST %ld\0" as *const u8 as *const libc::c_char, + (*data).state.resume_from, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_RETR_REST); - } - } else { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"RETR %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_RETR_REST, 2275 as libc::c_int); + } + } else { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"RETR %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_RETR); - } - } - return result; -} -unsafe extern "C" fn ftp_state_size_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut filesize: curl_off_t = -(1 as libc::c_int) as curl_off_t; - let mut buf: *mut libc::c_char = (*data).state.buffer; - if ftpcode == 213 as libc::c_int { - let mut start: *mut libc::c_char = - &mut *buf.offset(4 as libc::c_int as isize) as *mut libc::c_char; - let mut fdigit: *mut libc::c_char = strchr(start, '\r' as i32); - if !fdigit.is_null() { - loop { - fdigit = fdigit.offset(-1); - if !(Curl_isdigit(*fdigit as libc::c_uchar as libc::c_int) != 0 && fdigit > start) { - break; - } - } - if Curl_isdigit(*fdigit as libc::c_uchar as libc::c_int) == 0 { - fdigit = fdigit.offset(1); - } - } else { - fdigit = start; - } - curlx_strtoofft( - fdigit, - 0 as *mut *mut libc::c_char, - 0 as libc::c_int, - &mut filesize, - ); - } else if ftpcode == 550 as libc::c_int { - if instate as libc::c_uint != FTP_STOR_SIZE as libc::c_int as libc::c_uint { - Curl_failf( - data, - b"The file does not exist\0" as *const u8 as *const libc::c_char, - ); - return CURLE_REMOTE_FILE_NOT_FOUND; - } - } - if instate as libc::c_uint == FTP_SIZE as libc::c_int as libc::c_uint { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_RETR, 2281 as libc::c_int); + } + } + return result; + } + unsafe extern "C" fn ftp_state_size_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut filesize: curl_off_t = -(1 as libc::c_int) as curl_off_t; + let mut buf: *mut libc::c_char = (*data).state.buffer; + if ftpcode == 213 as libc::c_int { + let mut start: *mut libc::c_char = + &mut *buf.offset(4 as libc::c_int as isize) as *mut libc::c_char; + let mut fdigit: *mut libc::c_char = strchr(start, '\r' as i32); + if !fdigit.is_null() { + loop { + fdigit = fdigit.offset(-1); + if !(Curl_isdigit(*fdigit as libc::c_uchar as libc::c_int) != 0 && fdigit > start) { + break; + } + } + if Curl_isdigit(*fdigit as libc::c_uchar as libc::c_int) == 0 { + fdigit = fdigit.offset(1); + } + } else { + fdigit = start; + } + curlx_strtoofft( + fdigit, + 0 as *mut *mut libc::c_char, + 0 as libc::c_int, + &mut filesize, + ); + } else if ftpcode == 550 as libc::c_int { + if instate as libc::c_uint != FTP_STOR_SIZE as libc::c_int as libc::c_uint { + Curl_failf( + data, + b"The file does not exist\0" as *const u8 as *const libc::c_char, + ); + return CURLE_REMOTE_FILE_NOT_FOUND; + } + } + if instate as libc::c_uint == FTP_SIZE as libc::c_int as libc::c_uint { // #[cfg(CURL_FTP_HTTPSTYLE_HEAD)] - if -(1 as libc::c_int) as libc::c_long != filesize { - let mut clbuf: [libc::c_char; 128] = [0; 128]; - let mut clbuflen: libc::c_int = curl_msnprintf( - clbuf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 128]>() as libc::c_ulong, - b"Content-Length: %ld\r\n\0" as *const u8 as *const libc::c_char, - filesize, - ); - result = Curl_client_write( - data, - (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 1 as libc::c_int, - clbuf.as_mut_ptr(), - clbuflen as size_t, - ); - if result as u64 != 0 { - return result; - } - } - Curl_pgrsSetDownloadSize(data, filesize); - result = ftp_state_rest(data, (*data).conn); - } else if instate as libc::c_uint == FTP_RETR_SIZE as libc::c_int as libc::c_uint { - Curl_pgrsSetDownloadSize(data, filesize); - result = ftp_state_retr(data, filesize); - } else if instate as libc::c_uint == FTP_STOR_SIZE as libc::c_int as libc::c_uint { - (*data).state.resume_from = filesize; - result = ftp_state_ul_setup(data, 1 as libc::c_int != 0); - } - return result; -} -unsafe extern "C" fn ftp_state_rest_resp( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut ftpcode: libc::c_int, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - match instate as libc::c_uint { - 27 => { - if ftpcode != 350 as libc::c_int { - Curl_failf( - data, - b"Couldn't use REST\0" as *const u8 as *const libc::c_char, - ); - result = CURLE_FTP_COULDNT_USE_REST; - } else { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"RETR %s\0" as *const u8 as *const libc::c_char, - (*ftpc).file, - ); - if result as u64 == 0 { + if -(1 as libc::c_int) as libc::c_long != filesize { + let mut clbuf: [libc::c_char; 128] = [0; 128]; + let mut clbuflen: libc::c_int = curl_msnprintf( + clbuf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 128]>() as libc::c_ulong, + b"Content-Length: %ld\r\n\0" as *const u8 as *const libc::c_char, + filesize, + ); + result = Curl_client_write( + data, + (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 1 as libc::c_int, + clbuf.as_mut_ptr(), + clbuflen as size_t, + ); + if result as u64 != 0 { + return result; + } + } + Curl_pgrsSetDownloadSize(data, filesize); + result = ftp_state_rest(data, (*data).conn); + } else if instate as libc::c_uint == FTP_RETR_SIZE as libc::c_int as libc::c_uint { + Curl_pgrsSetDownloadSize(data, filesize); + result = ftp_state_retr(data, filesize); + } else if instate as libc::c_uint == FTP_STOR_SIZE as libc::c_int as libc::c_uint { + (*data).state.resume_from = filesize; + result = ftp_state_ul_setup(data, 1 as libc::c_int != 0); + } + return result; + } + unsafe extern "C" fn ftp_state_rest_resp( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut ftpcode: libc::c_int, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + match instate as libc::c_uint { + 27 => { + if ftpcode != 350 as libc::c_int { + Curl_failf( + data, + b"Couldn't use REST\0" as *const u8 as *const libc::c_char, + ); + result = CURLE_FTP_COULDNT_USE_REST; + } else { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"RETR %s\0" as *const u8 as *const libc::c_char, + (*ftpc).file, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_RETR); - } - } - } - 26 | _ => { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_RETR, 2381 as libc::c_int); + } + } + } + 26 | _ => { // #[cfg(CURL_FTP_HTTPSTYLE_HEAD)] - if ftpcode == 350 as libc::c_int { - let mut buffer: [libc::c_char; 24] = - *::std::mem::transmute::<&[u8; 24], &mut [libc::c_char; 24]>( - b"Accept-ranges: bytes\r\n\0\0", - ); - result = Curl_client_write( - data, - (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 1 as libc::c_int, - buffer.as_mut_ptr(), - strlen(buffer.as_mut_ptr()), - ); - if result as u64 != 0 { - return result; - } - } - result = ftp_state_prepare_transfer(data); - } - } - return result; -} -unsafe extern "C" fn ftp_state_stor_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - if ftpcode >= 400 as libc::c_int { - Curl_failf( - data, - b"Failed FTP upload: %0d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - _state(data, FTP_STOP); - return CURLE_UPLOAD_FAILED; - } - (*conn).proto.ftpc.state_saved = instate; - if ((*data).set).ftp_use_port() != 0 { - let mut connected: bool = false; - _state(data, FTP_STOP); - result = AllowServerConnect(data, &mut connected); - if result as u64 != 0 { - return result; - } - if !connected { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - Curl_infof( - data, - b"Data conn was not available immediately\0" as *const u8 as *const libc::c_char, - ); - (*ftpc).wait_data_conn = 1 as libc::c_int != 0; - } - return CURLE_OK; - } - return InitiateTransfer(data); -} -unsafe extern "C" fn ftp_state_get_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - if ftpcode == 150 as libc::c_int || ftpcode == 125 as libc::c_int { - let mut size: curl_off_t = -(1 as libc::c_int) as curl_off_t; - if instate as libc::c_uint != FTP_LIST as libc::c_int as libc::c_uint - && ((*data).state).prefer_ascii() == 0 - && (*ftp).downloadsize < 1 as libc::c_int as libc::c_long - { - let mut bytes: *mut libc::c_char = 0 as *mut libc::c_char; - let mut buf: *mut libc::c_char = (*data).state.buffer; - bytes = strstr(buf, b" bytes\0" as *const u8 as *const libc::c_char); - if !bytes.is_null() { - bytes = bytes.offset(-1); - let mut in_0: libc::c_long = bytes.offset_from(buf) as libc::c_long; - loop { - in_0 -= 1; - if !(in_0 != 0) { - break; - } - if '(' as i32 == *bytes as libc::c_int { - break; - } - if Curl_isdigit(*bytes as libc::c_uchar as libc::c_int) == 0 { - bytes = 0 as *mut libc::c_char; - break; - } else { - bytes = bytes.offset(-1); - } - } - if !bytes.is_null() { - bytes = bytes.offset(1); - curlx_strtoofft( - bytes, - 0 as *mut *mut libc::c_char, - 0 as libc::c_int, - &mut size, - ); - } - } - } else if (*ftp).downloadsize > -(1 as libc::c_int) as libc::c_long { - size = (*ftp).downloadsize; - } - if size > (*data).req.maxdownload - && (*data).req.maxdownload > 0 as libc::c_int as libc::c_long - { - let ref mut fresh27 = (*data).req.size; - *fresh27 = (*data).req.maxdownload; - size = *fresh27; - } else if instate as libc::c_uint != FTP_LIST as libc::c_int as libc::c_uint - && ((*data).state).prefer_ascii() as libc::c_int != 0 - { - size = -(1 as libc::c_int) as curl_off_t; - } - Curl_infof( - data, - b"Maxdownload = %ld\0" as *const u8 as *const libc::c_char, - (*data).req.maxdownload, - ); - if instate as libc::c_uint != FTP_LIST as libc::c_int as libc::c_uint { - Curl_infof( - data, - b"Getting file with size: %ld\0" as *const u8 as *const libc::c_char, - size, - ); - } - (*conn).proto.ftpc.state_saved = instate; - (*conn).proto.ftpc.retr_size_saved = size; - if ((*data).set).ftp_use_port() != 0 { - let mut connected: bool = false; - result = AllowServerConnect(data, &mut connected); - if result as u64 != 0 { - return result; - } - if !connected { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - Curl_infof( - data, - b"Data conn was not available immediately\0" as *const u8 - as *const libc::c_char, - ); - _state(data, FTP_STOP); - (*ftpc).wait_data_conn = 1 as libc::c_int != 0; - } - } else { - return InitiateTransfer(data); - } - } else if instate as libc::c_uint == FTP_LIST as libc::c_int as libc::c_uint - && ftpcode == 450 as libc::c_int - { - (*ftp).transfer = PPTRANSFER_NONE; - _state(data, FTP_STOP); - } else { - Curl_failf( - data, - b"RETR response: %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - return (if instate as libc::c_uint == FTP_RETR as libc::c_int as libc::c_uint - && ftpcode == 550 as libc::c_int - { - CURLE_REMOTE_FILE_NOT_FOUND as libc::c_int - } else { - CURLE_FTP_COULDNT_RETR_FILE as libc::c_int - }) as CURLcode; - } - return result; -} -unsafe extern "C" fn ftp_state_loggedin(mut data: *mut Curl_easy) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - if ((*conn).bits).ftp_use_control_ssl() != 0 { - result = Curl_pp_sendf( - data, - &mut (*conn).proto.ftpc.pp as *mut pingpong, - b"PBSZ %d\0" as *const u8 as *const libc::c_char, - 0 as libc::c_int, - ); - if result as u64 == 0 { + if ftpcode == 350 as libc::c_int { + let mut buffer: [libc::c_char; 24] = + *::std::mem::transmute::<&[u8; 24], &mut [libc::c_char; 24]>( + b"Accept-ranges: bytes\r\n\0\0", + ); + result = Curl_client_write( + data, + (1 as libc::c_int) << 0 as libc::c_int | (1 as libc::c_int) << 1 as libc::c_int, + buffer.as_mut_ptr(), + strlen(buffer.as_mut_ptr()), + ); + if result as u64 != 0 { + return result; + } + } + result = ftp_state_prepare_transfer(data); + } + } + return result; + } + unsafe extern "C" fn ftp_state_stor_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + if ftpcode >= 400 as libc::c_int { + Curl_failf( + data, + b"Failed FTP upload: %0d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2397 as libc::c_int); + return CURLE_UPLOAD_FAILED; + } + (*conn).proto.ftpc.state_saved = instate; + if ((*data).set).ftp_use_port() != 0 { + let mut connected: bool = false; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2408 as libc::c_int); + result = AllowServerConnect(data, &mut connected); + if result as u64 != 0 { + return result; + } + if !connected { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + Curl_infof( + data, + b"Data conn was not available immediately\0" as *const u8 as *const libc::c_char, + ); + (*ftpc).wait_data_conn = 1 as libc::c_int != 0; + } + return CURLE_OK; + } + return InitiateTransfer(data); + } + unsafe extern "C" fn ftp_state_get_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + if ftpcode == 150 as libc::c_int || ftpcode == 125 as libc::c_int { + let mut size: curl_off_t = -(1 as libc::c_int) as curl_off_t; + if instate as libc::c_uint != FTP_LIST as libc::c_int as libc::c_uint + && ((*data).state).prefer_ascii() == 0 + && (*ftp).downloadsize < 1 as libc::c_int as libc::c_long + { + let mut bytes: *mut libc::c_char = 0 as *mut libc::c_char; + let mut buf: *mut libc::c_char = (*data).state.buffer; + bytes = strstr(buf, b" bytes\0" as *const u8 as *const libc::c_char); + if !bytes.is_null() { + bytes = bytes.offset(-1); + let mut in_0: libc::c_long = bytes.offset_from(buf) as libc::c_long; + loop { + in_0 -= 1; + if !(in_0 != 0) { + break; + } + if '(' as i32 == *bytes as libc::c_int { + break; + } + if Curl_isdigit(*bytes as libc::c_uchar as libc::c_int) == 0 { + bytes = 0 as *mut libc::c_char; + break; + } else { + bytes = bytes.offset(-1); + } + } + if !bytes.is_null() { + bytes = bytes.offset(1); + curlx_strtoofft( + bytes, + 0 as *mut *mut libc::c_char, + 0 as libc::c_int, + &mut size, + ); + } + } + } else if (*ftp).downloadsize > -(1 as libc::c_int) as libc::c_long { + size = (*ftp).downloadsize; + } + if size > (*data).req.maxdownload + && (*data).req.maxdownload > 0 as libc::c_int as libc::c_long + { + let ref mut fresh27 = (*data).req.size; + *fresh27 = (*data).req.maxdownload; + size = *fresh27; + } else if instate as libc::c_uint != FTP_LIST as libc::c_int as libc::c_uint + && ((*data).state).prefer_ascii() as libc::c_int != 0 + { + size = -(1 as libc::c_int) as curl_off_t; + } + Curl_infof( + data, + b"Maxdownload = %ld\0" as *const u8 as *const libc::c_char, + (*data).req.maxdownload, + ); + if instate as libc::c_uint != FTP_LIST as libc::c_int as libc::c_uint { + Curl_infof( + data, + b"Getting file with size: %ld\0" as *const u8 as *const libc::c_char, + size, + ); + } + (*conn).proto.ftpc.state_saved = instate; + (*conn).proto.ftpc.retr_size_saved = size; + if ((*data).set).ftp_use_port() != 0 { + let mut connected: bool = false; + result = AllowServerConnect(data, &mut connected); + if result as u64 != 0 { + return result; + } + if !connected { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + Curl_infof( + data, + b"Data conn was not available immediately\0" as *const u8 + as *const libc::c_char, + ); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2530 as libc::c_int); + (*ftpc).wait_data_conn = 1 as libc::c_int != 0; + } + } else { + return InitiateTransfer(data); + } + } else if instate as libc::c_uint == FTP_LIST as libc::c_int as libc::c_uint + && ftpcode == 450 as libc::c_int + { + (*ftp).transfer = PPTRANSFER_NONE; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2541 as libc::c_int); + } else { + Curl_failf( + data, + b"RETR response: %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + return (if instate as libc::c_uint == FTP_RETR as libc::c_int as libc::c_uint + && ftpcode == 550 as libc::c_int + { + CURLE_REMOTE_FILE_NOT_FOUND as libc::c_int + } else { + CURLE_FTP_COULDNT_RETR_FILE as libc::c_int + }) as CURLcode; + } + return result; + } + unsafe extern "C" fn ftp_state_loggedin(mut data: *mut Curl_easy) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + if ((*conn).bits).ftp_use_control_ssl() != 0 { + result = Curl_pp_sendf( + data, + &mut (*conn).proto.ftpc.pp as *mut pingpong, + b"PBSZ %d\0" as *const u8 as *const libc::c_char, + 0 as libc::c_int, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_PBSZ); - } - } else { - result = ftp_state_pwd(data, conn); - } - return result; -} -unsafe extern "C" fn ftp_state_user_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, - mut instate: ftpstate, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if ftpcode == 331 as libc::c_int - && (*ftpc).state as libc::c_uint == FTP_USER as libc::c_int as libc::c_uint - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"PASS %s\0" as *const u8 as *const libc::c_char, - if !((*conn).passwd).is_null() { - (*conn).passwd as *const libc::c_char - } else { - b"\0" as *const u8 as *const libc::c_char - }, - ); - if result as u64 == 0 { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PBSZ, 2577 as libc::c_int); + } + } else { + result = ftp_state_pwd(data, conn); + } + return result; + } + unsafe extern "C" fn ftp_state_user_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + mut instate: ftpstate, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if ftpcode == 331 as libc::c_int + && (*ftpc).state as libc::c_uint == FTP_USER as libc::c_int as libc::c_uint + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"PASS %s\0" as *const u8 as *const libc::c_char, + if !((*conn).passwd).is_null() { + (*conn).passwd as *const libc::c_char + } else { + b"\0" as *const u8 as *const libc::c_char + }, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_PASS); - } - } else if ftpcode / 100 as libc::c_int == 2 as libc::c_int { - result = ftp_state_loggedin(data); - } else if ftpcode == 332 as libc::c_int { - if !((*data).set.str_0[STRING_FTP_ACCOUNT as libc::c_int as usize]).is_null() { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"ACCT %s\0" as *const u8 as *const libc::c_char, - (*data).set.str_0[STRING_FTP_ACCOUNT as libc::c_int as usize], - ); - if result as u64 == 0 { + #[cfg(DEBUGBUILD)] + _state(data, FTP_PASS, 2602 as libc::c_int); + } + } else if ftpcode / 100 as libc::c_int == 2 as libc::c_int { + result = ftp_state_loggedin(data); + } else if ftpcode == 332 as libc::c_int { + if !((*data).set.str_0[STRING_FTP_ACCOUNT as libc::c_int as usize]).is_null() { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"ACCT %s\0" as *const u8 as *const libc::c_char, + (*data).set.str_0[STRING_FTP_ACCOUNT as libc::c_int as usize], + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_ACCT); - } - } else { - Curl_failf( - data, - b"ACCT requested but none available\0" as *const u8 as *const libc::c_char, - ); - result = CURLE_LOGIN_DENIED; - } - } else if !((*data).set.str_0[STRING_FTP_ALTERNATIVE_TO_USER as libc::c_int as usize]).is_null() - && ((*data).state).ftp_trying_alternative() == 0 - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - (*data).set.str_0[STRING_FTP_ALTERNATIVE_TO_USER as libc::c_int as usize], - ); - if result as u64 == 0 { - let ref mut fresh28 = (*data).state; - (*fresh28).set_ftp_trying_alternative(1 as libc::c_int as bit); - _state(data, FTP_USER); - } - } else { - Curl_failf( - data, - b"Access denied: %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - result = CURLE_LOGIN_DENIED; - } - return result; -} -unsafe extern "C" fn ftp_state_acct_resp( - mut data: *mut Curl_easy, - mut ftpcode: libc::c_int, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - if ftpcode != 230 as libc::c_int { - Curl_failf( - data, - b"ACCT rejected by server: %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - result = CURLE_FTP_WEIRD_PASS_REPLY; - } else { - result = ftp_state_loggedin(data); - } - return result; -} -unsafe extern "C" fn ftp_statemachine( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut sock: curl_socket_t = (*conn).sock[0 as libc::c_int as usize]; - let mut ftpcode: libc::c_int = 0; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - static mut ftpauth: [[libc::c_char; 4]; 2] = unsafe { - [ - *::std::mem::transmute::<&[u8; 4], &[libc::c_char; 4]>(b"SSL\0"), - *::std::mem::transmute::<&[u8; 4], &[libc::c_char; 4]>(b"TLS\0"), - ] - }; - let mut nread: size_t = 0 as libc::c_int as size_t; - if (*pp).sendleft != 0 { - return Curl_pp_flushsend(data, pp); - } - result = ftp_readresp(data, sock, pp, &mut ftpcode, &mut nread); - if result as u64 != 0 { - return result; - } - if ftpcode != 0 { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_ACCT, 2614 as libc::c_int); + } + } else { + Curl_failf( + data, + b"ACCT requested but none available\0" as *const u8 as *const libc::c_char, + ); + result = CURLE_LOGIN_DENIED; + } + } else if !((*data).set.str_0[STRING_FTP_ALTERNATIVE_TO_USER as libc::c_int as usize]).is_null() + && ((*data).state).ftp_trying_alternative() == 0 + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + (*data).set.str_0[STRING_FTP_ALTERNATIVE_TO_USER as libc::c_int as usize], + ); + if result as u64 == 0 { + let ref mut fresh28 = (*data).state; + (*fresh28).set_ftp_trying_alternative(1 as libc::c_int as bit); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_USER); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_USER, 2635 as libc::c_int); + } + } else { + Curl_failf( + data, + b"Access denied: %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + result = CURLE_LOGIN_DENIED; + } + return result; + } + unsafe extern "C" fn ftp_state_acct_resp( + mut data: *mut Curl_easy, + mut ftpcode: libc::c_int, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + if ftpcode != 230 as libc::c_int { + Curl_failf( + data, + b"ACCT rejected by server: %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + result = CURLE_FTP_WEIRD_PASS_REPLY; + } else { + result = ftp_state_loggedin(data); + } + return result; + } + unsafe extern "C" fn ftp_statemachine( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut sock: curl_socket_t = (*conn).sock[0 as libc::c_int as usize]; + let mut ftpcode: libc::c_int = 0; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + static mut ftpauth: [[libc::c_char; 4]; 2] = unsafe { + [ + *::std::mem::transmute::<&[u8; 4], &[libc::c_char; 4]>(b"SSL\0"), + *::std::mem::transmute::<&[u8; 4], &[libc::c_char; 4]>(b"TLS\0"), + ] + }; + let mut nread: size_t = 0 as libc::c_int as size_t; + if (*pp).sendleft != 0 { + return Curl_pp_flushsend(data, pp); + } + result = ftp_readresp(data, sock, pp, &mut ftpcode, &mut nread); + if result as u64 != 0 { + return result; + } + if ftpcode != 0 { let mut current_block_187: u64; - match (*ftpc).state as libc::c_uint { - 1 => { - if ftpcode == 230 as libc::c_int { - if (*data).set.use_ssl as libc::c_uint - <= CURLUSESSL_TRY as libc::c_int as libc::c_uint - || ((*conn).bits).ftp_use_control_ssl() as libc::c_int != 0 - { - return ftp_state_user_resp(data, ftpcode, (*ftpc).state); - } - } else if ftpcode != 220 as libc::c_int { - Curl_failf( - data, - b"Got a %03d ftp-server response when 220 was expected\0" as *const u8 - as *const libc::c_char, - ftpcode, - ); - return CURLE_WEIRD_SERVER_REPLY; - } + match (*ftpc).state as libc::c_uint { + 1 => { + if ftpcode == 230 as libc::c_int { + if (*data).set.use_ssl as libc::c_uint + <= CURLUSESSL_TRY as libc::c_int as libc::c_uint + || ((*conn).bits).ftp_use_control_ssl() as libc::c_int != 0 + { + return ftp_state_user_resp(data, ftpcode, (*ftpc).state); + } + } else if ftpcode != 220 as libc::c_int { + Curl_failf( + data, + b"Got a %03d ftp-server response when 220 was expected\0" as *const u8 + as *const libc::c_char, + ftpcode, + ); + return CURLE_WEIRD_SERVER_REPLY; + } #[cfg(HAVE_GSSAPI)] if ((*data).set).krb() != 0 { Curl_sec_request_prot( @@ -2889,47 +3351,51 @@ unsafe extern "C" fn ftp_statemachine( ); } } - if (*data).set.use_ssl as libc::c_uint != 0 - && ((*conn).bits).ftp_use_control_ssl() == 0 - { - (*ftpc).count3 = 0 as libc::c_int; - match (*data).set.ftpsslauth as libc::c_uint { - 0 | 1 => { - (*ftpc).count2 = 1 as libc::c_int; - (*ftpc).count1 = 0 as libc::c_int; - } - 2 => { - (*ftpc).count2 = -(1 as libc::c_int); - (*ftpc).count1 = 1 as libc::c_int; - } - _ => { - Curl_failf( - data, - b"unsupported parameter to CURLOPT_FTPSSLAUTH: %d\0" as *const u8 - as *const libc::c_char, - (*data).set.ftpsslauth as libc::c_int, - ); - return CURLE_UNKNOWN_OPTION; - } - } - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"AUTH %s\0" as *const u8 as *const libc::c_char, - (ftpauth[(*ftpc).count1 as usize]).as_ptr(), - ); - if result as u64 == 0 { + if (*data).set.use_ssl as libc::c_uint != 0 + && ((*conn).bits).ftp_use_control_ssl() == 0 + { + (*ftpc).count3 = 0 as libc::c_int; + match (*data).set.ftpsslauth as libc::c_uint { + 0 | 1 => { + (*ftpc).count2 = 1 as libc::c_int; + (*ftpc).count1 = 0 as libc::c_int; + } + 2 => { + (*ftpc).count2 = -(1 as libc::c_int); + (*ftpc).count1 = 1 as libc::c_int; + } + _ => { + Curl_failf( + data, + b"unsupported parameter to CURLOPT_FTPSSLAUTH: %d\0" as *const u8 + as *const libc::c_char, + (*data).set.ftpsslauth as libc::c_int, + ); + return CURLE_UNKNOWN_OPTION; + } + } + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"AUTH %s\0" as *const u8 as *const libc::c_char, + (ftpauth[(*ftpc).count1 as usize]).as_ptr(), + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_AUTH); - } - } else { - result = ftp_state_user(data, conn); - } - } - 2 => { - if (*pp).cache_size != 0 { - return CURLE_WEIRD_SERVER_REPLY; - } - if ftpcode == 234 as libc::c_int || ftpcode == 334 as libc::c_int { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_AUTH, 2737 as libc::c_int); + } + } else { + result = ftp_state_user(data, conn); + } + } + 2 => { + if (*pp).cache_size != 0 { + return CURLE_WEIRD_SERVER_REPLY; + } + if ftpcode == 234 as libc::c_int || ftpcode == 334 as libc::c_int { // match () { // #[cfg(USE_SSL)] // _ => { @@ -2940,88 +3406,96 @@ unsafe extern "C" fn ftp_statemachine( // result = CURLE_NOT_BUILT_IN; // } // } - result = Curl_ssl_connect(data, conn, 0 as libc::c_int); - if result as u64 == 0 { - let ref mut fresh29 = (*conn).bits; - (*fresh29).set_ftp_use_data_ssl(0 as libc::c_int as bit); - let ref mut fresh30 = (*conn).bits; - (*fresh30).set_ftp_use_control_ssl(1 as libc::c_int as bit); - result = ftp_state_user(data, conn); - } - } else if (*ftpc).count3 < 1 as libc::c_int { - let ref mut fresh31 = (*ftpc).count3; - *fresh31 += 1; - (*ftpc).count1 += (*ftpc).count2; - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"AUTH %s\0" as *const u8 as *const libc::c_char, - (ftpauth[(*ftpc).count1 as usize]).as_ptr(), - ); - } else if (*data).set.use_ssl as libc::c_uint - > CURLUSESSL_TRY as libc::c_int as libc::c_uint - { - result = CURLE_USE_SSL_FAILED; - } else { - result = ftp_state_user(data, conn); - } - } - 3 | 4 => { - result = ftp_state_user_resp(data, ftpcode, (*ftpc).state); - } - 5 => { - result = ftp_state_acct_resp(data, ftpcode); - } - 6 => { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"PROT %c\0" as *const u8 as *const libc::c_char, - if (*data).set.use_ssl as libc::c_uint - == CURLUSESSL_CONTROL as libc::c_int as libc::c_uint - { - 'C' as i32 - } else { - 'P' as i32 - }, - ); - if result as u64 == 0 { + result = Curl_ssl_connect(data, conn, 0 as libc::c_int); + if result as u64 == 0 { + let ref mut fresh29 = (*conn).bits; + (*fresh29).set_ftp_use_data_ssl(0 as libc::c_int as bit); + let ref mut fresh30 = (*conn).bits; + (*fresh30).set_ftp_use_control_ssl(1 as libc::c_int as bit); + result = ftp_state_user(data, conn); + } + } else if (*ftpc).count3 < 1 as libc::c_int { + let ref mut fresh31 = (*ftpc).count3; + *fresh31 += 1; + (*ftpc).count1 += (*ftpc).count2; + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"AUTH %s\0" as *const u8 as *const libc::c_char, + (ftpauth[(*ftpc).count1 as usize]).as_ptr(), + ); + } else if (*data).set.use_ssl as libc::c_uint + > CURLUSESSL_TRY as libc::c_int as libc::c_uint + { + result = CURLE_USE_SSL_FAILED; + } else { + result = ftp_state_user(data, conn); + } + } + 3 | 4 => { + result = ftp_state_user_resp(data, ftpcode, (*ftpc).state); + } + 5 => { + result = ftp_state_acct_resp(data, ftpcode); + } + 6 => { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"PROT %c\0" as *const u8 as *const libc::c_char, + if (*data).set.use_ssl as libc::c_uint + == CURLUSESSL_CONTROL as libc::c_int as libc::c_uint + { + 'C' as i32 + } else { + 'P' as i32 + }, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_PROT); - } - } - 7 => { - if ftpcode / 100 as libc::c_int == 2 as libc::c_int { - let ref mut fresh32 = (*conn).bits; - (*fresh32).set_ftp_use_data_ssl( - (if (*data).set.use_ssl as libc::c_uint - != CURLUSESSL_CONTROL as libc::c_int as libc::c_uint - { - 1 as libc::c_int - } else { - 0 as libc::c_int - }) as bit, - ); - } else if (*data).set.use_ssl as libc::c_uint - > CURLUSESSL_CONTROL as libc::c_int as libc::c_uint - { - return CURLE_USE_SSL_FAILED; - } - if (*data).set.ftp_ccc as u64 != 0 { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - b"CCC\0" as *const u8 as *const libc::c_char, - ); - if result as u64 == 0 { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_PROT, 2796 as libc::c_int); + } + } + 7 => { + if ftpcode / 100 as libc::c_int == 2 as libc::c_int { + let ref mut fresh32 = (*conn).bits; + (*fresh32).set_ftp_use_data_ssl( + (if (*data).set.use_ssl as libc::c_uint + != CURLUSESSL_CONTROL as libc::c_int as libc::c_uint + { + 1 as libc::c_int + } else { + 0 as libc::c_int + }) as bit, + ); + } else if (*data).set.use_ssl as libc::c_uint + > CURLUSESSL_CONTROL as libc::c_int as libc::c_uint + { + return CURLE_USE_SSL_FAILED; + } + if (*data).set.ftp_ccc as u64 != 0 { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + b"CCC\0" as *const u8 as *const libc::c_char, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_CCC); - } - } else { - result = ftp_state_pwd(data, conn); - } - } - 8 => { - if ftpcode < 500 as libc::c_int { + + #[cfg(DEBUGBUILD)] + _state(data, FTP_CCC, 2815 as libc::c_int); + } + } else { + result = ftp_state_pwd(data, conn); + } + } + 8 => { + if ftpcode < 500 as libc::c_int { // match () { // #[cfg(USE_SSL)] // _ => { @@ -3032,387 +3506,522 @@ unsafe extern "C" fn ftp_statemachine( // result =CURLE_NOT_BUILT_IN; // } // } - result = Curl_ssl_shutdown(data, conn, 0 as libc::c_int); - if result as u64 != 0 { - Curl_failf( - data, - b"Failed to clear the command channel (CCC)\0" as *const u8 - as *const libc::c_char, - ); - } - } - if result as u64 == 0 { - result = ftp_state_pwd(data, conn); - } - } - 9 => { - if ftpcode == 257 as libc::c_int { - let mut ptr: *mut libc::c_char = &mut *((*data).state.buffer) - .offset(4 as libc::c_int as isize) - as *mut libc::c_char; - let buf_size: size_t = (*data).set.buffer_size as size_t; - let mut dir: *mut libc::c_char = 0 as *mut libc::c_char; - let mut entry_extracted: bool = 0 as libc::c_int != 0; - dir = Curl_cmalloc.expect("non-null function pointer")( - nread.wrapping_add(1 as libc::c_int as libc::c_ulong), - ) as *mut libc::c_char; - if dir.is_null() { - return CURLE_OUT_OF_MEMORY; + result = Curl_ssl_shutdown(data, conn, 0 as libc::c_int); + if result as u64 != 0 { + Curl_failf( + data, + b"Failed to clear the command channel (CCC)\0" as *const u8 + as *const libc::c_char, + ); + } + } + if result as u64 == 0 { + result = ftp_state_pwd(data, conn); + } + } + 9 => { + if ftpcode == 257 as libc::c_int { + let mut ptr: *mut libc::c_char = &mut *((*data).state.buffer) + .offset(4 as libc::c_int as isize) + as *mut libc::c_char; + let buf_size: size_t = (*data).set.buffer_size as size_t; + let mut dir: *mut libc::c_char = 0 as *mut libc::c_char; + let mut entry_extracted: bool = 0 as libc::c_int != 0; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + dir = Curl_cmalloc.expect("non-null function pointer")( + nread.wrapping_add(1 as libc::c_int as libc::c_ulong), + ) as *mut libc::c_char; + } + #[cfg(CURLDEBUG)] + _ => { + dir = curl_dbg_malloc( + nread.wrapping_add(1 as libc::c_int as libc::c_ulong), + 2841 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut libc::c_char; + } } - while ptr - < &mut *((*data).state.buffer).offset(buf_size as isize) - as *mut libc::c_char - && *ptr as libc::c_int != '\n' as i32 + + if dir.is_null() { + return CURLE_OUT_OF_MEMORY; + } + while ptr + < &mut *((*data).state.buffer).offset(buf_size as isize) + as *mut libc::c_char + && *ptr as libc::c_int != '\n' as i32 && *ptr as libc::c_int != '\0' as i32 - && *ptr as libc::c_int != '"' as i32 - { - ptr = ptr.offset(1); - } - if '"' as i32 == *ptr as libc::c_int { - let mut store: *mut libc::c_char = 0 as *mut libc::c_char; - ptr = ptr.offset(1); - store = dir; - while *ptr != 0 { - if '"' as i32 == *ptr as libc::c_int { - if '"' as i32 - == *ptr.offset(1 as libc::c_int as isize) as libc::c_int - { - *store = *ptr.offset(1 as libc::c_int as isize); - ptr = ptr.offset(1); - } else { - entry_extracted = 1 as libc::c_int != 0; - break; - } - } else { - *store = *ptr; - } - store = store.offset(1); - ptr = ptr.offset(1); - } + && *ptr as libc::c_int != '"' as i32 + { + ptr = ptr.offset(1); + } + if '"' as i32 == *ptr as libc::c_int { + let mut store: *mut libc::c_char = 0 as *mut libc::c_char; + ptr = ptr.offset(1); + store = dir; + while *ptr != 0 { + if '"' as i32 == *ptr as libc::c_int { + if '"' as i32 + == *ptr.offset(1 as libc::c_int as isize) as libc::c_int + { + *store = *ptr.offset(1 as libc::c_int as isize); + ptr = ptr.offset(1); + } else { + entry_extracted = 1 as libc::c_int != 0; + break; + } + } else { + *store = *ptr; + } + store = store.offset(1); + ptr = ptr.offset(1); + } *store = '\0' as i32 as libc::c_char; - } - if entry_extracted { - if ((*ftpc).server_os).is_null() - && *dir.offset(0 as libc::c_int as isize) as libc::c_int != '/' as i32 - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - b"SYST\0" as *const u8 as *const libc::c_char, - ); - if result as u64 != 0 { + } + if entry_extracted { + if ((*ftpc).server_os).is_null() + && *dir.offset(0 as libc::c_int as isize) as libc::c_int != '/' as i32 + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + b"SYST\0" as *const u8 as *const libc::c_char, + ); + if result as u64 != 0 { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")( dir as *mut libc::c_void, ); - return result; - } - Curl_cfree.expect("non-null function pointer")( + #[cfg(CURLDEBUG)] + curl_dbg_free( + dir as *mut libc::c_void, + 2899 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return result; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")( (*ftpc).entrypath as *mut libc::c_void, ); - let ref mut fresh33 = (*ftpc).entrypath; - *fresh33 = 0 as *mut libc::c_char; - let ref mut fresh34 = (*ftpc).entrypath; - *fresh34 = dir; - Curl_infof( - data, - b"Entry path is '%s'\0" as *const u8 as *const libc::c_char, - (*ftpc).entrypath, - ); - let ref mut fresh35 = (*data).state.most_recent_ftp_entrypath; - *fresh35 = (*ftpc).entrypath; - _state(data, FTP_SYST); - current_block_187 = 10490607306284298299; - } else { + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).entrypath as *mut libc::c_void, + 2902 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh33 = (*ftpc).entrypath; + *fresh33 = 0 as *mut libc::c_char; + let ref mut fresh34 = (*ftpc).entrypath; + *fresh34 = dir; + Curl_infof( + data, + b"Entry path is '%s'\0" as *const u8 as *const libc::c_char, + (*ftpc).entrypath, + ); + let ref mut fresh35 = (*data).state.most_recent_ftp_entrypath; + *fresh35 = (*ftpc).entrypath; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_SYST); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_SYST, 2907 as libc::c_int); + current_block_187 = 10490607306284298299; + } else { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")( (*ftpc).entrypath as *mut libc::c_void, ); - let ref mut fresh36 = (*ftpc).entrypath; - *fresh36 = 0 as *mut libc::c_char; - let ref mut fresh37 = (*ftpc).entrypath; - *fresh37 = dir; - Curl_infof( - data, - b"Entry path is '%s'\0" as *const u8 as *const libc::c_char, - (*ftpc).entrypath, - ); - let ref mut fresh38 = (*data).state.most_recent_ftp_entrypath; - *fresh38 = (*ftpc).entrypath; + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).entrypath as *mut libc::c_void, + 2911 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh36 = (*ftpc).entrypath; + *fresh36 = 0 as *mut libc::c_char; + let ref mut fresh37 = (*ftpc).entrypath; + *fresh37 = dir; + Curl_infof( + data, + b"Entry path is '%s'\0" as *const u8 as *const libc::c_char, + (*ftpc).entrypath, + ); + let ref mut fresh38 = (*data).state.most_recent_ftp_entrypath; + *fresh38 = (*ftpc).entrypath; current_block_187 = 17917672080766325409; - } - } else { + } + } else { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")(dir as *mut libc::c_void); - Curl_infof( - data, - b"Failed to figure out path\0" as *const u8 as *const libc::c_char, - ); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + dir as *mut libc::c_void, + 2919 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + Curl_infof( + data, + b"Failed to figure out path\0" as *const u8 as *const libc::c_char, + ); current_block_187 = 17917672080766325409; - } - } else { + } + } else { current_block_187 = 17917672080766325409; - } + } match current_block_187 { 10490607306284298299 => {} - _ => { + _ => { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2923 as libc::c_int); + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"protocol connect phase DONE\0" as *const u8 as *const libc::c_char, + ); + } + } + } + 10 => { + if ftpcode == 215 as libc::c_int { + let mut ptr_0: *mut libc::c_char = &mut *((*data).state.buffer) + .offset(4 as libc::c_int as isize) + as *mut libc::c_char; + let mut os: *mut libc::c_char = 0 as *mut libc::c_char; + let mut store_0: *mut libc::c_char = 0 as *mut libc::c_char; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + os = Curl_cmalloc.expect("non-null function pointer")( + nread.wrapping_add(1 as libc::c_int as libc::c_ulong), + ) as *mut libc::c_char; + } + #[cfg(CURLDEBUG)] + _ => { + os = curl_dbg_malloc( + nread.wrapping_add(1 as libc::c_int as libc::c_ulong), + 2933 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut libc::c_char; + } } - } - } - 10 => { - if ftpcode == 215 as libc::c_int { - let mut ptr_0: *mut libc::c_char = &mut *((*data).state.buffer) - .offset(4 as libc::c_int as isize) - as *mut libc::c_char; - let mut os: *mut libc::c_char = 0 as *mut libc::c_char; - let mut store_0: *mut libc::c_char = 0 as *mut libc::c_char; - os = Curl_cmalloc.expect("non-null function pointer")( - nread.wrapping_add(1 as libc::c_int as libc::c_ulong), - ) as *mut libc::c_char; - if os.is_null() { - return CURLE_OUT_OF_MEMORY; - } - while *ptr_0 as libc::c_int == ' ' as i32 { - ptr_0 = ptr_0.offset(1); - } - store_0 = os; - while *ptr_0 as libc::c_int != 0 && *ptr_0 as libc::c_int != ' ' as i32 { - let fresh39 = ptr_0; - ptr_0 = ptr_0.offset(1); - let fresh40 = store_0; - store_0 = store_0.offset(1); - *fresh40 = *fresh39; - } + + if os.is_null() { + return CURLE_OUT_OF_MEMORY; + } + while *ptr_0 as libc::c_int == ' ' as i32 { + ptr_0 = ptr_0.offset(1); + } + store_0 = os; + while *ptr_0 as libc::c_int != 0 && *ptr_0 as libc::c_int != ' ' as i32 { + let fresh39 = ptr_0; + ptr_0 = ptr_0.offset(1); + let fresh40 = store_0; + store_0 = store_0.offset(1); + *fresh40 = *fresh39; + } *store_0 = '\0' as i32 as libc::c_char; - if Curl_strcasecompare(os, b"OS/400\0" as *const u8 as *const libc::c_char) != 0 - { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - b"SITE NAMEFMT 1\0" as *const u8 as *const libc::c_char, - ); - if result as u64 != 0 { + if Curl_strcasecompare(os, b"OS/400\0" as *const u8 as *const libc::c_char) != 0 + { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + b"SITE NAMEFMT 1\0" as *const u8 as *const libc::c_char, + ); + if result as u64 != 0 { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")(os as *mut libc::c_void); - return result; - } - Curl_cfree.expect("non-null function pointer")( + + #[cfg(CURLDEBUG)] + curl_dbg_free( + os as *mut libc::c_void, + 2952 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return result; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")( (*ftpc).server_os as *mut libc::c_void, ); - let ref mut fresh41 = (*ftpc).server_os; - *fresh41 = 0 as *mut libc::c_char; - let ref mut fresh42 = (*ftpc).server_os; - *fresh42 = os; - _state(data, FTP_NAMEFMT); - current_block_187 = 10490607306284298299; - } else { + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).server_os as *mut libc::c_void, + 2956 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh41 = (*ftpc).server_os; + *fresh41 = 0 as *mut libc::c_char; + let ref mut fresh42 = (*ftpc).server_os; + *fresh42 = os; + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_NAMEFMT); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_NAMEFMT, 2958 as libc::c_int); + current_block_187 = 10490607306284298299; + + } else { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")( (*ftpc).server_os as *mut libc::c_void, ); - let ref mut fresh43 = (*ftpc).server_os; - *fresh43 = 0 as *mut libc::c_char; - let ref mut fresh44 = (*ftpc).server_os; - *fresh44 = os; + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).server_os as *mut libc::c_void, + 2963 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh43 = (*ftpc).server_os; + *fresh43 = 0 as *mut libc::c_char; + let ref mut fresh44 = (*ftpc).server_os; + *fresh44 = os; current_block_187 = 6938158527927677584; - } - } else { + } + } else { current_block_187 = 6938158527927677584; - } + } match current_block_187 { - 10490607306284298299 => {} - _ => { - _state(data, FTP_STOP); - } - } - } - 11 => { - if ftpcode == 250 as libc::c_int { - ftp_state_pwd(data, conn); - } else { - _state(data, FTP_STOP); - } - } - 12 | 15 | 13 | 14 => { - if ftpcode >= 400 as libc::c_int && (*ftpc).count2 == 0 { - Curl_failf( - data, - b"QUOT command failed with %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - result = CURLE_QUOTE_ERROR; - } else { - result = ftp_state_quote(data, 0 as libc::c_int != 0, (*ftpc).state); - } - } - 16 => { - if ftpcode / 100 as libc::c_int != 2 as libc::c_int { - if (*data).set.ftp_create_missing_dirs != 0 - && (*ftpc).cwdcount != 0 - && (*ftpc).count2 == 0 - { - let ref mut fresh45 = (*ftpc).count2; - *fresh45 += 1; - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"MKD %s\0" as *const u8 as *const libc::c_char, - *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), - ); - if result as u64 == 0 { - _state(data, FTP_MKD); - } - } else { - Curl_failf( - data, - b"Server denied you to change to the given directory\0" as *const u8 - as *const libc::c_char, - ); - (*ftpc).cwdfail = 1 as libc::c_int != 0; - result = CURLE_REMOTE_ACCESS_DENIED; - } - } else { - (*ftpc).count2 = 0 as libc::c_int; - let ref mut fresh46 = (*ftpc).cwdcount; - *fresh46 += 1; - if *fresh46 <= (*ftpc).dirdepth { - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"CWD %s\0" as *const u8 as *const libc::c_char, - *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), - ); - } else { - result = ftp_state_mdtm(data); - } - } - } - 17 => { - if ftpcode / 100 as libc::c_int != 2 as libc::c_int && { - let ref mut fresh47 = (*ftpc).count3; - let fresh48 = *fresh47; - *fresh47 = *fresh47 - 1; - fresh48 == 0 - } { - Curl_failf( - data, - b"Failed to MKD dir: %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - result = CURLE_REMOTE_ACCESS_DENIED; - } else { - _state(data, FTP_CWD); - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"CWD %s\0" as *const u8 as *const libc::c_char, - *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), - ); - } - } - 18 => { - result = ftp_state_mdtm_resp(data, ftpcode); - } - 19 | 20 | 21 | 22 => { - result = ftp_state_type_resp(data, ftpcode, (*ftpc).state); - } - 23 | 24 | 25 => { - result = ftp_state_size_resp(data, ftpcode, (*ftpc).state); - } - 26 | 27 => { - result = ftp_state_rest_resp(data, conn, ftpcode, (*ftpc).state); - } - 29 => { - if ftpcode != 200 as libc::c_int { - Curl_failf( - data, - b"PRET command not accepted: %03d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - return CURLE_FTP_PRET_FAILED; - } - result = ftp_state_use_pasv(data, conn); - } - 30 => { - result = ftp_state_pasv_resp(data, ftpcode); - } - 28 => { - result = ftp_state_port_resp(data, ftpcode); - } - 31 | 32 => { - result = ftp_state_get_resp(data, ftpcode, (*ftpc).state); - } - 33 => { - result = ftp_state_stor_resp(data, ftpcode, (*ftpc).state); - } - 34 | _ => { + 10490607306284298299 => {} + _ => { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2970 as libc::c_int); + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"protocol connect phase DONE\0" as *const u8 as *const libc::c_char, + ); + } + } + } + 11 => { + if ftpcode == 250 as libc::c_int { + ftp_state_pwd(data, conn); + } else { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 2981 as libc::c_int); + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"protocol connect phase DONE\0" as *const u8 as *const libc::c_char, + ); + } + } + 12 | 15 | 13 | 14 => { + if ftpcode >= 400 as libc::c_int && (*ftpc).count2 == 0 { + Curl_failf( + data, + b"QUOT command failed with %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + result = CURLE_QUOTE_ERROR; + } else { + result = ftp_state_quote(data, 0 as libc::c_int != 0, (*ftpc).state); + } + } + 16 => { + if ftpcode / 100 as libc::c_int != 2 as libc::c_int { + if (*data).set.ftp_create_missing_dirs != 0 + && (*ftpc).cwdcount != 0 + && (*ftpc).count2 == 0 + { + let ref mut fresh45 = (*ftpc).count2; + *fresh45 += 1; + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"MKD %s\0" as *const u8 as *const libc::c_char, + *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_MKD); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_MKD, 3008 as libc::c_int); + } + } else { + Curl_failf( + data, + b"Server denied you to change to the given directory\0" as *const u8 + as *const libc::c_char, + ); + (*ftpc).cwdfail = 1 as libc::c_int != 0; + result = CURLE_REMOTE_ACCESS_DENIED; + } + } else { + (*ftpc).count2 = 0 as libc::c_int; + let ref mut fresh46 = (*ftpc).cwdcount; + *fresh46 += 1; + if *fresh46 <= (*ftpc).dirdepth { + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"CWD %s\0" as *const u8 as *const libc::c_char, + *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), + ); + } else { + result = ftp_state_mdtm(data); + } + } + } + 17 => { + if ftpcode / 100 as libc::c_int != 2 as libc::c_int && { + let ref mut fresh47 = (*ftpc).count3; + let fresh48 = *fresh47; + *fresh47 = *fresh47 - 1; + fresh48 == 0 + } { + Curl_failf( + data, + b"Failed to MKD dir: %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + result = CURLE_REMOTE_ACCESS_DENIED; + } else { + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_CWD); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_CWD, 3037 as libc::c_int); + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"CWD %s\0" as *const u8 as *const libc::c_char, + *((*ftpc).dirs).offset(((*ftpc).cwdcount - 1 as libc::c_int) as isize), + ); + } + } + 18 => { + result = ftp_state_mdtm_resp(data, ftpcode); + } + 19 | 20 | 21 | 22 => { + result = ftp_state_type_resp(data, ftpcode, (*ftpc).state); + } + 23 | 24 | 25 => { + result = ftp_state_size_resp(data, ftpcode, (*ftpc).state); + } + 26 | 27 => { + result = ftp_state_rest_resp(data, conn, ftpcode, (*ftpc).state); + } + 29 => { + if ftpcode != 200 as libc::c_int { + Curl_failf( + data, + b"PRET command not accepted: %03d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + return CURLE_FTP_PRET_FAILED; + } + result = ftp_state_use_pasv(data, conn); + } + 30 => { + result = ftp_state_pasv_resp(data, ftpcode); + } + 28 => { + result = ftp_state_port_resp(data, ftpcode); + } + 31 | 32 => { + result = ftp_state_get_resp(data, ftpcode, (*ftpc).state); + } + 33 => { + result = ftp_state_stor_resp(data, ftpcode, (*ftpc).state); + } + 34 | _ => { + #[cfg(not(DEBUGBUILD))] _state(data, FTP_STOP); - } - } - } - return result; -} -unsafe extern "C" fn ftp_multi_statemach( - mut data: *mut Curl_easy, - mut done: *mut bool, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut result: CURLcode = Curl_pp_statemach( - data, - &mut (*ftpc).pp, - 0 as libc::c_int != 0, - 0 as libc::c_int != 0, - ); - *done = if (*ftpc).state as libc::c_uint == FTP_STOP as libc::c_int as libc::c_uint { - 1 as libc::c_int - } else { - 0 as libc::c_int - } != 0; - return result; -} -unsafe extern "C" fn ftp_block_statemach( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - let mut result: CURLcode = CURLE_OK; + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 3096 as libc::c_int); + } + } + } + return result; + } + unsafe extern "C" fn ftp_multi_statemach( + mut data: *mut Curl_easy, + mut done: *mut bool, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut result: CURLcode = Curl_pp_statemach( + data, + &mut (*ftpc).pp, + 0 as libc::c_int != 0, + 0 as libc::c_int != 0, + ); + *done = if (*ftpc).state as libc::c_uint == FTP_STOP as libc::c_int as libc::c_uint { + 1 as libc::c_int + } else { + 0 as libc::c_int + } != 0; + return result; + } + unsafe extern "C" fn ftp_block_statemach( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + let mut result: CURLcode = CURLE_OK; // 解决clippy错误 loop { if (*ftpc).state as libc::c_uint == FTP_STOP as libc::c_int as libc::c_uint { break; } // while (*ftpc).state as libc::c_uint != FTP_STOP as libc::c_int as libc::c_uint { - result = Curl_pp_statemach(data, pp, 1 as libc::c_int != 0, 1 as libc::c_int != 0); - if result as u64 != 0 { - break; - } - } - return result; -} -unsafe extern "C" fn ftp_connect(mut data: *mut Curl_easy, mut done: *mut bool) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - *done = 0 as libc::c_int != 0; - Curl_conncontrol(conn, 0 as libc::c_int); - (*pp).response_time = (120 as libc::c_int * 1000 as libc::c_int) as timediff_t; - let ref mut fresh49 = (*pp).statemachine; - *fresh49 = Some( - ftp_statemachine as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata) -> CURLcode, - ); - let ref mut fresh50 = (*pp).endofresp; - *fresh50 = Some( - ftp_endofresp - as unsafe extern "C" fn( - *mut Curl_easy, - *mut connectdata, - *mut libc::c_char, - size_t, - *mut libc::c_int, - ) -> bool, - ); - if (*(*conn).handler).flags & ((1 as libc::c_int) << 0 as libc::c_int) as libc::c_uint != 0 { + result = Curl_pp_statemach(data, pp, 1 as libc::c_int != 0, 1 as libc::c_int != 0); + if result as u64 != 0 { + break; + } + } + return result; + } + unsafe extern "C" fn ftp_connect(mut data: *mut Curl_easy, mut done: *mut bool) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + *done = 0 as libc::c_int != 0; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 0 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 0 as libc::c_int, + b"FTP default\0" as *const u8 as *const libc::c_char, + ); + (*pp).response_time = (120 as libc::c_int * 1000 as libc::c_int) as timediff_t; + let ref mut fresh49 = (*pp).statemachine; + *fresh49 = Some( + ftp_statemachine as unsafe extern "C" fn(*mut Curl_easy, *mut connectdata) -> CURLcode, + ); + let ref mut fresh50 = (*pp).endofresp; + *fresh50 = Some( + ftp_endofresp + as unsafe extern "C" fn( + *mut Curl_easy, + *mut connectdata, + *mut libc::c_char, + size_t, + *mut libc::c_int, + ) -> bool, + ); + if (*(*conn).handler).flags & ((1 as libc::c_int) << 0 as libc::c_int) as libc::c_uint != 0 { // match () { // #[cfg(USE_SSL)] // _ => { @@ -3423,1204 +4032,1606 @@ unsafe extern "C" fn ftp_connect(mut data: *mut Curl_easy, mut done: *mut bool) // result = CURLE_NOT_BUILT_IN; // } // } - result = Curl_ssl_connect(data, conn, 0 as libc::c_int); - if result as u64 != 0 { - return result; - } - let ref mut fresh51 = (*conn).bits; - (*fresh51).set_ftp_use_control_ssl(1 as libc::c_int as bit); - } - Curl_pp_setup(pp); - Curl_pp_init(data, pp); - _state(data, FTP_WAIT220); - result = ftp_multi_statemach(data, done); - return result; -} -unsafe extern "C" fn ftp_done( - mut data: *mut Curl_easy, - mut status: CURLcode, - mut premature: bool, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - let mut nread: ssize_t = 0; - let mut ftpcode: libc::c_int = 0; - let mut result: CURLcode = CURLE_OK; - let mut rawPath: *mut libc::c_char = 0 as *mut libc::c_char; - let mut pathLen: size_t = 0 as libc::c_int as size_t; - if ftp.is_null() { - return CURLE_OK; - } - let mut current_block_5: u64; - match status as libc::c_uint { - 23 => { + result = Curl_ssl_connect(data, conn, 0 as libc::c_int); + if result as u64 != 0 { + return result; + } + let ref mut fresh51 = (*conn).bits; + (*fresh51).set_ftp_use_control_ssl(1 as libc::c_int as bit); + } + Curl_pp_setup(pp); + Curl_pp_init(data, pp); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_WAIT220); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_WAIT220, 3173 as libc::c_int); + result = ftp_multi_statemach(data, done); + return result; + } + unsafe extern "C" fn ftp_done( + mut data: *mut Curl_easy, + mut status: CURLcode, + mut premature: bool, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + let mut nread: ssize_t = 0; + let mut ftpcode: libc::c_int = 0; + let mut result: CURLcode = CURLE_OK; + let mut rawPath: *mut libc::c_char = 0 as *mut libc::c_char; + let mut pathLen: size_t = 0 as libc::c_int as size_t; + if ftp.is_null() { + return CURLE_OK; + } + let mut current_block_5: u64; + match status as libc::c_uint { + 23 => { current_block_5 = 17258398194053458658; - } - 36 | 13 | 30 | 10 | 12 | 17 | 19 | 18 | 25 | 9 | 63 | 78 | 0 => { + } + 36 | 13 | 30 | 10 | 12 | 17 | 19 | 18 | 25 | 9 | 63 | 78 | 0 => { current_block_5 = 17258398194053458658; - } - _ => { + } + _ => { current_block_5 = 8000488408776534573; - } - } - match current_block_5 { + } + } + match current_block_5 { 17258398194053458658 => { - if !premature { - current_block_5 = 6057473163062296781; - } else { + if !premature { + current_block_5 = 6057473163062296781; + } else { current_block_5 = 8000488408776534573; - } - } - _ => {} - } - match current_block_5 { + } + } + _ => {} + } + match current_block_5 { 8000488408776534573 => { - (*ftpc).ctl_valid = 0 as libc::c_int != 0; - (*ftpc).cwdfail = 1 as libc::c_int != 0; - Curl_conncontrol(conn, 1 as libc::c_int); - result = status; - } - _ => {} - } - if ((*data).state).wildcardmatch() != 0 { - if ((*data).set.chunk_end).is_some() && !((*ftpc).file).is_null() { - Curl_set_in_callback(data, 1 as libc::c_int != 0); - ((*data).set.chunk_end).expect("non-null function pointer")((*data).wildcard.customptr); - Curl_set_in_callback(data, 0 as libc::c_int != 0); - } - (*ftpc).known_filesize = -(1 as libc::c_int) as curl_off_t; - } - if result as u64 == 0 { - result = Curl_urldecode( - data, - (*ftp).path, - 0 as libc::c_int as size_t, - &mut rawPath, - &mut pathLen, - REJECT_CTRL, - ); - } - if result as u64 != 0 { - (*ftpc).ctl_valid = 0 as libc::c_int != 0; - Curl_conncontrol(conn, 1 as libc::c_int); - Curl_cfree.expect("non-null function pointer")((*ftpc).prevpath as *mut libc::c_void); - let ref mut fresh52 = (*ftpc).prevpath; - *fresh52 = 0 as *mut libc::c_char; - } else { - if (*data).set.ftp_filemethod as libc::c_uint - == FTPFILE_NOCWD as libc::c_int as libc::c_uint - && *rawPath.offset(0 as libc::c_int as isize) as libc::c_int == '/' as i32 - { + (*ftpc).ctl_valid = 0 as libc::c_int != 0; + (*ftpc).cwdfail = 1 as libc::c_int != 0; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 1 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 1 as libc::c_int, + b"FTP ended with bad error code\0" as *const u8 as *const libc::c_char, + ); + result = status; + } + _ => {} + } + if ((*data).state).wildcardmatch() != 0 { + if ((*data).set.chunk_end).is_some() && !((*ftpc).file).is_null() { + Curl_set_in_callback(data, 1 as libc::c_int != 0); + ((*data).set.chunk_end).expect("non-null function pointer")((*data).wildcard.customptr); + Curl_set_in_callback(data, 0 as libc::c_int != 0); + } + (*ftpc).known_filesize = -(1 as libc::c_int) as curl_off_t; + } + if result as u64 == 0 { + result = Curl_urldecode( + data, + (*ftp).path, + 0 as libc::c_int as size_t, + &mut rawPath, + &mut pathLen, + REJECT_CTRL, + ); + } + if result as u64 != 0 { + (*ftpc).ctl_valid = 0 as libc::c_int != 0; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 1 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 1 as libc::c_int, + b"FTP: out of memory!\0" as *const u8 as *const libc::c_char, + ); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).prevpath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).prevpath as *mut libc::c_void, + 3256 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh52 = (*ftpc).prevpath; + *fresh52 = 0 as *mut libc::c_char; + } else { + if (*data).set.ftp_filemethod as libc::c_uint + == FTPFILE_NOCWD as libc::c_int as libc::c_uint + && *rawPath.offset(0 as libc::c_int as isize) as libc::c_int == '/' as i32 + { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - } else { + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 3261 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } else { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")((*ftpc).prevpath as *mut libc::c_void); - if !(*ftpc).cwdfail { - if (*data).set.ftp_filemethod as libc::c_uint - == FTPFILE_NOCWD as libc::c_int as libc::c_uint - { - pathLen = 0 as libc::c_int as size_t; - } else { - pathLen = - (pathLen as libc::c_ulong).wrapping_sub(if !((*ftpc).file).is_null() { - strlen((*ftpc).file) - } else { - 0 as libc::c_int as libc::c_ulong - }) as size_t as size_t; - } + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).prevpath as *mut libc::c_void, + 3263 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + if !(*ftpc).cwdfail { + if (*data).set.ftp_filemethod as libc::c_uint + == FTPFILE_NOCWD as libc::c_int as libc::c_uint + { + pathLen = 0 as libc::c_int as size_t; + } else { + pathLen = + (pathLen as libc::c_ulong).wrapping_sub(if !((*ftpc).file).is_null() { + strlen((*ftpc).file) + } else { + 0 as libc::c_int as libc::c_ulong + }) as size_t as size_t; + } *rawPath.offset(pathLen as isize) = '\0' as i32 as libc::c_char; - let ref mut fresh53 = (*ftpc).prevpath; - *fresh53 = rawPath; - } else { + let ref mut fresh53 = (*ftpc).prevpath; + *fresh53 = rawPath; + } else { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - let ref mut fresh54 = (*ftpc).prevpath; - *fresh54 = 0 as *mut libc::c_char; - } - } - if !((*ftpc).prevpath).is_null() { - Curl_infof( - data, - b"Remembering we are in dir \"%s\"\0" as *const u8 as *const libc::c_char, - (*ftpc).prevpath, - ); - } - } - freedirs(ftpc); - if (*conn).sock[1 as libc::c_int as usize] != -(1 as libc::c_int) { - if result as u64 == 0 - && (*ftpc).dont_check as libc::c_int != 0 - && (*data).req.maxdownload > 0 as libc::c_int as libc::c_long - { - result = Curl_pp_sendf( - data, - pp, - b"%s\0" as *const u8 as *const libc::c_char, - b"ABOR\0" as *const u8 as *const libc::c_char, - ); - if result as u64 != 0 { - Curl_failf( - data, - b"Failure sending ABOR command: %s\0" as *const u8 as *const libc::c_char, - curl_easy_strerror(result), - ); - (*ftpc).ctl_valid = 0 as libc::c_int != 0; - Curl_conncontrol(conn, 1 as libc::c_int); - } - } - if ((*conn).ssl[1 as libc::c_int as usize]).use_0() != 0 { + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 3275 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh54 = (*ftpc).prevpath; + *fresh54 = 0 as *mut libc::c_char; + } + } + if !((*ftpc).prevpath).is_null() { + Curl_infof( + data, + b"Remembering we are in dir \"%s\"\0" as *const u8 as *const libc::c_char, + (*ftpc).prevpath, + ); + } + } + freedirs(ftpc); + if (*conn).sock[1 as libc::c_int as usize] != -(1 as libc::c_int) { + if result as u64 == 0 + && (*ftpc).dont_check as libc::c_int != 0 + && (*data).req.maxdownload > 0 as libc::c_int as libc::c_long + { + result = Curl_pp_sendf( + data, + pp, + b"%s\0" as *const u8 as *const libc::c_char, + b"ABOR\0" as *const u8 as *const libc::c_char, + ); + if result as u64 != 0 { + Curl_failf( + data, + b"Failure sending ABOR command: %s\0" as *const u8 as *const libc::c_char, + curl_easy_strerror(result), + ); + (*ftpc).ctl_valid = 0 as libc::c_int != 0; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 1 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 1 as libc::c_int, + b"ABOR command failed\0" as *const u8 as *const libc::c_char, + ); + } + } + if ((*conn).ssl[1 as libc::c_int as usize]).use_0() != 0 { #[cfg(USE_SSL)] - Curl_ssl_close(data, conn, 1 as libc::c_int); - } - close_secondarysocket(data, conn); - } - if result as u64 == 0 - && (*ftp).transfer as libc::c_uint == PPTRANSFER_BODY as libc::c_int as libc::c_uint - && (*ftpc).ctl_valid as libc::c_int != 0 - && (*pp).pending_resp as libc::c_int != 0 - && !premature - { - let mut old_time: timediff_t = (*pp).response_time; - (*pp).response_time = (60 as libc::c_int * 1000 as libc::c_int) as timediff_t; - (*pp).response = Curl_now(); - result = Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); - (*pp).response_time = old_time; - if nread == 0 - && CURLE_OPERATION_TIMEDOUT as libc::c_int as libc::c_uint == result as libc::c_uint - { - Curl_failf( - data, - b"control connection looks dead\0" as *const u8 as *const libc::c_char, - ); - (*ftpc).ctl_valid = 0 as libc::c_int != 0; - Curl_conncontrol(conn, 1 as libc::c_int); - } - if result as u64 != 0 { + Curl_ssl_close(data, conn, 1 as libc::c_int); + } + close_secondarysocket(data, conn); + } + if result as u64 == 0 + && (*ftp).transfer as libc::c_uint == PPTRANSFER_BODY as libc::c_int as libc::c_uint + && (*ftpc).ctl_valid as libc::c_int != 0 + && (*pp).pending_resp as libc::c_int != 0 + && !premature + { + let mut old_time: timediff_t = (*pp).response_time; + (*pp).response_time = (60 as libc::c_int * 1000 as libc::c_int) as timediff_t; + (*pp).response = Curl_now(); + result = Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); + (*pp).response_time = old_time; + if nread == 0 + && CURLE_OPERATION_TIMEDOUT as libc::c_int as libc::c_uint == result as libc::c_uint + { + Curl_failf( + data, + b"control connection looks dead\0" as *const u8 as *const libc::c_char, + ); + (*ftpc).ctl_valid = 0 as libc::c_int != 0; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 1 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 1 as libc::c_int, + b"Timeout or similar in FTP DONE operation\0" as *const u8 as *const libc::c_char, + ); + } + if result as u64 != 0 { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")((*ftp).pathalloc as *mut libc::c_void); - let ref mut fresh55 = (*ftp).pathalloc; - *fresh55 = 0 as *mut libc::c_char; - return result; - } - if (*ftpc).dont_check as libc::c_int != 0 - && (*data).req.maxdownload > 0 as libc::c_int as libc::c_long - { - Curl_infof( - data, - b"partial download completed, closing connection\0" as *const u8 - as *const libc::c_char, - ); - Curl_conncontrol(conn, 1 as libc::c_int); - return result; - } - if !(*ftpc).dont_check { - match ftpcode { - 226 | 250 => {} - 552 => { - Curl_failf( - data, - b"Exceeded storage allocation\0" as *const u8 as *const libc::c_char, - ); - result = CURLE_REMOTE_DISK_FULL; - } - _ => { - Curl_failf( - data, - b"server did not report OK, got %d\0" as *const u8 as *const libc::c_char, - ftpcode, - ); - result = CURLE_PARTIAL_FILE; - } - } - } - } - if !(result as libc::c_uint != 0 || premature as libc::c_int != 0) { - if ((*data).set).upload() != 0 { - if -(1 as libc::c_int) as libc::c_long != (*data).state.infilesize - && (*data).state.infilesize != (*data).req.writebytecount - && ((*data).set).crlf() == 0 - && (*ftp).transfer as libc::c_uint == PPTRANSFER_BODY as libc::c_int as libc::c_uint - { - Curl_failf( - data, - b"Uploaded unaligned file size (%ld out of %ld bytes)\0" as *const u8 - as *const libc::c_char, - (*data).req.bytecount, - (*data).state.infilesize, - ); - result = CURLE_PARTIAL_FILE; - } + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftp).pathalloc as *mut libc::c_void, + 3340 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh55 = (*ftp).pathalloc; + *fresh55 = 0 as *mut libc::c_char; + return result; + } + if (*ftpc).dont_check as libc::c_int != 0 + && (*data).req.maxdownload > 0 as libc::c_int as libc::c_long + { + Curl_infof( + data, + b"partial download completed, closing connection\0" as *const u8 + as *const libc::c_char, + ); + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 1 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 1 as libc::c_int, + b"Partial download with no ability to check\0" as *const u8 as *const libc::c_char, + ); + return result; + } + if !(*ftpc).dont_check { + match ftpcode { + 226 | 250 => {} + 552 => { + Curl_failf( + data, + b"Exceeded storage allocation\0" as *const u8 as *const libc::c_char, + ); + result = CURLE_REMOTE_DISK_FULL; + } + _ => { + Curl_failf( + data, + b"server did not report OK, got %d\0" as *const u8 as *const libc::c_char, + ftpcode, + ); + result = CURLE_PARTIAL_FILE; + } + } + } + } + if !(result as libc::c_uint != 0 || premature as libc::c_int != 0) { + if ((*data).set).upload() != 0 { + if -(1 as libc::c_int) as libc::c_long != (*data).state.infilesize + && (*data).state.infilesize != (*data).req.writebytecount + && ((*data).set).crlf() == 0 + && (*ftp).transfer as libc::c_uint == PPTRANSFER_BODY as libc::c_int as libc::c_uint + { + Curl_failf( + data, + b"Uploaded unaligned file size (%ld out of %ld bytes)\0" as *const u8 + as *const libc::c_char, + (*data).req.bytecount, + (*data).state.infilesize, + ); + result = CURLE_PARTIAL_FILE; + } } else { let flag: bool = if cfg!(CURL_DO_LINEEND_CONV) { -(1 as libc::c_int) as libc::c_long != (*data).req.size - && (*data).req.size != (*data).req.bytecount - && (*data).req.size + (*data).state.crlf_conversions != (*data).req.bytecount - && (*data).req.maxdownload != (*data).req.bytecount + && (*data).req.size != (*data).req.bytecount + && (*data).req.size + (*data).state.crlf_conversions != (*data).req.bytecount + && (*data).req.maxdownload != (*data).req.bytecount } else { -(1 as libc::c_int) as libc::c_long != (*data).req.size && (*data).req.size != (*data).req.bytecount && (*data).req.maxdownload != (*data).req.bytecount }; if flag - { - Curl_failf( - data, - b"Received only partial file: %ld bytes\0" as *const u8 as *const libc::c_char, - (*data).req.bytecount, - ); - result = CURLE_PARTIAL_FILE; - } else if !(*ftpc).dont_check - && (*data).req.bytecount == 0 - && (*data).req.size > 0 as libc::c_int as libc::c_long - { - Curl_failf( - data, - b"No data was received!\0" as *const u8 as *const libc::c_char, - ); - result = CURLE_FTP_COULDNT_RETR_FILE; - } - } - } - (*ftp).transfer = PPTRANSFER_BODY; - (*ftpc).dont_check = 0 as libc::c_int != 0; - if status as u64 == 0 && result as u64 == 0 && !premature && !((*data).set.postquote).is_null() - { - result = ftp_sendquote(data, conn, (*data).set.postquote); - } - Curl_cfree.expect("non-null function pointer")((*ftp).pathalloc as *mut libc::c_void); - let ref mut fresh56 = (*ftp).pathalloc; - *fresh56 = 0 as *mut libc::c_char; - return result; -} -unsafe extern "C" fn ftp_sendquote( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut quote: *mut curl_slist, -) -> CURLcode { - let mut item: *mut curl_slist = 0 as *mut curl_slist; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - item = quote; - while !item.is_null() { - if !((*item).data).is_null() { - let mut nread: ssize_t = 0; - let mut cmd: *mut libc::c_char = (*item).data; - let mut acceptfail: bool = 0 as libc::c_int != 0; - let mut result: CURLcode = CURLE_OK; - let mut ftpcode: libc::c_int = 0 as libc::c_int; - if *cmd.offset(0 as libc::c_int as isize) as libc::c_int == '*' as i32 { - cmd = cmd.offset(1); - acceptfail = 1 as libc::c_int != 0; - } - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - cmd, - ); - if result as u64 == 0 { - (*pp).response = Curl_now(); - result = Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); - } - if result as u64 != 0 { - return result; - } - if !acceptfail && ftpcode >= 400 as libc::c_int { - Curl_failf( - data, - b"QUOT string not accepted: %s\0" as *const u8 as *const libc::c_char, - cmd, - ); - return CURLE_QUOTE_ERROR; - } - } - item = (*item).next; - } - return CURLE_OK; -} -unsafe extern "C" fn ftp_need_type( - mut conn: *mut connectdata, - mut ascii_wanted: bool, -) -> libc::c_int { - return ((*conn).proto.ftpc.transfertype as libc::c_int - != (if ascii_wanted as libc::c_int != 0 { - 'A' as i32 - } else { - 'I' as i32 - })) as libc::c_int; -} -unsafe extern "C" fn ftp_nb_type( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut ascii: bool, - mut newstate: ftpstate, -) -> CURLcode { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut result: CURLcode = CURLE_OK; - let mut want: libc::c_char = (if ascii as libc::c_int != 0 { - 'A' as i32 - } else { - 'I' as i32 - }) as libc::c_char; - if (*ftpc).transfertype as libc::c_int == want as libc::c_int { + { + Curl_failf( + data, + b"Received only partial file: %ld bytes\0" as *const u8 as *const libc::c_char, + (*data).req.bytecount, + ); + result = CURLE_PARTIAL_FILE; + } else if !(*ftpc).dont_check + && (*data).req.bytecount == 0 + && (*data).req.size > 0 as libc::c_int as libc::c_long + { + Curl_failf( + data, + b"No data was received!\0" as *const u8 as *const libc::c_char, + ); + result = CURLE_FTP_COULDNT_RETR_FILE; + } + } + } + (*ftp).transfer = PPTRANSFER_BODY; + (*ftpc).dont_check = 0 as libc::c_int != 0; + if status as u64 == 0 && result as u64 == 0 && !premature && !((*data).set.postquote).is_null() + { + result = ftp_sendquote(data, conn, (*data).set.postquote); + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftp).pathalloc as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftp).pathalloc as *mut libc::c_void, + 3416 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh56 = (*ftp).pathalloc; + *fresh56 = 0 as *mut libc::c_char; + return result; + } + unsafe extern "C" fn ftp_sendquote( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut quote: *mut curl_slist, + ) -> CURLcode { + let mut item: *mut curl_slist = 0 as *mut curl_slist; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + item = quote; + while !item.is_null() { + if !((*item).data).is_null() { + let mut nread: ssize_t = 0; + let mut cmd: *mut libc::c_char = (*item).data; + let mut acceptfail: bool = 0 as libc::c_int != 0; + let mut result: CURLcode = CURLE_OK; + let mut ftpcode: libc::c_int = 0 as libc::c_int; + if *cmd.offset(0 as libc::c_int as isize) as libc::c_int == '*' as i32 { + cmd = cmd.offset(1); + acceptfail = 1 as libc::c_int != 0; + } + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + cmd, + ); + if result as u64 == 0 { + (*pp).response = Curl_now(); + result = Curl_GetFTPResponse(data, &mut nread, &mut ftpcode); + } + if result as u64 != 0 { + return result; + } + if !acceptfail && ftpcode >= 400 as libc::c_int { + Curl_failf( + data, + b"QUOT string not accepted: %s\0" as *const u8 as *const libc::c_char, + cmd, + ); + return CURLE_QUOTE_ERROR; + } + } + item = (*item).next; + } + return CURLE_OK; + } + unsafe extern "C" fn ftp_need_type( + mut conn: *mut connectdata, + mut ascii_wanted: bool, + ) -> libc::c_int { + return ((*conn).proto.ftpc.transfertype as libc::c_int + != (if ascii_wanted as libc::c_int != 0 { + 'A' as i32 + } else { + 'I' as i32 + })) as libc::c_int; + } + unsafe extern "C" fn ftp_nb_type( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut ascii: bool, + mut newstate: ftpstate, + ) -> CURLcode { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut result: CURLcode = CURLE_OK; + let mut want: libc::c_char = (if ascii as libc::c_int != 0 { + 'A' as i32 + } else { + 'I' as i32 + }) as libc::c_char; + if (*ftpc).transfertype as libc::c_int == want as libc::c_int { + #[cfg(not(DEBUGBUILD))] _state(data, newstate); - return ftp_state_type_resp(data, 200 as libc::c_int, newstate); - } - result = Curl_pp_sendf( - data, - &mut (*ftpc).pp as *mut pingpong, - b"TYPE %c\0" as *const u8 as *const libc::c_char, - want as libc::c_int, - ); - if result as u64 == 0 { + + #[cfg(DEBUGBUILD)] + _state(data, newstate, 3506 as libc::c_int); + return ftp_state_type_resp(data, 200 as libc::c_int, newstate); + } + result = Curl_pp_sendf( + data, + &mut (*ftpc).pp as *mut pingpong, + b"TYPE %c\0" as *const u8 as *const libc::c_char, + want as libc::c_int, + ); + if result as u64 == 0 { + #[cfg(not(DEBUGBUILD))] _state(data, newstate); - (*ftpc).transfertype = want; - } - return result; -} + + #[cfg(DEBUGBUILD)] + _state(data, newstate, 3512 as libc::c_int); + (*ftpc).transfertype = want; + } + return result; + } #[cfg(not(CURL_DISABLE_VERBOSE_STRINGS))] -unsafe extern "C" fn ftp_pasv_verbose( - mut data: *mut Curl_easy, - mut ai: *mut Curl_addrinfo, - mut newhost: *mut libc::c_char, - mut port: libc::c_int, -) { - let mut buf: [libc::c_char; 256] = [0; 256]; - Curl_printable_address( - ai, - buf.as_mut_ptr(), - ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, - ); - Curl_infof( - data, - b"Connecting to %s (%s) port %d\0" as *const u8 as *const libc::c_char, - newhost, - buf.as_mut_ptr(), - port, - ); -} -unsafe extern "C" fn ftp_do_more( - mut data: *mut Curl_easy, - mut completep: *mut libc::c_int, -) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut result: CURLcode = CURLE_OK; - let mut connected: bool = 0 as libc::c_int != 0; - let mut complete: bool = 0 as libc::c_int != 0; - let mut ftp: *mut FTP = (*data).req.p.ftp; - if !(*conn).bits.tcpconnect[1 as libc::c_int as usize] { + unsafe extern "C" fn ftp_pasv_verbose( + mut data: *mut Curl_easy, + mut ai: *mut Curl_addrinfo, + mut newhost: *mut libc::c_char, + mut port: libc::c_int, + ) { + let mut buf: [libc::c_char; 256] = [0; 256]; + Curl_printable_address( + ai, + buf.as_mut_ptr(), + ::std::mem::size_of::<[libc::c_char; 256]>() as libc::c_ulong, + ); + Curl_infof( + data, + b"Connecting to %s (%s) port %d\0" as *const u8 as *const libc::c_char, + newhost, + buf.as_mut_ptr(), + port, + ); + } + unsafe extern "C" fn ftp_do_more( + mut data: *mut Curl_easy, + mut completep: *mut libc::c_int, + ) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut result: CURLcode = CURLE_OK; + let mut connected: bool = 0 as libc::c_int != 0; + let mut complete: bool = 0 as libc::c_int != 0; + let mut ftp: *mut FTP = (*data).req.p.ftp; + if !(*conn).bits.tcpconnect[1 as libc::c_int as usize] { #[cfg(not(CURL_DISABLE_PROXY))] - if Curl_connect_ongoing(conn) { - result = Curl_proxyCONNECT( - data, - 1 as libc::c_int, - 0 as *const libc::c_char, - 0 as libc::c_int, - ); - return result; - } - result = Curl_is_connected(data, conn, 1 as libc::c_int, &mut connected); - if connected { - } else { - if result as libc::c_uint != 0 && (*ftpc).count1 == 0 as libc::c_int { - *completep = -(1 as libc::c_int); - return ftp_epsv_disable(data, conn); - } - return result; - } - } + if Curl_connect_ongoing(conn) { + result = Curl_proxyCONNECT( + data, + 1 as libc::c_int, + 0 as *const libc::c_char, + 0 as libc::c_int, + ); + return result; + } + result = Curl_is_connected(data, conn, 1 as libc::c_int, &mut connected); + if connected { + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"DO-MORE connected phase starts\0" as *const u8 as *const libc::c_char, + ); + } else { + if result as libc::c_uint != 0 && (*ftpc).count1 == 0 as libc::c_int { + *completep = -(1 as libc::c_int); + return ftp_epsv_disable(data, conn); + } + return result; + } + } match () { #[cfg(not(CURL_DISABLE_PROXY))] _ => { - result = Curl_proxy_connect(data, 1 as libc::c_int); - if result as u64 != 0 { - return result; - } - if (*conn).http_proxy.proxytype as libc::c_uint - == CURLPROXY_HTTPS as libc::c_int as libc::c_uint - && !(*conn).bits.proxy_ssl_connected[1 as libc::c_int as usize] - { - return result; - } - if ((*conn).bits).tunnel_proxy() as libc::c_int != 0 - && ((*conn).bits).httpproxy() as libc::c_int != 0 - && Curl_connect_ongoing(conn) as libc::c_int != 0 - { - return result; - } + result = Curl_proxy_connect(data, 1 as libc::c_int); + if result as u64 != 0 { + return result; + } + if (*conn).http_proxy.proxytype as libc::c_uint + == CURLPROXY_HTTPS as libc::c_int as libc::c_uint + && !(*conn).bits.proxy_ssl_connected[1 as libc::c_int as usize] + { + return result; + } + if ((*conn).bits).tunnel_proxy() as libc::c_int != 0 + && ((*conn).bits).httpproxy() as libc::c_int != 0 + && Curl_connect_ongoing(conn) as libc::c_int != 0 + { + return result; + } } #[cfg(CURL_DISABLE_PROXY)] _ => { } } - if (*ftpc).state as u64 != 0 { - result = ftp_multi_statemach(data, &mut complete); - *completep = complete as libc::c_int; - if result as libc::c_uint != 0 || !(*ftpc).wait_data_conn { - return result; - } - *completep = 0 as libc::c_int; - } - if (*ftp).transfer as libc::c_uint <= PPTRANSFER_INFO as libc::c_int as libc::c_uint { - if (*ftpc).wait_data_conn as libc::c_int == 1 as libc::c_int { - let mut serv_conned: bool = false; - result = ReceivedServerConnect(data, &mut serv_conned); - if result as u64 != 0 { - return result; - } - if serv_conned { - result = AcceptServerConnect(data); - (*ftpc).wait_data_conn = 0 as libc::c_int != 0; - if result as u64 == 0 { - result = InitiateTransfer(data); - } - if result as u64 != 0 { - return result; - } - *completep = 1 as libc::c_int; - } - } else if ((*data).set).upload() != 0 { - result = ftp_nb_type( - data, - conn, - ((*data).state).prefer_ascii() != 0, - FTP_STOR_TYPE, - ); - if result as u64 != 0 { - return result; - } - result = ftp_multi_statemach(data, &mut complete); - if (*ftpc).wait_data_conn { - *completep = 0 as libc::c_int; - } else { - *completep = complete as libc::c_int; - } - } else { - (*ftp).downloadsize = -(1 as libc::c_int) as curl_off_t; - result = Curl_range(data); - if result as libc::c_uint == CURLE_OK as libc::c_int as libc::c_uint - && (*data).req.maxdownload >= 0 as libc::c_int as libc::c_long - { - (*ftpc).dont_check = 1 as libc::c_int != 0; + if (*ftpc).state as u64 != 0 { + result = ftp_multi_statemach(data, &mut complete); + *completep = complete as libc::c_int; + if result as libc::c_uint != 0 || !(*ftpc).wait_data_conn { + return result; + } + *completep = 0 as libc::c_int; + } + if (*ftp).transfer as libc::c_uint <= PPTRANSFER_INFO as libc::c_int as libc::c_uint { + if (*ftpc).wait_data_conn as libc::c_int == 1 as libc::c_int { + let mut serv_conned: bool = false; + result = ReceivedServerConnect(data, &mut serv_conned); + if result as u64 != 0 { + return result; + } + if serv_conned { + result = AcceptServerConnect(data); + (*ftpc).wait_data_conn = 0 as libc::c_int != 0; + if result as u64 == 0 { + result = InitiateTransfer(data); + } + if result as u64 != 0 { + return result; + } + *completep = 1 as libc::c_int; + } + } else if ((*data).set).upload() != 0 { + result = ftp_nb_type( + data, + conn, + ((*data).state).prefer_ascii() != 0, + FTP_STOR_TYPE, + ); + if result as u64 != 0 { + return result; + } + result = ftp_multi_statemach(data, &mut complete); + if (*ftpc).wait_data_conn { + *completep = 0 as libc::c_int; + } else { + *completep = complete as libc::c_int; + } + } else { + (*ftp).downloadsize = -(1 as libc::c_int) as curl_off_t; + result = Curl_range(data); + if result as libc::c_uint == CURLE_OK as libc::c_int as libc::c_uint + && (*data).req.maxdownload >= 0 as libc::c_int as libc::c_long + { + (*ftpc).dont_check = 1 as libc::c_int != 0; + } + if !(result as u64 != 0) { + if ((*data).state).list_only() as libc::c_int != 0 || ((*ftpc).file).is_null() { + if (*ftp).transfer as libc::c_uint + == PPTRANSFER_BODY as libc::c_int as libc::c_uint + { + result = ftp_nb_type(data, conn, 1 as libc::c_int != 0, FTP_LIST_TYPE); + if result as u64 != 0 { + return result; + } + } + } else { + result = ftp_nb_type( + data, + conn, + ((*data).state).prefer_ascii() != 0, + FTP_RETR_TYPE, + ); + if result as u64 != 0 { + return result; + } + } + } + result = ftp_multi_statemach(data, &mut complete); + *completep = complete as libc::c_int; + } + return result; + } + Curl_setup_transfer( + data, + -(1 as libc::c_int), + -(1 as libc::c_int) as curl_off_t, + 0 as libc::c_int != 0, + -(1 as libc::c_int), + ); + if !(*ftpc).wait_data_conn { + *completep = 1 as libc::c_int; + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"DO-MORE phase ends with %d\0" as *const u8 as *const libc::c_char, + result as libc::c_int, + ); + } + return result; + } + unsafe extern "C" fn ftp_perform( + mut data: *mut Curl_easy, + mut connected: *mut bool, + mut dophase_done: *mut bool, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"DO phase starts\0" as *const u8 as *const libc::c_char, + ); + if ((*data).set).opt_no_body() != 0 { + let mut ftp: *mut FTP = (*data).req.p.ftp; + (*ftp).transfer = PPTRANSFER_INFO; + } + *dophase_done = 0 as libc::c_int != 0; + result = ftp_state_quote(data, 1 as libc::c_int != 0, FTP_QUOTE); + if result as u64 != 0 { + return result; + } + result = ftp_multi_statemach(data, dophase_done); + *connected = (*conn).bits.tcpconnect[1 as libc::c_int as usize]; + Curl_infof( + data, + b"ftp_perform ends with SECONDARY: %d\0" as *const u8 as *const libc::c_char, + *connected as libc::c_int, + ); + #[cfg(DEBUGBUILD)] + if *dophase_done { + Curl_infof( + data, + b"DO phase is complete1\0" as *const u8 as *const libc::c_char, + ); + } + return result; + } + unsafe extern "C" fn wc_data_dtor(mut ptr: *mut libc::c_void) { + let mut ftpwc: *mut ftp_wc = ptr as *mut ftp_wc; + if !ftpwc.is_null() && !((*ftpwc).parser).is_null() { + Curl_ftp_parselist_data_free(&mut (*ftpwc).parser); + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(ftpwc as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + ftpwc as *mut libc::c_void, + 3764 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + unsafe extern "C" fn init_wc_data(mut data: *mut Curl_easy) -> CURLcode { + let mut last_slash: *mut libc::c_char = 0 as *mut libc::c_char; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut path: *mut libc::c_char = (*ftp).path; + let mut wildcard: *mut WildcardData = &mut (*data).wildcard; + let mut result: CURLcode = CURLE_OK; + let mut ftpwc: *mut ftp_wc = 0 as *mut ftp_wc; + last_slash = strrchr((*ftp).path, '/' as i32); + if !last_slash.is_null() { + last_slash = last_slash.offset(1); + if *last_slash.offset(0 as libc::c_int as isize) as libc::c_int == '\0' as i32 { + (*wildcard).state = CURLWC_CLEAN; + result = ftp_parse_url_path(data); + return result; + } + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*wildcard).pattern = Curl_cstrdup.expect("non-null function pointer")(last_slash); + } - if !(result as u64 != 0) { - if ((*data).state).list_only() as libc::c_int != 0 || ((*ftpc).file).is_null() { - if (*ftp).transfer as libc::c_uint - == PPTRANSFER_BODY as libc::c_int as libc::c_uint - { - result = ftp_nb_type(data, conn, 1 as libc::c_int != 0, FTP_LIST_TYPE); - if result as u64 != 0 { - return result; - } - } - } else { - result = ftp_nb_type( - data, - conn, - ((*data).state).prefer_ascii() != 0, - FTP_RETR_TYPE, - ); - if result as u64 != 0 { - return result; - } - } + #[cfg(CURLDEBUG)] + _ => { + (*wildcard).pattern = curl_dbg_strdup( + last_slash, + 3784 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); } - result = ftp_multi_statemach(data, &mut complete); - *completep = complete as libc::c_int; - } - return result; - } - Curl_setup_transfer( - data, - -(1 as libc::c_int), - -(1 as libc::c_int) as curl_off_t, - 0 as libc::c_int != 0, - -(1 as libc::c_int), - ); - if !(*ftpc).wait_data_conn { - *completep = 1 as libc::c_int; - } - return result; -} -unsafe extern "C" fn ftp_perform( - mut data: *mut Curl_easy, - mut connected: *mut bool, - mut dophase_done: *mut bool, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - if ((*data).set).opt_no_body() != 0 { - let mut ftp: *mut FTP = (*data).req.p.ftp; - (*ftp).transfer = PPTRANSFER_INFO; - } - *dophase_done = 0 as libc::c_int != 0; - result = ftp_state_quote(data, 1 as libc::c_int != 0, FTP_QUOTE); - if result as u64 != 0 { - return result; - } - result = ftp_multi_statemach(data, dophase_done); - *connected = (*conn).bits.tcpconnect[1 as libc::c_int as usize]; - Curl_infof( - data, - b"ftp_perform ends with SECONDARY: %d\0" as *const u8 as *const libc::c_char, - *connected as libc::c_int, - ); - *dophase_done; - return result; -} -unsafe extern "C" fn wc_data_dtor(mut ptr: *mut libc::c_void) { - let mut ftpwc: *mut ftp_wc = ptr as *mut ftp_wc; - if !ftpwc.is_null() && !((*ftpwc).parser).is_null() { - Curl_ftp_parselist_data_free(&mut (*ftpwc).parser); - } - Curl_cfree.expect("non-null function pointer")(ftpwc as *mut libc::c_void); -} -unsafe extern "C" fn init_wc_data(mut data: *mut Curl_easy) -> CURLcode { - let mut last_slash: *mut libc::c_char = 0 as *mut libc::c_char; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut path: *mut libc::c_char = (*ftp).path; - let mut wildcard: *mut WildcardData = &mut (*data).wildcard; - let mut result: CURLcode = CURLE_OK; - let mut ftpwc: *mut ftp_wc = 0 as *mut ftp_wc; - last_slash = strrchr((*ftp).path, '/' as i32); - if !last_slash.is_null() { - last_slash = last_slash.offset(1); - if *last_slash.offset(0 as libc::c_int as isize) as libc::c_int == '\0' as i32 { - (*wildcard).state = CURLWC_CLEAN; - result = ftp_parse_url_path(data); - return result; - } - let ref mut fresh57 = (*wildcard).pattern; - *fresh57 = Curl_cstrdup.expect("non-null function pointer")(last_slash); - if ((*wildcard).pattern).is_null() { - return CURLE_OUT_OF_MEMORY; } + + if ((*wildcard).pattern).is_null() { + return CURLE_OUT_OF_MEMORY; + } *last_slash.offset(0 as libc::c_int as isize) = '\0' as i32 as libc::c_char; - } else if *path.offset(0 as libc::c_int as isize) != 0 { - let ref mut fresh58 = (*wildcard).pattern; - *fresh58 = Curl_cstrdup.expect("non-null function pointer")(path); - if ((*wildcard).pattern).is_null() { - return CURLE_OUT_OF_MEMORY; - } - *path.offset(0 as libc::c_int as isize) = '\0' as i32 as libc::c_char; - } else { - (*wildcard).state = CURLWC_CLEAN; - result = ftp_parse_url_path(data); - return result; - } - ftpwc = Curl_ccalloc.expect("non-null function pointer")( - 1 as libc::c_int as size_t, - ::std::mem::size_of::() as libc::c_ulong, - ) as *mut ftp_wc; - if ftpwc.is_null() { - result = CURLE_OUT_OF_MEMORY; - } else { - let ref mut fresh59 = (*ftpwc).parser; - *fresh59 = Curl_ftp_parselist_data_alloc(); - if ((*ftpwc).parser).is_null() { - result = CURLE_OUT_OF_MEMORY; - } else { - let ref mut fresh60 = (*wildcard).protdata; - *fresh60 = ftpwc as *mut libc::c_void; - let ref mut fresh61 = (*wildcard).dtor; - *fresh61 = Some(wc_data_dtor as unsafe extern "C" fn(*mut libc::c_void) -> ()); - if (*data).set.ftp_filemethod as libc::c_uint - == FTPFILE_NOCWD as libc::c_int as libc::c_uint - { - (*data).set.ftp_filemethod = FTPFILE_MULTICWD; + } else if *path.offset(0 as libc::c_int as isize) != 0 { + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*wildcard).pattern = Curl_cstrdup.expect("non-null function pointer")(path); + } - result = ftp_parse_url_path(data); - if !(result as u64 != 0) { - let ref mut fresh62 = (*wildcard).path; - *fresh62 = Curl_cstrdup.expect("non-null function pointer")((*ftp).path); - if ((*wildcard).path).is_null() { - result = CURLE_OUT_OF_MEMORY; - } else { - let ref mut fresh63 = (*ftpwc).backup.write_function; - *fresh63 = (*data).set.fwrite_func; - let ref mut fresh64 = (*data).set.fwrite_func; - *fresh64 = Some( - Curl_ftp_parselist - as unsafe extern "C" fn( - *mut libc::c_char, - size_t, - size_t, - *mut libc::c_void, - ) -> size_t, - ); - let ref mut fresh65 = (*ftpwc).backup.file_descriptor; - *fresh65 = (*data).set.out as *mut FILE; - let ref mut fresh66 = (*data).set.out; - *fresh66 = data as *mut libc::c_void; - Curl_infof( - data, - b"Wildcard - Parsing started\0" as *const u8 as *const libc::c_char, - ); - return CURLE_OK; - } + #[cfg(CURLDEBUG)] + _ => { + (*wildcard).pattern = curl_dbg_strdup( + path, + 3791 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); } } + + if ((*wildcard).pattern).is_null() { + return CURLE_OUT_OF_MEMORY; + } + *path.offset(0 as libc::c_int as isize) = '\0' as i32 as libc::c_char; + } else { + (*wildcard).state = CURLWC_CLEAN; + result = ftp_parse_url_path(data); + return result; + } + match () { + #[cfg(not(CURLDEBUG))] + _ => { + ftpwc = Curl_ccalloc.expect("non-null function pointer")( + 1 as libc::c_int as size_t, + ::std::mem::size_of::() as libc::c_ulong, + ) as *mut ftp_wc; + } + #[cfg(CURLDEBUG)] + _ => { + ftpwc = curl_dbg_calloc( + 1 as libc::c_int as size_t, + ::std::mem::size_of::() as libc::c_ulong, + 3807 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut ftp_wc; + } } - if !ftpwc.is_null() { - Curl_ftp_parselist_data_free(&mut (*ftpwc).parser); - Curl_cfree.expect("non-null function pointer")(ftpwc as *mut libc::c_void); - } - Curl_cfree.expect("non-null function pointer")((*wildcard).pattern as *mut libc::c_void); - let ref mut fresh67 = (*wildcard).pattern; - *fresh67 = 0 as *mut libc::c_char; - let ref mut fresh68 = (*wildcard).dtor; - *fresh68 = None; - let ref mut fresh69 = (*wildcard).protdata; - *fresh69 = 0 as *mut libc::c_void; - return result; -} -unsafe extern "C" fn wc_statemach(mut data: *mut Curl_easy) -> CURLcode { - let wildcard: *mut WildcardData = &mut (*data).wildcard; - let mut conn: *mut connectdata = (*data).conn; - let mut result: CURLcode = CURLE_OK; - let mut current_block_53: u64; - loop { - match (*wildcard).state as libc::c_uint { - 1 => { - result = init_wc_data(data); - if (*wildcard).state as libc::c_uint == CURLWC_CLEAN as libc::c_int as libc::c_uint - { - return result; - } - (*wildcard).state = (if result as libc::c_uint != 0 { - CURLWC_ERROR as libc::c_int - } else { - CURLWC_MATCHING as libc::c_int - }) as wildcard_states; - return result; - } - 2 => { - let mut ftpwc: *mut ftp_wc = (*wildcard).protdata as *mut ftp_wc; - let ref mut fresh70 = (*data).set.fwrite_func; - *fresh70 = (*ftpwc).backup.write_function; - let ref mut fresh71 = (*data).set.out; - *fresh71 = (*ftpwc).backup.file_descriptor as *mut libc::c_void; - let ref mut fresh72 = (*ftpwc).backup.write_function; - *fresh72 = None; - let ref mut fresh73 = (*ftpwc).backup.file_descriptor; - *fresh73 = 0 as *mut FILE; - (*wildcard).state = CURLWC_DOWNLOADING; - if Curl_ftp_parselist_geterror((*ftpwc).parser) as u64 != 0 { - (*wildcard).state = CURLWC_CLEAN; - } else if (*wildcard).filelist.size == 0 as libc::c_int as libc::c_ulong { - (*wildcard).state = CURLWC_CLEAN; - return CURLE_REMOTE_FILE_NOT_FOUND; - } - } - 3 => { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut finfo: *mut curl_fileinfo = - (*(*wildcard).filelist.head).ptr as *mut curl_fileinfo; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut tmp_path: *mut libc::c_char = curl_maprintf( - b"%s%s\0" as *const u8 as *const libc::c_char, - (*wildcard).path, - (*finfo).filename, - ); - if tmp_path.is_null() { - return CURLE_OUT_OF_MEMORY; + + if ftpwc.is_null() { + result = CURLE_OUT_OF_MEMORY; + } else { + let ref mut fresh59 = (*ftpwc).parser; + *fresh59 = Curl_ftp_parselist_data_alloc(); + if ((*ftpwc).parser).is_null() { + result = CURLE_OUT_OF_MEMORY; + } else { + let ref mut fresh60 = (*wildcard).protdata; + *fresh60 = ftpwc as *mut libc::c_void; + let ref mut fresh61 = (*wildcard).dtor; + *fresh61 = Some(wc_data_dtor as unsafe extern "C" fn(*mut libc::c_void) -> ()); + if (*data).set.ftp_filemethod as libc::c_uint + == FTPFILE_NOCWD as libc::c_int as libc::c_uint + { + (*data).set.ftp_filemethod = FTPFILE_MULTICWD; + } + result = ftp_parse_url_path(data); + if !(result as u64 != 0) { + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*wildcard).path = Curl_cstrdup.expect("non-null function pointer")((*ftp).path); + + } + #[cfg(CURLDEBUG)] + _ => { + (*wildcard).path = curl_dbg_strdup( + (*ftp).path, + 3833 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } } - Curl_cfree.expect("non-null function pointer")( + + if ((*wildcard).path).is_null() { + result = CURLE_OUT_OF_MEMORY; + } else { + let ref mut fresh63 = (*ftpwc).backup.write_function; + *fresh63 = (*data).set.fwrite_func; + let ref mut fresh64 = (*data).set.fwrite_func; + *fresh64 = Some( + Curl_ftp_parselist + as unsafe extern "C" fn( + *mut libc::c_char, + size_t, + size_t, + *mut libc::c_void, + ) -> size_t, + ); + let ref mut fresh65 = (*ftpwc).backup.file_descriptor; + *fresh65 = (*data).set.out as *mut FILE; + let ref mut fresh66 = (*data).set.out; + *fresh66 = data as *mut libc::c_void; + Curl_infof( + data, + b"Wildcard - Parsing started\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OK; + } + } + } + } + if !ftpwc.is_null() { + Curl_ftp_parselist_data_free(&mut (*ftpwc).parser); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(ftpwc as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + + curl_dbg_free( + ftpwc as *mut libc::c_void, + 3854 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*wildcard).pattern as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + + curl_dbg_free( + (*wildcard).pattern as *mut libc::c_void, + 3856 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh67 = (*wildcard).pattern; + *fresh67 = 0 as *mut libc::c_char; + let ref mut fresh68 = (*wildcard).dtor; + *fresh68 = None; + let ref mut fresh69 = (*wildcard).protdata; + *fresh69 = 0 as *mut libc::c_void; + return result; + } + unsafe extern "C" fn wc_statemach(mut data: *mut Curl_easy) -> CURLcode { + let wildcard: *mut WildcardData = &mut (*data).wildcard; + let mut conn: *mut connectdata = (*data).conn; + let mut result: CURLcode = CURLE_OK; + let mut current_block_53: u64; + loop { + match (*wildcard).state as libc::c_uint { + 1 => { + result = init_wc_data(data); + if (*wildcard).state as libc::c_uint == CURLWC_CLEAN as libc::c_int as libc::c_uint + { + return result; + } + (*wildcard).state = (if result as libc::c_uint != 0 { + CURLWC_ERROR as libc::c_int + } else { + CURLWC_MATCHING as libc::c_int + }) as wildcard_states; + return result; + } + 2 => { + let mut ftpwc: *mut ftp_wc = (*wildcard).protdata as *mut ftp_wc; + let ref mut fresh70 = (*data).set.fwrite_func; + *fresh70 = (*ftpwc).backup.write_function; + let ref mut fresh71 = (*data).set.out; + *fresh71 = (*ftpwc).backup.file_descriptor as *mut libc::c_void; + let ref mut fresh72 = (*ftpwc).backup.write_function; + *fresh72 = None; + let ref mut fresh73 = (*ftpwc).backup.file_descriptor; + *fresh73 = 0 as *mut FILE; + (*wildcard).state = CURLWC_DOWNLOADING; + if Curl_ftp_parselist_geterror((*ftpwc).parser) as u64 != 0 { + (*wildcard).state = CURLWC_CLEAN; + } else if (*wildcard).filelist.size == 0 as libc::c_int as libc::c_ulong { + (*wildcard).state = CURLWC_CLEAN; + return CURLE_REMOTE_FILE_NOT_FOUND; + } + } + 3 => { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut finfo: *mut curl_fileinfo = + (*(*wildcard).filelist.head).ptr as *mut curl_fileinfo; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut tmp_path: *mut libc::c_char = curl_maprintf( + b"%s%s\0" as *const u8 as *const libc::c_char, + (*wildcard).path, + (*finfo).filename, + ); + if tmp_path.is_null() { + return CURLE_OUT_OF_MEMORY; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")( (*ftp).pathalloc as *mut libc::c_void, ); - let ref mut fresh74 = (*ftp).path; - *fresh74 = tmp_path; - let ref mut fresh75 = (*ftp).pathalloc; - *fresh75 = *fresh74; - Curl_infof( - data, - b"Wildcard - START of \"%s\"\0" as *const u8 as *const libc::c_char, - (*finfo).filename, - ); - if ((*data).set.chunk_bgn).is_some() { - let mut userresponse: libc::c_long = 0; - Curl_set_in_callback(data, 1 as libc::c_int != 0); - userresponse = ((*data).set.chunk_bgn).expect("non-null function pointer")( - finfo as *const libc::c_void, - (*wildcard).customptr, - (*wildcard).filelist.size as libc::c_int, - ); - Curl_set_in_callback(data, 0 as libc::c_int != 0); - match userresponse { - 2 => { + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftp).pathalloc as *mut libc::c_void, + 3912 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh74 = (*ftp).path; + *fresh74 = tmp_path; + let ref mut fresh75 = (*ftp).pathalloc; + *fresh75 = *fresh74; + Curl_infof( + data, + b"Wildcard - START of \"%s\"\0" as *const u8 as *const libc::c_char, + (*finfo).filename, + ); + if ((*data).set.chunk_bgn).is_some() { + let mut userresponse: libc::c_long = 0; + Curl_set_in_callback(data, 1 as libc::c_int != 0); + userresponse = ((*data).set.chunk_bgn).expect("non-null function pointer")( + finfo as *const libc::c_void, + (*wildcard).customptr, + (*wildcard).filelist.size as libc::c_int, + ); + Curl_set_in_callback(data, 0 as libc::c_int != 0); + match userresponse { + 2 => { current_block_53 = 3773843889947583363; - match current_block_53 { + match current_block_53 { 8041137041727403147 => return CURLE_CHUNK_FAILED, - _ => { - Curl_infof( - data, - b"Wildcard - \"%s\" skipped by user\0" as *const u8 - as *const libc::c_char, - (*finfo).filename, - ); - (*wildcard).state = CURLWC_SKIP; - continue; - } - } - } - 1 => { + _ => { + Curl_infof( + data, + b"Wildcard - \"%s\" skipped by user\0" as *const u8 + as *const libc::c_char, + (*finfo).filename, + ); + (*wildcard).state = CURLWC_SKIP; + continue; + } + } + } + 1 => { current_block_53 = 8041137041727403147; - match current_block_53 { + match current_block_53 { 8041137041727403147 => return CURLE_CHUNK_FAILED, - _ => { - Curl_infof( - data, - b"Wildcard - \"%s\" skipped by user\0" as *const u8 - as *const libc::c_char, - (*finfo).filename, - ); - (*wildcard).state = CURLWC_SKIP; - continue; - } - } - } - _ => {} - } - } - if (*finfo).filetype as libc::c_uint - != CURLFILETYPE_FILE as libc::c_int as libc::c_uint - { - (*wildcard).state = CURLWC_SKIP; - } else { - if (*finfo).flags & ((1 as libc::c_int) << 6 as libc::c_int) as libc::c_uint - != 0 - { - (*ftpc).known_filesize = (*finfo).size; - } - result = ftp_parse_url_path(data); - if result as u64 != 0 { - return result; - } - Curl_llist_remove( - &mut (*wildcard).filelist, - (*wildcard).filelist.head, - 0 as *mut libc::c_void, - ); - if (*wildcard).filelist.size == 0 as libc::c_int as libc::c_ulong { - (*wildcard).state = CURLWC_CLEAN; - return CURLE_OK; - } - return result; - } - } - 5 => { - if ((*data).set.chunk_end).is_some() { - Curl_set_in_callback(data, 1 as libc::c_int != 0); - ((*data).set.chunk_end).expect("non-null function pointer")( - (*data).wildcard.customptr, - ); - Curl_set_in_callback(data, 0 as libc::c_int != 0); - } - Curl_llist_remove( - &mut (*wildcard).filelist, - (*wildcard).filelist.head, - 0 as *mut libc::c_void, - ); - (*wildcard).state = - (if (*wildcard).filelist.size == 0 as libc::c_int as libc::c_ulong { - CURLWC_CLEAN as libc::c_int - } else { - CURLWC_DOWNLOADING as libc::c_int - }) as wildcard_states; - } - 4 => { - let mut ftpwc_0: *mut ftp_wc = (*wildcard).protdata as *mut ftp_wc; - result = CURLE_OK; - if !ftpwc_0.is_null() { - result = Curl_ftp_parselist_geterror((*ftpwc_0).parser); - } - (*wildcard).state = (if result as libc::c_uint != 0 { - CURLWC_ERROR as libc::c_int - } else { - CURLWC_DONE as libc::c_int - }) as wildcard_states; - return result; - } - 7 | 6 | 0 => { - if ((*wildcard).dtor).is_some() { - ((*wildcard).dtor).expect("non-null function pointer")((*wildcard).protdata); - } - return result; - } - _ => {} - } - } -} -unsafe extern "C" fn ftp_do(mut data: *mut Curl_easy, mut done: *mut bool) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - *done = 0 as libc::c_int != 0; - (*ftpc).wait_data_conn = 0 as libc::c_int != 0; - if ((*data).state).wildcardmatch() != 0 { - result = wc_statemach(data); - if (*data).wildcard.state as libc::c_uint == CURLWC_SKIP as libc::c_int as libc::c_uint - || (*data).wildcard.state as libc::c_uint == CURLWC_DONE as libc::c_int as libc::c_uint - { - return CURLE_OK; - } - if result as u64 != 0 { - return result; - } - } else { - result = ftp_parse_url_path(data); - if result as u64 != 0 { - return result; - } - } - result = ftp_regular_transfer(data, done); - return result; -} -unsafe extern "C" fn ftp_quit(mut data: *mut Curl_easy, mut conn: *mut connectdata) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - if (*conn).proto.ftpc.ctl_valid { - result = Curl_pp_sendf( - data, - &mut (*conn).proto.ftpc.pp as *mut pingpong, - b"%s\0" as *const u8 as *const libc::c_char, - b"QUIT\0" as *const u8 as *const libc::c_char, - ); - if result as u64 != 0 { - Curl_failf( - data, - b"Failure sending QUIT command: %s\0" as *const u8 as *const libc::c_char, - curl_easy_strerror(result), - ); - (*conn).proto.ftpc.ctl_valid = 0 as libc::c_int != 0; - Curl_conncontrol(conn, 1 as libc::c_int); - _state(data, FTP_STOP); - return result; - } - _state(data, FTP_QUIT); - result = ftp_block_statemach(data, conn); - } - return result; -} -unsafe extern "C" fn ftp_disconnect( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, - mut dead_connection: bool, -) -> CURLcode { - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut pp: *mut pingpong = &mut (*ftpc).pp; - if dead_connection { - (*ftpc).ctl_valid = 0 as libc::c_int != 0; - } - ftp_quit(data, conn); - if !((*ftpc).entrypath).is_null() { - if (*data).state.most_recent_ftp_entrypath == (*ftpc).entrypath { - let ref mut fresh76 = (*data).state.most_recent_ftp_entrypath; - *fresh76 = 0 as *mut libc::c_char; - } - Curl_cfree.expect("non-null function pointer")((*ftpc).entrypath as *mut libc::c_void); - let ref mut fresh77 = (*ftpc).entrypath; - *fresh77 = 0 as *mut libc::c_char; - } - freedirs(ftpc); - Curl_cfree.expect("non-null function pointer")((*ftpc).prevpath as *mut libc::c_void); - let ref mut fresh78 = (*ftpc).prevpath; - *fresh78 = 0 as *mut libc::c_char; - Curl_cfree.expect("non-null function pointer")((*ftpc).server_os as *mut libc::c_void); - let ref mut fresh79 = (*ftpc).server_os; - *fresh79 = 0 as *mut libc::c_char; - Curl_pp_disconnect(pp); + _ => { + Curl_infof( + data, + b"Wildcard - \"%s\" skipped by user\0" as *const u8 + as *const libc::c_char, + (*finfo).filename, + ); + (*wildcard).state = CURLWC_SKIP; + continue; + } + } + } + _ => {} + } + } + if (*finfo).filetype as libc::c_uint + != CURLFILETYPE_FILE as libc::c_int as libc::c_uint + { + (*wildcard).state = CURLWC_SKIP; + } else { + if (*finfo).flags & ((1 as libc::c_int) << 6 as libc::c_int) as libc::c_uint + != 0 + { + (*ftpc).known_filesize = (*finfo).size; + } + result = ftp_parse_url_path(data); + if result as u64 != 0 { + return result; + } + Curl_llist_remove( + &mut (*wildcard).filelist, + (*wildcard).filelist.head, + 0 as *mut libc::c_void, + ); + if (*wildcard).filelist.size == 0 as libc::c_int as libc::c_ulong { + (*wildcard).state = CURLWC_CLEAN; + return CURLE_OK; + } + return result; + } + } + 5 => { + if ((*data).set.chunk_end).is_some() { + Curl_set_in_callback(data, 1 as libc::c_int != 0); + ((*data).set.chunk_end).expect("non-null function pointer")( + (*data).wildcard.customptr, + ); + Curl_set_in_callback(data, 0 as libc::c_int != 0); + } + Curl_llist_remove( + &mut (*wildcard).filelist, + (*wildcard).filelist.head, + 0 as *mut libc::c_void, + ); + (*wildcard).state = + (if (*wildcard).filelist.size == 0 as libc::c_int as libc::c_ulong { + CURLWC_CLEAN as libc::c_int + } else { + CURLWC_DOWNLOADING as libc::c_int + }) as wildcard_states; + } + 4 => { + let mut ftpwc_0: *mut ftp_wc = (*wildcard).protdata as *mut ftp_wc; + result = CURLE_OK; + if !ftpwc_0.is_null() { + result = Curl_ftp_parselist_geterror((*ftpwc_0).parser); + } + (*wildcard).state = (if result as libc::c_uint != 0 { + CURLWC_ERROR as libc::c_int + } else { + CURLWC_DONE as libc::c_int + }) as wildcard_states; + return result; + } + 7 | 6 | 0 => { + if ((*wildcard).dtor).is_some() { + ((*wildcard).dtor).expect("non-null function pointer")((*wildcard).protdata); + } + return result; + } + _ => {} + } + } + } + unsafe extern "C" fn ftp_do(mut data: *mut Curl_easy, mut done: *mut bool) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + *done = 0 as libc::c_int != 0; + (*ftpc).wait_data_conn = 0 as libc::c_int != 0; + if ((*data).state).wildcardmatch() != 0 { + result = wc_statemach(data); + if (*data).wildcard.state as libc::c_uint == CURLWC_SKIP as libc::c_int as libc::c_uint + || (*data).wildcard.state as libc::c_uint == CURLWC_DONE as libc::c_int as libc::c_uint + { + return CURLE_OK; + } + if result as u64 != 0 { + return result; + } + } else { + result = ftp_parse_url_path(data); + if result as u64 != 0 { + return result; + } + } + result = ftp_regular_transfer(data, done); + return result; + } + unsafe extern "C" fn ftp_quit(mut data: *mut Curl_easy, mut conn: *mut connectdata) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + if (*conn).proto.ftpc.ctl_valid { + result = Curl_pp_sendf( + data, + &mut (*conn).proto.ftpc.pp as *mut pingpong, + b"%s\0" as *const u8 as *const libc::c_char, + b"QUIT\0" as *const u8 as *const libc::c_char, + ); + if result as u64 != 0 { + Curl_failf( + data, + b"Failure sending QUIT command: %s\0" as *const u8 as *const libc::c_char, + curl_easy_strerror(result), + ); + (*conn).proto.ftpc.ctl_valid = 0 as libc::c_int != 0; + #[cfg(not(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS))))] + Curl_conncontrol(conn, 1 as libc::c_int); + +#[cfg(all(DEBUGBUILD, not(CURL_DISABLE_VERBOSE_STRINGS)))] + Curl_conncontrol( + conn, + 1 as libc::c_int, + b"QUIT command failed\0" as *const u8 as *const libc::c_char, + ); + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_STOP); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_STOP, 4050 as libc::c_int); + return result; + } + #[cfg(not(DEBUGBUILD))] + _state(data, FTP_QUIT); + + #[cfg(DEBUGBUILD)] + _state(data, FTP_QUIT, 4054 as libc::c_int); + result = ftp_block_statemach(data, conn); + } + return result; + } + unsafe extern "C" fn ftp_disconnect( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + mut dead_connection: bool, + ) -> CURLcode { + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut pp: *mut pingpong = &mut (*ftpc).pp; + if dead_connection { + (*ftpc).ctl_valid = 0 as libc::c_int != 0; + } + ftp_quit(data, conn); + if !((*ftpc).entrypath).is_null() { + if (*data).state.most_recent_ftp_entrypath == (*ftpc).entrypath { + let ref mut fresh76 = (*data).state.most_recent_ftp_entrypath; + *fresh76 = 0 as *mut libc::c_char; + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).entrypath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).entrypath as *mut libc::c_void, + 4093 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh77 = (*ftpc).entrypath; + *fresh77 = 0 as *mut libc::c_char; + } + freedirs(ftpc); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).prevpath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).prevpath as *mut libc::c_void, + 4097 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh78 = (*ftpc).prevpath; + *fresh78 = 0 as *mut libc::c_char; + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")((*ftpc).server_os as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + (*ftpc).server_os as *mut libc::c_void, + 4098 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + let ref mut fresh79 = (*ftpc).server_os; + *fresh79 = 0 as *mut libc::c_char; + Curl_pp_disconnect(pp); #[cfg(HAVE_GSSAPI)] Curl_sec_end(conn); - return CURLE_OK; -} -unsafe extern "C" fn ftp_parse_url_path(mut data: *mut Curl_easy) -> CURLcode { - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - let mut slashPos: *const libc::c_char = 0 as *const libc::c_char; - let mut fileName: *const libc::c_char = 0 as *const libc::c_char; - let mut result: CURLcode = CURLE_OK; - let mut rawPath: *mut libc::c_char = 0 as *mut libc::c_char; - let mut pathLen: size_t = 0 as libc::c_int as size_t; - (*ftpc).ctl_valid = 0 as libc::c_int != 0; - (*ftpc).cwdfail = 0 as libc::c_int != 0; - result = Curl_urldecode( - data, - (*ftp).path, - 0 as libc::c_int as size_t, - &mut rawPath, - &mut pathLen, - REJECT_CTRL, - ); - if result as u64 != 0 { - return result; - } - match (*data).set.ftp_filemethod as libc::c_uint { - 2 => { - if pathLen > 0 as libc::c_int as libc::c_ulong - && *rawPath.offset(pathLen.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize) - as libc::c_int - != '/' as i32 - { - fileName = rawPath; - } - } - 3 => { - slashPos = strrchr(rawPath, '/' as i32); - if !slashPos.is_null() { - let mut dirlen: size_t = slashPos.offset_from(rawPath) as libc::c_long as size_t; - if dirlen == 0 as libc::c_int as libc::c_ulong { - dirlen = dirlen.wrapping_add(1); - } - let ref mut fresh80 = (*ftpc).dirs; - *fresh80 = Curl_ccalloc.expect("non-null function pointer")( - 1 as libc::c_int as size_t, - ::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, - ) as *mut *mut libc::c_char; - if ((*ftpc).dirs).is_null() { - Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - return CURLE_OUT_OF_MEMORY; + return CURLE_OK; + } + unsafe extern "C" fn ftp_parse_url_path(mut data: *mut Curl_easy) -> CURLcode { + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + let mut slashPos: *const libc::c_char = 0 as *const libc::c_char; + let mut fileName: *const libc::c_char = 0 as *const libc::c_char; + let mut result: CURLcode = CURLE_OK; + let mut rawPath: *mut libc::c_char = 0 as *mut libc::c_char; + let mut pathLen: size_t = 0 as libc::c_int as size_t; + (*ftpc).ctl_valid = 0 as libc::c_int != 0; + (*ftpc).cwdfail = 0 as libc::c_int != 0; + result = Curl_urldecode( + data, + (*ftp).path, + 0 as libc::c_int as size_t, + &mut rawPath, + &mut pathLen, + REJECT_CTRL, + ); + if result as u64 != 0 { + return result; + } + match (*data).set.ftp_filemethod as libc::c_uint { + 2 => { + if pathLen > 0 as libc::c_int as libc::c_ulong + && *rawPath.offset(pathLen.wrapping_sub(1 as libc::c_int as libc::c_ulong) as isize) + as libc::c_int + != '/' as i32 + { + fileName = rawPath; + } + } + 3 => { + slashPos = strrchr(rawPath, '/' as i32); + if !slashPos.is_null() { + let mut dirlen: size_t = slashPos.offset_from(rawPath) as libc::c_long as size_t; + if dirlen == 0 as libc::c_int as libc::c_ulong { + dirlen = dirlen.wrapping_add(1); + } + + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).dirs = Curl_ccalloc.expect("non-null function pointer")( + 1 as libc::c_int as size_t, + ::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, + ) as *mut *mut libc::c_char; + } + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).dirs = curl_dbg_calloc( + 1 as libc::c_int as size_t, + ::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, + 4153 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut *mut libc::c_char; + } } - let ref mut fresh81 = *((*ftpc).dirs).offset(0 as libc::c_int as isize); - *fresh81 = Curl_ccalloc.expect("non-null function pointer")( - 1 as libc::c_int as size_t, - dirlen.wrapping_add(1 as libc::c_int as libc::c_ulong), - ) as *mut libc::c_char; - if (*((*ftpc).dirs).offset(0 as libc::c_int as isize)).is_null() { + + if ((*ftpc).dirs).is_null() { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - return CURLE_OUT_OF_MEMORY; - } - strncpy( - *((*ftpc).dirs).offset(0 as libc::c_int as isize), - rawPath, - dirlen, - ); - (*ftpc).dirdepth = 1 as libc::c_int; - fileName = slashPos.offset(1 as libc::c_int as isize); - } else { - fileName = rawPath; - } - } - 1 | _ => { - let mut curPos: *const libc::c_char = rawPath; - let mut dirAlloc: libc::c_int = 0 as libc::c_int; - let mut str: *const libc::c_char = rawPath; - while *str as libc::c_int != 0 as libc::c_int { - if *str as libc::c_int == '/' as i32 { - dirAlloc += 1; + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 4155 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OUT_OF_MEMORY; + } + match () { + #[cfg(not(CURLDEBUG))] + _ => { + *((*ftpc).dirs).offset(0 as libc::c_int as isize) = Curl_ccalloc.expect("non-null function pointer")( + 1 as libc::c_int as size_t, + dirlen.wrapping_add(1 as libc::c_int as libc::c_ulong), + ) as *mut libc::c_char; + } + #[cfg(CURLDEBUG)] + _ => { + *((*ftpc).dirs).offset(0 as libc::c_int as isize) = curl_dbg_calloc( + 1 as libc::c_int as size_t, + dirlen.wrapping_add(1 as libc::c_int as libc::c_ulong), + 4159 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut libc::c_char; + } } - str = str.offset(1); - } - if dirAlloc > 0 as libc::c_int { - let ref mut fresh82 = (*ftpc).dirs; - *fresh82 = Curl_ccalloc.expect("non-null function pointer")( - dirAlloc as size_t, - ::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, - ) as *mut *mut libc::c_char; - if ((*ftpc).dirs).is_null() { + + if (*((*ftpc).dirs).offset(0 as libc::c_int as isize)).is_null() { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - return CURLE_OUT_OF_MEMORY; - } - loop { - slashPos = strchr(curPos, '/' as i32); - if slashPos.is_null() { - break; + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 4161 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OUT_OF_MEMORY; + } + strncpy( + *((*ftpc).dirs).offset(0 as libc::c_int as isize), + rawPath, + dirlen, + ); + (*ftpc).dirdepth = 1 as libc::c_int; + fileName = slashPos.offset(1 as libc::c_int as isize); + } else { + fileName = rawPath; + } + } + 1 | _ => { + let mut curPos: *const libc::c_char = rawPath; + let mut dirAlloc: libc::c_int = 0 as libc::c_int; + let mut str: *const libc::c_char = rawPath; + while *str as libc::c_int != 0 as libc::c_int { + if *str as libc::c_int == '/' as i32 { + dirAlloc += 1; + } + str = str.offset(1); + } + if dirAlloc > 0 as libc::c_int { + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).dirs = Curl_ccalloc.expect("non-null function pointer")( + dirAlloc as size_t, + ::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, + ) as *mut *mut libc::c_char; } - let mut compLen: size_t = - slashPos.offset_from(curPos) as libc::c_long as size_t; - if compLen == 0 as libc::c_int as libc::c_ulong - && (*ftpc).dirdepth == 0 as libc::c_int - { - compLen = compLen.wrapping_add(1); + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).dirs = curl_dbg_calloc( + dirAlloc as size_t, + ::std::mem::size_of::<*mut libc::c_char>() as libc::c_ulong, + 4185 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut *mut libc::c_char; } - if compLen > 0 as libc::c_int as libc::c_ulong { + } + + if ((*ftpc).dirs).is_null() { + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 4187 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OUT_OF_MEMORY; + } + loop { + slashPos = strchr(curPos, '/' as i32); + if slashPos.is_null() { + break; + } + let mut compLen: size_t = + slashPos.offset_from(curPos) as libc::c_long as size_t; + if compLen == 0 as libc::c_int as libc::c_ulong + && (*ftpc).dirdepth == 0 as libc::c_int + { + compLen = compLen.wrapping_add(1); + } + if compLen > 0 as libc::c_int as libc::c_ulong { + #[cfg(not(CURLDEBUG))] let mut comp: *mut libc::c_char = - Curl_ccalloc.expect("non-null function pointer")( - 1 as libc::c_int as size_t, - compLen.wrapping_add(1 as libc::c_int as libc::c_ulong), - ) as *mut libc::c_char; - if comp.is_null() { + Curl_ccalloc.expect("non-null function pointer")( + 1 as libc::c_int as size_t, + compLen.wrapping_add(1 as libc::c_int as libc::c_ulong), + ) as *mut libc::c_char; + #[cfg(CURLDEBUG)] + let mut comp: *mut libc::c_char = curl_dbg_calloc( + 1 as libc::c_int as size_t, + compLen.wrapping_add(1 as libc::c_int as libc::c_ulong), + 4203 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) + as *mut libc::c_char; + if comp.is_null() { + #[cfg(not(CURLDEBUG))] Curl_cfree.expect("non-null function pointer")( rawPath as *mut libc::c_void, ); - return CURLE_OUT_OF_MEMORY; - } - strncpy(comp, curPos, compLen); - let ref mut fresh83 = (*ftpc).dirdepth; - let fresh84 = *fresh83; - *fresh83 = *fresh83 + 1; - let ref mut fresh85 = *((*ftpc).dirs).offset(fresh84 as isize); - *fresh85 = comp; - } - curPos = slashPos.offset(1 as libc::c_int as isize); - } - } - fileName = curPos; - } - } - if !fileName.is_null() && *fileName as libc::c_int != 0 { - let ref mut fresh86 = (*ftpc).file; - *fresh86 = Curl_cstrdup.expect("non-null function pointer")(fileName); - } else { - let ref mut fresh87 = (*ftpc).file; - *fresh87 = 0 as *mut libc::c_char; - } - if ((*data).set).upload() as libc::c_int != 0 - && ((*ftpc).file).is_null() - && (*ftp).transfer as libc::c_uint == PPTRANSFER_BODY as libc::c_int as libc::c_uint - { - Curl_failf( - data, - b"Uploading to a URL without a file name!\0" as *const u8 as *const libc::c_char, - ); - Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - return CURLE_URL_MALFORMAT; - } - (*ftpc).cwddone = 0 as libc::c_int != 0; - if (*data).set.ftp_filemethod as libc::c_uint == FTPFILE_NOCWD as libc::c_int as libc::c_uint - && *rawPath.offset(0 as libc::c_int as isize) as libc::c_int == '/' as i32 - { - (*ftpc).cwddone = 1 as libc::c_int != 0; - } else { - let mut oldPath: *const libc::c_char = if ((*conn).bits).reuse() as libc::c_int != 0 { - (*ftpc).prevpath as *const libc::c_char - } else { - b"\0" as *const u8 as *const libc::c_char - }; - if !oldPath.is_null() { - let mut n: size_t = pathLen; - if (*data).set.ftp_filemethod as libc::c_uint - == FTPFILE_NOCWD as libc::c_int as libc::c_uint - { - n = 0 as libc::c_int as size_t; - } else { - n = (n as libc::c_ulong).wrapping_sub(if !((*ftpc).file).is_null() { - strlen((*ftpc).file) - } else { - 0 as libc::c_int as libc::c_ulong - }) as size_t as size_t; + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 4205 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OUT_OF_MEMORY; + } + strncpy(comp, curPos, compLen); + let ref mut fresh83 = (*ftpc).dirdepth; + let fresh84 = *fresh83; + *fresh83 = *fresh83 + 1; + let ref mut fresh85 = *((*ftpc).dirs).offset(fresh84 as isize); + *fresh85 = comp; + } + curPos = slashPos.offset(1 as libc::c_int as isize); + } + } + #[cfg(all(DEBUGBUILD, HAVE_ASSERT_H))] + if (*ftpc).dirdepth <= dirAlloc { + } else { + __assert_fail( + b"ftpc->dirdepth <= dirAlloc\0" as *const u8 as *const libc::c_char, + b"ftp.c\0" as *const u8 as *const libc::c_char, + 4214 as libc::c_int as libc::c_uint, + (*::std::mem::transmute::<&[u8; 48], &[libc::c_char; 48]>( + b"CURLcode ftp_parse_url_path(struct Curl_easy *)\0", + )) + .as_ptr(), + ); + } + fileName = curPos; + } + } + if !fileName.is_null() && *fileName as libc::c_int != 0 { + match () { + #[cfg(not(CURLDEBUG))] + _ => { + (*ftpc).file = Curl_cstrdup.expect("non-null function pointer")(fileName); + } - if strlen(oldPath) == n && strncmp(rawPath, oldPath, n) == 0 { - Curl_infof( - data, - b"Request has same path as previous transfer\0" as *const u8 - as *const libc::c_char, + #[cfg(CURLDEBUG)] + _ => { + (*ftpc).file = curl_dbg_strdup( + fileName, + 4221 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, ); - (*ftpc).cwddone = 1 as libc::c_int != 0; } } - } - Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); - return CURLE_OK; -} -unsafe extern "C" fn ftp_dophase_done(mut data: *mut Curl_easy, mut connected: bool) -> CURLcode { - let mut conn: *mut connectdata = (*data).conn; - let mut ftp: *mut FTP = (*data).req.p.ftp; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - if connected { - let mut completed: libc::c_int = 0; - let mut result: CURLcode = ftp_do_more(data, &mut completed); - if result as u64 != 0 { - close_secondarysocket(data, conn); - return result; - } - } - if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint { - Curl_setup_transfer( - data, - -(1 as libc::c_int), - -(1 as libc::c_int) as curl_off_t, - 0 as libc::c_int != 0, - -(1 as libc::c_int), - ); - } else if !connected { - let ref mut fresh88 = (*conn).bits; - (*fresh88).set_do_more(1 as libc::c_int as bit); - } - (*ftpc).ctl_valid = 1 as libc::c_int != 0; - return CURLE_OK; -} -unsafe extern "C" fn ftp_doing(mut data: *mut Curl_easy, mut dophase_done: *mut bool) -> CURLcode { - let mut result: CURLcode = ftp_multi_statemach(data, dophase_done); - if !(result as u64 != 0) { - if *dophase_done { - result = ftp_dophase_done(data, 0 as libc::c_int != 0); - } - } - return result; -} -unsafe extern "C" fn ftp_regular_transfer( - mut data: *mut Curl_easy, - mut dophase_done: *mut bool, -) -> CURLcode { - let mut result: CURLcode = CURLE_OK; - let mut connected: bool = 0 as libc::c_int != 0; - let mut conn: *mut connectdata = (*data).conn; - let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; - (*data).req.size = -(1 as libc::c_int) as curl_off_t; - Curl_pgrsSetUploadCounter(data, 0 as libc::c_int as curl_off_t); - Curl_pgrsSetDownloadCounter(data, 0 as libc::c_int as curl_off_t); - Curl_pgrsSetUploadSize(data, -(1 as libc::c_int) as curl_off_t); - Curl_pgrsSetDownloadSize(data, -(1 as libc::c_int) as curl_off_t); - (*ftpc).ctl_valid = 1 as libc::c_int != 0; - result = ftp_perform(data, &mut connected, dophase_done); - if result as u64 == 0 { - if !*dophase_done { - return CURLE_OK; - } - result = ftp_dophase_done(data, connected); - if result as u64 != 0 { - return result; + + } else { + let ref mut fresh87 = (*ftpc).file; + *fresh87 = 0 as *mut libc::c_char; + } + if ((*data).set).upload() as libc::c_int != 0 + && ((*ftpc).file).is_null() + && (*ftp).transfer as libc::c_uint == PPTRANSFER_BODY as libc::c_int as libc::c_uint + { + Curl_failf( + data, + b"Uploading to a URL without a file name!\0" as *const u8 as *const libc::c_char, + ); + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 4229 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_URL_MALFORMAT; + } + (*ftpc).cwddone = 0 as libc::c_int != 0; + if (*data).set.ftp_filemethod as libc::c_uint == FTPFILE_NOCWD as libc::c_int as libc::c_uint + && *rawPath.offset(0 as libc::c_int as isize) as libc::c_int == '/' as i32 + { + (*ftpc).cwddone = 1 as libc::c_int != 0; + } else { + let mut oldPath: *const libc::c_char = if ((*conn).bits).reuse() as libc::c_int != 0 { + (*ftpc).prevpath as *const libc::c_char + } else { + b"\0" as *const u8 as *const libc::c_char + }; + if !oldPath.is_null() { + let mut n: size_t = pathLen; + if (*data).set.ftp_filemethod as libc::c_uint + == FTPFILE_NOCWD as libc::c_int as libc::c_uint + { + n = 0 as libc::c_int as size_t; + } else { + n = (n as libc::c_ulong).wrapping_sub(if !((*ftpc).file).is_null() { + strlen((*ftpc).file) + } else { + 0 as libc::c_int as libc::c_ulong + }) as size_t as size_t; + } + if strlen(oldPath) == n && strncmp(rawPath, oldPath, n) == 0 { + Curl_infof( + data, + b"Request has same path as previous transfer\0" as *const u8 + as *const libc::c_char, + ); + (*ftpc).cwddone = 1 as libc::c_int != 0; + } + } + } + #[cfg(not(CURLDEBUG))] + Curl_cfree.expect("non-null function pointer")(rawPath as *mut libc::c_void); + + #[cfg(CURLDEBUG)] + curl_dbg_free( + rawPath as *mut libc::c_void, + 4253 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ); + return CURLE_OK; + } + unsafe extern "C" fn ftp_dophase_done(mut data: *mut Curl_easy, mut connected: bool) -> CURLcode { + let mut conn: *mut connectdata = (*data).conn; + let mut ftp: *mut FTP = (*data).req.p.ftp; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + if connected { + let mut completed: libc::c_int = 0; + let mut result: CURLcode = ftp_do_more(data, &mut completed); + if result as u64 != 0 { + close_secondarysocket(data, conn); + return result; + } + } + if (*ftp).transfer as libc::c_uint != PPTRANSFER_BODY as libc::c_int as libc::c_uint { + Curl_setup_transfer( + data, + -(1 as libc::c_int), + -(1 as libc::c_int) as curl_off_t, + 0 as libc::c_int != 0, + -(1 as libc::c_int), + ); + } else if !connected { + let ref mut fresh88 = (*conn).bits; + (*fresh88).set_do_more(1 as libc::c_int as bit); + } + (*ftpc).ctl_valid = 1 as libc::c_int != 0; + return CURLE_OK; + } + unsafe extern "C" fn ftp_doing(mut data: *mut Curl_easy, mut dophase_done: *mut bool) -> CURLcode { + let mut result: CURLcode = ftp_multi_statemach(data, dophase_done); + if result as u64 != 0 { + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"DO phase failed\0" as *const u8 as *const libc::c_char, + ); + } else if *dophase_done { + result = ftp_dophase_done(data, 0 as libc::c_int != 0); + #[cfg(DEBUGBUILD)] + Curl_infof( + data, + b"DO phase is complete2\0" as *const u8 as *const libc::c_char, + ); + } + return result; + } + unsafe extern "C" fn ftp_regular_transfer( + mut data: *mut Curl_easy, + mut dophase_done: *mut bool, + ) -> CURLcode { + let mut result: CURLcode = CURLE_OK; + let mut connected: bool = 0 as libc::c_int != 0; + let mut conn: *mut connectdata = (*data).conn; + let mut ftpc: *mut ftp_conn = &mut (*conn).proto.ftpc; + (*data).req.size = -(1 as libc::c_int) as curl_off_t; + Curl_pgrsSetUploadCounter(data, 0 as libc::c_int as curl_off_t); + Curl_pgrsSetDownloadCounter(data, 0 as libc::c_int as curl_off_t); + Curl_pgrsSetUploadSize(data, -(1 as libc::c_int) as curl_off_t); + Curl_pgrsSetDownloadSize(data, -(1 as libc::c_int) as curl_off_t); + (*ftpc).ctl_valid = 1 as libc::c_int != 0; + result = ftp_perform(data, &mut connected, dophase_done); + if result as u64 == 0 { + if !*dophase_done { + return CURLE_OK; + } + result = ftp_dophase_done(data, connected); + if result as u64 != 0 { + return result; + } + } else { + freedirs(ftpc); + } + return result; + } + unsafe extern "C" fn ftp_setup_connection( + mut data: *mut Curl_easy, + mut conn: *mut connectdata, + ) -> CURLcode { + let mut type_0: *mut libc::c_char = 0 as *mut libc::c_char; + let mut ftp: *mut FTP = 0 as *mut FTP; + match () { + #[cfg(not(CURLDEBUG))] + _ => { + ftp = Curl_ccalloc.expect("non-null function pointer")( + ::std::mem::size_of::() as libc::c_ulong, + 1 as libc::c_int as size_t, + ) as *mut FTP; } - } else { - freedirs(ftpc); - } - return result; -} -unsafe extern "C" fn ftp_setup_connection( - mut data: *mut Curl_easy, - mut conn: *mut connectdata, -) -> CURLcode { - let mut type_0: *mut libc::c_char = 0 as *mut libc::c_char; - let mut ftp: *mut FTP = 0 as *mut FTP; - ftp = Curl_ccalloc.expect("non-null function pointer")( - ::std::mem::size_of::() as libc::c_ulong, - 1 as libc::c_int as size_t, - ) as *mut FTP; - let ref mut fresh89 = (*data).req.p.ftp; - *fresh89 = ftp; - if ftp.is_null() { - return CURLE_OUT_OF_MEMORY; - } - let ref mut fresh90 = (*ftp).path; - *fresh90 = &mut *((*data).state.up.path).offset(1 as libc::c_int as isize) as *mut libc::c_char; - type_0 = strstr((*ftp).path, b";type=\0" as *const u8 as *const libc::c_char); - if type_0.is_null() { - type_0 = strstr( - (*conn).host.rawalloc, - b";type=\0" as *const u8 as *const libc::c_char, - ); - } - if !type_0.is_null() { - let mut command: libc::c_char = 0; - *type_0 = 0 as libc::c_int as libc::c_char; - command = Curl_raw_toupper(*type_0.offset(6 as libc::c_int as isize)); - match command as libc::c_int { - 65 => { - let ref mut fresh91 = (*data).state; - (*fresh91).set_prefer_ascii(1 as libc::c_int as bit); - } - 68 => { - let ref mut fresh92 = (*data).state; - (*fresh92).set_list_only(1 as libc::c_int as bit); - } - 73 | _ => { - let ref mut fresh93 = (*data).state; - (*fresh93).set_prefer_ascii(0 as libc::c_int as bit); - } + #[cfg(CURLDEBUG)] + _ => { + ftp = curl_dbg_calloc( + ::std::mem::size_of::() as libc::c_ulong, + 1 as libc::c_int as size_t, + 4358 as libc::c_int, + b"ftp.c\0" as *const u8 as *const libc::c_char, + ) as *mut FTP; } } - (*ftp).transfer = PPTRANSFER_BODY; - (*ftp).downloadsize = 0 as libc::c_int as curl_off_t; - (*conn).proto.ftpc.known_filesize = -(1 as libc::c_int) as curl_off_t; - return CURLE_OK; -} + + let ref mut fresh89 = (*data).req.p.ftp; + *fresh89 = ftp; + if ftp.is_null() { + return CURLE_OUT_OF_MEMORY; + } + let ref mut fresh90 = (*ftp).path; + *fresh90 = &mut *((*data).state.up.path).offset(1 as libc::c_int as isize) as *mut libc::c_char; + type_0 = strstr((*ftp).path, b";type=\0" as *const u8 as *const libc::c_char); + if type_0.is_null() { + type_0 = strstr( + (*conn).host.rawalloc, + b";type=\0" as *const u8 as *const libc::c_char, + ); + } + if !type_0.is_null() { + let mut command: libc::c_char = 0; + *type_0 = 0 as libc::c_int as libc::c_char; + command = Curl_raw_toupper(*type_0.offset(6 as libc::c_int as isize)); + match command as libc::c_int { + 65 => { + let ref mut fresh91 = (*data).state; + (*fresh91).set_prefer_ascii(1 as libc::c_int as bit); + } + 68 => { + let ref mut fresh92 = (*data).state; + (*fresh92).set_list_only(1 as libc::c_int as bit); + } + 73 | _ => { + let ref mut fresh93 = (*data).state; + (*fresh93).set_prefer_ascii(0 as libc::c_int as bit); + } + } + } + (*ftp).transfer = PPTRANSFER_BODY; + (*ftp).downloadsize = 0 as libc::c_int as curl_off_t; + (*conn).proto.ftpc.known_filesize = -(1 as libc::c_int) as curl_off_t; + return CURLE_OK; + } + \ No newline at end of file -- Gitee