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
This commit is contained in:
larryl
2007-10-22 08:22:30 +00:00
commit a99db5fd43
17 changed files with 3676 additions and 0 deletions

44
cURL.ecf Normal file
View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-2-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-2-0 http://www.eiffel.com/developers/xml/configuration-1-2-0.xsd" name="cURL" uuid="D51EF190-6157-4B47-8E73-FA93DCBB7A71" library_target="cURL">
<target name="cURL">
<description>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).</description>
<root all_classes="true"/>
<file_rule>
<exclude>/\.svn$</exclude>
<exclude>/EIFGEN.{0,1}$</exclude>
<exclude>/temp$</exclude>
</file_rule>
<option warning="true" namespace="EiffelSoftware.Library">
</option>
<setting name="dotnet_naming_convention" value="true"/>
<external_include location="$(ISE_LIBRARY)\library\cURL\spec\include">
<condition>
<platform value="windows"/>
</condition>
</external_include>
<external_include location="$(ISE_LIBRARY)/library/cURL/spec/include">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_include>
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$ISE_C_COMPILER\$ISE_PLATFORM\lib\libcurl_imp.lib">
<condition>
<platform value="windows"/>
<multithreaded value="true"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$ISE_LIBRARY\library\cURL\spec\$ISE_C_COMPILER\$ISE_PLATFORM\lib\ilvision2.lib">
<condition>
<platform value="windows"/>
<dotnet value="true"/>
</condition>
</external_object>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<cluster name="cURL" location=".\"/>
</target>
</system>

331
curl_codes.e Normal file
View File

@@ -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

167
curl_easy_externals.e Normal file
View File

@@ -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 <curl/curl.h>"
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 <curl/curl.h>"
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 <curl/curl.h>"
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 <curl/curl.h>"
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 <curl/curl.h>"
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 <curl/curl.h>"
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

151
curl_externals.e Normal file
View File

@@ -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 <curl/curl.h>"
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 <eiffel_curl.h>"
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 <eiffel_curl.h>"
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 <curl/curl.h>"
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 <curl/curl.h>"
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 <curl/curl.h>"
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

86
curl_form.e Normal file
View File

@@ -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

78
curl_form_constants.e Normal file
View File

@@ -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 <curl/curl.h>"
alias
"[
CURLFORM_COPYNAME
]"
end
curlform_copycontents: INTEGER is
-- Declared as CURLFORM_COPYCONTENTS
external
"C inline use <curl/curl.h>"
alias
"[
CURLFORM_COPYCONTENTS
]"
end
curlform_end: INTEGER is
-- Declared as CURLFORM_END
external
"C inline use <curl/curl.h>"
alias
"[
CURLFORM_END
]"
end
curlform_file: INTEGER is
-- Declared as CURLFORM_FILE
external
"C inline use <curl/curl.h>"
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

192
curl_memory_struct.e Normal file
View File

@@ -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 <eiffel_curl.h>]"
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 <eiffel_curl.h>"
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 <eiffel_curl.h>"
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 <eiffel_curl.h>"
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 <eiffel_curl.h>"
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

177
curl_opt_constants.e Normal file
View File

@@ -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 <curl/curl.h>"
alias
"[
return CURLOPT_HTTPHEADER;
]"
end
curlopt_writedata: INTEGER is
-- Declared as CURLOPT_WRITEDATA.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_WRITEDATA;
]"
end
curlopt_writeheader: INTEGER is
-- Declared as CURLOPT_WRITEHEADER.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_WRITEHEADER;
]"
end
curlopt_debugfunction: INTEGER is
-- Declared as CURLOPT_DEBUGFUNCTION.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_DEBUGFUNCTION;
]"
end
curlopt_verbose: INTEGER is
-- Declared as CURLOPT_VERBOSE.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_VERBOSE;
]"
end
curlopt_useragent: INTEGER is
-- Declared as CURLOPT_USERAGENT.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_USERAGENT;
]"
end
curlopt_url: INTEGER is
-- Declared as CURLOPT_URL.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_URL;
]"
end
curlopt_cookiefile: INTEGER is
-- Declared as CURLOPT_COOKIEFILE.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_COOKIEFILE;
]"
end
curlopt_ssl_verifypeer: INTEGER is
-- Declared as CURLOPT_SSL_VERIFYPEER.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_SSL_VERIFYPEER;
]"
end
curlopt_cookie: INTEGER is
-- Declared as CURLOPT_COOKIE.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_COOKIE;
]"
end
curlopt_post: INTEGER is
-- Declared as CURLOPT_POST.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_POST;
]"
end
curlopt_postfields: INTEGER is
-- Declared as CURLOPT_POSTFIELDS.
external
"C inline use <curl/curl.h>"
alias
"[
return CURLOPT_POSTFIELDS;
]"
end
curlopt_httppost: INTEGER is
-- Declared as CURLOPT_HTTPPOST.
external
"C inline use <curl/curl.h>"
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

1714
spec/include/curl/curl.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
#ifndef __CURL_CURLVER_H
#define __CURL_CURLVER_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, 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 */

81
spec/include/curl/easy.h Normal file
View File

@@ -0,0 +1,81 @@
#ifndef __CURL_EASY_H
#define __CURL_EASY_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, 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

View File

@@ -0,0 +1,80 @@
#ifndef __CURL_MPRINTF_H
#define __CURL_MPRINTF_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, 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 <stdarg.h>
#include <stdio.h> /* 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 */

346
spec/include/curl/multi.h Normal file
View File

@@ -0,0 +1,346 @@
#ifndef __CURL_MULTI_H
#define __CURL_MULTI_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, 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
* <curl/curl.h> 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

View File

@@ -0,0 +1,34 @@
#ifndef __STDC_HEADERS_H
#define __STDC_HEADERS_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, 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 <sys/types.h>
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

View File

@@ -0,0 +1 @@
/* not used */

127
spec/include/eiffel_curl.h Normal file
View File

@@ -0,0 +1,127 @@
#include <stdio.h>
#include <string.h>
/* unix-specific */
#ifndef EIF_WINNT
#include <sys/time.h>
#include <unistd.h>
#endif
#include <curl/curl.h>
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<size; i+= width) {
fprintf(stream, "%04zx: ", i);
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i+c < size)
fprintf(stream, "%02x ", ptr[i+c]);
else
fputs(" ", stream);
}
for(c = 0; (c < width) && (i+c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) {
i+=(c+2-width);
break;
}
fprintf(stream, "%c",
(ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.');
/* check again for 0D0A, to avoid an extra \n if it's at width */
if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) {
i+=(c+3-width);
break;
}
}
fputc('\n', stream); /* newline */
}
fflush(stream);
}
static int my_trace(CURL *handle, curl_infotype type, 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

Binary file not shown.