From a99db5fd43c2a41a17c9e9d12e7dca9cab666f8d Mon Sep 17 00:00:00 2001 From: larryl Date: Mon, 22 Oct 2007 08:22:30 +0000 Subject: [PATCH 01/64] First commit of libcURL Eiffel wrapper library. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@70782 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL.ecf | 44 + curl_codes.e | 331 ++++++ curl_easy_externals.e | 167 +++ curl_externals.e | 151 +++ curl_form.e | 86 ++ curl_form_constants.e | 78 ++ curl_memory_struct.e | 192 ++++ curl_opt_constants.e | 177 +++ spec/include/curl/curl.h | 1714 ++++++++++++++++++++++++++++ spec/include/curl/curlver.h | 67 ++ spec/include/curl/easy.h | 81 ++ spec/include/curl/mprintf.h | 80 ++ spec/include/curl/multi.h | 346 ++++++ spec/include/curl/stdcheaders.h | 34 + spec/include/curl/types.h | 1 + spec/include/eiffel_curl.h | 127 +++ spec/msc/win64/lib/libcurl_imp.lib | Bin 0 -> 12820 bytes 17 files changed, 3676 insertions(+) create mode 100644 cURL.ecf create mode 100644 curl_codes.e create mode 100644 curl_easy_externals.e create mode 100644 curl_externals.e create mode 100644 curl_form.e create mode 100644 curl_form_constants.e create mode 100644 curl_memory_struct.e create mode 100644 curl_opt_constants.e create mode 100644 spec/include/curl/curl.h create mode 100644 spec/include/curl/curlver.h create mode 100644 spec/include/curl/easy.h create mode 100644 spec/include/curl/mprintf.h create mode 100644 spec/include/curl/multi.h create mode 100644 spec/include/curl/stdcheaders.h create mode 100644 spec/include/curl/types.h create mode 100644 spec/include/eiffel_curl.h create mode 100644 spec/msc/win64/lib/libcurl_imp.lib diff --git a/cURL.ecf b/cURL.ecf new file mode 100644 index 00000000..cc834e7a --- /dev/null +++ b/cURL.ecf @@ -0,0 +1,44 @@ + + + + cURL: libcURL wrapper library for Eiffel. + Copyright (c) 1984-2006, Eiffel Software and others. + Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). + + + /\.svn$ + /EIFGEN.{0,1}$ + /temp$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/curl_codes.e b/curl_codes.e new file mode 100644 index 00000000..52c3982c --- /dev/null +++ b/curl_codes.e @@ -0,0 +1,331 @@ +indexing + description: "[ + All possible error codes from all sorts of curl functions. + Future versions may return other values, stay prepared. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_CODES + +feature -- Constants + + curle_ok: INTEGER is 0 + -- Declared as CURLE_OK + + curle_unsupported_protocol: INTEGER is 1 + -- Declared as CURLE_UNSUPPORTED_PROTOCOL + + curle_failed_init: INTEGER is 2 + -- Declared as CURLE_FAILED_INIT + + curle_url_malformat: INTEGER is 3 + -- Declared as CURLE_URL_MALFORMAT + + curle_obsolete4: INTEGER is 4 + -- Declared as CURLE_OBSOLETE4 + -- NOT USED + + curle_couldnt_resolve_proxy: INTEGER is 5 + -- Declared as CURLE_COULDNT_RESOLVE_PROXY + + curle_couldnt_resolve_host: INTEGER is 6 + -- Declared as CURLE_COULDNT_RESOLVE_HOST + + curle_couldnt_connect: INTEGER is 7 + -- Declared as CURLE_COULDNT_CONNECT + + curle_ftp_weird_server_reply: INTEGER is 8 + -- Declared as CURLE_FTP_WEIRD_SERVER_REPLY + + curle_remote_access_denied: INTEGER is 9 + -- Declared as CURLE_REMOTE_ACCESS_DENIED + -- A service was denied by the server due to lack of access + -- when login fails this is not returned. + + curle_obsolete10: INTEGER is 10 + -- Declared as CURLE_OBSOLETE10 NOT USED + + curle_ftp_weird_pass_reply: INTEGER is 11 + -- Declared as CURLE_FTP_WEIRD_PASS_REPLY + + curle_obsolete12: INTEGER is 12 + -- Declared as CURLE_OBSOLETE12 NOT USED + + curle_ftp_weird_pasv_reply: INTEGER is 13 + -- Declared as CURLE_FTP_WEIRD_PASV_REPLY + + curle_ftp_weird_227_format: INTEGER is 14 + -- Declared as CURLE_FTP_WEIRD_227_FORMAT + + curle_ftp_cant_get_host: INTEGER is 15 + -- Declared as CURLE_FTP_CANT_GET_HOST + + curle_obsolete16: INTEGER is 16 + -- Declared as CURLE_OBSOLETE16 + -- NOT USED + + curle_ftp_couldnt_set_type: INTEGER is 17 + -- Declared as CURLE_FTP_COULDNT_SET_TYPE + + curle_partial_file: INTEGER is 18 + -- Declared as CURLE_PARTIAL_FILE + + curle_ftp_couldnt_retr_file: INTEGER is 19 + -- Declared as CURLE_FTP_COULDNT_RETR_FILE + + curle_obsolete20: INTEGER is 20 + -- Declared as CURLE_OBSOLETE20 + -- NOT USED + + curle_quote_error: INTEGER is 21 + -- Declared as CURLE_QUOTE_ERROR + -- quote command failure + + curle_http_returned_error: INTEGER is 22 + -- Declared as CURLE_HTTP_RETURNED_ERROR + + curle_write_error: INTEGER is 23 + -- Declared as CURLE_WRITE_ERROR + + curle_obsolete24: INTEGER is 24 + -- Declared as CURLE_OBSOLETE24 NOT USED + + curle_upload_failed: INTEGER is 25 + -- Declared as CURLE_UPLOAD_FAILED + -- failed upload "command" + + curle_read_error: INTEGER is 26 + -- Declared as CURLE_READ_ERROR + -- couldn't open/read from file + + curle_out_of_memory: INTEGER is 27 + -- Declared as CURLE_OUT_OF_MEMORY + -- Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error + -- instead of a memory allocation error if CURL_DOES_CONVERSIONS + -- is defined + + curle_operation_timedout: INTEGER is 28 + -- Declared as CURLE_OPERATION_TIMEDOUT + -- the timeout time was reached + + curle_obsolete29: INTEGER is 29 + -- Declared as CURLE_OBSOLETE29 + -- NOT USED + + curle_ftp_port_failed: INTEGER is 30 + -- Declared as CURLE_FTP_PORT_FAILED + -- FTP PORT operation failed + + curle_ftp_couldnt_use_rest: INTEGER is 31 + -- Declared as CURLE_FTP_COULDNT_USE_REST + -- the REST command failed + + curle_obsolete32: INTEGER is 32 + -- Declared as CURLE_OBSOLETE32 + -- NOT USED + + curle_range_error: INTEGER is 33 + -- Declared as CURLE_RANGE_ERROR + -- RANGE "command" didn't work + + curle_http_post_error: INTEGER is 34 + -- Declared as CURLE_HTTP_POST_ERROR + + curle_ssl_connect_error: INTEGER is 35 + -- Declared CURLE_SSL_CONNECT_ERROR + -- wrong when connecting with SSL + + curle_bad_download_resume: INTEGER is 36 + -- Declared as CURLE_BAD_DOWNLOAD_RESUME + -- couldn't resume download + + curle_file_couldnt_read_file: INTEGER is 37 + -- Declared as CURLE_FILE_COULDNT_READ_FILE + + curle_ldap_cannot_bind: INTEGER is 38 + -- Declared as CURLE_LDAP_CANNOT_BIND + + curle_ldap_search_failed: INTEGER is 39 + -- Declared as CURLE_LDAP_SEARCH_FAILED + + curle_obsolete40: INTEGER is 40 + -- Declared as CURLE_OBSOLETE40 + -- NOT USED + + curle_function_not_found: INTEGER is 41 + -- Declared as CURLE_FUNCTION_NOT_FOUND + + curle_aborted_by_callback: INTEGER is 42 + -- Declared as CURLE_ABORTED_BY_CALLBACK + + curle_bad_function_argument: INTEGER is 43 + -- Declared as CURLE_BAD_FUNCTION_ARGUMENT + + curle_obsolete44: INTEGER is 44 + -- Declared as CURLE_OBSOLETE44 + -- NOT USED + + curle_interface_failed: INTEGER is 45 + -- Declared as CURLE_INTERFACE_FAILED + -- CURLOPT_INTERFACE failed + + curle_obsolete46: INTEGER is 46 + -- Declared as CURLE_OBSOLETE46 + -- NOT USED + + curle_too_many_redirects: INTEGER is 47 + -- Declared as CURLE_TOO_MANY_REDIRECTS + -- catch endless re-direct loops + + curle_unknown_telnet_option: INTEGER is 48 + -- Declared as CURLE_UNKNOWN_TELNET_OPTION + -- User specified an unknown option + + curle_telnet_option_syntax: INTEGER is 49 + -- Declared as CURLE_TELNET_OPTION_SYNTAX + -- Malformed telnet option + + curle_obsolete50: INTEGER is 50 + -- Declared as CURLE_OBSOLETE50 + -- NOT USED + + curle_ssl_peer_certificate: INTEGER is 51 + -- Declared as CURLE_SSL_PEER_CERTIFICATE + -- peer's certificate wasn't ok + + curle_got_nothing: INTEGER is 52 + -- Declared as CURLE_GOT_NOTHING + -- when this is a specific error + + curle_ssl_engine_notfound: INTEGER is 53 + -- Declared as CURLE_SSL_ENGINE_NOTFOUND + -- SSL crypto engine not found */ + + curle_ssl_engine_setfailed: INTEGER is 54 + -- Declared as CURLE_SSL_ENGINE_SETFAILED + -- can not set SSL crypto engine as default + + curle_send_error: INTEGER is 55 + -- Declared as CURLE_SEND_ERROR + -- failed sending network data + + curle_recv_error: INTEGER is 56 + -- Declared as CURLE_RECV_ERROR + -- failure in receiving network data + + curle_obsolete57: INTEGER is 57 + -- Declared as CURLE_OBSOLETE57 + -- NOT IN USE + + curle_ssl_certproblem: INTEGER is 58 + -- Declared as CURLE_SSL_CERTPROBLEM + -- problem with the local certificate + + curle_ssl_cipher: INTEGER is 59 + -- Declared as CURLE_SSL_CIPHER + -- couldn't use specified cipher + + curle_ssl_cacert: INTEGER is 60 + -- Declared as CURLE_SSL_CACERT + -- problem with the CA cert (path?) + + curle_bad_content_encoding: INTEGER is 61 + -- Declared as CURLE_BAD_CONTENT_ENCODING + -- Unrecognized transfer encoding + + curle_ldap_invalid_url: INTEGER is 62 + -- Declared as CURLE_LDAP_INVALID_URL + -- Invalid LDAP URL + + curle_filesize_exceeded: INTEGER is 63 + -- Declared as CURLE_FILESIZE_EXCEEDED + -- Maximum file size exceeded + + curle_use_ssl_failed: INTEGER is 64 + -- Declared as CURLE_USE_SSL_FAILED + -- Requested FTP SSL level failed + + curle_send_fail_rewind: INTEGER is 65 + -- Declared as CURLE_SEND_FAIL_REWIND + -- Sending the data requires a rewind that failed + + curle_ssl_engine_initfailed: INTEGER is 66 + -- Declared as CURLE_SSL_ENGINE_INITFAILED + -- failed to initialise ENGINE + + curle_login_denied: INTEGER is 67 + -- Declared as CURLE_LOGIN_DENIED + -- user, password or similar was not accepted and we failed to login + + curle_tftp_notfound: INTEGER is 68 + -- Declared as CURLE_TFTP_NOTFOUND + -- file not found on server + + curle_tftp_perm: INTEGER is 69 + -- Declared as CURLE_TFTP_PERM + -- permission problem on server + + curle_remote_disk_full: INTEGER is 70 + -- Declared as CURLE_REMOTE_DISK_FULL + -- out of disk space on server + + curle_tftp_illegal: INTEGER is 71 + -- Declared as CURLE_TFTP_ILLEGAL + -- Illegal TFTP operation + + curle_tftp_unknownid: INTEGER is 72 + -- Declared as CURLE_TFTP_UNKNOWNID + -- Unknown transfer ID + + curle_remote_file_exists: INTEGER is 73 + -- Declared as CURLE_REMOTE_FILE_EXISTS + -- File already exists + + curle_tftp_nosuchuser: INTEGER is 74 + -- Declared as CURLE_TFTP_NOSUCHUSER + -- No such user + + curle_conv_failed: INTEGER is 75 + -- Declared as CURLE_CONV_FAILED + -- conversion failed + + curle_conv_reqd: INTEGER is 76 + -- Declared as CURLE_CONV_REQD + -- caller must register conversion callbacks using curl_easy_setopt options + -- CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPT_CONV_TO_NETWORK_FUNCTION, and + -- CURLOPT_CONV_FROM_UTF8_FUNCTION + + curle_ssl_cacert_badfile: INTEGER is 77 + -- Declared as CURLE_SSL_CACERT_BADFILE + -- could not load CACERT file, missing or wrong format + + curle_remote_file_not_found: INTEGER is 78 + -- Declared as CURLE_REMOTE_FILE_NOT_FOUND + -- remote file not found + + curle_ssh: INTEGER is 79 + -- Declared as CURLE_SSH + -- error from the SSH layer, somewhat generic so the error message will be of + -- interest when this has happened + + curle_ssl_shutdown_failed: INTEGER is 80; + -- Declared as CURLE_SSL_SHUTDOWN_FAILED + -- Failed to shut down the SSL connection + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_easy_externals.e b/curl_easy_externals.e new file mode 100644 index 00000000..85307cb4 --- /dev/null +++ b/curl_easy_externals.e @@ -0,0 +1,167 @@ +indexing + description: "[ + cURL easy externals. + For more informaton see: + http://curl.haxx.se/libcurl/c/ + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_EASY_EXTERNALS + +feature -- Externals + + init: POINTER is + -- Declared as curl_easy_init(). + external + "C inline use " + alias + "[ + { + return curl_easy_init(); + } + ]" + ensure + exists: Result /= default_pointer + end + + setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_string: STRING_GENERAL) is + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + not_void: a_string /= Void + local + l_c_str: C_STRING + do + create l_c_str.make (a_string) + c_setopt_string (a_curl_handle, a_opt, l_c_str.item) + end + + setopt_form (a_curl_handle: POINTER; a_opt: INTEGER; a_form: CURL_FORM) is + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + not_void: a_form /= Void and then a_form.is_exists + do + setopt_void_star (a_curl_handle, a_opt, a_form.item) + end + + setopt_memory_struct (a_curl_handle: POINTER; a_opt: INTEGER; a_memory_struct: CURL_MEMORY_STRUCT) is + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + not_void: a_memory_struct /= Void + do + c_setopt_void_star (a_curl_handle, a_opt, a_memory_struct.item) + end + + setopt_integer (a_curl_handle: POINTER; a_opt: INTEGER; a_integer: INTEGER) is + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + external + "C inline use " + alias + "[ + { + size_t l_int; + l_int = $a_integer; + + curl_easy_setopt($a_curl_handle, $a_opt, l_int); + } + ]" + end + + perform (a_curl_handle: POINTER): INTEGER is + -- Declared as curl_easy_perform(). + require + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + { + return curl_easy_perform ($a_curl_handle); + } + ]" + ensure + valid: + end + + cleanup (a_curl_handle: POINTER) is + -- Declared as curl_easy_cleanup(). + require + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + { + curl_easy_cleanup($a_curl_handle); + + } + ]" + end + +feature {NONE} -- Implementation + + setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + do + c_setopt_void_star (a_curl_handle, a_opt, a_data) + end + + c_setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is + -- C implementation of `setopt_void_star'. + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + external + "C inline use " + alias + "[ + { + curl_easy_setopt($a_curl_handle, $a_opt, (void *)$a_data); + } + ]" + end + + c_setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_c_string: POINTER) is + -- C implementation of `setopt_string'. + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + exists: a_c_string /= default_pointer + external + "C inline use " + alias + "[ + { + curl_easy_setopt($a_curl_handle, $a_opt, (char *)$a_c_string); + } + ]" + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_externals.e b/curl_externals.e new file mode 100644 index 00000000..f3a7558d --- /dev/null +++ b/curl_externals.e @@ -0,0 +1,151 @@ +indexing + description: "[ + cURL externals. + For more information, see: + http://curl.haxx.se/libcurl/c/ + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_EXTERNALS + +feature -- Externals + + global_init is + -- Declared as curl_global_init(). + external + "C inline use " + alias + "[ + { + curl_global_init (CURL_GLOBAL_ALL); + } + ]" + end + + formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is + -- Declared as curl_formadd (). + require + not_void: a_form /= Void + not_void: a_last_pointer /= Void + valid: (create {CURL_FORM_CONSTANTS}).is_valid (a_arg_1) + not_void: a_arg_1_value /= Void + valid: (create {CURL_FORM_CONSTANTS}).is_valid (a_arg_2) + not_void: a_arg_2_value /= Void + valid: (create {CURL_FORM_CONSTANTS}).is_valid (a_arg_3) + local + l_form_pointer, l_last_pointer: POINTER + do + l_form_pointer := a_form.item + l_last_pointer := a_last_pointer.item + + internal_formadd_string_string ($l_form_pointer, $l_last_pointer, a_arg_1, a_arg_1_value, a_arg_2, a_arg_2_value, a_arg_3) + + if a_form.item /= l_form_pointer then + check not_set: a_form.item = default_pointer end + a_form.set_item (l_form_pointer) + end + if a_last_pointer.item /= l_last_pointer then + a_last_pointer.set_item (l_last_pointer) + end + end + + set_write_function (a_curl_handle: POINTER) is + -- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a static c function pointer as value. + require + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + { + curl_easy_setopt ($a_curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); + } + ]" + end + + set_debug_function (a_curl_handle: POINTER) is + -- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a static c function pointer as value. + require + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + { + curl_easy_setopt($a_curl_handle, CURLOPT_DEBUGFUNCTION, my_trace); + curl_easy_setopt($a_curl_handle, CURLOPT_VERBOSE, TRUE); + } + ]" + end + +feature {CURL_FORM} -- Internal command + + formfree (a_curl_form: POINTER) is + -- Declared as curl_formfree (). + require + exists: a_curl_form /= default_pointer + external + "C inline use " + alias + "[ + { + curl_formfree($a_curl_form); + } + ]" + end + +feature {NONE} -- Implementation + + c_slist_append (a_list_pointer: POINTER; a_string: POINTER): POINTER is + -- Declared as curl_slist_append (). + external + "C inline use " + alias + "[ + { + return curl_slist_append ((struct curl_slist *)$a_list_pointer, (char *)$a_string); + } + ]" + end + + internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is + -- Declared as curl_formadd (). + local + l_c_string_1, l_c_string_2: C_STRING + do + create l_c_string_1.make (a_arg_1_value) + create l_c_string_2.make (a_arg_2_value) + c_formadd_string_string (a_form, a_last_pointer, a_arg_1, l_c_string_1.item, a_arg_2, l_c_string_2.item, a_arg_3) + end + + c_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: POINTER; a_arg_2: INTEGER; a_arg_2_value: POINTER; a_arg_3: INTEGER) is + -- C implementation of formadd_string_string (). + external + "C inline use " + alias + "[ + { + curl_formadd ((struct curl_httppost *)$a_form, (struct curl_httppost *)$a_last_pointer, (int)$a_arg_1, (char *)$a_arg_1_value, (int)$a_arg_2, (char *)$a_arg_2_value, (int)$a_arg_3); + } + ]" + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_form.e b/curl_form.e new file mode 100644 index 00000000..2e698208 --- /dev/null +++ b/curl_form.e @@ -0,0 +1,86 @@ +indexing + description: "[ + cURL form. + For more informaton see: + http://curl.haxx.se/libcurl/c/curl_formadd.html + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_FORM + +inherit + DISPOSABLE + +create + make, + share_with_pointer + +feature {NONE} -- Initialization + + make is + -- Creation method. + do + end + + share_with_pointer (a_pointer: POINTER) is + -- Creation method. + -- `item' share with `a_pointer'. + require + exists: a_pointer /= default_pointer + do + item := a_pointer + ensure + set: item = a_pointer + end + +feature -- Query + + item: POINTER + -- C pointer of Current. + + is_exists: BOOLEAN + -- If C pointer exists? + do + Result := item /= default_pointer + end + +feature -- Command + + dispose is + -- Free memory if possible. + local + l_curl: CURL_EXTERNALS + do + if item /= default_pointer then + create l_curl + l_curl.formfree (item) + end + end + +feature {CURL_EXTERNALS} -- Internal command + + set_item (a_item: POINTER) is + -- Set `item' with `a_item' + do + item := a_item + ensure + set: item = a_item + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_form_constants.e b/curl_form_constants.e new file mode 100644 index 00000000..414d99b0 --- /dev/null +++ b/curl_form_constants.e @@ -0,0 +1,78 @@ +indexing + description: "[ + cURL form constants. + For more informaton see: + http://curl.haxx.se/libcurl/c/curl_formadd.html + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_FORM_CONSTANTS + +feature -- Query + + curlform_copyname: INTEGER is + -- Declared as CURLFORM_COPYNAME + external + "C inline use " + alias + "[ + CURLFORM_COPYNAME + ]" + end + + curlform_copycontents: INTEGER is + -- Declared as CURLFORM_COPYCONTENTS + external + "C inline use " + alias + "[ + CURLFORM_COPYCONTENTS + ]" + end + + curlform_end: INTEGER is + -- Declared as CURLFORM_END + external + "C inline use " + alias + "[ + CURLFORM_END + ]" + end + + curlform_file: INTEGER is + -- Declared as CURLFORM_FILE + external + "C inline use " + alias + "[ + CURLFORM_FILE + ]" + end + + is_valid (a_integer: INTEGER): BOOLEAN is + -- If `a_integer' valid? + do + Result := a_integer = curlform_copycontents or + a_integer = curlform_copyname or + a_integer = curlform_end or + a_integer = curlform_file + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_memory_struct.e b/curl_memory_struct.e new file mode 100644 index 00000000..601c50bb --- /dev/null +++ b/curl_memory_struct.e @@ -0,0 +1,192 @@ +indexing + description: "[ + When libcURL write data which get from remote web site, + this memory stuct will be used by Eiffel language to store the data. + For more informaton see: + http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEDATA + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_MEMORY_STRUCT + +inherit + DISPOSABLE + +create + make + +feature {NONE} -- Intialization + + make is + -- Creation method. + do + item := item.memory_alloc (struct_size) + set_size (0) + set_memory_chunk (default_pointer) + end + +feature -- Query + + item: POINTER + -- Managed pointer. + + size: INTEGER is + -- String size. + do + if item /= default_pointer then + Result := c_size (item) + end + end + + memory_chunk: POINTER is + -- Memory chunk access pointer + do + if item /= default_pointer then + Result := c_memory_chunck (item) + end + end + + string: STRING_GENERAL is + -- Covert to Eiffel String. + -- Maybe void if not exists. + local + l_c_string: C_STRING + l_mem: POINTER + l_size: INTEGER + do + l_mem := c_memory_chunck (item) + l_size := size + if l_mem /= default_pointer and then l_size > 0 then + create l_c_string.share_from_pointer_and_count (l_mem, l_size) + Result := l_c_string.string + end + end + + struct_size: INTEGER is + -- Size of C Structure. + do + Result := c_size_of_memory_struct + ensure + nonnegative: Result >= 0 + end + +feature -- Command + + set_size (a_size: INTEGER) is + -- Set `size' to `a_size' + require + nonnegative: a_size >= 0 + do + c_set_size (item, a_size) + ensure + set: size = a_size + end + + set_memory_chunk (a_ptr: POINTER) is + -- Set `memory_chunk' to `a_ptr'. + do + c_set_memory_chunk (item, a_ptr) + ensure + set: memory_chunk = a_ptr + end + + dispose is + -- Clean up. + local + l_mem: POINTER + do + if item /= default_pointer then + l_mem := c_memory_chunck (item) + if l_mem /= default_pointer then + l_mem.memory_free + end + item.memory_free + item := default_pointer + end + ensure then + cleared: item = default_pointer + end + +feature {NONE} -- C externals + + c_size_of_memory_struct: INTEGER is + -- CURL memory struct struct size. + external + "C [macro ]" + alias + "sizeof (struct cURLMemoryStruct)" + end + + c_size (a_item: POINTER): INTEGER is + -- `a_item''s size + require + exists: a_item /= default_pointer + external + "C inline use " + alias + "[ + ((struct cURLMemoryStruct *)$a_item)->size + ]" + end + + c_set_size (a_item: POINTER; a_size: INTEGER) is + -- Set `a_item''s size to `a_size'. + require + exists: a_item /=default_pointer + external + "C inline use " + alias + "[ + { + ((struct cURLMemoryStruct *)$a_item)->size = $a_size; + } + ]" + ensure + set: c_size (a_item) = a_size + end + + c_memory_chunck (a_item: POINTER): POINTER is + -- `a_item''s memory pointer. + require + exists: a_item /= default_pointer + external + "C inline use " + alias + "[ + ((struct cURLMemoryStruct *)$a_item)->memory + ]" + end + + c_set_memory_chunk (a_item: POINTER; a_ptr: POINTER) is + -- Set `a_item''s memory to `a_ptr'. + require + exists: a_item /= default_pointer + external + "C inline use " + alias + "[ + { + ((struct cURLMemoryStruct *)$a_item)->memory = $a_ptr; + } + ]" + ensure + set: c_memory_chunck (a_item) = a_ptr + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_opt_constants.e b/curl_opt_constants.e new file mode 100644 index 00000000..651090ce --- /dev/null +++ b/curl_opt_constants.e @@ -0,0 +1,177 @@ +indexing + description: "[ + libcurl library opt constants + For more informaton see: + http://curl.haxx.se/libcurl/c/curl_easy_setopt.html + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_OPT_CONSTANTS + +feature -- Enumerations. + + curlopt_httpheader: INTEGER is + -- Declared as CURLOPT_HTTPHEADER. + external + "C inline use " + alias + "[ + return CURLOPT_HTTPHEADER; + ]" + end + + curlopt_writedata: INTEGER is + -- Declared as CURLOPT_WRITEDATA. + external + "C inline use " + alias + "[ + return CURLOPT_WRITEDATA; + ]" + end + + curlopt_writeheader: INTEGER is + -- Declared as CURLOPT_WRITEHEADER. + external + "C inline use " + alias + "[ + return CURLOPT_WRITEHEADER; + ]" + end + + curlopt_debugfunction: INTEGER is + -- Declared as CURLOPT_DEBUGFUNCTION. + external + "C inline use " + alias + "[ + return CURLOPT_DEBUGFUNCTION; + ]" + end + + curlopt_verbose: INTEGER is + -- Declared as CURLOPT_VERBOSE. + external + "C inline use " + alias + "[ + return CURLOPT_VERBOSE; + ]" + end + + curlopt_useragent: INTEGER is + -- Declared as CURLOPT_USERAGENT. + external + "C inline use " + alias + "[ + return CURLOPT_USERAGENT; + ]" + end + + curlopt_url: INTEGER is + -- Declared as CURLOPT_URL. + external + "C inline use " + alias + "[ + return CURLOPT_URL; + ]" + end + + curlopt_cookiefile: INTEGER is + -- Declared as CURLOPT_COOKIEFILE. + external + "C inline use " + alias + "[ + return CURLOPT_COOKIEFILE; + ]" + end + + curlopt_ssl_verifypeer: INTEGER is + -- Declared as CURLOPT_SSL_VERIFYPEER. + external + "C inline use " + alias + "[ + return CURLOPT_SSL_VERIFYPEER; + ]" + end + + curlopt_cookie: INTEGER is + -- Declared as CURLOPT_COOKIE. + external + "C inline use " + alias + "[ + return CURLOPT_COOKIE; + ]" + end + + curlopt_post: INTEGER is + -- Declared as CURLOPT_POST. + external + "C inline use " + alias + "[ + return CURLOPT_POST; + ]" + end + + curlopt_postfields: INTEGER is + -- Declared as CURLOPT_POSTFIELDS. + external + "C inline use " + alias + "[ + return CURLOPT_POSTFIELDS; + ]" + end + + curlopt_httppost: INTEGER is + -- Declared as CURLOPT_HTTPPOST. + external + "C inline use " + alias + "[ + return CURLOPT_HTTPPOST; + ]" + end + + is_valid (a_integer: INTEGER): BOOLEAN is + -- If `a_integer' value vaild? + do + Result := a_integer = curlopt_cookie or + a_integer = curlopt_cookiefile or + a_integer = curlopt_debugfunction or + a_integer = curlopt_httpheader or + a_integer = curlopt_httppost or + a_integer = curlopt_post or + a_integer = curlopt_postfields or + a_integer = curlopt_ssl_verifypeer or + a_integer = curlopt_url or + a_integer = curlopt_useragent or + a_integer = curlopt_verbose or + a_integer = curlopt_writedata or + a_integer = curlopt_writeheader + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/spec/include/curl/curl.h b/spec/include/curl/curl.h new file mode 100644 index 00000000..e7f5ec59 --- /dev/null +++ b/spec/include/curl/curl.h @@ -0,0 +1,1714 @@ +#ifndef __CURL_CURL_H +#define __CURL_CURL_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ + +/* If you have problems, all libcurl docs and details are found here: + http://curl.haxx.se/libcurl/ +*/ + +#include "curlver.h" /* the libcurl version defines */ + +#include +#include + +/* The include stuff here below is mainly for time_t! */ +#ifdef vms +# include +# include +#else +# include +# include +#endif /* defined (vms) */ + +typedef void CURL; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Decorate exportable functions for Win32 DLL linking. + * This avoids using a .def file for building libcurl.dll. + */ +#if (defined(WIN32) || defined(_WIN32)) && !defined(CURL_STATICLIB) +#if defined(BUILDING_LIBCURL) +#define CURL_EXTERN __declspec(dllexport) +#else +#define CURL_EXTERN __declspec(dllimport) +#endif +#else + +#ifdef CURL_HIDDEN_SYMBOLS +/* + * This definition is used to make external definitions visibile in the + * shared library when symbols are hidden by default. It makes no + * difference when compiling applications whether this is set or not, + * only when compiling the library. + */ +#define CURL_EXTERN CURL_EXTERN_SYMBOL +#else +#define CURL_EXTERN +#endif +#endif + +/* + * We want the typedef curl_off_t setup for large file support on all + * platforms. We also provide a CURL_FORMAT_OFF_T define to use in *printf + * format strings when outputting a variable of type curl_off_t. + * + * Note: "pocc -Ze" is MSVC compatibily mode and this sets _MSC_VER! + */ + +#if (defined(_MSC_VER) && !defined(__POCC__)) || (defined(__LCC__) && defined(WIN32)) +/* MSVC */ +#ifdef _WIN32_WCE + typedef long curl_off_t; +#define CURL_FORMAT_OFF_T "%ld" +#else + typedef signed __int64 curl_off_t; +#define CURL_FORMAT_OFF_T "%I64d" +#endif +#else /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */ +#if (defined(__GNUC__) && defined(WIN32)) || defined(__WATCOMC__) +/* gcc on windows or Watcom */ + typedef long long curl_off_t; +#define CURL_FORMAT_OFF_T "%I64d" +#else /* GCC or Watcom on Windows */ +#if defined(__ILEC400__) +/* OS400 C compiler. */ + typedef long long curl_off_t; +#define CURL_FORMAT_OFF_T "%lld" +#else /* OS400 C compiler. */ + +/* "normal" POSIX approach, do note that this does not necessarily mean that + the type is >32 bits, see the SIZEOF_CURL_OFF_T define for that! */ + typedef off_t curl_off_t; + +/* Check a range of defines to detect large file support. On Linux it seems + none of these are set by default, so if you don't explicitly switches on + large file support, this define will be made for "small file" support. */ +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 0 /* to prevent warnings in the check below */ +#define UNDEF_FILE_OFFSET_BITS +#endif +#ifndef FILESIZEBITS +#define FILESIZEBITS 0 /* to prevent warnings in the check below */ +#define UNDEF_FILESIZEBITS +#endif + +#if defined(_LARGE_FILES) || (_FILE_OFFSET_BITS > 32) || (FILESIZEBITS > 32) \ + || defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE) + /* For now, we assume at least one of these to be set for large files to + work! */ +#define CURL_FORMAT_OFF_T "%lld" +#else /* LARGE_FILE support */ +#define CURL_FORMAT_OFF_T "%ld" +#endif +#endif /* OS400 C compiler. */ +#endif /* GCC or Watcom on Windows */ +#endif /* (_MSC_VER && !__POCC__) || (__LCC__ && WIN32) */ + +#ifdef UNDEF_FILE_OFFSET_BITS +/* this was defined above for our checks, undefine it again */ +#undef _FILE_OFFSET_BITS +#endif + +#ifdef UNDEF_FILESIZEBITS +/* this was defined above for our checks, undefine it again */ +#undef FILESIZEBITS +#endif + +#if defined(_WIN32) && !defined(WIN32) +/* Chris Lewis mentioned that he doesn't get WIN32 defined, only _WIN32 so we + make this adjustment to catch this. */ +#define WIN32 1 +#endif + +#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \ + !defined(__CYGWIN__) || defined(__MINGW32__) +#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H)) +/* The check above prevents the winsock2 inclusion if winsock.h already was + included, since they can't co-exist without problems */ +#include +#endif +#else + +/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish + libc5-based Linux systems. Only include it on system that are known to + require it! */ +#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || defined(__minix) +#include +#endif + +#ifndef _WIN32_WCE +#include +#endif +#ifndef __WATCOMC__ +#include +#endif +#include +#endif + +#ifndef curl_socket_typedef +/* socket typedef */ +#ifdef WIN32 +typedef SOCKET curl_socket_t; +#define CURL_SOCKET_BAD INVALID_SOCKET +#else +typedef int curl_socket_t; +#define CURL_SOCKET_BAD -1 +#endif +#define curl_socket_typedef +#endif /* curl_socket_typedef */ + +struct curl_httppost { + struct curl_httppost *next; /* next entry in the list */ + char *name; /* pointer to allocated name */ + long namelength; /* length of name length */ + char *contents; /* pointer to allocated data contents */ + long contentslength; /* length of contents field */ + char *buffer; /* pointer to allocated buffer contents */ + long bufferlength; /* length of buffer field */ + char *contenttype; /* Content-Type */ + struct curl_slist* contentheader; /* list of extra headers for this form */ + struct curl_httppost *more; /* if one field name has more than one + file, this link should link to following + files */ + long flags; /* as defined below */ +#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */ +#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */ +#define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer + do not free in formfree */ +#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer + do not free in formfree */ +#define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */ +#define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */ + + char *showfilename; /* The file name to show. If not set, the + actual file name will be used (if this + is a file part) */ +}; + +typedef int (*curl_progress_callback)(void *clientp, + double dltotal, + double dlnow, + double ultotal, + double ulnow); + +#ifndef CURL_MAX_WRITE_SIZE + /* Tests have proven that 20K is a very bad buffer size for uploads on + Windows, while 16K for some odd reason performed a lot better. + We do the ifndef check to allow this value to easier be changed at build + time for those who feel adventurous. */ +#define CURL_MAX_WRITE_SIZE 16384 +#endif + +typedef size_t (*curl_write_callback)(char *buffer, + size_t size, + size_t nitems, + void *outstream); + +/* This is a return code for the read callback that, when returned, will + signal libcurl to immediately abort the current transfer. */ +#define CURL_READFUNC_ABORT 0x10000000 +typedef size_t (*curl_read_callback)(char *buffer, + size_t size, + size_t nitems, + void *instream); + +typedef enum { + CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */ + CURLSOCKTYPE_LAST /* never use */ +} curlsocktype; + +typedef int (*curl_sockopt_callback)(void *clientp, + curl_socket_t curlfd, + curlsocktype purpose); + +#ifndef CURL_NO_OLDIES + /* not used since 7.10.8, will be removed in a future release */ +typedef int (*curl_passwd_callback)(void *clientp, + const char *prompt, + char *buffer, + int buflen); +#endif + +typedef enum { + CURLIOE_OK, /* I/O operation successful */ + CURLIOE_UNKNOWNCMD, /* command was unknown to callback */ + CURLIOE_FAILRESTART, /* failed to restart the read */ + CURLIOE_LAST /* never use */ +} curlioerr; + +typedef enum { + CURLIOCMD_NOP, /* no operation */ + CURLIOCMD_RESTARTREAD, /* restart the read stream from start */ + CURLIOCMD_LAST /* never use */ +} curliocmd; + +typedef curlioerr (*curl_ioctl_callback)(CURL *handle, + int cmd, + void *clientp); + +/* + * The following typedef's are signatures of malloc, free, realloc, strdup and + * calloc respectively. Function pointers of these types can be passed to the + * curl_global_init_mem() function to set user defined memory management + * callback routines. + */ +typedef void *(*curl_malloc_callback)(size_t size); +typedef void (*curl_free_callback)(void *ptr); +typedef void *(*curl_realloc_callback)(void *ptr, size_t size); +typedef char *(*curl_strdup_callback)(const char *str); +typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); + +/* the kind of data that is passed to information_callback*/ +typedef enum { + CURLINFO_TEXT = 0, + CURLINFO_HEADER_IN, /* 1 */ + CURLINFO_HEADER_OUT, /* 2 */ + CURLINFO_DATA_IN, /* 3 */ + CURLINFO_DATA_OUT, /* 4 */ + CURLINFO_SSL_DATA_IN, /* 5 */ + CURLINFO_SSL_DATA_OUT, /* 6 */ + CURLINFO_END +} curl_infotype; + +typedef int (*curl_debug_callback) + (CURL *handle, /* the handle/transfer this concerns */ + curl_infotype type, /* what kind of data */ + char *data, /* points to the data */ + size_t size, /* size of the data pointed to */ + void *userptr); /* whatever the user please */ + +/* All possible error codes from all sorts of curl functions. Future versions + may return other values, stay prepared. + + Always add new return codes last. Never *EVER* remove any. The return + codes must remain the same! + */ + +typedef enum { + CURLE_OK = 0, + CURLE_UNSUPPORTED_PROTOCOL, /* 1 */ + CURLE_FAILED_INIT, /* 2 */ + CURLE_URL_MALFORMAT, /* 3 */ + CURLE_OBSOLETE4, /* 4 - NOT USED */ + CURLE_COULDNT_RESOLVE_PROXY, /* 5 */ + CURLE_COULDNT_RESOLVE_HOST, /* 6 */ + CURLE_COULDNT_CONNECT, /* 7 */ + CURLE_FTP_WEIRD_SERVER_REPLY, /* 8 */ + CURLE_REMOTE_ACCESS_DENIED, /* 9 a service was denied by the server + due to lack of access - when login fails + this is not returned. */ + CURLE_OBSOLETE10, /* 10 - NOT USED */ + CURLE_FTP_WEIRD_PASS_REPLY, /* 11 */ + CURLE_OBSOLETE12, /* 12 - NOT USED */ + CURLE_FTP_WEIRD_PASV_REPLY, /* 13 */ + CURLE_FTP_WEIRD_227_FORMAT, /* 14 */ + CURLE_FTP_CANT_GET_HOST, /* 15 */ + CURLE_OBSOLETE16, /* 16 - NOT USED */ + CURLE_FTP_COULDNT_SET_TYPE, /* 17 */ + CURLE_PARTIAL_FILE, /* 18 */ + CURLE_FTP_COULDNT_RETR_FILE, /* 19 */ + CURLE_OBSOLETE20, /* 20 - NOT USED */ + CURLE_QUOTE_ERROR, /* 21 - quote command failure */ + CURLE_HTTP_RETURNED_ERROR, /* 22 */ + CURLE_WRITE_ERROR, /* 23 */ + CURLE_OBSOLETE24, /* 24 - NOT USED */ + CURLE_UPLOAD_FAILED, /* 25 - failed upload "command" */ + CURLE_READ_ERROR, /* 26 - could open/read from file */ + CURLE_OUT_OF_MEMORY, /* 27 */ + /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error + instead of a memory allocation error if CURL_DOES_CONVERSIONS + is defined + */ + CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was reached */ + CURLE_OBSOLETE29, /* 29 - NOT USED */ + CURLE_FTP_PORT_FAILED, /* 30 - FTP PORT operation failed */ + CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */ + CURLE_OBSOLETE32, /* 32 - NOT USED */ + CURLE_RANGE_ERROR, /* 33 - RANGE "command" didn't work */ + CURLE_HTTP_POST_ERROR, /* 34 */ + CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */ + CURLE_BAD_DOWNLOAD_RESUME, /* 36 - couldn't resume download */ + CURLE_FILE_COULDNT_READ_FILE, /* 37 */ + CURLE_LDAP_CANNOT_BIND, /* 38 */ + CURLE_LDAP_SEARCH_FAILED, /* 39 */ + CURLE_OBSOLETE40, /* 40 - NOT USED */ + CURLE_FUNCTION_NOT_FOUND, /* 41 */ + CURLE_ABORTED_BY_CALLBACK, /* 42 */ + CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */ + CURLE_OBSOLETE44, /* 44 - NOT USED */ + CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ + CURLE_OBSOLETE46, /* 46 - NOT USED */ + CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ + CURLE_UNKNOWN_TELNET_OPTION, /* 48 - User specified an unknown option */ + CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ + CURLE_OBSOLETE50, /* 50 - NOT USED */ + CURLE_SSL_PEER_CERTIFICATE, /* 51 - peer's certificate wasn't ok */ + CURLE_GOT_NOTHING, /* 52 - when this is a specific error */ + CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */ + CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as + default */ + CURLE_SEND_ERROR, /* 55 - failed sending network data */ + CURLE_RECV_ERROR, /* 56 - failure in receiving network data */ + CURLE_OBSOLETE57, /* 57 - NOT IN USE */ + CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */ + CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */ + CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */ + CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized transfer encoding */ + CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */ + CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */ + CURLE_USE_SSL_FAILED, /* 64 - Requested FTP SSL level failed */ + CURLE_SEND_FAIL_REWIND, /* 65 - Sending the data requires a rewind + that failed */ + CURLE_SSL_ENGINE_INITFAILED, /* 66 - failed to initialise ENGINE */ + CURLE_LOGIN_DENIED, /* 67 - user, password or similar was not + accepted and we failed to login */ + CURLE_TFTP_NOTFOUND, /* 68 - file not found on server */ + CURLE_TFTP_PERM, /* 69 - permission problem on server */ + CURLE_REMOTE_DISK_FULL, /* 70 - out of disk space on server */ + CURLE_TFTP_ILLEGAL, /* 71 - Illegal TFTP operation */ + CURLE_TFTP_UNKNOWNID, /* 72 - Unknown transfer ID */ + CURLE_REMOTE_FILE_EXISTS, /* 73 - File already exists */ + CURLE_TFTP_NOSUCHUSER, /* 74 - No such user */ + CURLE_CONV_FAILED, /* 75 - conversion failed */ + CURLE_CONV_REQD, /* 76 - caller must register conversion + callbacks using curl_easy_setopt options + CURLOPT_CONV_FROM_NETWORK_FUNCTION, + CURLOPT_CONV_TO_NETWORK_FUNCTION, and + CURLOPT_CONV_FROM_UTF8_FUNCTION */ + CURLE_SSL_CACERT_BADFILE, /* 77 - could not load CACERT file, missing + or wrong format */ + CURLE_REMOTE_FILE_NOT_FOUND, /* 78 - remote file not found */ + CURLE_SSH, /* 79 - error from the SSH layer, somewhat + generic so the error message will be of + interest when this has happened */ + + CURLE_SSL_SHUTDOWN_FAILED, /* 80 - Failed to shut down the SSL + connection */ + CURL_LAST /* never use! */ +} CURLcode; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2009 */ + +/* The following were added in 7.17.0 */ +#define CURLE_OBSOLETE CURLE_OBSOLETE50 /* noone should be using this! */ +#define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46 +#define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44 +#define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10 +#define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16 +#define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32 +#define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29 +#define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12 +#define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20 +#define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40 +#define CURLE_MALFORMAT_USER CURLE_OBSOLETE24 +#define CURLE_SHARE_IN_USE CURLE_OBSOLETE57 +#define CURLE_URL_MALFORMAT_USER CURLE_OBSOLETE4 + +#define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED +#define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE +#define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR +#define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL +#define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS +#define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR +#define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED + +/* The following were added earlier */ + +#define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT + +#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR +#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED +#define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED + +#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE +#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME + +/* This was the error code 50 in 7.7.3 and a few earlier versions, this + is no longer used by libcurl but is instead #defined here only to not + make programs break */ +#define CURLE_ALREADY_COMPLETE 99999 + +#endif /*!CURL_NO_OLDIES*/ + +/* This prototype applies to all conversion callbacks */ +typedef CURLcode (*curl_conv_callback)(char *buffer, size_t length); + +typedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl, /* easy handle */ + void *ssl_ctx, /* actually an + OpenSSL SSL_CTX */ + void *userptr); + +typedef enum { + CURLPROXY_HTTP = 0, + CURLPROXY_SOCKS4 = 4, + CURLPROXY_SOCKS5 = 5 +} curl_proxytype; + +#define CURLAUTH_NONE 0 /* nothing */ +#define CURLAUTH_BASIC (1<<0) /* Basic (default) */ +#define CURLAUTH_DIGEST (1<<1) /* Digest */ +#define CURLAUTH_GSSNEGOTIATE (1<<2) /* GSS-Negotiate */ +#define CURLAUTH_NTLM (1<<3) /* NTLM */ +#define CURLAUTH_ANY ~0 /* all types set */ +#define CURLAUTH_ANYSAFE (~CURLAUTH_BASIC) + +#define CURLSSH_AUTH_ANY ~0 /* all types supported by the server */ +#define CURLSSH_AUTH_NONE 0 /* none allowed, silly but complete */ +#define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */ +#define CURLSSH_AUTH_PASSWORD (1<<1) /* password */ +#define CURLSSH_AUTH_HOST (1<<2) /* host key files */ +#define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */ +#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY + +#define CURL_ERROR_SIZE 256 + +/* parameter for the CURLOPT_USE_SSL option */ +typedef enum { + CURLUSESSL_NONE, /* do not attempt to use SSL */ + CURLUSESSL_TRY, /* try using SSL, proceed anyway otherwise */ + CURLUSESSL_CONTROL, /* SSL for the control connection or fail */ + CURLUSESSL_ALL, /* SSL for all communication or fail */ + CURLUSESSL_LAST /* not an option, never use */ +} curl_usessl; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2009 */ + +#define CURLFTPSSL_NONE CURLUSESSL_NONE +#define CURLFTPSSL_TRY CURLUSESSL_TRY +#define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL +#define CURLFTPSSL_ALL CURLUSESSL_ALL +#define CURLFTPSSL_LAST CURLUSESSL_LAST +#define curl_ftpssl curl_usessl +#endif /*!CURL_NO_OLDIES*/ + +/* parameter for the CURLOPT_FTP_SSL_CCC option */ +typedef enum { + CURLFTPSSL_CCC_NONE, /* do not send CCC */ + CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */ + CURLFTPSSL_CCC_ACTIVE, /* Initiate the shutdown */ + CURLFTPSSL_CCC_LAST /* not an option, never use */ +} curl_ftpccc; + +/* parameter for the CURLOPT_FTPSSLAUTH option */ +typedef enum { + CURLFTPAUTH_DEFAULT, /* let libcurl decide */ + CURLFTPAUTH_SSL, /* use "AUTH SSL" */ + CURLFTPAUTH_TLS, /* use "AUTH TLS" */ + CURLFTPAUTH_LAST /* not an option, never use */ +} curl_ftpauth; + +/* parameter for the CURLOPT_FTP_FILEMETHOD option */ +typedef enum { + CURLFTPMETHOD_DEFAULT, /* let libcurl pick */ + CURLFTPMETHOD_MULTICWD, /* single CWD operation for each path part */ + CURLFTPMETHOD_NOCWD, /* no CWD at all */ + CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */ + CURLFTPMETHOD_LAST /* not an option, never use */ +} curl_ftpmethod; + +/* long may be 32 or 64 bits, but we should never depend on anything else + but 32 */ +#define CURLOPTTYPE_LONG 0 +#define CURLOPTTYPE_OBJECTPOINT 10000 +#define CURLOPTTYPE_FUNCTIONPOINT 20000 +#define CURLOPTTYPE_OFF_T 30000 + +/* name is uppercase CURLOPT_, + type is one of the defined CURLOPTTYPE_ + number is unique identifier */ +#ifdef CINIT +#undef CINIT +#endif +/* + * Figure out if we can use the ## operator, which is supported by ISO/ANSI C + * and C++. Some compilers support it without setting __STDC__ or __cplusplus + * so we need to carefully check for them too. We don't use configure-checks + * for these since we want these headers to remain generic and working for all + * platforms. + */ +#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ + defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \ + defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \ + defined(__ILEC400__) + /* This compiler is believed to have an ISO compatible preprocessor */ +#define CURL_ISOCPP +#else + /* This compiler is believed NOT to have an ISO compatible preprocessor */ +#undef CURL_ISOCPP +#endif + +#ifdef CURL_ISOCPP +#define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define LONG CURLOPTTYPE_LONG +#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT +#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT +#define OFF_T CURLOPTTYPE_OFF_T +#define CINIT(name,type,number) CURLOPT_/**/name = type + number +#endif + +/* + * This macro-mania below setups the CURLOPT_[what] enum, to be used with + * curl_easy_setopt(). The first argument in the CINIT() macro is the [what] + * word. + */ + +typedef enum { + /* This is the FILE * or void * the regular output should be written to. */ + CINIT(FILE, OBJECTPOINT, 1), + + /* The full URL to get/put */ + CINIT(URL, OBJECTPOINT, 2), + + /* Port number to connect to, if other than default. */ + CINIT(PORT, LONG, 3), + + /* Name of proxy to use. */ + CINIT(PROXY, OBJECTPOINT, 4), + + /* "name:password" to use when fetching. */ + CINIT(USERPWD, OBJECTPOINT, 5), + + /* "name:password" to use with proxy. */ + CINIT(PROXYUSERPWD, OBJECTPOINT, 6), + + /* Range to get, specified as an ASCII string. */ + CINIT(RANGE, OBJECTPOINT, 7), + + /* not used */ + + /* Specified file stream to upload from (use as input): */ + CINIT(INFILE, OBJECTPOINT, 9), + + /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE + * bytes big. If this is not used, error messages go to stderr instead: */ + CINIT(ERRORBUFFER, OBJECTPOINT, 10), + + /* Function that will be called to store the output (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11), + + /* Function that will be called to read the input (instead of fread). The + * parameters will use fread() syntax, make sure to follow them. */ + CINIT(READFUNCTION, FUNCTIONPOINT, 12), + + /* Time-out the read operation after this amount of seconds */ + CINIT(TIMEOUT, LONG, 13), + + /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about + * how large the file being sent really is. That allows better error + * checking and better verifies that the upload was succcessful. -1 means + * unknown size. + * + * For large file support, there is also a _LARGE version of the key + * which takes an off_t type, allowing platforms with larger off_t + * sizes to handle larger files. See below for INFILESIZE_LARGE. + */ + CINIT(INFILESIZE, LONG, 14), + + /* POST input fields. */ + CINIT(POSTFIELDS, OBJECTPOINT, 15), + + /* Set the referer page (needed by some CGIs) */ + CINIT(REFERER, OBJECTPOINT, 16), + + /* Set the FTP PORT string (interface name, named or numerical IP address) + Use i.e '-' to use default address. */ + CINIT(FTPPORT, OBJECTPOINT, 17), + + /* Set the User-Agent string (examined by some CGIs) */ + CINIT(USERAGENT, OBJECTPOINT, 18), + + /* If the download receives less than "low speed limit" bytes/second + * during "low speed time" seconds, the operations is aborted. + * You could i.e if you have a pretty high speed connection, abort if + * it is less than 2000 bytes/sec during 20 seconds. + */ + + /* Set the "low speed limit" */ + CINIT(LOW_SPEED_LIMIT, LONG, 19), + + /* Set the "low speed time" */ + CINIT(LOW_SPEED_TIME, LONG, 20), + + /* Set the continuation offset. + * + * Note there is also a _LARGE version of this key which uses + * off_t types, allowing for large file offsets on platforms which + * use larger-than-32-bit off_t's. Look below for RESUME_FROM_LARGE. + */ + CINIT(RESUME_FROM, LONG, 21), + + /* Set cookie in request: */ + CINIT(COOKIE, OBJECTPOINT, 22), + + /* This points to a linked list of headers, struct curl_slist kind */ + CINIT(HTTPHEADER, OBJECTPOINT, 23), + + /* This points to a linked list of post entries, struct HttpPost */ + CINIT(HTTPPOST, OBJECTPOINT, 24), + + /* name of the file keeping your private SSL-certificate */ + CINIT(SSLCERT, OBJECTPOINT, 25), + + /* password for the SSL or SSH private key */ + CINIT(KEYPASSWD, OBJECTPOINT, 26), + + /* send TYPE parameter? */ + CINIT(CRLF, LONG, 27), + + /* send linked-list of QUOTE commands */ + CINIT(QUOTE, OBJECTPOINT, 28), + + /* send FILE * or void * to store headers to, if you use a callback it + is simply passed to the callback unmodified */ + CINIT(WRITEHEADER, OBJECTPOINT, 29), + + /* point to a file to read the initial cookies from, also enables + "cookie awareness" */ + CINIT(COOKIEFILE, OBJECTPOINT, 31), + + /* What version to specifly try to use. + See CURL_SSLVERSION defines below. */ + CINIT(SSLVERSION, LONG, 32), + + /* What kind of HTTP time condition to use, see defines */ + CINIT(TIMECONDITION, LONG, 33), + + /* Time to use with the above condition. Specified in number of seconds + since 1 Jan 1970 */ + CINIT(TIMEVALUE, LONG, 34), + + /* 35 = OBSOLETE */ + + /* Custom request, for customizing the get command like + HTTP: DELETE, TRACE and others + FTP: to use a different list command + */ + CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), + + /* HTTP request, for odd commands like DELETE, TRACE and others */ + CINIT(STDERR, OBJECTPOINT, 37), + + /* 38 is not used */ + + /* send linked-list of post-transfer QUOTE commands */ + CINIT(POSTQUOTE, OBJECTPOINT, 39), + + /* Pass a pointer to string of the output using full variable-replacement + as described elsewhere. */ + CINIT(WRITEINFO, OBJECTPOINT, 40), + + CINIT(VERBOSE, LONG, 41), /* talk a lot */ + CINIT(HEADER, LONG, 42), /* throw the header out too */ + CINIT(NOPROGRESS, LONG, 43), /* shut off the progress meter */ + CINIT(NOBODY, LONG, 44), /* use HEAD to get http document */ + CINIT(FAILONERROR, LONG, 45), /* no output on http error codes >= 300 */ + CINIT(UPLOAD, LONG, 46), /* this is an upload */ + CINIT(POST, LONG, 47), /* HTTP POST method */ + CINIT(DIRLISTONLY, LONG, 48), /* return bare names when listing directories */ + + CINIT(APPEND, LONG, 50), /* Append instead of overwrite on upload! */ + + /* Specify whether to read the user+password from the .netrc or the URL. + * This must be one of the CURL_NETRC_* enums below. */ + CINIT(NETRC, LONG, 51), + + CINIT(FOLLOWLOCATION, LONG, 52), /* use Location: Luke! */ + + CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */ + CINIT(PUT, LONG, 54), /* HTTP PUT */ + + /* 55 = OBSOLETE */ + + /* Function that will be called instead of the internal progress display + * function. This function should be defined as the curl_progress_callback + * prototype defines. */ + CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56), + + /* Data passed to the progress callback */ + CINIT(PROGRESSDATA, OBJECTPOINT, 57), + + /* We want the referer field set automatically when following locations */ + CINIT(AUTOREFERER, LONG, 58), + + /* Port of the proxy, can be set in the proxy string as well with: + "[host]:[port]" */ + CINIT(PROXYPORT, LONG, 59), + + /* size of the POST input data, if strlen() is not good to use */ + CINIT(POSTFIELDSIZE, LONG, 60), + + /* tunnel non-http operations through a HTTP proxy */ + CINIT(HTTPPROXYTUNNEL, LONG, 61), + + /* Set the interface string to use as outgoing network interface */ + CINIT(INTERFACE, OBJECTPOINT, 62), + + /* Set the krb4/5 security level, this also enables krb4/5 awareness. This + * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string + * is set but doesn't match one of these, 'private' will be used. */ + CINIT(KRBLEVEL, OBJECTPOINT, 63), + + /* Set if we should verify the peer in ssl handshake, set 1 to verify. */ + CINIT(SSL_VERIFYPEER, LONG, 64), + + /* The CApath or CAfile used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CINIT(CAINFO, OBJECTPOINT, 65), + + /* 66 = OBSOLETE */ + /* 67 = OBSOLETE */ + + /* Maximum number of http redirects to follow */ + CINIT(MAXREDIRS, LONG, 68), + + /* Pass a long set to 1 to get the date of the requested document (if + possible)! Pass a zero to shut it off. */ + CINIT(FILETIME, LONG, 69), + + /* This points to a linked list of telnet options */ + CINIT(TELNETOPTIONS, OBJECTPOINT, 70), + + /* Max amount of cached alive connections */ + CINIT(MAXCONNECTS, LONG, 71), + + /* What policy to use when closing connections when the cache is filled + up */ + CINIT(CLOSEPOLICY, LONG, 72), + + /* 73 = OBSOLETE */ + + /* Set to explicitly use a new connection for the upcoming transfer. + Do not use this unless you're absolutely sure of this, as it makes the + operation slower and is less friendly for the network. */ + CINIT(FRESH_CONNECT, LONG, 74), + + /* Set to explicitly forbid the upcoming transfer's connection to be re-used + when done. Do not use this unless you're absolutely sure of this, as it + makes the operation slower and is less friendly for the network. */ + CINIT(FORBID_REUSE, LONG, 75), + + /* Set to a file name that contains random data for libcurl to use to + seed the random engine when doing SSL connects. */ + CINIT(RANDOM_FILE, OBJECTPOINT, 76), + + /* Set to the Entropy Gathering Daemon socket pathname */ + CINIT(EGDSOCKET, OBJECTPOINT, 77), + + /* Time-out connect operations after this amount of seconds, if connects + are OK within this time, then fine... This only aborts the connect + phase. [Only works on unix-style/SIGALRM operating systems] */ + CINIT(CONNECTTIMEOUT, LONG, 78), + + /* Function that will be called to store headers (instead of fwrite). The + * parameters will use fwrite() syntax, make sure to follow them. */ + CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79), + + /* Set this to force the HTTP request to get back to GET. Only really usable + if POST, PUT or a custom request have been used first. + */ + CINIT(HTTPGET, LONG, 80), + + /* Set if we should verify the Common name from the peer certificate in ssl + * handshake, set 1 to check existence, 2 to ensure that it matches the + * provided hostname. */ + CINIT(SSL_VERIFYHOST, LONG, 81), + + /* Specify which file name to write all known cookies in after completed + operation. Set file name to "-" (dash) to make it go to stdout. */ + CINIT(COOKIEJAR, OBJECTPOINT, 82), + + /* Specify which SSL ciphers to use */ + CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83), + + /* Specify which HTTP version to use! This must be set to one of the + CURL_HTTP_VERSION* enums set below. */ + CINIT(HTTP_VERSION, LONG, 84), + + /* Specificly switch on or off the FTP engine's use of the EPSV command. By + default, that one will always be attempted before the more traditional + PASV command. */ + CINIT(FTP_USE_EPSV, LONG, 85), + + /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ + CINIT(SSLCERTTYPE, OBJECTPOINT, 86), + + /* name of the file keeping your private SSL-key */ + CINIT(SSLKEY, OBJECTPOINT, 87), + + /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ + CINIT(SSLKEYTYPE, OBJECTPOINT, 88), + + /* crypto engine for the SSL-sub system */ + CINIT(SSLENGINE, OBJECTPOINT, 89), + + /* set the crypto engine for the SSL-sub system as default + the param has no meaning... + */ + CINIT(SSLENGINE_DEFAULT, LONG, 90), + + /* Non-zero value means to use the global dns cache */ + CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* To become OBSOLETE soon */ + + /* DNS cache timeout */ + CINIT(DNS_CACHE_TIMEOUT, LONG, 92), + + /* send linked-list of pre-transfer QUOTE commands (Wesley Laxton)*/ + CINIT(PREQUOTE, OBJECTPOINT, 93), + + /* set the debug function */ + CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94), + + /* set the data for the debug function */ + CINIT(DEBUGDATA, OBJECTPOINT, 95), + + /* mark this as start of a cookie session */ + CINIT(COOKIESESSION, LONG, 96), + + /* The CApath directory used to validate the peer certificate + this option is used only if SSL_VERIFYPEER is true */ + CINIT(CAPATH, OBJECTPOINT, 97), + + /* Instruct libcurl to use a smaller receive buffer */ + CINIT(BUFFERSIZE, LONG, 98), + + /* Instruct libcurl to not use any signal/alarm handlers, even when using + timeouts. This option is useful for multi-threaded applications. + See libcurl-the-guide for more background information. */ + CINIT(NOSIGNAL, LONG, 99), + + /* Provide a CURLShare for mutexing non-ts data */ + CINIT(SHARE, OBJECTPOINT, 100), + + /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default), + CURLPROXY_SOCKS4 and CURLPROXY_SOCKS5. */ + CINIT(PROXYTYPE, LONG, 101), + + /* Set the Accept-Encoding string. Use this to tell a server you would like + the response to be compressed. */ + CINIT(ENCODING, OBJECTPOINT, 102), + + /* Set pointer to private data */ + CINIT(PRIVATE, OBJECTPOINT, 103), + + /* Set aliases for HTTP 200 in the HTTP Response header */ + CINIT(HTTP200ALIASES, OBJECTPOINT, 104), + + /* Continue to send authentication (user+password) when following locations, + even when hostname changed. This can potentionally send off the name + and password to whatever host the server decides. */ + CINIT(UNRESTRICTED_AUTH, LONG, 105), + + /* Specificly switch on or off the FTP engine's use of the EPRT command ( it + also disables the LPRT attempt). By default, those ones will always be + attempted before the good old traditional PORT command. */ + CINIT(FTP_USE_EPRT, LONG, 106), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_USERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CINIT(HTTPAUTH, LONG, 107), + + /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx + in second argument. The function must be matching the + curl_ssl_ctx_callback proto. */ + CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108), + + /* Set the userdata for the ssl context callback function's third + argument */ + CINIT(SSL_CTX_DATA, OBJECTPOINT, 109), + + /* FTP Option that causes missing dirs to be created on the remote server */ + CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110), + + /* Set this to a bitmask value to enable the particular authentications + methods you like. Use this in combination with CURLOPT_PROXYUSERPWD. + Note that setting multiple bits may cause extra network round-trips. */ + CINIT(PROXYAUTH, LONG, 111), + + /* FTP option that changes the timeout, in seconds, associated with + getting a response. This is different from transfer timeout time and + essentially places a demand on the FTP server to acknowledge commands + in a timely manner. */ + CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112), + + /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to + tell libcurl to resolve names to those IP versions only. This only has + affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */ + CINIT(IPRESOLVE, LONG, 113), + + /* Set this option to limit the size of a file that will be downloaded from + an HTTP or FTP server. + + Note there is also _LARGE version which adds large file support for + platforms which have larger off_t sizes. See MAXFILESIZE_LARGE below. */ + CINIT(MAXFILESIZE, LONG, 114), + + /* See the comment for INFILESIZE above, but in short, specifies + * the size of the file being uploaded. -1 means unknown. + */ + CINIT(INFILESIZE_LARGE, OFF_T, 115), + + /* Sets the continuation offset. There is also a LONG version of this; + * look above for RESUME_FROM. + */ + CINIT(RESUME_FROM_LARGE, OFF_T, 116), + + /* Sets the maximum size of data that will be downloaded from + * an HTTP or FTP server. See MAXFILESIZE above for the LONG version. + */ + CINIT(MAXFILESIZE_LARGE, OFF_T, 117), + + /* Set this option to the file name of your .netrc file you want libcurl + to parse (using the CURLOPT_NETRC option). If not set, libcurl will do + a poor attempt to find the user's home directory and check for a .netrc + file in there. */ + CINIT(NETRC_FILE, OBJECTPOINT, 118), + + /* Enable SSL/TLS for FTP, pick one of: + CURLFTPSSL_TRY - try using SSL, proceed anyway otherwise + CURLFTPSSL_CONTROL - SSL for the control connection or fail + CURLFTPSSL_ALL - SSL for all communication or fail + */ + CINIT(USE_SSL, LONG, 119), + + /* The _LARGE version of the standard POSTFIELDSIZE option */ + CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120), + + /* Enable/disable the TCP Nagle algorithm */ + CINIT(TCP_NODELAY, LONG, 121), + + /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 123 OBSOLETE. Gone in 7.16.0 */ + /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */ + /* 127 OBSOLETE. Gone in 7.16.0 */ + /* 128 OBSOLETE. Gone in 7.16.0 */ + + /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option + can be used to change libcurl's default action which is to first try + "AUTH SSL" and then "AUTH TLS" in this order, and proceed when a OK + response has been received. + + Available parameters are: + CURLFTPAUTH_DEFAULT - let libcurl decide + CURLFTPAUTH_SSL - try "AUTH SSL" first, then TLS + CURLFTPAUTH_TLS - try "AUTH TLS" first, then SSL + */ + CINIT(FTPSSLAUTH, LONG, 129), + + CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130), + CINIT(IOCTLDATA, OBJECTPOINT, 131), + + /* 132 OBSOLETE. Gone in 7.16.0 */ + /* 133 OBSOLETE. Gone in 7.16.0 */ + + /* zero terminated string for pass on to the FTP server when asked for + "account" info */ + CINIT(FTP_ACCOUNT, OBJECTPOINT, 134), + + /* feed cookies into cookie engine */ + CINIT(COOKIELIST, OBJECTPOINT, 135), + + /* ignore Content-Length */ + CINIT(IGNORE_CONTENT_LENGTH, LONG, 136), + + /* Set to non-zero to skip the IP address received in a 227 PASV FTP server + response. Typically used for FTP-SSL purposes but is not restricted to + that. libcurl will then instead use the same IP address it used for the + control connection. */ + CINIT(FTP_SKIP_PASV_IP, LONG, 137), + + /* Select "file method" to use when doing FTP, see the curl_ftpmethod + above. */ + CINIT(FTP_FILEMETHOD, LONG, 138), + + /* Local port number to bind the socket to */ + CINIT(LOCALPORT, LONG, 139), + + /* Number of ports to try, including the first one set with LOCALPORT. + Thus, setting it to 1 will make no additional attempts but the first. + */ + CINIT(LOCALPORTRANGE, LONG, 140), + + /* no transfer, set up connection and let application use the socket by + extracting it with CURLINFO_LASTSOCKET */ + CINIT(CONNECT_ONLY, LONG, 141), + + /* Function that will be called to convert from the + network encoding (instead of using the iconv calls in libcurl) */ + CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142), + + /* Function that will be called to convert to the + network encoding (instead of using the iconv calls in libcurl) */ + CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143), + + /* Function that will be called to convert from UTF8 + (instead of using the iconv calls in libcurl) + Note that this is used only for SSL certificate processing */ + CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144), + + /* if the connection proceeds too quickly then need to slow it down */ + /* limit-rate: maximum number of bytes per second to send or receive */ + CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145), + CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146), + + /* Pointer to command string to send if USER/PASS fails. */ + CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147), + + /* callback function for setting socket options */ + CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148), + CINIT(SOCKOPTDATA, OBJECTPOINT, 149), + + /* set to 0 to disable session ID re-use for this transfer, default is + enabled (== 1) */ + CINIT(SSL_SESSIONID_CACHE, LONG, 150), + + /* allowed SSH authentication methods */ + CINIT(SSH_AUTH_TYPES, LONG, 151), + + /* Used by scp/sftp to do public/private key authentication */ + CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152), + CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153), + + /* Send CCC (Clear Command Channel) after authentication */ + CINIT(FTP_SSL_CCC, LONG, 154), + + /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */ + CINIT(TIMEOUT_MS, LONG, 155), + CINIT(CONNECTTIMEOUT_MS, LONG, 156), + + /* set to zero to disable the libcurl's decoding and thus pass the raw body + data to the appliction even when it is encoded/compressed */ + CINIT(HTTP_TRANSFER_DECODING, LONG, 157), + CINIT(HTTP_CONTENT_DECODING, LONG, 158), + + /* Permission used when creating new files and directories on the remote + server for protocols that support it, SFTP/SCP/FILE */ + CINIT(NEW_FILE_PERMS, LONG, 159), + CINIT(NEW_DIRECTORY_PERMS, LONG, 160), + + CURLOPT_LASTENTRY /* the last unused */ +} CURLoption; + +#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all + the obsolete stuff removed! */ + +/* Backwards compatibility with older names */ +/* These are scheduled to disappear by 2009 */ + +/* The following were added in 7.17.0 */ +#define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD +#define CURLOPT_FTPAPPEND CURLOPT_APPEND +#define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY +#define CURLOPT_FTP_SSL CURLOPT_USE_SSL + +/* The following were added earlier */ + +#define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD +#define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL + +#else +/* This is set if CURL_NO_OLDIES is defined at compile-time */ +#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ +#endif + + + /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host + name resolves addresses using more than one IP protocol version, this + option might be handy to force libcurl to use a specific IP version. */ +#define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP + versions that your system allows */ +#define CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */ +#define CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */ + + /* three convenient "aliases" that follow the name scheme better */ +#define CURLOPT_WRITEDATA CURLOPT_FILE +#define CURLOPT_READDATA CURLOPT_INFILE +#define CURLOPT_HEADERDATA CURLOPT_WRITEHEADER + + /* These enums are for use with the CURLOPT_HTTP_VERSION option. */ +enum { + CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd + like the library to choose the best possible + for us! */ + CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */ + CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */ + + CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */ +}; + + /* These enums are for use with the CURLOPT_NETRC option. */ +enum CURL_NETRC_OPTION { + CURL_NETRC_IGNORED, /* The .netrc will never be read. + * This is the default. */ + CURL_NETRC_OPTIONAL, /* A user:password in the URL will be preferred + * to one in the .netrc. */ + CURL_NETRC_REQUIRED, /* A user:password in the URL will be ignored. + * Unless one is set programmatically, the .netrc + * will be queried. */ + CURL_NETRC_LAST +}; + +enum { + CURL_SSLVERSION_DEFAULT, + CURL_SSLVERSION_TLSv1, + CURL_SSLVERSION_SSLv2, + CURL_SSLVERSION_SSLv3, + + CURL_SSLVERSION_LAST /* never use, keep last */ +}; + + +typedef enum { + CURL_TIMECOND_NONE, + + CURL_TIMECOND_IFMODSINCE, + CURL_TIMECOND_IFUNMODSINCE, + CURL_TIMECOND_LASTMOD, + + CURL_TIMECOND_LAST +} curl_TimeCond; + +#ifdef __BEOS__ +#include +#endif + + +/* curl_strequal() and curl_strnequal() are subject for removal in a future + libcurl, see lib/README.curlx for details */ +CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2); +CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n); + +/* name is uppercase CURLFORM_ */ +#ifdef CFINIT +#undef CFINIT +#endif + +#ifdef CURL_ISOCPP +#define CFINIT(name) CURLFORM_ ## name +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define CFINIT(name) CURLFORM_/**/name +#endif + +typedef enum { + CFINIT(NOTHING), /********* the first one is unused ************/ + + /* */ + CFINIT(COPYNAME), + CFINIT(PTRNAME), + CFINIT(NAMELENGTH), + CFINIT(COPYCONTENTS), + CFINIT(PTRCONTENTS), + CFINIT(CONTENTSLENGTH), + CFINIT(FILECONTENT), + CFINIT(ARRAY), + CFINIT(OBSOLETE), + CFINIT(FILE), + + CFINIT(BUFFER), + CFINIT(BUFFERPTR), + CFINIT(BUFFERLENGTH), + + CFINIT(CONTENTTYPE), + CFINIT(CONTENTHEADER), + CFINIT(FILENAME), + CFINIT(END), + CFINIT(OBSOLETE2), + + CURLFORM_LASTENTRY /* the last unusued */ +} CURLformoption; + +#undef CFINIT /* done */ + +/* structure to be used as parameter for CURLFORM_ARRAY */ +struct curl_forms { + CURLformoption option; + const char *value; +}; + +/* use this for multipart formpost building */ +/* Returns code for curl_formadd() + * + * Returns: + * CURL_FORMADD_OK on success + * CURL_FORMADD_MEMORY if the FormInfo allocation fails + * CURL_FORMADD_OPTION_TWICE if one option is given twice for one Form + * CURL_FORMADD_NULL if a null pointer was given for a char + * CURL_FORMADD_MEMORY if the allocation of a FormInfo struct failed + * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used + * CURL_FORMADD_INCOMPLETE if the some FormInfo is not complete (or error) + * CURL_FORMADD_MEMORY if a HttpPost struct cannot be allocated + * CURL_FORMADD_MEMORY if some allocation for string copying failed. + * CURL_FORMADD_ILLEGAL_ARRAY if an illegal option is used in an array + * + ***************************************************************************/ +typedef enum { + CURL_FORMADD_OK, /* first, no error */ + + CURL_FORMADD_MEMORY, + CURL_FORMADD_OPTION_TWICE, + CURL_FORMADD_NULL, + CURL_FORMADD_UNKNOWN_OPTION, + CURL_FORMADD_INCOMPLETE, + CURL_FORMADD_ILLEGAL_ARRAY, + CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */ + + CURL_FORMADD_LAST /* last */ +} CURLFORMcode; + +/* + * NAME curl_formadd() + * + * DESCRIPTION + * + * Pretty advanved function for building multi-part formposts. Each invoke + * adds one part that together construct a full post. Then use + * CURLOPT_HTTPPOST to send it off to libcurl. + */ +CURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost, + struct curl_httppost **last_post, + ...); + +/* + * callback function for curl_formget() + * The void *arg pointer will be the one passed as second argument to curl_formget(). + * The character buffer passed to it must not be freed. + * Should return the buffer length passed to it as the argument "len" on success. + */ +typedef size_t (*curl_formget_callback)(void *arg, const char *buf, size_t len); + +/* + * NAME curl_formget() + * + * DESCRIPTION + * + * Serialize a curl_httppost struct built with curl_formadd(). + * Accepts a void pointer as second argument which will be passed to + * the curl_formget_callback function. + * Returns 0 on success. + */ +CURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg, + curl_formget_callback append); +/* + * NAME curl_formfree() + * + * DESCRIPTION + * + * Free a multipart formpost previously built with curl_formadd(). + */ +CURL_EXTERN void curl_formfree(struct curl_httppost *form); + +/* + * NAME curl_getenv() + * + * DESCRIPTION + * + * Returns a malloc()'ed string that MUST be curl_free()ed after usage is + * complete. DEPRECATED - see lib/README.curlx + */ +CURL_EXTERN char *curl_getenv(const char *variable); + +/* + * NAME curl_version() + * + * DESCRIPTION + * + * Returns a static ascii string of the libcurl version. + */ +CURL_EXTERN char *curl_version(void); + +/* + * NAME curl_easy_escape() + * + * DESCRIPTION + * + * Escapes URL strings (converts all letters consider illegal in URLs to their + * %XX versions). This function returns a new allocated string or NULL if an + * error occurred. + */ +CURL_EXTERN char *curl_easy_escape(CURL *handle, + const char *string, + int length); + +/* the previous version: */ +CURL_EXTERN char *curl_escape(const char *string, + int length); + + +/* + * NAME curl_easy_unescape() + * + * DESCRIPTION + * + * Unescapes URL encoding in strings (converts all %XX codes to their 8bit + * versions). This function returns a new allocated string or NULL if an error + * occurred. + * Conversion Note: On non-ASCII platforms the ASCII %XX codes are + * converted into the host encoding. + */ +CURL_EXTERN char *curl_easy_unescape(CURL *handle, + const char *string, + int length, + int *outlength); + +/* the previous version */ +CURL_EXTERN char *curl_unescape(const char *string, + int length); + +/* + * NAME curl_free() + * + * DESCRIPTION + * + * Provided for de-allocation in the same translation unit that did the + * allocation. Added in libcurl 7.10 + */ +CURL_EXTERN void curl_free(void *p); + +/* + * NAME curl_global_init() + * + * DESCRIPTION + * + * curl_global_init() should be invoked exactly once for each application that + * uses libcurl + */ +CURL_EXTERN CURLcode curl_global_init(long flags); + +/* + * NAME curl_global_init_mem() + * + * DESCRIPTION + * + * curl_global_init() or curl_global_init_mem() should be invoked exactly once + * for each application that uses libcurl. This function can be used to + * initialize libcurl and set user defined memory management callback + * functions. Users can implement memory management routines to check for + * memory leaks, check for mis-use of the curl library etc. User registered + * callback routines with be invoked by this library instead of the system + * memory management routines like malloc, free etc. + */ +CURL_EXTERN CURLcode curl_global_init_mem(long flags, + curl_malloc_callback m, + curl_free_callback f, + curl_realloc_callback r, + curl_strdup_callback s, + curl_calloc_callback c); + +/* + * NAME curl_global_cleanup() + * + * DESCRIPTION + * + * curl_global_cleanup() should be invoked exactly once for each application + * that uses libcurl + */ +CURL_EXTERN void curl_global_cleanup(void); + +/* linked-list structure for the CURLOPT_QUOTE option (and other) */ +struct curl_slist { + char *data; + struct curl_slist *next; +}; + +/* + * NAME curl_slist_append() + * + * DESCRIPTION + * + * Appends a string to a linked list. If no list exists, it will be created + * first. Returns the new list, after appending. + */ +CURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *, + const char *); + +/* + * NAME curl_slist_free_all() + * + * DESCRIPTION + * + * free a previously built curl_slist. + */ +CURL_EXTERN void curl_slist_free_all(struct curl_slist *); + +/* + * NAME curl_getdate() + * + * DESCRIPTION + * + * Returns the time, in seconds since 1 Jan 1970 of the time string given in + * the first argument. The time argument in the second parameter is unused + * and should be set to NULL. + */ +CURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused); + +#define CURLINFO_STRING 0x100000 +#define CURLINFO_LONG 0x200000 +#define CURLINFO_DOUBLE 0x300000 +#define CURLINFO_SLIST 0x400000 +#define CURLINFO_MASK 0x0fffff +#define CURLINFO_TYPEMASK 0xf00000 + +typedef enum { + CURLINFO_NONE, /* first, never use this */ + CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1, + CURLINFO_RESPONSE_CODE = CURLINFO_LONG + 2, + CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3, + CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4, + CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5, + CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6, + CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7, + CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8, + CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9, + CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10, + CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11, + CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12, + CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13, + CURLINFO_FILETIME = CURLINFO_LONG + 14, + CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15, + CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16, + CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17, + CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18, + CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19, + CURLINFO_REDIRECT_COUNT = CURLINFO_LONG + 20, + CURLINFO_PRIVATE = CURLINFO_STRING + 21, + CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG + 22, + CURLINFO_HTTPAUTH_AVAIL = CURLINFO_LONG + 23, + CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, + CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, + CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, + CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, + CURLINFO_COOKIELIST = CURLINFO_SLIST + 28, + CURLINFO_LASTSOCKET = CURLINFO_LONG + 29, + CURLINFO_FTP_ENTRY_PATH = CURLINFO_STRING + 30, + /* Fill in new entries below here! */ + + CURLINFO_LASTONE = 30 +} CURLINFO; + +/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as + CURLINFO_HTTP_CODE */ +#define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE + +typedef enum { + CURLCLOSEPOLICY_NONE, /* first, never use this */ + + CURLCLOSEPOLICY_OLDEST, + CURLCLOSEPOLICY_LEAST_RECENTLY_USED, + CURLCLOSEPOLICY_LEAST_TRAFFIC, + CURLCLOSEPOLICY_SLOWEST, + CURLCLOSEPOLICY_CALLBACK, + + CURLCLOSEPOLICY_LAST /* last, never use this */ +} curl_closepolicy; + +#define CURL_GLOBAL_SSL (1<<0) +#define CURL_GLOBAL_WIN32 (1<<1) +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_NOTHING 0 +#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL + + +/***************************************************************************** + * Setup defines, protos etc for the sharing stuff. + */ + +/* Different data locks for a single share */ +typedef enum { + CURL_LOCK_DATA_NONE = 0, + /* CURL_LOCK_DATA_SHARE is used internaly to say that + * the locking is just made to change the internal state of the share + * itself. + */ + CURL_LOCK_DATA_SHARE, + CURL_LOCK_DATA_COOKIE, + CURL_LOCK_DATA_DNS, + CURL_LOCK_DATA_SSL_SESSION, + CURL_LOCK_DATA_CONNECT, + CURL_LOCK_DATA_LAST +} curl_lock_data; + +/* Different lock access types */ +typedef enum { + CURL_LOCK_ACCESS_NONE = 0, /* unspecified action */ + CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */ + CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */ + CURL_LOCK_ACCESS_LAST /* never use */ +} curl_lock_access; + +typedef void (*curl_lock_function)(CURL *handle, + curl_lock_data data, + curl_lock_access locktype, + void *userptr); +typedef void (*curl_unlock_function)(CURL *handle, + curl_lock_data data, + void *userptr); + +typedef void CURLSH; + +typedef enum { + CURLSHE_OK, /* all is fine */ + CURLSHE_BAD_OPTION, /* 1 */ + CURLSHE_IN_USE, /* 2 */ + CURLSHE_INVALID, /* 3 */ + CURLSHE_NOMEM, /* out of memory */ + CURLSHE_LAST /* never use */ +} CURLSHcode; + +typedef enum { + CURLSHOPT_NONE, /* don't use */ + CURLSHOPT_SHARE, /* specify a data type to share */ + CURLSHOPT_UNSHARE, /* specify shich data type to stop sharing */ + CURLSHOPT_LOCKFUNC, /* pass in a 'curl_lock_function' pointer */ + CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */ + CURLSHOPT_USERDATA, /* pass in a user data pointer used in the lock/unlock + callback functions */ + CURLSHOPT_LAST /* never use */ +} CURLSHoption; + +CURL_EXTERN CURLSH *curl_share_init(void); +CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...); +CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *); + +/**************************************************************************** + * Structures for querying information about the curl library at runtime. + */ + +typedef enum { + CURLVERSION_FIRST, + CURLVERSION_SECOND, + CURLVERSION_THIRD, + CURLVERSION_FOURTH, + CURLVERSION_LAST /* never actually use this */ +} CURLversion; + +/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by + basicly all programs ever, that want to get version information. It is + meant to be a built-in version number for what kind of struct the caller + expects. If the struct ever changes, we redefine the NOW to another enum + from above. */ +#define CURLVERSION_NOW CURLVERSION_FOURTH + +typedef struct { + CURLversion age; /* age of the returned struct */ + const char *version; /* LIBCURL_VERSION */ + unsigned int version_num; /* LIBCURL_VERSION_NUM */ + const char *host; /* OS/host/cpu/machine when configured */ + int features; /* bitmask, see defines below */ + const char *ssl_version; /* human readable string */ + long ssl_version_num; /* not used anymore, always 0 */ + const char *libz_version; /* human readable string */ + /* protocols is terminated by an entry with a NULL protoname */ + const char * const *protocols; + + /* The fields below this were added in CURLVERSION_SECOND */ + const char *ares; + int ares_num; + + /* This field was added in CURLVERSION_THIRD */ + const char *libidn; + + /* These field were added in CURLVERSION_FOURTH */ + + /* Same as '_libiconv_version' if built with HAVE_ICONV */ + int iconv_ver_num; + + const char *libssh_version; /* human readable string */ + +} curl_version_info_data; + +#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */ +#define CURL_VERSION_KERBEROS4 (1<<1) /* kerberos auth is supported */ +#define CURL_VERSION_SSL (1<<2) /* SSL options are present */ +#define CURL_VERSION_LIBZ (1<<3) /* libz features are present */ +#define CURL_VERSION_NTLM (1<<4) /* NTLM auth is supported */ +#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support */ +#define CURL_VERSION_DEBUG (1<<6) /* built with debug capabilities */ +#define CURL_VERSION_ASYNCHDNS (1<<7) /* asynchronous dns resolves */ +#define CURL_VERSION_SPNEGO (1<<8) /* SPNEGO auth */ +#define CURL_VERSION_LARGEFILE (1<<9) /* supports files bigger than 2GB */ +#define CURL_VERSION_IDN (1<<10) /* International Domain Names support */ +#define CURL_VERSION_SSPI (1<<11) /* SSPI is supported */ +#define CURL_VERSION_CONV (1<<12) /* character conversions are + supported */ + +/* + * NAME curl_version_info() + * + * DESCRIPTION + * + * This function returns a pointer to a static copy of the version info + * struct. See above. + */ +CURL_EXTERN curl_version_info_data *curl_version_info(CURLversion); + +/* + * NAME curl_easy_strerror() + * + * DESCRIPTION + * + * The curl_easy_strerror function may be used to turn a CURLcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +CURL_EXTERN const char *curl_easy_strerror(CURLcode); + +/* + * NAME curl_share_strerror() + * + * DESCRIPTION + * + * The curl_share_strerror function may be used to turn a CURLSHcode value + * into the equivalent human readable error string. This is useful + * for printing meaningful error messages. + */ +CURL_EXTERN const char *curl_share_strerror(CURLSHcode); + +#ifdef __cplusplus +} +#endif + +/* unfortunately, the easy.h and multi.h include files need options and info + stuff before they can be included! */ +#include "easy.h" /* nothing in curl is fun without the easy stuff */ +#include "multi.h" + +#endif /* __CURL_CURL_H */ diff --git a/spec/include/curl/curlver.h b/spec/include/curl/curlver.h new file mode 100644 index 00000000..1936c317 --- /dev/null +++ b/spec/include/curl/curlver.h @@ -0,0 +1,67 @@ +#ifndef __CURL_CURLVER_H +#define __CURL_CURLVER_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ + +/* This header file contains nothing but libcurl version info, generated by + a script at release-time. This was made its own header file in 7.11.2 */ + +/* This is the version number of the libcurl package from which this header + file origins: */ +#define LIBCURL_VERSION "7.17.0" + +/* The numeric version number is also available "in parts" by using these + defines: */ +#define LIBCURL_VERSION_MAJOR 7 +#define LIBCURL_VERSION_MINOR 17 +#define LIBCURL_VERSION_PATCH 0 + +/* This is the numeric version of the libcurl version number, meant for easier + parsing and comparions by programs. The LIBCURL_VERSION_NUM define will + always follow this syntax: + + 0xXXYYZZ + + Where XX, YY and ZZ are the main version, release and patch numbers in + hexadecimal (using 8 bits each). All three numbers are always represented + using two digits. 1.2 would appear as "0x010200" while version 9.11.7 + appears as "0x090b07". + + This 6-digit (24 bits) hexadecimal number does not show pre-release number, + and it is always a greater number in a more recent release. It makes + comparisons with greater than and less than work. +*/ +#define LIBCURL_VERSION_NUM 0x071100 + +/* + * This is the date and time when the full source package was created. The + * timestamp is not stored in CVS, as the timestamp is properly set in the + * tarballs by the maketgz script. + * + * The format of the date should follow this template: + * + * "Mon Feb 12 11:35:33 UTC 2007" + */ +#define LIBCURL_TIMESTAMP "Thu Sep 13 20:22:24 UTC 2007" + +#endif /* __CURL_CURLVER_H */ diff --git a/spec/include/curl/easy.h b/spec/include/curl/easy.h new file mode 100644 index 00000000..17de2107 --- /dev/null +++ b/spec/include/curl/easy.h @@ -0,0 +1,81 @@ +#ifndef __CURL_EASY_H +#define __CURL_EASY_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +CURL_EXTERN CURL *curl_easy_init(void); +CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...); +CURL_EXTERN CURLcode curl_easy_perform(CURL *curl); +CURL_EXTERN void curl_easy_cleanup(CURL *curl); + +/* + * NAME curl_easy_getinfo() + * + * DESCRIPTION + * + * Request internal information from the curl session with this function. The + * third argument MUST be a pointer to a long, a pointer to a char * or a + * pointer to a double (as the documentation describes elsewhere). The data + * pointed to will be filled in accordingly and can be relied upon only if the + * function returns CURLE_OK. This function is intended to get used *AFTER* a + * performed transfer, all results from this function are undefined until the + * transfer is completed. + */ +CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); + + +/* + * NAME curl_easy_duphandle() + * + * DESCRIPTION + * + * Creates a new curl session handle with the same options set for the handle + * passed in. Duplicating a handle could only be a matter of cloning data and + * options, internal state info and things like persistant connections cannot + * be transfered. It is useful in multithreaded applications when you can run + * curl_easy_duphandle() for each new thread to avoid a series of identical + * curl_easy_setopt() invokes in every thread. + */ +CURL_EXTERN CURL* curl_easy_duphandle(CURL *curl); + +/* + * NAME curl_easy_reset() + * + * DESCRIPTION + * + * Re-initializes a CURL handle to the default values. This puts back the + * handle to the same state as it was in when it was just created. + * + * It does keep: live connections, the Session ID cache, the DNS cache and the + * cookies. + */ +CURL_EXTERN void curl_easy_reset(CURL *curl); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/spec/include/curl/mprintf.h b/spec/include/curl/mprintf.h new file mode 100644 index 00000000..5c526882 --- /dev/null +++ b/spec/include/curl/mprintf.h @@ -0,0 +1,80 @@ +#ifndef __CURL_MPRINTF_H +#define __CURL_MPRINTF_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ + +#include +#include /* needed for FILE */ + +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +CURL_EXTERN int curl_mprintf(const char *format, ...); +CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...); +CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...); +CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...); +CURL_EXTERN int curl_mvprintf(const char *format, va_list args); +CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args); +CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args); +CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength, const char *format, va_list args); +CURL_EXTERN char *curl_maprintf(const char *format, ...); +CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); + +#ifdef _MPRINTF_REPLACE +# undef printf +# undef fprintf +# undef sprintf +# undef vsprintf +# undef snprintf +# undef vprintf +# undef vfprintf +# undef vsnprintf +# undef aprintf +# undef vaprintf +# define printf curl_mprintf +# define fprintf curl_mfprintf +#ifdef CURLDEBUG +/* When built with CURLDEBUG we define away the sprintf() functions since we + don't want internal code to be using them */ +# define sprintf sprintf_was_used +# define vsprintf vsprintf_was_used +#else +# define sprintf curl_msprintf +# define vsprintf curl_mvsprintf +#endif +# define snprintf curl_msnprintf +# define vprintf curl_mvprintf +# define vfprintf curl_mvfprintf +# define vsnprintf curl_mvsnprintf +# define aprintf curl_maprintf +# define vaprintf curl_mvaprintf +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __CURL_MPRINTF_H */ diff --git a/spec/include/curl/multi.h b/spec/include/curl/multi.h new file mode 100644 index 00000000..094c6484 --- /dev/null +++ b/spec/include/curl/multi.h @@ -0,0 +1,346 @@ +#ifndef __CURL_MULTI_H +#define __CURL_MULTI_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ +/* + This is an "external" header file. Don't give away any internals here! + + GOALS + + o Enable a "pull" interface. The application that uses libcurl decides where + and when to ask libcurl to get/send data. + + o Enable multiple simultaneous transfers in the same thread without making it + complicated for the application. + + o Enable the application to select() on its own file descriptors and curl's + file descriptors simultaneous easily. + +*/ + +/* + * This header file should not really need to include "curl.h" since curl.h + * itself includes this file and we expect user applications to do #include + * without the need for especially including multi.h. + * + * For some reason we added this include here at one point, and rather than to + * break existing (wrongly written) libcurl applications, we leave it as-is + * but with this warning attached. + */ +#include "curl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void CURLM; + +typedef enum { + CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or + curl_multi_socket*() soon */ + CURLM_OK, + CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */ + CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */ + CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */ + CURLM_INTERNAL_ERROR, /* this is a libcurl bug */ + CURLM_BAD_SOCKET, /* the passed in socket argument did not match */ + CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */ + CURLM_LAST +} CURLMcode; + +/* just to make code nicer when using curl_multi_socket() you can now check + for CURLM_CALL_MULTI_SOCKET too in the same style it works for + curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */ +#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM + +typedef enum { + CURLMSG_NONE, /* first, not used */ + CURLMSG_DONE, /* This easy handle has completed. 'result' contains + the CURLcode of the transfer */ + CURLMSG_LAST /* last, not used */ +} CURLMSG; + +struct CURLMsg { + CURLMSG msg; /* what this message means */ + CURL *easy_handle; /* the handle it concerns */ + union { + void *whatever; /* message-specific data */ + CURLcode result; /* return code for transfer */ + } data; +}; +typedef struct CURLMsg CURLMsg; + +/* + * Name: curl_multi_init() + * + * Desc: inititalize multi-style curl usage + * + * Returns: a new CURLM handle to use in all 'curl_multi' functions. + */ +CURL_EXTERN CURLM *curl_multi_init(void); + +/* + * Name: curl_multi_add_handle() + * + * Desc: add a standard curl handle to the multi stack + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, + CURL *curl_handle); + + /* + * Name: curl_multi_remove_handle() + * + * Desc: removes a curl handle from the multi stack again + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, + CURL *curl_handle); + + /* + * Name: curl_multi_fdset() + * + * Desc: Ask curl for its fd_set sets. The app can use these to select() or + * poll() on. We want curl_multi_perform() called as soon as one of + * them are ready. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *exc_fd_set, + int *max_fd); + + /* + * Name: curl_multi_perform() + * + * Desc: When the app thinks there's data available for curl it calls this + * function to read/write whatever there is right now. This returns + * as soon as the reads and writes are done. This function does not + * require that there actually is data available for reading or that + * data can be written, it can be called just in case. It returns + * the number of handles that still transfer data in the second + * argument's integer-pointer. + * + * Returns: CURLMcode type, general multi error code. *NOTE* that this only + * returns errors etc regarding the whole multi stack. There might + * still have occurred problems on invidual transfers even when this + * returns OK. + */ +CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, + int *running_handles); + + /* + * Name: curl_multi_cleanup() + * + * Desc: Cleans up and removes a whole multi stack. It does not free or + * touch any individual easy handles in any way. We need to define + * in what state those handles will be if this function is called + * in the middle of a transfer. + * + * Returns: CURLMcode type, general multi error code. + */ +CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); + +/* + * Name: curl_multi_info_read() + * + * Desc: Ask the multi handle if there's any messages/informationals from + * the individual transfers. Messages include informationals such as + * error code from the transfer or just the fact that a transfer is + * completed. More details on these should be written down as well. + * + * Repeated calls to this function will return a new struct each + * time, until a special "end of msgs" struct is returned as a signal + * that there is no more to get at this point. + * + * The data the returned pointer points to will not survive calling + * curl_multi_cleanup(). + * + * The 'CURLMsg' struct is meant to be very simple and only contain + * very basic informations. If more involved information is wanted, + * we will provide the particular "transfer handle" in that struct + * and that should/could/would be used in subsequent + * curl_easy_getinfo() calls (or similar). The point being that we + * must never expose complex structs to applications, as then we'll + * undoubtably get backwards compatibility problems in the future. + * + * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out + * of structs. It also writes the number of messages left in the + * queue (after this read) in the integer the second argument points + * to. + */ +CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle, + int *msgs_in_queue); + +/* + * Name: curl_multi_strerror() + * + * Desc: The curl_multi_strerror function may be used to turn a CURLMcode + * value into the equivalent human readable error string. This is + * useful for printing meaningful error messages. + * + * Returns: A pointer to a zero-terminated error message. + */ +CURL_EXTERN const char *curl_multi_strerror(CURLMcode); + +/* + * Name: curl_multi_socket() and + * curl_multi_socket_all() + * + * Desc: An alternative version of curl_multi_perform() that allows the + * application to pass in one of the file descriptors that have been + * detected to have "action" on them and let libcurl perform. + * See man page for details. + */ +#define CURL_POLL_NONE 0 +#define CURL_POLL_IN 1 +#define CURL_POLL_OUT 2 +#define CURL_POLL_INOUT 3 +#define CURL_POLL_REMOVE 4 + +#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD + +#define CURL_CSELECT_IN 0x01 +#define CURL_CSELECT_OUT 0x02 +#define CURL_CSELECT_ERR 0x04 + +typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */ + curl_socket_t s, /* socket */ + int what, /* see above */ + void *userp, /* private callback + pointer */ + void *socketp); /* private socket + pointer */ +/* + * Name: curl_multi_timer_callback + * + * Desc: Called by libcurl whenever the library detects a change in the + * maximum number of milliseconds the app is allowed to wait before + * curl_multi_socket() or curl_multi_perform() must be called + * (to allow libcurl's timed events to take place). + * + * Returns: The callback should return zero. + */ +typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */ + long timeout_ms, /* see above */ + void *userp); /* private callback + pointer */ + +CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s, + int *running_handles); + +CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle, + curl_socket_t s, + int ev_bitmask, + int *running_handles); + +CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle, + int *running_handles); + +#ifndef CURL_ALLOW_OLD_MULTI_SOCKET +/* This macro below was added in 7.16.3 to push users who recompile to use + the new curl_multi_socket_action() instead of the old curl_multi_socket() +*/ +#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) +#endif + +/* + * Name: curl_multi_timeout() + * + * Desc: Returns the maximum number of milliseconds the app is allowed to + * wait before curl_multi_socket() or curl_multi_perform() must be + * called (to allow libcurl's timed events to take place). + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle, + long *milliseconds); + +#undef CINIT /* re-using the same name as in curl.h */ + +#ifdef CURL_ISOCPP +#define CINIT(name,type,number) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + number +#else +/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ +#define LONG CURLOPTTYPE_LONG +#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT +#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT +#define OFF_T CURLOPTTYPE_OFF_T +#define CINIT(name,type,number) CURLMOPT_/**/name = type + number +#endif + +typedef enum { + /* This is the socket callback function pointer */ + CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1), + + /* This is the argument passed to the socket callback */ + CINIT(SOCKETDATA, OBJECTPOINT, 2), + + /* set to 1 to enable pipelining for this multi handle */ + CINIT(PIPELINING, LONG, 3), + + /* This is the timer callback function pointer */ + CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4), + + /* This is the argument passed to the timer callback */ + CINIT(TIMERDATA, OBJECTPOINT, 5), + + /* maximum number of entries in the connection cache */ + CINIT(MAXCONNECTS, LONG, 6), + + CURLMOPT_LASTENTRY /* the last unused */ +} CURLMoption; + + +/* + * Name: curl_multi_setopt() + * + * Desc: Sets options for the multi handle. + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, + CURLMoption option, ...); + + +/* + * Name: curl_multi_assign() + * + * Desc: This function sets an association in the multi handle between the + * given socket and a private pointer of the application. This is + * (only) useful for curl_multi_socket uses. + * + * Returns: CURLM error code. + */ +CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, + curl_socket_t sockfd, void *sockp); + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif diff --git a/spec/include/curl/stdcheaders.h b/spec/include/curl/stdcheaders.h new file mode 100644 index 00000000..11c1e2f6 --- /dev/null +++ b/spec/include/curl/stdcheaders.h @@ -0,0 +1,34 @@ +#ifndef __STDC_HEADERS_H +#define __STDC_HEADERS_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + ***************************************************************************/ + +#include + +size_t fread (void *, size_t, size_t, FILE *); +size_t fwrite (const void *, size_t, size_t, FILE *); + +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); + +#endif diff --git a/spec/include/curl/types.h b/spec/include/curl/types.h new file mode 100644 index 00000000..d37d6ae9 --- /dev/null +++ b/spec/include/curl/types.h @@ -0,0 +1 @@ +/* not used */ diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h new file mode 100644 index 00000000..e803f0d2 --- /dev/null +++ b/spec/include/eiffel_curl.h @@ -0,0 +1,127 @@ +#include +#include + +/* unix-specific */ +#ifndef EIF_WINNT +#include +#include +#endif + +#include + +typedef char bool; +#define TRUE 1 + +#ifndef my_curl +#define my_curl + +struct cURLMemoryStruct { + char *memory; + size_t size; +}; + +static void dump(const char *text, FILE *stream, unsigned char *ptr, size_t size,bool nohex) +{ + size_t i; + size_t c; + + unsigned int width=0x10; + + if(nohex) + /* without the hex output, we can fit more on screen */ + width = 0x400; + + fprintf(stream, "%s, %zd bytes (0x%zx)\n", text, size, size); + + for(i=0; i=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); + /* check again for 0D0A, to avoid an extra \n if it's at width */ + if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { + i+=(c+3-width); + break; + } + } + fputc('\n', stream); /* newline */ + } + fflush(stream); +} + +static int my_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) +{ + const char *text; + + (void)handle; /* prevent compiler warning */ + + switch (type) { + case CURLINFO_TEXT: + fprintf(stderr, "== Info: %s", data); + default: /* in case a new one is introduced to shock us */ + return 0; + + case CURLINFO_HEADER_OUT: + text = "=> Send header"; + break; + case CURLINFO_DATA_OUT: + text = "=> Send data"; + break; + case CURLINFO_HEADER_IN: + text = "<= Recv header"; + + break; + case CURLINFO_DATA_IN: + text = "<= Recv data"; + break; + } + + dump(text, stderr, data, size, TRUE); + return 0; +} + +static void *myrealloc(void *ptr, size_t size) +{ + /* There might be a realloc() out there that doesn't like reallocing + NULL pointers, so we take care of it here */ + if(ptr) + return realloc(ptr, size); + else + return malloc(size); +} + +static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) +{ + size_t realsize = size * nmemb; + size_t totalsize; + + struct cURLMemoryStruct *mem = (struct cURLMemoryStruct *)data; + + mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1); + + if (mem->memory) { + memcpy(&(mem->memory[mem->size]), ptr, realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } + + return realsize; +} + +#endif diff --git a/spec/msc/win64/lib/libcurl_imp.lib b/spec/msc/win64/lib/libcurl_imp.lib new file mode 100644 index 0000000000000000000000000000000000000000..40e89ddb3dd5b29c180c18347470e12c7808b859 GIT binary patch literal 12820 zcmcgxON<;v5)HR)ybQm=KWxv(JwMO?*VAo}k%bzT)vmz|Xc#1JO?$f9Znl4P_l&gc zVI>ZTgO7+KM;|#M4xHx15g~+p;IKj#XU;w#v5^@WRgqO$MU`i~Ek##lp)OyuH0sdHrwi{&oB2 zJ3DW0SDKC6yL-JRR4QBV-MSS8z<&&a@^}96-qxFy*I(Uv6-zW)-HIw)@v8lQRlNRg zwd+Ad5ytJcBS>E*u=Sp2D${Qw$0|;wBG<1=H^ff~M7`5%RckeBDJMetf*sM}7N|mZ zyg^WdN{AXTS*s3A^EqMXd+mKHj@jy6;BBKBFS zhpXi$C8lrH!YPTc045>x>lT1h60y(Kns#u~!dSKJJ9zfFYEug*MJ@eiqd%xryIrqs zmVl*+Al2Mgs?8?N1z~-iK<|6KexuVS7$>6nl}5YXu|T8|$UDu>?P?R%4YR_e!i}r6 zycSg|uv!_#?>4<^d#`K3Stroirh_&F$uOqx4LV)ZQjIc-Fs|$Ml-&@o2C^oM_#6<_`zKND;wV%!FiB1gqw) z((|gu2$`Oh5xnd_fusE={h-nEI(ugNY*nPzYQNvOV~m!dMiW8yyjEx5tH?z}1?-GS zIXr0`g@iUzg3W^VFg;DIieUSl-GA~*rREq-46;()9r(MHEWjDD<#-3Q3!zq&AoE9K z==C~1VLr-Qv`S!2J)9#t>q46qZ=plF>>loh@8P}-01wXL-vxlpivYb56!alK%L6>b z=a1-ny>S`fYm{-+{f6@X1i-x|fGzaNhNm!p5#U>V{}taqMtOvJlPKSyetZ?NC^yyt z?xU0NIqbuSi1`ZZKvy1)K@KKi8cx6zT!smlfjn%& zNjL>h!w@_JPrby$NJ;Uzc^ z&%-%bfH|0lmvJaB!WEc>zrZCJ`9HHA$5r_lzOGoFiN{X-!C`#Ua7A&al0ILLG$ZIj7=I z({$%aq#0C9JI>KO-o_(2e00kU=as~F^ev=gMuWSQg>=kmtfxd7VN*4yPsI8{r;=bz zdC!m~aG0yS?&x&$VITR80}Y@L)J>@if2*o%S-m%rWUGX6$G zDeJ=OZ!VO_OOR6G4Ml1rKC0DBxqXOI!Ny@J`A$ittQm4`6QZn~D}u&3pX^J@!rD&_ z?$M?KYqm+pTL2aIjo&1BA2&&Bd;?QAxz-5V=B*LJuti$-Gi1z!iU}b2K>2gY5 z2JI!yhN_V!K|z7o*qe#Tt<;)L?e_jzG`D!YNWt9v2Sc?_kAvr(`TMiS0DUw1t<=2R zdv~VaHA#34U+!_jJj*cr+DZe@^6GSfvoQP!-=jP=Sj8n-n zDDsbKCRzTQ|4fH2L;Jv8k3Q zK|fi)4deew{U&IjyxVDYv9Yt?{Tu%HLzX}&`p8PS&t-J0mF6yMbnl4AV2TQZkN{H( zG)kXWf99v^0`#4OUke8vNlWJfxd$1OH??+AgRQAx{*w<;&VO|Uw}pJ+2<@_XFBgQnY*l>%JYz{7@TCwVMT-u_mf!)5 z*laF`JNqh0@PJ2cK8ljd&ShpRCF~(%Hd_!wI}~Fv!B-p)Gh%>Fl8N_pYcpZ)F56r# zH#qxf##lIhgv4lv@jYCTMbWYBr)iQsOxUarmsn7z8`FgQ=VXYDzQ+p&Ih*O&5=L~& z#m3=QNt%5g6ZSOqomdAaW!P88awVmBPuI^F4=;}^XC}nRabm%deOwbPW4RI4#*wiX4Kqg$Cr z&=0YO?rZ9Xy~JGh_X^RS?7L;sI4;|K5f@z$ry9qkoq5IPI*Oe+VGmgiu^q`Cl5i5N z`F!#Nkr==1J61yP)@?Tb Date: Mon, 22 Oct 2007 10:16:49 +0000 Subject: [PATCH 02/64] Removed the lib file which should be generated from C source codes. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@70783 8089f293-4706-0410-a29e-feb5c42a2edf --- spec/msc/win64/lib/libcurl_imp.lib | Bin 12820 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 spec/msc/win64/lib/libcurl_imp.lib diff --git a/spec/msc/win64/lib/libcurl_imp.lib b/spec/msc/win64/lib/libcurl_imp.lib deleted file mode 100644 index 40e89ddb3dd5b29c180c18347470e12c7808b859..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12820 zcmcgxON<;v5)HR)ybQm=KWxv(JwMO?*VAo}k%bzT)vmz|Xc#1JO?$f9Znl4P_l&gc zVI>ZTgO7+KM;|#M4xHx15g~+p;IKj#XU;w#v5^@WRgqO$MU`i~Ek##lp)OyuH0sdHrwi{&oB2 zJ3DW0SDKC6yL-JRR4QBV-MSS8z<&&a@^}96-qxFy*I(Uv6-zW)-HIw)@v8lQRlNRg zwd+Ad5ytJcBS>E*u=Sp2D${Qw$0|;wBG<1=H^ff~M7`5%RckeBDJMetf*sM}7N|mZ zyg^WdN{AXTS*s3A^EqMXd+mKHj@jy6;BBKBFS zhpXi$C8lrH!YPTc045>x>lT1h60y(Kns#u~!dSKJJ9zfFYEug*MJ@eiqd%xryIrqs zmVl*+Al2Mgs?8?N1z~-iK<|6KexuVS7$>6nl}5YXu|T8|$UDu>?P?R%4YR_e!i}r6 zycSg|uv!_#?>4<^d#`K3Stroirh_&F$uOqx4LV)ZQjIc-Fs|$Ml-&@o2C^oM_#6<_`zKND;wV%!FiB1gqw) z((|gu2$`Oh5xnd_fusE={h-nEI(ugNY*nPzYQNvOV~m!dMiW8yyjEx5tH?z}1?-GS zIXr0`g@iUzg3W^VFg;DIieUSl-GA~*rREq-46;()9r(MHEWjDD<#-3Q3!zq&AoE9K z==C~1VLr-Qv`S!2J)9#t>q46qZ=plF>>loh@8P}-01wXL-vxlpivYb56!alK%L6>b z=a1-ny>S`fYm{-+{f6@X1i-x|fGzaNhNm!p5#U>V{}taqMtOvJlPKSyetZ?NC^yyt z?xU0NIqbuSi1`ZZKvy1)K@KKi8cx6zT!smlfjn%& zNjL>h!w@_JPrby$NJ;Uzc^ z&%-%bfH|0lmvJaB!WEc>zrZCJ`9HHA$5r_lzOGoFiN{X-!C`#Ua7A&al0ILLG$ZIj7=I z({$%aq#0C9JI>KO-o_(2e00kU=as~F^ev=gMuWSQg>=kmtfxd7VN*4yPsI8{r;=bz zdC!m~aG0yS?&x&$VITR80}Y@L)J>@if2*o%S-m%rWUGX6$G zDeJ=OZ!VO_OOR6G4Ml1rKC0DBxqXOI!Ny@J`A$ittQm4`6QZn~D}u&3pX^J@!rD&_ z?$M?KYqm+pTL2aIjo&1BA2&&Bd;?QAxz-5V=B*LJuti$-Gi1z!iU}b2K>2gY5 z2JI!yhN_V!K|z7o*qe#Tt<;)L?e_jzG`D!YNWt9v2Sc?_kAvr(`TMiS0DUw1t<=2R zdv~VaHA#34U+!_jJj*cr+DZe@^6GSfvoQP!-=jP=Sj8n-n zDDsbKCRzTQ|4fH2L;Jv8k3Q zK|fi)4deew{U&IjyxVDYv9Yt?{Tu%HLzX}&`p8PS&t-J0mF6yMbnl4AV2TQZkN{H( zG)kXWf99v^0`#4OUke8vNlWJfxd$1OH??+AgRQAx{*w<;&VO|Uw}pJ+2<@_XFBgQnY*l>%JYz{7@TCwVMT-u_mf!)5 z*laF`JNqh0@PJ2cK8ljd&ShpRCF~(%Hd_!wI}~Fv!B-p)Gh%>Fl8N_pYcpZ)F56r# zH#qxf##lIhgv4lv@jYCTMbWYBr)iQsOxUarmsn7z8`FgQ=VXYDzQ+p&Ih*O&5=L~& z#m3=QNt%5g6ZSOqomdAaW!P88awVmBPuI^F4=;}^XC}nRabm%deOwbPW4RI4#*wiX4Kqg$Cr z&=0YO?rZ9Xy~JGh_X^RS?7L;sI4;|K5f@z$ry9qkoq5IPI*Oe+VGmgiu^q`Cl5i5N z`F!#Nkr==1J61yP)@?Tb Date: Fri, 26 Oct 2007 08:05:22 +0000 Subject: [PATCH 03/64] We can start our executables even without dll (so) files. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@70908 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL.ecf | 9 +- curl_easy_externals.e | 231 +++++++++++++++++++++++++++++-------- curl_externals.e | 152 ++++++++++++++---------- curl_global_constants.e | 78 +++++++++++++ spec/include/eiffel_curl.h | 2 +- 5 files changed, 358 insertions(+), 114 deletions(-) create mode 100644 curl_global_constants.e diff --git a/cURL.ecf b/cURL.ecf index cc834e7a..f0f10ec9 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -1,6 +1,6 @@ - - + + cURL: libcURL wrapper library for Eiffel. Copyright (c) 1984-2006, Eiffel Software and others. Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). @@ -23,7 +23,6 @@ - @@ -38,7 +37,7 @@ - + + - diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 85307cb4..11c5daa1 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -12,18 +12,17 @@ indexing class CURL_EASY_EXTERNALS -feature -- Externals +feature -- Command init: POINTER is -- Declared as curl_easy_init(). - external - "C inline use " - alias - "[ - { - return curl_easy_init(); - } - ]" + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_init") + if l_api /= default_pointer then + Result := c_init (l_api) + end ensure exists: Result /= default_pointer end @@ -35,10 +34,14 @@ feature -- Externals valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) not_void: a_string /= Void local + l_api: POINTER l_c_str: C_STRING do - create l_c_str.make (a_string) - c_setopt_string (a_curl_handle, a_opt, l_c_str.item) + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + create l_c_str.make (a_string) + c_setopt (l_api, a_curl_handle, a_opt, l_c_str.item) + end end setopt_form (a_curl_handle: POINTER; a_opt: INTEGER; a_form: CURL_FORM) is @@ -57,8 +60,13 @@ feature -- Externals exists: a_curl_handle /= default_pointer valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) not_void: a_memory_struct /= Void + local + l_api: POINTER do - c_setopt_void_star (a_curl_handle, a_opt, a_memory_struct.item) + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + c_setopt (l_api, a_curl_handle, a_opt, a_memory_struct.item) + end end setopt_integer (a_curl_handle: POINTER; a_opt: INTEGER; a_integer: INTEGER) is @@ -66,31 +74,26 @@ feature -- Externals require exists: a_curl_handle /= default_pointer valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) - external - "C inline use " - alias - "[ - { - size_t l_int; - l_int = $a_integer; - - curl_easy_setopt($a_curl_handle, $a_opt, l_int); - } - ]" + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + c_setopt_int (l_api, a_curl_handle, a_opt, a_integer) + end end perform (a_curl_handle: POINTER): INTEGER is -- Declared as curl_easy_perform(). require exists: a_curl_handle /= default_pointer - external - "C inline use " - alias - "[ - { - return curl_easy_perform ($a_curl_handle); - } - ]" + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_perform") + if l_api /= default_pointer then + Result := c_perform (l_api, a_curl_handle) + end ensure valid: end @@ -99,31 +102,115 @@ feature -- Externals -- Declared as curl_easy_cleanup(). require exists: a_curl_handle /= default_pointer - external - "C inline use " - alias - "[ - { - curl_easy_cleanup($a_curl_handle); - - } - ]" + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_cleanup") + if l_api /= default_pointer then + c_cleanup (l_api, a_curl_handle) + end + end + +feature -- Special setting + + set_write_function (a_curl_handle: POINTER) is + -- Set cURL write function + require + exists: a_curl_handle /= default_pointer + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + c_set_write_function (l_api, a_curl_handle) + end + end + + set_debug_function (a_curl_handle: POINTER) is + -- Set cURL debug function + require + exists: a_curl_handle /= default_pointer + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + c_debug_function (l_api, a_curl_handle) + end end feature {NONE} -- Implementation + api_loader: API_LOADER is + -- API dynamic loader + once + create Result + ensure + not_void: Result /= Void + end + + module_name: STRING is "libcurl.dll" + -- Module name. + setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + local + l_api: POINTER do - c_setopt_void_star (a_curl_handle, a_opt, a_data) + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + c_setopt (l_api, a_curl_handle, a_opt, a_data) + end end - c_setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is - -- C implementation of `setopt_void_star'. +feature {NONE} -- C externals + + c_init (a_api: POINTER): POINTER is + -- Declared curl_easy_init (). require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURL *, ()) $a_api)(); + ]" + end + + c_cleanup (a_api: POINTER; a_curl_handle: POINTER) is + -- Decalred as curl_easy_cleanup (). + require + exists: a_api /= default_pointer + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void, (CURL *)) $a_api)((CURL *)$a_curl_handle); + ]" + end + + c_perform (a_api: POINTER; a_curl_handle: POINTER): INTEGER is + -- Declared as curl_easy_perform(). + require + exists: a_api /= default_pointer + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURLcode, (CURL *)) $a_api) + ((CURL *) $a_curl_handle); + ]" + end + + c_setopt_int (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: INTEGER) is + -- Same as `c_setopt' except we can pass `a_data' as integer. + require + exists: a_api /= default_pointer exists: a_curl_handle /= default_pointer valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) external @@ -131,23 +218,71 @@ feature {NONE} -- Implementation alias "[ { - curl_easy_setopt($a_curl_handle, $a_opt, (void *)$a_data); + (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_api) + ((CURL *) $a_curl_handle, + (CURLoption)$a_opt, + (CURLoption)$a_data); } ]" end - c_setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_c_string: POINTER) is - -- C implementation of `setopt_string'. + c_setopt (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is + -- C implementation of `setopt_void_star'. + -- Declared as curl_easy_setopt (). require + exists: a_api /= default_pointer exists: a_curl_handle /= default_pointer valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) - exists: a_c_string /= default_pointer external "C inline use " alias "[ { - curl_easy_setopt($a_curl_handle, $a_opt, (char *)$a_c_string); + (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_api) + ((CURL *) $a_curl_handle, + (CURLoption)$a_opt, + (CURLoption)$a_data); + } + ]" + end + + c_set_write_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + -- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a static c function pointer as value. + require + exists: a_setopt_api /= default_pointer + external + "C inline use " + alias + "[ + { + (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_WRITEFUNCTION, + (CURLoption)WriteMemoryCallback); + } + ]" + end + + c_debug_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + -- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a static c function pointer as value. + require + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + { + (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_DEBUGFUNCTION, + (CURLoption)curl_trace); + + (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_VERBOSE, + (CURLoption)TRUE); } ]" end diff --git a/curl_externals.e b/curl_externals.e index f3a7558d..912e2175 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -12,18 +12,17 @@ indexing class CURL_EXTERNALS -feature -- Externals +feature -- Command global_init is -- Declared as curl_global_init(). - external - "C inline use " - alias - "[ - { - curl_global_init (CURL_GLOBAL_ALL); - } - ]" + local + l_ptr: POINTER + do + l_ptr := api_loader.safe_load_api (module_name, "curl_global_init") + if l_ptr /= default_pointer then + c_curl_global_init (l_ptr, {CURL_GLOBAL_CONSTANTS}.curl_global_all); + end end formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is @@ -53,35 +52,12 @@ feature -- Externals end end - set_write_function (a_curl_handle: POINTER) is - -- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'. - -- We need this function since cURL need a static c function pointer as value. - require - exists: a_curl_handle /= default_pointer - external - "C inline use " - alias - "[ - { - curl_easy_setopt ($a_curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); - } - ]" - end +feature -- Query - set_debug_function (a_curl_handle: POINTER) is - -- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'. - -- We need this function since cURL need a static c function pointer as value. - require - exists: a_curl_handle /= default_pointer - external - "C inline use " - alias - "[ - { - curl_easy_setopt($a_curl_handle, CURLOPT_DEBUGFUNCTION, my_trace); - curl_easy_setopt($a_curl_handle, CURLOPT_VERBOSE, TRUE); - } - ]" + is_dynamic_library_exists: BOOLEAN is + -- If dll/so files exist? + do + Result := (api_loader.module_pointer (module_name) /= default_pointer) end feature {CURL_FORM} -- Internal command @@ -90,48 +66,104 @@ feature {CURL_FORM} -- Internal command -- Declared as curl_formfree (). require exists: a_curl_form /= default_pointer - external - "C inline use " - alias - "[ - { - curl_formfree($a_curl_form); - } - ]" + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_formfree") + if l_api /= default_pointer then + c_formfree (l_api, a_curl_form) + end end feature {NONE} -- Implementation - c_slist_append (a_list_pointer: POINTER; a_string: POINTER): POINTER is - -- Declared as curl_slist_append (). - external - "C inline use " - alias - "[ - { - return curl_slist_append ((struct curl_slist *)$a_list_pointer, (char *)$a_string); - } - ]" + api_loader: API_LOADER is + -- API dynamic loader + once + create Result + ensure + not_void: Result /= Void end + module_name: STRING is "libcurl.dll" + -- Module name. + internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is -- Declared as curl_formadd (). local l_c_string_1, l_c_string_2: C_STRING + l_api: POINTER do - create l_c_string_1.make (a_arg_1_value) - create l_c_string_2.make (a_arg_2_value) - c_formadd_string_string (a_form, a_last_pointer, a_arg_1, l_c_string_1.item, a_arg_2, l_c_string_2.item, a_arg_3) + l_api := api_loader.safe_load_api (module_name, "curl_formadd"); + if l_api /= default_pointer then + create l_c_string_1.make (a_arg_1_value) + create l_c_string_2.make (a_arg_2_value) + c_formadd_string_string (l_api, a_form, a_last_pointer, a_arg_1, l_c_string_1.item, a_arg_2, l_c_string_2.item, a_arg_3) + end end - c_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: POINTER; a_arg_2: INTEGER; a_arg_2_value: POINTER; a_arg_3: INTEGER) is +feature {NONE} -- C externals + + c_formadd_string_string (a_api: POINTER; a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: POINTER; a_arg_2: INTEGER; a_arg_2_value: POINTER; a_arg_3: INTEGER) is -- C implementation of formadd_string_string (). + require + exists: a_api /= default_pointer external "C inline use " alias "[ { - curl_formadd ((struct curl_httppost *)$a_form, (struct curl_httppost *)$a_last_pointer, (int)$a_arg_1, (char *)$a_arg_1_value, (int)$a_arg_2, (char *)$a_arg_2_value, (int)$a_arg_3); + (FUNCTION_CAST(void, (struct curl_httppost **, struct curl_httppost **, int, char *, int, char *, int)) $a_api) + ((struct curl_httppost *)$a_form, + (struct curl_httppost *)$a_last_pointer, + (int)$a_arg_1, + (char *)$a_arg_1_value, + (int)$a_arg_2, + (char *)$a_arg_2_value, + (int)$a_arg_3); + } + ]" + end + + c_formfree (a_api: POINTER; a_curl_form: POINTER) is + -- Declared as curl_formfree (). + require + exists: a_api /= default_pointer + exists: a_curl_form /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void, (struct curl_httppost *)) $a_api) + ((struct curl_httppost *) $a_curl_form); + ]" + end + + c_curl_global_init (a_api: POINTER; a_opt: NATURAL_64) is + -- `a_api' point to AIP curl_global_init () + -- `a_opt' is intialization option. + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void, (long)) $a_api)((long) $a_opt); + ]" + end + + c_slist_append (a_api: POINTER; a_list_pointer: POINTER; a_string: POINTER): POINTER is + -- Declared as curl_slist_append (). + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + { + return (FUNCTION_CAST(void *, (struct curl_slist *, const char *)) $a_api) + ((struct curl_slist *)$a_list_pointer, + (const char *)$a_string); } ]" end diff --git a/curl_global_constants.e b/curl_global_constants.e new file mode 100644 index 00000000..da466828 --- /dev/null +++ b/curl_global_constants.e @@ -0,0 +1,78 @@ +indexing + description: "[ + cURL library constants used by curl_global_init () + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_GLOBAL_CONSTANTS + +feature -- Query + + curl_global_ssl: NATURAL_64 is + -- Delcared as CURL_GLOBAL_SSL + external + "C inline use " + alias + "[ + return CURL_GLOBAL_SSL; + ]" + end + + curl_global_win32: NATURAL_64 is + -- Delcared as CURL_GLOBAL_WIN32 + external + "C inline use " + alias + "[ + return CURL_GLOBAL_WIN32; + ]" + end + + curl_global_all: NATURAL_64 is + -- Delcared as CURL_GLOBAL_ALL + external + "C inline use " + alias + "[ + return CURL_GLOBAL_ALL; + ]" + end + + curl_global_nothing: NATURAL_64 is + -- Delcared as CURL_GLOBAL_NOTHING + external + "C inline use " + alias + "[ + return CURL_GLOBAL_NOTHING; + ]" + end + + curl_global_default: NATURAL_64 is + -- Delcared as CURL_GLOBAL_DEFAULT + external + "C inline use " + alias + "[ + return CURL_GLOBAL_DEFAULT; + ]" + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end + diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index e803f0d2..69161def 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -65,7 +65,7 @@ static void dump(const char *text, FILE *stream, unsigned char *ptr, size_t size fflush(stream); } -static int my_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) +static int curl_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) { const char *text; From 2d99813b5d6285cb4b93a761b9ceced63938a964 Mon Sep 17 00:00:00 2001 From: larryl Date: Fri, 26 Oct 2007 13:10:12 +0000 Subject: [PATCH 04/64] Removed `libcurl_imp.lib' external object since we use dynamic loading technique now. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@70914 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL.ecf | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/cURL.ecf b/cURL.ecf index f0f10ec9..b92ba6cd 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -23,19 +23,6 @@ - - - - - - - - - - - - - From 09a1c2d34a24add534d1ab8ac72b5a71638c3da0 Mon Sep 17 00:00:00 2001 From: larryl Date: Tue, 30 Oct 2007 11:22:26 +0000 Subject: [PATCH 05/64] Made cURL wrapper library works on Linux. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@70943 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_easy_externals.e | 28 +++++++++++++++++----------- curl_externals.e | 8 +++++++- curl_utility.e | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 curl_utility.e diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 11c5daa1..bd1a9805 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -149,8 +149,14 @@ feature {NONE} -- Implementation not_void: Result /= Void end - module_name: STRING is "libcurl.dll" + module_name: STRING is -- Module name. + local + l_utility: CURL_UTILITY + once + create l_utility + Result := l_utility.module_name + end setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is -- Declared as curl_easy_setopt(). @@ -218,10 +224,10 @@ feature {NONE} -- C externals alias "[ { - (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_api) + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_api) ((CURL *) $a_curl_handle, (CURLoption)$a_opt, - (CURLoption)$a_data); + $a_data); } ]" end @@ -238,10 +244,10 @@ feature {NONE} -- C externals alias "[ { - (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_api) + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_api) ((CURL *) $a_curl_handle, (CURLoption)$a_opt, - (CURLoption)$a_data); + $a_data); } ]" end @@ -256,10 +262,10 @@ feature {NONE} -- C externals alias "[ { - (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_setopt_api) + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) ((CURL *) $a_curl_handle, (CURLoption)CURLOPT_WRITEFUNCTION, - (CURLoption)WriteMemoryCallback); + WriteMemoryCallback); } ]" end @@ -274,15 +280,15 @@ feature {NONE} -- C externals alias "[ { - (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_setopt_api) + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) ((CURL *) $a_curl_handle, (CURLoption)CURLOPT_DEBUGFUNCTION, - (CURLoption)curl_trace); + curl_trace); - (FUNCTION_CAST(void, (CURL *, CURLoption, CURLoption)) $a_setopt_api) + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) ((CURL *) $a_curl_handle, (CURLoption)CURLOPT_VERBOSE, - (CURLoption)TRUE); + TRUE); } ]" end diff --git a/curl_externals.e b/curl_externals.e index 912e2175..44c058cc 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -85,8 +85,14 @@ feature {NONE} -- Implementation not_void: Result /= Void end - module_name: STRING is "libcurl.dll" + module_name: STRING is -- Module name. + local + l_utility: CURL_UTILITY + once + create l_utility + Result := l_utility.module_name + end internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is -- Declared as curl_formadd (). diff --git a/curl_utility.e b/curl_utility.e new file mode 100644 index 00000000..4a204759 --- /dev/null +++ b/curl_utility.e @@ -0,0 +1,42 @@ +indexing + description: "[ + Utilities for Eiffel cURL wrapper library. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_UTILITY + +feature -- Query + + module_name: STRING is + -- Module name. + local + l_platform: PLATFORM + once + create l_platform + if l_platform.is_windows then + Result := "libcurl.dll" + else + Result := "libcurl.so" + end + ensure + not_void: Result /= Void + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end From 77c028a9cd5bc719766f3b49e0e3b97b15848ca3 Mon Sep 17 00:00:00 2001 From: larryl Date: Sat, 3 Nov 2007 06:08:03 +0000 Subject: [PATCH 06/64] Cosmetics. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71027 8089f293-4706-0410-a29e-feb5c42a2edf --- spec/include/eiffel_curl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index 69161def..1cf3ec45 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -12,8 +12,8 @@ typedef char bool; #define TRUE 1 -#ifndef my_curl -#define my_curl +#ifndef eiffel_curl +#define eiffel_curl struct cURLMemoryStruct { char *memory; @@ -96,7 +96,7 @@ static int curl_trace(CURL *handle, curl_infotype type, unsigned char *data, siz return 0; } -static void *myrealloc(void *ptr, size_t size) +static void *eiffel_realloc(void *ptr, size_t size) { /* There might be a realloc() out there that doesn't like reallocing NULL pointers, so we take care of it here */ @@ -113,7 +113,7 @@ static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *da struct cURLMemoryStruct *mem = (struct cURLMemoryStruct *)data; - mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1); + mem->memory = (char *)eiffel_realloc(mem->memory, mem->size + realsize + 1); if (mem->memory) { memcpy(&(mem->memory[mem->size]), ptr, realsize); From 6179b0f223cab71426a818937c51301931b7c225 Mon Sep 17 00:00:00 2001 From: larryl Date: Sat, 3 Nov 2007 06:09:00 +0000 Subject: [PATCH 07/64] Added constant: curlopt_writefunction git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71028 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 651090ce..c12171ed 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -144,6 +144,16 @@ feature -- Enumerations. ]" end + curlopt_writefunction: INTEGER is + -- Declared as CURLOPT_WRITEFUNCTION. + external + "C inline use " + alias + "[ + return CURLOPT_WRITEFUNCTION; + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN is -- If `a_integer' value vaild? do @@ -159,7 +169,8 @@ feature -- Enumerations. a_integer = curlopt_useragent or a_integer = curlopt_verbose or a_integer = curlopt_writedata or - a_integer = curlopt_writeheader + a_integer = curlopt_writeheader or + a_integer = curlopt_writefunction end indexing From 179ac3a128532824cb68b6a99ae9363f2e3b4134 Mon Sep 17 00:00:00 2001 From: larryl Date: Thu, 8 Nov 2007 07:09:16 +0000 Subject: [PATCH 08/64] Improved cURL wrapper library. We can write functions from curl_easy_setopt in pure Eiffel now. Before we have to implement the functions in C. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71081 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_default_function.e | 105 ++++++++++++++++ curl_easy_externals.e | 89 +++++++------- curl_function.e | 166 +++++++++++++++++++++++++ curl_info_type.e | 62 ++++++++++ curl_memory_struct.e | 192 ----------------------------- curl_opt_constants.e | 35 +++++- curl_string.e | 50 ++++++++ spec/include/eiffel_curl.h | 243 ++++++++++++++++++++----------------- 8 files changed, 591 insertions(+), 351 deletions(-) create mode 100644 curl_default_function.e create mode 100644 curl_function.e create mode 100644 curl_info_type.e delete mode 100644 curl_memory_struct.e create mode 100644 curl_string.e diff --git a/curl_default_function.e b/curl_default_function.e new file mode 100644 index 00000000..b8ddb07c --- /dev/null +++ b/curl_default_function.e @@ -0,0 +1,105 @@ +indexing + description: "[ + Default implementation of CURL_FUNCTION. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_DEFAULT_FUNCTION + +inherit + CURL_FUNCTION + +create + make + +feature {NONE} -- Initialization + + make is + -- Creation method + do + set_object_and_function_address + end + +feature -- Command + + progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER is + -- Redefine + do + end + + write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER is + -- Redefine + local + l_c_string: C_STRING + l_string: STRING + l_identified: IDENTIFIED + do + Result := a_size * a_nmemb + create l_c_string.share_from_pointer_and_count (a_data_pointer, Result) + + create l_identified + l_string ?= l_identified.id_object (a_object_id.to_integer_32) + check not_void: l_string /= Void end + l_string.append (l_c_string.string) + end + + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER is + -- Redefine + local + l_c_string: C_STRING + do + inspect + a_curl_infotype + when {CURL_INFO_TYPE}.curlinfo_data_in then + dump ("<= Recv data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_data_out then + dump ("=> Send data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_header_in then + dump ("<= Recv header", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_header_out then + dump ("=> Send header", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_ssl_data_in then + dump ("<= Recv SSL data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_ssl_data_out then + dump ("=> Send SSL data", a_char_pointer, a_size) + when {CURL_INFO_TYPE}.curlinfo_text then + create l_c_string.make_by_pointer_and_count (a_char_pointer, a_size) + print ("%N== Info: " + l_c_string.string) + else + check type_unknow: False end + end + end + +feature {NONE} -- Implementation + + dump (a_text: STRING; a_char_pointer: POINTER; a_size: INTEGER) is + -- Dump debug information + require + not_void: a_text /= Void + exists: a_char_pointer /= default_pointer + non_negative: a_size >= 0 + local + l_c_string: C_STRING + do + print ("%N" + a_text) + create l_c_string.share_from_pointer_and_count (a_char_pointer, a_size) + print ("%N" + l_c_string.string) + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_easy_externals.e b/curl_easy_externals.e index bd1a9805..42932207 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -54,18 +54,18 @@ feature -- Command setopt_void_star (a_curl_handle, a_opt, a_form.item) end - setopt_memory_struct (a_curl_handle: POINTER; a_opt: INTEGER; a_memory_struct: CURL_MEMORY_STRUCT) is + setopt_curl_string (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_string: CURL_STRING) is -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) - not_void: a_memory_struct /= Void + not_void: a_curl_string /= Void local l_api: POINTER do l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") if l_api /= default_pointer then - c_setopt (l_api, a_curl_handle, a_opt, a_memory_struct.item) + c_setopt_int (l_api, a_curl_handle, a_opt, a_curl_string.object_id) end end @@ -113,6 +113,26 @@ feature -- Command feature -- Special setting + set_curl_function (a_curl_function: CURL_FUNCTION) is + -- Set `curl_function' with `a_curl_function' + do + internal_curl_function := a_curl_function + ensure + set: a_curl_function /= Void implies curl_function = a_curl_function + end + + curl_function: CURL_FUNCTION is + -- cURL functions in curl_easy_setopt. + do + Result := internal_curl_function + if Result = Void then + create {CURL_DEFAULT_FUNCTION} Result.make + internal_curl_function := Result + end + ensure + not_void: Result /= Void + end + set_write_function (a_curl_handle: POINTER) is -- Set cURL write function require @@ -122,7 +142,20 @@ feature -- Special setting do l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") if l_api /= default_pointer then - c_set_write_function (l_api, a_curl_handle) + curl_function.c_set_write_function (l_api, a_curl_handle) + end + end + + set_progress_function (a_curl_handle: POINTER) is + -- Set cURL progress function for upload/download progress. + require + exists: a_curl_handle /= default_pointer + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + curl_function.c_set_progress_function (l_api, a_curl_handle) end end @@ -135,12 +168,15 @@ feature -- Special setting do l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") if l_api /= default_pointer then - c_debug_function (l_api, a_curl_handle) + curl_function.c_set_debug_function (l_api, a_curl_handle) end end feature {NONE} -- Implementation + internal_curl_function: CURL_FUNCTION + -- cURL functions. + api_loader: API_LOADER is -- API dynamic loader once @@ -232,7 +268,7 @@ feature {NONE} -- C externals ]" end - c_setopt (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is + c_setopt (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: POINTER) is -- C implementation of `setopt_void_star'. -- Declared as curl_easy_setopt (). require @@ -252,47 +288,6 @@ feature {NONE} -- C externals ]" end - c_set_write_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is - -- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'. - -- We need this function since cURL need a static c function pointer as value. - require - exists: a_setopt_api /= default_pointer - external - "C inline use " - alias - "[ - { - (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) - ((CURL *) $a_curl_handle, - (CURLoption)CURLOPT_WRITEFUNCTION, - WriteMemoryCallback); - } - ]" - end - - c_debug_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is - -- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'. - -- We need this function since cURL need a static c function pointer as value. - require - exists: a_curl_handle /= default_pointer - external - "C inline use " - alias - "[ - { - (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) - ((CURL *) $a_curl_handle, - (CURLoption)CURLOPT_DEBUGFUNCTION, - curl_trace); - - (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) - ((CURL *) $a_curl_handle, - (CURLoption)CURLOPT_VERBOSE, - TRUE); - } - ]" - end - indexing library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" diff --git a/curl_function.e b/curl_function.e new file mode 100644 index 00000000..055de7cc --- /dev/null +++ b/curl_function.e @@ -0,0 +1,166 @@ +indexing + description: "[ + cURL curl_easy_setopt callback functions' Eiffel wrappers. + We need this class since cURL need a c function pointer as value but + Eiffel function need frist parameter of any funciton call is object address. + Client programmers can inherit this class to fit their needs. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +deferred class + CURL_FUNCTION + +inherit + DISPOSABLE + +feature -- Interactive with C + + set_object_and_function_address is + -- Set object and function addresses. + -- Call this feature before call `c_set_progress_function', `c_set_debug_function' and `c_set_write_function'. + do + c_set_object (Current) + c_set_progress_function_address ($progress_function) + c_set_write_function_address ($write_function) + c_set_debug_function_address ($debug_function) + end + + c_set_progress_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + -- Setting CURLOPT_PROGRESSFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a c function pointer as value. + require + exists: a_setopt_api /= default_pointer + external + "C inline use " + alias + "[ + { + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_PROGRESSFUNCTION, + curl_progress_function); + } + ]" + end + + c_set_debug_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + -- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a c function pointer as value. + require + exists: a_curl_handle /= default_pointer + external + "C inline use " + alias + "[ + { + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_DEBUGFUNCTION, + curl_debug_function); + + } + ]" + end + + c_set_write_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + -- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a c function pointer as value. + require + exists: a_setopt_api /= default_pointer + external + "C inline use " + alias + "[ + { + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_WRITEFUNCTION, + curl_write_function); + } + ]" + end + +feature -- cURL curl_easy_setopt functions + + progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER is + -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_progressfunction + -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which + -- may changed during GC. + deferred + end + + write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER is + -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_writefunction + -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which + -- may changed during GC. + deferred + end + + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER is + -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_debugfunction + -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which + -- may changed during GC. + require + vaild: (create {CURL_INFO_TYPE}).is_valid (a_curl_infotype) + deferred + end + +feature {NONE} -- Externals + + c_set_object (a_object: like Current) is + -- Set Current object address. + external + "C macro signature (EIF_OBJECT) use %"eiffel_curl.h%"" + end + + c_release_object is + -- Release Current pointer in C + external + "C [macro %"eiffel_curl.h%"]" + end + + c_set_progress_function_address (a_address: POINTER) is + -- Set progress function address. + external + "C [macro %"eiffel_curl.h%"]" + end + + c_set_write_function_address (a_address: POINTER) is + -- Set write function address. + external + "C [macro %"eiffel_curl.h%"]" + end + + c_set_debug_function_address (a_address: POINTER) is + -- Set write function address. + external + "C [macro %"eiffel_curl.h%"]" + end + +feature {NONE} -- Implementation + + dispose is + -- Wean `Current' + local + default_object: like Current + do + c_release_object + c_set_object (default_object) + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_info_type.e b/curl_info_type.e new file mode 100644 index 00000000..5300bc29 --- /dev/null +++ b/curl_info_type.e @@ -0,0 +1,62 @@ +indexing + description: "[ + cURL library info type constants. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_INFO_TYPE + +feature -- Enumeration + + curlinfo_text: INTEGER is 0 + -- Declared as CURLINFO_TEXT + + curlinfo_header_in: INTEGER is 1 + -- Declared as CURLINFO_HEADER_IN + + curlinfo_header_out: INTEGER is 2 + -- Declared as CURLINFO_HEADER_OUT + + curlinfo_data_in: INTEGER is 3 + -- Declared as CURLINFO_DATA_IN + + curlinfo_data_out: INTEGER is 4 + -- Declared as CURLINFO_DATA_OUT + + curlinfo_ssl_data_in: INTEGER is 5 + -- Declared as CURLINFO_SSL_DATA_IN + + curlinfo_ssl_data_out: INTEGER is 6 + -- Declared as CURLINFO_SSL_DATA_OUT + +feature -- Contract support + + is_valid (a_type: INTEGER): BOOLEAN is + -- If `a_type' valid? + do + Result := a_type = curlinfo_data_in or + a_type = curlinfo_data_out or + a_type = curlinfo_header_in or + a_type = curlinfo_header_out or + a_type = curlinfo_ssl_data_in or + a_type = curlinfo_ssl_data_out or + a_type = curlinfo_text + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_memory_struct.e b/curl_memory_struct.e deleted file mode 100644 index 601c50bb..00000000 --- a/curl_memory_struct.e +++ /dev/null @@ -1,192 +0,0 @@ -indexing - description: "[ - When libcURL write data which get from remote web site, - this memory stuct will be used by Eiffel language to store the data. - For more informaton see: - http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEDATA - ]" - status: "See notice at end of class." - legal: "See notice at end of class." - date: "$Date$" - revision: "$Revision$" - -class - CURL_MEMORY_STRUCT - -inherit - DISPOSABLE - -create - make - -feature {NONE} -- Intialization - - make is - -- Creation method. - do - item := item.memory_alloc (struct_size) - set_size (0) - set_memory_chunk (default_pointer) - end - -feature -- Query - - item: POINTER - -- Managed pointer. - - size: INTEGER is - -- String size. - do - if item /= default_pointer then - Result := c_size (item) - end - end - - memory_chunk: POINTER is - -- Memory chunk access pointer - do - if item /= default_pointer then - Result := c_memory_chunck (item) - end - end - - string: STRING_GENERAL is - -- Covert to Eiffel String. - -- Maybe void if not exists. - local - l_c_string: C_STRING - l_mem: POINTER - l_size: INTEGER - do - l_mem := c_memory_chunck (item) - l_size := size - if l_mem /= default_pointer and then l_size > 0 then - create l_c_string.share_from_pointer_and_count (l_mem, l_size) - Result := l_c_string.string - end - end - - struct_size: INTEGER is - -- Size of C Structure. - do - Result := c_size_of_memory_struct - ensure - nonnegative: Result >= 0 - end - -feature -- Command - - set_size (a_size: INTEGER) is - -- Set `size' to `a_size' - require - nonnegative: a_size >= 0 - do - c_set_size (item, a_size) - ensure - set: size = a_size - end - - set_memory_chunk (a_ptr: POINTER) is - -- Set `memory_chunk' to `a_ptr'. - do - c_set_memory_chunk (item, a_ptr) - ensure - set: memory_chunk = a_ptr - end - - dispose is - -- Clean up. - local - l_mem: POINTER - do - if item /= default_pointer then - l_mem := c_memory_chunck (item) - if l_mem /= default_pointer then - l_mem.memory_free - end - item.memory_free - item := default_pointer - end - ensure then - cleared: item = default_pointer - end - -feature {NONE} -- C externals - - c_size_of_memory_struct: INTEGER is - -- CURL memory struct struct size. - external - "C [macro ]" - alias - "sizeof (struct cURLMemoryStruct)" - end - - c_size (a_item: POINTER): INTEGER is - -- `a_item''s size - require - exists: a_item /= default_pointer - external - "C inline use " - alias - "[ - ((struct cURLMemoryStruct *)$a_item)->size - ]" - end - - c_set_size (a_item: POINTER; a_size: INTEGER) is - -- Set `a_item''s size to `a_size'. - require - exists: a_item /=default_pointer - external - "C inline use " - alias - "[ - { - ((struct cURLMemoryStruct *)$a_item)->size = $a_size; - } - ]" - ensure - set: c_size (a_item) = a_size - end - - c_memory_chunck (a_item: POINTER): POINTER is - -- `a_item''s memory pointer. - require - exists: a_item /= default_pointer - external - "C inline use " - alias - "[ - ((struct cURLMemoryStruct *)$a_item)->memory - ]" - end - - c_set_memory_chunk (a_item: POINTER; a_ptr: POINTER) is - -- Set `a_item''s memory to `a_ptr'. - require - exists: a_item /= default_pointer - external - "C inline use " - alias - "[ - { - ((struct cURLMemoryStruct *)$a_item)->memory = $a_ptr; - } - ]" - ensure - set: c_memory_chunck (a_item) = a_ptr - end - -indexing - library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" - license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" - source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]" - -end diff --git a/curl_opt_constants.e b/curl_opt_constants.e index c12171ed..c748e999 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -154,6 +154,36 @@ feature -- Enumerations. ]" end + curlopt_progressfunction: INTEGER is + -- Declared as CURLOPT_PROGRESSFUNCTION + external + "C inline use " + alias + "[ + return CURLOPT_PROGRESSFUNCTION; + ]" + end + + curlopt_noprogress: INTEGER is + -- Decalred as CURLOPT_NOPROGRESS + external + "C inline use " + alias + "[ + return CURLOPT_NOPROGRESS; + ]" + end + + curlopt_progressdata: INTEGER is + -- Decalred as CURLOPT_PROGRESSDATA + external + "C inline use " + alias + "[ + return CURLOPT_PROGRESSDATA; + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN is -- If `a_integer' value vaild? do @@ -170,7 +200,10 @@ feature -- Enumerations. a_integer = curlopt_verbose or a_integer = curlopt_writedata or a_integer = curlopt_writeheader or - a_integer = curlopt_writefunction + a_integer = curlopt_writefunction or + a_integer = curlopt_progressfunction or + a_integer = curlopt_progressdata or + a_integer = curlopt_noprogress end indexing diff --git a/curl_string.e b/curl_string.e new file mode 100644 index 00000000..ce055282 --- /dev/null +++ b/curl_string.e @@ -0,0 +1,50 @@ +indexing + description: "[ + String used by cURL wrapper library. + Only added features from IDENTIFIED. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_STRING + +inherit + STRING + select + is_equal, + copy, + out + end + + IDENTIFIED + rename + is_equal as identified_is_equal, + copy as identified_copy, + out as identified_out + end + +create + make, + make_empty, + make_filled, + make_from_string, + make_from_c, + make_from_cil + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end + diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index 1cf3ec45..fa48272d 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -9,119 +9,140 @@ #include -typedef char bool; -#define TRUE 1 +#include "eif_main.h" + +#ifdef EIF_THREADS +#include "eif_threads.h" +#endif #ifndef eiffel_curl #define eiffel_curl -struct cURLMemoryStruct { - char *memory; - size_t size; -}; - -static void dump(const char *text, FILE *stream, unsigned char *ptr, size_t size,bool nohex) -{ - size_t i; - size_t c; - - unsigned int width=0x10; - - if(nohex) - /* without the hex output, we can fit more on screen */ - width = 0x400; - - fprintf(stream, "%s, %zd bytes (0x%zx)\n", text, size, size); - - for(i=0; i=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); - /* check again for 0D0A, to avoid an extra \n if it's at width */ - if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { - i+=(c+3-width); - break; - } - } - fputc('\n', stream); /* newline */ - } - fflush(stream); -} - -static int curl_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) -{ - const char *text; - - (void)handle; /* prevent compiler warning */ - - switch (type) { - case CURLINFO_TEXT: - fprintf(stderr, "== Info: %s", data); - default: /* in case a new one is introduced to shock us */ - return 0; - - case CURLINFO_HEADER_OUT: - text = "=> Send header"; - break; - case CURLINFO_DATA_OUT: - text = "=> Send data"; - break; - case CURLINFO_HEADER_IN: - text = "<= Recv header"; - - break; - case CURLINFO_DATA_IN: - text = "<= Recv data"; - break; - } - - dump(text, stderr, data, size, TRUE); - return 0; -} - -static void *eiffel_realloc(void *ptr, size_t size) -{ - /* There might be a realloc() out there that doesn't like reallocing - NULL pointers, so we take care of it here */ - if(ptr) - return realloc(ptr, size); - else - return malloc(size); -} - -static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) -{ - size_t realsize = size * nmemb; - size_t totalsize; - - struct cURLMemoryStruct *mem = (struct cURLMemoryStruct *)data; - - mem->memory = (char *)eiffel_realloc(mem->memory, mem->size + realsize + 1); - - if (mem->memory) { - memcpy(&(mem->memory[mem->size]), ptr, realsize); - mem->size += realsize; - mem->memory[mem->size] = 0; - } - - return realsize; -} - +typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) ( +#ifndef EIF_IL_DLL + EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ #endif + EIF_POINTER, /* a_user_pointer */ + EIF_REAL_64, /* a_dltotal */ + EIF_REAL_64, /* a_dlnow */ + EIF_REAL_64, /* a_ultotal */ + EIF_REAL_64 /* a_ulnow */ + ); + +typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( +#ifndef EIF_IL_DLL + EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ +#endif + EIF_POINTER, /* a_data_pointer */ + EIF_INTEGER, /* a_size */ + EIF_INTEGER, /* a_nmemb */ + EIF_POINTER /* a_write_pointer */ + ); + +typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( +#ifndef EIF_IL_DLL + EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ +#endif + EIF_POINTER, /* a_curl_handle */ + EIF_INTEGER, /* a_curl_infotype */ + EIF_POINTER /* a_char_pointer */ + EIF_INTEGER, /* a_size */ + EIF_POINTER /* a_user_pointer */ + ); + +EIF_OBJECT eiffel_function_object = NULL; + /* Address of Eiffel object CURL_FUNCTION */ + +EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; + /* Address of Eiffel CURL_FUNCTION.progress_function */ + +EIF_CURL_WRITE_PROC eiffel_write_function = NULL; + /* Address of Eiffel CURL_FUNCTION.write_function */ + +EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; + /* Address of Eiffel CURL_FUNCTION.debug_function */ + +/* Set Eiffel CURL_FUNCTION object address */ +void c_set_object(EIF_OBJECT a_address) +{ + eiffel_function_object = (EIF_OBJECT) eif_adopt (a_address); +} + +/* Release Eiffel CURL_FUNCTION object address */ +void c_release_object() +{ + eif_wean (eiffel_function_object); +} + +/* Set CURL_FUNCTOIN.progress_function address */ +void c_set_progress_function_address( EIF_POINTER a_address) +{ + eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address; +} + +/* Set CURL_FUNCTOIN.write_function address */ +void c_set_write_function_address( EIF_POINTER a_address) +{ + eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address; +} + +/* Set CURL_FUNCTOIN.debug_function address */ +void c_set_debug_function_address (EIF_POINTER a_address) +{ + eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address; +} + +/* Eiffel adapter function for CURLOPT_WRITEFUNCTION + We need this function since Eiffel function call need first parameter is EIF_OBJECT. */ +size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) +{ + if (eiffel_function_object) { + return (size_t) ((eiffel_write_function) ( +#ifndef EIF_IL_DLL + (EIF_OBJECT) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) ptr, + (EIF_INTEGER) size, + (EIF_INTEGER) nmemb, + (EIF_POINTER) data)); + } else { + } +} + +/* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION + We need this function since Eiffel function call need first parameter is EIF_OBJECT. */ +size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) + { + if (eiffel_function_object) { + return (size_t) ((eiffel_progress_function) ( +#ifndef EIF_IL_DLL + (EIF_OBJECT) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) a_object_id, + (EIF_REAL_64) a_dltotal, + (EIF_REAL_64) a_dlnow, + (EIF_REAL_64) a_ultotal, + (EIF_REAL_64) a_ulnow)); + } else { + } + } + +/* Eiffel adapter function for CURLOPT_DEBUGFUNCTION + We need this function since Eiffel function call need first parameter is EIF_OBJECT. */ +size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id) + { + if (eiffel_function_object) { + return (size_t) ((eiffel_debug_function) ( +#ifndef EIF_IL_DLL + (EIF_OBJECT) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) a_curl_handle, + (EIF_INTEGER) a_curl_infotype, + (EIF_POINTER) a_char_pointer, + (EIF_INTEGER) a_size, + (EIF_POINTER) a_object_id)); + } else { + } + } + +#endif From 65559b8b826ec7dad0e74256508f27e06a5231e7 Mon Sep 17 00:00:00 2001 From: larryl Date: Thu, 8 Nov 2007 07:52:34 +0000 Subject: [PATCH 09/64] Removed some preprocessors. Made it compiled on Solaris. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71083 8089f293-4706-0410-a29e-feb5c42a2edf --- spec/include/eiffel_curl.h | 52 +++++++++++++++----------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index fa48272d..de172122 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -19,36 +19,30 @@ #define eiffel_curl typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) ( -#ifndef EIF_IL_DLL - EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ -#endif - EIF_POINTER, /* a_user_pointer */ - EIF_REAL_64, /* a_dltotal */ - EIF_REAL_64, /* a_dlnow */ - EIF_REAL_64, /* a_ultotal */ - EIF_REAL_64 /* a_ulnow */ - ); + EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ + EIF_POINTER, /* a_user_pointer */ + EIF_REAL_64, /* a_dltotal */ + EIF_REAL_64, /* a_dlnow */ + EIF_REAL_64, /* a_ultotal */ + EIF_REAL_64 /* a_ulnow */ + ); typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( -#ifndef EIF_IL_DLL - EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ -#endif - EIF_POINTER, /* a_data_pointer */ - EIF_INTEGER, /* a_size */ - EIF_INTEGER, /* a_nmemb */ - EIF_POINTER /* a_write_pointer */ - ); + EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ + EIF_POINTER, /* a_data_pointer */ + EIF_INTEGER, /* a_size */ + EIF_INTEGER, /* a_nmemb */ + EIF_POINTER /* a_write_pointer */ + ); typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( -#ifndef EIF_IL_DLL - EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ -#endif - EIF_POINTER, /* a_curl_handle */ - EIF_INTEGER, /* a_curl_infotype */ - EIF_POINTER /* a_char_pointer */ - EIF_INTEGER, /* a_size */ - EIF_POINTER /* a_user_pointer */ - ); + EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ + EIF_POINTER, /* a_curl_handle */ + EIF_INTEGER, /* a_curl_infotype */ + EIF_POINTER, /* a_char_pointer */ + EIF_INTEGER, /* a_size */ + EIF_POINTER /* a_user_pointer */ + ); EIF_OBJECT eiffel_function_object = NULL; /* Address of Eiffel object CURL_FUNCTION */ @@ -98,9 +92,7 @@ size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) { if (eiffel_function_object) { return (size_t) ((eiffel_write_function) ( -#ifndef EIF_IL_DLL (EIF_OBJECT) eif_access (eiffel_function_object), -#endif (EIF_POINTER) ptr, (EIF_INTEGER) size, (EIF_INTEGER) nmemb, @@ -115,9 +107,7 @@ size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dl { if (eiffel_function_object) { return (size_t) ((eiffel_progress_function) ( -#ifndef EIF_IL_DLL (EIF_OBJECT) eif_access (eiffel_function_object), -#endif (EIF_POINTER) a_object_id, (EIF_REAL_64) a_dltotal, (EIF_REAL_64) a_dlnow, @@ -133,9 +123,7 @@ size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, { if (eiffel_function_object) { return (size_t) ((eiffel_debug_function) ( -#ifndef EIF_IL_DLL (EIF_OBJECT) eif_access (eiffel_function_object), -#endif (EIF_POINTER) a_curl_handle, (EIF_INTEGER) a_curl_infotype, (EIF_POINTER) a_char_pointer, From 7e024b589ab55859406c4fb3a45bea330b421675 Mon Sep 17 00:00:00 2001 From: larryl Date: Thu, 8 Nov 2007 08:55:00 +0000 Subject: [PATCH 10/64] Use EIF_REFERENCE instead of EIF_OBJECT. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71086 8089f293-4706-0410-a29e-feb5c42a2edf --- spec/include/eiffel_curl.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index de172122..01ec99d6 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -19,7 +19,7 @@ #define eiffel_curl typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) ( - EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ EIF_POINTER, /* a_user_pointer */ EIF_REAL_64, /* a_dltotal */ EIF_REAL_64, /* a_dlnow */ @@ -28,7 +28,7 @@ typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) ( ); typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( - EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ EIF_POINTER, /* a_data_pointer */ EIF_INTEGER, /* a_size */ EIF_INTEGER, /* a_nmemb */ @@ -36,7 +36,7 @@ typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( ); typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( - EIF_OBJECT, /* CURL_FUNCTION Eiffel object */ + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ EIF_POINTER, /* a_curl_handle */ EIF_INTEGER, /* a_curl_infotype */ EIF_POINTER, /* a_char_pointer */ @@ -44,7 +44,7 @@ typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( EIF_POINTER /* a_user_pointer */ ); -EIF_OBJECT eiffel_function_object = NULL; +EIF_REFERENCE eiffel_function_object = NULL; /* Address of Eiffel object CURL_FUNCTION */ EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; @@ -57,9 +57,9 @@ EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; /* Address of Eiffel CURL_FUNCTION.debug_function */ /* Set Eiffel CURL_FUNCTION object address */ -void c_set_object(EIF_OBJECT a_address) +void c_set_object(EIF_REFERENCE a_address) { - eiffel_function_object = (EIF_OBJECT) eif_adopt (a_address); + eiffel_function_object = (EIF_REFERENCE) eif_adopt (a_address); } /* Release Eiffel CURL_FUNCTION object address */ @@ -87,12 +87,12 @@ void c_set_debug_function_address (EIF_POINTER a_address) } /* Eiffel adapter function for CURLOPT_WRITEFUNCTION - We need this function since Eiffel function call need first parameter is EIF_OBJECT. */ + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) { if (eiffel_function_object) { return (size_t) ((eiffel_write_function) ( - (EIF_OBJECT) eif_access (eiffel_function_object), + (EIF_REFERENCE) eif_access (eiffel_function_object), (EIF_POINTER) ptr, (EIF_INTEGER) size, (EIF_INTEGER) nmemb, @@ -102,12 +102,12 @@ size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) } /* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION - We need this function since Eiffel function call need first parameter is EIF_OBJECT. */ + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) { if (eiffel_function_object) { return (size_t) ((eiffel_progress_function) ( - (EIF_OBJECT) eif_access (eiffel_function_object), + (EIF_REFERENCE) eif_access (eiffel_function_object), (EIF_POINTER) a_object_id, (EIF_REAL_64) a_dltotal, (EIF_REAL_64) a_dlnow, @@ -118,12 +118,12 @@ size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dl } /* Eiffel adapter function for CURLOPT_DEBUGFUNCTION - We need this function since Eiffel function call need first parameter is EIF_OBJECT. */ + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id) { if (eiffel_function_object) { return (size_t) ((eiffel_debug_function) ( - (EIF_OBJECT) eif_access (eiffel_function_object), + (EIF_REFERENCE) eif_access (eiffel_function_object), (EIF_POINTER) a_curl_handle, (EIF_INTEGER) a_curl_infotype, (EIF_POINTER) a_char_pointer, From 81d91930ef38fa9956a92fa758235050ed3f4e9c Mon Sep 17 00:00:00 2001 From: larryl Date: Fri, 9 Nov 2007 08:36:46 +0000 Subject: [PATCH 11/64] Added class description and license information. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71100 8089f293-4706-0410-a29e-feb5c42a2edf --- spec/include/eiffel_curl.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index 01ec99d6..2c4d94b0 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -1,3 +1,17 @@ +/* +indexing + description: "Functions used by the class CURL_FUNCTION." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +*/ + #include #include From fe76c9eac58687b5589e4a100b978244ab68ca07 Mon Sep 17 00:00:00 2001 From: larryl Date: Fri, 9 Nov 2007 10:19:23 +0000 Subject: [PATCH 12/64] Added `static' to each variable and function to fix Linux Eiffel Studio finalizing C multiply definition problem. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71101 8089f293-4706-0410-a29e-feb5c42a2edf --- spec/include/eiffel_curl.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index 2c4d94b0..fe8c07ea 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -58,51 +58,51 @@ typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( EIF_POINTER /* a_user_pointer */ ); -EIF_REFERENCE eiffel_function_object = NULL; +static EIF_REFERENCE eiffel_function_object = NULL; /* Address of Eiffel object CURL_FUNCTION */ -EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; +static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; /* Address of Eiffel CURL_FUNCTION.progress_function */ -EIF_CURL_WRITE_PROC eiffel_write_function = NULL; +static EIF_CURL_WRITE_PROC eiffel_write_function = NULL; /* Address of Eiffel CURL_FUNCTION.write_function */ -EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; +static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; /* Address of Eiffel CURL_FUNCTION.debug_function */ /* Set Eiffel CURL_FUNCTION object address */ -void c_set_object(EIF_REFERENCE a_address) +static void c_set_object(EIF_REFERENCE a_address) { eiffel_function_object = (EIF_REFERENCE) eif_adopt (a_address); } /* Release Eiffel CURL_FUNCTION object address */ -void c_release_object() +static void c_release_object() { eif_wean (eiffel_function_object); } /* Set CURL_FUNCTOIN.progress_function address */ -void c_set_progress_function_address( EIF_POINTER a_address) +static void c_set_progress_function_address( EIF_POINTER a_address) { eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address; } /* Set CURL_FUNCTOIN.write_function address */ -void c_set_write_function_address( EIF_POINTER a_address) +static void c_set_write_function_address( EIF_POINTER a_address) { eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address; } /* Set CURL_FUNCTOIN.debug_function address */ -void c_set_debug_function_address (EIF_POINTER a_address) +static void c_set_debug_function_address (EIF_POINTER a_address) { eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address; } /* Eiffel adapter function for CURLOPT_WRITEFUNCTION We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ -size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) +static size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) { if (eiffel_function_object) { return (size_t) ((eiffel_write_function) ( @@ -117,7 +117,7 @@ size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) /* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ -size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) +static size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) { if (eiffel_function_object) { return (size_t) ((eiffel_progress_function) ( @@ -133,7 +133,7 @@ size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dl /* Eiffel adapter function for CURLOPT_DEBUGFUNCTION We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ -size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id) +static size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id) { if (eiffel_function_object) { return (size_t) ((eiffel_debug_function) ( From 4daf5b727a8aa45df8f7789a466242505d9ea753 Mon Sep 17 00:00:00 2001 From: paulb Date: Fri, 16 Nov 2007 00:13:35 +0000 Subject: [PATCH 13/64] Set item to default_pointer on dispose, to prevent a panic. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71170 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_form.e | 1 + 1 file changed, 1 insertion(+) diff --git a/curl_form.e b/curl_form.e index 2e698208..360257a4 100644 --- a/curl_form.e +++ b/curl_form.e @@ -58,6 +58,7 @@ feature -- Command if item /= default_pointer then create l_curl l_curl.formfree (item) + item := default_pointer end end From c8c23ca06433afb905772c5dfff06c1730d8eae3 Mon Sep 17 00:00:00 2001 From: manus Date: Sun, 18 Nov 2007 05:32:48 +0000 Subject: [PATCH 14/64] Fixed various errors in the C interface. Use new C external syntax. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71204 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_function.e | 18 ++++++++---------- spec/include/eiffel_curl.h | 11 +++++++++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/curl_function.e b/curl_function.e index 055de7cc..80f21b84 100644 --- a/curl_function.e +++ b/curl_function.e @@ -22,7 +22,7 @@ feature -- Interactive with C -- Set object and function addresses. -- Call this feature before call `c_set_progress_function', `c_set_debug_function' and `c_set_write_function'. do - c_set_object (Current) + c_set_object ($Current) c_set_progress_function_address ($progress_function) c_set_write_function_address ($write_function) c_set_debug_function_address ($debug_function) @@ -110,45 +110,43 @@ feature -- cURL curl_easy_setopt functions feature {NONE} -- Externals - c_set_object (a_object: like Current) is + c_set_object (a_object: POINTER) is -- Set Current object address. external - "C macro signature (EIF_OBJECT) use %"eiffel_curl.h%"" + "C signature (EIF_REFERENCE) use %"eiffel_curl.h%"" end c_release_object is -- Release Current pointer in C external - "C [macro %"eiffel_curl.h%"]" + "C use %"eiffel_curl.h%"" end c_set_progress_function_address (a_address: POINTER) is -- Set progress function address. external - "C [macro %"eiffel_curl.h%"]" + "C use %"eiffel_curl.h%"" end c_set_write_function_address (a_address: POINTER) is -- Set write function address. external - "C [macro %"eiffel_curl.h%"]" + "C use %"eiffel_curl.h%"" end c_set_debug_function_address (a_address: POINTER) is -- Set write function address. external - "C [macro %"eiffel_curl.h%"]" + "C use %"eiffel_curl.h%"" end feature {NONE} -- Implementation dispose is -- Wean `Current' - local - default_object: like Current do c_release_object - c_set_object (default_object) + c_set_object (default_pointer) end indexing diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index fe8c07ea..95fb3f0c 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -58,7 +58,7 @@ typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( EIF_POINTER /* a_user_pointer */ ); -static EIF_REFERENCE eiffel_function_object = NULL; +static EIF_OBJECT eiffel_function_object = NULL; /* Address of Eiffel object CURL_FUNCTION */ static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; @@ -73,7 +73,11 @@ static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; /* Set Eiffel CURL_FUNCTION object address */ static void c_set_object(EIF_REFERENCE a_address) { - eiffel_function_object = (EIF_REFERENCE) eif_adopt (a_address); + if (a_address) { + eiffel_function_object = eif_protect (a_address); + } else { + eiffel_function_object = NULL; + } } /* Release Eiffel CURL_FUNCTION object address */ @@ -112,6 +116,7 @@ static size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *d (EIF_INTEGER) nmemb, (EIF_POINTER) data)); } else { + return 0; } } @@ -128,6 +133,7 @@ static size_t curl_progress_function (void * a_object_id, double a_dltotal, doub (EIF_REAL_64) a_ultotal, (EIF_REAL_64) a_ulnow)); } else { + return 0; } } @@ -144,6 +150,7 @@ static size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_in (EIF_INTEGER) a_size, (EIF_POINTER) a_object_id)); } else { + return 0; } } From 9a3e12fe127d1f66139ae5014fde70310b83aa5d Mon Sep 17 00:00:00 2001 From: manus Date: Fri, 7 Dec 2007 01:08:12 +0000 Subject: [PATCH 15/64] Ensured that the library also works in finalized mode. The issue is that in finalized mode more than one copy of `eiffel_curl.h' could be present, meaning that multiple values of each static declared variables could be present at run-time and in one case, one was properly initialized, but not the other. Fixes bug#13671. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71399 8089f293-4706-0410-a29e-feb5c42a2edf --- Clib/Makefile-win.SH | 67 +++++++++++++++++ Clib/Makefile.SH | 94 +++++++++++++++++++++++ Clib/eiffel_curl.c | 149 ++++++++++++++++++++++++++++++++++++ cURL.ecf | 32 ++++++++ spec/include/eiffel_curl.h | 150 +++++-------------------------------- 5 files changed, 361 insertions(+), 131 deletions(-) create mode 100644 Clib/Makefile-win.SH create mode 100644 Clib/Makefile.SH create mode 100644 Clib/eiffel_curl.c diff --git a/Clib/Makefile-win.SH b/Clib/Makefile-win.SH new file mode 100644 index 00000000..11f90ca1 --- /dev/null +++ b/Clib/Makefile-win.SH @@ -0,0 +1,67 @@ +TOP = .. +DIR = $dir_sep +OUTDIR= . +INDIR= . +CC = $cc +OUTPUT_CMD = $output_cmd +CFLAGS = -I"$rt_include" -I..$(DIR)spec$(DIR)include -I. \ + -I..$(DIR)..$(DIR)..$(DIR)C_library$(DIR)libpng -I..$(DIR)..$(DIR)..$(DIR)C_library$(DIR)zlib +JCFLAGS = $(CFLAGS) $ccflags $optimize +JMTCFLAGS = $(CFLAGS) $mtccflags $optimize +JILCFLAGS = $(CFLAGS) $mtccflags $optimize -DEIF_IL_DLL +LN = copy +MV = $mv +RM = $del +MKDIR_TARGET = $mkdir_target +LINK = $link32 +DLL_FLAGS = $dll_flags +DLL_LIBS = $dll_libs +OBJECTS = eiffel_curl.$obj +MT_OBJECTS = MTeiffel_curl.$obj +IL_OBJECTS = ILeiffel_curl.$obj + +.c.$obj: + $(CC) -c $(JCFLAGS) $< + +all:: lib_dir $output_libraries clean + +standard:: eiffel_curl.lib ileiffel_curl.lib +mtstandard:: mteiffel_curl.lib + +..$(DIR)spec: + $(MKDIR_TARGET) + +..$(DIR)spec$(DIR)$(ISE_C_COMPILER): ..$(DIR)spec + $(MKDIR_TARGET) + +..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM): ..$(DIR)spec$(DIR)$(ISE_C_COMPILER) + $(MKDIR_TARGET) + +..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib: ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM) + $(MKDIR_TARGET) + +lib_dir: ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib + +clean: + $(RM) *.$obj + $(RM) *.lib + +eiffel_curl.lib: $(OBJECTS) + $alib_line + $(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@ + +mteiffel_curl.lib: $(MT_OBJECTS) + $alib_line + $(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@ + +ileiffel_curl.lib: $(IL_OBJECTS) + $alib_line + $(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@ + +#Multithreaded targets. +MTeiffel_curl.$obj: eiffel_curl.c + $(CC) $(JMTCFLAGS) $(OUTPUT_CMD)$@ -c $? + +#.NET targets. +ILeiffel_curl.$obj: eiffel_curl.c + $(CC) $(JILCFLAGS) $(OUTPUT_CMD)$@ -c $? diff --git a/Clib/Makefile.SH b/Clib/Makefile.SH new file mode 100644 index 00000000..325dbfe8 --- /dev/null +++ b/Clib/Makefile.SH @@ -0,0 +1,94 @@ +case $CONFIG in +'') + if test ! -f config.sh; then + (echo "Can't find config.sh."; exit 1) + fi 2>/dev/null + . ./config.sh + ;; +esac +case "$0" in +*/*) cd `expr X$0 : 'X\(.*\)/'` ;; +esac +echo "Extracting "."/Makefile (with variable substitutions)" +$spitshell >Makefile <>Makefile <<'!NO!SUBS!' + +MT_OBJECTS = MTeiffel_curl.o +OBJECTS = eiffel_curl.o + +ALL_OBJECTS = $(OBJECTS) $(MT_OBJECTS) + +all: $(ALL_OBJECTS) + $(MKDIR) ../spec/$(PLATFORM)/lib + $(MV) $? ../spec/$(PLATFORM)/lib + $(MAKE) clobber + +MTeiffel_curl.o: eiffel_curl.c + $(CC) -c $(MTCFLAGS) $? -o $@ + +local_realclean:: + $(RM) $(ALL_OBJECTS) +######################################################################## +# Common rules for all Makefiles -- do not edit + +emptyrule:: + +clean: local_clean +realclean: local_realclean +clobber: local_clobber + +local_clean:: + $(RM) core *~ *.o + +local_realclean:: local_clean + +local_clobber:: local_realclean + $(RM) Makefile config.sh + +Makefile: Makefile.SH + /bin/sh Makefile.SH + +tags:: + $(CTAGS) -w *.[ch] + $(CTAGS) -xw *.[ch] > tags + +local_clobber:: + $(RM) tags + +######################################################################## +# Dependencies generated by make depend +# DO NOT DELETE THIS LINE -- make depend relies on it + +# Put nothing here or make depend will gobble it up +.FORCE_DEPEND:: + @echo "You must run 'make depend' in $(TOP) first."; exit 1 +!NO!SUBS! +chmod 644 Makefile +$eunicefix Makefile + diff --git a/Clib/eiffel_curl.c b/Clib/eiffel_curl.c new file mode 100644 index 00000000..a3ea435d --- /dev/null +++ b/Clib/eiffel_curl.c @@ -0,0 +1,149 @@ +/* +indexing + description: "Functions used by the class CURL_FUNCTION." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +*/ + +#include "eiffel_curl.h" + +typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) ( +#ifndef EIF_IL_DLL + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ +#endif + EIF_POINTER, /* a_user_pointer */ + EIF_REAL_64, /* a_dltotal */ + EIF_REAL_64, /* a_dlnow */ + EIF_REAL_64, /* a_ultotal */ + EIF_REAL_64 /* a_ulnow */ + ); + +typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( +#ifndef EIF_IL_DLL + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ +#endif + EIF_POINTER, /* a_data_pointer */ + EIF_INTEGER, /* a_size */ + EIF_INTEGER, /* a_nmemb */ + EIF_POINTER /* a_write_pointer */ + ); + +typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( +#ifndef EIF_IL_DLL + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ +#endif + EIF_POINTER, /* a_curl_handle */ + EIF_INTEGER, /* a_curl_infotype */ + EIF_POINTER, /* a_char_pointer */ + EIF_INTEGER, /* a_size */ + EIF_POINTER /* a_user_pointer */ + ); + +static EIF_OBJECT eiffel_function_object = NULL; + /* Address of Eiffel object CURL_FUNCTION */ + +static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; + /* Address of Eiffel CURL_FUNCTION.progress_function */ + +static EIF_CURL_WRITE_PROC eiffel_write_function = NULL; + /* Address of Eiffel CURL_FUNCTION.write_function */ + +static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; + /* Address of Eiffel CURL_FUNCTION.debug_function */ + +/* Set Eiffel CURL_FUNCTION object address */ +void c_set_object(EIF_REFERENCE a_address) +{ + if (a_address) { + eiffel_function_object = eif_protect (a_address); + } else { + eiffel_function_object = NULL; + } +} + +/* Release Eiffel CURL_FUNCTION object address */ +void c_release_object() +{ + eif_wean (eiffel_function_object); +} + +/* Set CURL_FUNCTOIN.progress_function address */ +void c_set_progress_function_address( EIF_POINTER a_address) +{ + eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address; +} + +/* Set CURL_FUNCTOIN.write_function address */ +void c_set_write_function_address( EIF_POINTER a_address) +{ + eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address; +} + +/* Set CURL_FUNCTOIN.debug_function address */ +void c_set_debug_function_address (EIF_POINTER a_address) +{ + eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address; +} + +/* Eiffel adapter function for CURLOPT_WRITEFUNCTION + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ +size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) +{ + if (eiffel_function_object) { + return (size_t) ((eiffel_write_function) ( +#ifndef EIF_IL_DLL + (EIF_REFERENCE) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) ptr, + (EIF_INTEGER) size, + (EIF_INTEGER) nmemb, + (EIF_POINTER) data)); + } else { + return 0; + } +} + +/* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ +size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) + { + if (eiffel_function_object) { + return (size_t) ((eiffel_progress_function) ( +#ifndef EIF_IL_DLL + (EIF_REFERENCE) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) a_object_id, + (EIF_REAL_64) a_dltotal, + (EIF_REAL_64) a_dlnow, + (EIF_REAL_64) a_ultotal, + (EIF_REAL_64) a_ulnow)); + } else { + return 0; + } + } + +/* Eiffel adapter function for CURLOPT_DEBUGFUNCTION + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ +size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id) + { + if (eiffel_function_object) { + return (size_t) ((eiffel_debug_function) ( +#ifndef EIF_IL_DLL + (EIF_REFERENCE) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) a_curl_handle, + (EIF_INTEGER) a_curl_infotype, + (EIF_POINTER) a_char_pointer, + (EIF_INTEGER) a_size, + (EIF_POINTER) a_object_id)); + } else { + return 0; + } + } diff --git a/cURL.ecf b/cURL.ecf index b92ba6cd..0ba49079 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -23,6 +23,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index 95fb3f0c..e9138e2e 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -12,146 +12,34 @@ indexing ]" */ -#include -#include +#ifndef _eiffel_curl_h_ +#define _eiffel_curl_h_ + +#include "eif_eiffel.h" /* unix-specific */ -#ifndef EIF_WINNT +#ifndef EIF_WINDOWS #include #include #endif #include -#include "eif_main.h" - -#ifdef EIF_THREADS -#include "eif_threads.h" +#ifdef __cplusplus +extern "C" { #endif -#ifndef eiffel_curl -#define eiffel_curl - -typedef EIF_INTEGER (* EIF_CURL_PROGRESS_PROC) ( - EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ - EIF_POINTER, /* a_user_pointer */ - EIF_REAL_64, /* a_dltotal */ - EIF_REAL_64, /* a_dlnow */ - EIF_REAL_64, /* a_ultotal */ - EIF_REAL_64 /* a_ulnow */ - ); - -typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( - EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ - EIF_POINTER, /* a_data_pointer */ - EIF_INTEGER, /* a_size */ - EIF_INTEGER, /* a_nmemb */ - EIF_POINTER /* a_write_pointer */ - ); - -typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( - EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ - EIF_POINTER, /* a_curl_handle */ - EIF_INTEGER, /* a_curl_infotype */ - EIF_POINTER, /* a_char_pointer */ - EIF_INTEGER, /* a_size */ - EIF_POINTER /* a_user_pointer */ - ); - -static EIF_OBJECT eiffel_function_object = NULL; - /* Address of Eiffel object CURL_FUNCTION */ - -static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; - /* Address of Eiffel CURL_FUNCTION.progress_function */ - -static EIF_CURL_WRITE_PROC eiffel_write_function = NULL; - /* Address of Eiffel CURL_FUNCTION.write_function */ - -static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; - /* Address of Eiffel CURL_FUNCTION.debug_function */ - -/* Set Eiffel CURL_FUNCTION object address */ -static void c_set_object(EIF_REFERENCE a_address) -{ - if (a_address) { - eiffel_function_object = eif_protect (a_address); - } else { - eiffel_function_object = NULL; - } -} - -/* Release Eiffel CURL_FUNCTION object address */ -static void c_release_object() -{ - eif_wean (eiffel_function_object); -} - -/* Set CURL_FUNCTOIN.progress_function address */ -static void c_set_progress_function_address( EIF_POINTER a_address) -{ - eiffel_progress_function = (EIF_CURL_PROGRESS_PROC) a_address; -} - -/* Set CURL_FUNCTOIN.write_function address */ -static void c_set_write_function_address( EIF_POINTER a_address) -{ - eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address; -} - -/* Set CURL_FUNCTOIN.debug_function address */ -static void c_set_debug_function_address (EIF_POINTER a_address) -{ - eiffel_debug_function = (EIF_CURL_DEBUG_PROC) a_address; -} - -/* Eiffel adapter function for CURLOPT_WRITEFUNCTION - We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ -static size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) -{ - if (eiffel_function_object) { - return (size_t) ((eiffel_write_function) ( - (EIF_REFERENCE) eif_access (eiffel_function_object), - (EIF_POINTER) ptr, - (EIF_INTEGER) size, - (EIF_INTEGER) nmemb, - (EIF_POINTER) data)); - } else { - return 0; - } -} - -/* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION - We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ -static size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) - { - if (eiffel_function_object) { - return (size_t) ((eiffel_progress_function) ( - (EIF_REFERENCE) eif_access (eiffel_function_object), - (EIF_POINTER) a_object_id, - (EIF_REAL_64) a_dltotal, - (EIF_REAL_64) a_dlnow, - (EIF_REAL_64) a_ultotal, - (EIF_REAL_64) a_ulnow)); - } else { - return 0; - } - } - -/* Eiffel adapter function for CURLOPT_DEBUGFUNCTION - We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ -static size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id) - { - if (eiffel_function_object) { - return (size_t) ((eiffel_debug_function) ( - (EIF_REFERENCE) eif_access (eiffel_function_object), - (EIF_POINTER) a_curl_handle, - (EIF_INTEGER) a_curl_infotype, - (EIF_POINTER) a_char_pointer, - (EIF_INTEGER) a_size, - (EIF_POINTER) a_object_id)); - } else { - return 0; - } - } +extern void c_set_object(EIF_REFERENCE a_address); +extern void c_release_object(void); +extern void c_set_progress_function_address( EIF_POINTER a_address); +extern void c_set_write_function_address( EIF_POINTER a_address); +extern void c_set_debug_function_address (EIF_POINTER a_address); +extern size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data); +extern size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow); +extern size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id); +#ifdef __cplusplus +} +#endif + #endif From ea4be7219b1c74afd6288d328de84207544e6675 Mon Sep 17 00:00:00 2001 From: manus Date: Fri, 7 Dec 2007 01:15:55 +0000 Subject: [PATCH 16/64] Fixed bug#13627 where we had an incorrect cast. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71400 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_externals.e | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/curl_externals.e b/curl_externals.e index 44c058cc..274b9d4d 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -120,8 +120,8 @@ feature {NONE} -- C externals "[ { (FUNCTION_CAST(void, (struct curl_httppost **, struct curl_httppost **, int, char *, int, char *, int)) $a_api) - ((struct curl_httppost *)$a_form, - (struct curl_httppost *)$a_last_pointer, + ((struct curl_httppost **)$a_form, + (struct curl_httppost **)$a_last_pointer, (int)$a_arg_1, (char *)$a_arg_1_value, (int)$a_arg_2, From 7448567c53b36992db9ab96d6077d0fc8bdf519e Mon Sep 17 00:00:00 2001 From: jfiat Date: Fri, 7 Dec 2007 12:15:52 +0000 Subject: [PATCH 17/64] Fully automated EiffelStudio's building using geant scripts: It integrates part of the work done by "es-make" project from ETH (mainly on the checker script) This is a first step in rewriting the previous $EIFFEL_SRC/scripts/*.eant scripts to build 'ec' and make a new delivery. Added a few standalone geant scripts in the EiffelStudio's source code, to ease the compilation. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71410 8089f293-4706-0410-a29e-feb5c42a2edf --- Clib/build.eant | 24 ++++++++++++++++++++++++ build.eant | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 Clib/build.eant create mode 100644 build.eant diff --git a/Clib/build.eant b/Clib/build.eant new file mode 100644 index 00000000..ca40ab29 --- /dev/null +++ b/Clib/build.eant @@ -0,0 +1,24 @@ + + + + + description: "cURL Clib library compilation" + + + + + + + + + + + + + + + + + + + diff --git a/build.eant b/build.eant new file mode 100644 index 00000000..221aa5b3 --- /dev/null +++ b/build.eant @@ -0,0 +1,28 @@ + + + + + description: "cURL library compilation" + + + + + + + + + + + + + + + + + + + + + + From 5980a724cc6845e73e28aec0251b126b9f648b64 Mon Sep 17 00:00:00 2001 From: manus Date: Mon, 10 Dec 2007 17:21:34 +0000 Subject: [PATCH 18/64] Removed directory integrated by mistake. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71441 8089f293-4706-0410-a29e-feb5c42a2edf From 987c18198e8ab3a047170203cdae6fb5c222c8b3 Mon Sep 17 00:00:00 2001 From: larryl Date: Mon, 31 Dec 2007 09:48:53 +0000 Subject: [PATCH 19/64] Added http header related features. It means we can change http header by setting a list ourself. Wrapped more cURL constants. Added `release_item' in {CURL_FORM} which is useful to clean the {CURL_FORM} generated by {CURL_EXTERNALS}.formadd_string_string. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71685 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_default_function.e | 5 ++--- curl_easy_externals.e | 10 ++++++++++ curl_externals.e | 19 +++++++++++++++++++ curl_form.e | 7 +++++++ curl_opt_constants.e | 26 +++++++++++++++++++++++++- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/curl_default_function.e b/curl_default_function.e index b8ddb07c..f6248443 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -35,7 +35,7 @@ feature -- Command -- Redefine local l_c_string: C_STRING - l_string: STRING + l_string: CURL_STRING l_identified: IDENTIFIED do Result := a_size * a_nmemb @@ -85,9 +85,8 @@ feature {NONE} -- Implementation local l_c_string: C_STRING do - print ("%N" + a_text) create l_c_string.share_from_pointer_and_count (a_char_pointer, a_size) - print ("%N" + l_c_string.string) + print ("%N" + a_text + "%N" + l_c_string.string) end indexing diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 42932207..73259dab 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -54,6 +54,16 @@ feature -- Command setopt_void_star (a_curl_handle, a_opt, a_form.item) end + setopt_slist (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_slist: POINTER) is + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: a_opt = {CURL_OPT_CONSTANTS}.curlopt_httpheader + exists: a_curl_slist /= default_pointer + do + setopt_void_star (a_curl_handle, a_opt, a_curl_slist) + end + setopt_curl_string (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_string: CURL_STRING) is -- Declared as curl_easy_setopt(). require diff --git a/curl_externals.e b/curl_externals.e index 274b9d4d..d834c389 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -52,6 +52,22 @@ feature -- Command end end + slist_append (a_list: POINTER; a_string: STRING_GENERAL): POINTER is + -- Declared as curl_slist_append (). + require + exists: a_list /= default_pointer + not_void: a_string /= Void + local + l_c_string: C_STRING + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_slist_append") + if l_api /= default_pointer then + create l_c_string.make (a_string) + Result := c_slist_append (l_api, a_list, l_c_string.item) + end + end + feature -- Query is_dynamic_library_exists: BOOLEAN is @@ -64,6 +80,9 @@ feature {CURL_FORM} -- Internal command formfree (a_curl_form: POINTER) is -- Declared as curl_formfree (). + -- See: http://curl.askapache.com/libcurl/c/curl_formfree.html + -- curl_formfree() is used to clean up data previously built/appended with curl_formadd(3). + -- This must be called when the data has been used, which typically means after the curl_easy_perform(3) has been called. require exists: a_curl_form /= default_pointer local diff --git a/curl_form.e b/curl_form.e index 360257a4..6d26c2e6 100644 --- a/curl_form.e +++ b/curl_form.e @@ -62,6 +62,13 @@ feature -- Command end end + release_item is + -- Release item + -- NOT free memory! This is useful if Current generated by {CURL_EXTERNALS}.formadd_string_string. + do + item := default_pointer + end + feature {CURL_EXTERNALS} -- Internal command set_item (a_item: POINTER) is diff --git a/curl_opt_constants.e b/curl_opt_constants.e index c748e999..f31c55a8 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -184,6 +184,28 @@ feature -- Enumerations. ]" end + curlopt_referer: INTEGER is + -- Declared as CURLOPT_REFERER + external + "C inline use " + alias + "[ + return CURLOPT_REFERER; + ]" + end + + curlopt_httpget: INTEGER is + -- Declared as CURLOPT_HTTPGET + -- Pass a long. If the long is non-zero, this forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle. + -- When setting CURLOPT_HTTPGET to a non-zero value, it will automatically set CURLOPT_NOBODY to 0 (since 7.14.1). + external + "C inline use " + alias + "[ + return CURLOPT_HTTPGET; + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN is -- If `a_integer' value vaild? do @@ -203,7 +225,9 @@ feature -- Enumerations. a_integer = curlopt_writefunction or a_integer = curlopt_progressfunction or a_integer = curlopt_progressdata or - a_integer = curlopt_noprogress + a_integer = curlopt_noprogress or + a_integer = curlopt_referer or + a_integer = curlopt_httpget end indexing From 60b99e48d4126ec9d612203f46d2244f36c63e11 Mon Sep 17 00:00:00 2001 From: larryl Date: Wed, 9 Jan 2008 06:50:07 +0000 Subject: [PATCH 20/64] Added `global_cleanup' which declared as curl_global_cleanup() in C. Added comments. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71817 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_easy_externals.e | 3 +++ curl_externals.e | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 73259dab..3fdb7e36 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -95,6 +95,7 @@ feature -- Command perform (a_curl_handle: POINTER): INTEGER is -- Declared as curl_easy_perform(). + -- Result is one value from {CURL_CODES} require exists: a_curl_handle /= default_pointer local @@ -145,6 +146,8 @@ feature -- Special setting set_write_function (a_curl_handle: POINTER) is -- Set cURL write function + -- Set cURL write function with Eiffel default write function. + -- So we can use CURL_STRING as parameter in {CURL_EASY_EXTERNALS}.setopt_curl_string when the option is {CURL_OPT_CONSTANTS}.curlopt_writedata require exists: a_curl_handle /= default_pointer local diff --git a/curl_externals.e b/curl_externals.e index d834c389..d430736e 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -25,6 +25,17 @@ feature -- Command end end + global_cleanup is + -- Declared as curl_global_cleanup(). + local + l_ptr: POINTER + do + l_ptr := api_loader.safe_load_api (module_name, "curl_global_cleanup") + if l_ptr /= default_pointer then + c_curl_global_cleanup (l_ptr); + end + end + formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is -- Declared as curl_formadd (). require @@ -165,7 +176,7 @@ feature {NONE} -- C externals end c_curl_global_init (a_api: POINTER; a_opt: NATURAL_64) is - -- `a_api' point to AIP curl_global_init () + -- `a_api' point to API curl_global_init () -- `a_opt' is intialization option. require exists: a_api /= default_pointer @@ -177,6 +188,18 @@ feature {NONE} -- C externals ]" end + c_curl_global_cleanup (a_api: POINTER) is + -- `a_api' point to API curl_global_cleanup() + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void, ()) $a_api)(); + ]" + end + c_slist_append (a_api: POINTER; a_list_pointer: POINTER; a_string: POINTER): POINTER is -- Declared as curl_slist_append (). require From 3b231019ea6e528785f7fadd697e6120200e6525 Mon Sep 17 00:00:00 2001 From: jfiat Date: Mon, 14 Jan 2008 11:50:55 +0000 Subject: [PATCH 21/64] Added {CURL_OPT_CONSTANTS}.curlopt_followlocation git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71900 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index f31c55a8..9958c24a 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -54,6 +54,16 @@ feature -- Enumerations. ]" end + curlopt_followlocation: INTEGER is + -- Declared as CURLOPT_FOLLOWLOCATION + external + "C inline use " + alias + "[ + return CURLOPT_FOLLOWLOCATION; + ]" + end + curlopt_verbose: INTEGER is -- Declared as CURLOPT_VERBOSE. external @@ -165,7 +175,7 @@ feature -- Enumerations. end curlopt_noprogress: INTEGER is - -- Decalred as CURLOPT_NOPROGRESS + -- Declared as CURLOPT_NOPROGRESS external "C inline use " alias @@ -175,7 +185,7 @@ feature -- Enumerations. end curlopt_progressdata: INTEGER is - -- Decalred as CURLOPT_PROGRESSDATA + -- Declared as CURLOPT_PROGRESSDATA external "C inline use " alias @@ -212,6 +222,7 @@ feature -- Enumerations. Result := a_integer = curlopt_cookie or a_integer = curlopt_cookiefile or a_integer = curlopt_debugfunction or + a_integer = curlopt_followlocation or a_integer = curlopt_httpheader or a_integer = curlopt_httppost or a_integer = curlopt_post or From b1952a6e2c098c58ff748fb9a64126972b580889 Mon Sep 17 00:00:00 2001 From: paulb Date: Thu, 31 Jan 2008 21:02:28 +0000 Subject: [PATCH 22/64] Added query for Mac OS as a platform in PLATFORM. Fixed cURL library to ustilize Mac OS dylib version of libcurl git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@72154 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_utility.e | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/curl_utility.e b/curl_utility.e index 4a204759..19841255 100644 --- a/curl_utility.e +++ b/curl_utility.e @@ -14,12 +14,11 @@ feature -- Query module_name: STRING is -- Module name. - local - l_platform: PLATFORM once - create l_platform - if l_platform.is_windows then + if {PLATFORM}.is_windows then Result := "libcurl.dll" + elseif {PLATFORM}.is_mac then + Result := "libcurl.dylib" else Result := "libcurl.so" end From 839cb26d7ef58dca7667ab21a6381d46cd1f55a8 Mon Sep 17 00:00:00 2001 From: paulb Date: Fri, 1 Feb 2008 16:36:55 +0000 Subject: [PATCH 23/64] changed platform query `is_mac' to `is_mac_os' git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@72173 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_utility.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curl_utility.e b/curl_utility.e index 19841255..5eec05c4 100644 --- a/curl_utility.e +++ b/curl_utility.e @@ -17,7 +17,7 @@ feature -- Query once if {PLATFORM}.is_windows then Result := "libcurl.dll" - elseif {PLATFORM}.is_mac then + elseif {PLATFORM}.is_mac_os then Result := "libcurl.dylib" else Result := "libcurl.so" From 893fce57065556ece398379f13286348d88ca3b9 Mon Sep 17 00:00:00 2001 From: paulb Date: Fri, 1 Feb 2008 16:42:36 +0000 Subject: [PATCH 24/64] Reverted to is_mac git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@72174 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_utility.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curl_utility.e b/curl_utility.e index 5eec05c4..19841255 100644 --- a/curl_utility.e +++ b/curl_utility.e @@ -17,7 +17,7 @@ feature -- Query once if {PLATFORM}.is_windows then Result := "libcurl.dll" - elseif {PLATFORM}.is_mac_os then + elseif {PLATFORM}.is_mac then Result := "libcurl.dylib" else Result := "libcurl.so" From 098032e81580d001cdb84f99934f220977eb0657 Mon Sep 17 00:00:00 2001 From: larryl Date: Fri, 29 Feb 2008 03:43:43 +0000 Subject: [PATCH 25/64] Raise an exception when cURL dynamic library not found. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@72546 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_dynamic_library_not_found_exception.e | 40 ++++++++++++++++++++++ curl_easy_externals.e | 4 +++ curl_externals.e | 4 +++ 3 files changed, 48 insertions(+) create mode 100644 curl_dynamic_library_not_found_exception.e diff --git a/curl_dynamic_library_not_found_exception.e b/curl_dynamic_library_not_found_exception.e new file mode 100644 index 00000000..7686dbd7 --- /dev/null +++ b/curl_dynamic_library_not_found_exception.e @@ -0,0 +1,40 @@ +indexing + description: "[ + Exception which means cURL dynamic library (*.dll on Windows, + *.so on Linux and ...) not found. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_DYNAMIC_LIBRARY_NOT_FOUND_EXCEPTION + +inherit + DEVELOPER_EXCEPTION + +create + make + +feature {NONE} -- Initialization + + make is + -- Creation method. + do + set_message ("cURL dynamic library not found.") + end + +indexing + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 3fdb7e36..752b03cb 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -18,10 +18,14 @@ feature -- Command -- Declared as curl_easy_init(). local l_api: POINTER + l_exception: CURL_DYNAMIC_LIBRARY_NOT_FOUND_EXCEPTION do l_api := api_loader.safe_load_api (module_name, "curl_easy_init") if l_api /= default_pointer then Result := c_init (l_api) + else + create l_exception.make + l_exception.raise end ensure exists: Result /= default_pointer diff --git a/curl_externals.e b/curl_externals.e index d430736e..5bcdce7e 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -18,10 +18,14 @@ feature -- Command -- Declared as curl_global_init(). local l_ptr: POINTER + l_exception: CURL_DYNAMIC_LIBRARY_NOT_FOUND_EXCEPTION do l_ptr := api_loader.safe_load_api (module_name, "curl_global_init") if l_ptr /= default_pointer then c_curl_global_init (l_ptr, {CURL_GLOBAL_CONSTANTS}.curl_global_all); + else + create l_exception.make + l_exception.raise end end From a06fbd5f0b6dd7896515ea1d14bbb32b8cbf4198 Mon Sep 17 00:00:00 2001 From: larryl Date: Wed, 5 Mar 2008 11:06:41 +0000 Subject: [PATCH 26/64] Use precondition instead of raising an exception. Fixed bug#14062: CURL dynamic library not found exception is causing an internal failure in WEL git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@72612 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_dynamic_library_not_found_exception.e | 40 ---------------------- curl_easy_externals.e | 14 +++++--- curl_externals.e | 6 ++-- 3 files changed, 12 insertions(+), 48 deletions(-) delete mode 100644 curl_dynamic_library_not_found_exception.e diff --git a/curl_dynamic_library_not_found_exception.e b/curl_dynamic_library_not_found_exception.e deleted file mode 100644 index 7686dbd7..00000000 --- a/curl_dynamic_library_not_found_exception.e +++ /dev/null @@ -1,40 +0,0 @@ -indexing - description: "[ - Exception which means cURL dynamic library (*.dll on Windows, - *.so on Linux and ...) not found. - ]" - status: "See notice at end of class." - legal: "See notice at end of class." - date: "$Date$" - revision: "$Revision$" - -class - CURL_DYNAMIC_LIBRARY_NOT_FOUND_EXCEPTION - -inherit - DEVELOPER_EXCEPTION - -create - make - -feature {NONE} -- Initialization - - make is - -- Creation method. - do - set_message ("cURL dynamic library not found.") - end - -indexing - library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" - license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" - source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]" - -end diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 752b03cb..e48efd09 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -16,16 +16,14 @@ feature -- Command init: POINTER is -- Declared as curl_easy_init(). + require + dynamic_library_exists: is_dynamic_library_exists local l_api: POINTER - l_exception: CURL_DYNAMIC_LIBRARY_NOT_FOUND_EXCEPTION do l_api := api_loader.safe_load_api (module_name, "curl_easy_init") if l_api /= default_pointer then Result := c_init (l_api) - else - create l_exception.make - l_exception.raise end ensure exists: Result /= default_pointer @@ -126,6 +124,14 @@ feature -- Command end end +feature -- Query + + is_dynamic_library_exists: BOOLEAN is + -- If dll/so files exist? + do + Result := (api_loader.module_pointer (module_name) /= default_pointer) + end + feature -- Special setting set_curl_function (a_curl_function: CURL_FUNCTION) is diff --git a/curl_externals.e b/curl_externals.e index 5bcdce7e..36637d3d 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -16,16 +16,14 @@ feature -- Command global_init is -- Declared as curl_global_init(). + require + dynamic_library_exists: is_dynamic_library_exists local l_ptr: POINTER - l_exception: CURL_DYNAMIC_LIBRARY_NOT_FOUND_EXCEPTION do l_ptr := api_loader.safe_load_api (module_name, "curl_global_init") if l_ptr /= default_pointer then c_curl_global_init (l_ptr, {CURL_GLOBAL_CONSTANTS}.curl_global_all); - else - create l_exception.make - l_exception.raise end end From 9ef3391b26ea17b82c384708c4a9cd5bce87cf58 Mon Sep 17 00:00:00 2001 From: paulb Date: Fri, 18 Jul 2008 20:07:15 +0000 Subject: [PATCH 27/64] Added major version to load the shared library according to rules of ldconfig and the like on other OSs. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@74121 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_utility.e | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/curl_utility.e b/curl_utility.e index 19841255..b272be3b 100644 --- a/curl_utility.e +++ b/curl_utility.e @@ -18,9 +18,9 @@ feature -- Query if {PLATFORM}.is_windows then Result := "libcurl.dll" elseif {PLATFORM}.is_mac then - Result := "libcurl.dylib" + Result := "libcurl.3.dylib" else - Result := "libcurl.so" + Result := "libcurl.so.3" end ensure not_void: Result /= Void From 544b5784ae7e8158daff321b76baf371fa529af0 Mon Sep 17 00:00:00 2001 From: manus Date: Mon, 1 Dec 2008 19:34:30 +0000 Subject: [PATCH 28/64] Moved API_LOADER class to where it was used, i.e. the cURL library. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@75972 8089f293-4706-0410-a29e-feb5c42a2edf --- api_loader.e | 115 ++++++++++++++++++++++++++ cURL.ecf | 24 +++++- implementation/gtk/api_loader_imp.e | 79 ++++++++++++++++++ implementation/mswin/api_loader_imp.e | 96 +++++++++++++++++++++ 4 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 api_loader.e create mode 100644 implementation/gtk/api_loader_imp.e create mode 100644 implementation/mswin/api_loader_imp.e diff --git a/api_loader.e b/api_loader.e new file mode 100644 index 00000000..310f2e85 --- /dev/null +++ b/api_loader.e @@ -0,0 +1,115 @@ +indexing + description: "[ + Dynamic load a external API which exists in a dll or so. + Benefit is we can still use our executables even without the dll/so files. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + API_LOADER + +feature -- Query + + safe_load_api (a_module_name: STRING; a_api_name: STRING): POINTER is + -- Safe loading `a_api_name' in `a_module_name' if possible. + -- `a_module_name' is case sensitive. + require + not_void: a_module_name /= Void and then not a_module_name.is_empty + not_void: a_api_name /= Void and then not a_api_name.is_empty + local + l_module: POINTER + do + l_module := module_pointer (a_module_name) + if l_module /= default_pointer then + Result := api_pointer (l_module, a_api_name) + end + end + + module_pointer (a_name: STRING): POINTER is + -- Find module hanle with `a_name' + -- Result is void if not exists + require + not_void: a_name /= Void + do + if loaded_modules.has_key (a_name) then + Result := loaded_modules.item (a_name) + else + Result := implementation.load_module (a_name) + if Result /= default_pointer then + loaded_modules.extend (Result, a_name) + end + end + end + + api_pointer (a_module: POINTER; a_name: STRING): POINTER is + -- Find API pointer which name is `a_name' in `a_module' + -- Result is void if not exists. + require + exists: a_module /= default_pointer + not_void: a_name /= Void + do + if loaded_apis.has (a_name) then + Result := loaded_apis.item (a_name) + else + Result := implementation.loal_api (a_module, a_name) + if Result /= default_pointer then + loaded_apis.extend (Result, a_name) + end + end + end + +feature {NONE} -- Implementation + + loaded_modules: HASH_TABLE [POINTER, STRING] is + -- Loaded modules + once + create Result.make (1) + end + + loaded_apis: HASH_TABLE [POINTER, STRING] is + -- Loaded apis. + once + create Result.make (10) + end + + implementation: API_LOADER_IMP is + -- Native loader + once + create Result + end +indexing + copyright: "Copyright (c) 1984-2007, Eiffel Software" + license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" + licensing_options: "http://www.eiffel.com/licensing" + copying: "[ + This file is part of Eiffel Software's Eiffel Development Environment. + + Eiffel Software's Eiffel Development Environment is free + software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published + by the Free Software Foundation, version 2 of the License + (available at the URL listed under "license" above). + + Eiffel Software's Eiffel Development Environment is + distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with Eiffel Software's Eiffel Development + Environment; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + ]" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/cURL.ecf b/cURL.ecf index 0ba49079..c063ebdc 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -1,5 +1,5 @@ - + cURL: libcURL wrapper library for Eiffel. Copyright (c) 1984-2006, Eiffel Software and others. @@ -56,7 +56,25 @@ - - + + + + + /spec$ + /Clib$ + + + /gtk$ + + + + + + /mswin$ + + + + + diff --git a/implementation/gtk/api_loader_imp.e b/implementation/gtk/api_loader_imp.e new file mode 100644 index 00000000..339fa4ae --- /dev/null +++ b/implementation/gtk/api_loader_imp.e @@ -0,0 +1,79 @@ +indexing + description: "[ + Interactive with native system APIs for dynamic loading. + GTK verson. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + API_LOADER_IMP + +feature -- Command + + load_module (a_name: STRING): POINTER is + -- Load module with `a_name'. + -- `a_name' is LPCTSTR, we should use WEL_STRING here. + require + exists: a_name /= Void + local + l_c_string: EV_GTK_C_STRING + do + l_c_string := a_name + Result := {EV_GTK_EXTERNALS}.g_module_open (l_c_string.item, 0) + end + + loal_api (a_module: POINTER; a_name: STRING): POINTER is + -- Load api which name is `a_name' in `a_module' + require + exists: a_module /= default_pointer + exists: a_name /= Void + local + l_c_string: EV_GTK_C_STRING + l_success: BOOLEAN + l_result: POINTER + do + if a_module /= default_pointer then + l_c_string := a_name + l_success := {EV_GTK_EXTERNALS}.g_module_symbol (a_module, l_c_string.item, $l_result) + if l_success then + Result := l_result + end + end + end + +indexing + copyright: "Copyright (c) 1984-2007, Eiffel Software" + license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" + licensing_options: "http://www.eiffel.com/licensing" + copying: "[ + This file is part of Eiffel Software's Eiffel Development Environment. + + Eiffel Software's Eiffel Development Environment is free + software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published + by the Free Software Foundation, version 2 of the License + (available at the URL listed under "license" above). + + Eiffel Software's Eiffel Development Environment is + distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with Eiffel Software's Eiffel Development + Environment; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + ]" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/implementation/mswin/api_loader_imp.e b/implementation/mswin/api_loader_imp.e new file mode 100644 index 00000000..d53934a8 --- /dev/null +++ b/implementation/mswin/api_loader_imp.e @@ -0,0 +1,96 @@ +indexing + description: "[ + Interactive with native system APIs for dynamic loading. + Windows verson. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + API_LOADER_IMP + +feature -- Command + + load_module (a_name: STRING): POINTER is + -- Load module with `a_name'. + -- `a_name' is LPCTSTR, we should use WEL_STRING here. + require + exists: a_name /= Void + local + l_wel_string: WEL_STRING + do + create l_wel_string.make (a_name) + Result := c_load_module (l_wel_string.item) + end + + loal_api (a_module: POINTER; a_name: STRING): POINTER is + -- Load api which name is `a_name' in `a_module' + require + exists: a_module /= default_pointer + exists: a_name /= Void + local + l_c_string: C_STRING + do + create l_c_string.make (a_name) + Result := c_loal_api (a_module, l_c_string.item) + end + +feature {NONE} -- Implementation + + c_load_module (a_name: POINTER): POINTER is + -- Load module with `a_name'. + -- `a_name' is LPCTSTR, we should use WEL_STRING here. + require + exists: a_name /= default_pointer + external + "C inline use " + alias + "return (EIF_POINTER) LoadLibrary ($a_name);" + end + + c_loal_api (a_module: POINTER; a_name: POINTER): POINTER is + -- Load api which name is `a_name' in `a_module' + require + exists: a_module /= default_pointer + exists: a_name /= default_pointer + external + "C inline use " + alias + "return GetProcAddress ((HMODULE) $a_module, $a_name);" + end + +indexing + copyright: "Copyright (c) 1984-2007, Eiffel Software" + license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" + licensing_options: "http://www.eiffel.com/licensing" + copying: "[ + This file is part of Eiffel Software's Eiffel Development Environment. + + Eiffel Software's Eiffel Development Environment is free + software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published + by the Free Software Foundation, version 2 of the License + (available at the URL listed under "license" above). + + Eiffel Software's Eiffel Development Environment is + distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with Eiffel Software's Eiffel Development + Environment; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + ]" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end From 5506ab09dc0992c2bc2e4123b03b7ff26d1b4cd7 Mon Sep 17 00:00:00 2001 From: manus Date: Mon, 29 Dec 2008 20:27:11 +0000 Subject: [PATCH 29/64] Removal of `is' keyword. Replacement of `is' by `=' for constant definitions. Replaced `indexing' by `note'. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76420 8089f293-4706-0410-a29e-feb5c42a2edf --- api_loader.e | 16 +-- cURL.ecf | 2 +- curl_codes.e | 166 +++++++++++++------------- curl_default_function.e | 14 +-- curl_easy_externals.e | 48 ++++---- curl_externals.e | 32 ++--- curl_form.e | 14 +-- curl_form_constants.e | 14 +-- curl_function.e | 30 ++--- curl_global_constants.e | 14 +-- curl_info_type.e | 20 ++-- curl_opt_constants.e | 46 +++---- curl_string.e | 4 +- curl_utility.e | 6 +- implementation/gtk/api_loader_imp.e | 8 +- implementation/mswin/api_loader_imp.e | 12 +- 16 files changed, 223 insertions(+), 223 deletions(-) diff --git a/api_loader.e b/api_loader.e index 310f2e85..eb9dd0bf 100644 --- a/api_loader.e +++ b/api_loader.e @@ -1,4 +1,4 @@ -indexing +note description: "[ Dynamic load a external API which exists in a dll or so. Benefit is we can still use our executables even without the dll/so files. @@ -13,7 +13,7 @@ class feature -- Query - safe_load_api (a_module_name: STRING; a_api_name: STRING): POINTER is + safe_load_api (a_module_name: STRING; a_api_name: STRING): POINTER -- Safe loading `a_api_name' in `a_module_name' if possible. -- `a_module_name' is case sensitive. require @@ -28,7 +28,7 @@ feature -- Query end end - module_pointer (a_name: STRING): POINTER is + module_pointer (a_name: STRING): POINTER -- Find module hanle with `a_name' -- Result is void if not exists require @@ -44,7 +44,7 @@ feature -- Query end end - api_pointer (a_module: POINTER; a_name: STRING): POINTER is + api_pointer (a_module: POINTER; a_name: STRING): POINTER -- Find API pointer which name is `a_name' in `a_module' -- Result is void if not exists. require @@ -63,24 +63,24 @@ feature -- Query feature {NONE} -- Implementation - loaded_modules: HASH_TABLE [POINTER, STRING] is + loaded_modules: HASH_TABLE [POINTER, STRING] -- Loaded modules once create Result.make (1) end - loaded_apis: HASH_TABLE [POINTER, STRING] is + loaded_apis: HASH_TABLE [POINTER, STRING] -- Loaded apis. once create Result.make (10) end - implementation: API_LOADER_IMP is + implementation: API_LOADER_IMP -- Native loader once create Result end -indexing +note copyright: "Copyright (c) 1984-2007, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" diff --git a/cURL.ecf b/cURL.ecf index c063ebdc..062cd010 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -10,7 +10,7 @@ /EIFGEN.{0,1}$ /temp$ - diff --git a/curl_codes.e b/curl_codes.e index 52c3982c..e3627cbc 100644 --- a/curl_codes.e +++ b/curl_codes.e @@ -1,4 +1,4 @@ -indexing +note description: "[ All possible error codes from all sorts of curl functions. Future versions may return other values, stay prepared. @@ -13,310 +13,310 @@ class feature -- Constants - curle_ok: INTEGER is 0 + curle_ok: INTEGER = 0 -- Declared as CURLE_OK - curle_unsupported_protocol: INTEGER is 1 + curle_unsupported_protocol: INTEGER = 1 -- Declared as CURLE_UNSUPPORTED_PROTOCOL - curle_failed_init: INTEGER is 2 + curle_failed_init: INTEGER = 2 -- Declared as CURLE_FAILED_INIT - curle_url_malformat: INTEGER is 3 + curle_url_malformat: INTEGER = 3 -- Declared as CURLE_URL_MALFORMAT - curle_obsolete4: INTEGER is 4 + curle_obsolete4: INTEGER = 4 -- Declared as CURLE_OBSOLETE4 -- NOT USED - curle_couldnt_resolve_proxy: INTEGER is 5 + curle_couldnt_resolve_proxy: INTEGER = 5 -- Declared as CURLE_COULDNT_RESOLVE_PROXY - curle_couldnt_resolve_host: INTEGER is 6 + curle_couldnt_resolve_host: INTEGER = 6 -- Declared as CURLE_COULDNT_RESOLVE_HOST - curle_couldnt_connect: INTEGER is 7 + curle_couldnt_connect: INTEGER = 7 -- Declared as CURLE_COULDNT_CONNECT - curle_ftp_weird_server_reply: INTEGER is 8 + curle_ftp_weird_server_reply: INTEGER = 8 -- Declared as CURLE_FTP_WEIRD_SERVER_REPLY - curle_remote_access_denied: INTEGER is 9 + curle_remote_access_denied: INTEGER = 9 -- Declared as CURLE_REMOTE_ACCESS_DENIED -- A service was denied by the server due to lack of access -- when login fails this is not returned. - curle_obsolete10: INTEGER is 10 + curle_obsolete10: INTEGER = 10 -- Declared as CURLE_OBSOLETE10 NOT USED - curle_ftp_weird_pass_reply: INTEGER is 11 + curle_ftp_weird_pass_reply: INTEGER = 11 -- Declared as CURLE_FTP_WEIRD_PASS_REPLY - curle_obsolete12: INTEGER is 12 + curle_obsolete12: INTEGER = 12 -- Declared as CURLE_OBSOLETE12 NOT USED - curle_ftp_weird_pasv_reply: INTEGER is 13 + curle_ftp_weird_pasv_reply: INTEGER = 13 -- Declared as CURLE_FTP_WEIRD_PASV_REPLY - curle_ftp_weird_227_format: INTEGER is 14 + curle_ftp_weird_227_format: INTEGER = 14 -- Declared as CURLE_FTP_WEIRD_227_FORMAT - curle_ftp_cant_get_host: INTEGER is 15 + curle_ftp_cant_get_host: INTEGER = 15 -- Declared as CURLE_FTP_CANT_GET_HOST - curle_obsolete16: INTEGER is 16 + curle_obsolete16: INTEGER = 16 -- Declared as CURLE_OBSOLETE16 -- NOT USED - curle_ftp_couldnt_set_type: INTEGER is 17 + curle_ftp_couldnt_set_type: INTEGER = 17 -- Declared as CURLE_FTP_COULDNT_SET_TYPE - curle_partial_file: INTEGER is 18 + curle_partial_file: INTEGER = 18 -- Declared as CURLE_PARTIAL_FILE - curle_ftp_couldnt_retr_file: INTEGER is 19 + curle_ftp_couldnt_retr_file: INTEGER = 19 -- Declared as CURLE_FTP_COULDNT_RETR_FILE - curle_obsolete20: INTEGER is 20 + curle_obsolete20: INTEGER = 20 -- Declared as CURLE_OBSOLETE20 -- NOT USED - curle_quote_error: INTEGER is 21 + curle_quote_error: INTEGER = 21 -- Declared as CURLE_QUOTE_ERROR -- quote command failure - curle_http_returned_error: INTEGER is 22 + curle_http_returned_error: INTEGER = 22 -- Declared as CURLE_HTTP_RETURNED_ERROR - curle_write_error: INTEGER is 23 + curle_write_error: INTEGER = 23 -- Declared as CURLE_WRITE_ERROR - curle_obsolete24: INTEGER is 24 + curle_obsolete24: INTEGER = 24 -- Declared as CURLE_OBSOLETE24 NOT USED - curle_upload_failed: INTEGER is 25 + curle_upload_failed: INTEGER = 25 -- Declared as CURLE_UPLOAD_FAILED -- failed upload "command" - curle_read_error: INTEGER is 26 + curle_read_error: INTEGER = 26 -- Declared as CURLE_READ_ERROR -- couldn't open/read from file - curle_out_of_memory: INTEGER is 27 + curle_out_of_memory: INTEGER = 27 -- Declared as CURLE_OUT_OF_MEMORY -- Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error -- instead of a memory allocation error if CURL_DOES_CONVERSIONS -- is defined - curle_operation_timedout: INTEGER is 28 + curle_operation_timedout: INTEGER = 28 -- Declared as CURLE_OPERATION_TIMEDOUT -- the timeout time was reached - curle_obsolete29: INTEGER is 29 + curle_obsolete29: INTEGER = 29 -- Declared as CURLE_OBSOLETE29 -- NOT USED - curle_ftp_port_failed: INTEGER is 30 + curle_ftp_port_failed: INTEGER = 30 -- Declared as CURLE_FTP_PORT_FAILED -- FTP PORT operation failed - curle_ftp_couldnt_use_rest: INTEGER is 31 + curle_ftp_couldnt_use_rest: INTEGER = 31 -- Declared as CURLE_FTP_COULDNT_USE_REST -- the REST command failed - curle_obsolete32: INTEGER is 32 + curle_obsolete32: INTEGER = 32 -- Declared as CURLE_OBSOLETE32 -- NOT USED - curle_range_error: INTEGER is 33 + curle_range_error: INTEGER = 33 -- Declared as CURLE_RANGE_ERROR -- RANGE "command" didn't work - curle_http_post_error: INTEGER is 34 + curle_http_post_error: INTEGER = 34 -- Declared as CURLE_HTTP_POST_ERROR - curle_ssl_connect_error: INTEGER is 35 + curle_ssl_connect_error: INTEGER = 35 -- Declared CURLE_SSL_CONNECT_ERROR -- wrong when connecting with SSL - curle_bad_download_resume: INTEGER is 36 + curle_bad_download_resume: INTEGER = 36 -- Declared as CURLE_BAD_DOWNLOAD_RESUME -- couldn't resume download - curle_file_couldnt_read_file: INTEGER is 37 + curle_file_couldnt_read_file: INTEGER = 37 -- Declared as CURLE_FILE_COULDNT_READ_FILE - curle_ldap_cannot_bind: INTEGER is 38 + curle_ldap_cannot_bind: INTEGER = 38 -- Declared as CURLE_LDAP_CANNOT_BIND - curle_ldap_search_failed: INTEGER is 39 + curle_ldap_search_failed: INTEGER = 39 -- Declared as CURLE_LDAP_SEARCH_FAILED - curle_obsolete40: INTEGER is 40 + curle_obsolete40: INTEGER = 40 -- Declared as CURLE_OBSOLETE40 -- NOT USED - curle_function_not_found: INTEGER is 41 + curle_function_not_found: INTEGER = 41 -- Declared as CURLE_FUNCTION_NOT_FOUND - curle_aborted_by_callback: INTEGER is 42 + curle_aborted_by_callback: INTEGER = 42 -- Declared as CURLE_ABORTED_BY_CALLBACK - curle_bad_function_argument: INTEGER is 43 + curle_bad_function_argument: INTEGER = 43 -- Declared as CURLE_BAD_FUNCTION_ARGUMENT - curle_obsolete44: INTEGER is 44 + curle_obsolete44: INTEGER = 44 -- Declared as CURLE_OBSOLETE44 -- NOT USED - curle_interface_failed: INTEGER is 45 + curle_interface_failed: INTEGER = 45 -- Declared as CURLE_INTERFACE_FAILED -- CURLOPT_INTERFACE failed - curle_obsolete46: INTEGER is 46 + curle_obsolete46: INTEGER = 46 -- Declared as CURLE_OBSOLETE46 -- NOT USED - curle_too_many_redirects: INTEGER is 47 + curle_too_many_redirects: INTEGER = 47 -- Declared as CURLE_TOO_MANY_REDIRECTS -- catch endless re-direct loops - curle_unknown_telnet_option: INTEGER is 48 + curle_unknown_telnet_option: INTEGER = 48 -- Declared as CURLE_UNKNOWN_TELNET_OPTION -- User specified an unknown option - curle_telnet_option_syntax: INTEGER is 49 + curle_telnet_option_syntax: INTEGER = 49 -- Declared as CURLE_TELNET_OPTION_SYNTAX -- Malformed telnet option - curle_obsolete50: INTEGER is 50 + curle_obsolete50: INTEGER = 50 -- Declared as CURLE_OBSOLETE50 -- NOT USED - curle_ssl_peer_certificate: INTEGER is 51 + curle_ssl_peer_certificate: INTEGER = 51 -- Declared as CURLE_SSL_PEER_CERTIFICATE -- peer's certificate wasn't ok - curle_got_nothing: INTEGER is 52 + curle_got_nothing: INTEGER = 52 -- Declared as CURLE_GOT_NOTHING -- when this is a specific error - curle_ssl_engine_notfound: INTEGER is 53 + curle_ssl_engine_notfound: INTEGER = 53 -- Declared as CURLE_SSL_ENGINE_NOTFOUND -- SSL crypto engine not found */ - curle_ssl_engine_setfailed: INTEGER is 54 + curle_ssl_engine_setfailed: INTEGER = 54 -- Declared as CURLE_SSL_ENGINE_SETFAILED -- can not set SSL crypto engine as default - curle_send_error: INTEGER is 55 + curle_send_error: INTEGER = 55 -- Declared as CURLE_SEND_ERROR -- failed sending network data - curle_recv_error: INTEGER is 56 + curle_recv_error: INTEGER = 56 -- Declared as CURLE_RECV_ERROR -- failure in receiving network data - curle_obsolete57: INTEGER is 57 + curle_obsolete57: INTEGER = 57 -- Declared as CURLE_OBSOLETE57 -- NOT IN USE - curle_ssl_certproblem: INTEGER is 58 + curle_ssl_certproblem: INTEGER = 58 -- Declared as CURLE_SSL_CERTPROBLEM -- problem with the local certificate - curle_ssl_cipher: INTEGER is 59 + curle_ssl_cipher: INTEGER = 59 -- Declared as CURLE_SSL_CIPHER -- couldn't use specified cipher - curle_ssl_cacert: INTEGER is 60 + curle_ssl_cacert: INTEGER = 60 -- Declared as CURLE_SSL_CACERT -- problem with the CA cert (path?) - curle_bad_content_encoding: INTEGER is 61 + curle_bad_content_encoding: INTEGER = 61 -- Declared as CURLE_BAD_CONTENT_ENCODING -- Unrecognized transfer encoding - curle_ldap_invalid_url: INTEGER is 62 + curle_ldap_invalid_url: INTEGER = 62 -- Declared as CURLE_LDAP_INVALID_URL -- Invalid LDAP URL - curle_filesize_exceeded: INTEGER is 63 + curle_filesize_exceeded: INTEGER = 63 -- Declared as CURLE_FILESIZE_EXCEEDED -- Maximum file size exceeded - curle_use_ssl_failed: INTEGER is 64 + curle_use_ssl_failed: INTEGER = 64 -- Declared as CURLE_USE_SSL_FAILED -- Requested FTP SSL level failed - curle_send_fail_rewind: INTEGER is 65 + curle_send_fail_rewind: INTEGER = 65 -- Declared as CURLE_SEND_FAIL_REWIND -- Sending the data requires a rewind that failed - curle_ssl_engine_initfailed: INTEGER is 66 + curle_ssl_engine_initfailed: INTEGER = 66 -- Declared as CURLE_SSL_ENGINE_INITFAILED -- failed to initialise ENGINE - curle_login_denied: INTEGER is 67 + curle_login_denied: INTEGER = 67 -- Declared as CURLE_LOGIN_DENIED -- user, password or similar was not accepted and we failed to login - curle_tftp_notfound: INTEGER is 68 + curle_tftp_notfound: INTEGER = 68 -- Declared as CURLE_TFTP_NOTFOUND -- file not found on server - curle_tftp_perm: INTEGER is 69 + curle_tftp_perm: INTEGER = 69 -- Declared as CURLE_TFTP_PERM -- permission problem on server - curle_remote_disk_full: INTEGER is 70 + curle_remote_disk_full: INTEGER = 70 -- Declared as CURLE_REMOTE_DISK_FULL -- out of disk space on server - curle_tftp_illegal: INTEGER is 71 + curle_tftp_illegal: INTEGER = 71 -- Declared as CURLE_TFTP_ILLEGAL -- Illegal TFTP operation - curle_tftp_unknownid: INTEGER is 72 + curle_tftp_unknownid: INTEGER = 72 -- Declared as CURLE_TFTP_UNKNOWNID -- Unknown transfer ID - curle_remote_file_exists: INTEGER is 73 + curle_remote_file_exists: INTEGER = 73 -- Declared as CURLE_REMOTE_FILE_EXISTS -- File already exists - curle_tftp_nosuchuser: INTEGER is 74 + curle_tftp_nosuchuser: INTEGER = 74 -- Declared as CURLE_TFTP_NOSUCHUSER -- No such user - curle_conv_failed: INTEGER is 75 + curle_conv_failed: INTEGER = 75 -- Declared as CURLE_CONV_FAILED -- conversion failed - curle_conv_reqd: INTEGER is 76 + curle_conv_reqd: INTEGER = 76 -- Declared as CURLE_CONV_REQD -- caller must register conversion callbacks using curl_easy_setopt options -- CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPT_CONV_TO_NETWORK_FUNCTION, and -- CURLOPT_CONV_FROM_UTF8_FUNCTION - curle_ssl_cacert_badfile: INTEGER is 77 + curle_ssl_cacert_badfile: INTEGER = 77 -- Declared as CURLE_SSL_CACERT_BADFILE -- could not load CACERT file, missing or wrong format - curle_remote_file_not_found: INTEGER is 78 + curle_remote_file_not_found: INTEGER = 78 -- Declared as CURLE_REMOTE_FILE_NOT_FOUND -- remote file not found - curle_ssh: INTEGER is 79 + curle_ssh: INTEGER = 79 -- Declared as CURLE_SSH -- error from the SSH layer, somewhat generic so the error message will be of -- interest when this has happened - curle_ssl_shutdown_failed: INTEGER is 80; + curle_ssl_shutdown_failed: INTEGER = 80; -- Declared as CURLE_SSL_SHUTDOWN_FAILED -- Failed to shut down the SSL connection -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_default_function.e b/curl_default_function.e index f6248443..5b755885 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -1,4 +1,4 @@ -indexing +note description: "[ Default implementation of CURL_FUNCTION. ]" @@ -18,7 +18,7 @@ create feature {NONE} -- Initialization - make is + make -- Creation method do set_object_and_function_address @@ -26,12 +26,12 @@ feature {NONE} -- Initialization feature -- Command - progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER is + progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER -- Redefine do end - write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER is + write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER -- Redefine local l_c_string: C_STRING @@ -47,7 +47,7 @@ feature -- Command l_string.append (l_c_string.string) end - debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER is + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER -- Redefine local l_c_string: C_STRING @@ -76,7 +76,7 @@ feature -- Command feature {NONE} -- Implementation - dump (a_text: STRING; a_char_pointer: POINTER; a_size: INTEGER) is + dump (a_text: STRING; a_char_pointer: POINTER; a_size: INTEGER) -- Dump debug information require not_void: a_text /= Void @@ -89,7 +89,7 @@ feature {NONE} -- Implementation print ("%N" + a_text + "%N" + l_c_string.string) end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_easy_externals.e b/curl_easy_externals.e index e48efd09..cfe97b38 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL easy externals. For more informaton see: @@ -14,7 +14,7 @@ class feature -- Command - init: POINTER is + init: POINTER -- Declared as curl_easy_init(). require dynamic_library_exists: is_dynamic_library_exists @@ -29,7 +29,7 @@ feature -- Command exists: Result /= default_pointer end - setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_string: STRING_GENERAL) is + setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_string: STRING_GENERAL) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -46,7 +46,7 @@ feature -- Command end end - setopt_form (a_curl_handle: POINTER; a_opt: INTEGER; a_form: CURL_FORM) is + setopt_form (a_curl_handle: POINTER; a_opt: INTEGER; a_form: CURL_FORM) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -56,7 +56,7 @@ feature -- Command setopt_void_star (a_curl_handle, a_opt, a_form.item) end - setopt_slist (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_slist: POINTER) is + setopt_slist (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_slist: POINTER) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -66,7 +66,7 @@ feature -- Command setopt_void_star (a_curl_handle, a_opt, a_curl_slist) end - setopt_curl_string (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_string: CURL_STRING) is + setopt_curl_string (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_string: CURL_STRING) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -81,7 +81,7 @@ feature -- Command end end - setopt_integer (a_curl_handle: POINTER; a_opt: INTEGER; a_integer: INTEGER) is + setopt_integer (a_curl_handle: POINTER; a_opt: INTEGER; a_integer: INTEGER) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -95,7 +95,7 @@ feature -- Command end end - perform (a_curl_handle: POINTER): INTEGER is + perform (a_curl_handle: POINTER): INTEGER -- Declared as curl_easy_perform(). -- Result is one value from {CURL_CODES} require @@ -111,7 +111,7 @@ feature -- Command valid: end - cleanup (a_curl_handle: POINTER) is + cleanup (a_curl_handle: POINTER) -- Declared as curl_easy_cleanup(). require exists: a_curl_handle /= default_pointer @@ -126,7 +126,7 @@ feature -- Command feature -- Query - is_dynamic_library_exists: BOOLEAN is + is_dynamic_library_exists: BOOLEAN -- If dll/so files exist? do Result := (api_loader.module_pointer (module_name) /= default_pointer) @@ -134,7 +134,7 @@ feature -- Query feature -- Special setting - set_curl_function (a_curl_function: CURL_FUNCTION) is + set_curl_function (a_curl_function: CURL_FUNCTION) -- Set `curl_function' with `a_curl_function' do internal_curl_function := a_curl_function @@ -142,7 +142,7 @@ feature -- Special setting set: a_curl_function /= Void implies curl_function = a_curl_function end - curl_function: CURL_FUNCTION is + curl_function: CURL_FUNCTION -- cURL functions in curl_easy_setopt. do Result := internal_curl_function @@ -154,7 +154,7 @@ feature -- Special setting not_void: Result /= Void end - set_write_function (a_curl_handle: POINTER) is + set_write_function (a_curl_handle: POINTER) -- Set cURL write function -- Set cURL write function with Eiffel default write function. -- So we can use CURL_STRING as parameter in {CURL_EASY_EXTERNALS}.setopt_curl_string when the option is {CURL_OPT_CONSTANTS}.curlopt_writedata @@ -169,7 +169,7 @@ feature -- Special setting end end - set_progress_function (a_curl_handle: POINTER) is + set_progress_function (a_curl_handle: POINTER) -- Set cURL progress function for upload/download progress. require exists: a_curl_handle /= default_pointer @@ -182,7 +182,7 @@ feature -- Special setting end end - set_debug_function (a_curl_handle: POINTER) is + set_debug_function (a_curl_handle: POINTER) -- Set cURL debug function require exists: a_curl_handle /= default_pointer @@ -200,7 +200,7 @@ feature {NONE} -- Implementation internal_curl_function: CURL_FUNCTION -- cURL functions. - api_loader: API_LOADER is + api_loader: API_LOADER -- API dynamic loader once create Result @@ -208,7 +208,7 @@ feature {NONE} -- Implementation not_void: Result /= Void end - module_name: STRING is + module_name: STRING -- Module name. local l_utility: CURL_UTILITY @@ -217,7 +217,7 @@ feature {NONE} -- Implementation Result := l_utility.module_name end - setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) is + setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -233,7 +233,7 @@ feature {NONE} -- Implementation feature {NONE} -- C externals - c_init (a_api: POINTER): POINTER is + c_init (a_api: POINTER): POINTER -- Declared curl_easy_init (). require exists: a_api /= default_pointer @@ -245,7 +245,7 @@ feature {NONE} -- C externals ]" end - c_cleanup (a_api: POINTER; a_curl_handle: POINTER) is + c_cleanup (a_api: POINTER; a_curl_handle: POINTER) -- Decalred as curl_easy_cleanup (). require exists: a_api /= default_pointer @@ -258,7 +258,7 @@ feature {NONE} -- C externals ]" end - c_perform (a_api: POINTER; a_curl_handle: POINTER): INTEGER is + c_perform (a_api: POINTER; a_curl_handle: POINTER): INTEGER -- Declared as curl_easy_perform(). require exists: a_api /= default_pointer @@ -272,7 +272,7 @@ feature {NONE} -- C externals ]" end - c_setopt_int (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: INTEGER) is + c_setopt_int (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: INTEGER) -- Same as `c_setopt' except we can pass `a_data' as integer. require exists: a_api /= default_pointer @@ -291,7 +291,7 @@ feature {NONE} -- C externals ]" end - c_setopt (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: POINTER) is + c_setopt (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: POINTER) -- C implementation of `setopt_void_star'. -- Declared as curl_easy_setopt (). require @@ -311,7 +311,7 @@ feature {NONE} -- C externals ]" end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_externals.e b/curl_externals.e index 36637d3d..2dd05cef 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL externals. For more information, see: @@ -14,7 +14,7 @@ class feature -- Command - global_init is + global_init -- Declared as curl_global_init(). require dynamic_library_exists: is_dynamic_library_exists @@ -27,7 +27,7 @@ feature -- Command end end - global_cleanup is + global_cleanup -- Declared as curl_global_cleanup(). local l_ptr: POINTER @@ -38,7 +38,7 @@ feature -- Command end end - formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is + formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) -- Declared as curl_formadd (). require not_void: a_form /= Void @@ -65,7 +65,7 @@ feature -- Command end end - slist_append (a_list: POINTER; a_string: STRING_GENERAL): POINTER is + slist_append (a_list: POINTER; a_string: STRING_GENERAL): POINTER -- Declared as curl_slist_append (). require exists: a_list /= default_pointer @@ -83,7 +83,7 @@ feature -- Command feature -- Query - is_dynamic_library_exists: BOOLEAN is + is_dynamic_library_exists: BOOLEAN -- If dll/so files exist? do Result := (api_loader.module_pointer (module_name) /= default_pointer) @@ -91,7 +91,7 @@ feature -- Query feature {CURL_FORM} -- Internal command - formfree (a_curl_form: POINTER) is + formfree (a_curl_form: POINTER) -- Declared as curl_formfree (). -- See: http://curl.askapache.com/libcurl/c/curl_formfree.html -- curl_formfree() is used to clean up data previously built/appended with curl_formadd(3). @@ -109,7 +109,7 @@ feature {CURL_FORM} -- Internal command feature {NONE} -- Implementation - api_loader: API_LOADER is + api_loader: API_LOADER -- API dynamic loader once create Result @@ -117,7 +117,7 @@ feature {NONE} -- Implementation not_void: Result /= Void end - module_name: STRING is + module_name: STRING -- Module name. local l_utility: CURL_UTILITY @@ -126,7 +126,7 @@ feature {NONE} -- Implementation Result := l_utility.module_name end - internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) is + internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) -- Declared as curl_formadd (). local l_c_string_1, l_c_string_2: C_STRING @@ -142,7 +142,7 @@ feature {NONE} -- Implementation feature {NONE} -- C externals - c_formadd_string_string (a_api: POINTER; a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: POINTER; a_arg_2: INTEGER; a_arg_2_value: POINTER; a_arg_3: INTEGER) is + c_formadd_string_string (a_api: POINTER; a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: POINTER; a_arg_2: INTEGER; a_arg_2_value: POINTER; a_arg_3: INTEGER) -- C implementation of formadd_string_string (). require exists: a_api /= default_pointer @@ -163,7 +163,7 @@ feature {NONE} -- C externals ]" end - c_formfree (a_api: POINTER; a_curl_form: POINTER) is + c_formfree (a_api: POINTER; a_curl_form: POINTER) -- Declared as curl_formfree (). require exists: a_api /= default_pointer @@ -177,7 +177,7 @@ feature {NONE} -- C externals ]" end - c_curl_global_init (a_api: POINTER; a_opt: NATURAL_64) is + c_curl_global_init (a_api: POINTER; a_opt: NATURAL_64) -- `a_api' point to API curl_global_init () -- `a_opt' is intialization option. require @@ -190,7 +190,7 @@ feature {NONE} -- C externals ]" end - c_curl_global_cleanup (a_api: POINTER) is + c_curl_global_cleanup (a_api: POINTER) -- `a_api' point to API curl_global_cleanup() require exists: a_api /= default_pointer @@ -202,7 +202,7 @@ feature {NONE} -- C externals ]" end - c_slist_append (a_api: POINTER; a_list_pointer: POINTER; a_string: POINTER): POINTER is + c_slist_append (a_api: POINTER; a_list_pointer: POINTER; a_string: POINTER): POINTER -- Declared as curl_slist_append (). require exists: a_api /= default_pointer @@ -218,7 +218,7 @@ feature {NONE} -- C externals ]" end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_form.e b/curl_form.e index 6d26c2e6..05ff7f69 100644 --- a/curl_form.e +++ b/curl_form.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL form. For more informaton see: @@ -21,12 +21,12 @@ create feature {NONE} -- Initialization - make is + make -- Creation method. do end - share_with_pointer (a_pointer: POINTER) is + share_with_pointer (a_pointer: POINTER) -- Creation method. -- `item' share with `a_pointer'. require @@ -50,7 +50,7 @@ feature -- Query feature -- Command - dispose is + dispose -- Free memory if possible. local l_curl: CURL_EXTERNALS @@ -62,7 +62,7 @@ feature -- Command end end - release_item is + release_item -- Release item -- NOT free memory! This is useful if Current generated by {CURL_EXTERNALS}.formadd_string_string. do @@ -71,7 +71,7 @@ feature -- Command feature {CURL_EXTERNALS} -- Internal command - set_item (a_item: POINTER) is + set_item (a_item: POINTER) -- Set `item' with `a_item' do item := a_item @@ -79,7 +79,7 @@ feature {CURL_EXTERNALS} -- Internal command set: item = a_item end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_form_constants.e b/curl_form_constants.e index 414d99b0..260d5761 100644 --- a/curl_form_constants.e +++ b/curl_form_constants.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL form constants. For more informaton see: @@ -14,7 +14,7 @@ class feature -- Query - curlform_copyname: INTEGER is + curlform_copyname: INTEGER -- Declared as CURLFORM_COPYNAME external "C inline use " @@ -24,7 +24,7 @@ feature -- Query ]" end - curlform_copycontents: INTEGER is + curlform_copycontents: INTEGER -- Declared as CURLFORM_COPYCONTENTS external "C inline use " @@ -34,7 +34,7 @@ feature -- Query ]" end - curlform_end: INTEGER is + curlform_end: INTEGER -- Declared as CURLFORM_END external "C inline use " @@ -44,7 +44,7 @@ feature -- Query ]" end - curlform_file: INTEGER is + curlform_file: INTEGER -- Declared as CURLFORM_FILE external "C inline use " @@ -54,7 +54,7 @@ feature -- Query ]" end - is_valid (a_integer: INTEGER): BOOLEAN is + is_valid (a_integer: INTEGER): BOOLEAN -- If `a_integer' valid? do Result := a_integer = curlform_copycontents or @@ -63,7 +63,7 @@ feature -- Query a_integer = curlform_file end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_function.e b/curl_function.e index 80f21b84..28f2e78a 100644 --- a/curl_function.e +++ b/curl_function.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL curl_easy_setopt callback functions' Eiffel wrappers. We need this class since cURL need a c function pointer as value but @@ -18,7 +18,7 @@ inherit feature -- Interactive with C - set_object_and_function_address is + set_object_and_function_address -- Set object and function addresses. -- Call this feature before call `c_set_progress_function', `c_set_debug_function' and `c_set_write_function'. do @@ -28,7 +28,7 @@ feature -- Interactive with C c_set_debug_function_address ($debug_function) end - c_set_progress_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + c_set_progress_function (a_setopt_api: POINTER; a_curl_handle: POINTER) -- Setting CURLOPT_PROGRESSFUNCTION option of `a_curl_handle'. -- We need this function since cURL need a c function pointer as value. require @@ -46,7 +46,7 @@ feature -- Interactive with C ]" end - c_set_debug_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + c_set_debug_function (a_setopt_api: POINTER; a_curl_handle: POINTER) -- Setting CURLOPT_DEBUGFUNCTION option of `a_curl_handle'. -- We need this function since cURL need a c function pointer as value. require @@ -65,7 +65,7 @@ feature -- Interactive with C ]" end - c_set_write_function (a_setopt_api: POINTER; a_curl_handle: POINTER) is + c_set_write_function (a_setopt_api: POINTER; a_curl_handle: POINTER) -- Setting CURLOPT_WRITEFUNCTION option of `a_curl_handle'. -- We need this function since cURL need a c function pointer as value. require @@ -85,21 +85,21 @@ feature -- Interactive with C feature -- cURL curl_easy_setopt functions - progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER is + progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_progressfunction -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which -- may changed during GC. deferred end - write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER is + write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_writefunction -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which -- may changed during GC. deferred end - debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER is + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_debugfunction -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which -- may changed during GC. @@ -110,31 +110,31 @@ feature -- cURL curl_easy_setopt functions feature {NONE} -- Externals - c_set_object (a_object: POINTER) is + c_set_object (a_object: POINTER) -- Set Current object address. external "C signature (EIF_REFERENCE) use %"eiffel_curl.h%"" end - c_release_object is + c_release_object -- Release Current pointer in C external "C use %"eiffel_curl.h%"" end - c_set_progress_function_address (a_address: POINTER) is + c_set_progress_function_address (a_address: POINTER) -- Set progress function address. external "C use %"eiffel_curl.h%"" end - c_set_write_function_address (a_address: POINTER) is + c_set_write_function_address (a_address: POINTER) -- Set write function address. external "C use %"eiffel_curl.h%"" end - c_set_debug_function_address (a_address: POINTER) is + c_set_debug_function_address (a_address: POINTER) -- Set write function address. external "C use %"eiffel_curl.h%"" @@ -142,14 +142,14 @@ feature {NONE} -- Externals feature {NONE} -- Implementation - dispose is + dispose -- Wean `Current' do c_release_object c_set_object (default_pointer) end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_global_constants.e b/curl_global_constants.e index da466828..90d4c29a 100644 --- a/curl_global_constants.e +++ b/curl_global_constants.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL library constants used by curl_global_init () ]" @@ -12,7 +12,7 @@ class feature -- Query - curl_global_ssl: NATURAL_64 is + curl_global_ssl: NATURAL_64 -- Delcared as CURL_GLOBAL_SSL external "C inline use " @@ -22,7 +22,7 @@ feature -- Query ]" end - curl_global_win32: NATURAL_64 is + curl_global_win32: NATURAL_64 -- Delcared as CURL_GLOBAL_WIN32 external "C inline use " @@ -32,7 +32,7 @@ feature -- Query ]" end - curl_global_all: NATURAL_64 is + curl_global_all: NATURAL_64 -- Delcared as CURL_GLOBAL_ALL external "C inline use " @@ -42,7 +42,7 @@ feature -- Query ]" end - curl_global_nothing: NATURAL_64 is + curl_global_nothing: NATURAL_64 -- Delcared as CURL_GLOBAL_NOTHING external "C inline use " @@ -52,7 +52,7 @@ feature -- Query ]" end - curl_global_default: NATURAL_64 is + curl_global_default: NATURAL_64 -- Delcared as CURL_GLOBAL_DEFAULT external "C inline use " @@ -62,7 +62,7 @@ feature -- Query ]" end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_info_type.e b/curl_info_type.e index 5300bc29..a3c9cb39 100644 --- a/curl_info_type.e +++ b/curl_info_type.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL library info type constants. ]" @@ -12,30 +12,30 @@ class feature -- Enumeration - curlinfo_text: INTEGER is 0 + curlinfo_text: INTEGER = 0 -- Declared as CURLINFO_TEXT - curlinfo_header_in: INTEGER is 1 + curlinfo_header_in: INTEGER = 1 -- Declared as CURLINFO_HEADER_IN - curlinfo_header_out: INTEGER is 2 + curlinfo_header_out: INTEGER = 2 -- Declared as CURLINFO_HEADER_OUT - curlinfo_data_in: INTEGER is 3 + curlinfo_data_in: INTEGER = 3 -- Declared as CURLINFO_DATA_IN - curlinfo_data_out: INTEGER is 4 + curlinfo_data_out: INTEGER = 4 -- Declared as CURLINFO_DATA_OUT - curlinfo_ssl_data_in: INTEGER is 5 + curlinfo_ssl_data_in: INTEGER = 5 -- Declared as CURLINFO_SSL_DATA_IN - curlinfo_ssl_data_out: INTEGER is 6 + curlinfo_ssl_data_out: INTEGER = 6 -- Declared as CURLINFO_SSL_DATA_OUT feature -- Contract support - is_valid (a_type: INTEGER): BOOLEAN is + is_valid (a_type: INTEGER): BOOLEAN -- If `a_type' valid? do Result := a_type = curlinfo_data_in or @@ -47,7 +47,7 @@ feature -- Contract support a_type = curlinfo_text end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 9958c24a..b2a611ea 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -1,4 +1,4 @@ -indexing +note description: "[ libcurl library opt constants For more informaton see: @@ -14,7 +14,7 @@ class feature -- Enumerations. - curlopt_httpheader: INTEGER is + curlopt_httpheader: INTEGER -- Declared as CURLOPT_HTTPHEADER. external "C inline use " @@ -24,7 +24,7 @@ feature -- Enumerations. ]" end - curlopt_writedata: INTEGER is + curlopt_writedata: INTEGER -- Declared as CURLOPT_WRITEDATA. external "C inline use " @@ -34,7 +34,7 @@ feature -- Enumerations. ]" end - curlopt_writeheader: INTEGER is + curlopt_writeheader: INTEGER -- Declared as CURLOPT_WRITEHEADER. external "C inline use " @@ -44,7 +44,7 @@ feature -- Enumerations. ]" end - curlopt_debugfunction: INTEGER is + curlopt_debugfunction: INTEGER -- Declared as CURLOPT_DEBUGFUNCTION. external "C inline use " @@ -54,7 +54,7 @@ feature -- Enumerations. ]" end - curlopt_followlocation: INTEGER is + curlopt_followlocation: INTEGER -- Declared as CURLOPT_FOLLOWLOCATION external "C inline use " @@ -64,7 +64,7 @@ feature -- Enumerations. ]" end - curlopt_verbose: INTEGER is + curlopt_verbose: INTEGER -- Declared as CURLOPT_VERBOSE. external "C inline use " @@ -74,7 +74,7 @@ feature -- Enumerations. ]" end - curlopt_useragent: INTEGER is + curlopt_useragent: INTEGER -- Declared as CURLOPT_USERAGENT. external "C inline use " @@ -84,7 +84,7 @@ feature -- Enumerations. ]" end - curlopt_url: INTEGER is + curlopt_url: INTEGER -- Declared as CURLOPT_URL. external "C inline use " @@ -94,7 +94,7 @@ feature -- Enumerations. ]" end - curlopt_cookiefile: INTEGER is + curlopt_cookiefile: INTEGER -- Declared as CURLOPT_COOKIEFILE. external "C inline use " @@ -104,7 +104,7 @@ feature -- Enumerations. ]" end - curlopt_ssl_verifypeer: INTEGER is + curlopt_ssl_verifypeer: INTEGER -- Declared as CURLOPT_SSL_VERIFYPEER. external "C inline use " @@ -114,7 +114,7 @@ feature -- Enumerations. ]" end - curlopt_cookie: INTEGER is + curlopt_cookie: INTEGER -- Declared as CURLOPT_COOKIE. external "C inline use " @@ -124,7 +124,7 @@ feature -- Enumerations. ]" end - curlopt_post: INTEGER is + curlopt_post: INTEGER -- Declared as CURLOPT_POST. external "C inline use " @@ -134,7 +134,7 @@ feature -- Enumerations. ]" end - curlopt_postfields: INTEGER is + curlopt_postfields: INTEGER -- Declared as CURLOPT_POSTFIELDS. external "C inline use " @@ -144,7 +144,7 @@ feature -- Enumerations. ]" end - curlopt_httppost: INTEGER is + curlopt_httppost: INTEGER -- Declared as CURLOPT_HTTPPOST. external "C inline use " @@ -154,7 +154,7 @@ feature -- Enumerations. ]" end - curlopt_writefunction: INTEGER is + curlopt_writefunction: INTEGER -- Declared as CURLOPT_WRITEFUNCTION. external "C inline use " @@ -164,7 +164,7 @@ feature -- Enumerations. ]" end - curlopt_progressfunction: INTEGER is + curlopt_progressfunction: INTEGER -- Declared as CURLOPT_PROGRESSFUNCTION external "C inline use " @@ -174,7 +174,7 @@ feature -- Enumerations. ]" end - curlopt_noprogress: INTEGER is + curlopt_noprogress: INTEGER -- Declared as CURLOPT_NOPROGRESS external "C inline use " @@ -184,7 +184,7 @@ feature -- Enumerations. ]" end - curlopt_progressdata: INTEGER is + curlopt_progressdata: INTEGER -- Declared as CURLOPT_PROGRESSDATA external "C inline use " @@ -194,7 +194,7 @@ feature -- Enumerations. ]" end - curlopt_referer: INTEGER is + curlopt_referer: INTEGER -- Declared as CURLOPT_REFERER external "C inline use " @@ -204,7 +204,7 @@ feature -- Enumerations. ]" end - curlopt_httpget: INTEGER is + curlopt_httpget: INTEGER -- Declared as CURLOPT_HTTPGET -- Pass a long. If the long is non-zero, this forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle. -- When setting CURLOPT_HTTPGET to a non-zero value, it will automatically set CURLOPT_NOBODY to 0 (since 7.14.1). @@ -216,7 +216,7 @@ feature -- Enumerations. ]" end - is_valid (a_integer: INTEGER): BOOLEAN is + is_valid (a_integer: INTEGER): BOOLEAN -- If `a_integer' value vaild? do Result := a_integer = curlopt_cookie or @@ -241,7 +241,7 @@ feature -- Enumerations. a_integer = curlopt_httpget end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_string.e b/curl_string.e index ce055282..5f38934c 100644 --- a/curl_string.e +++ b/curl_string.e @@ -1,4 +1,4 @@ -indexing +note description: "[ String used by cURL wrapper library. Only added features from IDENTIFIED. @@ -34,7 +34,7 @@ create make_from_c, make_from_cil -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/curl_utility.e b/curl_utility.e index b272be3b..d00db8ad 100644 --- a/curl_utility.e +++ b/curl_utility.e @@ -1,4 +1,4 @@ -indexing +note description: "[ Utilities for Eiffel cURL wrapper library. ]" @@ -12,7 +12,7 @@ class feature -- Query - module_name: STRING is + module_name: STRING -- Module name. once if {PLATFORM}.is_windows then @@ -26,7 +26,7 @@ feature -- Query not_void: Result /= Void end -indexing +note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/implementation/gtk/api_loader_imp.e b/implementation/gtk/api_loader_imp.e index 339fa4ae..766a3529 100644 --- a/implementation/gtk/api_loader_imp.e +++ b/implementation/gtk/api_loader_imp.e @@ -1,4 +1,4 @@ -indexing +note description: "[ Interactive with native system APIs for dynamic loading. GTK verson. @@ -13,7 +13,7 @@ class feature -- Command - load_module (a_name: STRING): POINTER is + load_module (a_name: STRING): POINTER -- Load module with `a_name'. -- `a_name' is LPCTSTR, we should use WEL_STRING here. require @@ -25,7 +25,7 @@ feature -- Command Result := {EV_GTK_EXTERNALS}.g_module_open (l_c_string.item, 0) end - loal_api (a_module: POINTER; a_name: STRING): POINTER is + loal_api (a_module: POINTER; a_name: STRING): POINTER -- Load api which name is `a_name' in `a_module' require exists: a_module /= default_pointer @@ -44,7 +44,7 @@ feature -- Command end end -indexing +note copyright: "Copyright (c) 1984-2007, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" diff --git a/implementation/mswin/api_loader_imp.e b/implementation/mswin/api_loader_imp.e index d53934a8..adedd01a 100644 --- a/implementation/mswin/api_loader_imp.e +++ b/implementation/mswin/api_loader_imp.e @@ -1,4 +1,4 @@ -indexing +note description: "[ Interactive with native system APIs for dynamic loading. Windows verson. @@ -13,7 +13,7 @@ class feature -- Command - load_module (a_name: STRING): POINTER is + load_module (a_name: STRING): POINTER -- Load module with `a_name'. -- `a_name' is LPCTSTR, we should use WEL_STRING here. require @@ -25,7 +25,7 @@ feature -- Command Result := c_load_module (l_wel_string.item) end - loal_api (a_module: POINTER; a_name: STRING): POINTER is + loal_api (a_module: POINTER; a_name: STRING): POINTER -- Load api which name is `a_name' in `a_module' require exists: a_module /= default_pointer @@ -39,7 +39,7 @@ feature -- Command feature {NONE} -- Implementation - c_load_module (a_name: POINTER): POINTER is + c_load_module (a_name: POINTER): POINTER -- Load module with `a_name'. -- `a_name' is LPCTSTR, we should use WEL_STRING here. require @@ -50,7 +50,7 @@ feature {NONE} -- Implementation "return (EIF_POINTER) LoadLibrary ($a_name);" end - c_loal_api (a_module: POINTER; a_name: POINTER): POINTER is + c_loal_api (a_module: POINTER; a_name: POINTER): POINTER -- Load api which name is `a_name' in `a_module' require exists: a_module /= default_pointer @@ -61,7 +61,7 @@ feature {NONE} -- Implementation "return GetProcAddress ((HMODULE) $a_module, $a_name);" end -indexing +note copyright: "Copyright (c) 1984-2007, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" From 2f1e4e561bd5a99170848eae2e484d143bdcf6cd Mon Sep 17 00:00:00 2001 From: manus Date: Wed, 4 Feb 2009 01:04:28 +0000 Subject: [PATCH 30/64] Removed vision2 since not used. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76960 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL.ecf | 1 - 1 file changed, 1 deletion(-) diff --git a/cURL.ecf b/cURL.ecf index 062cd010..6b979ea7 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -57,7 +57,6 @@ - /spec$ From 925fdcd9791aa817de41fdfe239959be1f1ec1c9 Mon Sep 17 00:00:00 2001 From: manus Date: Wed, 4 Feb 2009 01:05:57 +0000 Subject: [PATCH 31/64] Made the cURL library void-safe. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76961 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 79 +++++++++++++++++++++++++++++++++++++++++ curl_default_function.e | 13 +++---- curl_easy_externals.e | 9 ++--- curl_string.e | 2 +- 4 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 cURL-safe.ecf diff --git a/cURL-safe.ecf b/cURL-safe.ecf new file mode 100644 index 00000000..6feff68e --- /dev/null +++ b/cURL-safe.ecf @@ -0,0 +1,79 @@ + + + + cURL: libcURL wrapper library for Eiffel. + Copyright (c) 1984-2006, Eiffel Software and others. + Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). + + + /\.svn$ + /EIFGEN.{0,1}$ + /temp$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /spec$ + /Clib$ + + + /gtk$ + + + + + + /mswin$ + + + + + + + diff --git a/curl_default_function.e b/curl_default_function.e index 5b755885..644142fb 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -35,16 +35,17 @@ feature -- Command -- Redefine local l_c_string: C_STRING - l_string: CURL_STRING l_identified: IDENTIFIED do Result := a_size * a_nmemb - create l_c_string.share_from_pointer_and_count (a_data_pointer, Result) + create l_c_string.make_shared_from_pointer_and_count (a_data_pointer, Result) create l_identified - l_string ?= l_identified.id_object (a_object_id.to_integer_32) - check not_void: l_string /= Void end - l_string.append (l_c_string.string) + if {l_string: CURL_STRING} l_identified.id_object (a_object_id.to_integer_32) then + l_string.append (l_c_string.string) + else + check False end + end end debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER @@ -85,7 +86,7 @@ feature {NONE} -- Implementation local l_c_string: C_STRING do - create l_c_string.share_from_pointer_and_count (a_char_pointer, a_size) + create l_c_string.make_shared_from_pointer_and_count (a_char_pointer, a_size) print ("%N" + a_text + "%N" + l_c_string.string) end diff --git a/curl_easy_externals.e b/curl_easy_externals.e index cfe97b38..0c88d61a 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -131,7 +131,7 @@ feature -- Query do Result := (api_loader.module_pointer (module_name) /= default_pointer) end - + feature -- Special setting set_curl_function (a_curl_function: CURL_FUNCTION) @@ -145,8 +145,9 @@ feature -- Special setting curl_function: CURL_FUNCTION -- cURL functions in curl_easy_setopt. do - Result := internal_curl_function - if Result = Void then + if {l_curl_function: like curl_function} internal_curl_function then + Result := l_curl_function + else create {CURL_DEFAULT_FUNCTION} Result.make internal_curl_function := Result end @@ -197,7 +198,7 @@ feature -- Special setting feature {NONE} -- Implementation - internal_curl_function: CURL_FUNCTION + internal_curl_function: ?CURL_FUNCTION -- cURL functions. api_loader: API_LOADER diff --git a/curl_string.e b/curl_string.e index 5f38934c..87ad63c6 100644 --- a/curl_string.e +++ b/curl_string.e @@ -31,7 +31,7 @@ create make_empty, make_filled, make_from_string, - make_from_c, + make_from_c_pointer, make_from_cil note From 93b74d0d5edf5144012a161713cad899551121fa Mon Sep 17 00:00:00 2001 From: manus Date: Wed, 4 Feb 2009 16:58:59 +0000 Subject: [PATCH 32/64] Added back vision2 since used for the API_LOADER_IMP on Unix but this time with an explicit conditional. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76965 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 5 +++++ cURL.ecf | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/cURL-safe.ecf b/cURL-safe.ecf index 6feff68e..fa62d892 100644 --- a/cURL-safe.ecf +++ b/cURL-safe.ecf @@ -57,6 +57,11 @@ + + + + + /spec$ diff --git a/cURL.ecf b/cURL.ecf index 6b979ea7..91cc4c8f 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -57,6 +57,11 @@ + + + + + /spec$ From 9a4a1a3a40109f384ef29b132b64545b613ad495 Mon Sep 17 00:00:00 2001 From: king Date: Wed, 4 Feb 2009 17:01:51 +0000 Subject: [PATCH 33/64] Fixed typo from previous commit git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76966 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL.ecf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cURL.ecf b/cURL.ecf index 91cc4c8f..fae7399e 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -61,7 +61,7 @@ - + /spec$ From 816e5b4d6cc36ea925995f513abb1004cd4dce3c Mon Sep 17 00:00:00 2001 From: king Date: Wed, 4 Feb 2009 17:02:38 +0000 Subject: [PATCH 34/64] Fixed typo from previous commit git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76967 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cURL-safe.ecf b/cURL-safe.ecf index fa62d892..a6100e46 100644 --- a/cURL-safe.ecf +++ b/cURL-safe.ecf @@ -61,7 +61,7 @@ - + /spec$ From 9e27a526705bce92ab87a3c975abdab2828810c6 Mon Sep 17 00:00:00 2001 From: manus Date: Fri, 6 Feb 2009 22:45:24 +0000 Subject: [PATCH 35/64] To make transition easier, we are preserving `make_from_c' as creation procedure in the STRING classes and therefore we should use it instead of `make_from_c_pointer' that will be obsoleted soon. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@77047 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_string.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curl_string.e b/curl_string.e index 87ad63c6..5f38934c 100644 --- a/curl_string.e +++ b/curl_string.e @@ -31,7 +31,7 @@ create make_empty, make_filled, make_from_string, - make_from_c_pointer, + make_from_c, make_from_cil note From e880fbde1400d8e4a978abd8683a2e8945551f41 Mon Sep 17 00:00:00 2001 From: manus Date: Tue, 24 Feb 2009 23:44:31 +0000 Subject: [PATCH 36/64] Use new syntax for object test and attached/detachable type. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@77298 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_default_function.e | 2 +- curl_easy_externals.e | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/curl_default_function.e b/curl_default_function.e index 644142fb..099fd32f 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -41,7 +41,7 @@ feature -- Command create l_c_string.make_shared_from_pointer_and_count (a_data_pointer, Result) create l_identified - if {l_string: CURL_STRING} l_identified.id_object (a_object_id.to_integer_32) then + if attached {CURL_STRING} l_identified.id_object (a_object_id.to_integer_32) as l_string then l_string.append (l_c_string.string) else check False end diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 0c88d61a..4ee7d90e 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -145,7 +145,7 @@ feature -- Special setting curl_function: CURL_FUNCTION -- cURL functions in curl_easy_setopt. do - if {l_curl_function: like curl_function} internal_curl_function then + if attached {like curl_function} internal_curl_function as l_curl_function then Result := l_curl_function else create {CURL_DEFAULT_FUNCTION} Result.make @@ -198,7 +198,7 @@ feature -- Special setting feature {NONE} -- Implementation - internal_curl_function: ?CURL_FUNCTION + internal_curl_function: detachable CURL_FUNCTION -- cURL functions. api_loader: API_LOADER From caf6d8c5286fd87bdbe484f9871d637a64351f32 Mon Sep 17 00:00:00 2001 From: larryl Date: Fri, 27 Feb 2009 13:02:12 +0000 Subject: [PATCH 37/64] Added features related with curlopt_readfunction (for setting and using read function), so users can read data from local machine and send the data to server. Added curlopt_put and other constance to {CURL_OPT_CONSTATNS} which used by {CURL_EASY_EXTERNALS} Contributed by Heiko Gering git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@77404 8089f293-4706-0410-a29e-feb5c42a2edf --- Clib/eiffel_curl.c | 41 +++++++++++++++++++++++++- curl_default_function.e | 7 ++++- curl_easy_externals.e | 27 ++++++++++++++++- curl_function.e | 36 +++++++++++++++++++++-- curl_opt_constants.e | 59 ++++++++++++++++++++++++++++++++++++-- spec/include/eiffel_curl.h | 2 ++ 6 files changed, 165 insertions(+), 7 deletions(-) diff --git a/Clib/eiffel_curl.c b/Clib/eiffel_curl.c index a3ea435d..635ea00c 100644 --- a/Clib/eiffel_curl.c +++ b/Clib/eiffel_curl.c @@ -34,6 +34,17 @@ typedef EIF_INTEGER (* EIF_CURL_WRITE_PROC) ( EIF_INTEGER, /* a_nmemb */ EIF_POINTER /* a_write_pointer */ ); + +typedef EIF_INTEGER (* EIF_CURL_READ_PROC) ( +#ifndef EIF_IL_DLL + EIF_REFERENCE, /* CURL_FUNCTION Eiffel object */ +#endif + EIF_POINTER, /* a_data_pointer */ + EIF_INTEGER, /* a_size */ + EIF_INTEGER, /* a_nmemb */ + EIF_POINTER /* a_write_pointer */ + ); + typedef EIF_INTEGER (* EIF_CURL_DEBUG_PROC) ( #ifndef EIF_IL_DLL @@ -54,7 +65,10 @@ static EIF_CURL_PROGRESS_PROC eiffel_progress_function = NULL; static EIF_CURL_WRITE_PROC eiffel_write_function = NULL; /* Address of Eiffel CURL_FUNCTION.write_function */ - + +static EIF_CURL_READ_PROC eiffel_read_function = NULL; + /* Address of Eiffel CURL_FUNCTION.read_function */ + static EIF_CURL_DEBUG_PROC eiffel_debug_function = NULL; /* Address of Eiffel CURL_FUNCTION.debug_function */ @@ -86,6 +100,12 @@ void c_set_write_function_address( EIF_POINTER a_address) eiffel_write_function = (EIF_CURL_WRITE_PROC) a_address; } +/* Set CURL_FUNCTOIN.read_function address */ +void c_set_read_function_address( EIF_POINTER a_address) +{ + eiffel_read_function = (EIF_CURL_READ_PROC) a_address; +} + /* Set CURL_FUNCTOIN.debug_function address */ void c_set_debug_function_address (EIF_POINTER a_address) { @@ -110,6 +130,25 @@ size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data) } } +/* Eiffel adapter function for CURLOPT_READFUNCTION + We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ +size_t curl_read_function (void *ptr, size_t size, size_t nmemb, void *data) +{ + if (eiffel_function_object) { + return (size_t) ((eiffel_read_function) ( +#ifndef EIF_IL_DLL + (EIF_REFERENCE) eif_access (eiffel_function_object), +#endif + (EIF_POINTER) ptr, + (EIF_INTEGER) size, + (EIF_INTEGER) nmemb, + (EIF_POINTER) data)); + } else { + return 0; + } +} + + /* Eiffel adapter function for CURLOPT_PROGRESSFUNCTION We need this function since Eiffel function call need first parameter is EIF_REFERENCE. */ size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow) diff --git a/curl_default_function.e b/curl_default_function.e index 099fd32f..796c45b9 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -1,4 +1,4 @@ -note +indexing description: "[ Default implementation of CURL_FUNCTION. ]" @@ -48,6 +48,11 @@ feature -- Command end end + read_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER + -- A callback readfunction + do + end + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER -- Redefine local diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 4ee7d90e..ea16da24 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -1,4 +1,4 @@ -note +indexing description: "[ cURL easy externals. For more informaton see: @@ -95,6 +95,16 @@ feature -- Command end end + setopt_file (a_curl_handle: POINTER; a_opt: INTEGER; a_file: FILE) + -- Declared as curl_easy_setopt(). + require + exists: a_curl_handle /= default_pointer + valid: a_opt = {CURL_OPT_CONSTANTS}.curlopt_readdata + readable: a_file /= void and then a_file.file_readable + do + setopt_void_star (a_curl_handle, a_opt, a_file.file_pointer) + end + perform (a_curl_handle: POINTER): INTEGER -- Declared as curl_easy_perform(). -- Result is one value from {CURL_CODES} @@ -170,6 +180,21 @@ feature -- Special setting end end + set_read_function (a_curl_handle: POINTER) + -- Set cURL read function + -- Set cURL read function with Eiffel default read function. + -- So we can use a c file pointer as parameter in {CURL_EASY_EXTERNALS}.setopt_file_pointer when the option is {CURL_OPT_CONSTANTS}.curlopt_readdata + require + exists: a_curl_handle /= default_pointer + local + l_api: POINTER + do + l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + if l_api /= default_pointer then + curl_function.c_set_read_function (l_api, a_curl_handle) + end + end + set_progress_function (a_curl_handle: POINTER) -- Set cURL progress function for upload/download progress. require diff --git a/curl_function.e b/curl_function.e index 28f2e78a..cb26ad1f 100644 --- a/curl_function.e +++ b/curl_function.e @@ -1,4 +1,4 @@ -note +indexing description: "[ cURL curl_easy_setopt callback functions' Eiffel wrappers. We need this class since cURL need a c function pointer as value but @@ -20,11 +20,12 @@ feature -- Interactive with C set_object_and_function_address -- Set object and function addresses. - -- Call this feature before call `c_set_progress_function', `c_set_debug_function' and `c_set_write_function'. + -- Call this feature before call `c_set_progress_function', `c_set_debug_function' and `c_set_write_function, c_set_read_function'. do c_set_object ($Current) c_set_progress_function_address ($progress_function) c_set_write_function_address ($write_function) + c_set_read_function_address ($read_function) c_set_debug_function_address ($debug_function) end @@ -83,6 +84,24 @@ feature -- Interactive with C ]" end + c_set_read_function (a_setopt_api: POINTER; a_curl_handle: POINTER) + -- Setting CURLOPT_READFUNCTION option of `a_curl_handle'. + -- We need this function since cURL need a c function pointer as value. + require + exists: a_setopt_api /= default_pointer + external + "C inline use " + alias + "[ + { + (FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api) + ((CURL *) $a_curl_handle, + (CURLoption)CURLOPT_READFUNCTION, + curl_read_function); + } + ]" + end + feature -- cURL curl_easy_setopt functions progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER @@ -99,6 +118,13 @@ feature -- cURL curl_easy_setopt functions deferred end + read_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER + -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_readfunction + -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which + -- may changed during GC. + deferred + end + debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_debugfunction -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which @@ -134,6 +160,12 @@ feature {NONE} -- Externals "C use %"eiffel_curl.h%"" end + c_set_read_function_address (a_address: POINTER) + -- Set read function address. + external + "C use %"eiffel_curl.h%"" + end + c_set_debug_function_address (a_address: POINTER) -- Set write function address. external diff --git a/curl_opt_constants.e b/curl_opt_constants.e index b2a611ea..5fa9fee1 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -216,8 +216,58 @@ feature -- Enumerations. ]" end + curlopt_readfunction: INTEGER + -- Declared as CURLOPT_READFUNCTION. + external + "C inline use " + alias + "[ + return CURLOPT_READFUNCTION; + ]" + end + + curlopt_upload: INTEGER + -- Declared as CURLOPT_UPLOAD. + external + "C inline use " + alias + "[ + return CURLOPT_UPLOAD; + ]" + end + + curlopt_put: INTEGER + -- Declared as CURLOPT_PUT. + external + "C inline use " + alias + "[ + return CURLOPT_PUT; + ]" + end + + curlopt_readdata: INTEGER + -- Declared as CURLOPT_READDATA. + external + "C inline use " + alias + "[ + return CURLOPT_READDATA; + ]" + end + + curlopt_infilesize_large: INTEGER + -- Declared as CURLOPT_INFILESIZE_LARGE. + external + "C inline use " + alias + "[ + return CURLOPT_INFILESIZE_LARGE; + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN - -- If `a_integer' value vaild? + -- If `a_integer' value valid? do Result := a_integer = curlopt_cookie or a_integer = curlopt_cookiefile or @@ -238,7 +288,12 @@ feature -- Enumerations. a_integer = curlopt_progressdata or a_integer = curlopt_noprogress or a_integer = curlopt_referer or - a_integer = curlopt_httpget + a_integer = curlopt_httpget or + a_integer = curlopt_readfunction or + a_integer = curlopt_upload or + a_integer = curlopt_put or + a_integer = curlopt_readdata or + a_integer = curlopt_infilesize_large end note diff --git a/spec/include/eiffel_curl.h b/spec/include/eiffel_curl.h index e9138e2e..3dd9b005 100644 --- a/spec/include/eiffel_curl.h +++ b/spec/include/eiffel_curl.h @@ -32,9 +32,11 @@ extern "C" { extern void c_set_object(EIF_REFERENCE a_address); extern void c_release_object(void); extern void c_set_progress_function_address( EIF_POINTER a_address); +extern void c_set_read_function_address( EIF_POINTER a_address); extern void c_set_write_function_address( EIF_POINTER a_address); extern void c_set_debug_function_address (EIF_POINTER a_address); extern size_t curl_write_function (void *ptr, size_t size, size_t nmemb, void *data); +extern size_t curl_read_function (void *ptr, size_t size, size_t nmemb, void *data); extern size_t curl_progress_function (void * a_object_id, double a_dltotal, double a_dlnow, double a_ultotal, double a_ulnow); extern size_t curl_debug_function (CURL * a_curl_handle, curl_infotype a_curl_infotype, unsigned char * a_char_pointer, size_t a_size, void * a_object_id); From e3d8fbb263b51fb6d999ecb7fb0af0392274953f Mon Sep 17 00:00:00 2001 From: manus Date: Wed, 4 Mar 2009 00:51:24 +0000 Subject: [PATCH 38/64] Removed duplicated `local_realclean' definition which could cause a Makefile execution to fail when launching multiple jobs on a slow file system and slow OS. Fixed the one already committed for EiffelNet as we had removed `local_clean' which is still needed for the `clean' target. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@77516 8089f293-4706-0410-a29e-feb5c42a2edf --- Clib/Makefile.SH | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Clib/Makefile.SH b/Clib/Makefile.SH index 325dbfe8..7c49d5de 100644 --- a/Clib/Makefile.SH +++ b/Clib/Makefile.SH @@ -52,8 +52,6 @@ all: $(ALL_OBJECTS) MTeiffel_curl.o: eiffel_curl.c $(CC) -c $(MTCFLAGS) $? -o $@ -local_realclean:: - $(RM) $(ALL_OBJECTS) ######################################################################## # Common rules for all Makefiles -- do not edit @@ -64,7 +62,7 @@ realclean: local_realclean clobber: local_clobber local_clean:: - $(RM) core *~ *.o + $(RM) core *~ *.o *.so *.a local_realclean:: local_clean From 6bb5b0bac8ce3761bfb7a48ccb56ff942cdd67f3 Mon Sep 17 00:00:00 2001 From: jfiat Date: Wed, 18 Mar 2009 08:21:46 +0000 Subject: [PATCH 39/64] Removed erroneous precondition `exists', since we can call slist_append with null pointer to get an initialized pointer. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@77774 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_externals.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curl_externals.e b/curl_externals.e index 2dd05cef..b62eda7e 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -67,8 +67,8 @@ feature -- Command slist_append (a_list: POINTER; a_string: STRING_GENERAL): POINTER -- Declared as curl_slist_append (). + -- note: call with a null `a_list' to get initialized pointer as Result require - exists: a_list /= default_pointer not_void: a_string /= Void local l_c_string: C_STRING From dae6d64f8219193a384f2eea652995681cfa8ece Mon Sep 17 00:00:00 2001 From: jfiat Date: Thu, 19 Mar 2009 08:18:02 +0000 Subject: [PATCH 40/64] Added curl_easy_getinfo. Associated constants and also CURLOPT_USERPWD. Minor optimization and cosmetics. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@77794 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_easy_externals.e | 67 ++++++++++++++++++++++- curl_info_constants.e | 122 ++++++++++++++++++++++++++++++++++++++++++ curl_info_type.e | 21 +++++--- curl_opt_constants.e | 10 ++++ 4 files changed, 212 insertions(+), 8 deletions(-) create mode 100644 curl_info_constants.e diff --git a/curl_easy_externals.e b/curl_easy_externals.e index ea16da24..6245b219 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -100,7 +100,7 @@ feature -- Command require exists: a_curl_handle /= default_pointer valid: a_opt = {CURL_OPT_CONSTANTS}.curlopt_readdata - readable: a_file /= void and then a_file.file_readable + readable: a_file /= Void and then a_file.file_readable do setopt_void_star (a_curl_handle, a_opt, a_file.file_pointer) end @@ -136,6 +136,53 @@ feature -- Command feature -- Query + getinfo (a_curl_handle: POINTER; a_info: INTEGER; a_data: CELL [detachable ANY]): INTEGER + -- `curl_getinfo + --|* Request internal information from the curl session with this function. The + --|* third argument MUST be a pointer to a long, a pointer to a char * or a + --|* pointer to a double (as the documentation describes elsewhere). The data + --|* pointed to will be filled in accordingly and can be relied upon only if the + --|* function returns CURLE_OK. This function is intended to get used *AFTER* a + --|* performed transfer, all results from this function are undefined until the + --|* transfer is completed. + require + exists: a_curl_handle /= default_pointer + valid: (create {CURL_INFO_CONSTANTS}).is_valid (a_info) + local + l_api: POINTER + mp: detachable MANAGED_POINTER + l: INTEGER + cs: C_STRING + d: REAL_64 + do + a_data.replace (Void) + l_api := api_loader.safe_load_api (module_name, "curl_easy_getinfo") + if l_api /= default_pointer then + if a_info & {CURL_INFO_CONSTANTS}.curlinfo_long /= 0 then + create mp.make ({PLATFORM}.integer_32_bytes) + elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_string /= 0 then + create mp.make ({PLATFORM}.pointer_bytes) + elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_double /= 0 then + create mp.make ({PLATFORM}.real_64_bytes) + end + if mp /= Void then + Result := c_getinfo (l_api, a_curl_handle, a_info, mp.item) + if Result = {CURL_CODES}.curle_ok then + if a_info & {CURL_INFO_CONSTANTS}.curlinfo_long /= 0 then + l := mp.read_integer_32 (0) + a_data.put (l) + elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_string /= 0 then + create cs.make_shared_from_pointer (mp.read_pointer (0)) + a_data.put (cs.string) + elseif a_info & {CURL_INFO_CONSTANTS}.curlinfo_double /= 0 then + d := mp.read_real_64 (0) + a_data.put (d) + end + end + end + end + end + is_dynamic_library_exists: BOOLEAN -- If dll/so files exist? do @@ -337,6 +384,24 @@ feature {NONE} -- C externals ]" end + c_getinfo (a_api: POINTER; a_curl_handle: POINTER; a_opt: INTEGER; a_data: POINTER): INTEGER + -- C implementation of `curl_easy_getinfo'. + -- Declared as curl_easy_setopt (). + require + exists: a_api /= default_pointer + exists: a_curl_handle /= default_pointer + valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt) + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURLcode, (CURL *, CURLINFO info, ...)) $a_api) + ((CURL *) $a_curl_handle, + (CURLINFO)$a_opt, + $a_data); + ]" + end + note library: "cURL: Library of reusable components for Eiffel." copyright: "Copyright (c) 1984-2006, Eiffel Software and others" diff --git a/curl_info_constants.e b/curl_info_constants.e new file mode 100644 index 00000000..c8dfd480 --- /dev/null +++ b/curl_info_constants.e @@ -0,0 +1,122 @@ +note + description: "[ + cURL library info constants. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + CURL_INFO_CONSTANTS + +feature -- Constants + + curlinfo_string: INTEGER = 0x100000 + -- Declared as CURLINFO_STRING + + curlinfo_long: INTEGER = 0x200000 + -- Declared as CURLINFO_LONG + + curlinfo_double: INTEGER = 0x300000 + -- Declared as CURLINFO_DOUBLE + + curlinfo_slist: INTEGER = 0x400000 + -- Declared as CURLINFO_SLIST + + curlinfo_mask: INTEGER = 0x0fffff + -- Declared as CURLINFO_MASK + + curlinfo_typemask: INTEGER = 0xf00000 + -- Declared as CURLINFO_TYPEMASK + +feature -- Info constants + + curlinfo_effective_url: INTEGER = 0x100001 -- CURLINFO_STRING + 1, + curlinfo_response_code: INTEGER = 0x200002 -- CURLINFO_LONG + 2, + curlinfo_total_time: INTEGER = 0x300003 -- CURLINFO_DOUBLE + 3, + curlinfo_namelookup_time: INTEGER = 0x300004 -- CURLINFO_DOUBLE + 4, + curlinfo_connect_time: INTEGER = 0x300005 -- CURLINFO_DOUBLE + 5, + curlinfo_pretransfer_time: INTEGER = 0x300006 -- CURLINFO_DOUBLE + 6, + curlinfo_size_upload: INTEGER = 0x300007 -- CURLINFO_DOUBLE + 7, + curlinfo_size_download: INTEGER = 0x300008 -- CURLINFO_DOUBLE + 8, + curlinfo_speed_download: INTEGER = 0x300009 -- CURLINFO_DOUBLE + 9, + curlinfo_speed_upload: INTEGER = 0x30000a -- CURLINFO_DOUBLE + 10, + curlinfo_header_size: INTEGER = 0x20000b -- CURLINFO_LONG + 11, + curlinfo_request_size: INTEGER = 0x20000c -- CURLINFO_LONG + 12, + curlinfo_ssl_verifyresult: INTEGER = 0x20000d -- CURLINFO_LONG + 13, + curlinfo_filetime: INTEGER = 0x20000e -- CURLINFO_LONG + 14, + curlinfo_content_length_download: INTEGER = 0x30000f -- CURLINFO_DOUBLE + 15, + curlinfo_content_length_upload: INTEGER = 0x300010 -- CURLINFO_DOUBLE + 16, + curlinfo_starttransfer_time: INTEGER = 0x300011 -- CURLINFO_DOUBLE + 17, + curlinfo_content_type: INTEGER = 0x100012 -- CURLINFO_STRING + 18, + curlinfo_redirect_time: INTEGER = 0x300013 -- CURLINFO_DOUBLE + 19, + curlinfo_redirect_count: INTEGER = 0x200014 -- CURLINFO_LONG + 20, + curlinfo_private: INTEGER = 0x100015 -- CURLINFO_STRING + 21, + curlinfo_http_connectcode: INTEGER = 0x200016 -- CURLINFO_LONG + 22, + curlinfo_httpauth_avail: INTEGER = 0x200017 -- CURLINFO_LONG + 23, + curlinfo_proxyauth_avail: INTEGER = 0x200018 -- CURLINFO_LONG + 24, + curlinfo_os_errno: INTEGER = 0x200019 -- CURLINFO_LONG + 25, + curlinfo_num_connects: INTEGER = 0x20001a -- CURLINFO_LONG + 26, + curlinfo_ssl_engines: INTEGER = 0x40001b -- CURLINFO_SLIST + 27, + curlinfo_cookielist: INTEGER = 0x40001c -- CURLINFO_SLIST + 28, + curlinfo_lastsocket: INTEGER = 0x20001d -- CURLINFO_LONG + 29, + curlinfo_ftp_entry_path: INTEGER = 0x10001e -- CURLINFO_STRING + 30, + +feature -- Contract support + + is_valid (a_code: INTEGER): BOOLEAN + -- Is `a_code' valid? + do + inspect a_code + when + curlinfo_effective_url, + curlinfo_response_code, + curlinfo_total_time, + curlinfo_namelookup_time, + curlinfo_connect_time, + curlinfo_pretransfer_time, + curlinfo_size_upload, + curlinfo_size_download, + curlinfo_speed_download, + curlinfo_speed_upload, + curlinfo_header_size, + curlinfo_request_size, + curlinfo_ssl_verifyresult, + curlinfo_filetime, + curlinfo_content_length_download, + curlinfo_content_length_upload, + curlinfo_starttransfer_time, + curlinfo_content_type, + curlinfo_redirect_time, + curlinfo_redirect_count, + curlinfo_private, + curlinfo_http_connectcode, + curlinfo_httpauth_avail, + curlinfo_proxyauth_avail, + curlinfo_os_errno, + curlinfo_num_connects, + curlinfo_ssl_engines, + curlinfo_cookielist, + curlinfo_lastsocket, + curlinfo_ftp_entry_path + then + Result := True + else + Result := False + end + end + +note + library: "cURL: Library of reusable components for Eiffel." + copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end diff --git a/curl_info_type.e b/curl_info_type.e index a3c9cb39..7137e97e 100644 --- a/curl_info_type.e +++ b/curl_info_type.e @@ -38,13 +38,20 @@ feature -- Contract support is_valid (a_type: INTEGER): BOOLEAN -- If `a_type' valid? do - Result := a_type = curlinfo_data_in or - a_type = curlinfo_data_out or - a_type = curlinfo_header_in or - a_type = curlinfo_header_out or - a_type = curlinfo_ssl_data_in or - a_type = curlinfo_ssl_data_out or - a_type = curlinfo_text + inspect a_type + when + curlinfo_data_in, + curlinfo_data_out, + curlinfo_header_in, + curlinfo_header_out, + curlinfo_ssl_data_in, + curlinfo_ssl_data_out, + curlinfo_text + then + Result := True + else + Result := False + end end note diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 5fa9fee1..128d75da 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -84,6 +84,16 @@ feature -- Enumerations. ]" end + curlopt_userpwd: INTEGER + -- Declared as CURLOPT_USERPWD. + external + "C inline use " + alias + "[ + return CURLOPT_USERPWD; + ]" + end + curlopt_url: INTEGER -- Declared as CURLOPT_URL. external From 0759dfe1a750380fef6ffc9e8c8eb0704ee6b704 Mon Sep 17 00:00:00 2001 From: manus Date: Thu, 9 Apr 2009 18:51:20 +0000 Subject: [PATCH 41/64] Use new `note' syntax. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78146 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_default_function.e | 2 +- curl_easy_externals.e | 2 +- curl_function.e | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/curl_default_function.e b/curl_default_function.e index 796c45b9..111011b8 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -1,4 +1,4 @@ -indexing +note description: "[ Default implementation of CURL_FUNCTION. ]" diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 6245b219..604177de 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL easy externals. For more informaton see: diff --git a/curl_function.e b/curl_function.e index cb26ad1f..0e481625 100644 --- a/curl_function.e +++ b/curl_function.e @@ -1,4 +1,4 @@ -indexing +note description: "[ cURL curl_easy_setopt callback functions' Eiffel wrappers. We need this class since cURL need a c function pointer as value but From 7e2a847e39369f16b0c54ae826354a887162cb61 Mon Sep 17 00:00:00 2001 From: jfiat Date: Fri, 10 Apr 2009 08:45:10 +0000 Subject: [PATCH 42/64] cosmetic git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78170 8089f293-4706-0410-a29e-feb5c42a2edf --- build.eant | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.eant b/build.eant index 221aa5b3..325768ce 100644 --- a/build.eant +++ b/build.eant @@ -13,13 +13,13 @@ - + - + From 03851ac02e09861c278c744b39127a93dc4ec8b3 Mon Sep 17 00:00:00 2001 From: manus Date: Fri, 1 May 2009 21:42:03 +0000 Subject: [PATCH 43/64] Updated to 1-5-0 schema version of ECFs. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78475 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 6 +++--- cURL.ecf | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cURL-safe.ecf b/cURL-safe.ecf index a6100e46..997f2d03 100644 --- a/cURL-safe.ecf +++ b/cURL-safe.ecf @@ -1,5 +1,5 @@ - + cURL: libcURL wrapper library for Eiffel. Copyright (c) 1984-2006, Eiffel Software and others. @@ -10,7 +10,7 @@ /EIFGEN.{0,1}$ /temp$ - @@ -56,12 +56,12 @@ - + /spec$ diff --git a/cURL.ecf b/cURL.ecf index fae7399e..6d7cbf65 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -1,5 +1,5 @@ - + cURL: libcURL wrapper library for Eiffel. Copyright (c) 1984-2006, Eiffel Software and others. @@ -10,7 +10,7 @@ /EIFGEN.{0,1}$ /temp$ - @@ -56,12 +56,12 @@ - + /spec$ From 5d63551002521c6496d4d27cdbd7ccc5d703f438 Mon Sep 17 00:00:00 2001 From: larryl Date: Mon, 18 May 2009 04:33:10 +0000 Subject: [PATCH 44/64] Updated cURL library to use API wrapper library Then removed useless classes such as {API_LOADER} {API_LOADER_IMP}, removed useless library references such as Vision2 and WEL git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78736 8089f293-4706-0410-a29e-feb5c42a2edf --- api_loader.e | 115 -------------------------- cURL.ecf | 7 +- curl_easy_externals.e | 38 ++++----- curl_externals.e | 24 ++---- curl_utility.e | 24 ++++-- implementation/gtk/api_loader_imp.e | 79 ------------------ implementation/mswin/api_loader_imp.e | 96 --------------------- 7 files changed, 41 insertions(+), 342 deletions(-) delete mode 100644 api_loader.e delete mode 100644 implementation/gtk/api_loader_imp.e delete mode 100644 implementation/mswin/api_loader_imp.e diff --git a/api_loader.e b/api_loader.e deleted file mode 100644 index eb9dd0bf..00000000 --- a/api_loader.e +++ /dev/null @@ -1,115 +0,0 @@ -note - description: "[ - Dynamic load a external API which exists in a dll or so. - Benefit is we can still use our executables even without the dll/so files. - ]" - status: "See notice at end of class." - legal: "See notice at end of class." - date: "$Date$" - revision: "$Revision$" - -class - API_LOADER - -feature -- Query - - safe_load_api (a_module_name: STRING; a_api_name: STRING): POINTER - -- Safe loading `a_api_name' in `a_module_name' if possible. - -- `a_module_name' is case sensitive. - require - not_void: a_module_name /= Void and then not a_module_name.is_empty - not_void: a_api_name /= Void and then not a_api_name.is_empty - local - l_module: POINTER - do - l_module := module_pointer (a_module_name) - if l_module /= default_pointer then - Result := api_pointer (l_module, a_api_name) - end - end - - module_pointer (a_name: STRING): POINTER - -- Find module hanle with `a_name' - -- Result is void if not exists - require - not_void: a_name /= Void - do - if loaded_modules.has_key (a_name) then - Result := loaded_modules.item (a_name) - else - Result := implementation.load_module (a_name) - if Result /= default_pointer then - loaded_modules.extend (Result, a_name) - end - end - end - - api_pointer (a_module: POINTER; a_name: STRING): POINTER - -- Find API pointer which name is `a_name' in `a_module' - -- Result is void if not exists. - require - exists: a_module /= default_pointer - not_void: a_name /= Void - do - if loaded_apis.has (a_name) then - Result := loaded_apis.item (a_name) - else - Result := implementation.loal_api (a_module, a_name) - if Result /= default_pointer then - loaded_apis.extend (Result, a_name) - end - end - end - -feature {NONE} -- Implementation - - loaded_modules: HASH_TABLE [POINTER, STRING] - -- Loaded modules - once - create Result.make (1) - end - - loaded_apis: HASH_TABLE [POINTER, STRING] - -- Loaded apis. - once - create Result.make (10) - end - - implementation: API_LOADER_IMP - -- Native loader - once - create Result - end -note - copyright: "Copyright (c) 1984-2007, Eiffel Software" - license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" - licensing_options: "http://www.eiffel.com/licensing" - copying: "[ - This file is part of Eiffel Software's Eiffel Development Environment. - - Eiffel Software's Eiffel Development Environment is free - software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published - by the Free Software Foundation, version 2 of the License - (available at the URL listed under "license" above). - - Eiffel Software's Eiffel Development Environment is - distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with Eiffel Software's Eiffel Development - Environment; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - ]" - source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]" - -end diff --git a/cURL.ecf b/cURL.ecf index 6d7cbf65..9b3aae81 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -55,13 +55,8 @@ + - - - - - - /spec$ diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 604177de..c91ced83 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -21,7 +21,7 @@ feature -- Command local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_init") + l_api := api_loader.api_pointer ("curl_easy_init") if l_api /= default_pointer then Result := c_init (l_api) end @@ -39,7 +39,7 @@ feature -- Command l_api: POINTER l_c_str: C_STRING do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then create l_c_str.make (a_string) c_setopt (l_api, a_curl_handle, a_opt, l_c_str.item) @@ -75,7 +75,7 @@ feature -- Command local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then c_setopt_int (l_api, a_curl_handle, a_opt, a_curl_string.object_id) end @@ -89,7 +89,7 @@ feature -- Command local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then c_setopt_int (l_api, a_curl_handle, a_opt, a_integer) end @@ -113,7 +113,7 @@ feature -- Command local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_perform") + l_api := api_loader.api_pointer ("curl_easy_perform") if l_api /= default_pointer then Result := c_perform (l_api, a_curl_handle) end @@ -128,7 +128,7 @@ feature -- Command local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_cleanup") + l_api := api_loader.api_pointer ("curl_easy_cleanup") if l_api /= default_pointer then c_cleanup (l_api, a_curl_handle) end @@ -156,7 +156,7 @@ feature -- Query d: REAL_64 do a_data.replace (Void) - l_api := api_loader.safe_load_api (module_name, "curl_easy_getinfo") + l_api := api_loader.api_pointer ("curl_easy_getinfo") if l_api /= default_pointer then if a_info & {CURL_INFO_CONSTANTS}.curlinfo_long /= 0 then create mp.make ({PLATFORM}.integer_32_bytes) @@ -186,7 +186,7 @@ feature -- Query is_dynamic_library_exists: BOOLEAN -- If dll/so files exist? do - Result := (api_loader.module_pointer (module_name) /= default_pointer) + Result := api_loader.is_interface_usable end feature -- Special setting @@ -221,7 +221,7 @@ feature -- Special setting local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then curl_function.c_set_write_function (l_api, a_curl_handle) end @@ -236,7 +236,7 @@ feature -- Special setting local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then curl_function.c_set_read_function (l_api, a_curl_handle) end @@ -249,7 +249,7 @@ feature -- Special setting local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then curl_function.c_set_progress_function (l_api, a_curl_handle) end @@ -262,7 +262,7 @@ feature -- Special setting local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then curl_function.c_set_debug_function (l_api, a_curl_handle) end @@ -273,21 +273,13 @@ feature {NONE} -- Implementation internal_curl_function: detachable CURL_FUNCTION -- cURL functions. - api_loader: API_LOADER - -- API dynamic loader - once - create Result - ensure - not_void: Result /= Void - end - - module_name: STRING + api_loader: DYNAMIC_MODULE -- Module name. local l_utility: CURL_UTILITY once create l_utility - Result := l_utility.module_name + Result := l_utility.api_loader end setopt_void_star (a_curl_handle: POINTER; a_opt: INTEGER; a_data:POINTER) @@ -298,7 +290,7 @@ feature {NONE} -- Implementation local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_easy_setopt") + l_api := api_loader.api_pointer ("curl_easy_setopt") if l_api /= default_pointer then c_setopt (l_api, a_curl_handle, a_opt, a_data) end diff --git a/curl_externals.e b/curl_externals.e index b62eda7e..2474a36c 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -21,7 +21,7 @@ feature -- Command local l_ptr: POINTER do - l_ptr := api_loader.safe_load_api (module_name, "curl_global_init") + l_ptr := api_loader.api_pointer ("curl_global_init") if l_ptr /= default_pointer then c_curl_global_init (l_ptr, {CURL_GLOBAL_CONSTANTS}.curl_global_all); end @@ -32,7 +32,7 @@ feature -- Command local l_ptr: POINTER do - l_ptr := api_loader.safe_load_api (module_name, "curl_global_cleanup") + l_ptr := api_loader.api_pointer ("curl_global_cleanup") if l_ptr /= default_pointer then c_curl_global_cleanup (l_ptr); end @@ -74,7 +74,7 @@ feature -- Command l_c_string: C_STRING l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_slist_append") + l_api := api_loader.api_pointer ("curl_slist_append") if l_api /= default_pointer then create l_c_string.make (a_string) Result := c_slist_append (l_api, a_list, l_c_string.item) @@ -86,7 +86,7 @@ feature -- Query is_dynamic_library_exists: BOOLEAN -- If dll/so files exist? do - Result := (api_loader.module_pointer (module_name) /= default_pointer) + Result := api_loader.is_interface_usable end feature {CURL_FORM} -- Internal command @@ -101,7 +101,7 @@ feature {CURL_FORM} -- Internal command local l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_formfree") + l_api := api_loader.api_pointer ("curl_formfree") if l_api /= default_pointer then c_formfree (l_api, a_curl_form) end @@ -109,21 +109,13 @@ feature {CURL_FORM} -- Internal command feature {NONE} -- Implementation - api_loader: API_LOADER - -- API dynamic loader - once - create Result - ensure - not_void: Result /= Void - end - - module_name: STRING + api_loader: DYNAMIC_MODULE -- Module name. local l_utility: CURL_UTILITY once create l_utility - Result := l_utility.module_name + Result := l_utility.api_loader end internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) @@ -132,7 +124,7 @@ feature {NONE} -- Implementation l_c_string_1, l_c_string_2: C_STRING l_api: POINTER do - l_api := api_loader.safe_load_api (module_name, "curl_formadd"); + l_api := api_loader.api_pointer ("curl_formadd"); if l_api /= default_pointer then create l_c_string_1.make (a_arg_1_value) create l_c_string_2.make (a_arg_2_value) diff --git a/curl_utility.e b/curl_utility.e index d00db8ad..941e822b 100644 --- a/curl_utility.e +++ b/curl_utility.e @@ -12,16 +12,26 @@ class feature -- Query + api_loader: DYNAMIC_MODULE + -- API dynamic loader + local + l_platform: PLATFORM + once + create l_platform + if l_platform.is_unix or l_platform.is_mac then + create Result.make_with_version (module_name, "3") + else + check is_window: l_platform.is_windows end + create Result.make (module_name) + end + ensure + not_void: Result /= Void + end + module_name: STRING -- Module name. once - if {PLATFORM}.is_windows then - Result := "libcurl.dll" - elseif {PLATFORM}.is_mac then - Result := "libcurl.3.dylib" - else - Result := "libcurl.so.3" - end + Result := "libcurl" ensure not_void: Result /= Void end diff --git a/implementation/gtk/api_loader_imp.e b/implementation/gtk/api_loader_imp.e deleted file mode 100644 index 766a3529..00000000 --- a/implementation/gtk/api_loader_imp.e +++ /dev/null @@ -1,79 +0,0 @@ -note - description: "[ - Interactive with native system APIs for dynamic loading. - GTK verson. - ]" - status: "See notice at end of class." - legal: "See notice at end of class." - date: "$Date$" - revision: "$Revision$" - -class - API_LOADER_IMP - -feature -- Command - - load_module (a_name: STRING): POINTER - -- Load module with `a_name'. - -- `a_name' is LPCTSTR, we should use WEL_STRING here. - require - exists: a_name /= Void - local - l_c_string: EV_GTK_C_STRING - do - l_c_string := a_name - Result := {EV_GTK_EXTERNALS}.g_module_open (l_c_string.item, 0) - end - - loal_api (a_module: POINTER; a_name: STRING): POINTER - -- Load api which name is `a_name' in `a_module' - require - exists: a_module /= default_pointer - exists: a_name /= Void - local - l_c_string: EV_GTK_C_STRING - l_success: BOOLEAN - l_result: POINTER - do - if a_module /= default_pointer then - l_c_string := a_name - l_success := {EV_GTK_EXTERNALS}.g_module_symbol (a_module, l_c_string.item, $l_result) - if l_success then - Result := l_result - end - end - end - -note - copyright: "Copyright (c) 1984-2007, Eiffel Software" - license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" - licensing_options: "http://www.eiffel.com/licensing" - copying: "[ - This file is part of Eiffel Software's Eiffel Development Environment. - - Eiffel Software's Eiffel Development Environment is free - software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published - by the Free Software Foundation, version 2 of the License - (available at the URL listed under "license" above). - - Eiffel Software's Eiffel Development Environment is - distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with Eiffel Software's Eiffel Development - Environment; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - ]" - source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]" - -end diff --git a/implementation/mswin/api_loader_imp.e b/implementation/mswin/api_loader_imp.e deleted file mode 100644 index adedd01a..00000000 --- a/implementation/mswin/api_loader_imp.e +++ /dev/null @@ -1,96 +0,0 @@ -note - description: "[ - Interactive with native system APIs for dynamic loading. - Windows verson. - ]" - status: "See notice at end of class." - legal: "See notice at end of class." - date: "$Date$" - revision: "$Revision$" - -class - API_LOADER_IMP - -feature -- Command - - load_module (a_name: STRING): POINTER - -- Load module with `a_name'. - -- `a_name' is LPCTSTR, we should use WEL_STRING here. - require - exists: a_name /= Void - local - l_wel_string: WEL_STRING - do - create l_wel_string.make (a_name) - Result := c_load_module (l_wel_string.item) - end - - loal_api (a_module: POINTER; a_name: STRING): POINTER - -- Load api which name is `a_name' in `a_module' - require - exists: a_module /= default_pointer - exists: a_name /= Void - local - l_c_string: C_STRING - do - create l_c_string.make (a_name) - Result := c_loal_api (a_module, l_c_string.item) - end - -feature {NONE} -- Implementation - - c_load_module (a_name: POINTER): POINTER - -- Load module with `a_name'. - -- `a_name' is LPCTSTR, we should use WEL_STRING here. - require - exists: a_name /= default_pointer - external - "C inline use " - alias - "return (EIF_POINTER) LoadLibrary ($a_name);" - end - - c_loal_api (a_module: POINTER; a_name: POINTER): POINTER - -- Load api which name is `a_name' in `a_module' - require - exists: a_module /= default_pointer - exists: a_name /= default_pointer - external - "C inline use " - alias - "return GetProcAddress ((HMODULE) $a_module, $a_name);" - end - -note - copyright: "Copyright (c) 1984-2007, Eiffel Software" - license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" - licensing_options: "http://www.eiffel.com/licensing" - copying: "[ - This file is part of Eiffel Software's Eiffel Development Environment. - - Eiffel Software's Eiffel Development Environment is free - software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published - by the Free Software Foundation, version 2 of the License - (available at the URL listed under "license" above). - - Eiffel Software's Eiffel Development Environment is - distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty - of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with Eiffel Software's Eiffel Development - Environment; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - ]" - source: "[ - Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]" - -end From 8ddc27b9cb3a03e426dc9fb419a814e970d2be95 Mon Sep 17 00:00:00 2001 From: dfurrer Date: Mon, 18 May 2009 16:06:27 +0000 Subject: [PATCH 45/64] - Adding the necessary platform-specific implementations (stubs atm) to build EiffelStudio using the Cocoa Vision2 implementation (without GTK+ dependencies). - There is a new target "bench_cocoa" in ec.ecf which builds the native Mac version of EiffelStudio git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78745 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 11 +++++ cURL.ecf | 11 +++++ implementation/mac/api_loader_imp.e | 65 +++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 implementation/mac/api_loader_imp.e diff --git a/cURL-safe.ecf b/cURL-safe.ecf index 997f2d03..3c851e32 100644 --- a/cURL-safe.ecf +++ b/cURL-safe.ecf @@ -69,14 +69,25 @@ /gtk$ + /mac$ /mswin$ + /gtk$ + + + + + + + /mswin$ + /mac$ + diff --git a/cURL.ecf b/cURL.ecf index 9b3aae81..885a50ce 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -64,14 +64,25 @@ /gtk$ + /mac$ /mswin$ + /gtk$ + + + + + + + /mswin$ + /mac$ + diff --git a/implementation/mac/api_loader_imp.e b/implementation/mac/api_loader_imp.e new file mode 100644 index 00000000..e2eaf163 --- /dev/null +++ b/implementation/mac/api_loader_imp.e @@ -0,0 +1,65 @@ +note + description: "[ + Interactive with native system APIs for dynamic loading. + Cocoa verson. + ]" + status: "See notice at end of class." + legal: "See notice at end of class." + date: "$Date$" + revision: "$Revision$" + +class + API_LOADER_IMP + +feature -- Command + + load_module (a_name: STRING): POINTER + -- Load module with `a_name'. + require + exists: a_name /= Void + do + -- fixme: implement + end + + loal_api (a_module: POINTER; a_name: STRING): POINTER + -- Load api which name is `a_name' in `a_module' + require + exists: a_module /= default_pointer + exists: a_name /= Void + do + -- fixme: implement + end + +note + copyright: "Copyright (c) 1984-2007, Eiffel Software" + license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" + licensing_options: "http://www.eiffel.com/licensing" + copying: "[ + This file is part of Eiffel Software's Eiffel Development Environment. + + Eiffel Software's Eiffel Development Environment is free + software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published + by the Free Software Foundation, version 2 of the License + (available at the URL listed under "license" above). + + Eiffel Software's Eiffel Development Environment is + distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty + of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with Eiffel Software's Eiffel Development + Environment; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + ]" + source: "[ + Eiffel Software + 356 Storke Road, Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" + +end From 764372f0722caecdc096861a65d262ef8d80aad0 Mon Sep 17 00:00:00 2001 From: manus Date: Mon, 18 May 2009 21:06:56 +0000 Subject: [PATCH 46/64] Updated safe-version to also use the API wrapper library otherwise it does not compile. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78752 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cURL-safe.ecf b/cURL-safe.ecf index 3c851e32..291780ca 100644 --- a/cURL-safe.ecf +++ b/cURL-safe.ecf @@ -55,13 +55,8 @@ + - - - - - - /spec$ From ee8bce82b29ca018de2b9609c853f290cbcd7f9d Mon Sep 17 00:00:00 2001 From: larryl Date: Mon, 13 Jul 2009 09:07:05 +0000 Subject: [PATCH 47/64] Added curlopt_proxy constant Contributed by Heiko Gering git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@79745 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 128d75da..b47d8742 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -276,6 +276,16 @@ feature -- Enumerations. ]" end + curlopt_proxy: INTEGER + -- Declared as CURLOPT_PROXY. + external + "C inline use " + alias + "[ + return CURLOPT_PROXY; + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN -- If `a_integer' value valid? do @@ -303,7 +313,8 @@ feature -- Enumerations. a_integer = curlopt_upload or a_integer = curlopt_put or a_integer = curlopt_readdata or - a_integer = curlopt_infilesize_large + a_integer = curlopt_infilesize_large or + a_integer = curlopt_proxy end note From eefd98c630e7d30f6d6566885db8aa455d0d6e05 Mon Sep 17 00:00:00 2001 From: larryl Date: Tue, 25 Aug 2009 09:40:26 +0000 Subject: [PATCH 48/64] Added automatic license files for docking and cURL library git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@80413 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.lic | 1 + cURL.lic | 1 + 2 files changed, 2 insertions(+) create mode 100644 cURL-safe.lic create mode 100644 cURL.lic diff --git a/cURL-safe.lic b/cURL-safe.lic new file mode 100644 index 00000000..c929225f --- /dev/null +++ b/cURL-safe.lic @@ -0,0 +1 @@ +reference:forum2 diff --git a/cURL.lic b/cURL.lic new file mode 100644 index 00000000..c929225f --- /dev/null +++ b/cURL.lic @@ -0,0 +1 @@ +reference:forum2 From 7717502363504520cfe160f3a33a04b5a70d1082 Mon Sep 17 00:00:00 2001 From: larryl Date: Thu, 15 Oct 2009 14:38:50 +0000 Subject: [PATCH 49/64] Added useful comments git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@81175 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_function.e | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/curl_function.e b/curl_function.e index 0e481625..83ea6d3f 100644 --- a/curl_function.e +++ b/curl_function.e @@ -4,6 +4,10 @@ note We need this class since cURL need a c function pointer as value but Eiffel function need frist parameter of any funciton call is object address. Client programmers can inherit this class to fit their needs. + + Note: descendants of this class have to call `set_object_and_function_address', + otherwise cURL would not know how to call Eiffel features (such as `write_function'). + See example: $ISE_LIBRARY\examples\cURL\upload_and_read_function ]" status: "See notice at end of class." legal: "See notice at end of class." From 683aa808ad33f2b438a3ea0c28f539c7c78a3508 Mon Sep 17 00:00:00 2001 From: manus Date: Sat, 14 Nov 2009 00:46:07 +0000 Subject: [PATCH 50/64] In non-experimental version of EiffelStudio we do not distribute void-safe version of the libraries as it does not make sense (since it would convey the message that it is void-safe when it is actually not void-safe). git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@81549 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 90 --------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 cURL-safe.ecf diff --git a/cURL-safe.ecf b/cURL-safe.ecf deleted file mode 100644 index 291780ca..00000000 --- a/cURL-safe.ecf +++ /dev/null @@ -1,90 +0,0 @@ - - - - cURL: libcURL wrapper library for Eiffel. - Copyright (c) 1984-2006, Eiffel Software and others. - Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). - - - /\.svn$ - /EIFGEN.{0,1}$ - /temp$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /spec$ - /Clib$ - - - /gtk$ - /mac$ - - - - - - /mswin$ - /gtk$ - - - - - - - /mswin$ - /mac$ - - - - - - - - From 3d669e3043cefe2f5644813a84b8c362e13d2de4 Mon Sep 17 00:00:00 2001 From: manus Date: Tue, 16 Mar 2010 03:07:44 +0000 Subject: [PATCH 51/64] Moved the experimental branch to be the default for libraries. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@82581 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL-safe.ecf | 93 +++++++++++++++++++++++++++++++++++++++++++ cURL.ecf | 3 ++ curl_easy_externals.e | 6 +-- curl_function.e | 6 +-- curl_opt_constants.e | 39 ++++++++++++++++-- 5 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 cURL-safe.ecf diff --git a/cURL-safe.ecf b/cURL-safe.ecf new file mode 100644 index 00000000..02b15b65 --- /dev/null +++ b/cURL-safe.ecf @@ -0,0 +1,93 @@ + + + + cURL: libcURL wrapper library for Eiffel. + Copyright (c) 1984-2006, Eiffel Software and others. + Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt). + + + /\.svn$ + /EIFGEN.{0,1}$ + /temp$ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /spec$ + /Clib$ + + + /gtk$ + /mac$ + + + + + + /mswin$ + /gtk$ + + + + + + + /mswin$ + /mac$ + + + + + + + + + + + diff --git a/cURL.ecf b/cURL.ecf index 885a50ce..0707e6ec 100644 --- a/cURL.ecf +++ b/cURL.ecf @@ -87,4 +87,7 @@ + + + diff --git a/curl_easy_externals.e b/curl_easy_externals.e index c91ced83..4ba6c0ee 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -202,7 +202,7 @@ feature -- Special setting curl_function: CURL_FUNCTION -- cURL functions in curl_easy_setopt. do - if attached {like curl_function} internal_curl_function as l_curl_function then + if attached internal_curl_function as l_curl_function then Result := l_curl_function else create {CURL_DEFAULT_FUNCTION} Result.make @@ -396,11 +396,11 @@ feature {NONE} -- C externals note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2009, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA + 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com diff --git a/curl_function.e b/curl_function.e index 83ea6d3f..4d61bdc8 100644 --- a/curl_function.e +++ b/curl_function.e @@ -7,7 +7,7 @@ note Note: descendants of this class have to call `set_object_and_function_address', otherwise cURL would not know how to call Eiffel features (such as `write_function'). - See example: $ISE_LIBRARY\examples\cURL\upload_and_read_function + See example: $ISE_LIBRARY\examples\cURL\upload_and_read_function ]" status: "See notice at end of class." legal: "See notice at end of class." @@ -187,11 +187,11 @@ feature {NONE} -- Implementation note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2009, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA + 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com diff --git a/curl_opt_constants.e b/curl_opt_constants.e index b47d8742..8543514d 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -114,6 +114,16 @@ feature -- Enumerations. ]" end + curlopt_cookielist: INTEGER + -- Declared as CURLOPT_COOKIELIST. + external + "C inline use " + alias + "[ + return CURLOPT_COOKIELIST + ]" + end + curlopt_ssl_verifypeer: INTEGER -- Declared as CURLOPT_SSL_VERIFYPEER. external @@ -286,11 +296,32 @@ feature -- Enumerations. ]" end + curlopt_encoding: INTEGER + -- Declared as CURLOPT_ENCODING. + external + "C inline use " + alias + "[ + return CURLOPT_ENCODING; + ]" + end + + curlopt_timeout: INTEGER + -- Declared as CURLOPT_TIMEOUT. + external + "C inline use " + alias + "[ + return CURLOPT_TIMEOUT + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN -- If `a_integer' value valid? do Result := a_integer = curlopt_cookie or a_integer = curlopt_cookiefile or + a_integer = curlopt_cookielist or a_integer = curlopt_debugfunction or a_integer = curlopt_followlocation or a_integer = curlopt_httpheader or @@ -314,16 +345,18 @@ feature -- Enumerations. a_integer = curlopt_put or a_integer = curlopt_readdata or a_integer = curlopt_infilesize_large or - a_integer = curlopt_proxy + a_integer = curlopt_proxy or + a_integer = curlopt_encoding or + a_integer = curlopt_timeout end note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2009, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA + 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com From eb57cb19738cf5ce4885b31f8846d411a7d22321 Mon Sep 17 00:00:00 2001 From: larryl Date: Tue, 8 Jun 2010 03:09:06 +0000 Subject: [PATCH 52/64] Added CURLOPT_CUSTOMREQUEST More info please check: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html Contributed by Javier Hector git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@83453 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 8543514d..c7cd55c8 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -316,6 +316,16 @@ feature -- Enumerations. ]" end + curlopt_customrequest: INTEGER + -- Declared as CURLOPT_CUSTOMREQUEST + external + "C inline use " + alias + "[ + return CURLOPT_CUSTOMREQUEST + ]" + end + is_valid (a_integer: INTEGER): BOOLEAN -- If `a_integer' value valid? do @@ -347,12 +357,13 @@ feature -- Enumerations. a_integer = curlopt_infilesize_large or a_integer = curlopt_proxy or a_integer = curlopt_encoding or - a_integer = curlopt_timeout + a_integer = curlopt_timeout or + a_integer = curlopt_customrequest end note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2009, Eiffel Software and others" + copyright: "Copyright (c) 1984-2010, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From e78d34774e710d5ceee0a903ed796754db26eef2 Mon Sep 17 00:00:00 2001 From: jfiat Date: Thu, 10 Jun 2010 12:31:16 +0000 Subject: [PATCH 53/64] missing curlopt_userpwd case for `is_valid' git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@83514 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 1 + 1 file changed, 1 insertion(+) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index c7cd55c8..54a764d0 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -358,6 +358,7 @@ feature -- Enumerations. a_integer = curlopt_proxy or a_integer = curlopt_encoding or a_integer = curlopt_timeout or + a_integer = curlopt_userpwd or a_integer = curlopt_customrequest end From 3c0d34270499245a15aa4e9b078d08cefaff8e25 Mon Sep 17 00:00:00 2001 From: manus Date: Fri, 11 Jun 2010 23:30:18 +0000 Subject: [PATCH 54/64] Updated to match the new config.sh file used on Windows, so that it can work with MSC (already the case) but also with MinGW on a multiprocessor architecture. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@83539 8089f293-4706-0410-a29e-feb5c42a2edf --- Clib/Makefile-win.SH | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/Clib/Makefile-win.SH b/Clib/Makefile-win.SH index 11f90ca1..9db5fcfc 100644 --- a/Clib/Makefile-win.SH +++ b/Clib/Makefile-win.SH @@ -12,7 +12,8 @@ JILCFLAGS = $(CFLAGS) $mtccflags $optimize -DEIF_IL_DLL LN = copy MV = $mv RM = $del -MKDIR_TARGET = $mkdir_target +MAKE = $make +MKDIR = $mkdir LINK = $link32 DLL_FLAGS = $dll_flags DLL_LIBS = $dll_libs @@ -23,39 +24,29 @@ IL_OBJECTS = ILeiffel_curl.$obj .c.$obj: $(CC) -c $(JCFLAGS) $< -all:: lib_dir $output_libraries clean +all:: $output_libraries + $(MAKE) clean standard:: eiffel_curl.lib ileiffel_curl.lib mtstandard:: mteiffel_curl.lib -..$(DIR)spec: - $(MKDIR_TARGET) - -..$(DIR)spec$(DIR)$(ISE_C_COMPILER): ..$(DIR)spec - $(MKDIR_TARGET) - -..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM): ..$(DIR)spec$(DIR)$(ISE_C_COMPILER) - $(MKDIR_TARGET) - -..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib: ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM) - $(MKDIR_TARGET) - -lib_dir: ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib - clean: $(RM) *.$obj $(RM) *.lib eiffel_curl.lib: $(OBJECTS) $alib_line + $(MKDIR) ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib $(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@ mteiffel_curl.lib: $(MT_OBJECTS) $alib_line + $(MKDIR) ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib $(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@ ileiffel_curl.lib: $(IL_OBJECTS) $alib_line + $(MKDIR) ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib $(MV) $@ ..$(DIR)spec$(DIR)$(ISE_C_COMPILER)$(DIR)$(ISE_PLATFORM)$(DIR)lib$(DIR)$@ #Multithreaded targets. From d0ca77f1041844312ea39a69270efc9a515f98ce Mon Sep 17 00:00:00 2001 From: larryl Date: Tue, 15 Jun 2010 09:23:11 +0000 Subject: [PATCH 55/64] Added `linux-x86' and `linux-x86-64' to SVN ignore list git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@83576 8089f293-4706-0410-a29e-feb5c42a2edf From 3af8d34f0f0fdfba8fefb5201dee604d201192dd Mon Sep 17 00:00:00 2001 From: manus Date: Thu, 13 Jan 2011 23:53:42 +0000 Subject: [PATCH 56/64] * Use READABLE_STRING_GENERAL instead of STRING_GENERAL for routines expecting a string. This enables us to use IMMUTABLE_STRINGs as argument without conversion. * As a consequence we are also now using `same_string' instead of `is_equal' to compare strings which will handle any type of strings. * Enforced the rule that arguments are READABLE_STRING_GENERAL and queries are STRING_32 when unicode is expected. * The most delicate part of the change was the update of the encoding library. Now we have two queries:last_converted_string_32 and last_converted_string_8 in addition of the typeless last_converted_string. The idea is that if you know that you are converting to something where characters are at least 2 bytes wide, you know that you have to use STRING_32, otherwise it will be STRING_8. * Unlike STRING_GENERAL, READABLE_STRING_GENERAL does not have a conversion to STRING_32 and thus in a few places we had to use `as_string_32' for explicit conversion which I found better. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@85350 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_easy_externals.e | 4 ++-- curl_externals.e | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 4ba6c0ee..7ed81eb1 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -29,7 +29,7 @@ feature -- Command exists: Result /= default_pointer end - setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_string: STRING_GENERAL) + setopt_string (a_curl_handle: POINTER; a_opt: INTEGER; a_string: READABLE_STRING_GENERAL) -- Declared as curl_easy_setopt(). require exists: a_curl_handle /= default_pointer @@ -396,7 +396,7 @@ feature {NONE} -- C externals note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2009, Eiffel Software and others" + copyright: "Copyright (c) 1984-2010, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/curl_externals.e b/curl_externals.e index 2474a36c..36a18d0b 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -38,7 +38,7 @@ feature -- Command end end - formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) + formadd_string_string (a_form: CURL_FORM; a_last_pointer: CURL_FORM; a_arg_1: INTEGER; a_arg_1_value: READABLE_STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: READABLE_STRING_GENERAL; a_arg_3: INTEGER) -- Declared as curl_formadd (). require not_void: a_form /= Void @@ -65,7 +65,7 @@ feature -- Command end end - slist_append (a_list: POINTER; a_string: STRING_GENERAL): POINTER + slist_append (a_list: POINTER; a_string: READABLE_STRING_GENERAL): POINTER -- Declared as curl_slist_append (). -- note: call with a null `a_list' to get initialized pointer as Result require @@ -118,7 +118,7 @@ feature {NONE} -- Implementation Result := l_utility.api_loader end - internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: STRING_GENERAL; a_arg_3: INTEGER) + internal_formadd_string_string (a_form: TYPED_POINTER [POINTER]; a_last_pointer: TYPED_POINTER [POINTER]; a_arg_1: INTEGER; a_arg_1_value: READABLE_STRING_GENERAL; a_arg_2: INTEGER; a_arg_2_value: READABLE_STRING_GENERAL; a_arg_3: INTEGER) -- Declared as curl_formadd (). local l_c_string_1, l_c_string_2: C_STRING @@ -212,11 +212,11 @@ feature {NONE} -- C externals note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2010, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA + 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com From 803412368385c6353d1072093d9333282774b1ba Mon Sep 17 00:00:00 2001 From: jfiat Date: Tue, 20 Sep 2011 14:06:20 +0000 Subject: [PATCH 57/64] Added a few missing CURLOPT_ constants Grouped constants by category git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@87244 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 1211 +++++++++++++++++++++++++++++++++--------- 1 file changed, 967 insertions(+), 244 deletions(-) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 54a764d0..6bb67d79 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -2,8 +2,11 @@ note description: "[ libcurl library opt constants For more informaton see: + http://curl.haxx.se/libcurl/c/curl_easy_setopt.html - ]" + + Code related to LIBCURL_VERSION: 7.17.0 + ]" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date$" @@ -12,16 +15,74 @@ note class CURL_OPT_CONSTANTS -feature -- Enumerations. +feature -- Version - curlopt_httpheader: INTEGER - -- Declared as CURLOPT_HTTPHEADER. + libcurl_version: INTEGER + -- Declared as LIBCURL_VERSION + external + "C inline use " + alias + "return LIBCURL_VERSION;" + end + + libcurl_version_major: INTEGER + -- Declared as LIBCURL_VERSION_MAJOR + external + "C inline use " + alias + "return LIBCURL_VERSION_MAJOR;" + end + + libcurl_version_minor: INTEGER + -- Declared as LIBCURL_VERSION_MINOR + external + "C inline use " + alias + "return LIBCURL_VERSION_MINOR;" + end + + libcurl_version_patch: INTEGER + -- Declared as LIBCURL_VERSION_PATCH + external + "C inline use " + alias + "return LIBCURL_VERSION_PATCH;" + end + +feature -- Behavior + + curlopt_verbose: INTEGER + -- Declared as CURLOPT_VERBOSE. external "C inline use " alias - "[ - return CURLOPT_HTTPHEADER; - ]" + "return CURLOPT_VERBOSE;" + end + + curlopt_header: INTEGER + -- Declared as CURLOPT_HEADER. + external + "C inline use " + alias + "return CURLOPT_HEADER;" + end + + curlopt_noprogress: INTEGER + -- Declared as CURLOPT_NOPROGRESS + external + "C inline use " + alias + "return CURLOPT_NOPROGRESS;" + end + +feature -- Callback + + curlopt_writefunction: INTEGER + -- Declared as CURLOPT_WRITEFUNCTION. + external + "C inline use " + alias + "return CURLOPT_WRITEFUNCTION;" end curlopt_writedata: INTEGER @@ -29,19 +90,23 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_WRITEDATA; - ]" + "return CURLOPT_WRITEDATA;" end - curlopt_writeheader: INTEGER - -- Declared as CURLOPT_WRITEHEADER. + curlopt_readfunction: INTEGER + -- Declared as CURLOPT_READFUNCTION. external "C inline use " alias - "[ - return CURLOPT_WRITEHEADER; - ]" + "return CURLOPT_READFUNCTION;" + end + + curlopt_readdata: INTEGER + -- Declared as CURLOPT_READDATA. + external + "C inline use " + alias + "return CURLOPT_READDATA;" end curlopt_debugfunction: INTEGER @@ -49,139 +114,7 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_DEBUGFUNCTION; - ]" - end - - curlopt_followlocation: INTEGER - -- Declared as CURLOPT_FOLLOWLOCATION - external - "C inline use " - alias - "[ - return CURLOPT_FOLLOWLOCATION; - ]" - end - - curlopt_verbose: INTEGER - -- Declared as CURLOPT_VERBOSE. - external - "C inline use " - alias - "[ - return CURLOPT_VERBOSE; - ]" - end - - curlopt_useragent: INTEGER - -- Declared as CURLOPT_USERAGENT. - external - "C inline use " - alias - "[ - return CURLOPT_USERAGENT; - ]" - end - - curlopt_userpwd: INTEGER - -- Declared as CURLOPT_USERPWD. - external - "C inline use " - alias - "[ - return CURLOPT_USERPWD; - ]" - end - - curlopt_url: INTEGER - -- Declared as CURLOPT_URL. - external - "C inline use " - alias - "[ - return CURLOPT_URL; - ]" - end - - curlopt_cookiefile: INTEGER - -- Declared as CURLOPT_COOKIEFILE. - external - "C inline use " - alias - "[ - return CURLOPT_COOKIEFILE; - ]" - end - - curlopt_cookielist: INTEGER - -- Declared as CURLOPT_COOKIELIST. - external - "C inline use " - alias - "[ - return CURLOPT_COOKIELIST - ]" - end - - curlopt_ssl_verifypeer: INTEGER - -- Declared as CURLOPT_SSL_VERIFYPEER. - external - "C inline use " - alias - "[ - return CURLOPT_SSL_VERIFYPEER; - ]" - end - - curlopt_cookie: INTEGER - -- Declared as CURLOPT_COOKIE. - external - "C inline use " - alias - "[ - return CURLOPT_COOKIE; - ]" - end - - curlopt_post: INTEGER - -- Declared as CURLOPT_POST. - external - "C inline use " - alias - "[ - return CURLOPT_POST; - ]" - end - - curlopt_postfields: INTEGER - -- Declared as CURLOPT_POSTFIELDS. - external - "C inline use " - alias - "[ - return CURLOPT_POSTFIELDS; - ]" - end - - curlopt_httppost: INTEGER - -- Declared as CURLOPT_HTTPPOST. - external - "C inline use " - alias - "[ - return CURLOPT_HTTPPOST; - ]" - end - - curlopt_writefunction: INTEGER - -- Declared as CURLOPT_WRITEFUNCTION. - external - "C inline use " - alias - "[ - return CURLOPT_WRITEFUNCTION; - ]" + "return CURLOPT_DEBUGFUNCTION;" end curlopt_progressfunction: INTEGER @@ -189,19 +122,7 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_PROGRESSFUNCTION; - ]" - end - - curlopt_noprogress: INTEGER - -- Declared as CURLOPT_NOPROGRESS - external - "C inline use " - alias - "[ - return CURLOPT_NOPROGRESS; - ]" + "return CURLOPT_PROGRESSFUNCTION;" end curlopt_progressdata: INTEGER @@ -209,9 +130,270 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_PROGRESSDATA; - ]" + "return CURLOPT_PROGRESSDATA;" + end + + curlopt_writeheader: INTEGER + -- Declared as CURLOPT_WRITEHEADER. + external + "C inline use " + alias + "return CURLOPT_WRITEHEADER;" + end + +feature -- Network + + curlopt_url: INTEGER + -- Declared as CURLOPT_URL. + external + "C inline use " + alias + "return CURLOPT_URL;" + end + + curlopt_proxy: INTEGER + -- Declared as CURLOPT_PROXY. + external + "C inline use " + alias + "return CURLOPT_PROXY;" + end + + curlopt_proxyport: INTEGER + -- Declared as CURLOPT_PROXYPORT. + external + "C inline use " + alias + "return CURLOPT_PROXYPORT;" + end + + curlopt_proxytype: INTEGER + -- Declared as CURLOPT_PROXYTYPE. + external + "C inline use " + alias + "return CURLOPT_PROXYTYPE;" + end + + curlopt_httpproxytunnel: INTEGER + -- Declared as CURLOPT_HTTPPROXYTUNNEL. + external + "C inline use " + alias + "return CURLOPT_HTTPPROXYTUNNEL;" + end + + curlopt_interface: INTEGER + -- Declared as CURLOPT_INTERFACE. + external + "C inline use " + alias + "return CURLOPT_INTERFACE;" + end + + curlopt_localport: INTEGER + -- Declared as CURLOPT_LOCALPORT + external + "C inline use " + alias + "return CURLOPT_LOCALPORT;" + end + + curlopt_localportrange: INTEGER + -- Declared as CURLOPT_LOCALPORTRANGE + external + "C inline use " + alias + "return CURLOPT_LOCALPORTRANGE;" + end + + curlopt_buffersize: INTEGER + -- Declared as CURLOPT_BUFFERSIZE + external + "C inline use " + alias + "return CURLOPT_BUFFERSIZE" + end + + curlopt_port: INTEGER + -- Declared as CURLOPT_PORT + external + "C inline use " + alias + "return CURLOPT_PORT;" + end + + curlopt_tcp_nodelay: INTEGER + -- Declared as CURLOPT_TCP_NODELAY + external + "C inline use " + alias + "return CURLOPT_TCP_NODELAY;" + end + +feature -- Names and Passwords (Authentication) + + curlopt_userpwd: INTEGER + -- Declared as CURLOPT_USERPWD. + external + "C inline use " + alias + "return CURLOPT_USERPWD;" + end + + curlopt_proxyuserpwd: INTEGER + -- Declared as CURLOPT_PROXYUSERPWD + external + "C inline use " + alias + "return CURLOPT_PROXYUSERPWD;" + end + + curlopt_httpauth: INTEGER + -- Declared as CURLOPT_HTTPAUTH. + external + "C inline use " + alias + "return CURLOPT_HTTPAUTH;" + end + + curlauth_none: INTEGER + -- Declared as CURLAUTH_NONE. + external + "C inline use " + alias + "return CURLAUTH_NONE;" + end + + curlauth_basic: INTEGER + -- Declared as CURLAUTH_BASIC. + external + "C inline use " + alias + "return CURLAUTH_BASIC;" + end + + curlauth_digest: INTEGER + -- Declared as CURLAUTH_DIGEST. + external + "C inline use " + alias + "return CURLAUTH_DIGEST;" + end + + curlauth_any: INTEGER + -- Declared as CURLAUTH_ANY. + external + "C inline use " + alias + "return CURLAUTH_ANY;" + end + + curlauth_anysafe: INTEGER + -- Declared as CURLAUTH_ANYSAFE. + external + "C inline use " + alias + "return CURLAUTH_ANYSAFE;" + end + + curlopt_proxyauth: INTEGER + -- Declared as CURLOPT_PROXYAUTH + external + "C inline use " + alias + "return CURLOPT_PROXYAUTH;" + end + +feature -- HTTP + + curlopt_autoreferer: INTEGER + -- Declared as CURLOPT_AUTOREFERER + external + "C inline use " + alias + "return CURLOPT_AUTOREFERER;" + end + + curlopt_encoding: INTEGER + -- Declared as CURLOPT_ENCODING. + -- in future version, this is called CURLOPT_ACCEPT_ENCODING + external + "C inline use " + alias + "return CURLOPT_ENCODING;" + end + + curlopt_followlocation: INTEGER + -- Declared as CURLOPT_FOLLOWLOCATION + external + "C inline use " + alias + "return CURLOPT_FOLLOWLOCATION;" + end + + curlopt_unrestricted_auth: INTEGER + -- Declared as CURLOPT_UNRESTRICTED_AUTH + external + "C inline use " + alias + "return CURLOPT_UNRESTRICTED_AUTH;" + end + + curlopt_maxredirs: INTEGER + -- Declared as CURLOPT_MAXREDIRS + external + "C inline use " + alias + "return CURLOPT_MAXREDIRS;" + end + + curlopt_put: INTEGER + -- Declared as CURLOPT_PUT. + external + "C inline use " + alias + "return CURLOPT_PUT;" + end + + curlopt_post: INTEGER + -- Declared as CURLOPT_POST. + external + "C inline use " + alias + "return CURLOPT_POST;" + end + + curlopt_postfields: INTEGER + -- Declared as CURLOPT_POSTFIELDS. + external + "C inline use " + alias + "return CURLOPT_POSTFIELDS;" + end + + curlopt_postfieldsize: INTEGER + -- Declared as CURLOPT_POSTFIELDSIZE + external + "C inline use " + alias + "return CURLOPT_POSTFIELDSIZE;" + end + + curlopt_postfieldsize_large: INTEGER + -- Declared as CURLOPT_POSTFIELDSIZE_LARGE + external + "C inline use " + alias + "return CURLOPT_POSTFIELDSIZE_LARGE;" + end + + curlopt_httppost: INTEGER + -- Declared as CURLOPT_HTTPPOST. + external + "C inline use " + alias + "return CURLOPT_HTTPPOST;" end curlopt_referer: INTEGER @@ -219,9 +401,63 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_REFERER; - ]" + "return CURLOPT_REFERER;" + end + + curlopt_useragent: INTEGER + -- Declared as CURLOPT_USERAGENT. + external + "C inline use " + alias + "return CURLOPT_USERAGENT;" + end + + curlopt_httpheader: INTEGER + -- Declared as CURLOPT_HTTPHEADER. + external + "C inline use " + alias + "return CURLOPT_HTTPHEADER;" + end + + curlopt_cookie: INTEGER + -- Declared as CURLOPT_COOKIE. + external + "C inline use " + alias + "return CURLOPT_COOKIE;" + end + + curlopt_cookiefile: INTEGER + -- Declared as CURLOPT_COOKIEFILE. + external + "C inline use " + alias + "return CURLOPT_COOKIEFILE;" + end + + curlopt_cookiejar: INTEGER + -- Declared as CURLOPT_COOKIEJAR + external + "C inline use " + alias + "return CURLOPT_COOKIEJAR;" + end + + curlopt_cookiesession: INTEGER + -- Declared as CURLOPT_COOKIESESSION + external + "C inline use " + alias + "return CURLOPT_COOKIESESSION;" + end + + curlopt_cookielist: INTEGER + -- Declared as CURLOPT_COOKIELIST. + external + "C inline use " + alias + "return CURLOPT_COOKIELIST" end curlopt_httpget: INTEGER @@ -231,49 +467,97 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_HTTPGET; - ]" + "return CURLOPT_HTTPGET;" end - curlopt_readfunction: INTEGER - -- Declared as CURLOPT_READFUNCTION. + curlopt_http_version: INTEGER + -- Declared as CURLOPT_HTTP_VERSION external "C inline use " alias - "[ - return CURLOPT_READFUNCTION; - ]" + "return CURLOPT_HTTP_VERSION;" end - curlopt_upload: INTEGER - -- Declared as CURLOPT_UPLOAD. + curlopt_ignore_content_length: INTEGER + -- Declared as CURLOPT_IGNORE_CONTENT_LENGTH external "C inline use " alias - "[ - return CURLOPT_UPLOAD; - ]" + "return CURLOPT_IGNORE_CONTENT_LENGTH;" end - curlopt_put: INTEGER - -- Declared as CURLOPT_PUT. + curlopt_http_content_decoding: INTEGER + -- Declared as CURLOPT_HTTP_CONTENT_DECODING external "C inline use " alias - "[ - return CURLOPT_PUT; - ]" + "return CURLOPT_HTTP_CONTENT_DECODING;" end - curlopt_readdata: INTEGER - -- Declared as CURLOPT_READDATA. +feature -- Protocol + + curlopt_transfertext: INTEGER + -- Declared as CURLOPT_TRANSFERTEXT external "C inline use " alias - "[ - return CURLOPT_READDATA; - ]" + "return CURLOPT_TRANSFERTEXT;" + end + + curlopt_crlf: INTEGER + -- Declared as CURLOPT_CRLF + external + "C inline use " + alias + "return CURLOPT_CRLF;" + end + + curlopt_resume_from: INTEGER + -- Declared as CURLOPT_RESUME_FROM + external + "C inline use " + alias + "return CURLOPT_RESUME_FROM;" + end + + curlopt_resume_from_large: INTEGER + -- Declared as CURLOPT_RESUME_FROM_LARGE + external + "C inline use " + alias + "return CURLOPT_RESUME_FROM_LARGE;" + end + + curlopt_customrequest: INTEGER + -- Declared as CURLOPT_CUSTOMREQUEST + external + "C inline use " + alias + "return CURLOPT_CUSTOMREQUEST" + end + + curlopt_filetime: INTEGER + -- Declared as CURLOPT_FILETIME + external + "C inline use " + alias + "return CURLOPT_FILETIME;" + end + + curlopt_nobody: INTEGER + -- Declared as CURLOPT_NOBODY + external + "C inline use " + alias + "return CURLOPT_NOBODY;" + end + + curlopt_infilesize: INTEGER + -- Declared as CURLOPT_INFILESIZE + external + "C inline use " + alias + "return CURLOPT_INFILESIZE;" end curlopt_infilesize_large: INTEGER @@ -281,85 +565,524 @@ feature -- Enumerations. external "C inline use " alias - "[ - return CURLOPT_INFILESIZE_LARGE; - ]" + "return CURLOPT_INFILESIZE_LARGE;" end - curlopt_proxy: INTEGER - -- Declared as CURLOPT_PROXY. + curlopt_upload: INTEGER + -- Declared as CURLOPT_UPLOAD. external "C inline use " alias - "[ - return CURLOPT_PROXY; - ]" + "return CURLOPT_UPLOAD;" end - curlopt_encoding: INTEGER - -- Declared as CURLOPT_ENCODING. + curlopt_maxfilesize: INTEGER + -- Declared as CURLOPT_MAXFILESIZE external "C inline use " alias - "[ - return CURLOPT_ENCODING; - ]" + "return CURLOPT_MAXFILESIZE;" end + curlopt_maxfilesize_large: INTEGER + -- Declared as CURLOPT_MAXFILESIZE_LARGE + external + "C inline use " + alias + "return CURLOPT_MAXFILESIZE_LARGE;" + end + + curlopt_timecondition: INTEGER + -- Declared as CURLOPT_TIMECONDITION + external + "C inline use " + alias + "return CURLOPT_TIMECONDITION;" + end + + curlopt_timevalue: INTEGER + -- Declared as CURLOPT_TIMEVALUE + external + "C inline use " + alias + "return CURLOPT_TIMEVALUE;" + end + +feature -- Connection + curlopt_timeout: INTEGER -- Declared as CURLOPT_TIMEOUT. external "C inline use " alias - "[ - return CURLOPT_TIMEOUT - ]" + "return CURLOPT_TIMEOUT" end - curlopt_customrequest: INTEGER - -- Declared as CURLOPT_CUSTOMREQUEST + curlopt_timeout_ms: INTEGER + -- Declared as CURLOPT_TIMEOUT_MS external "C inline use " alias - "[ - return CURLOPT_CUSTOMREQUEST - ]" + "return CURLOPT_TIMEOUT_MS;" end - is_valid (a_integer: INTEGER): BOOLEAN - -- If `a_integer' value valid? + curlopt_low_speed_limit: INTEGER + -- Declared as CURLOPT_LOW_SPEED_LIMIT + external + "C inline use " + alias + "return CURLOPT_LOW_SPEED_LIMIT;" + end + + curlopt_low_speed_time: INTEGER + -- Declared as CURLOPT_LOW_SPEED_TIME + external + "C inline use " + alias + "return CURLOPT_LOW_SPEED_TIME;" + end + + curlopt_max_send_speed_large: INTEGER + -- Declared as CURLOPT_MAX_SEND_SPEED_LARGE + external + "C inline use " + alias + "return CURLOPT_MAX_SEND_SPEED_LARGE;" + end + + curlopt_max_recv_speed_large: INTEGER + -- Declared as CURLOPT_MAX_RECV_SPEED_LARGE + external + "C inline use " + alias + "return CURLOPT_MAX_RECV_SPEED_LARGE;" + end + + curlopt_maxconnects: INTEGER + -- Declared as CURLOPT_MAXCONNECTS + external + "C inline use " + alias + "return CURLOPT_MAXCONNECTS;" + end + + curlopt_fresh_connect: INTEGER + -- Declared as CURLOPT_FRESH_CONNECT + external + "C inline use " + alias + "return CURLOPT_FRESH_CONNECT;" + end + + curlopt_forbid_reuse: INTEGER + -- Declared as CURLOPT_FORBID_REUSE + external + "C inline use " + alias + "return CURLOPT_FORBID_REUSE;" + end + + curlopt_connecttimeout: INTEGER + -- Declared as CURLOPT_CONNECTTIMEOUT. + external + "C inline use " + alias + "return CURLOPT_CONNECTTIMEOUT" + end + + curlopt_ipresolve: INTEGER + -- Declared as CURLOPT_IPRESOLVE + external + "C inline use " + alias + "return CURLOPT_IPRESOLVE;" + end + + curl_ipresolve_whatever: INTEGER + -- Declared as CURL_IPRESOLVE_WHATEVER + external + "C inline use " + alias + "return CURL_IPRESOLVE_WHATEVER;" + end + + curl_ipresolve_v4: INTEGER + -- Declared as CURL_IPRESOLVE_V4 + external + "C inline use " + alias + "return CURL_IPRESOLVE_V4;" + end + + curl_ipresolve_v6: INTEGER + -- Declared as CURL_IPRESOLVE_V6 + external + "C inline use " + alias + "return CURL_IPRESOLVE_V6;" + end + + curlopt_connect_only: INTEGER + -- Declared as CURLOPT_CONNECT_ONLY + external + "C inline use " + alias + "return CURLOPT_CONNECT_ONLY;" + end + + curlopt_use_ssl: INTEGER + -- Declared as CURLOPT_USE_SSL + external + "C inline use " + alias + "return CURLOPT_USE_SSL;" + end + + curlusessl_none: INTEGER + -- Declared as CURLUSESSL_NONE + external + "C inline use " + alias + "return CURLUSESSL_NONE;" + end + + curlusessl_try: INTEGER + -- Declared as CURLUSESSL_TRY + external + "C inline use " + alias + "return CURLUSESSL_TRY;" + end + + curlusessl_control: INTEGER + -- Declared as CURLUSESSL_CONTROL + external + "C inline use " + alias + "return CURLUSESSL_CONTROL;" + end + + curlusessl_all: INTEGER + -- Declared as CURLUSESSL_ALL + external + "C inline use " + alias + "return CURLUSESSL_ALL;" + end + +feature -- SSL and Security + + curlopt_sslcert: INTEGER + -- Declared as CURLOPT_SSLCERT + external + "C inline use " + alias + "return CURLOPT_SSLCERT;" + end + + curlopt_sslcerttype: INTEGER + -- Declared as CURLOPT_SSLCERTTYPE + external + "C inline use " + alias + "return CURLOPT_SSLCERTTYPE;" + end + + curlopt_sslkey: INTEGER + -- Declared as CURLOPT_SSLKEY + external + "C inline use " + alias + "return CURLOPT_SSLKEY;" + end + + curlopt_sslkeytype: INTEGER + -- Declared as CURLOPT_SSLKEYTYPE + external + "C inline use " + alias + "return CURLOPT_SSLKEYTYPE;" + end + + curlopt_keypasswd: INTEGER + -- Declared as CURLOPT_KEYPASSWD + external + "C inline use " + alias + "return CURLOPT_KEYPASSWD;" + end + + curlopt_sslengine: INTEGER + -- Declared as CURLOPT_SSLENGINE + external + "C inline use " + alias + "return CURLOPT_SSLENGINE;" + end + + curlopt_sslengine_default: INTEGER + -- Declared as CURLOPT_SSLENGINE_DEFAULT + external + "C inline use " + alias + "return CURLOPT_SSLENGINE_DEFAULT;" + end + + curlopt_sslversion: INTEGER + -- Declared as CURLOPT_SSLVERSION + external + "C inline use " + alias + "return CURLOPT_SSLVERSION;" + end + + curl_sslversion_default: INTEGER + -- Declared as CURL_SSLVERSION_DEFAULT + external + "C inline use " + alias + "return CURL_SSLVERSION_DEFAULT;" + end + + curl_sslversion_tlsv1: INTEGER + -- Declared as CURL_SSLVERSION_TLSv1 + external + "C inline use " + alias + "return CURL_SSLVERSION_TLSv1;" + end + + curl_sslversion_sslv2: INTEGER + -- Declared as CURL_SSLVERSION_SSLv2 + external + "C inline use " + alias + "return CURL_SSLVERSION_SSLv2;" + end + + curl_sslversion_sslv3: INTEGER + -- Declared as CURL_SSLVERSION_SSLv3 + external + "C inline use " + alias + "return CURL_SSLVERSION_SSLv3;" + end + + curlopt_ssl_verifypeer: INTEGER + -- Declared as CURLOPT_SSL_VERIFYPEER. + external + "C inline use " + alias + "return CURLOPT_SSL_VERIFYPEER;" + end + + curlopt_cainfo: INTEGER + -- Declared as CURLOPT_CAINFO + external + "C inline use " + alias + "return CURLOPT_CAINFO;" + end + + curlopt_capath: INTEGER + -- Declared as CURLOPT_CAPATH + external + "C inline use " + alias + "return CURLOPT_CAPATH;" + end + + curlopt_ssl_verifyhost: INTEGER + -- Declared as CURLOPT_SSL_VERIFYHOST + external + "C inline use " + alias + "return CURLOPT_SSL_VERIFYHOST;" + end + + curlopt_random_file: INTEGER + -- Declared as CURLOPT_RANDOM_FILE + external + "C inline use " + alias + "return CURLOPT_RANDOM_FILE;" + end + + curlopt_egdsocket: INTEGER + -- Declared as CURLOPT_EGDSOCKET + external + "C inline use " + alias + "return CURLOPT_EGDSOCKET;" + end + + curlopt_ssl_cipher_list: INTEGER + -- Declared as CURLOPT_SSL_CIPHER_LIST + external + "C inline use " + alias + "return CURLOPT_SSL_CIPHER_LIST;" + end + + curlopt_ssl_sessionid_cache: INTEGER + -- Declared as CURLOPT_SSL_SESSIONID_CACHE + external + "C inline use " + alias + "return CURLOPT_SSL_SESSIONID_CACHE;" + end + + curlopt_krblevel: INTEGER + -- Declared as CURLOPT_KRBLEVEL + external + "C inline use " + alias + "return CURLOPT_KRBLEVEL;" + end + +feature -- SSH + + curlopt_ssh_auth_types: INTEGER + -- Declared as CURLOPT_SSH_AUTH_TYPES + external + "C inline use " + alias + "return CURLOPT_SSH_AUTH_TYPES;" + end + + curlopt_ssh_public_keyfile: INTEGER + -- Declared as CURLOPT_SSH_PUBLIC_KEYFILE + external + "C inline use " + alias + "return CURLOPT_SSH_PUBLIC_KEYFILE;" + end + + curlopt_ssh_private_keyfile: INTEGER + -- Declared as CURLOPT_SSH_PRIVATE_KEYFILE + external + "C inline use " + alias + "return CURLOPT_SSH_PRIVATE_KEYFILE;" + end + +feature -- Status report + + is_valid (v: INTEGER): BOOLEAN + -- If `v' value valid? do - Result := a_integer = curlopt_cookie or - a_integer = curlopt_cookiefile or - a_integer = curlopt_cookielist or - a_integer = curlopt_debugfunction or - a_integer = curlopt_followlocation or - a_integer = curlopt_httpheader or - a_integer = curlopt_httppost or - a_integer = curlopt_post or - a_integer = curlopt_postfields or - a_integer = curlopt_ssl_verifypeer or - a_integer = curlopt_url or - a_integer = curlopt_useragent or - a_integer = curlopt_verbose or - a_integer = curlopt_writedata or - a_integer = curlopt_writeheader or - a_integer = curlopt_writefunction or - a_integer = curlopt_progressfunction or - a_integer = curlopt_progressdata or - a_integer = curlopt_noprogress or - a_integer = curlopt_referer or - a_integer = curlopt_httpget or - a_integer = curlopt_readfunction or - a_integer = curlopt_upload or - a_integer = curlopt_put or - a_integer = curlopt_readdata or - a_integer = curlopt_infilesize_large or - a_integer = curlopt_proxy or - a_integer = curlopt_encoding or - a_integer = curlopt_timeout or - a_integer = curlopt_userpwd or - a_integer = curlopt_customrequest + Result := v = curlopt_verbose or + v = curlopt_header or + v = curlopt_noprogress or + v = curlopt_writefunction or + v = curlopt_writedata or + v = curlopt_readfunction or + v = curlopt_readdata or + v = curlopt_debugfunction or + v = curlopt_progressfunction or + v = curlopt_progressdata or + v = curlopt_writeheader or + v = curlopt_url or + v = curlopt_proxy or + v = curlopt_proxyport or + v = curlopt_proxytype or + v = curlopt_httpproxytunnel or + v = curlopt_interface or + v = curlopt_localport or + v = curlopt_localportrange or + v = curlopt_buffersize or + v = curlopt_port or + v = curlopt_tcp_nodelay or + v = curlopt_userpwd or + v = curlopt_proxyuserpwd or + v = curlopt_httpauth or + v = curlauth_none or + v = curlauth_basic or + v = curlauth_digest or + v = curlauth_any or + v = curlauth_anysafe or + v = curlopt_proxyauth or + v = curlopt_autoreferer or + v = curlopt_encoding or + v = curlopt_followlocation or + v = curlopt_unrestricted_auth or + v = curlopt_maxredirs or + v = curlopt_put or + v = curlopt_post or + v = curlopt_postfields or + v = curlopt_postfieldsize or + v = curlopt_postfieldsize_large or + v = curlopt_httppost or + v = curlopt_referer or + v = curlopt_useragent or + v = curlopt_httpheader or + v = curlopt_cookie or + v = curlopt_cookiefile or + v = curlopt_cookiejar or + v = curlopt_cookiesession or + v = curlopt_cookielist or + v = curlopt_httpget or + v = curlopt_http_version or + v = curlopt_ignore_content_length or + v = curlopt_http_content_decoding or + v = curlopt_transfertext or + v = curlopt_crlf or + v = curlopt_resume_from or + v = curlopt_resume_from_large or + v = curlopt_customrequest or + v = curlopt_filetime or + v = curlopt_nobody or + v = curlopt_infilesize or + v = curlopt_infilesize_large or + v = curlopt_upload or + v = curlopt_maxfilesize or + v = curlopt_maxfilesize_large or + v = curlopt_timecondition or + v = curlopt_timevalue or + v = curlopt_timeout or + v = curlopt_timeout_ms or + v = curlopt_low_speed_limit or + v = curlopt_low_speed_time or + v = curlopt_max_send_speed_large or + v = curlopt_max_recv_speed_large or + v = curlopt_maxconnects or + v = curlopt_fresh_connect or + v = curlopt_forbid_reuse or + v = curlopt_connecttimeout or + v = curlopt_ipresolve or + v = curl_ipresolve_whatever or + v = curl_ipresolve_v4 or + v = curl_ipresolve_v6 or + v = curlopt_connect_only or + v = curlopt_use_ssl or + v = curlusessl_none or + v = curlusessl_try or + v = curlusessl_control or + v = curlusessl_all or + v = curlopt_sslcert or + v = curlopt_sslcerttype or + v = curlopt_sslkey or + v = curlopt_sslkeytype or + v = curlopt_keypasswd or + v = curlopt_sslengine or + v = curlopt_sslengine_default or + v = curlopt_sslversion or + v = curl_sslversion_default or + v = curl_sslversion_tlsv1 or + v = curl_sslversion_sslv2 or + v = curl_sslversion_sslv3 or + v = curlopt_ssl_verifypeer or + v = curlopt_cainfo or + v = curlopt_capath or + v = curlopt_ssl_verifyhost or + v = curlopt_random_file or + v = curlopt_egdsocket or + v = curlopt_ssl_cipher_list or + v = curlopt_ssl_sessionid_cache or + v = curlopt_krblevel or + v = curlopt_ssh_auth_types or + v = curlopt_ssh_public_keyfile or + v = curlopt_ssh_private_keyfile end note From 19637b616b5edfdd99c6a0bc9a70656597362eb8 Mon Sep 17 00:00:00 2001 From: jfiat Date: Tue, 27 Sep 2011 08:06:20 +0000 Subject: [PATCH 58/64] Be sure to set the Result /= 0 (i.e ECURLE_OK) when error occurred. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@87340 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_codes.e | 5 +++++ curl_easy_externals.e | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/curl_codes.e b/curl_codes.e index e3627cbc..d9b320ed 100644 --- a/curl_codes.e +++ b/curl_codes.e @@ -11,6 +11,11 @@ note class CURL_CODES +feature -- Eiffel cURL: Constants + + eiffelcurle_error_occurred: INTEGER = -1 + -- Error occurred in Eiffel cURL internals + feature -- Constants curle_ok: INTEGER = 0 diff --git a/curl_easy_externals.e b/curl_easy_externals.e index 7ed81eb1..5fb94d9a 100644 --- a/curl_easy_externals.e +++ b/curl_easy_externals.e @@ -116,9 +116,9 @@ feature -- Command l_api := api_loader.api_pointer ("curl_easy_perform") if l_api /= default_pointer then Result := c_perform (l_api, a_curl_handle) + else + Result := {CURL_CODES}.eiffelcurle_error_occurred end - ensure - valid: end cleanup (a_curl_handle: POINTER) From f17f785ee36db5b424ce40dfcd7bbd41924613bc Mon Sep 17 00:00:00 2001 From: larryl Date: Tue, 25 Oct 2011 08:03:57 +0000 Subject: [PATCH 59/64] Added simple readme file to cURL library. It tells user the cURL library need 3 DLLs to work. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@87608 8089f293-4706-0410-a29e-feb5c42a2edf --- readme.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 readme.txt diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..aaf6c644 --- /dev/null +++ b/readme.txt @@ -0,0 +1,5 @@ +When your Eiffel executable running, Eiffel cURL library needs 3 DLLs, they are: + +libcurl.dll, libeay32.dll and ssleay32.dll + +Please make sure the 3 DLLs files can be found in your environment PATH or in same folder of your executable. \ No newline at end of file From 2b7043f670f6efc70ebed5fbf62d83a22c095ffe Mon Sep 17 00:00:00 2001 From: jfiat Date: Mon, 28 Nov 2011 08:21:54 +0000 Subject: [PATCH 60/64] Fixed bug#18008: Function {CURL_OPT_CONSTANTS}.libcurl_version has wrong type git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@88050 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_opt_constants.e | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 6bb67d79..7adb0ea8 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -17,8 +17,14 @@ class feature -- Version - libcurl_version: INTEGER - -- Declared as LIBCURL_VERSION + libcurl_version: STRING + -- String representation of LIBCURL_VERSION + do + create Result.make_from_c (libcurl_version_pointer) + end + + libcurl_version_pointer: POINTER + -- String pointer declared as LIBCURL_VERSION external "C inline use " alias @@ -65,7 +71,7 @@ feature -- Behavior "C inline use " alias "return CURLOPT_HEADER;" - end + end curlopt_noprogress: INTEGER -- Declared as CURLOPT_NOPROGRESS @@ -527,7 +533,7 @@ feature -- Protocol alias "return CURLOPT_RESUME_FROM_LARGE;" end - + curlopt_customrequest: INTEGER -- Declared as CURLOPT_CUSTOMREQUEST external @@ -697,7 +703,7 @@ feature -- Connection alias "return CURLOPT_IPRESOLVE;" end - + curl_ipresolve_whatever: INTEGER -- Declared as CURL_IPRESOLVE_WHATEVER external @@ -940,7 +946,7 @@ feature -- SSL and Security "return CURLOPT_KRBLEVEL;" end -feature -- SSH +feature -- SSH curlopt_ssh_auth_types: INTEGER -- Declared as CURLOPT_SSH_AUTH_TYPES @@ -1087,7 +1093,7 @@ feature -- Status report note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2010, Eiffel Software and others" + copyright: "Copyright (c) 1984-2011, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From 1ab383268510b78dc63ece4f41360151671fdcb6 Mon Sep 17 00:00:00 2001 From: manus Date: Fri, 20 Jan 2012 16:35:05 +0000 Subject: [PATCH 61/64] Removed the ECF bounds license file and replaced them with `license.lic' files. Made sure all license are the Eiffel Forum License 2. git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@88213 8089f293-4706-0410-a29e-feb5c42a2edf --- cURL.lic | 1 - cURL-safe.lic => license.lic | 0 2 files changed, 1 deletion(-) delete mode 100644 cURL.lic rename cURL-safe.lic => license.lic (100%) diff --git a/cURL.lic b/cURL.lic deleted file mode 100644 index c929225f..00000000 --- a/cURL.lic +++ /dev/null @@ -1 +0,0 @@ -reference:forum2 diff --git a/cURL-safe.lic b/license.lic similarity index 100% rename from cURL-safe.lic rename to license.lic From ad2a498fc067926713ffdc0a9db99358f142fada Mon Sep 17 00:00:00 2001 From: larryl Date: Tue, 14 Feb 2012 02:52:03 +0000 Subject: [PATCH 62/64] Added cURL multi interface support (most APIs) issue#7305157 The multi interface offers several abilities that the easy interface doesn't. They are mainly: 1. Enable a "pull" interface. The application that uses libcurl decides where and when to ask libcurl to get/send data. 2. Enable multiple simultaneous transfers in the same thread without making it complicated for the application. 3. Enable the application to wait for action on its own file descriptors and curl's file descriptors simultaneous easily. More info: http://curl.haxx.se/libcurl/c/libcurl-multi.html git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@88299 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_msg.e | 51 +++++++++ curl_msg_struct.e | 83 ++++++++++++++ curl_multi_codes.e | 48 ++++++++ curl_multi_externals.e | 251 +++++++++++++++++++++++++++++++++++++++++ curl_opt_constants.e | 13 ++- 5 files changed, 445 insertions(+), 1 deletion(-) create mode 100644 curl_msg.e create mode 100644 curl_msg_struct.e create mode 100644 curl_multi_codes.e create mode 100644 curl_multi_externals.e diff --git a/curl_msg.e b/curl_msg.e new file mode 100644 index 00000000..3a318a81 --- /dev/null +++ b/curl_msg.e @@ -0,0 +1,51 @@ +note + description: "[ + C CURLMSG enum + ]" + date: "$Date$" + revision: "$Revision$" + +class + CURL_MSG + +feature -- Query + + curlmsg_done: INTEGER + -- Declared as CURLMSG_DONE. + -- This easy handle has completed. + -- 'result' contains the CURLcode of the transfer + external + "C inline use " + alias + "return CURLMSG_DONE;" + end + + curlmsg_none: INTEGER + -- Declared as CURLMSG_NONE. + -- First, not used + external + "C inline use " + alias + "return CURLMSG_NONE;" + end + + curlmsg_last: INTEGER + -- Declared as CURLMSG_LAST. + -- Last, not used + external + "C inline use " + alias + "return CURLMSG_LAST;" + end + +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/curl_msg_struct.e b/curl_msg_struct.e new file mode 100644 index 00000000..b5e618a1 --- /dev/null +++ b/curl_msg_struct.e @@ -0,0 +1,83 @@ +note + description: "[ + + C Struct CURLMsg wrapper + Read multi stack informationals + + This class is used by {CURL_MSG_STRUCT}.info_read + + More info: + http://curl.haxx.se/libcurl/c/curl_multi_info_read.html + ]" + date: "$Date$" + revision: "$Revision$" + +class + CURL_MSG_STRUCT + +create + make + +feature {NONE} -- Initialization + + make (a_pointer: POINTER) + -- Creation method + -- Bind message structure to the address `a_pointer'". + require + not_default: a_pointer /= default_pointer + do + item := a_pointer + ensure + set: item = a_pointer + end + +feature -- Query + + curl_handle: POINTER + -- CURL easy_handle + -- The handle it concerns + do + Result := c_curl_handle (item) + end + + msg: INTEGER + -- What does this message mean? + -- It's one value from {CURLMSG} + do + Result := c_msg (item) + end + +feature {NONE} -- Implementation + + item: POINTER + -- C struct item + +feature {NONE} -- C externals + + c_curl_handle (a_item: POINTER): POINTER + -- cURL easy handle it concerns + external + "C inline use " + alias + "return (CURL *)((CURLMsg *)$a_item)->easy_handle;" + end + + c_msg (a_item: POINTER): INTEGER + -- Get msg + external + "C inline use " + alias + "return (CURLMSG)((CURLMsg *)$a_item)->msg;" + end + +;note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/curl_multi_codes.e b/curl_multi_codes.e new file mode 100644 index 00000000..44951a36 --- /dev/null +++ b/curl_multi_codes.e @@ -0,0 +1,48 @@ +note + description: "[ + The generic return code used by functions in the libcurl multi interface. + Also consider curl_multi_strerror(3). + ]" + date: "$Date$" + revision: "$Revision$" + +class + CURL_MULTI_CODES + +feature -- Query + + curlm_call_multi_perform: INTEGER = -1 + -- This is not really an error. It means you should call curl_multi_perform(3) again without doing select() or similar in between. + + curlm_ok: INTEGER = 0 + -- Things are fine. + + curlm_bad_handle: INTEGER = 1 + -- The passed-in handle is not a valid CURLM handle. + + curlm_bad_easy_handle: INTEGER = 2 + -- An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle. + + curlm_out_of_memory: INTEGER = 3 + -- You are doomed. + + curlm_internal_error: INTEGER = 4 + -- This can only be returned if libcurl bugs. Please report it to us! + + curlm_bad_socket: INTEGER = 5 + -- The passed-in socket is not a valid one that libcurl already knows about. (Added in 7.15.4) + + curlm_unknown_option: INTEGER = 6 + -- curl_multi_setopt() with unsupported option (Added in 7.15.4) + +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/curl_multi_externals.e b/curl_multi_externals.e new file mode 100644 index 00000000..2ee944b0 --- /dev/null +++ b/curl_multi_externals.e @@ -0,0 +1,251 @@ +note + description: "[ + The multi interface offers several abilities that the easy interface doesn't. They are mainly: + 1. Enable a "pull" interface. The application that uses libcurl decides where and when to ask libcurl to get/send data. + 2. Enable multiple simultaneous transfers in the same thread without making it complicated for the application. + 3. Enable the application to wait for action on its own file descriptors and curl's file descriptors simultaneous easily. + + More info: http://curl.haxx.se/libcurl/c/libcurl-multi.html + ]" + date: "$Date$" + revision: "$Revision$" + +class + CURL_MULTI_EXTERNALS + +feature -- Command + + init + -- Create a multi handle. + -- If success, Result is a cURL multi hanlde just created. + -- This feature maybe failed in some cases: cannot find required DLL, etc. + -- Then the post condition would be violated. + require + dynamic_library_exists: is_dynamic_library_exists + local + l_api: POINTER + do + l_api := api_loader.api_pointer ("curl_multi_init") + if l_api /= default_pointer then + item := c_init (l_api) + end + end + + add_handle (a_easy_handle: POINTER) + -- Add an easy handle to a multi session. + require + dynamic_library_exists: is_dynamic_library_exists + is_multi_handle_exists: is_exists + local + l_api: POINTER + do + l_api := api_loader.api_pointer ("curl_multi_add_handle") + if l_api /= default_pointer then + c_add_handle (l_api, item, a_easy_handle) + end + end + + remove_handle (a_easy_handle: POINTER) + -- Remove an easy handle from a multi session. + require + dynamic_library_exists: is_dynamic_library_exists + is_multi_handle_exists: is_exists + local + l_api: POINTER + do + l_api := api_loader.api_pointer ("curl_multi_remove_handle") + if l_api /= default_pointer then + c_remove_handle (l_api, item, a_easy_handle) + end + end + + cleanup: INTEGER + -- Close down a multi session. + -- Result is one value from {CURL_MULTI_CODES}. + require + dynamic_library_exists: is_dynamic_library_exists + is_multi_handle_exists: is_exists + local + l_api: POINTER + do + l_api := api_loader.api_pointer ("curl_multi_cleanup") + if l_api /= default_pointer then + Result := c_cleanup (l_api, item) + end + end + + perform (a_running_handle: CELL [INTEGER]): INTEGER + -- Reads/writes available data from each easy handle. + -- Result is one value from {CURL_MULTI_CODES}. + require + dynamic_library_exists: is_dynamic_library_exists + is_multi_handle_exists: is_exists + local + l_api: POINTER + l_running_handle: INTEGER + do + l_api := api_loader.api_pointer ("curl_multi_perform") + if l_api /= default_pointer then + Result := c_perform (l_api, item, $l_running_handle) + a_running_handle.put (l_running_handle) + end + end + + info_read (a_msgs_in_queue: CELL [INTEGER]): POINTER + -- Read multi stack informationals. + -- The result is C struct CURLMsg {CURL_MSG_STRUCT}. + -- Repeated calls to this function will return a new struct each time, until a NULL + -- is returned as a signal that there is no more to get at this point. The integer + -- pointed to with msgs_in_queue will contain the number of remaining messages after + -- this function was called. + -- When you fetch a message using this function, it is removed from the internal queue + -- so calling this function again will not return the same message again. It will instead + -- return new messages at each new invoke until the queue is emptied. + require + dynamic_library_exists: is_dynamic_library_exists + is_multi_handle_exists: is_exists + local + l_api: POINTER + l_msgs_in_queue: INTEGER + do + l_api := api_loader.api_pointer ("curl_multi_info_read") + if l_api /= default_pointer then + Result := c_info_read (l_api, item, $l_msgs_in_queue) + a_msgs_in_queue.put (l_msgs_in_queue) + end + end + + is_dynamic_library_exists: BOOLEAN + -- Are required .dll/.so files available? + do + Result := api_loader.is_interface_usable + end + +-- Feature not yet wrapped/tested +-- curl_multi_assign +-- curl_multi_fdset +-- curl_multi_setopt +-- curl_multi_socket +-- curl_multi_socket_action +-- curl_multi_strerror +-- curl_multi_timeout + +feature -- Query + + is_exists: BOOLEAN + -- If C pointer exists? + do + Result := item /= default_pointer + end + +feature {NONE} -- Implementation + + item: POINTER + -- C pointer item for cURL multi + +feature {NONE} -- C externals + + c_init (a_api: POINTER): POINTER + -- Declared as curl_multi_init (). + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURLM *, ()) $a_api)(); + ]" + end + + c_cleanup (a_api: POINTER; a_multi_handle: POINTER): INTEGER + -- Declared as curl_multi_cleanup (). + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURLMcode, (CURLM *)) $a_api) + ((CURLM *)$a_multi_handle); + ]" + end + + c_add_handle (a_api: POINTER; a_multi_handle: POINTER; a_easy_handle: POINTER) + -- Declared as curl_multi_add_handle (). + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void, (CURLM *, CURL *)) $a_api) + ((CURLM *) $a_multi_handle, + (CURL *) $a_easy_handle); + ]" + end + + c_remove_handle (a_api: POINTER; a_multi_handle: POINTER; a_easy_handle: POINTER) + -- Declared as curl_multi_remove_handle (). + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void, (CURLM *, CURL *)) $a_api) + ((CURLM *) $a_multi_handle, + (CURL *) $a_easy_handle); + ]" + end + + c_perform (a_api: POINTER; a_multi_handle: POINTER; a_running_handles: TYPED_POINTER [INTEGER]): INTEGER + -- Declared as curl_multi_perform. + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURLMcode, (CURLM *, int *)) $a_api) + ((CURLM *) $a_multi_handle, + (int *) $a_running_handles); + ]" + end + + c_info_read (a_api: POINTER; a_multi_handle: POINTER; a_msgs_in_queue: TYPED_POINTER [INTEGER]): POINTER + -- Declared as curl_multi_info_read. + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + return (FUNCTION_CAST(CURLMsg *, (CURLM *, int *)) $a_api) + ((CURLM *) $a_multi_handle, + (int *) $a_msgs_in_queue); + ]" + end + +feature {NONE} -- Implementation + + api_loader: DYNAMIC_MODULE + -- Module name. + local + l_utility: CURL_UTILITY + once + create l_utility + Result := l_utility.api_loader + end + + +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/curl_opt_constants.e b/curl_opt_constants.e index 7adb0ea8..372e3f27 100644 --- a/curl_opt_constants.e +++ b/curl_opt_constants.e @@ -624,6 +624,17 @@ feature -- Connection "return CURLOPT_TIMEOUT" end + curlopt_connect_timeout: INTEGER + -- The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. + -- Declared as CURLOPT_CONNECTTIMEOUT + external + "C inline use " + alias + "[ + return CURLOPT_CONNECTTIMEOUT + ]" + end + curlopt_timeout_ms: INTEGER -- Declared as CURLOPT_TIMEOUT_MS external @@ -1093,7 +1104,7 @@ feature -- Status report note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From 081392529cb1f1518a23881f253aa4b285232734 Mon Sep 17 00:00:00 2001 From: jfiat Date: Tue, 13 Mar 2012 17:36:43 +0000 Subject: [PATCH 63/64] Better use C_STRING.substring (1, size) instead of C_STRING.string since we know the exact size and this way, no risk with \0 character inside the string itself (for binary data..) Added comments git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@88401 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_default_function.e | 16 ++++------ curl_function.e | 65 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/curl_default_function.e b/curl_default_function.e index 111011b8..01c1c540 100644 --- a/curl_default_function.e +++ b/curl_default_function.e @@ -27,24 +27,19 @@ feature {NONE} -- Initialization feature -- Command progress_function (a_object_id: POINTER; a_download_total, a_download_now, a_upload_total, a_upload_now: REAL_64): INTEGER - -- Redefine do end write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER - -- Redefine local l_c_string: C_STRING - l_identified: IDENTIFIED do + -- Returns the number of bytes actually saved into object identified by `a_object_id' Result := a_size * a_nmemb create l_c_string.make_shared_from_pointer_and_count (a_data_pointer, Result) - create l_identified - if attached {CURL_STRING} l_identified.id_object (a_object_id.to_integer_32) as l_string then - l_string.append (l_c_string.string) - else - check False end + check attached {CURL_STRING} (create {IDENTIFIED}).id_object (a_object_id.to_integer_32) as l_string then + l_string.append (l_c_string.substring (1, Result)) end end @@ -54,7 +49,6 @@ feature -- Command end debug_function (a_curl_handle: POINTER; a_curl_infotype: INTEGER; a_char_pointer: POINTER; a_size: INTEGER; a_object_id: POINTER): INTEGER - -- Redefine local l_c_string: C_STRING do @@ -97,11 +91,11 @@ feature {NONE} -- Implementation note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2006, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software - 356 Storke Road, Goleta, CA 93117 USA + 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com diff --git a/curl_function.e b/curl_function.e index 4d61bdc8..f5790214 100644 --- a/curl_function.e +++ b/curl_function.e @@ -8,7 +8,9 @@ note Note: descendants of this class have to call `set_object_and_function_address', otherwise cURL would not know how to call Eiffel features (such as `write_function'). See example: $ISE_LIBRARY\examples\cURL\upload_and_read_function - ]" + + See http://curl.haxx.se/libcurl/c/curl_easy_setopt.html for libcurl documentation + ]" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date$" @@ -116,16 +118,71 @@ feature -- cURL curl_easy_setopt functions end write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER - -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_writefunction + -- Function called by libcurl as soon as there is data received that needs to be saved. + -- The size of the data pointed to by `a_data_pointer' is `a_size' multiplied with `a_nmemb', it will not be null terminated. + -- Returns the number of bytes actually taken care of + -- + -- Function corresponds to {CURL_OPT_CONSTANTS}.curlopt_writefunction -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which -- may changed during GC. + --| libcurl doc: + --| Function pointer that should match the following prototype: size_t function( char *ptr, size_t size, size_t nmemb, void *userdata); + --| This function gets called by libcurl as soon as there is data received that needs to be saved. + --| The size of the data pointed to by ptr is size multiplied with nmemb, it will not be zero terminated. + --| Return the number of bytes actually taken care of. + --| If that amount differs from the amount passed to your function, it'll signal an error to the library. + --| This will abort the transfer and return CURLE_WRITE_ERROR. + --| From 7.18.0, the function can return CURL_WRITEFUNC_PAUSE which then will cause writing to this connection to become paused. + --| See curl_easy_pause(3) for further details. + --| + --| This function may be called with zero bytes data if the transferred file is empty. + --| + --| Set this option to NULL to get the internal default function. + --| The internal default function will write the data to the FILE * given with CURLOPT_WRITEDATA. + --| + --| Set the userdata argument with the CURLOPT_WRITEDATA option. + --| + --| The callback function will be passed as much data as possible in all invokes, + --| but you cannot possibly make any assumptions. It may be one byte, it may be thousands. + --| The maximum amount of body data that can be passed to the write callback is defined + --| in the curl.h header file: CURL_MAX_WRITE_SIZE (the usual default is 16K). + --| If you however have CURLOPT_HEADER set, which sends header data to the write callback, + --| you can get up to CURL_MAX_HTTP_HEADER bytes of header data passed into it. This usually means 100K. deferred end read_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER - -- Function correspond to {CURL_OPT_CONSTANTS}.curlopt_readfunction + -- Function called by libcurl as soon as it needs to read data in order to send it to the peer. + -- The data area pointed at by the pointer `a_data_pointer' may be filled with at most + -- `a_size' multiplied with `a_nmemb' number of bytes. + -- Returns the actual number of bytes stored in that memory area. + -- Returning 0 will signal end-of-file to the library and cause it to stop the current transfer. + -- + -- Function corresponds to {CURL_OPT_CONSTANTS}.curlopt_readfunction -- Note, pass a {IDENTIFIED}.object_id as `a_object_id' value is helpful since we can't directly pass an Eiffel Object address which -- may changed during GC. + --| libcurl doc: + --| Function pointer that should match the following prototype: size_t function( void *ptr, size_t size, size_t nmemb, void *userdata); + --| This function gets called by libcurl as soon as it needs to read data in order to send it to the peer. + --| The data area pointed at by the pointer ptr may be filled with at most size multiplied with nmemb number of bytes. + --| Your function must return the actual number of bytes that you stored in that memory area. + --| Returning 0 will signal end-of-file to the library and cause it to stop the current transfer. + --| + --| If you stop the current transfer by returning 0 "pre-maturely" (i.e before the server expected it, + --| like when you've said you will upload N bytes and you upload less than N bytes), + --| you may experience that the server "hangs" waiting for the rest of the data that won't come. + --| + --| The read callback may return CURL_READFUNC_ABORT to stop the current operation immediately, + --| resulting in a CURLE_ABORTED_BY_CALLBACK error code from the transfer (Added in 7.12.1) + --| + --| From 7.18.0, the function can return CURL_READFUNC_PAUSE which then will cause reading from this connection to become paused. + --| See curl_easy_pause(3) for further details. + --| + --| Bugs: when doing TFTP uploads, you must return the exact amount of data that the callback wants, + --| or it will be considered the final packet by the server end and the transfer will end there. + --| + --| If you set this callback pointer to NULL, or don't set it at all, the default internal read function will be used. + --| It is doing an fread() on the FILE * userdata set with CURLOPT_READDATA. deferred end @@ -187,7 +244,7 @@ feature {NONE} -- Implementation note library: "cURL: Library of reusable components for Eiffel." - copyright: "Copyright (c) 1984-2009, Eiffel Software and others" + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From c4e25a309132a7adced96f5ac1e278eb44582945 Mon Sep 17 00:00:00 2001 From: jfiat Date: Wed, 2 May 2012 19:58:42 +0000 Subject: [PATCH 64/64] Added {CURL_EXTERNALS}.slist_free_all review#7828040 git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@88674 8089f293-4706-0410-a29e-feb5c42a2edf --- curl_externals.e | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/curl_externals.e b/curl_externals.e index 36a18d0b..1843e6e6 100644 --- a/curl_externals.e +++ b/curl_externals.e @@ -81,6 +81,22 @@ feature -- Command end end + slist_free_all (a_curl_slist: POINTER) + -- Declared as curl_slist_free_all (). + -- See: http://curl.haxx.se/libcurl/c/curl_slist_free_all.html + -- curl_slist_free_all - free an entire curl_slist list + -- This must be called when the data has been used, which typically means after the curl_easy_perform(3) has been called. + require + exists: a_curl_slist /= default_pointer + local + l_api: POINTER + do + l_api := api_loader.api_pointer ("curl_slist_free_all") + if l_api /= default_pointer then + c_slist_free_all (l_api, a_curl_slist) + end + end + feature -- Query is_dynamic_library_exists: BOOLEAN @@ -209,6 +225,19 @@ feature {NONE} -- C externals } ]" end + + c_slist_free_all (a_api: POINTER; a_list_pointer: POINTER) + -- Declared as void curl_slist_free_all(struct curl_slist * list) + require + exists: a_api /= default_pointer + external + "C inline use " + alias + "[ + (FUNCTION_CAST(void *, (struct curl_slist *)) $a_api) + ((struct curl_slist *)$a_list_pointer); + ]" + end note library: "cURL: Library of reusable components for Eiffel."