Compare commits

..

798 Commits

Author SHA1 Message Date
Jocelyn Fiat
f898df0ffa Merge branch 'master' of https://github.com/EiffelWebFramework/EWF.wiki into release-0.1
Conflicts:
	doc/wiki/Home.md
2012-06-29 07:41:58 +02:00
jocelyn
9adbee9887 Updated EWSGI specification: difference in main proposals (markdown) 2012-06-28 22:39:41 -07:00
Jocelyn Fiat
0375072540 updated git howto 2012-06-27 09:37:29 +02:00
Jocelyn Fiat
ad3b975d0a use svn export instead of svn checkout 2012-06-27 09:31:43 +02:00
Jocelyn Fiat
37e60a1f92 If library/cURL exists, do not copy cURL to contrib/library/network/cURL 2012-06-26 22:50:36 +02:00
jocelyn
675f58f42b Updated Community collaboration (markdown) 2012-06-20 12:56:55 -07:00
jocelyn
3d686fb50c Updated Task json (markdown) 2012-06-20 12:54:37 -07:00
jocelyn
ca6b4c468f Updated Tasks Roadmap (markdown) 2012-06-20 12:53:52 -07:00
Jocelyn Fiat
c7db4529a3 When installing, remove the folder "fonts" from the nino's example 2012-06-20 10:42:03 +02:00
Jocelyn Fiat
7273f5086d release v0.1 2012-06-20 10:16:11 +02:00
Jocelyn Fiat
4d7e427d7a removed git submodule for contrib/ise_library/cURL (replaced by git subtree merged) 2012-06-20 09:56:45 +02:00
Jocelyn Fiat
5059f4eb1c fixed path in uninstall_ewf.bat 2012-06-20 09:56:06 +02:00
Jocelyn Fiat
2ac7633b80 Replaced git submodule by subtree merged in contrib/ise_library/cURL 2012-06-20 09:55:34 +02:00
Jocelyn Fiat
e8fa284c79 Replaced git submodule by subtree merged in contrib/library/text/parser/json 2012-06-20 09:52:07 +02:00
Jocelyn Fiat
51b602b42a Fixed typo in linux command line (should use -option instead of --option ) 2012-06-19 23:46:58 +02:00
Jocelyn Fiat
50146cebf5 Put examples under examples/web/ewf/... 2012-06-19 15:24:16 +02:00
Jocelyn Fiat
1d425d2947 Fixed typo 2012-06-19 14:56:24 +02:00
Jocelyn Fiat
74061f83b3 fixed typo in dos batch script 2012-06-19 14:32:52 +02:00
Jocelyn Fiat
692ff182ca IfECF_PATH_UPDATER is defined, let's use it to find ecf_updater executable 2012-06-19 02:36:54 -07:00
Jocelyn Fiat
89110e3568 put everything under contrib for now, eventually svn checkout missing parts 2012-06-18 09:24:07 -07:00
Jocelyn Fiat
8e9db583cc fixed not enought argument for internal shell function (typo..) 2012-06-18 07:22:15 -07:00
Jocelyn Fiat
1509d68ca6 Final version of the install scripts. 2012-06-18 16:11:01 +02:00
Jocelyn Fiat
3709dec5e9 Fixed typo and path separators usage in dos batch scripts 2012-06-18 14:57:52 +02:00
Jocelyn Fiat
ba7886f73d Install script does the same on Windows and Linux 2012-06-18 14:51:26 +02:00
Jocelyn Fiat
0217083d79 improved install_ewf.sh , and removed usage of deleted router.ecf 2012-06-18 02:24:47 -07:00
Jocelyn Fiat
1260ebf999 Updated install_ewf.sh 2012-06-15 14:02:49 -07:00
colin-adams
f6d64b42c6 Complete. 2012-06-15 08:38:30 -07:00
colin-adams
c9b11a6401 Updated Library conneg (markdown) 2012-06-15 08:09:39 -07:00
colin-adams
53a206694a Updated Library conneg (markdown) 2012-06-15 08:04:30 -07:00
colin-adams
74079325a0 Updated Library conneg (markdown) 2012-06-15 07:57:48 -07:00
colin-adams
d0e9438d46 Updated Library conneg (markdown) 2012-06-15 07:44:14 -07:00
Jocelyn Fiat
f3e1c524db Cleaned up compile_all.ini 2012-06-15 16:43:54 +02:00
Jocelyn Fiat
efeb372631 Updated draft library (consider it as draft quality) 2012-06-15 16:32:39 +02:00
Jocelyn Fiat
3389973a75 More flexible signature to allow detachable READABLE_STRING_8
Signed-off-by: Colin Adams <colinpauladams@gmail.com>
2012-06-15 16:28:01 +02:00
colin-adams
bd5985a99a Created Library conneg (markdown) 2012-06-15 07:10:36 -07:00
Jocelyn Fiat
5f3749e463 updated eel and eapml from more recent versions. 2012-06-15 14:57:12 +02:00
Jocelyn Fiat
0203e0fdc7 Moved eel and eapml under the contrib folder. 2012-06-15 14:24:23 +02:00
Jocelyn Fiat
12d56861e6 Fixing wrong path for ewsgi connector nino
(this was introduced recently when we moved folder location)
2012-06-15 14:15:44 +02:00
Jocelyn Fiat
23de980e57 added methods_head_get_post and methods_head_get 2012-06-15 10:54:53 +02:00
Jocelyn Fiat
ad5fed84ca Fixed previous commit where nino .ecf path was empty. 2012-06-15 10:53:32 +02:00
colin-adams
e2adc3cfbb Updated Tasks Roadmap (markdown) 2012-06-14 22:13:52 -07:00
colin-adams
51e54311b1 Updated Task json (markdown) 2012-06-14 22:13:02 -07:00
jocelyn
8a43e4ebb1 Updated Home (markdown) 2012-06-14 05:50:27 -07:00
Jocelyn Fiat
aa38cf787a Merge branch 'master' of github.com:EiffelWebFramework/EWF 2012-06-14 14:17:02 +02:00
Jocelyn Fiat
3702842337 Updated structure of EWF, applied
Now "nino" is under contrib/library/network/server/nino  (as git merge subtree, and not anymore as submodule)
2012-06-14 13:35:08 +02:00
Jocelyn Fiat
2b730186a2 Fixing issue with HEAD and make_from_iterable 2012-06-14 12:28:52 +02:00
Jocelyn Fiat
dbd5e481b8 Merge remote-tracking branch 'ewf_wiki/master' 2012-06-13 23:10:04 +02:00
jocelyn
167c9403c0 Updated Home (markdown) 2012-06-13 14:08:17 -07:00
Jocelyn Fiat
b61cd7f512 Update master 2012-06-14 00:06:44 +03:00
Jocelyn Fiat
0a31cb38a3 Added "nino" subtree merged in contrib/library/network/server/nino 2012-06-13 22:45:50 +02:00
Jocelyn Fiat
db448001a1 Change structure of EWF, to follow better categorization 2012-06-13 22:32:17 +02:00
Jocelyn Fiat
3df1a26220 Better script, do not use default folder without asking. 2012-06-13 19:21:08 +02:00
Jocelyn Fiat
369a63c797 Added temporary scripts to install EWF on Windows 2012-06-13 18:51:19 +02:00
Jocelyn Fiat
52adff29aa updated script with official git repo 2012-06-11 15:20:41 +02:00
Jocelyn Fiat
8a58d62a7e Adopted convention name and value or values for WSF_VALUE and descendant (WSF_STRING ...)
kept `key' as redirection, and also string as obsolete redirection.
Router: provide a way to pass the request methods without using manifest string, thanks to WSF_ROUTER_METHODS
  so instead of using manifest array or manifest strings, just create an instance of WSF_ROUTER_METHODS
  for convenience, WSF_ROUTER provides a few `methods_...' returning prebuilt WSF_ROUTER_METHODS objects
Improved code related to unicode handling in URL, and parameters (before the framework was doing too much)
2012-06-11 14:58:13 +02:00
Jocelyn Fiat
36ed6f525c Update examples/tutorial/step_4.wiki 2012-05-30 11:10:56 +03:00
Jocelyn Fiat
815b62153a Update examples/tutorial/step_4.wiki 2012-05-30 11:10:25 +03:00
Jocelyn Fiat
a9cf373443 Update examples/tutorial/step_1.wiki 2012-05-30 10:57:36 +03:00
Jocelyn Fiat
97b549cf83 Added precompile for step_3 2012-05-30 09:53:00 +02:00
Jocelyn Fiat
7a619fa7a5 Sync with json 2012-05-30 09:52:41 +02:00
Jocelyn Fiat
0d5011b03e Added html encoding facility to WSF_STRING
Added WSF_STRING.is_empty
Improved HTML_ENCODER to be able to decode a STRING_8 or STRING_32 using general_decoded_string (s)
Improved tutorial example
Added precompilation for WSF library
Cosmetic (removed unused locals)
2012-05-30 09:36:55 +02:00
Jocelyn Fiat
8dd0cb29fa Applied recent changes made on EWF
Updated copyright
2012-05-28 11:21:28 +02:00
Jocelyn Fiat
445a27ddf8 Now inherit create_router ; but it is still possible to redefine it.
Added some wsf_reponse_message for redirection
Use "found" for the redirec_now ...
Added content to the tutorial
2012-05-28 10:54:05 +02:00
Jocelyn Fiat
171be24d2a Better us OK status for redirection by default 2012-05-25 23:56:10 +02:00
Jocelyn Fiat
fb7d5054da Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2012-05-25 23:55:35 +02:00
Jocelyn Fiat
03bf467ee5 Added descriptions to WSF_RESPONSE about .send (mesg)
Fixed minor issues in other classes
2012-05-25 23:51:59 +02:00
Jocelyn Fiat
fd73af2cf8 Update examples/tutorial/step_3.wiki 2012-05-26 00:21:31 +03:00
Jocelyn Fiat
5504175d00 added eiffel code 2012-05-26 00:19:14 +03:00
Jocelyn Fiat
8283979a1e cosmetic 2012-05-26 00:17:27 +03:00
Jocelyn Fiat
3982c46ac4 Update examples/tutorial/step_3.wiki 2012-05-26 00:14:32 +03:00
Jocelyn Fiat
37a68dc778 Update examples/tutorial/step_3.wiki 2012-05-26 00:13:46 +03:00
Jocelyn Fiat
dafd8335d2 Update examples/tutorial/step_1.wiki 2012-05-26 00:10:20 +03:00
Jocelyn Fiat
4324b83cba fixed github wikitext usage 2012-05-26 00:08:28 +03:00
Jocelyn Fiat
b37a2bd17f Update examples/tutorial/step_4.wiki 2012-05-26 00:07:09 +03:00
Jocelyn Fiat
2a781b9081 Update examples/tutorial/step_3.wiki 2012-05-26 00:06:05 +03:00
Jocelyn Fiat
4bd8a24478 Update examples/tutorial/step_2.wiki 2012-05-26 00:05:06 +03:00
Jocelyn Fiat
f1e7639e6c Update examples/tutorial/step_1.wiki 2012-05-26 00:04:01 +03:00
Jocelyn Fiat
08347da643 Added more content to the tutorial 2012-05-25 22:55:15 +02:00
Jocelyn Fiat
6cff00428b Protected export of WSF_RESPONSE_MESSAGE.send_to
Added WSF_DEFAULT_RESPONSE_SERVICE
Added simple WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI class to load launch option from ini file.

Removed a few obsolete features
2012-05-25 20:17:55 +02:00
Jocelyn Fiat
aa6a1f2b8a Update examples/tutorial/README.wiki 2012-05-25 19:07:58 +03:00
Jocelyn Fiat
0f42eb2af0 Update examples/tutorial/README.wiki 2012-05-25 19:06:55 +03:00
Jocelyn Fiat
6d428cf078 added skeleton for tutorial_i text 2012-05-25 18:05:01 +02:00
Jocelyn Fiat
bd5238cf10 removed README.md 2012-05-25 17:57:13 +02:00
Jocelyn Fiat
e006b476af Removed to README.wiki 2012-05-25 17:56:19 +02:00
Jocelyn Fiat
f07fbbe450 Merge branch 'master' of github.com:EiffelWebFramework/EWF 2012-05-25 17:49:54 +02:00
Jocelyn Fiat
00a88e98e5 Updated indexing notes
started tutorial
Sync
2012-05-25 17:47:43 +02:00
Jocelyn Fiat
f1498e2a07 http_client PUT uploaded data is not correctly implemented using libcurl
so for now, let's use a real temporary file to use the upload filename implementation
2012-05-23 23:17:50 +02:00
Jocelyn Fiat
5899da6197 fixed typo in curl.ecf 2012-05-21 17:25:53 +02:00
Berend de Boer
2ff3cff70f Do not use 307 but 302 response 2012-05-21 17:18:12 +02:00
Jocelyn Fiat
8fddfd6d22 Added presentation of EWF from march 2012 2012-05-15 19:05:16 +02:00
jocelyn
81da23c472 Updated Home (markdown) 2012-05-15 10:01:41 -07:00
Jocelyn Fiat
a3ae808a59 misc: script to checkout the source code with svn 2012-05-15 18:53:58 +02:00
Jocelyn Fiat
1d82a55e76 added some git tips in doc 2012-05-15 18:38:16 +02:00
Jocelyn Fiat
cf68ce6681 Added subtree merged in doc/wiki 2012-05-15 18:26:08 +02:00
Jocelyn Fiat
1d89a2bd9f Removed submodule doc/wiki 2012-05-15 18:25:09 +02:00
Jocelyn Fiat
ddd9eb646d removed commented lines 2012-05-14 22:07:48 +02:00
Jocelyn Fiat
ff97b041a9 updated ChangeLog 2012-05-14 21:41:43 +02:00
Jocelyn Fiat
c3c27c5027 Rather use (READABLE_)STRING_GENERAL for argument instead of _8 or _32 variant
Better design to set the WSF_REQUEST.path_parameters
   especially handle the case where the request goes trought more than one route (could be the case when using WSF_ROUTING_HANDLER)
2012-05-14 18:12:28 +02:00
Jocelyn Fiat
64eebd32db Updated URI Template to follow official RFC6570 2012-05-14 18:11:12 +02:00
Jocelyn Fiat
278a71eaaf Reviewed WSF_REQUEST.item (..) and items to look into Form, Query, and Path (cookie are excluded for security)
Added WSF_REQUEST.path_parameter (a_name): detachable WSF_VALUE
   - fill path_parameters using `import_raw_path_parameters"
     when executing the route
   - reset to previous value with reset_path_parameters (..),
     just in case the request is executed via severals routes.
2012-05-07 23:16:52 +02:00
Jocelyn Fiat
e615026520 Reverted back to export upload_data and upload_filename to ANY (and related features) 2012-05-04 13:45:17 +02:00
Jocelyn Fiat
3a979915f5 Removed HTTP_CLIENT_SESSION.post_multipart .. because it was not doing what the name might evoque
Restrict export of HTTP_CLIENT_REQUEST_CONTEXT.upload_data and upload_filename (and related) to .._SESSION and .._REQUEST
   this is mainly internal data, and is more about implementation than interface
2012-05-04 12:37:51 +02:00
Jocelyn Fiat
4508a76683 Now the http_client will send the form parameters urlencoded if this is possible (instead of multipart form data)
Note for now, the library does not support sending file and form parameters at the same time.
2012-05-04 12:23:37 +02:00
Jocelyn Fiat
d40cc5d669 Fixed typo in .ecf .. curl instead of cURL 2012-05-03 18:46:04 +02:00
Jocelyn Fiat
3b27e093eb Added geant scripts to compile EWF 2012-05-03 18:29:46 +02:00
Jocelyn Fiat
eb04ac5405 Improved the libcurl implementation of http_client by adding HTTP_CLIENT_SESSION.is_debug: BOOLEAN
if True, this display verbose debug information in console
Implemented uploading of file for PUT and POST requests
Refactored LIBCURL_HTTP_CLIENT_REQUEST to free used pointer, and also ease extension of the class if needed.
Updated cURL library with addition of {CURL_EXTERNALS}.slist_free_all (..)
2012-05-03 16:21:42 +02:00
jfiat
c4e25a3091 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
2012-05-02 19:58:42 +00:00
Jocelyn Fiat
31cf64f4ad do not use implicit conversion from HTTP_CONTENT_TYPE 2012-05-02 19:25:14 +02:00
Jocelyn Fiat
face4550f2 Fixed wrong signature should be READABLE_STRING_32 instead of _8 2012-05-02 19:22:39 +02:00
Jocelyn Fiat
ee0e3df05f Also removing the implicit conversion from STRING to HTTP_*_TYPE 2012-05-02 11:40:23 +02:00
Jocelyn Fiat
18ced46c99 Removed implicit conversion from HTTP_CONTENT_TYPE to STRING_8
because it could be a source of bug due to hidden conversion (and parameters)
Applied changes to autotest cases
Cosmetic
2012-05-02 11:35:53 +02:00
Jocelyn Fiat
7c95e514ad Added comments
Added `url' to compute the url from base_url, path and query parameters
2012-04-30 15:54:21 +02:00
Jocelyn Fiat
e304113984 Fixed error in URL encoding, according to the RFC3986, space should not be encoded with '+' but with percent encoding. 2012-04-30 15:53:44 +02:00
Jocelyn Fiat
07b3eddefe Fixed signature issue, the argument `name' should be READABLE_STRING_32 2012-04-30 15:51:10 +02:00
Jocelyn Fiat
dc2e535fe8 Code cleaning 2012-04-30 15:49:35 +02:00
Jocelyn Fiat
bd33aabd93 Added specific helper function related to `charset' parameter 2012-04-30 15:49:24 +02:00
Jocelyn Fiat
80a1c85844 added postcondition status_reason_phrase_unset to `set_status' 2012-04-27 08:52:58 +02:00
Jocelyn Fiat
9ba3caba12 cosmetic 2012-04-27 08:52:29 +02:00
Jocelyn Fiat
34c6288032 Fixed a last minute regression due to removal REQUEST.chunked_input 2012-04-13 17:19:14 +02:00
Jocelyn Fiat
21b03a05fd Added WSF_ROUTER.pre_route_execution_actions: ACTION_SEQUENCE [like route]
This way, one can add logger hook to router, to see which "route" was taken by the request.
2012-04-13 16:40:19 +02:00
Jocelyn Fiat
0bd2d16c12 Made WGI_CHUNKED_INPUT_STREAM inherits from WGI_INPUT_STREAM
Merged REQUEST.input and REQUEST.chunked_input
  Now REQUEST.input handles directly the chunked transfer encoding, or the non chunked.
Kept REQUEST.is_chunked_input since it matters that Content-Length is 0 even if there are input (chunked) data.
2012-04-13 16:33:49 +02:00
Jocelyn Fiat
e6a727ee42 Fixed compilation of samples 2012-04-12 12:51:52 +02:00
Jocelyn Fiat
1403cc5c09 Fixed compilation 2012-04-12 12:25:34 +02:00
Jocelyn Fiat
3bbf356f19 Missing commit related to changes on WSF_ROUTER 2012-04-12 11:59:14 +02:00
Jocelyn Fiat
b541efcc8f Now WGI_RESPONSE.set_status_code (..) has a new argument to pass optional custom reason phrase.
This is a minor breaking change (but prior to the first release, so acceptable)
   And then it is now possible to precise a custom reason phrase (useful for 4xx and 5xx response)

At the WSF_RESPONSE level, the status code is now sent only when the header are sent.
thus, it is possible to change the status code as long as no header is sent.
(in the future, we should also try to delay the sending of headers)

Removed WGI_RESPONSE.put_header_lines (..) which was not used, and WGI is not meant to provide such user friendly features
Now this is available directly on WSF_RESPONSE
2012-04-12 11:19:41 +02:00
Jocelyn Fiat
082def2b70 Merge branch 'master' of github.com:EiffelWebFramework/EWF 2012-04-06 15:52:03 +02:00
Jocelyn Fiat
79607600e6 updated to EiffelWebFramework/EWF 2012-04-06 16:27:22 +03:00
jocelyn
8870e19991 Updated Home (markdown) 2012-04-06 06:25:05 -07:00
Jocelyn Fiat
0b6b7f793c sync with json lib. 2012-04-06 11:31:57 +02:00
Jocelyn Fiat
badc2458c4 Sync with wiki 2012-04-06 11:29:07 +02:00
Jocelyn Fiat
d4208c59f3 Use https://github.com/EiffelWebFramework/EWF.git as master 2012-04-06 11:21:50 +02:00
Jocelyn Fiat
4bafa5b3c0 Added `transfered_content_length' to WSF_RESPONSE to provide the information to application
This can be used to build logs for instance.
2012-04-05 21:15:12 +02:00
Jocelyn Fiat
c89b19371e Relaxed WSF_REDIRECTION_RESPONSE.set_content (.., ..) to allow Void for content type
in order to use the one set in header or the default one.
2012-04-05 21:14:10 +02:00
Jocelyn Fiat
10ebc12852 Removed default handler for WSF_ROUTER
Added 	WSF_ROUTE to replace a TUPLE [H, C]
	WSF_ROUTER.route (req): detachable WSF_ROUTE
	WSF_ROUTER.execute_route (a_route, req, res)
	To help usage of Routers
Remove WSF_HANDLER_CONTEXT obsolete features.
Added comments
2012-04-05 21:13:04 +02:00
Jocelyn Fiat
593e48ec5b Merge remote-tracking branch 'remotes/eiffelworld/master' 2012-04-02 09:29:53 +02:00
Jocelyn Fiat
11b15ec5b7 Merge pull request #10 from oligot/unneeded_precondition
Unneeded precondition
2012-04-02 00:28:23 -07:00
Olivier Ligot
ff713a42ab [REM] Remove unneeded precondition 2012-04-02 09:28:22 +02:00
Olivier Ligot
155c45be6c [IMP] Ignore *.swp files 2012-04-02 09:28:10 +02:00
Jocelyn Fiat
09fa1adaab removed obsolete message. 2012-04-02 09:27:59 +02:00
Olivier Ligot
425c276051 [REM] Remove unneeded precondition 2012-03-27 11:30:42 +02:00
Olivier Ligot
0040e4b0d0 [IMP] Ignore *.swp files 2012-03-27 11:29:33 +02:00
Olivier Ligot
b862065c04 Merge branch 'master', remote branch 'upstream/master' 2012-03-26 17:19:02 +02:00
Jocelyn Fiat
874677ab7a Renamed same_media_type as same_simple_type
Added comments
2012-03-23 19:00:49 +01:00
Jocelyn Fiat
ed200b93dd updated tests.ecf 2012-03-23 18:40:29 +01:00
Jocelyn Fiat
bcccfb22ed Added HTTP_MEDIA_TYPE (maybe it will just replace the HTTP_CONTENT_TYPE later)
renamed .media_type as .simple_type for now
  allow more than one parameters
2012-03-23 18:39:19 +01:00
Jocelyn Fiat
5c98d7ba4e Use media_type as replacement for type_and_subtype_string in HTTP_CONTENT_TYPE 2012-03-23 16:49:13 +01:00
Jocelyn Fiat
40c6aff423 Added class HTTP_CONTENT_TYPE to help manipulation of Content-Type value
Now WSF_REQUEST return a HTTP_CONTENT_TYPE if available
Adapted WSF_MIME_HANDLER to use this new class
Added one manual autotest to test MIME handler
2012-03-23 16:40:13 +01:00
Jocelyn Fiat
ac9cbb0bd2 in WSF_RESPONSE, put_header' now call put_header_text'
Removed unused local variable
2012-03-21 14:49:09 +01:00
Jocelyn Fiat
95c3bbf6e5 Fixed very bad mistake where no Result was ever set for WSF_REQUEST.item (..) 2012-03-21 14:43:32 +01:00
Jocelyn Fiat
b955912dc2 fixed compilation issue (typo) 2012-03-20 16:17:43 +01:00
Jocelyn Fiat
50223b12f7 Do not try to compile_all in "dev" folder 2012-03-20 16:15:16 +01:00
Jocelyn Fiat
6c7ba93062 Reverted a previous change, we should not truncated Content-Type after ;
In the case of multipart/form-data  the parameter "boundary=" is essential
2012-03-20 14:35:04 +01:00
Jocelyn Fiat
743f26c376 Use WSF_DEFAULT_SERVICE for the test echo server 2012-03-20 12:18:44 +01:00
Jocelyn Fiat
d256ec3944 Fixing compilation of specific example using the WGI connector directly 2012-03-20 12:15:45 +01:00
Jocelyn Fiat
482f8e41e7 Added WSF_SERVICE.to_wgi_service to ease direct integration with existing WGI components 2012-03-20 11:40:13 +01:00
Jocelyn Fiat
9eef812795 Relaxed access to `send_to', now it is exported again to avoid breaking existing code. 2012-03-20 11:38:44 +01:00
Jocelyn Fiat
86fcaa2835 remove unused local variable 2012-03-20 11:15:14 +01:00
Jocelyn Fiat
897aeb3132 WSF_REQUEST.content_type should keep only the relevant part of the content type
and forget about the eventual parameters (charset, name) ...

  note: it is possible to query meta_string_variable ("CONTENT_TYPE")
        to get the complete Content-Type header
2012-03-20 11:12:18 +01:00
Jocelyn Fiat
48acdea73c Added HTTP_HEADER.(put|add)_content_type_with_parameters (...) 2012-03-20 11:08:52 +01:00
Jocelyn Fiat
cbaae12156 removed obsolete 2012-03-20 10:30:04 +01:00
Jocelyn Fiat
8344607eb6 Implemented WSF_RESPONSE.put_error (...) and related
Added WSF_RESPONSE.put_character
Renamed  WGI_OUTPUT_STREAM.put_character_8 as put_character  to follow style of put_string  (and not put_string_8)
Refactored the WSF_DEFAULT_SERVICE_LAUNCHER
Added WSF_DEFAULT_SERVICE to be more user friendly
Splitted the wsf/default/ libraries to have wsf/connector/... and being able to handle more than one connector in the same application
2012-03-20 10:29:55 +01:00
Jocelyn Fiat
71d5dc4795 Moved mime handler classes under wsf/src/mime/ 2012-03-20 08:38:38 +01:00
Jocelyn Fiat
3f0b745ecc removed unwanted rescue clause 2012-03-19 15:20:29 +01:00
Jocelyn Fiat
3432e2d8b2 Updating EWSGI specification classes 2012-03-19 15:06:50 +01:00
Jocelyn Fiat
fea0f115a0 Removed WGI_RESPONSE.write (..)
Replaced any internal call to WGI_RESPONSE.write () by the associated implementation (i.e  output.put_string (...)  )
Added WGI_OUTPUT_STREAM.put_crlf

Renamed WSF_RESPONSE.put_response (a_message) as  `send (a_message)'
WSF_RESPONSE_MESSAGE.send_to (res)  is now exported only to WSF_RESPONSE
2012-03-19 14:52:12 +01:00
Berend de Boer
84a12447db Avoid another indirection. 2012-03-19 14:02:13 +01:00
Berend de Boer
876f9e02b7 status must be set, else WGI_SERVICE.execute will report the
postcondition violation.

Conflicts:

	library/server/wsf/router/wsf_handler.e
2012-03-19 13:58:17 +01:00
Berend de Boer
e5323dd208 Minor code cleanup/typo fix. 2012-03-19 13:54:48 +01:00
Berend de Boer
77834a3dd8 Move wgi_service spec to its own directory else I get a class
conflicts with compile_ise.ecf generated by gexace.
2012-03-19 13:54:34 +01:00
Jocelyn Fiat
4906345a62 Improved comment in WSF_RESPONSE.put_response (..)
Added WSF_REDIRECTION_RESPONSE class
2012-03-19 12:32:12 +01:00
Jocelyn Fiat
487487ad44 Added WSF_RESPONSE_HANDLER based on WSF_RESPONSE_MESSAGE
The descendant has to implement the function

    response (ctx: C; req: WSF_REQUEST): WSF_RESPONSE_MESSAGE

Added related features and class in WSF_ROUTER to be able to use agent easily.
2012-03-19 12:04:46 +01:00
Jocelyn Fiat
ef5ba19c46 Refactored WSF_HANDLER_CONTEXT
- removed path_parameter
  - added `item' to include WSF_REQUEST.item
  - marked obsolete `parameter'

The goal is to remove confusion, remove URI_TEMPLATE specific `path_parameter'
and provide a way to use ctx.item (..) to also include meta variable, query, form, ... items
2012-03-19 10:21:29 +01:00
Jocelyn Fiat
b05ff01262 Use local variable to speed up access to `input' 2012-03-19 10:12:06 +01:00
Jocelyn Fiat
9f1940c46d Applied wsf_extension creation, and classes moved from wsf to wsf_extension 2012-03-16 15:17:22 +01:00
Jocelyn Fiat
f69ff42564 Created wsf_extension, and moved some classes from wsf to wsf_extension
WSF_HANDLER_HELPER
   WSF_RESOURCE_HANDLER_HELPER
   WSF_HANDLER_ROUTES_RECORDER
2012-03-16 14:12:02 +01:00
Jocelyn Fiat
eb3e9f2186 applied removal of HTTP_HEADER.put_status (..) 2012-03-16 13:53:22 +01:00
Jocelyn Fiat
03b10bdc14 Removed HTTP_HEADER.put_status (...)
It is not recommended to send the status code as part of the HTTP Header,
  so let's remove this ambiguity and do not encourage EWF user to use it
2012-03-16 13:35:52 +01:00
Jocelyn Fiat
46eb92ac37 Major renaming, adopt the WSF_ prefix for all classes under "wsf", and simplify some class names
Removed in WGI_INPUT_STREAM, the assertion "same_last_string_reference"
Copyright updates
2012-03-16 09:49:41 +01:00
Jocelyn Fiat
25218996e0 Fixed compilation of draft/library/server/request/rest/tests/..
Note the "rest" library will not be maintained since this is not REST.
2012-03-13 18:41:32 +01:00
jfiat
081392529c 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
2012-03-13 17:36:43 +00:00
Jocelyn Fiat
68dbbdea9f precise that library/server/request/router is now part of "wsf" library and not anymore independant library. 2012-03-13 18:09:16 +01:00
Jocelyn Fiat
5abc79b7c3 Nino connector:
- fixed issue related to `ready_for_reading'  now use the `try_...' variant
 - for now Nino does not support persistent connection, then we have to respond with "Connection: close"

REQUEST_FILE_SYSTEM_HANDLER:
 - added not_found_handler and access_denied_handler, so that the user can customize related response

WSF_REQUEST and WSF_VALUE:
 - modified how uploaded file are handled, fixed various issues, and added WSF_UPLOADED_FILE (it is a WSF_VALUE)

WSF_VALUE:
 - added change_name (a_name: like name)
 - added url_encoded_name to other WSF_values

WSF_REQUEST:
 - added `destroy' to perform end of request cleaning (such as deleting temp uploaded files)
 - renamed `raw_post_data_recorded' as `raw_input_data_recorded', and related feature
 - do not store the RAW_POST_DATA in meta variable anymore, but in WSF_REQUEST.raw_input_data is asked

Added WSF_HTML_PAGE_RESPONSE to help user

WSF_REPONSE.redirect_... now use "temp_redirect" as default
  instead of "moved_permanently" which is specific usage

Removed many obsolete features.
2012-03-13 18:07:28 +01:00
Jocelyn Fiat
e85213689e TCP_STREAM_SOCKET: added try_ready_for_reading' which is the same as ready_for_reading' but without any timeout 2012-03-13 17:38:33 +01:00
Jocelyn Fiat
c5fe539acb use https:// url for git submodules 2012-02-29 17:23:34 +01:00
Jocelyn Fiat
ac3e969b3c Added assertions to catch if route mapping does not already exists 2012-02-29 11:27:46 +01:00
Jocelyn Fiat
98f2efbd68 Merging changes from Javier
Updated restbucksCRUD example, and related class in wsf/router
2012-02-28 09:23:09 +01:00
Jocelyn Fiat
7314e92fe6 Synchronized with nino and json library 2012-02-28 09:20:08 +01:00
jvelilla
ab38345c25 Update readme.txt 2012-02-24 08:54:27 -02:00
jvelilla
468b2851be Refactor REQUEST_RESOURCE_HANDLER_HELPER to figure out the
transfer encoding: Chunked.
Added a new method to retrieve_data independently if the
transfer is chunked or not.
Updated ORDER_HANLDER to use this new feature.
Sync with Jocelyn repo
2012-02-17 08:48:27 -03:00
jvelilla
f1fe5464c6 Merge branch 'master' of git://github.com/jocelyn/Eiffel-Web-Framework 2012-02-17 07:28:57 -03:00
Jocelyn Fiat
d621987020 Minor correction, to avoid returning 200 as status code, when the client can not connect 2012-02-16 10:32:24 +01:00
Jocelyn Fiat
e541fdcb0c fixed compilation 2012-02-15 12:36:57 +01:00
Jocelyn Fiat
5950d768c9 sync with cURL library 2012-02-15 11:58:32 +01:00
Jocelyn Fiat
413fdaf6cd Fixed error visitor due to recent signature changes 2012-02-15 11:33:39 +01:00
Jocelyn Fiat
9138ffedfb renamed (add|remove)_synchronized_handler as (add|remove)_synchronization 2012-02-15 11:07:12 +01:00
Jocelyn Fiat
72cc05532c Removed tests target from encoder(-safe).ecf
(now there is a tests-safe.ecf in folder tests)
2012-02-15 11:04:42 +01:00
Jocelyn Fiat
145b129b28 Fixed ERROR_HANDLER.destroy
Fixed and export ERROR_HANDLER.remove_synchronized_handler
Added comments
Added associated autotests
2012-02-15 11:03:30 +01:00
Jocelyn Fiat
fbec89f354 Better signature for encoders
Split library .ecf and the autotest .ecf
2012-02-14 18:03:42 +01:00
Jocelyn Fiat
f59d5cac32 added postcondition to ensure the body string set to the response, is the same reference
this is important, since sometime we just do
  rep.set_body (s)
  s.append_string ("..")
2012-02-14 18:02:14 +01:00
Jocelyn Fiat
4bb8a71c1b Added DEBUG_OUTPUT to ERROR, since this is convenient during debugging 2012-02-14 18:01:17 +01:00
Jocelyn Fiat
dd6b74326e Added notion of synchronization between error handler
this is convenient to integrate two components using their own ERROR_HANDLER (not sharing the same object)
2012-02-14 12:57:01 +01:00
Jocelyn Fiat
e52cd6b352 use WSF_PAGE_RESPONSE, instead of reimplementing it ourself 2012-02-14 10:20:15 +01:00
larryl
ad2a498fc0 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
2012-02-14 02:52:03 +00:00
Jocelyn Fiat
537bd8241f added a JSON encoder test case 2012-02-13 14:38:13 +01:00
Jocelyn Fiat
040c1d1c10 Merge pull request #9 from oligot/fix-libfcgi-location
[FIX] libfcgi.so location
2012-02-13 03:21:29 -08:00
Olivier Ligot
f3c779cf6e [FIX] libfcgi.so location
On Ubuntu 10.04 LTS, libfcgi.so is in /usr/lib instead of /usr/local/lib
2012-02-10 14:01:04 +01:00
Jocelyn Fiat
6cf35e90c6 added a case in test_json_encoder 2012-02-08 21:36:49 +01:00
unknown
497fe03d38 libcurl: Applied a workaround to avoid issue on Win32 (see LIBCURL_HTTP_CLIENT_REQUEST.apply_workaround)
Separated the http_client-safe.ecf and test-safe.ecf
Added HTTP_CLIENT_SESSION.set_max_redirects
Fixed broken test due to formatting trouble.
2012-02-08 21:32:25 +01:00
Jocelyn Fiat
ca3a520bb9 fixed http_client tests 2012-02-08 16:36:54 +01:00
jvelilla
3c755019aa Updated content 2012-02-08 08:47:39 -03:00
Jocelyn Fiat
3a9b67c8ad Better code to test similar functions but with chunked input 2012-02-07 16:05:19 +01:00
Jocelyn Fiat
e21da4a591 Improved the WSF_PAGE_RESPONSE to be more flexible and allow to change some values as expected. 2012-02-07 15:49:02 +01:00
Jocelyn Fiat
69bc4d568c Added support for chunked input data (see Transfer-Encoding: chunked) 2012-02-07 15:47:55 +01:00
Jocelyn Fiat
cf8d25c4e5 Added HTTP_HEADER.append_header_object and append_array.
This is helpful to "merge" two HTTP_HEADER and provide user friendly features
2012-02-07 15:45:44 +01:00
Jocelyn Fiat
2b9ca86501 Added proxy, at least to make it is possible to use http://fiddler2.com/ to inspect the traffic. 2012-02-07 15:44:45 +01:00
Jocelyn Fiat
2f43660628 Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework 2012-02-07 15:13:59 +01:00
Jocelyn Fiat
d8476edf36 Fixed wrong code for postcondition on HTTP_HEADER.string
Patch provided by Paul-G.Crismer
2012-02-01 16:53:24 +01:00
Jocelyn Fiat
67e6b460b3 removed unwanted set_status_code, since we already use put_header to set the status code. 2012-02-01 16:05:30 +01:00
Jocelyn Fiat
962154fc81 Eventually fixing trouble with c_strlen being over capacity
(added this for testing, and while waiting a fix from EiffelcURL)
2012-02-01 11:57:42 +01:00
Jocelyn Fiat
645b35590b Improved redirect_now_custom to allow custom status code, custom header, and custom content 2012-02-01 10:57:52 +01:00
Jocelyn Fiat
a1354136fa Fixed usage of lst[] in web form, now we are url-decoding the name because the [] could escaped...
Fixed bad code for assertion related to variable url-encoded name
2012-01-31 17:57:59 +01:00
Jocelyn Fiat
945ef79857 added REQUEST_HANDLER_CONTEXT.string_array_path_parameter (...) to help user handling list/array parameters
fixed postcondition WSF_REQUEST.set_meta_string_variable ...
2012-01-31 12:12:41 +01:00
Jocelyn Fiat
2c4df29877 Make sure to return a response
Added precondition to check URI_TEMPLATE is valid
2012-01-25 16:27:22 +01:00
Jocelyn Fiat
e6687c7791 Fixed wrong assertion, status_committed instead of status_set 2012-01-24 16:47:12 +01:00
Jocelyn Fiat
754d3f670c Fixed issue with WSF_FILE_RESPONSE not setting the status code
Added Last-Modified
2012-01-23 18:20:25 +01:00
Jocelyn Fiat
8e420de8ec Fixed wrong code for postcondition in unset_orig_path_info 2012-01-23 15:32:11 +01:00
Jocelyn Fiat
6dc1c0d2b0 Removed most of the "retry" in rescue clauses, since it was hidding critical issue.
This should be the choice of the application to "retry" on exception, otherwise let the framework handle this in the lower part.

Better handling of response termination (alias commit)
Added the notion of "status_committed"
2012-01-23 15:31:34 +01:00
Jocelyn Fiat
80d68699b1 added "conversion" to ease the use of HTTP_HEADER 2012-01-23 15:28:06 +01:00
Jocelyn Fiat
fcdf4e456e fixed compilation (was not up to date with tests.ecf) 2012-01-20 20:04:56 +01:00
Jocelyn Fiat
c92c2a91b4 Corrected remaining issue related to recent addition of REQUEST_ROUTER.make_with_base_url
And applied removal of format_name and format_id, and replaced by accepted_format_name, ...
2012-01-20 18:55:03 +01:00
manus
1ab3832685 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
2012-01-20 16:35:05 +00:00
Jocelyn Fiat
da9fa4ecc2 Do not add again ctx.headers, since it is already "imported" during the creation of Current request
(see HTTP_CLIENT_REQUEST.make)
2012-01-20 15:37:04 +01:00
Jocelyn Fiat
abdd68863d Removed any "format" related query from router lib, this is too application specific to be there.
Better handling of base_url for REQUEST_ROUTER
2012-01-20 15:35:03 +01:00
Jocelyn Fiat
83a8ad3879 separate library .ecf and tests .ecf
merged tests .ecf for draft 05 and current implementation
2012-01-19 14:34:04 +01:00
Jocelyn Fiat
1b55b09b64 Fixed WSF_REQUEST.script_url (..) for clean path
Added related autotests
2012-01-19 10:25:53 +01:00
Jocelyn Fiat
4cf3393a13 Don't forget to put Content-Length: 0 for redirect without any content 2012-01-17 17:37:26 +01:00
Jocelyn Fiat
4486df14cc export handler from REQUEST_ROUTER 2012-01-17 07:51:26 -08:00
Jocelyn Fiat
60574ee85f REQUEST_ROUTER now inherit from ITERABLE [..] 2012-01-17 16:35:52 +01:00
Jocelyn Fiat
7a6c51e47e Send the Status code, as an header line Status: code reason 2012-01-17 16:34:48 +01:00
Jocelyn Fiat
d8c420c4b7 use READABLE_STRING_8 instead of STRING_8 2012-01-17 16:33:40 +01:00
Jocelyn Fiat
790aa40591 According to http://www.fastcgi.com/docs/faq.html#httpstatus
send the Status code, as an header line  Status: code reason
2012-01-17 13:49:04 +01:00
Jocelyn Fiat
e506397406 Do not send any Status line back to the FastCGI client 2012-01-16 13:49:38 +01:00
Jocelyn Fiat
434f031680 Synchronized with ejson library
Cleaned JSON_ENCODER
2012-01-13 19:04:26 +01:00
Jocelyn Fiat
e36533bc99 Added JSON_ENCODER 2012-01-12 10:38:43 +01:00
Jocelyn Fiat
d90ecbd5fe removed obsolete call on WSF_RESPONSE.write_..' by using the up-to-date WSF_RESPONSE.put_..' 2012-01-09 10:21:35 +01:00
Jocelyn Fiat
20281bc922 HTTP_HEADER: - added put_last_modified
- added RFC1123 http date format helper
             - added put_cookie_with_expiration_date as DATE_TIME
REQUEST: added `execution_variable' to provide a way to keep object attached to the request
         and indexed by a string. A typical usage is a SESSION object
2012-01-06 18:27:52 +01:00
jvelilla
6b3a2d3b43 Update examples/restbucksCRUD/readme.md 2011-12-21 15:40:03 -02:00
Jocelyn Fiat
83346c92a7 added REQUEST.execution_variables ... to provide a solution to store data during request execution
could be used for SESSION, or any "shared" data inside the same Request
2011-12-18 12:57:24 +01:00
Jocelyn Fiat
6b50ab8c55 applied write_ as put_ renaming to examples 2011-12-18 12:55:42 +01:00
Jocelyn Fiat
c8efa04147 Use put_ instead of write_ 2011-12-15 23:52:53 +01:00
Jocelyn Fiat
37860f43b5 various minor changes 2011-12-15 23:38:34 +01:00
Jocelyn Fiat
65a998cec3 use /usr/lib/libfcgi.so instead of /usr/local/lib/libfcgi.so 2011-12-15 20:10:31 +01:00
Jocelyn Fiat
7207a021be Applied renaming from write_ to put_ 2011-12-15 19:34:20 +01:00
Jocelyn Fiat
32373addfa Renamed write_ feature as put_ 2011-12-15 19:04:26 +01:00
Jocelyn Fiat
e16f03b1c2 Fixed stupid mistake in {WGI_NINO_INPUT_SREEAM}.end_of_input 2011-12-15 15:36:47 +01:00
Jocelyn Fiat
1698a06ea0 Fixed typo and missing uri_template reference for draft rest library 2011-12-15 14:40:43 +01:00
Jocelyn Fiat
da3594db50 Now the 'router' library is part of 'wsf'
Move hello_routed_world under tests/dev since it was not really an example, but more a dev workspace/test
2011-12-15 14:10:52 +01:00
Jocelyn Fiat
bfa620eee3 Made DEFAULT_SERVICE_LAUNCHER more flexible for the user. 2011-12-15 13:30:19 +01:00
jvelilla
1423412f31 Update read_trailer feature. 2011-12-15 09:18:37 -03:00
jvelilla
0f51925ec1 Initial implementation of wgi_chunked_input_stream
as a wrapper of wgi_input_stream
2011-12-15 08:53:50 -03:00
Jocelyn Fiat
b6784ee35c Use port 9090 for restbuck server
mainly to avoid using 80 or 8080 which are often already used (by current webserver, or even skype, or jenkins, or ...)
2011-12-14 16:34:01 +01:00
Jocelyn Fiat
ab5b43d8ef Forgot to add make_and_launch_with_options to the creation procedures 2011-12-14 15:04:29 +01:00
Jocelyn Fiat
c7366615cf Added DEFAULT_SERVICE_LAUNCHER.make_and_launch_with_options
Added WSF_RESPONSE.redirect_now_with_content (...)
Updated hello_routed_world .. mainly example use to test/develop... not really a nice example
2011-12-14 14:44:06 +01:00
Jocelyn Fiat
b60c41ee1b Updated readme on how to get source code 2011-12-13 11:43:24 +01:00
Jocelyn Fiat
f9dfeb0034 added head and bottom value in WSF_FILE_RESPONSE, to enable the user to set a head and bottom part easily 2011-12-13 10:35:49 +01:00
Jocelyn Fiat
5e35bc59a9 avoid infinite rescue due to internal error or user code not dealing well with socket disconnection 2011-12-12 21:19:45 +01:00
Jocelyn Fiat
2ed6d92e53 Removed dotnet target for now 2011-12-12 21:18:35 +01:00
Jocelyn Fiat
33d3071cad Merge branch 'master' of github.com:Eiffel-World/Eiffel-Web-Framework 2011-12-12 18:57:09 +01:00
Jocelyn Fiat
35dde23976 Fixed http_client autotest code 2011-12-12 18:50:40 +01:00
Jocelyn Fiat
390c05b056 Break inheritance from WGI_RESPONSE, since it is not flexible for future improvement. 2011-12-12 18:24:46 +01:00
Jocelyn Fiat
011f8746d6 Fixed HTTP client callers 2011-12-12 18:17:39 +01:00
Jocelyn Fiat
0335226e8b Renamed DEFAULT_SERVICE as DEFAULT_SERVICE_LAUNCHER 2011-12-12 18:17:27 +01:00
Jocelyn Fiat
68e4ac9a8f Fixed WSF_FILE_RESPONSE
and added WSF_FORCE_DOWNLOAD_RESPONSE
2011-12-12 16:20:06 +01:00
Jocelyn Fiat
f6b293d4ae Merge changes from Javier
- update on RESTbuck examples
- new example
- fixed bad typo in WSF_REQUEST

Reverted some changes such as
- http_client_response: keep the headers as a list to handle multiple message-value with same message-name

Fixed simple and simple_file example
Improved HTTP_HEADER

Changed libcurl implementation for http client
- now the header from the context really overwrite any of the session headers
- better design which is more strict, and remove any doubt about context's header usage
2011-12-12 16:03:38 +01:00
Jocelyn Fiat
89572b4f33 Removed any (put|write)_file_content from the WSF_ or WGI_ OUTPUT classes
Now DEFAULT_SERVICE has to be created instead of inherited.
   - This seems to be better for new user, and this avoid potential conflict and difference when inheriting between the various DEFAULT_SERVICE implementation.
   - remember that DEFAULT_SERVICE, is mainly to help the user to build its very first service.
Use READABLE_STRING_8 as argument whenever it is possible.
Added WSF_RESPONSE_MESSAGE, and WSF_RESPONSE.put_response (a_response_message)
Now WSF_RESPONSE inherit from WGI_RESPONSE
2011-12-12 11:16:15 +01:00
Jocelyn Fiat
8b4f774bab Handling bad incoming request (keep a check assertion to help during debugging period) 2011-12-12 10:44:50 +01:00
jvelilla
52e6944f37 Merge branch 'master' of github.com:jvelilla/Eiffel-Web-Framework 2011-12-10 18:06:39 -03:00
jvelilla
bf056154d8 Update restbuck client, create and read an order.
Update JSON converter, the id is not important, applied the DRY principle.
Update the ORDER_HANDLER to use the meta_string_variable instead of meta_variable from req.
Fix, the key in meta_variable_table, use c.key instead of c.item
2011-12-10 18:05:41 -03:00
jvelilla
a3c50956f1 Update examples/restbucksCRUD/readme.md 2011-12-10 11:02:20 -02:00
jvelilla
0d67533c83 Merge branch 'master' of github.com:jvelilla/Eiffel-Web-Framework 2011-12-09 21:14:18 -03:00
jvelilla
c0c206e9ae Update the restbuck_client, still work in progress.
Update restbuck_server, remove unused class in inherit.
Update libcurl_http_client_request, to parse context headers before the
execution.
Update wgi_input_stream, commented precondition.
2011-12-09 21:11:16 -03:00
jvelilla
36601fd3a4 Update examples/restbucksCRUD/readme.md 2011-12-09 19:16:07 -02:00
jvelilla
9a85c24c0d Update examples/restbucksCRUD/readme.md 2011-12-09 19:15:33 -02:00
jvelilla
5ef19021eb Update examples/restbucksCRUD/readme.md 2011-12-09 19:10:09 -02:00
jvelilla
7495d0e6a7 Update examples/restbucksCRUD/readme.md 2011-12-09 19:00:58 -02:00
jvelilla
f27c1f97a3 Update examples/restbucksCRUD/readme.md 2011-12-09 18:59:23 -02:00
jvelilla
b96029a750 Update examples/restbucksCRUD/readme.md 2011-12-09 18:56:49 -02:00
jvelilla
9ef10c749a Update examples/restbucksCRUD/readme.md 2011-12-09 18:45:50 -02:00
jvelilla
0aa3d81b22 Update examples/restbucksCRUD/readme.md 2011-12-09 18:44:21 -02:00
jvelilla
5d17b0dd29 Update examples/restbucksCRUD/readme.md 2011-12-09 17:24:01 -02:00
jvelilla
5e2c2af18a Update examples/restbucksCRUD/readme.md 2011-12-09 11:57:47 -02:00
jvelilla
de157be6f1 Update examples/restbucksCRUD/readme.md 2011-12-09 11:57:04 -02:00
jvelilla
f601ae1c8b Update examples/restbucksCRUD/readme.md 2011-12-09 11:52:18 -02:00
jvelilla
f6f94add80 Update examples/restbucksCRUD/readme.md 2011-12-09 11:43:58 -02:00
jvelilla
a70e75f729 Update examples/restbucksCRUD/readme.md 2011-12-09 11:41:58 -02:00
jvelilla
2dd43ad829 Update examples/restbucksCRUD/readme.md 2011-12-09 11:02:31 -02:00
jvelilla
108396bd91 Update examples/restbucksCRUD/readme.md 2011-12-09 10:56:58 -02:00
jvelilla
e9b7fc4c93 Update examples/restbucksCRUD/readme.md 2011-12-08 20:28:14 -02:00
jvelilla
0dd2812574 Updated documentation 2011-12-08 20:04:39 -02:00
jvelilla
d961544b8b Updated restbucksCRUD documentation 2011-12-08 18:48:50 -03:00
jvelilla
3313e9cf81 Added basic two basic examples, refactor rename restbucks
to restbucksCRUD
2011-12-08 18:43:29 -03:00
jvelilla
39b5a70979 Sync Jocelyn repo 2011-12-07 07:22:51 -03:00
Jocelyn Fiat
379e806166 Update README.md 2011-12-03 14:55:55 +01:00
Jocelyn Fiat
c1e08a1bdc Update README.md 2011-12-03 14:55:28 +01:00
Jocelyn Fiat
af21520e5d Update README.md 2011-12-03 14:42:09 +01:00
Jocelyn Fiat
effc6ba81d fixed markdown syntax 2011-12-03 14:40:54 +01:00
Jocelyn Fiat
019fb539ae Remove any useless library include from this .ecf
we just need default_"connector", router, wsf and http
2011-12-02 13:50:39 +01:00
Jocelyn Fiat
03938b43c3 Fixed compilation issue for CGI and libFCGI connector
due to recent changes in interface  (use READABLE_STRING_8)
2011-12-02 12:05:07 +01:00
Jocelyn Fiat
e70d67aed5 Integrated new system to handle form_parameter, input_data in relation with MIME handling
This is not yet clear how to let the user precise its own MIME handler
but it is in progress
2011-12-01 19:12:26 +01:00
Jocelyn Fiat
de38f46d1d fixed remaining issue or useless code to set http environment variable 2011-12-01 18:41:51 +01:00
Jocelyn Fiat
8c79a64f0c Fixed stupid error where we were concatenating ... value by error 2011-12-01 18:38:26 +01:00
Jocelyn Fiat
fff7a5c96d Added WSF_RESPONSE.write_chunk (s: ?READABLE_STRING_8)
to help user sending chunk with "Transfer-Encoding: chunked"
2011-12-01 18:22:47 +01:00
Jocelyn Fiat
1b92403045 Synchronized with Nino 2011-12-01 17:59:35 +01:00
Jocelyn Fiat
59505ccdc4 various renaming and preparation to merge Thread and SCOOP implementation of Eiffel Web Nino 2011-12-01 17:58:01 +01:00
Jocelyn Fiat
8ae4a30ee8 Fixed WSF_RESPONSE.redirect* features 2011-12-01 17:52:31 +01:00
Jocelyn Fiat
8ffe2a8f73 sync with Nino, call to put_readable_string_8 2011-12-01 17:52:00 +01:00
Jocelyn Fiat
800815c8dd Added put_readable_string_8 to avoid call to .as_string_8 2011-12-01 17:48:15 +01:00
Jocelyn Fiat
769f2bb5a8 Synchronized with EiffelWebNino 2011-12-01 15:28:38 +01:00
Jocelyn Fiat
483f065ef1 relative path for README link 2011-12-01 15:13:15 +01:00
jvelilla
8ff055803d Update library/protocol/CONNEG/README.md 2011-12-01 09:38:13 -02:00
jvelilla
3b30f4b994 Update library/protocol/CONNEG/README.md 2011-12-01 09:34:11 -02:00
jvelilla
f71bbc07e8 Updated Conneg library, added test cases 2011-12-01 08:13:42 -03:00
jvelilla
faafa894c2 Merge pull request #9 from jocelyn/master
Removed main thread and removed shared configuration class
2011-12-01 01:23:35 -08:00
Jocelyn Fiat
89cd5a3b44 Removed initial Thread for the HTTP_HANDLER, this is not needed here
Removed HTTP_SERVER_SHARED_CONFIGURATION from the library ... not needed by the library.
Added HTTP_SERVER_SHARED_CONFIGURATION  to the example to show how to share the configuration, if needed
2011-11-30 19:05:16 +01:00
jvelilla
9b9bc1f190 Fixed minor issue, added test cases to check language negotiation. 2011-11-30 08:56:13 -03:00
jvelilla
6feaf5757f Update conneg library and test cases 2011-11-30 07:15:17 -03:00
jfiat
2b7043f670 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
2011-11-28 08:21:54 +00:00
Jocelyn Fiat
6f4ec89404 Fixed example due to recent interface changes 2011-11-25 20:44:32 +01:00
Jocelyn Fiat
cdfc6851e7 - (WGI|WSF)_RESPONSE(*) renamed write_headers_string as write_header_text
- HTTP_HEADER.string does not have the ending CRLFCRLF .. but just CRLF
- WGI_RESPONSE.write_header_text has the responsibility to handle the last blank line CRLF (separating the header from the message)
- HTTP_HEADER.string does not set anymore a default content type as text/html
- added WGI_RESPONSE.write_header_lines (ITERABLE [TUPLE [name,value: READABLE_STRING_8]] mainly as an helper method,
   this way the WGI user does not have to know about the CRLF end of line
2011-11-25 20:43:04 +01:00
Jocelyn Fiat
e0ec84611e Applied recent renaming from WGI_RESPONSE_BUFFER as WGI_RESPONSE 2011-11-25 19:21:45 +01:00
Jocelyn Fiat
2234d3712b updated WGI specification 2011-11-25 18:25:50 +01:00
Jocelyn Fiat
c89ccfa768 Added missing wgi_connector 2011-11-25 16:27:46 +01:00
Jocelyn Fiat
1a88388ffe added "redirect" helper feature to WSF_RESPONSE 2011-11-25 16:24:55 +01:00
Jocelyn Fiat
5eab38778a Added `{WGI_REQUEST}.wgi_*' function to WSF_REQUEST 2011-11-25 16:24:26 +01:00
Jocelyn Fiat
9d457bb978 rename application' as service' 2011-11-25 16:22:44 +01:00
Jocelyn Fiat
42be0b2a4e Use HTTP_HEADER instead of WSF_HEADER
(WSF_HEADER is kept for convenience and existing code)
2011-11-25 15:53:15 +01:00
Jocelyn Fiat
48d4d26cda better script to check compilation and tests 2011-11-25 14:52:00 +01:00
Jocelyn Fiat
182749d010 Moved implementation of WSF_HEADER to HTTP_HEADER in the http library 2011-11-25 14:51:46 +01:00
Jocelyn Fiat
fd0912904c Simplified EWSGI interfaces
Renamed WGI_RESPONSE_BUFFER as WGI_RESPONSE to avoid confusion
Removed EWF_HEADER and removed related caller from WGI implementation,
   now this is only part of WSF library
Added wgi_version, wgi_implementation and wgi_connector to the WGI_REQUEST interface
   to give more information to the user
Added back WGI_CONNECTOR to WGI specification, mainly because of `{WGI_REQUEST}.wgi_connector'
   simplified WGI_CONNECTOR to contain for now only `name' and `version'
   if the implementation of connector inherit from WGI_CONNECTOR (recommended)
   this might gives more access to the user using a reverse assignment for specific needs
   (but this usage is not recommended due to portability issue on other connector)
Removed useless connector.ecf since now EWF/WGI library provides the helper classes
2011-11-25 14:39:48 +01:00
Jocelyn Fiat
51b912c4f8 Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework.wiki 2011-11-25 13:18:46 +01:00
jvelilla
7dd9a30740 Updated HTTP Library Features (markdown) 2011-11-24 09:38:40 -08:00
jvelilla
92c58bbbe0 Updated HTTP Library Features (markdown) 2011-11-24 09:37:45 -08:00
jvelilla
f4b621ba08 Updated HTTP Library Features (markdown) 2011-11-24 09:34:35 -08:00
jvelilla
dc0c90ab46 Updated HTTP Library Features (markdown) 2011-11-24 09:32:07 -08:00
jvelilla
fdef9b0c8f Updated HTTP Library Features (markdown) 2011-11-24 09:23:42 -08:00
jvelilla
40ec2f6419 Created HTTP client library (markdown) 2011-11-24 09:22:12 -08:00
Jocelyn Fiat
3032b91ff7 Fixed sample example config file after recent location change for "rest" lib 2011-11-23 18:36:56 +01:00
Jocelyn Fiat
772b88f257 Improved run_CI_tests.py and include the compile_all call directly in the python script.
If compile_all tool supports  -keep ... let's use it. (recent addition)
2011-11-23 16:35:22 +01:00
Jocelyn Fiat
a1cc2d1d1a fixed rest(-safe).ecf due to recent location change 2011-11-23 15:37:01 +01:00
Jocelyn Fiat
9f90bf56a5 Merge branch 'master' of github.com:Eiffel-World/Eiffel-Web-Framework 2011-11-23 15:31:47 +01:00
Jocelyn Fiat
dbea0e509b Updated README.md in relation with "rest" lib relocation 2011-11-23 15:27:51 +01:00
Jocelyn Fiat
a3f28e3945 Move "rest" library under "draft/..." since it is more an experiment rather than a real REST library 2011-11-23 15:18:35 +01:00
Jocelyn Fiat
379a6193e9 Update draft/README.md 2011-11-21 18:28:33 +01:00
Jocelyn Fiat
03d9c3785c updated Eiffel libfcgi README file 2011-11-21 17:43:02 +01:00
Jocelyn Fiat
612915c918 Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework
Conflicts:
	library/server/libfcgi/Clib/README.md
2011-11-21 17:33:34 +01:00
Jocelyn Fiat
ff967d6332 Added scripts to help building the libfcgi.dll and .lib from modified source of libfcgi
Extracted into "libfcgi" only the files needed to compile the Windows .dll and .lib
2011-11-21 17:07:38 +01:00
Jocelyn Fiat
8d75a04068 Added scripts to help building the libfcgi.dll and .lib from modified source of libfcgi 2011-11-21 16:38:36 +01:00
Jocelyn Fiat
202ad2861b updated README to apply 'ext' renamed as 'contrib' 2011-11-21 14:30:03 +01:00
Jocelyn Fiat
44857d28ec fixed compilation for tests.ecf 2011-11-18 14:56:02 +01:00
Jocelyn Fiat
e3597c0f3b fixed typo 2011-11-18 14:18:30 +01:00
Jocelyn Fiat
0cce4d8244 Updated "draft" folder which contain potential future addition to EWF 2011-11-18 14:18:22 +01:00
Jocelyn Fiat
aab910ab64 Added "draft" folder to contain potential future addition to EWF 2011-11-18 13:56:07 +01:00
Jocelyn Fiat
257ede7586 restructured CONNEG library
fixed various issue in .ecf files
2011-11-18 11:14:30 +01:00
jvelilla
b58e4e19e1 Initial import CONNEG library, support server side
content negotiation.
2011-11-18 10:19:54 +01:00
Jocelyn Fiat
6ec37c90a2 Rename "ext" as "contrib" in compile_all.ini as well
no need to test the code coming from other projects.
2011-11-17 16:03:29 +01:00
Jocelyn Fiat
49c3e8e789 Renamed "ext" folder as "contrib" folder and reorganized a little bit
Renamed any *_APPLICATION as *_SERVICE
   mainly because those components
   such as WSF_APPLICATION, renamed as WSF_SERVICE
   are not always the main application entry, and "service" describe them better
Minor implementation change in WSF_REQUEST
Cosmetics
2011-11-17 15:50:30 +01:00
Jocelyn Fiat
cc11debf08 handle last run failure 2011-11-16 16:18:27 +01:00
Jocelyn Fiat
b71a22d040 Added request method PATCH even if not really used for now, it might in the future 2011-11-16 15:52:00 +01:00
Jocelyn Fiat
7022206a73 Do not print command during script execution 2011-11-16 13:10:35 +01:00
Jocelyn Fiat
b715d674ca fixed indentation in python script 2011-11-16 09:00:23 +01:00
Jocelyn Fiat
02f5bdd801 Added information output to run_CI_tests.py 2011-11-16 08:57:02 +01:00
Jocelyn Fiat
203d51a97e updated run_CI_tests.py 2011-11-16 08:48:24 +01:00
Jocelyn Fiat
733296e71e updated run_CI_tests.py 2011-11-16 08:42:08 +01:00
Jocelyn Fiat
0a497b9a4d updated run_CI_tests.py 2011-11-16 08:34:00 +01:00
Jocelyn Fiat
4ed91a91a2 updated run_CI_tests.py 2011-11-16 07:51:04 +01:00
Jocelyn Fiat
a76eb75267 removed unused local variables 2011-11-16 07:25:29 +01:00
Jocelyn Fiat
2c94a98730 added a python script to be use inside jenkins CI server
(experimental for now)
2011-11-16 07:25:15 +01:00
Jocelyn Fiat
cc960310e9 cosmetic 2011-11-14 19:06:31 +01:00
Jocelyn Fiat
d9daac67d9 cosmetics 2011-11-14 19:05:48 +01:00
Jocelyn Fiat
955f73dee9 Added various README.md (using the markdown syntax) 2011-11-14 19:00:00 +01:00
Jocelyn Fiat
137ed3888c updated README with links to sub READM.md 2011-11-14 18:46:37 +01:00
Jocelyn Fiat
8382e8f134 sync with Eiffel Web Nino 2011-11-14 16:39:26 +01:00
Jocelyn Fiat
713978d70f Using `is_verbose' instead of debug clause "nino" 2011-11-14 16:32:28 +01:00
Jocelyn Fiat
b78c44f4a1 Applied the removal of HTTP_INPUT_STREAM and HTTP_OUTPUT_STREAM to the example. 2011-11-14 16:32:09 +01:00
Jocelyn Fiat
0b7ea3c427 Added default WSF_APPLICATION for libfcgi connector 2011-11-14 16:27:55 +01:00
Jocelyn Fiat
1e7b370859 code removal 2011-11-14 16:26:31 +01:00
Jocelyn Fiat
8c02b0d546 Updated libfcgi source code for Windows AND Linux.
Cleaning some code and feature clauses.
2011-11-14 15:44:10 +01:00
Jocelyn Fiat
13b09adc8c Changed the WGI_INPUT_STREAM and WGI_OUTPUT_STREAM interfaces
main changes for existing code  `read_stream' is renamed `read_string'
2011-11-14 14:17:41 +01:00
jvelilla
9f2abab670 Merge pull request #8 from jocelyn/master
Removed HTTP_(INPUT,OUTPUT)_STREAM classes
2011-11-11 03:57:24 -08:00
Jocelyn Fiat
a46c08de11 Removed HTTP_(INPUT,OUTPUT)_STREAM, since it is unlikely that we use something else than TCP_STREAM_SOCKET
This way, we remove one indirection for users, and get smaller code.
2011-11-10 22:05:34 +01:00
Jocelyn Fiat
bc2e8b8ee2 Added is_request_method (STRING): BOOLEAN to help users 2011-11-09 18:07:03 +01:00
Jocelyn Fiat
36493b4324 updated readme with better way to get the source code recursively 2011-11-07 11:11:04 +01:00
Jocelyn Fiat
a09908c048 added script to build archive for download area 2011-11-07 01:22:14 -08:00
Jocelyn Fiat
d96ee66a32 sync with Eiffel Web Nino 2011-11-04 20:28:08 +01:00
Jocelyn Fiat
abd67c8caa applied recent changes related to HTTP_HANDLER.make 2011-11-04 20:27:30 +01:00
Jocelyn Fiat
7669ccfc1d sync with nino and applied changes to connector 2011-11-04 20:21:35 +01:00
Jocelyn Fiat
53496e010b removed useless "a_name" argument
Fixed typo in on_launched
2011-11-04 19:09:49 +01:00
Jocelyn Fiat
3a6e3592ae Use recent changes from Nino, to get access to the launched and port information.
Quite useful when launching using port=0 to use a random free port.
This is great for testing, this way we can run many tests in the same time without any port blocking.
2011-11-04 12:15:40 +01:00
jvelilla
cef6f30251 Merge pull request #6 from jocelyn/master
new event on_launched and on_stopped to ease integration with launching application
2011-11-04 03:51:27 -07:00
Jocelyn Fiat
00ffa50054 added events on_launched and on_stopped to ease integration with launching application 2011-11-04 11:46:56 +01:00
Jocelyn Fiat
07f9a8cec7 applied recent changes from Nino 2011-11-03 18:50:19 +01:00
jvelilla
cac126f2f1 Merge pull request #5 from jocelyn/master
Please pull this change
2011-11-03 10:27:27 -07:00
Jocelyn Fiat
c53d4d37a7 added access to the effective port that the server is listening to (useful when we set port to 0 it use a random free port)
added verbose , so that we write message to the console only if desired.
2011-11-03 18:13:55 +01:00
Jocelyn Fiat
16cab53fb4 removed compliance on ewsgi, since now we target WSF
applied recent changes related to WSF_VALUE
2011-11-02 16:11:40 +01:00
Jocelyn Fiat
a2bf68e18a Safer interface for WSF_VALUE, when related to STRING value 2011-11-02 15:42:58 +01:00
Jocelyn Fiat
214255c4b9 sync with submodules 2011-11-02 13:30:35 +01:00
Jocelyn Fiat
082b8902ea Merge branch 'master' of git://github.com/Eiffel-World/Eiffel-Web-Framework 2011-11-02 13:11:09 +01:00
Jocelyn Fiat
ee9722fa18 renamed WSF_(.*)_VALUE as WSF_$1 2011-11-02 13:10:35 +01:00
Jocelyn Fiat
4a81d02d12 Fixed obsolete calls, and compilation error. 2011-10-31 18:42:44 +01:00
Jocelyn Fiat
0f5ae7e153 fixed path to cURL.ecf file, using the correct uppercase 2011-10-31 09:14:43 -07:00
Jocelyn Fiat
179dbceaba Fixed missing syntax="provisional" , this was preventing compiling with "across" statements 2011-10-31 16:06:10 +01:00
Jocelyn Fiat
45292e0248 Better implementation to get http header for http_client, and to get list of header entries by key,value 2011-10-31 16:05:34 +01:00
Jocelyn Fiat
a38fca267b Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework 2011-10-31 12:33:20 +01:00
Jocelyn Fiat
d4266a83ec updated instructions related to submodules 2011-10-31 02:43:44 -07:00
Jocelyn Fiat
83a181ebf1 Fixed remaining 6.8 vs 7.0 compilation issue related to UTF8_(URL_)ENCODER 2011-10-31 09:02:19 +01:00
Jocelyn Fiat
54ecd2b1e8 Merge branch 'master' of github.com:Eiffel-World/Eiffel-Web-Framework 2011-10-31 08:48:44 +01:00
Jocelyn Fiat
da8a216448 removed unused local variable 2011-10-31 08:48:19 +01:00
Jocelyn Fiat
085b520879 Added convenient features to BASE64
- decode_string_to_buffer (v: STRING; a_buffer: STRING)
   - decode_string_to_output_medium (v: STRING; a_output: IO_MEDIUM)
2011-10-31 08:45:50 +01:00
Jocelyn Fiat
c115a40922 removed unused local variable 2011-10-31 08:43:04 +01:00
Jocelyn Fiat
6f600362e3 Fixed code to be compilable with EiffelStudio 6.8 and 7.0 (due to recent change in UNICODE_CONVERSION) UNICODE_CONVERSION 2011-10-31 08:42:48 +01:00
jvelilla
bd36aa8b04 Added headers to response in HTTP_CLIENT_RESPONSE 2011-10-28 14:25:26 -03:00
Jocelyn Fiat
812f521c88 Merge branch 'master' of github.com:Eiffel-World/Eiffel-Web-Framework 2011-10-27 16:24:40 +02:00
Jocelyn Fiat
beb1bd1599 use '%/123/' syntax, to make sure no editor replace the accentued characters 2011-10-27 16:24:19 +02:00
Jocelyn Fiat
9bbcdc9927 removed unwanted .rc 2011-10-27 16:03:10 +02:00
Jocelyn Fiat
0d637d478a Fixed a previously character changes in WSF_REQUEST (related to safe_filename), and modified the implementation to use inspect
Fixed the request_content_type computation
Cosmetic in REQUEST_RESOURCE_HANDLER_HELPER
2011-10-27 16:00:33 +02:00
Jocelyn Fiat
8e4e7a5084 Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework
Conflicts:
	library/server/wsf/src/wsf_request.e
2011-10-27 15:49:12 +02:00
Jocelyn Fiat
95d44890d9 added script to update current git working copy and submodules recursively 2011-10-27 14:58:14 +02:00
Jocelyn Fiat
161a5c720b Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-10-27 14:45:37 +02:00
Jocelyn Fiat
35a4cd7df9 cosmetic, or minor changes 2011-10-27 14:45:14 +02:00
Jocelyn Fiat
70ee7ff47a Merge branch 'master' of github.com:Eiffel-World/Eiffel-Web-Framework 2011-10-27 14:43:32 +02:00
jvelilla
c9343688f3 Added eel and eapml in EWF libraries.
Removed them from gitmodule
2011-10-27 08:29:01 -03:00
jvelilla
f804a705d5 Updated request resource handler.
TODO: implement Content-Negotiation
2011-10-26 08:21:50 -03:00
larryl
f17f785ee3 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
2011-10-25 08:03:57 +00:00
Jocelyn Fiat
926c0a79b7 Start index for list[]=a&list[]=b ... from 1 instead of 0
Stick to Eiffel spirit
2011-10-24 17:44:13 +02:00
Jocelyn Fiat
fb7854fbcc Added visitor patterns to WSF_VALUE
Handling UTF-8 unencoding for WSF_VALUE ...
Added WSF_TABLE_VALUE to handle list[]=a&list[]=b ...

Library encoder: added UTF8 facilities
2011-10-24 17:23:36 +02:00
Jocelyn Fiat
663a39d2ec missing implementation (forgot to uncomment) 2011-10-24 09:07:26 +03:00
jvelilla
6fb36da9ac Merge remote-tracking branch 'jocelynEWF/master'
Conflicts:
	examples/restbucks/restbucks-safe.ecf
	examples/restbucks/src/resource/order_handler.e
	library/server/request/router/src/misc/request_resource_handler_helper.e
2011-10-23 20:58:28 -03:00
jvelilla
3fbd81aeb1 Added eel and eapml modules 2011-10-23 09:10:27 -03:00
jvelilla
6344f964fa Update delete method to hanlde method not allowed.
Added method not allowed to request resource handler helper class.
Update gitmodules
2011-10-23 09:05:12 -03:00
Jocelyn Fiat
14a2c01f41 Applied recent changes on WGI_ and WSF_
Moved classes away from ewsgi, restructured, cleaned
2011-10-21 16:58:23 +02:00
Jocelyn Fiat
79e12b8d04 Continued reducing WGI and move implementation to WSF (Web Server Framework)
Removed many usage of READABLE_STRING_GENERAL in favor to READABLE_STRING_8
   to avoid potential nasty issues in user's code
URI-template is working only with STRING_8, then changed any _GENERAL or _STRING_32 to _STRING_8
2011-10-21 16:58:18 +02:00
Jocelyn Fiat
aec0136739 First try to get a limited WGI_ and use WSF_ as default framework 2011-10-21 16:58:11 +02:00
Jocelyn Fiat
7fd4cdbe44 Code cleaning, and nicer output under debug clause 2011-10-21 13:40:56 +02:00
jvelilla
9f53287226 Update Restbucks example: Conditional GET, PUT.
Added a response method to support resource not
modified.
Added a ETAG_UTILS class to calcule md5_digest.
Added ext libs eel and eapml.
2011-10-21 08:26:14 -03:00
Jocelyn Fiat
eaa99c9c61 Used object test 2011-10-19 00:40:04 +02:00
Jocelyn Fiat
5f492d6fb6 removed useless local variable 2011-10-19 00:35:32 +02:00
Jocelyn Fiat
c3f5376ef5 fixed cgi and libfcgi connectors due to recent changes from WGI_APPLICATION 2011-10-14 14:27:54 +02:00
Jocelyn Fiat
21e973f8a4 Removed handling of internal error from WGI_APPLICATION
And for now added it into nino connector
2011-10-14 14:15:23 +02:00
Jocelyn Fiat
dec1958909 Fixed issue with index in uri template matcher 2011-10-14 14:14:13 +02:00
Jocelyn Fiat
1453873b6c Added HTTP_FILE_EXTENSION_MIME_MAPPING
Added REQUEST_FILE_SYSTEM_HANDLER to the router library
Added file system handler in "hello_routed_world" example
2011-10-14 14:13:40 +02:00
jvelilla
8255dfd996 Added handle_resource_conflict_response feature to handle 409 reponse,
Cosmetic.
2011-10-13 09:07:37 -03:00
Jocelyn Fiat
e66c666e64 removed unwanted first line 2011-10-12 22:56:01 +03:00
Jocelyn Fiat
fcdc164214 Added data and file for post and put request methods 2011-10-12 21:45:57 +02:00
Jocelyn Fiat
4c36d75ef3 Using Transfer-Encoding: chunked in example to send response progressively 2011-10-12 17:23:24 +02:00
Jocelyn Fiat
09030a27d9 sync with submodules 2011-10-12 17:22:46 +02:00
Jocelyn Fiat
b9ca22006b removed unwanted code 2011-10-12 15:38:45 +02:00
Jocelyn Fiat
593b48fe90 applied recent changes on HTTP_REQUEST_METHOD_CONSTANTS 2011-10-12 11:56:25 +02:00
Jocelyn Fiat
735730b5a0 cosmetic 2011-10-12 11:52:00 +02:00
Jocelyn Fiat
035a133b5b Addition to "http" library, separated constants into
- HTTP_MIME_TYPES
 - HTTP_HEADER_NAMES
 - HTTP_REQUEST_METHODS
 - HTTP_STATUS_CODE   (already exists)

Do not set the "Status" header when using WGI_RESPONSE_BUFFER.write_header (...)
Cosmetic
2011-10-12 11:51:49 +02:00
Jocelyn Fiat
0144e97d69 Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework
Conflicts:	examples/restbucks/src/domain/json_order_converter.e
Cosmetics
2011-10-11 14:25:22 +02:00
Jocelyn Fiat
26bfd72f5f Fixed errors recently introduced 2011-10-11 14:16:08 +02:00
Jocelyn Fiat
88542c2762 Merge branch 'master' of github.com:Eiffel-World/Eiffel-Web-Framework 2011-10-11 14:09:10 +02:00
Jocelyn Fiat
12fc54a403 sync with latest JSON 2011-10-11 14:08:41 +02:00
jvelilla
eb44eef885 Update order_handler, fix json_order_converter 2011-10-11 08:18:46 -03:00
Jocelyn Fiat
c2b66d6ca6 Use local curl if compiler is < 7.0.8.7340
otherwise, use ISE_LIBRARY cURL
2011-10-11 11:09:00 +02:00
Jocelyn Fiat
6758c4aef4 Temporary fixed issue of using modified cURL (which is cURL provided with EiffelStudio 7.0)
This changes will be reverted in the future
2011-10-11 10:46:56 +02:00
Jocelyn Fiat
6408bec628 Updated readme related to mirrored Eiffel cURL library 2011-10-10 17:56:09 +02:00
Jocelyn Fiat
f77ba9ccd8 added submodule ext/ise_library/curl to use the updated Eiffel cURL from ISE. 2011-10-10 17:48:18 +02:00
Jocelyn Fiat
c105c267e7 cosmetic 2011-10-10 16:09:44 +02:00
Jocelyn Fiat
19da4d6fd0 added http diagrams found on the web 2011-10-07 16:05:39 +02:00
Jocelyn Fiat
a9e2dc1135 Added the possibility to specify the supported content types
Added FIXME
2011-10-07 15:39:04 +02:00
Jocelyn Fiat
4cd1b67607 Cosmetic 2011-10-07 14:40:04 +02:00
Jocelyn Fiat
34bb793599 Added license.lic and copyright to Javier 2011-10-07 14:36:20 +02:00
Jocelyn Fiat
142dbc39b4 Cosmetic 2011-10-07 14:11:03 +02:00
Jocelyn Fiat
b17887d634 Added "Date:" helper feature in EWF_HEADER
Added license.lic to restbuck example, and mainly copyright to Javier
Use HTTP_STATUS_CODES
Minor improvements using object tests
Cosmetic (indentation, ..)
2011-10-07 14:03:31 +02:00
Jocelyn Fiat
f443087e71 Added a first simple test client to test the restbuck client 2011-10-06 19:09:56 +02:00
Jocelyn Fiat
e5eb11b4e7 added support for data in POST request 2011-10-06 19:09:17 +02:00
Jocelyn Fiat
720d8be08a Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework 2011-10-06 17:37:41 +02:00
jvelilla
ed04b7fba0 Added REQUEST_RESOURCE_HANDLER_HELPER class to contain
common http method behavior.
Updated ORDER_HANLDER to use this new class.
2011-10-06 09:54:20 -03:00
Jocelyn Fiat
4c9e7a4331 Added `base_url' for REQUEST_ROUTER (and descendants)
Fixed implementation of REST_REQUEST_AGENT_HANDLER to avoid wrong path in inherited routine.
Allow to build a URI_TEMPLATE from another URI TEMPLATE,
   this way, if later we have more attribute (status or settings) to URI_TEMPLATE,
   we'll be able to change the `template' without breaking the settings
2011-10-05 17:09:16 +02:00
Jocelyn Fiat
cc6992a6fc added missing call to pre_execute and post_execute 2011-10-05 14:47:59 +02:00
Jocelyn Fiat
71c851ca39 Fixed missing http:// in absolute URL 2011-10-05 14:47:30 +02:00
Jocelyn Fiat
900ed8baea remove pre_execute, and post_execute, and make process_request frozen
this way, the user won't be tempted to redefine feature not being part of pure EWSGI interface.
2011-10-05 14:46:39 +02:00
Jocelyn Fiat
dba55fcfd9 better argument name, to precise the timeout is in second
also in comment.
2011-10-05 14:45:47 +02:00
Jocelyn Fiat
456299ccdf Fixed agent handler for rest library 2011-10-04 17:33:15 +02:00
Jocelyn Fiat
810208f176 Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-10-04 16:19:36 +02:00
Jocelyn Fiat
27c637b066 fixed inheritance and precursor bad usage. 2011-10-04 16:19:09 +02:00
Jocelyn Fiat
a0df04a7f2 Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-10-04 09:50:14 +02:00
Jocelyn Fiat
bc5d20b221 Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework 2011-10-04 09:49:20 +02:00
jvelilla
7ba3eb9ecd Updated support for PUT. Now the example support
GET, POST, PUT, DELETE.
2011-10-03 09:26:01 -03:00
Jocelyn Fiat
2b14a40898 fixed compilation for ewsgi/tests/tests.ecf file 2011-09-28 17:08:28 +02:00
Jocelyn Fiat
aa20a1423f Made WGI_VALUE.name as READABLE_STRING_32 .. otherwise it is a pain to manipulate.
Changed return type of meta_variable to be WGI_STRING_VALUE ... since the meta variable can not be anything else.
Made sure REQUEST_URI starts with one and only one slash
Internal implementation: the _table now compares object
Removed SELF variable ... at least for now
Be sure to provide a REQUEST_URI even if the underlying connector does not.
2011-09-28 16:41:22 +02:00
Jocelyn Fiat
34c8cfa427 cleaned http_client configuration files 2011-09-28 14:53:34 +02:00
Jocelyn Fiat
f7dcadccd5 Added library/library.index 2011-09-28 14:42:53 +02:00
Jocelyn Fiat
f24df1d745 restructured ewsgi to avoid too many sub cluster 2011-09-28 14:42:34 +02:00
jvelilla
5adf40a9ed Updated Restbucks examples, handle not method allowed
in a better way, added the readme file.
2011-09-28 08:54:12 -03:00
jvelilla
f20bc42b76 Merge remote-tracking branch 'jocelynEWF/master' 2011-09-28 07:36:35 -03:00
jfiat
19637b616b 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
2011-09-27 08:06:20 +00:00
Jocelyn Fiat
a4df57a7ac fixed compilation of rest example 2011-09-26 20:54:04 +02:00
Jocelyn Fiat
df59ae579b fixed typo 2011-09-26 17:19:37 +02:00
jocelyn
2b112da43d Updated EWSGI specification (markdown) 2011-09-26 08:18:15 -07:00
Jocelyn Fiat
738eb7555f Changed ITERATION_CURSOR [WGI_VALUE] into ITERABLE [WGI_VALUE] for WGI_REQUEST.*parameters* and similar
Applied recent changes on EWF_HEADER
2011-09-26 17:10:05 +02:00
jocelyn
aaf8af85fd Updated EWSGI (markdown) 2011-09-26 07:53:32 -07:00
jocelyn
beb721ed4b Updated EWSGI (markdown) 2011-09-26 07:51:08 -07:00
jocelyn
2407cb6a63 Updated EWSGI (markdown) 2011-09-26 07:50:17 -07:00
Jocelyn Fiat
d397d4e35d Updated changelogs.txt
sync with nino and doc
2011-09-23 18:34:44 +02:00
Jocelyn Fiat
eeaa47d4f1 Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-09-23 18:23:35 +02:00
Jocelyn Fiat
0db4317a49 Added AutoTest simple cases for ewsgi using Nino web server 2011-09-23 18:22:42 +02:00
Jocelyn Fiat
668847f8e8 Fixing issue with experimental WGI_MULTIPLE_STRING_VALUE
Fixed issue with RAW_POST_DATA
2011-09-23 18:21:57 +02:00
Jocelyn Fiat
e7fd7af2c5 Removed put_redirection' and replaced by put_location'
Removed useless code in some features
2011-09-23 18:20:23 +02:00
Jocelyn Fiat
24a5c7613d Use READABLE_STRING(_*) instead of just STRING(_*) 2011-09-23 18:20:16 +02:00
Jocelyn Fiat
d9f6cbe80e Added feature to shutdown the Nino http server 2011-09-23 18:18:54 +02:00
Jocelyn Fiat
95ec2e77df Added error reporting in HTTP_CLIENT_RESPONSE
Added missing set_connect_timeout
2011-09-23 18:18:27 +02:00
jvelilla
19b5edd9b4 Added validations. 2011-09-23 09:06:23 -03:00
Jocelyn Fiat
d25146dd27 Merge branch 'master' of https://github.com/jvelilla/Eiffel-Web-Framework 2011-09-22 16:19:48 +02:00
Jocelyn Fiat
ab1c696837 Added code to create an HTTP_AUTHORIZATION from the client side as well.
So now we can either interpret an HTTP_AUTHORIZATION  or build one HTTP_AUTHORIZATION

So far , only Basic auth is supported.
2011-09-22 15:13:59 +02:00
Jocelyn Fiat
dae8e1d67d Made all libraries compilable in any mode (voidsafe or not)
Fixed related examples
2011-09-22 15:12:33 +02:00
jvelilla
888bc61522 Initial import, work in progress restbuck example. Only support create
a resource
2011-09-22 09:29:59 -03:00
jvelilla
8291905da1 Merge remote-tracking branch 'jocelynEWF/master' 2011-09-22 07:53:23 -03:00
Jocelyn Fiat
d9ba97d33b Fixed issue where Content-Type and Content-Length were translated into HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH instead of just
CONTENT_TYPE and CONTENT_LENGTH
2011-09-21 15:33:40 +02:00
Jocelyn Fiat
33eddd9197 better assertion to ensure `base' is a valid base url 2011-09-21 15:30:20 +02:00
Jocelyn Fiat
458cb56f75 synch with Nino 2011-09-21 15:29:25 +02:00
Jocelyn Fiat
88c015470e better return type for http client functions
added helper features
2011-09-21 15:29:12 +02:00
Jocelyn Fiat
58767bb1c1 add precondition saying the request line should not be empty 2011-09-21 15:26:23 +02:00
jvelilla
f68a713c48 Merge remote-tracking branch 'jocelynEWF/master' 2011-09-21 07:49:40 -03:00
Jocelyn Fiat
0414cd4501 fixed case sensitive path 2011-09-20 18:19:23 +02:00
Jocelyn Fiat
284d7826c8 missing -safe.ecf config file for http_client 2011-09-20 16:59:54 +02:00
Jocelyn Fiat
dff267cd58 Now using READABLE_STRING_... type 2011-09-20 16:57:28 +02:00
Jocelyn Fiat
c2f7c198e0 Added simple HTTP client.
For now the implementation is using Eiffel cURL library.
It requires Eiffel cURL coming with next EiffelStudio 7.0 (or from eiffelstudio's repo from rev#87244 )
2011-09-20 16:55:44 +02:00
jfiat
8034123683 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
2011-09-20 14:06:20 +00:00
Jocelyn Fiat
b3ef7c846b Fixed issues in WGI_REQUEST's invariant
Fixed issues with guessing the default format for REST handling
Fixed issue with .._ROUTING_.. component.
2011-09-16 20:59:06 +02:00
Jocelyn Fiat
111812c4e9 Fixed issue with uri template router ..
it was applying on request_uri instead of path_info
now it match on PATH_INFO
2011-09-16 18:56:02 +02:00
Jocelyn Fiat
92d8357d09 more flexible authenticated query .. on handler, and not anymore on context object 2011-09-16 18:55:26 +02:00
Jocelyn Fiat
64060cfa41 fixed wrong order in parameter for callers of set_meta_string_variable 2011-09-16 18:54:44 +02:00
Jocelyn Fiat
d3239ec41b added debug_output to WGI_VALUE 2011-09-16 18:54:16 +02:00
Jocelyn Fiat
7b1557a52a first version of http authorization ..
for now, only basic digest
2011-09-16 18:53:57 +02:00
Jocelyn Fiat
c9a4ebcb23 added request_handler_routes_recorder to provide an implementation for `REQUEST_HANDLER.on_handler_mapped' 2011-09-16 15:17:49 +02:00
Jocelyn Fiat
3f899f6aae Added "on_handler_mapped" callback
to allow any REQUEST_HANDLER to record the existing routes.
2011-09-16 15:11:37 +02:00
Jocelyn Fiat
18684d167b typo 2011-09-16 15:02:08 +02:00
jvelilla
32bb75b9dc Merge remote-tracking branch 'jocelynEWF/master' 2011-09-16 07:04:40 -03:00
Jocelyn Fiat
d06bc76944 minor enhancement of error lib 2011-09-15 22:02:58 +02:00
Jocelyn Fiat
86825854ca Added WGI_MULTIPLE_STRING_VALUE
Renamed value as WGI_STRING_VALUE.string
Renamed a few classes .._CONTEXT_I  as .._CONTEXT
updated example.
2011-09-15 17:49:47 +02:00
Jocelyn Fiat
774cd004db cosmetic 2011-09-15 15:49:53 +02:00
Jocelyn Fiat
c300cf5b6e Merge branch 'master' of git://github.com/Eiffel-World/Eiffel-Web-Framework 2011-09-15 11:17:07 +02:00
Jocelyn Fiat
68247a1849 updated README.md 2011-09-15 10:55:14 +02:00
Jocelyn Fiat
22fd7490fe Simplified interface of "router" library classes 2011-09-14 16:48:27 +02:00
Jocelyn Fiat
8b6e9273fa applied renaming for rest and router lib 2011-09-14 16:05:01 +02:00
Jocelyn Fiat
76fa3e9ff5 Reorganized library "server/request/rest" 2011-09-14 15:46:45 +02:00
Jocelyn Fiat
1e3770d724 some renaming to use _I for the generic classes, and removed the DEFAULT_ prefix for default implementation
this should makes things easier for new users
2011-09-14 15:39:37 +02:00
Jocelyn Fiat
840ae1e6e4 reorganized router library 2011-09-14 15:04:29 +02:00
Jocelyn Fiat
5626e03aa8 - Adopted deferred WGI_VALUE design for Result type of *_parameter and similar functions
- Adopted the ITERATION_CURSOR [WGI_VALUE] design for *_parameters and similar functions
- renamed parameter as item
- provided helper function to handle "string" value parameters

Experimental for now.
2011-09-14 14:54:06 +02:00
Jocelyn Fiat
4bcea900a6 better result type (using READABLE_..) 2011-09-14 14:48:08 +02:00
Jocelyn Fiat
b1f5065e63 sync with nino 2011-09-14 14:47:29 +02:00
jvelilla
c37fe9ad79 Merge remote-tracking branch 'jocelynEWF/master' 2011-09-14 07:58:40 -03:00
Jocelyn Fiat
2e53f7e0c4 updated changelogs 2011-09-13 17:12:12 +02:00
Jocelyn Fiat
512f2d2ce5 Added first draft for RESTful library
note: the interfaces are likely to change in the future
2011-09-13 17:08:40 +02:00
Jocelyn Fiat
92105ca7b3 updated config file and examples 2011-09-13 17:07:17 +02:00
Jocelyn Fiat
f0c6eec23d adding routing handler
few renaming
2011-09-13 16:49:45 +02:00
Jocelyn Fiat
32197d0513 changing design to use generic instead of anchor types 2011-09-09 16:24:11 +02:00
Jocelyn Fiat
11286eeeef make router more easy to inherit from and specialized 2011-09-09 14:10:54 +02:00
Jocelyn Fiat
fb8412fcae Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-09-09 08:54:20 +02:00
Jocelyn Fiat
9ec87a4329 Added support during match for {/vars}
and also handle cases such as   /foo.{format}{/vars}  or /foo.{format}{?vars} where no literal exists between the uri template expressions
2011-09-09 08:51:45 +02:00
Jocelyn Fiat
0c7e6c08e7 better type for argument and result (using READABLE_...) 2011-09-09 08:50:29 +02:00
Jocelyn Fiat
c1120a4226 change to standard default values 2011-09-09 08:50:05 +02:00
jvelilla
5c0cae35ef Sync to jocelyn EWF master 2011-09-08 07:45:10 -03:00
jvelilla
7bd5cdc232 Merge remote-tracking branch 'jocelynEWF/master' 2011-09-08 07:44:27 -03:00
jvelilla
ef85c07603 Update 2011-09-08 07:43:36 -03:00
Jocelyn Fiat
10db3c28a5 sync doc/wiki 2011-09-07 14:31:52 +02:00
jocelyn
820bd7bd6f Updated EWSGI (markdown) 2011-09-07 05:30:29 -07:00
Jocelyn Fiat
54dc7de189 use `resource' as generic name for uri or uri_template 2011-09-07 12:46:09 +02:00
Jocelyn Fiat
2244d101ea added changelogs.txt 2011-09-07 12:22:11 +02:00
Jocelyn Fiat
244fdf1b02 Added request methods criteria for the router component.
Now one can decide

map_agent_with_request_methods ("/foo/bar/{bar_id}", agent handle_foo_bar, <<"GET">>)
(and similar for non agent way)
This might be useful in pure RESTful environment.
2011-09-07 12:14:03 +02:00
Jocelyn Fiat
3c9fce293f fixed example .. where we forgot to set the status, and send the header
(DbC helped here)
2011-09-07 12:10:48 +02:00
Jocelyn Fiat
eee085dd5a renamed (un)set_meta_parameter as (un)set_meta_variable 2011-09-07 11:42:53 +02:00
Jocelyn Fiat
2d9e2d12a0 Missing HTTP_ prefix for header meta variable in REQUEST 2011-09-07 11:42:02 +02:00
jocelyn
4a7b6ecc94 Updated EWSGI (markdown) 2011-09-05 06:59:49 -07:00
jocelyn
28d03ddf2a Updated EWSGI (markdown) 2011-09-05 06:58:15 -07:00
jocelyn
d0bb906a96 Updated EWSGI (markdown) 2011-09-05 06:56:42 -07:00
jocelyn
597f4bc6bd Updated EWSGI (markdown) 2011-09-05 06:54:29 -07:00
jocelyn
4744bb15c3 Updated EWSGI (markdown) 2011-09-05 06:15:07 -07:00
jocelyn
d0576c6829 Updated EWSGI Open Questions (markdown) 2011-09-05 06:03:33 -07:00
jvelilla
9fef2d71f0 Fixed ecf files that cause a cat-call in the example
web server.
2011-09-05 09:18:39 -03:00
Jocelyn Fiat
6a581f6d62 Changed prefix from EWSGI_ to WGI_
Changed meta variable type to READABLE_STRING_32
2011-08-30 19:20:42 +02:00
Jocelyn Fiat
060f1482fe Changed prefix class name from EWSGI_ to WGI_
changes in interface for REQUEST and RESPONSE
2011-08-30 19:16:40 +02:00
Jocelyn Fiat
ed8f5d694f naming: meta_variable(s)
changed some string type to READABLE_STRING_32
or READABLE_STRING_8 for now regarding Meta variables (need decision here..)
2011-08-29 12:48:03 +02:00
Jocelyn Fiat
c20600f281 changed prefix GW_ into EWF_ for EiffelWebFramework
use READABLE_STRING_GENERAL instead of just STRING
2011-08-25 16:00:18 +02:00
Jocelyn Fiat
53ccaa3fde sync wiki doc 2011-08-25 14:48:30 +02:00
Jocelyn Fiat
22afbd7ed0 Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework
Conflicts:
	library/server/ewsgi/connectors/nino/src/gw_nino_connector.e
	library/server/ewsgi/ewsgi-safe.ecf
2011-08-25 14:48:02 +02:00
Jocelyn Fiat
f6b362217c Merged REQUEST and ENVIRONMENT into REQUEST
renamed ENVIRONMENT_NAMES into META_NAMES
better usage of READABLE_STRING_GENERAL, and other strings
abstract RESPONSE_BUFFER in implementation of EWSGI
for the implementation, inheriting from deferred specification (more to come later)
2011-08-25 14:41:35 +02:00
Jocelyn Fiat
e9ccf855b3 Merged REQUEST and ENVIRONMENT into REQUEST
renamed ENVIRONMENT_NAMES into META_NAMES
better usage of READABLE_STRING_GENERAL, and other strings
for the implementation, inheriting from deferred specification (more to come later)
2011-08-25 12:33:20 +02:00
Jocelyn Fiat
4d0148d562 fixing wrong feature usage 2011-08-24 15:54:01 +02:00
Jocelyn Fiat
ec6cc5f2b8 code cleaning, and prepare for internal review 2011-08-18 12:25:40 +02:00
Jocelyn Fiat
40018d36eb enhanced the ERROR_HANDLER 2011-08-04 15:11:51 +02:00
jocelyn
d14e65fdc0 Updated EWSGI : open questions (markdown) 2011-08-02 07:40:10 -07:00
jocelyn
c337f49c87 Updated EWSGI (markdown) 2011-08-02 07:39:45 -07:00
jocelyn
ed587493e9 Updated Home (markdown) 2011-08-02 07:39:34 -07:00
jocelyn
e2fb499853 Updated EWSGI (markdown) 2011-08-02 07:35:47 -07:00
jocelyn
59d4eb528c Created EWSGI (markdown) 2011-08-02 07:35:28 -07:00
jocelyn
afb3890f50 Updated EWSGI: open questions (markdown) 2011-08-02 07:34:52 -07:00
jocelyn
077c140576 Updated Home (markdown) 2011-08-02 07:33:41 -07:00
jocelyn
75dc9fac3e Updated Source structure (markdown) 2011-08-02 07:32:31 -07:00
jocelyn
637909614b Updated EWSGI: open questions (markdown) 2011-08-02 07:31:08 -07:00
jocelyn
45db7eb537 Created EWSGI: open questions (markdown) 2011-08-02 07:30:35 -07:00
Jocelyn Fiat
8e18329063 minor improvements on response_as_result code 2011-08-02 14:53:37 +02:00
jocelyn
8a3b5a77e3 Updated EWSGI specification: difference in main proposals (markdown) 2011-08-02 02:57:33 -07:00
jocelyn
4ab99dcd4a Created EWSGI specification: difference in main proposals (markdown) 2011-08-02 02:52:31 -07:00
Jocelyn Fiat
c372494713 cosmetic in config file .ecf 2011-08-02 10:47:16 +02:00
Jocelyn Fiat
10f4a99ee1 add "write_headers_string" to RESPONSE_BUFFER 2011-08-02 10:46:53 +02:00
jocelyn
cefc95e56f added current eiffel interfaces for APPLICATION, REQUEST and RESPONSE_BUFFER 2011-08-02 01:02:01 -07:00
jocelyn
0194450892 Updated EWSGI specification (markdown) 2011-08-02 00:21:53 -07:00
Jocelyn Fiat
e9085c614c sync wiki 2011-08-01 17:02:33 +02:00
Jocelyn Fiat
f7d3f519a7 moved ewsgi-full config file under tests (this is mainly for dev purpose, to be able to compile and edit all classes related to ewsgi) 2011-08-01 16:47:00 +02:00
Jocelyn Fiat
4eb22d0272 Tried to reduce gap between both EWSGI proposals
Re-adapt the Spec-compliant solution (instead of Lib-compliant solution).
  Thus no more 100% deferred interface.
Rename EWSGI_RESPONSE into EWSGI_RESPONSE_BUFFER
Added in extra/response-as-result/  an copy/paste from the implementation of Paul's proposal (not up to date with Paul's spec). But this is mainly for information and tests.
Removed part of the ewsgi/specification interfaces ... to be able to test EWSGI compliant library against the pure specification (experimental).
Renamed most of the GW_... into EWSGI_...
2011-08-01 16:41:16 +02:00
jocelyn
a2a1f89299 Updated EWSGI specification (markdown) 2011-08-01 01:19:54 -07:00
jocelyn
b869eb7333 Updated Home (markdown) 2011-08-01 00:36:52 -07:00
jocelyn
7680d071f1 Updated Community collaboration (markdown) 2011-07-29 06:15:51 -07:00
Jocelyn Fiat
bbcc9ef44b added http_accept feature to represent "Accept:" HTTP header 2011-07-29 15:13:34 +02:00
Jocelyn Fiat
801caa4e69 added hello_routed_world example
few changes on new `router' library (still in-progress)
2011-07-29 15:13:08 +02:00
Jocelyn Fiat
1b49445077 Added first draft for a URI and/or URI-template base request router. 2011-07-29 10:51:22 +02:00
Jocelyn Fiat
f005d8bb06 cosmetic 2011-07-29 10:50:31 +02:00
Jocelyn Fiat
a278537f7b Added "flush" to the EWSGI_RESPONSE_STREAM 2011-07-29 10:50:24 +02:00
Jocelyn Fiat
78b5b6f5fe Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-07-29 08:52:57 +02:00
Jocelyn Fiat
a215c1e4d2 added missing non-void-safe .ecf 2011-07-29 08:52:36 +02:00
Jocelyn Fiat
fe3726677b added missing non-void-safe .ecf 2011-07-29 08:45:26 +02:00
Jocelyn Fiat
94d4909644 Fixed various issue with URI template, added corresponding tests 2011-07-28 18:45:25 +02:00
Jocelyn Fiat
0da4b7d61b It seems good convention to also add the "Status:" header 2011-07-28 10:57:24 +02:00
Jocelyn Fiat
5c5ba9f038 fix hello world example 2011-07-28 10:41:57 +02:00
Jocelyn Fiat
d65c8de1d2 ignore tests/temp 2011-07-28 08:28:54 +02:00
Jocelyn Fiat
3d93dbc66d added script to test compilations of .ecf in EWF 2011-07-27 18:35:17 +02:00
Jocelyn Fiat
436f2afd00 Added the possibility to set the "Status" header (different from the status line) in GW_HEADER
Renamed EWSGI_RESPONSE as EWSGI_RESPONSE_STREAM to avoid confusion with EWSGI_RESPONSE as stated in Paul's proposal
Added default "configuration" (for nino and cgi) to be independant of the connector (at compilation time)
Added example implementing Paul's proposal on top of EWSGI
2011-07-27 18:34:06 +02:00
Jocelyn Fiat
73284575d4 Added an implementation folder in ewsgi_spec, mainly to provide default implementation just to save the developer of connector some time.
changed structured
2011-07-27 17:34:53 +02:00
Jocelyn Fiat
e9b05ffc0b added non void-safe configuration files 2011-07-27 16:07:00 +02:00
Jocelyn Fiat
012bb2f6c9 restructured specification folders 2011-07-27 15:58:31 +02:00
Jocelyn Fiat
e883163fe9 Apply prefix renaming from the specification
Reduced the number of EWSGI classes
2011-07-27 15:56:44 +02:00
Jocelyn Fiat
e5fb3f8328 now use prefix EWSGI_ instead of GW_ for ewsgi specification 2011-07-27 15:40:51 +02:00
Jocelyn Fiat
302ae8d030 First step to extract the interface of the EWSGI specification into its own library
Applied the changes
2011-07-27 15:34:22 +02:00
Jocelyn Fiat
694c0a193c removed implementation from APPLICATION , RESPONSE and REQUEST classes 2011-07-27 15:11:07 +02:00
Jocelyn Fiat
4075b08b7e removed the notion of status from GW_HEADER, since it should not be part of the HTTP header
added status setting in GW_RESPONSE
added a default implementation for write_status in OUTPUT_STREAM
  (it should be moved away in the future)
removed any implementation from GW_REQUEST, and put it in GW_REQUEST_IMP
2011-07-27 14:51:47 +02:00
Jocelyn Fiat
65800371cd replace write_string by write in RESPONSE 2011-07-26 16:01:23 +02:00
Jocelyn Fiat
2c6196017e various alternative implementation for response 2011-07-26 16:01:18 +02:00
Jocelyn Fiat
5a155e0cee Redesigned the RESPONSE to remove the output stream from the deferred interface
Redesigned the uploaded file part to be more object oriented
Move some implementation from REQUEST to REQUEST_IMP
2011-07-25 12:38:25 +02:00
Jocelyn Fiat
08bec49da4 added doc/spec for uri template 2011-07-25 12:38:16 +02:00
Jocelyn Fiat
4940ddb8f5 Fixed issue with matcher 2011-07-22 17:29:17 +02:00
Jocelyn Fiat
6599bf1a07 fixed typo 2011-07-22 17:06:08 +02:00
Jocelyn Fiat
0ef88eadf5 Improvement
and revert back to support draft 04
(but using custom variable, allow the user to follow draft 05 spec)
2011-07-22 16:58:31 +02:00
Jocelyn Fiat
e1ef4c390e fixing issue with URI TEMPLATE matcher 2011-07-22 13:14:09 +02:00
Jocelyn Fiat
11baeefe1c Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework 2011-07-22 08:30:49 +02:00
Jocelyn Fiat
ac7f58722d added URI_TEMPLATE_MATCH_RESULT 2011-07-22 08:30:08 +02:00
Jocelyn Fiat
acd395376a sync 2011-07-21 19:06:04 +02:00
jocelyn
c7f4f45f5e Updated Libraries (markdown) 2011-07-21 10:01:04 -07:00
Jocelyn Fiat
a7a27bee0a updated README 2011-07-21 18:59:27 +02:00
Jocelyn Fiat
fc0a25acc9 updated README 2011-07-21 18:48:54 +02:00
Jocelyn Fiat
0d363f065b added use of URL-encoder to unencode the URL values (to fill the parameters)
review design of GW_RESPONSE to hide the output, and remove the header attribute
added script_url in REQUEST to help the user build url relative to script_name

+ cosmetic
2011-07-20 18:27:02 +02:00
Jocelyn Fiat
51b70a2490 First version of URI Template library
as specified by http://tools.ietf.org/html/draft-gregorio-uritemplate-05
(it seems to contains some error in the spec .. or minor incoherences, to double check)
The matcher is basic, it does not handle all the details of the string builder, but that seems ok for now.
2011-07-20 12:11:05 +02:00
Jocelyn Fiat
917f80c0c8 added format and request method constants classes
+ license file
2011-07-18 16:36:56 +02:00
Jocelyn Fiat
73e5fd6cd6 added default rescue code on exception rescue 2011-07-18 16:33:10 +02:00
Jocelyn Fiat
0abab83566 nicer Eiffel code, let's not try to achieve everything-in-one-line style ... 2011-07-18 16:32:42 +02:00
Jocelyn Fiat
f764e63b45 restrict creation only by GW_APPLICATION and descendant 2011-07-18 16:31:32 +02:00
Jocelyn Fiat
0a1c4676a4 add output helper feature to RESPONSE 2011-07-18 16:29:43 +02:00
Jocelyn Fiat
8a38519fb0 Fixed issue with nino handler and base url 2011-07-18 16:07:45 +02:00
Jocelyn Fiat
54c9addb30 sync nino and json 2011-07-18 16:06:21 +02:00
Javier Velilla
9dd1439a2f Refactor to use the new library structure convention. 2011-07-15 08:15:31 -03:00
Jocelyn Fiat
30d4843a5b rename new_request_context by new_request 2011-07-14 14:56:34 +02:00
Jocelyn Fiat
3e73298806 cosmetic 2011-07-13 16:25:17 +02:00
Jocelyn Fiat
01b16d0a82 renamed GW_REQUEST_CONTEXT as GW_REQUEST 2011-07-13 16:22:20 +02:00
Jocelyn Fiat
ac97d6019b Design change, now we have req' REQUEST and res' RESPONSE instead of just `ctx' 2011-07-13 16:13:25 +02:00
Jocelyn Fiat
4e2f0dbc72 enhanced comment for `execute' 2011-07-13 15:37:50 +02:00
Jocelyn Fiat
9d1fb56cc1 Make a simple hello world based on nino 2011-07-13 15:26:21 +02:00
seibo
e1120040bb Updated EWSGI specification (markdown) 2011-07-12 16:02:30 -07:00
seibo
e63553555d Updated EWSGI specification (markdown) 2011-07-12 15:57:54 -07:00
seibo
4904aba360 Updated EWSGI specification (markdown) 2011-07-12 15:48:53 -07:00
seibo
cc7e54a19b Updated EWSGI specification (markdown) 2011-07-12 14:34:05 -07:00
jocelyn
8389829067 Updated Libraries (markdown) 2011-07-12 10:42:23 -07:00
jocelyn
4880d23846 Updated Libraries (markdown) 2011-07-12 10:42:09 -07:00
jocelyn
d409eac9d6 Updated Libraries (markdown) 2011-07-12 10:41:22 -07:00
jocelyn
13993197d3 Created Libraries (markdown) 2011-07-12 10:39:15 -07:00
jocelyn
d5288a4ebe Updated Home (markdown) 2011-07-12 10:33:14 -07:00
Jocelyn Fiat
bc98c5a317 Added GW_HEADER
Added pre_, post_ and rescue_execute for GW_APPLICATION
Fixed an unknown class in export clause
cosmetic + copyright
2011-07-12 17:47:17 +02:00
Jocelyn Fiat
681bb19ab7 fixed submodule path ... Windows path separator issue.. 2011-07-12 17:12:36 +02:00
Jocelyn Fiat
026b4f8682 added instruction to get the source code 2011-07-12 16:48:46 +02:00
jvelilla
4a87d5822b Merge pull request #2 from jocelyn/master
Please consider pulling from my repository
2011-07-12 03:36:36 -07:00
Jocelyn Fiat
f74ac66569 First integration of the new GW_ design more centralized on connector, and does not require specific feature on GW_APPLICATION depending on the connector.
So this is really more flexible this way, and much easier to write application supporting CGI, FCGI, Nino and so on .. as demonstrated in hello_world

This is a first version, more will come later, mainly migrating from Eiffel Web Reloaded to this Eiffel Web Framework project.
2011-07-12 11:53:00 +02:00
Jocelyn Fiat
de77802546 Merge branch 'master' of github.com:jocelyn/EiffelWebNino 2011-07-12 11:09:59 +02:00
Jocelyn Fiat
f7cf91500c let's have a nino-safe.ecf and also a nino.ecf for non void-safe system 2011-07-12 11:07:09 +02:00
jocelyn
6309bbfa52 Updated The Eiffel Web Server Gateway Interface (markdown) 2011-07-08 05:39:44 -07:00
Jocelyn Fiat
4fb42df5fb focus on GW_APPLICATION 2011-07-08 11:27:06 +02:00
seibo
ab924d3596 Updated The Eiffel Web Server Gateway Interface (markdown) 2011-07-07 16:11:10 -07:00
seibo
13515504c3 Updated The Eiffel Web Server Gateway Interface (markdown) 2011-07-07 15:58:16 -07:00
seibo
831f73b308 Updated EWSGI specification (markdown) 2011-07-07 15:57:14 -07:00
seibo
6cba9a912f Created EWSGI/specification (markdown) 2011-07-07 15:56:14 -07:00
Jocelyn Fiat
f1d8d18811 a few renaming
better GW_ENVIRONMENT interface
2011-07-07 17:24:21 +02:00
Jocelyn Fiat
c6162aea7e Merge branch 'master' of github.com:jocelyn/Eiffel-Web-Framework.wiki 2011-07-07 16:48:52 +02:00
jocelyn
1f385658ed Updated Source structure (markdown) 2011-07-07 06:41:47 -07:00
jocelyn
36539997cd Updated Community collaboration (markdown) 2011-07-07 01:24:05 -07:00
jocelyn
b57450d762 Updated Home (markdown) 2011-07-06 03:48:31 -07:00
jocelyn
398139ee19 Updated Home (markdown) 2011-07-06 03:47:02 -07:00
jocelyn
843a3efe0f Updated Home (markdown) 2011-07-06 03:45:59 -07:00
Jocelyn Fiat
545db51fc9 updated doc 2011-07-06 12:45:29 +02:00
jocelyn
5a4a749c0f Updated Tasks Roadmap (markdown) 2011-07-06 02:24:18 -07:00
jocelyn
fbbfc784b1 Created Community collaboration (markdown) 2011-07-06 02:22:41 -07:00
jocelyn
dd7b62f7a1 Updated Home (markdown) 2011-07-06 02:14:45 -07:00
jocelyn
b86057e6a4 Created Spec server architecture (markdown) 2011-07-06 02:05:43 -07:00
jocelyn
6bdfb1d74a Updated Home (markdown) 2011-07-06 02:05:17 -07:00
Jocelyn Fiat
baae1daa85 Added server side architecture for EWSGI 2011-07-06 11:03:21 +02:00
jocelyn
c9c2b37070 Created Task json (markdown) 2011-07-05 05:37:20 -07:00
jocelyn
5f5a8c6daf Updated Tasks Roadmap (markdown) 2011-07-05 05:34:06 -07:00
jocelyn
e0eedef3a7 Updated Source structure (markdown) 2011-07-05 05:33:22 -07:00
jocelyn
f9a79c0800 Created Source structure (markdown) 2011-07-05 05:31:59 -07:00
jocelyn
7f35ca21e2 Updated Home (markdown) 2011-07-05 05:22:01 -07:00
jocelyn
71cdfe18ab Updated Home (markdown) 2011-07-05 05:01:45 -07:00
Jocelyn Fiat
20bf9efaa0 cosmetic, license, copyright 2011-07-05 12:07:49 +02:00
jocelyn
d9b52d2691 Updated Tasks Roadmap (markdown) 2011-07-05 02:43:47 -07:00
jocelyn
0b7165b260 Updated Eiffel-Web-Framework (markdown) 2011-07-05 02:40:41 -07:00
jocelyn
057cec2b44 Updated Tasks Roadmap (markdown) 2011-07-05 02:38:30 -07:00
jocelyn
23d8adaa3d Updated Tasks (markdown) 2011-07-05 02:38:05 -07:00
jocelyn
aca99fe6d4 Created Tasks (markdown) 2011-07-05 02:37:56 -07:00
Jocelyn Fiat
a168cc62e7 added doc/wiki (wiki from github) 2011-07-05 10:52:05 +02:00
Jocelyn Fiat
b9e89758ce First draft for the ewsgi spec 2011-07-05 10:45:16 +02:00
jocelyn
1782fc9f4d Updated Home (markdown) 2011-06-30 02:24:59 -07:00
jocelyn
509375f7e6 Updated Home (markdown) 2011-06-30 02:24:23 -07:00
Eiffel-World
58f72fdf18 Initial Commit 2011-06-30 02:09:51 -07:00
Jocelyn
19da9436ff Let's start the Eiffel Web Framework 2011-06-29 08:38:57 +02:00
Javier Velilla
32ff399442 Merge branch 'jocelyn' 2011-06-23 22:59:41 -03:00
Jocelyn Fiat
c7440a2ca0 Fixed the HTTP_SERVER.shutdown_server 2011-06-01 19:13:09 +02:00
Jocelyn Fiat
63cd0610ec Fixed remote info computing 2011-05-31 14:29:16 +02:00
Javier Velilla
c772fc5194 Commit merge jocelyn changes 2011-05-30 23:16:58 -03:00
Jocelyn Fiat
0fda0dc34c left adjust request_header_map items. 2011-05-30 22:26:35 +02:00
Jocelyn Fiat
f22f42c463 Fixed nino.ecf by removing the root class since this is a library config file. 2011-05-30 11:31:53 +02:00
Javier Velilla
569a587ffd Update Readme files 2011-05-28 20:15:48 -03:00
Javier Velilla
6317ca2fe5 Merge git@github.com:jvelilla/EiffelWebNino
Conflicts:
	README
2011-05-28 19:53:47 -03:00
Javier Velilla
12d9dcfff5 Commit Jocelyn changes. 2011-05-28 19:40:31 -03:00
Jocelyn Fiat
824750e748 Don't forget to reset request data 2011-05-27 22:05:56 +02:00
Jocelyn Fiat
c544da3561 Reset values after processing the request
Added port information when starting the server
2011-05-27 19:44:50 +02:00
Jocelyn Fiat
e5e9f9486e Added force_single_threaded option
Modified the interface of process request
default port is now 80
2011-05-27 19:08:35 +02:00
Jocelyn Fiat
720351871b fixed typo in assertion 2011-05-27 16:03:50 +02:00
Jocelyn Fiat
54b95650c5 Moving things around to make it more structured. and turn into library 2011-05-27 15:21:30 +02:00
Jocelyn Fiat
c553bd1e1e abstracted the HTTP_HANDLER
to let the user integrate at the level of its choice
(either very early so handle itself the header handling, or later to reuse existing code)
2011-05-27 13:07:06 +02:00
Jocelyn Fiat
64cf2b6936 A few change to make it more customizable
and prepare integration to EiffelWebReloaded (see on github)
2011-05-26 17:23:21 +02:00
jvelilla
85cf39f3c6 Edited README via GitHub 2011-05-21 09:11:32 -07:00
Javier Velilla
af852498be Added process directory 2011-05-21 12:46:45 -03:00
Javier Velilla
dfa30471e3 Import HTTPD Eiffel 2011-05-20 08:58:26 -03:00
Javier Velilla
094dc09354 first commit 2011-05-20 08:53:04 -03:00
manus
3af8d34f0f * 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
2011-01-13 23:53:42 +00:00
larryl
d0ca77f104 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
2010-06-15 09:23:11 +00:00
manus
3c0d342704 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
2010-06-11 23:30:18 +00:00
jfiat
e78d34774e 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
2010-06-10 12:31:16 +00:00
larryl
eb57cb1973 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
2010-06-08 03:09:06 +00:00
manus
3d669e3043 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
2010-03-16 03:07:44 +00:00
manus
683aa808ad 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
2009-11-14 00:46:07 +00:00
larryl
7717502363 Added useful comments
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@81175 8089f293-4706-0410-a29e-feb5c42a2edf
2009-10-15 14:38:50 +00:00
larryl
eefd98c630 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
2009-08-25 09:40:26 +00:00
larryl
ee8bce82b2 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
2009-07-13 09:07:05 +00:00
manus
764372f072 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
2009-05-18 21:06:56 +00:00
dfurrer
8ddc27b9cb - 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
2009-05-18 16:06:27 +00:00
larryl
5d63551002 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
2009-05-18 04:33:10 +00:00
manus
03851ac02e 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
2009-05-01 21:42:03 +00:00
jfiat
7e2a847e39 cosmetic
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78170 8089f293-4706-0410-a29e-feb5c42a2edf
2009-04-10 08:45:10 +00:00
manus
0759dfe1a7 Use new `note' syntax.
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@78146 8089f293-4706-0410-a29e-feb5c42a2edf
2009-04-09 18:51:20 +00:00
jfiat
dae6d64f82 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
2009-03-19 08:18:02 +00:00
jfiat
6bb5b0bac8 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
2009-03-18 08:21:46 +00:00
manus
e3d8fbb263 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
2009-03-04 00:51:24 +00:00
larryl
caf6d8c528 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
2009-02-27 13:02:12 +00:00
manus
e880fbde14 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
2009-02-24 23:44:31 +00:00
manus
9e27a52670 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
2009-02-06 22:45:24 +00:00
king
816e5b4d6c Fixed typo from previous commit
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76967 8089f293-4706-0410-a29e-feb5c42a2edf
2009-02-04 17:02:38 +00:00
king
9a4a1a3a40 Fixed typo from previous commit
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76966 8089f293-4706-0410-a29e-feb5c42a2edf
2009-02-04 17:01:51 +00:00
manus
93b74d0d5e 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
2009-02-04 16:58:59 +00:00
manus
925fdcd979 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
2009-02-04 01:05:57 +00:00
manus
2f1e4e561b Removed vision2 since not used.
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@76960 8089f293-4706-0410-a29e-feb5c42a2edf
2009-02-04 01:04:28 +00:00
manus
5506ab09dc 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
2008-12-29 20:27:11 +00:00
manus
544b5784ae 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
2008-12-01 19:34:30 +00:00
paulb
9ef3391b26 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
2008-07-18 20:07:15 +00:00
larryl
a06fbd5f0b 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
2008-03-05 11:06:41 +00:00
larryl
098032e815 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
2008-02-29 03:43:43 +00:00
paulb
893fce5706 Reverted to is_mac
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@72174 8089f293-4706-0410-a29e-feb5c42a2edf
2008-02-01 16:42:36 +00:00
paulb
839cb26d7e 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
2008-02-01 16:36:55 +00:00
paulb
b1952a6e2c 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
2008-01-31 21:02:28 +00:00
jfiat
3b231019ea 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
2008-01-14 11:50:55 +00:00
larryl
60b99e48d4 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
2008-01-09 06:50:07 +00:00
larryl
987c18198e 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
2007-12-31 09:48:53 +00:00
manus
5980a724cc Removed directory integrated by mistake.
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71441 8089f293-4706-0410-a29e-feb5c42a2edf
2007-12-10 17:21:34 +00:00
jfiat
7448567c53 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
2007-12-07 12:15:52 +00:00
manus
ea4be7219b 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
2007-12-07 01:15:55 +00:00
manus
9a3e12fe12 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
2007-12-07 01:08:12 +00:00
manus
c8c23ca064 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
2007-11-18 05:32:48 +00:00
paulb
4daf5b727a 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
2007-11-16 00:13:35 +00:00
larryl
fe76c9eac5 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
2007-11-09 10:19:23 +00:00
larryl
81d91930ef 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
2007-11-09 08:36:46 +00:00
larryl
7e024b589a 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
2007-11-08 08:55:00 +00:00
larryl
65559b8b82 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
2007-11-08 07:52:34 +00:00
larryl
179ac3a128 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
2007-11-08 07:09:16 +00:00
larryl
6179b0f223 Added constant: curlopt_writefunction
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71028 8089f293-4706-0410-a29e-feb5c42a2edf
2007-11-03 06:09:00 +00:00
larryl
77c028a9cd Cosmetics.
git-svn-id: https://svn.origo.ethz.ch/eiffelstudio/trunk/Src/library/cURL@71027 8089f293-4706-0410-a29e-feb5c42a2edf
2007-11-03 06:08:03 +00:00
larryl
09a1c2d34a 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
2007-10-30 11:22:26 +00:00
larryl
2d99813b5d 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
2007-10-26 13:10:12 +00:00
larryl
6cf3589a43 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
2007-10-26 08:05:22 +00:00
larryl
1b972b3e24 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
2007-10-22 10:16:49 +00:00
larryl
a99db5fd43 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
2007-10-22 08:22:30 +00:00
926 changed files with 108361 additions and 363 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
EIFGENs
tests/temp/
.svn/
*.swp

0
.gitmodules vendored Normal file
View File

38
CHANGELOGS.txt Normal file
View File

@@ -0,0 +1,38 @@
History for Eiffel-Web-Framework
[2011-09-23] Jocelyn
* library "ewsgi":
- NEW simple autotest cases using Nino web server
-fixed issue with RAW_POST_DATA being added in form_data_parameters
instead of meta_variables ...
- Implemented WGI_VALUE for parameter's type (query_parameter,
form_data_parameter, item ...)
* Nino connector: added feature to shutdown the server from the WGI application
* NEW library "http_client": a new library to perform simple http requests
such as get, head, post, put, ... (currently implemented with Eiffel cURL)
* NEW library "http_authorization": added simple library to support
HTTP_AUTHORIZATION. For now only "Basic" auth type is supported ..
[2011-09-22] Javier
* NEW Example: added partial Restbuck example
[2011-09-21] Jocelyn
* Nino connector: fixed an issue with missing value for Content-Type and Content-Length
[2011-09-13] Jocelyn
* library "router": now using a generic design to allow customization of
request handler context class.
* NEW library "server/request/rest": first attempt to provide a library to
help building RESTful application (the interfaces are likely to change
soon) EXPERIMENTAL
[2011-09-09] Jocelyn
* library "uri-template": better support for {/vars} and {?vars}
[2011-09-07] Jocelyn
* library "router": now routing depends on uri (or uri template) and request methods
* Nino connector: Fixed issue where HTTP_ prefix were missing for header meta variable.
[2011-09-07] Jocelyn
* changelog: starting to write down changelogs file

1534
ChangeLog Normal file

File diff suppressed because it is too large Load Diff

20
LICENSE Normal file
View File

@@ -0,0 +1,20 @@
Eiffel Forum License, version 2
1. Permission is hereby granted to use, copy, modify and/or distribute
this package, provided that:
* copyright notices are retained unchanged,
* any distribution of this package, whether modified or not,
includes this license text.
2. Permission is hereby also granted to distribute binary programs which
depend on this package. If the binary program depends on a modified
version of this package, you are encouraged to publicly release the
modified version of this package.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT WARRANTY. ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS PACKAGE.

84
README.md Normal file
View File

@@ -0,0 +1,84 @@
# Eiffel Web Framework
## Version: v0.1
## Overview
Official project site for Eiffel Web Framework:
* http://eiffelwebframework.github.com/EWF/
For more information please have a look at the related wiki:
* https://github.com/EiffelWebFramework/EWF/wiki
For download, check
* https://github.com/EiffelWebFramework/EWF/downloads
## Requirements
* Developped using EiffelStudio 7.0 (on Windows, Linux)
* Tested using EiffelStudio 7.0 with "jenkins" CI server (and v6.8 for time to time)
* The code have to allow __void-safe__ compilation and non void-safe system (see [more about void-safety](http://docs.eiffel.com/book/method/void-safe-programming-eiffel) )
## How to get the source code?
Using git version >= 1.6.5
* git clone --recursive https://github.com/EiffelWebFramework/EWF.git
Otherwise, try
* git clone https://github.com/EiffelWebFramework/EWF.git
* cd Eiffel-Web-Framework
* git submodule update --init
* git submodule foreach --recursive git checkout master
An alternative to the last 2 instructions is to use the script from tools folder:
* cd tools
* update_git_working_copy
* And to build the required and related Clibs
* cd contrib/ise_library/cURL
* geant compile
## Libraries under 'library'
### server
* __ewsgi__: Eiffel Web Server Gateway Interface [read more](library/server/ewsgi)
* connectors: various web server connectors for EWSGI
* libfcgi: Wrapper for libfcgi SDK
* __wsf__: Web Server Framework [read more](library/server/wsf)
* include URL dispatching/routing based on uri, uri_template, or custom [read more](library/server/wsf/router)
### protocol
* __http__: HTTP related classes, constants for status code, content types, ... [read more](library/protocol/http)
* __uri_template__: URI Template library (parsing and expander) [read more](library/protocol/uri_template)
* __CONNEG__: CONNEG library (Content-type Negociation) [read more](library/protocol/CONNEG)
### client
* __http_client__: simple HTTP client based on cURL [read more](library/client/http_client)
### text
* __encoder__: Various simpler encoders: base64, url-encoder, xml entities, html entities [read more](library/text/encoder)
### Others
* error: very simple/basic library to handle error
## External libraries under 'contrib'
* [Eiffel Web Nino](contrib/library/server/nino)
* contrib/ise_library/cURL
* contrib/ise_library/math/eapml
* contrib/ise_library/text/encryption/eel
* contrib/library/text/parser/json
## Draft folder = call for contribution ##
### library/server/request ###
* request
* rest: (experimental) "a" RESTful library to help building RESTful services
## Examples
..
For more information please have a look at the related wiki:
* https://github.com/EiffelWebFramework/EWF/wiki

1
VERSION.txt Normal file
View File

@@ -0,0 +1 @@
Version v0.1

35
build.eant Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<project name="build_library" default="help">
<description>
description: "Compile Eiffel Web Framework"
</description>
<target name="help">
<echo message="usage:"/>
<echo message=" geant compile"/>
<echo message=" geant clean"/>
<echo message=" geant clobber"/>
</target>
<target name="compile" >
<echo message="- Compile EWF" />
<geant target="_build_tpl_" arguments="compile" />
</target>
<target name="clean" >
<echo message="- Clean EWF" />
<geant target="_build_tpl_" arguments="clean" />
</target>
<target name="clobber" >
<echo message="- Clobber EWF" />
<geant target="_build_tpl_" arguments="clobber" />
</target>
<target name="_build_tpl_" >
<argument name="_target_name" />
<geant target="${_target_name}" dir="contrib" file="build.eant" reuse_variables="true" />
</target>
</project>

35
contrib/build.eant Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<project name="build_library" default="help">
<description>
description: "Compile Eiffel Web Framework / Contrib"
</description>
<target name="help">
<echo message="usage:"/>
<echo message=" geant compile"/>
<echo message=" geant clean"/>
<echo message=" geant clobber"/>
</target>
<target name="compile" >
<echo message="- Compile contrib" />
<geant target="_build_tpl_" arguments="compile" />
</target>
<target name="clean" >
<echo message="- Clean contrib" />
<geant target="_build_tpl_" arguments="clean" />
</target>
<target name="clobber" >
<echo message="- Clobber contrib" />
<geant target="_build_tpl_" arguments="clobber" />
</target>
<target name="_build_tpl_" >
<argument name="_target_name" />
<geant target="${_target_name}" dir="ise_library" file="build.eant" reuse_variables="true" />
</target>
</project>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<project name="build_library" default="help">
<description>
description: "Compile Eiffel Web Framework / Contrib / ISE library"
</description>
<target name="help">
<echo message="usage:"/>
<echo message=" geant compile"/>
<echo message=" geant clean"/>
<echo message=" geant clobber"/>
</target>
<target name="compile" >
<echo message="- Compile ise_library" />
<geant target="_build_tpl_" arguments="compile" />
</target>
<target name="clean" >
<echo message="- Clean ise_library" />
<geant target="_build_tpl_" arguments="clean" />
</target>
<target name="clobber" >
<echo message="- Clobber ise_library" />
<geant target="_build_tpl_" arguments="clobber" />
</target>
<target name="_build_tpl_" >
<argument name="_target_name" />
<geant target="${_target_name}" dir="cURL" file="build.eant" reuse_variables="true" />
</target>
</project>

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-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" full_class_checking="true" cat_call_detection="false" is_attached_by_default="true" void_safety="all" namespace="EiffelSoftware.Library">
</option>
<setting name="dotnet_naming_convention" value="true"/>
<external_include location="$(ECF_CONFIG_PATH)\cURL\spec\include">
<condition>
<platform value="windows"/>
</condition>
</external_include>
<external_include location="$(ECF_CONFIG_PATH)/cURL/spec/include">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_include>
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="false"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="true"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
<condition>
<platform value="windows"/>
<multithreaded value="false"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
<condition>
<platform value="windows"/>
<multithreaded value="true"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
<condition>
<platform value="windows"/>
<dotnet value="true"/>
</condition>
</external_object>
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper-safe.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<cluster name="curl" location=".\cURL" recursive="true">
<file_rule>
<exclude>/spec$</exclude>
<exclude>/Clib$</exclude>
</file_rule>
<file_rule>
<exclude>/gtk$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform value="windows"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/gtk$</exclude>
<condition>
<platform value="macintosh"/>
<custom name="vision_implementation" value="cocoa"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform excluded_value="windows"/>
<custom name="vision_implementation" excluded_value="cocoa"/>
</condition>
</file_rule>
</cluster>
</target>
<target name="curl_dotnet" extends="curl">
<setting name="msil_generation" value="true"/>
</target>
</system>

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-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="$(ECF_CONFIG_PATH)\cURL\spec\include">
<condition>
<platform value="windows"/>
</condition>
</external_include>
<external_include location="$(ECF_CONFIG_PATH)/cURL/spec/include">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_include>
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/eiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="false"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="true"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
<condition>
<platform value="windows"/>
<multithreaded value="false"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.lib">
<condition>
<platform value="windows"/>
<multithreaded value="true"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$(ECF_CONFIG_PATH)\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\ileiffel_curl.lib">
<condition>
<platform value="windows"/>
<dotnet value="true"/>
</condition>
</external_object>
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<cluster name="curl" location=".\cURL" recursive="true">
<file_rule>
<exclude>/spec$</exclude>
<exclude>/Clib$</exclude>
</file_rule>
<file_rule>
<exclude>/gtk$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform value="windows"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/gtk$</exclude>
<condition>
<platform value="macintosh"/>
<custom name="vision_implementation" value="cocoa"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform excluded_value="windows"/>
<custom name="vision_implementation" excluded_value="cocoa"/>
</condition>
</file_rule>
</cluster>
</target>
<target name="curl_dotnet" extends="curl">
<setting name="msil_generation" value="true"/>
</target>
</system>

View File

@@ -0,0 +1,58 @@
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
MAKE = $make
MKDIR = $mkdir
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:: $output_libraries
$(MAKE) clean
standard:: eiffel_curl.lib ileiffel_curl.lib
mtstandard:: mteiffel_curl.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.
MTeiffel_curl.$obj: eiffel_curl.c
$(CC) $(JMTCFLAGS) $(OUTPUT_CMD)$@ -c $?
#.NET targets.
ILeiffel_curl.$obj: eiffel_curl.c
$(CC) $(JILCFLAGS) $(OUTPUT_CMD)$@ -c $?

View File

@@ -0,0 +1,92 @@
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 <<!GROK!THIS!
########################################################################
# Makefile generated from Makefile.SH on $DATE
SHELL = /bin/sh
AR = ar rc
CC = $cc
CTAGS = ctags
INCLUDE = -I$rt_include -I../spec/include -I../../../C_library/libpng -I../../../C_library/zlib
CFLAGS = $optimize $ccflags $large -g \$(INCLUDE)
MTCFLAGS = $optimize $mtccflags $large -g \$(INCLUDE)
SHAREDLINK = $sharedlink
LDSHAREDFLAGS = $ldsharedflags
LN = $ln
MAKE = $make
MKDEP = $mkdep \$(DPFLAGS) --
RANLIB = $ranlib
RM = $rm -f
MV = $mv
MKDIR = $mkdir -p
PLATFORM = $ISE_PLATFORM
########################################################################
# New suffixes and associated building rules -- edit with care
!GROK!THIS!
$spitshell >>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 $@
########################################################################
# Common rules for all Makefiles -- do not edit
emptyrule::
clean: local_clean
realclean: local_realclean
clobber: local_clobber
local_clean::
$(RM) core *~ *.o *.so *.a
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

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<project name="build_curl_clib" default="help">
<description>
description: "cURL Clib library compilation"
</description>
<target name="help">
<echo message="usage:"/>
<echo message=" geant compile"/>
<echo message=" geant clean"/>
<echo message=" geant clobber"/>
</target>
<target name="compile" >
<exec executable="finish_freezing -library" />
</target>
<target name="clean" >
</target>
<target name="clobber" depend="clean" />
</project>

View File

@@ -0,0 +1,188 @@
/*
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_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
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_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 */
/* 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.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)
{
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_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)
{
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;
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<project name="build_curl" default="help">
<description>
description: "cURL library compilation"
</description>
<target name="help">
<echo message="usage:"/>
<echo message=" geant compile"/>
<echo message=" geant clean"/>
<echo message=" geant clobber"/>
</target>
<target name="compile">
<echo message="- Compile [cURL]" />
<geant target="compile" file="build.eant" dir="Clib"
reuse_variables="true" />
</target>
<target name="clean">
<echo message="- Clean [cURL]" />
<delete directory="spec\${ISE_C_COMPILER}\${ISE_PLATFORM}" />
</target>
<target name="clobber" depend="clean" />
</project>

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-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" full_class_checking="true" cat_call_detection="false" is_attached_by_default="true" void_safety="all" 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_PLATFORM)/lib/eiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="false"/>
</condition>
</external_object>
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="true"/>
</condition>
</external_object>
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
<condition>
<platform value="windows"/>
<multithreaded value="false"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.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\ileiffel_curl.lib">
<condition>
<platform value="windows"/>
<dotnet value="true"/>
</condition>
</external_object>
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper-safe.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<cluster name="curl" location=".\" recursive="true">
<file_rule>
<exclude>/spec$</exclude>
<exclude>/Clib$</exclude>
</file_rule>
<file_rule>
<exclude>/gtk$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform value="windows"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/gtk$</exclude>
<condition>
<platform value="macintosh"/>
<custom name="vision_implementation" value="cocoa"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform excluded_value="windows"/>
<custom name="vision_implementation" excluded_value="cocoa"/>
</condition>
</file_rule>
</cluster>
</target>
<target name="curl_dotnet" extends="curl">
<setting name="msil_generation" value="true"/>
</target>
</system>

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-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_PLATFORM)/lib/eiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="false"/>
</condition>
</external_object>
<external_object location="$(ISE_LIBRARY)/library/cURL/spec/$(ISE_PLATFORM)/lib/MTeiffel_curl.o">
<condition>
<platform excluded_value="windows"/>
<multithreaded value="true"/>
</condition>
</external_object>
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\eiffel_curl.lib">
<condition>
<platform value="windows"/>
<multithreaded value="false"/>
<dotnet value="false"/>
</condition>
</external_object>
<external_object location="$(ISE_LIBRARY)\library\cURL\spec\$(ISE_C_COMPILER)\$(ISE_PLATFORM)\lib\mteiffel_curl.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\ileiffel_curl.lib">
<condition>
<platform value="windows"/>
<dotnet value="true"/>
</condition>
</external_object>
<library name="api_wrapper" location="$ISE_LIBRARY\library\api_wrapper\api_wrapper.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<cluster name="curl" location=".\" recursive="true">
<file_rule>
<exclude>/spec$</exclude>
<exclude>/Clib$</exclude>
</file_rule>
<file_rule>
<exclude>/gtk$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform value="windows"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/gtk$</exclude>
<condition>
<platform value="macintosh"/>
<custom name="vision_implementation" value="cocoa"/>
</condition>
</file_rule>
<file_rule>
<exclude>/mswin$</exclude>
<exclude>/mac$</exclude>
<condition>
<platform excluded_value="windows"/>
<custom name="vision_implementation" excluded_value="cocoa"/>
</condition>
</file_rule>
</cluster>
</target>
<target name="curl_dotnet" extends="curl">
<setting name="msil_generation" value="true"/>
</target>
</system>

View File

@@ -0,0 +1,336 @@
note
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 -- Eiffel cURL: Constants
eiffelcurle_error_occurred: INTEGER = -1
-- Error occurred in Eiffel cURL internals
feature -- Constants
curle_ok: INTEGER = 0
-- Declared as CURLE_OK
curle_unsupported_protocol: INTEGER = 1
-- Declared as CURLE_UNSUPPORTED_PROTOCOL
curle_failed_init: INTEGER = 2
-- Declared as CURLE_FAILED_INIT
curle_url_malformat: INTEGER = 3
-- Declared as CURLE_URL_MALFORMAT
curle_obsolete4: INTEGER = 4
-- Declared as CURLE_OBSOLETE4
-- NOT USED
curle_couldnt_resolve_proxy: INTEGER = 5
-- Declared as CURLE_COULDNT_RESOLVE_PROXY
curle_couldnt_resolve_host: INTEGER = 6
-- Declared as CURLE_COULDNT_RESOLVE_HOST
curle_couldnt_connect: INTEGER = 7
-- Declared as CURLE_COULDNT_CONNECT
curle_ftp_weird_server_reply: INTEGER = 8
-- Declared as CURLE_FTP_WEIRD_SERVER_REPLY
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 = 10
-- Declared as CURLE_OBSOLETE10 NOT USED
curle_ftp_weird_pass_reply: INTEGER = 11
-- Declared as CURLE_FTP_WEIRD_PASS_REPLY
curle_obsolete12: INTEGER = 12
-- Declared as CURLE_OBSOLETE12 NOT USED
curle_ftp_weird_pasv_reply: INTEGER = 13
-- Declared as CURLE_FTP_WEIRD_PASV_REPLY
curle_ftp_weird_227_format: INTEGER = 14
-- Declared as CURLE_FTP_WEIRD_227_FORMAT
curle_ftp_cant_get_host: INTEGER = 15
-- Declared as CURLE_FTP_CANT_GET_HOST
curle_obsolete16: INTEGER = 16
-- Declared as CURLE_OBSOLETE16
-- NOT USED
curle_ftp_couldnt_set_type: INTEGER = 17
-- Declared as CURLE_FTP_COULDNT_SET_TYPE
curle_partial_file: INTEGER = 18
-- Declared as CURLE_PARTIAL_FILE
curle_ftp_couldnt_retr_file: INTEGER = 19
-- Declared as CURLE_FTP_COULDNT_RETR_FILE
curle_obsolete20: INTEGER = 20
-- Declared as CURLE_OBSOLETE20
-- NOT USED
curle_quote_error: INTEGER = 21
-- Declared as CURLE_QUOTE_ERROR
-- quote command failure
curle_http_returned_error: INTEGER = 22
-- Declared as CURLE_HTTP_RETURNED_ERROR
curle_write_error: INTEGER = 23
-- Declared as CURLE_WRITE_ERROR
curle_obsolete24: INTEGER = 24
-- Declared as CURLE_OBSOLETE24 NOT USED
curle_upload_failed: INTEGER = 25
-- Declared as CURLE_UPLOAD_FAILED
-- failed upload "command"
curle_read_error: INTEGER = 26
-- Declared as CURLE_READ_ERROR
-- couldn't open/read from file
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 = 28
-- Declared as CURLE_OPERATION_TIMEDOUT
-- the timeout time was reached
curle_obsolete29: INTEGER = 29
-- Declared as CURLE_OBSOLETE29
-- NOT USED
curle_ftp_port_failed: INTEGER = 30
-- Declared as CURLE_FTP_PORT_FAILED
-- FTP PORT operation failed
curle_ftp_couldnt_use_rest: INTEGER = 31
-- Declared as CURLE_FTP_COULDNT_USE_REST
-- the REST command failed
curle_obsolete32: INTEGER = 32
-- Declared as CURLE_OBSOLETE32
-- NOT USED
curle_range_error: INTEGER = 33
-- Declared as CURLE_RANGE_ERROR
-- RANGE "command" didn't work
curle_http_post_error: INTEGER = 34
-- Declared as CURLE_HTTP_POST_ERROR
curle_ssl_connect_error: INTEGER = 35
-- Declared CURLE_SSL_CONNECT_ERROR
-- wrong when connecting with SSL
curle_bad_download_resume: INTEGER = 36
-- Declared as CURLE_BAD_DOWNLOAD_RESUME
-- couldn't resume download
curle_file_couldnt_read_file: INTEGER = 37
-- Declared as CURLE_FILE_COULDNT_READ_FILE
curle_ldap_cannot_bind: INTEGER = 38
-- Declared as CURLE_LDAP_CANNOT_BIND
curle_ldap_search_failed: INTEGER = 39
-- Declared as CURLE_LDAP_SEARCH_FAILED
curle_obsolete40: INTEGER = 40
-- Declared as CURLE_OBSOLETE40
-- NOT USED
curle_function_not_found: INTEGER = 41
-- Declared as CURLE_FUNCTION_NOT_FOUND
curle_aborted_by_callback: INTEGER = 42
-- Declared as CURLE_ABORTED_BY_CALLBACK
curle_bad_function_argument: INTEGER = 43
-- Declared as CURLE_BAD_FUNCTION_ARGUMENT
curle_obsolete44: INTEGER = 44
-- Declared as CURLE_OBSOLETE44
-- NOT USED
curle_interface_failed: INTEGER = 45
-- Declared as CURLE_INTERFACE_FAILED
-- CURLOPT_INTERFACE failed
curle_obsolete46: INTEGER = 46
-- Declared as CURLE_OBSOLETE46
-- NOT USED
curle_too_many_redirects: INTEGER = 47
-- Declared as CURLE_TOO_MANY_REDIRECTS
-- catch endless re-direct loops
curle_unknown_telnet_option: INTEGER = 48
-- Declared as CURLE_UNKNOWN_TELNET_OPTION
-- User specified an unknown option
curle_telnet_option_syntax: INTEGER = 49
-- Declared as CURLE_TELNET_OPTION_SYNTAX
-- Malformed telnet option
curle_obsolete50: INTEGER = 50
-- Declared as CURLE_OBSOLETE50
-- NOT USED
curle_ssl_peer_certificate: INTEGER = 51
-- Declared as CURLE_SSL_PEER_CERTIFICATE
-- peer's certificate wasn't ok
curle_got_nothing: INTEGER = 52
-- Declared as CURLE_GOT_NOTHING
-- when this is a specific error
curle_ssl_engine_notfound: INTEGER = 53
-- Declared as CURLE_SSL_ENGINE_NOTFOUND
-- SSL crypto engine not found */
curle_ssl_engine_setfailed: INTEGER = 54
-- Declared as CURLE_SSL_ENGINE_SETFAILED
-- can not set SSL crypto engine as default
curle_send_error: INTEGER = 55
-- Declared as CURLE_SEND_ERROR
-- failed sending network data
curle_recv_error: INTEGER = 56
-- Declared as CURLE_RECV_ERROR
-- failure in receiving network data
curle_obsolete57: INTEGER = 57
-- Declared as CURLE_OBSOLETE57
-- NOT IN USE
curle_ssl_certproblem: INTEGER = 58
-- Declared as CURLE_SSL_CERTPROBLEM
-- problem with the local certificate
curle_ssl_cipher: INTEGER = 59
-- Declared as CURLE_SSL_CIPHER
-- couldn't use specified cipher
curle_ssl_cacert: INTEGER = 60
-- Declared as CURLE_SSL_CACERT
-- problem with the CA cert (path?)
curle_bad_content_encoding: INTEGER = 61
-- Declared as CURLE_BAD_CONTENT_ENCODING
-- Unrecognized transfer encoding
curle_ldap_invalid_url: INTEGER = 62
-- Declared as CURLE_LDAP_INVALID_URL
-- Invalid LDAP URL
curle_filesize_exceeded: INTEGER = 63
-- Declared as CURLE_FILESIZE_EXCEEDED
-- Maximum file size exceeded
curle_use_ssl_failed: INTEGER = 64
-- Declared as CURLE_USE_SSL_FAILED
-- Requested FTP SSL level failed
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 = 66
-- Declared as CURLE_SSL_ENGINE_INITFAILED
-- failed to initialise ENGINE
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 = 68
-- Declared as CURLE_TFTP_NOTFOUND
-- file not found on server
curle_tftp_perm: INTEGER = 69
-- Declared as CURLE_TFTP_PERM
-- permission problem on server
curle_remote_disk_full: INTEGER = 70
-- Declared as CURLE_REMOTE_DISK_FULL
-- out of disk space on server
curle_tftp_illegal: INTEGER = 71
-- Declared as CURLE_TFTP_ILLEGAL
-- Illegal TFTP operation
curle_tftp_unknownid: INTEGER = 72
-- Declared as CURLE_TFTP_UNKNOWNID
-- Unknown transfer ID
curle_remote_file_exists: INTEGER = 73
-- Declared as CURLE_REMOTE_FILE_EXISTS
-- File already exists
curle_tftp_nosuchuser: INTEGER = 74
-- Declared as CURLE_TFTP_NOSUCHUSER
-- No such user
curle_conv_failed: INTEGER = 75
-- Declared as CURLE_CONV_FAILED
-- conversion failed
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 = 77
-- Declared as CURLE_SSL_CACERT_BADFILE
-- could not load CACERT file, missing or wrong format
curle_remote_file_not_found: INTEGER = 78
-- Declared as CURLE_REMOTE_FILE_NOT_FOUND
-- remote file not found
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 = 80;
-- Declared as CURLE_SSL_SHUTDOWN_FAILED
-- Failed to shut down the SSL connection
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

View File

@@ -0,0 +1,104 @@
note
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
-- 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
do
end
write_function (a_data_pointer: POINTER; a_size, a_nmemb: INTEGER; a_object_id: POINTER): INTEGER
local
l_c_string: C_STRING
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)
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
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
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)
-- 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
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
note
library: "cURL: Library of reusable components for Eiffel."
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

View File

@@ -0,0 +1,409 @@
note
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 -- Command
init: POINTER
-- Declared as curl_easy_init().
require
dynamic_library_exists: is_dynamic_library_exists
local
l_api: POINTER
do
l_api := api_loader.api_pointer ("curl_easy_init")
if l_api /= default_pointer then
Result := c_init (l_api)
end
ensure
exists: Result /= default_pointer
end
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
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
not_void: a_string /= Void
local
l_api: POINTER
l_c_str: C_STRING
do
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)
end
end
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
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_slist (a_curl_handle: POINTER; a_opt: INTEGER; a_curl_slist: POINTER)
-- 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)
-- Declared as curl_easy_setopt().
require
exists: a_curl_handle /= default_pointer
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
not_void: a_curl_string /= Void
local
l_api: POINTER
do
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
end
setopt_integer (a_curl_handle: POINTER; a_opt: INTEGER; a_integer: INTEGER)
-- 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
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
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}
require
exists: a_curl_handle /= default_pointer
local
l_api: POINTER
do
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
end
cleanup (a_curl_handle: POINTER)
-- Declared as curl_easy_cleanup().
require
exists: a_curl_handle /= default_pointer
local
l_api: POINTER
do
l_api := api_loader.api_pointer ("curl_easy_cleanup")
if l_api /= default_pointer then
c_cleanup (l_api, a_curl_handle)
end
end
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.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)
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
Result := api_loader.is_interface_usable
end
feature -- Special setting
set_curl_function (a_curl_function: CURL_FUNCTION)
-- 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
-- cURL functions in curl_easy_setopt.
do
if attached internal_curl_function as l_curl_function then
Result := l_curl_function
else
create {CURL_DEFAULT_FUNCTION} Result.make
internal_curl_function := Result
end
ensure
not_void: Result /= Void
end
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
require
exists: a_curl_handle /= default_pointer
local
l_api: POINTER
do
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
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.api_pointer ("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
exists: a_curl_handle /= default_pointer
local
l_api: POINTER
do
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
end
set_debug_function (a_curl_handle: POINTER)
-- Set cURL debug function
require
exists: a_curl_handle /= default_pointer
local
l_api: POINTER
do
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
end
feature {NONE} -- Implementation
internal_curl_function: detachable CURL_FUNCTION
-- cURL functions.
api_loader: DYNAMIC_MODULE
-- Module name.
local
l_utility: CURL_UTILITY
once
create l_utility
Result := l_utility.api_loader
end
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
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
local
l_api: POINTER
do
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
end
feature {NONE} -- C externals
c_init (a_api: POINTER): POINTER
-- Declared curl_easy_init ().
require
exists: a_api /= default_pointer
external
"C inline use <curl/curl.h>"
alias
"[
return (FUNCTION_CAST(CURL *, ()) $a_api)();
]"
end
c_cleanup (a_api: POINTER; a_curl_handle: POINTER)
-- Decalred as curl_easy_cleanup ().
require
exists: a_api /= default_pointer
exists: a_curl_handle /= default_pointer
external
"C inline use <curl/curl.h>"
alias
"[
(FUNCTION_CAST(void, (CURL *)) $a_api)((CURL *)$a_curl_handle);
]"
end
c_perform (a_api: POINTER; a_curl_handle: POINTER): INTEGER
-- Declared as curl_easy_perform().
require
exists: a_api /= default_pointer
exists: a_curl_handle /= default_pointer
external
"C inline use <curl/curl.h>"
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)
-- 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
"C inline use <curl/curl.h>"
alias
"[
{
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_api)
((CURL *) $a_curl_handle,
(CURLoption)$a_opt,
$a_data);
}
]"
end
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
exists: a_api /= default_pointer
exists: a_curl_handle /= default_pointer
valid: (create {CURL_OPT_CONSTANTS}).is_valid (a_opt)
external
"C inline use <curl/curl.h>"
alias
"[
{
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_api)
((CURL *) $a_curl_handle,
(CURLoption)$a_opt,
$a_data);
}
]"
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 <curl/curl.h>"
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-2010, 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

View File

@@ -0,0 +1,254 @@
note
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 -- Command
global_init
-- Declared as curl_global_init().
require
dynamic_library_exists: is_dynamic_library_exists
local
l_ptr: POINTER
do
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
end
global_cleanup
-- Declared as curl_global_cleanup().
local
l_ptr: POINTER
do
l_ptr := api_loader.api_pointer ("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: 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
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
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
not_void: a_string /= Void
local
l_c_string: C_STRING
l_api: POINTER
do
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)
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
-- If dll/so files exist?
do
Result := api_loader.is_interface_usable
end
feature {CURL_FORM} -- Internal command
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).
-- 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
l_api: POINTER
do
l_api := api_loader.api_pointer ("curl_formfree")
if l_api /= default_pointer then
c_formfree (l_api, a_curl_form)
end
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
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
l_api: POINTER
do
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)
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
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)
-- C implementation of formadd_string_string ().
require
exists: a_api /= default_pointer
external
"C inline use <curl/curl.h>"
alias
"[
{
(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)
-- Declared as curl_formfree ().
require
exists: a_api /= default_pointer
exists: a_curl_form /= default_pointer
external
"C inline use <curl/curl.h>"
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)
-- `a_api' point to API curl_global_init ()
-- `a_opt' is intialization option.
require
exists: a_api /= default_pointer
external
"C inline use <curl/curl.h>"
alias
"[
(FUNCTION_CAST(void, (long)) $a_api)((long) $a_opt);
]"
end
c_curl_global_cleanup (a_api: POINTER)
-- `a_api' point to API curl_global_cleanup()
require
exists: a_api /= default_pointer
external
"C inline use <curl/curl.h>"
alias
"[
(FUNCTION_CAST(void, ()) $a_api)();
]"
end
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
external
"C inline use <curl/curl.h>"
alias
"[
{
return (FUNCTION_CAST(void *, (struct curl_slist *, const char *)) $a_api)
((struct curl_slist *)$a_list_pointer,
(const char *)$a_string);
}
]"
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 <curl/curl.h>"
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."
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
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

View File

@@ -0,0 +1,94 @@
note
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
-- Creation method.
do
end
share_with_pointer (a_pointer: POINTER)
-- 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
-- Free memory if possible.
local
l_curl: CURL_EXTERNALS
do
if item /= default_pointer then
create l_curl
l_curl.formfree (item)
item := default_pointer
end
end
release_item
-- 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)
-- Set `item' with `a_item'
do
item := a_item
ensure
set: item = a_item
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

View File

@@ -0,0 +1,78 @@
note
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
-- Declared as CURLFORM_COPYNAME
external
"C inline use <curl/curl.h>"
alias
"[
CURLFORM_COPYNAME
]"
end
curlform_copycontents: INTEGER
-- Declared as CURLFORM_COPYCONTENTS
external
"C inline use <curl/curl.h>"
alias
"[
CURLFORM_COPYCONTENTS
]"
end
curlform_end: INTEGER
-- Declared as CURLFORM_END
external
"C inline use <curl/curl.h>"
alias
"[
CURLFORM_END
]"
end
curlform_file: INTEGER
-- Declared as CURLFORM_FILE
external
"C inline use <curl/curl.h>"
alias
"[
CURLFORM_FILE
]"
end
is_valid (a_integer: INTEGER): BOOLEAN
-- 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
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

View File

@@ -0,0 +1,257 @@
note
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.
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$"
revision: "$Revision$"
deferred class
CURL_FUNCTION
inherit
DISPOSABLE
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, 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
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
exists: a_setopt_api /= default_pointer
external
"C inline use <eiffel_curl.h>"
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)
-- 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 <eiffel_curl.h>"
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)
-- 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 <eiffel_curl.h>"
alias
"[
{
(FUNCTION_CAST(void, (CURL *, CURLoption, ...)) $a_setopt_api)
((CURL *) $a_curl_handle,
(CURLoption)CURLOPT_WRITEFUNCTION,
curl_write_function);
}
]"
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 <eiffel_curl.h>"
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
-- 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
-- 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 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
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.
require
vaild: (create {CURL_INFO_TYPE}).is_valid (a_curl_infotype)
deferred
end
feature {NONE} -- Externals
c_set_object (a_object: POINTER)
-- Set Current object address.
external
"C signature (EIF_REFERENCE) use %"eiffel_curl.h%""
end
c_release_object
-- Release Current pointer in C
external
"C use %"eiffel_curl.h%""
end
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)
-- Set write function address.
external
"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
"C use %"eiffel_curl.h%""
end
feature {NONE} -- Implementation
dispose
-- Wean `Current'
do
c_release_object
c_set_object (default_pointer)
end
note
library: "cURL: Library of reusable components for Eiffel."
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

View File

@@ -0,0 +1,78 @@
note
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
-- Delcared as CURL_GLOBAL_SSL
external
"C inline use <curl/curl.h>"
alias
"[
return CURL_GLOBAL_SSL;
]"
end
curl_global_win32: NATURAL_64
-- Delcared as CURL_GLOBAL_WIN32
external
"C inline use <curl/curl.h>"
alias
"[
return CURL_GLOBAL_WIN32;
]"
end
curl_global_all: NATURAL_64
-- Delcared as CURL_GLOBAL_ALL
external
"C inline use <curl/curl.h>"
alias
"[
return CURL_GLOBAL_ALL;
]"
end
curl_global_nothing: NATURAL_64
-- Delcared as CURL_GLOBAL_NOTHING
external
"C inline use <curl/curl.h>"
alias
"[
return CURL_GLOBAL_NOTHING;
]"
end
curl_global_default: NATURAL_64
-- Delcared as CURL_GLOBAL_DEFAULT
external
"C inline use <curl/curl.h>"
alias
"[
return CURL_GLOBAL_DEFAULT;
]"
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

View File

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

View File

@@ -0,0 +1,69 @@
note
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 = 0
-- Declared as CURLINFO_TEXT
curlinfo_header_in: INTEGER = 1
-- Declared as CURLINFO_HEADER_IN
curlinfo_header_out: INTEGER = 2
-- Declared as CURLINFO_HEADER_OUT
curlinfo_data_in: INTEGER = 3
-- Declared as CURLINFO_DATA_IN
curlinfo_data_out: INTEGER = 4
-- Declared as CURLINFO_DATA_OUT
curlinfo_ssl_data_in: INTEGER = 5
-- Declared as CURLINFO_SSL_DATA_IN
curlinfo_ssl_data_out: INTEGER = 6
-- Declared as CURLINFO_SSL_DATA_OUT
feature -- Contract support
is_valid (a_type: INTEGER): BOOLEAN
-- If `a_type' valid?
do
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
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

View File

@@ -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 <curl/curl.h>"
alias
"return CURLMSG_DONE;"
end
curlmsg_none: INTEGER
-- Declared as CURLMSG_NONE.
-- First, not used
external
"C inline use <curl/curl.h>"
alias
"return CURLMSG_NONE;"
end
curlmsg_last: INTEGER
-- Declared as CURLMSG_LAST.
-- Last, not used
external
"C inline use <curl/curl.h>"
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

View File

@@ -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 <curl/curl.h>"
alias
"return (CURL *)((CURLMsg *)$a_item)->easy_handle;"
end
c_msg (a_item: POINTER): INTEGER
-- Get msg
external
"C inline use <curl/curl.h>"
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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,50 @@
note
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
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

View File

@@ -0,0 +1,51 @@
note
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
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
Result := "libcurl"
ensure
not_void: Result /= Void
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

View File

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

View File

@@ -0,0 +1 @@
reference:forum2

View File

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

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 */

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 */

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 */

View File

@@ -0,0 +1,47 @@
/*
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
]"
*/
#ifndef _eiffel_curl_h_
#define _eiffel_curl_h_
#include "eif_eiffel.h"
/* unix-specific */
#ifndef EIF_WINDOWS
#include <sys/time.h>
#include <unistd.h>
#endif
#include <curl/curl.h>
#ifdef __cplusplus
extern "C" {
#endif
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);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,4 @@
Eiffel Arbitrary Precision Mathematics Library
Contribution from Colin LeMahieu
see original source: https://github.com/clemahieu/eapml

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-6-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-6-0 http://www.eiffel.com/developers/xml/configuration-1-6-0.xsd" name="eapml" uuid="3E9258E1-383A-40BF-864B-231FC8F25ADF" library_target="eapml">
<description>Eiffel Arbitrary Precision Mathematics Library
Note: you should set 'eapml_scan_type' to 'gcc' or 'vc'
and 'eapml_limb_type' to 'natural_32' (or 'natural_64')
If not, default values will be used depending on the platform
</description>
<target name="eapml">
<file_rule>
<exclude>/.svn$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.hg$</exclude>
<exclude>/EIFGENs$</exclude>
</file_rule>
<description>Eiffel Arbitrary Precision Mathematics</description>
<root all_classes="true"/>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<cluster name="bit_scan_gcc" location=".\src\bit_scan_gcc\" recursive="true">
<condition>
<custom name="eapml_scan_type" value="gcc"/>
</condition>
<condition>
<platform excluded_value="windows"/>
<custom name="eapml_scan_type" excluded_value="vc"/>
</condition>
</cluster>
<cluster name="bit_scan_vc" location=".\src\bit_scan_vc\" recursive="true">
<condition>
<custom name="eapml_scan_type" value="vc"/>
</condition>
<condition>
<platform value="windows"/>
<custom name="eapml_scan_type" excluded_value="gcc"/>
</condition>
</cluster>
<cluster name="eapml" location=".\src\" recursive="true">
<file_rule>
<exclude>/bit_scan_vc$</exclude>
<exclude>/bit_scan_gcc$</exclude>
<exclude>/limb_natural_32$</exclude>
<exclude>/limb_natural_64$</exclude>
</file_rule>
<file_rule>
<exclude>^/mp/number/support$</exclude>
</file_rule>
</cluster>
<cluster name="limb_natural_32" location=".\src\limb_natural_32\" recursive="true">
<!--
<condition>
<custom name="eapml_limb_type" value="natural_32"/>
</condition>
-->
</cluster>
<!--
<cluster name="limb_natural_64" location=".\src\limb_natural_64\" recursive="true">
<condition>
<custom name="eapml_limb_type" value="natural_64"/>
</condition>
</cluster>
-->
</target>
</system>

View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="eapml" uuid="3E9258E1-383A-40BF-864B-231FC8F25ADF" library_target="eapml">
<description>Eiffel Arbitrary Precision Mathematics Library
Note: you should set 'eapml_scan_type' to 'gcc' or 'vc'
and 'eapml_limb_type' to 'natural_32' (or 'natural_64')
If not, default values will be used depending on the platform
</description>
<target name="eapml">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/\.svn$</exclude>
<exclude>/\.hg$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="false" void_safety="none" syntax="standard">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<cluster name="bit_scan_gcc" location=".\src\bit_scan_gcc\" recursive="true">
<condition>
<custom name="eapml_scan_type" value="gcc"/>
</condition>
<condition>
<platform excluded_value="windows"/>
<custom name="eapml_scan_type" excluded_value="vc"/>
</condition>
</cluster>
<cluster name="bit_scan_vc" location=".\src\bit_scan_vc\" recursive="true">
<condition>
<custom name="eapml_scan_type" value="vc"/>
</condition>
<condition>
<platform value="windows"/>
<custom name="eapml_scan_type" excluded_value="gcc"/>
</condition>
</cluster>
<cluster name="eapml" location=".\src\" recursive="true">
<file_rule>
<exclude>/bit_scan_vc$</exclude>
<exclude>/bit_scan_gcc$</exclude>
<exclude>/limb_natural_32$</exclude>
<exclude>/limb_natural_64$</exclude>
</file_rule>
<file_rule>
<exclude>^/mp/number/support$</exclude>
</file_rule>
</cluster>
<cluster name="limb_natural_32" location=".\src\limb_natural_32\" recursive="true">
<!--
<condition>
<custom name="eapml_limb_type" value="natural_32"/>
</condition>
-->
</cluster>
<!--
<cluster name="limb_natural_64" location=".\src\limb_natural_64\" recursive="true">
<condition>
<custom name="eapml_limb_type" value="natural_64"/>
</condition>
</cluster>
-->
</target>
</system>

View File

@@ -0,0 +1,59 @@
note
description: "Summary description for {LIMB_BIT_SCANNING}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
deferred class
LIMB_BIT_SCANNING
inherit
LIMB_DEFINITION
feature
leading_zeros (limb_a: NATURAL_32): INTEGER
do
if limb_a = 0 then
Result := limb_bits
else
Result := count_leading_zeros (limb_a)
end
end
most_significant_one (limb_a: NATURAL_32): INTEGER
-- 31 high, 0 low
require
limb_a /= 0
do
Result := limb_high_bit - leading_zeros (limb_a)
end
trailing_zeros (limb_a: NATURAL_32): INTEGER
-- 31 high, 0 low
require
limb_a /= 0
do
Result := count_trailing_zeros (limb_a)
end
feature {NONE} -- Implementation
count_trailing_zeros (limb_a: NATURAL_32): INTEGER
external
"C inline"
alias
"[
return __builtin_ctz ($limb_a);
]"
end
count_leading_zeros (limb_a: NATURAL_32): INTEGER
external
"C inline"
alias
"[
return __builtin_clz ($limb_a);
]"
end
end

View File

@@ -0,0 +1,59 @@
note
description: "Summary description for {LIMB_BIT_SCANNING}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
deferred class
LIMB_BIT_SCANNING
inherit
LIMB_DEFINITION
feature
leading_zeros (limb_a: NATURAL_32): INTEGER
do
if limb_a = 0 then
Result := limb_bits
else
Result := limb_high_bit - most_significant_one (limb_a)
end
end
most_significant_one (limb_a: NATURAL_32): INTEGER
-- 31 high, 0 low
require
limb_a /= 0
do
bit_scan_reverse ($Result, limb_a)
end
trailing_zeros (limb_a: NATURAL_32): INTEGER
-- 31 high, 0 low
require
limb_a /= 0
do
bit_scan_forward ($Result, limb_a)
end
feature {NONE} -- Implementation
bit_scan_reverse (target: POINTER; limb_a: NATURAL_32)
external
"C inline use %"intrin.h%""
alias
"[
_BitScanReverse ($target, $limb_a);
]"
end
bit_scan_forward (target: POINTER; limb_a: NATURAL_32)
external
"C inline use %"intrin.h%""
alias
"[
_BitScanForward ($target, $limb_a);
]"
end
end

View File

@@ -0,0 +1,19 @@
note
description: "An exception when dividing by zero"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "A right is not what someone gives you; it's what no one can take from you. - Ramsey Clark, U.S. Attorney General, New York Times, 10/02/77"
class
DIVIDE_BY_ZERO
inherit
DEVELOPER_EXCEPTION
redefine
internal_meaning
end
feature
internal_meaning: STRING = "Divide by zero"
end

View File

@@ -0,0 +1,224 @@
note
description: "Convert between character codes and numbers ignoring case"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "There can be no freedom without freedom to fail. - Eric Hoffer (1902-1983), The Ordeal of Change, 1964"
class
CASE_INSENSITIVE_STRATEGY
inherit
CHARACTER_STRATEGY
feature
text_to_number (in: NATURAL_8): NATURAL_8
do
inspect
in
when 0x30 then
Result := 0x0
when 0x31 then
Result := 1
when 0x32 then
Result := 2
when 0x33 then
Result := 3
when 0x34 then
Result := 4
when 0x35 then
Result := 5
when 0x36 then
Result := 6
when 0x37 then
Result := 7
when 0x38 then
Result := 8
when 0x39 then
Result := 9
when 0x41 then
Result := 10
when 0x42 then
Result := 11
when 0x43 then
Result := 12
when 0x44 then
Result := 13
when 0x45 then
Result := 14
when 0x46 then
Result := 15
when 0x47 then
Result := 16
when 0x48 then
Result := 17
when 0x49 then
Result := 18
when 0x4a then
Result := 19
when 0x4b then
Result := 20
when 0x4c then
Result := 21
when 0x4d then
Result := 22
when 0x4e then
Result := 23
when 0x4f then
Result := 24
when 0x50 then
Result := 25
when 0x51 then
Result := 26
when 0x52 then
Result := 27
when 0x53 then
Result := 28
when 0x54 then
Result := 29
when 0x55 then
Result := 30
when 0x56 then
Result := 31
when 0x57 then
Result := 32
when 0x58 then
Result := 33
when 0x59 then
Result := 34
when 0x5a then
Result := 35
when 0x61 then
Result := 10
when 0x62 then
Result := 11
when 0x63 then
Result := 12
when 0x64 then
Result := 13
when 0x65 then
Result := 14
when 0x66 then
Result := 15
when 0x67 then
Result := 16
when 0x68 then
Result := 17
when 0x69 then
Result := 18
when 0x6a then
Result := 19
when 0x6b then
Result := 20
when 0x6c then
Result := 21
when 0x6d then
Result := 22
when 0x6e then
Result := 23
when 0x6f then
Result := 24
when 0x70 then
Result := 25
when 0x71 then
Result := 26
when 0x72 then
Result := 27
when 0x73 then
Result := 28
when 0x74 then
Result := 29
when 0x75 then
Result := 30
when 0x76 then
Result := 31
when 0x77 then
Result := 32
when 0x78 then
Result := 33
when 0x79 then
Result := 34
when 0x7a then
Result := 35
end
end
number_to_text (in: NATURAL_8): NATURAL_8
do
inspect in
when 0 then
Result := 0x30
when 1 then
Result := 0x31
when 2 then
Result := 0x32
when 3 then
Result := 0x33
when 4 then
Result := 0x34
when 5 then
Result := 0x35
when 6 then
Result := 0x36
when 7 then
Result := 0x37
when 8 then
Result := 0x38
when 9 then
Result := 0x39
when 10 then
Result := 0x61
when 11 then
Result := 0x62
when 12 then
Result := 0x63
when 13 then
Result := 0x64
when 14 then
Result := 0x65
when 15 then
Result := 0x66
when 16 then
Result := 0x67
when 17 then
Result := 0x68
when 18 then
Result := 0x69
when 19 then
Result := 0x6a
when 20 then
Result := 0x6b
when 21 then
Result := 0x6c
when 22 then
Result := 0x6d
when 23 then
Result := 0x6e
when 24 then
Result := 0x6f
when 25 then
Result := 0x70
when 26 then
Result := 0x71
when 27 then
Result := 0x72
when 28 then
Result := 0x73
when 29 then
Result := 0x74
when 30 then
Result := 0x75
when 31 then
Result := 0x76
when 32 then
Result := 0x77
when 33 then
Result := 0x78
when 34 then
Result := 0x79
when 35 then
Result := 0x7a
end
end
end

View File

@@ -0,0 +1,276 @@
note
description: "Convert between character codes and numbers case-sensitive"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "I believe the State exists for the development of individual lives, not individuals for the development of the state. - Julian Huxley (1878-1975)"
class
CASE_SENSITIVE_STRATEGY
inherit
CHARACTER_STRATEGY
feature
text_to_number (in: NATURAL_8): NATURAL_8
do
inspect
in
when 0x30 then
Result := 0x0
when 0x31 then
Result := 1
when 0x32 then
Result := 2
when 0x33 then
Result := 3
when 0x34 then
Result := 4
when 0x35 then
Result := 5
when 0x36 then
Result := 6
when 0x37 then
Result := 7
when 0x38 then
Result := 8
when 0x39 then
Result := 9
when 0x41 then
Result := 10
when 0x42 then
Result := 11
when 0x43 then
Result := 12
when 0x44 then
Result := 13
when 0x45 then
Result := 14
when 0x46 then
Result := 15
when 0x47 then
Result := 16
when 0x48 then
Result := 17
when 0x49 then
Result := 18
when 0x4a then
Result := 19
when 0x4b then
Result := 20
when 0x4c then
Result := 21
when 0x4d then
Result := 22
when 0x4e then
Result := 23
when 0x4f then
Result := 24
when 0x50 then
Result := 25
when 0x51 then
Result := 26
when 0x52 then
Result := 27
when 0x53 then
Result := 28
when 0x54 then
Result := 29
when 0x55 then
Result := 30
when 0x56 then
Result := 31
when 0x57 then
Result := 32
when 0x58 then
Result := 33
when 0x59 then
Result := 34
when 0x5a then
Result := 35
when 0x61 then
Result := 36
when 0x62 then
Result := 37
when 0x63 then
Result := 38
when 0x64 then
Result := 39
when 0x65 then
Result := 40
when 0x66 then
Result := 41
when 0x67 then
Result := 42
when 0x68 then
Result := 43
when 0x69 then
Result := 44
when 0x6a then
Result := 45
when 0x6b then
Result := 46
when 0x6c then
Result := 47
when 0x6d then
Result := 48
when 0x6e then
Result := 49
when 0x6f then
Result := 50
when 0x70 then
Result := 51
when 0x71 then
Result := 52
when 0x72 then
Result := 53
when 0x73 then
Result := 54
when 0x74 then
Result := 55
when 0x75 then
Result := 56
when 0x76 then
Result := 57
when 0x77 then
Result := 58
when 0x78 then
Result := 59
when 0x79 then
Result := 60
when 0x7a then
Result := 61
end
end
number_to_text (in: NATURAL_8): NATURAL_8
do
inspect in
when 0 then
Result := 0x30
when 1 then
Result := 0x31
when 2 then
Result := 0x32
when 3 then
Result := 0x33
when 4 then
Result := 0x34
when 5 then
Result := 0x35
when 6 then
Result := 0x36
when 7 then
Result := 0x37
when 8 then
Result := 0x38
when 9 then
Result := 0x39
when 10 then
Result := 0x41
when 11 then
Result := 0x42
when 12 then
Result := 0x43
when 13 then
Result := 0x44
when 14 then
Result := 0x45
when 15 then
Result := 0x46
when 16 then
Result := 0x47
when 17 then
Result := 0x48
when 18 then
Result := 0x49
when 19 then
Result := 0x4a
when 20 then
Result := 0x4b
when 21 then
Result := 0x4c
when 22 then
Result := 0x4d
when 23 then
Result := 0x4e
when 24 then
Result := 0x4f
when 25 then
Result := 0x50
when 26 then
Result := 0x51
when 27 then
Result := 0x52
when 28 then
Result := 0x53
when 29 then
Result := 0x54
when 30 then
Result := 0x55
when 31 then
Result := 0x56
when 32 then
Result := 0x57
when 33 then
Result := 0x58
when 34 then
Result := 0x59
when 35 then
Result := 0x5a
when 36 then
Result := 0x61
when 37 then
Result := 0x62
when 38 then
Result := 0x63
when 39 then
Result := 0x64
when 40 then
Result := 0x65
when 41 then
Result := 0x66
when 42 then
Result := 0x67
when 43 then
Result := 0x68
when 44 then
Result := 0x69
when 45 then
Result := 0x6a
when 46 then
Result := 0x6b
when 47 then
Result := 0x6c
when 48 then
Result := 0x6d
when 49 then
Result := 0x6e
when 50 then
Result := 0x6f
when 51 then
Result := 0x70
when 52 then
Result := 0x71
when 53 then
Result := 0x72
when 54 then
Result := 0x73
when 55 then
Result := 0x74
when 56 then
Result := 0x75
when 57 then
Result := 0x76
when 58 then
Result := 0x77
when 59 then
Result := 0x78
when 60 then
Result := 0x79
when 61 then
Result := 0x7a
end
end
end

View File

@@ -0,0 +1,20 @@
note
description: "A strategy for converting character codes to numbers and vica-versa"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Free speech is meaningless unless it tolerates the speech that we hate. - Henry J. Hyde, U.S. Congressman, Speech, 5/3/91"
deferred class
CHARACTER_STRATEGY
feature
text_to_number (in: NATURAL_8): NATURAL_8
deferred
end
number_to_text (in: NATURAL_8): NATURAL_8
deferred
end
end

View File

@@ -0,0 +1,77 @@
note
description: "Summary description for {INTEGER_X_ACCESS}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "It is error alone which needs the support of government. Truth can stand by itself. - Thomas Jefferson (1743-1846), U.S. President, Notes on the State of Virginia, 1782"
deferred class
INTEGER_X_ACCESS
inherit
INTEGER_X_FACILITIES
SPECIAL_SIZING
SPECIAL_ACCESS
rename
get_str as get_str_special
end
feature
get_string (op: READABLE_INTEGER_X; base: INTEGER): STRING_8
require
base >= 2
base <= 62
local
xp: SPECIAL [NATURAL_32]
xp_offset: INTEGER
x_size: INTEGER
str: STRING_8
str_offset: INTEGER
return_str: STRING_8
return_str_offset: INTEGER
str_size: INTEGER
alloc_size: INTEGER
num_to_text: CHARACTER_STRATEGY
i: INTEGER
do
x_size := op.count
if base <= 35 then
create {CASE_INSENSITIVE_STRATEGY}num_to_text
else
create {CASE_SENSITIVE_STRATEGY}num_to_text
end
alloc_size := sizeinbase (op.item, 0, x_size.abs, base)
alloc_size := alloc_size + (x_size < 0).to_integer
create Result.make_filled ('%U', alloc_size)
return_str := Result
return_str_offset := 1
if x_size < 0 then
return_str [return_str_offset] := '-'
return_str_offset := return_str_offset + 1
x_size := -x_size
end
xp := op.item
xp_offset := 0
if not pow2_p (base.to_natural_32) then
create xp.make_filled (0, x_size + 1)
xp.copy_data (op.item, 0, 0, x_size)
end
str_size := get_str_special (return_str, return_str_offset, base, xp, xp_offset, x_size)
str := return_str
str.remove_tail (alloc_size - str_size - (return_str_offset - 1))
str_offset := return_str_offset
if str [str_offset] = (0x0).to_character_8 and str_size /= 1 then
str_size := str_size - 1
str_offset := str_offset + 1
end
from
i := 0
until
i >= str_size
loop
return_str [return_str_offset + i] := num_to_text.number_to_text (str [str_offset + i].code.to_natural_8).to_character_8
i := i + 1
end
end
end

View File

@@ -0,0 +1,914 @@
note
description: "Summary description for {INTEGER_X_ARITHMETIC}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Every man should know that his conversations, his correspondence, and his personal life are private. - Lyndon B. Johnson (1908-1973), Remarks, 3/10/67"
deferred class
INTEGER_X_ARITHMETIC
inherit
INTEGER_X_FACILITIES
SPECIAL_ARITHMETIC
rename
add as add_special,
sub as sub_special,
mul as mul_special
export
{NONE}
all
end
SPECIAL_COMPARISON
SPECIAL_UTILITY
feature
add (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X)
-- Set `rop' to `op1' + `op2'.
local
wp: SPECIAL [NATURAL_32]
wp_offset: INTEGER
up: SPECIAL [NATURAL_32]
vp: SPECIAL [NATURAL_32]
usize: INTEGER_32
vsize: INTEGER_32
wsize: INTEGER_32
abs_usize: INTEGER_32
abs_vsize: INTEGER_32
pointer_temp: READABLE_INTEGER_X
int_temp: INTEGER_32
junk2: NATURAL_32
cy_limb: NATURAL_32
op1: READABLE_INTEGER_X
op2: READABLE_INTEGER_X
carry: CELL [NATURAL_32]
do
create carry.put (0)
op1 := op1_a
op2 := op2_a
usize := op1.count
vsize := op2.count
abs_usize := usize.abs
abs_vsize := vsize.abs
if abs_usize < abs_vsize then
pointer_temp := op1
op1 := op2
op2 := pointer_temp
int_temp := usize
usize := vsize
vsize := int_temp
int_temp := abs_usize
abs_usize := abs_vsize
abs_vsize := int_temp
end
wsize := abs_usize + 1
target.resize (wsize)
up := op1.item
vp := op2.item
wp := target.item
if usize.bit_xor (vsize) < 0 then
if abs_usize /= abs_vsize then
sub_special (wp, 0, up, 0, abs_usize, vp, 0, abs_vsize, carry)
junk2 := carry.item
wsize := abs_usize
wsize := normalize (wp, wp_offset, wsize)
if usize < 0 then
wsize := -wsize
end
elseif cmp (up, 0, vp, 0, abs_usize) < 0 then
sub_n (wp, 0, vp, 0, up, 0, abs_usize, carry)
junk2 := carry.item
wsize := abs_usize
wsize := normalize (wp, wp_offset, wsize)
if usize >= 0 then
wsize := -wsize
end
else
sub_n (wp, 0, up, 0, vp, 0, abs_usize, carry)
junk2 := carry.item
wsize := abs_usize
wsize := normalize (wp, wp_offset, wsize)
if usize < 0 then
wsize := -wsize
end
end
else
add_special (wp, 0, up, 0, abs_usize, vp, 0, abs_vsize, carry)
cy_limb := carry.item
wp [wp_offset + abs_usize] := cy_limb
wsize := abs_usize + cy_limb.to_integer_32
if usize < 0 then
wsize := -wsize
end
end
target.count := wsize
end
add_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
-- Set `rop' to `op1' + `op2'.
local
usize: INTEGER_32
wsize: INTEGER_32
abs_usize: INTEGER_32
cy: NATURAL_32
junk2: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
usize := op1.count
abs_usize := usize.abs
wsize := abs_usize + 1
target.resize (wsize)
if abs_usize = 0 then
target.item [0] := op2
if op2 /= 0 then
target.count := 1
else
target.count := 0
end
else
if usize >= 0 then
add_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
cy := carry.item
target.item [abs_usize] := cy
wsize := abs_usize + cy.to_integer_32
else
if abs_usize = 1 and op1.item [0] < op2 then
target.item [0] := op2 - op1.item [0]
wsize := 1
else
sub_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
junk2 := carry.item
if target.item [abs_usize - 1] = 0 then
wsize := - (abs_usize - 1)
else
wsize := - (abs_usize)
end
end
end
target.count := wsize
end
end
aorsmul (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X; sub_a: INTEGER_32)
local
xsize: INTEGER_32
ysize: INTEGER_32
tsize: INTEGER_32
wsize: INTEGER_32
wsize_signed: INTEGER_32
wp: INTEGER_32
tp: SPECIAL [NATURAL_32]
c: NATURAL_32
high: NATURAL_32
tmp_marker: SPECIAL [NATURAL_32]
tp_offset: INTEGER_32
current_temp: READABLE_INTEGER_X
int_temp: INTEGER_32
usize: INTEGER_32
sub_l: INTEGER_32
junk2: NATURAL_32
op1: READABLE_INTEGER_X
op2: READABLE_INTEGER_X
carry: CELL [NATURAL_32]
do
create carry.put (0)
op1 := op1_a
op2 := op2_a
sub_l := sub_a
xsize := op1.count
ysize := op2.count
if xsize = 0 or ysize = 0 then
else
if ysize.abs > xsize.abs then
current_temp := op1
op1 := op2
op2 := current_temp
int_temp := xsize
xsize := ysize
ysize := int_temp
end
sub_l := sub_l.bit_xor (ysize)
ysize := ysize.abs
if ysize = 1 then
aorsmul_1 (target, op1, op2.item [0], sub_l)
else
sub_l := sub_l.bit_xor (xsize)
xsize := xsize.abs
wsize_signed := target.count
sub_l := sub_l.bit_xor (wsize_signed)
wsize := wsize_signed.abs
tsize := xsize + ysize
if wsize > tsize then
if wsize + 1 > target.capacity then
target.resize (wsize)
end
else
if tsize + 1 > target.capacity then
target.resize (tsize)
end
end
if wsize_signed = 0 then
mul_special (target.item, 0, op1.item, 0, xsize, op2.item, 0, ysize, carry)
high := carry.item
if high = 0 then
tsize := tsize - 1
end
if sub_l >= 0 then
target.count := tsize
else
target.count := -tsize
end
else
create tmp_marker.make_filled (0, tsize)
tp := tmp_marker
tp_offset := 0
mul_special (tmp_marker, 0, op1.item, 0, xsize, op2.item, 0, ysize, carry)
high := carry.item
if high = 0 then
tsize := tsize - 1
end
if sub_l >= 0 then
usize := wsize
if usize < tsize then
usize := tsize
tp_offset := wp
tsize := wsize
wsize := usize
end
add_special (target.item, wp, op1.item, 0, usize, tp, 0, tsize, carry)
c := carry.item
target.item [wp + wsize] := c
if c /= 0 then
wsize := wsize + 1
end
else
usize := wsize
if usize < tsize or usize = tsize and cmp (target.item, wp, tmp_marker, 0, usize) < 0 then
usize := tsize
tp_offset := wp
tsize := wsize
wsize := usize
wsize_signed := -wsize_signed
end
sub_special (target.item, wp, target.item, wp, usize, tp, tp_offset, tsize, carry)
junk2 := carry.item
wsize := usize
from
until
wsize > 0 or target.item [wp + wsize - 1] /= 0
loop
wsize := wsize - 1
end
end
if wsize_signed >= 0 then
target.count := wsize
else
target.count := -wsize
end
end
end
end
end
aorsmul_1 (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL_32; sub_a: INTEGER_32)
local
xsize: INTEGER_32
wsize: INTEGER_32
wsize_signed: INTEGER_32
new_wsize: INTEGER_32
min_size: INTEGER_32
dsize: INTEGER_32
xp: INTEGER_32
wp: INTEGER_32
cy: NATURAL_32
sub_l: INTEGER_32
cy2: NATURAL_32
d: INTEGER_32
s: INTEGER_32
n: INTEGER_32
x: NATURAL_32
p: INTEGER_32
cy__: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
sub_l := sub_a
xsize := op1.count
if xsize = 0 or op2 = 0 then
else
sub_l := sub_l.bit_xor (xsize)
xsize := xsize.abs
wsize_signed := target.count
if wsize_signed = 0 then
target.resize (xsize + 1)
wp := 0
mul_1 (target.item, 0, op1.item, 0, xsize, op2, carry)
cy := carry.item
target.item [xsize] := cy
if cy /= 0 then
xsize := xsize + 1
end
if sub_l >= 0 then
target.count := xsize
else
target.count := -xsize
end
else
sub_l := sub_l.bit_xor (wsize_signed)
wsize := wsize_signed.abs
new_wsize := wsize.max (xsize)
target.resize (new_wsize + 1)
wp := 0
xp := 0
min_size := wsize.min (xsize)
if sub_l >= 0 then
addmul_1 (target.item, 0, op1.item, 0, min_size, op2, carry)
cy := carry.item
wp := wp + min_size
xp := xp + min_size
dsize := xsize - wsize
if dsize /= 0 then
if dsize > 0 then
mul_1 (target.item, wp, op1.item, xp, min_size, op2, carry)
cy2 := carry.item
else
dsize := -dsize
cy2 := 0
end
add_1 (target.item, wp, target.item, wp, dsize, cy, carry)
cy := cy2 + carry.item
end
target.item [wp + dsize] := cy
if cy /= 0 then
new_wsize := new_wsize + 1
end
else
submul_1 (target.item, wp, op1.item, xp, min_size, op2, carry)
cy := carry.item
if wsize >= xsize then
if wsize /= xsize then
sub_1 (target.item, wp + xsize, op1.item, wp + xsize, wsize - xsize, cy, carry)
cy := carry.item
if cy /= 0 then
target.item [wp + new_wsize] := (-cy.to_integer_32).bit_not.to_natural_32
d := wp
s := wp
n := new_wsize
from
target.item [d] := target.item [s].bit_not
d := d + 1
s := s + 1
n := n - 1
until
n = 0
loop
target.item [d] := target.item [s].bit_not
d := d + 1
s := s + 1
n := n - 1
end
new_wsize := new_wsize + 1
p := wp
x := target.item [p] + 1
target.item [p] := x
if x < 1 then
from
p := p + 1
target.item [p] := target.item [p] + 1
until
target.item [p] /= 0
loop
p := p + 1
target.item [p] := target.item [p] + 1
end
end
wsize_signed := -wsize_signed
end
else
d := wp
s := wp
n := wsize
from
target.item [d] := target.item [s].bit_not
s := s + 1
d := d + 1
n := n - 1
until
n = 0
loop
target.item [d] := target.item [s].bit_not
s := s + 1
d := d + 1
n := n - 1
end
add_1 (target.item, wp, target.item, wp, wsize, 1, carry)
cy := carry.item
cy := cy - 1
if cy = (0).to_natural_32.bit_not then
cy2 := cy2 + 1
end
cy := cy + cy2
mul_1 (target.item, wp + wsize, target.item, xp + wsize, xsize - wsize, op2, carry)
cy__ := carry.item
add_1 (target.item, wp + wsize, target.item, wp + wsize, xsize - wsize, cy, carry)
cy := cy__ + carry.item
target.item [wp + new_wsize] := cy
if cy /= 0 then
new_wsize := new_wsize + 1
end
if cy2 /= 0 then
p := wp + wsize
x := target.item [p]
target.item [p] := x - 1
if x < 1 then
from
p := p + 1
target.item [p] := target.item [p] - 1
until
target.item [p] = 0
loop
p := p + 1
target.item [p] := target.item [p] - 1
end
end
end
wsize_signed := -wsize_signed
end
end
from
until
new_wsize <= 0 or target.item [(wp + new_wsize) * 4] /= 0
loop
new_wsize := new_wsize - 1
end
end
if wsize_signed >= 0 then
target.count := new_wsize
else
target.count := -new_wsize
end
end
end
end
sub (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X)
-- Set `rop' to `op1' - `op2'.
local
usize: INTEGER_32
vsize: INTEGER_32
wsize: INTEGER_32
abs_usize: INTEGER_32
abs_vsize: INTEGER_32
pointer_temp: READABLE_INTEGER_X
integer_temp: INTEGER_32
junk2: NATURAL_32
cy_limb: NATURAL_32
op1: READABLE_INTEGER_X
op2: READABLE_INTEGER_X
carry: CELL [NATURAL_32]
do
create carry.put (0)
op1 := op1_a
op2 := op2_a
usize := op1.count
vsize := -op2.count
abs_usize := usize.abs
abs_vsize := vsize.abs
if abs_usize < abs_vsize then
pointer_temp := op1
op1 := op2
op2 := pointer_temp
integer_temp := usize
usize := vsize
vsize := integer_temp
integer_temp := abs_usize
abs_usize := abs_vsize
abs_vsize := integer_temp
end
wsize := abs_usize + 1
target.resize (wsize)
if usize.bit_xor (vsize) < 0 then
if abs_usize /= abs_vsize then
sub_special (target.item, 0, op1.item, 0, abs_usize, op2.item, 0, abs_vsize, carry)
junk2 := carry.item
wsize := abs_usize
from
until
wsize <= 0 or target.item [wsize - 1] /= 0
loop
wsize := wsize - 1
end
if usize < 0 then
wsize := -wsize
end
elseif cmp (op1.item, 0, op2.item, 0, abs_usize) < 0 then
sub_n (target.item, 0, op2.item, 0, op1.item, 0, abs_usize, carry)
junk2 := carry.item
wsize := abs_usize
from
until
wsize <= 0 or target.item [wsize - 1] /= 0
loop
wsize := wsize - 1
end
if usize >= 0 then
wsize := -wsize
end
else
sub_n (target.item, 0, op1.item, 0, op2.item, 0, abs_usize, carry)
junk2 := carry.item
wsize := abs_usize
from
until
wsize <= 0 or target.item [wsize - 1] /= 0
loop
wsize := wsize - 1
end
if usize < 0 then
wsize := -wsize
end
end
else
add_special (target.item, 0, op1.item, 0, abs_usize, op2.item, 0, abs_vsize, carry)
cy_limb := carry.item
target.item [abs_usize] := cy_limb
wsize := abs_usize + cy_limb.to_integer_32
if usize < 0 then
wsize := -wsize
end
end
target.count := wsize
end
sub_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
-- Set `rop' to `op1' - `op2'.
local
usize: INTEGER_32
wsize: INTEGER_32
abs_usize: INTEGER_32
vval: NATURAL_32
cy: NATURAL_32
junk2: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
usize := op1.count
abs_usize := usize.abs
wsize := abs_usize + 1
target.resize (wsize)
if abs_usize = 0 then
target.item [0] := vval
if op2 /= 0 then
target.count := -1
else
target.count := 0
end
else
if usize < 0 then
add_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
cy := carry.item
target.item [abs_usize] := cy
wsize := - (abs_usize + cy.to_integer_32)
else
if abs_usize = 1 and op1.item [0] < op2 then
target.item [0] := op2 - op1.item [0]
wsize := -1
else
sub_1 (target.item, 0, op1.item, 0, abs_usize, op2, carry)
junk2 := carry.item
if target.item [abs_usize - 1] = 0 then
wsize := abs_usize - 1
else
wsize := abs_usize
end
end
end
target.count := wsize
end
end
ui_sub (target: READABLE_INTEGER_X; op1: NATURAL_32; op2: READABLE_INTEGER_X)
-- Set `rop' to `op1' - `op2'.
local
vn: INTEGER_32
wn: INTEGER_32
cy: NATURAL_32
junk2: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
vn := op2.count
if vn > 1 then
if vn > target.capacity then
target.resize (vn)
end
sub_1 (target.item, 0, op2.item, 0, vn, op1, carry)
junk2 := carry.item
if target.item [vn - 1] = 0 then
wn := - (vn - 1)
else
wn := - vn
end
elseif vn = 1 then
if op1 >= op2.item [0] then
target.item [0] := op1 - op2.item [0]
if target.item [0] /= 0 then
wn := 1
else
wn := 0
end
else
target.item [0] := op2.item [0] - op1
wn := -1
end
elseif vn = 0 then
target.item [0] := op1
if op1 /= 0 then
wn := 1
else
wn := 0
end
else
vn := -vn
target.resize (vn + 1)
add_1 (target.item, 0, op2.item, 0, vn, op1, carry)
cy := carry.item
target.item [vn] := cy
if cy /= 0 then
wn := vn + 1
else
wn := vn
end
end
target.count := wn
end
addmul (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: READABLE_INTEGER_X)
-- Set `rop' to `rop' + `op1' times `op2'.
do
aorsmul (target, op1, op2, 0)
end
addmul_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
-- Set `rop' to `rop' + `op1' times `op2'.
do
aorsmul_1 (target, op1, op2, 0)
end
submul (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: READABLE_INTEGER_X)
-- Set `rop' to `rop' - `op1' times `op2'.
do
aorsmul (target, op1, op2, -1)
end
submul_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL)
-- Set `rop' to `rop' - `op1' times `op2'.
do
aorsmul_1 (target, op1, op2, -1)
end
mul (target: READABLE_INTEGER_X; op1_a: READABLE_INTEGER_X; op2_a: READABLE_INTEGER_X)
-- Set `rop' to `op1' times `op2'.
local
usize: INTEGER
vsize: INTEGER
wsize: INTEGER
sign_product: INTEGER
vp: SPECIAL [NATURAL_32]
vp_offset: INTEGER
up: SPECIAL [NATURAL_32]
up_offset: INTEGER
wp: SPECIAL [NATURAL_32]
wp_offset: INTEGER
cy_limb: NATURAL_32
op_temp: READABLE_INTEGER_X
size_temp: INTEGER_32
op1: READABLE_INTEGER_X
op2: READABLE_INTEGER_X
carry: CELL [NATURAL_32]
do
create carry.put (0)
op1 := op1_a
op2 := op2_a
usize := op1.count
vsize := op2.count
sign_product := usize.bit_xor (vsize)
usize := usize.abs
vsize := vsize.abs
if usize = 0 or vsize = 0 then
target.count := 0
else
if vsize = 1 then
if usize + 1 > target.capacity then
target.resize (usize + 1)
end
wp := target.item
mul_1 (target.item, 0, op1.item, 0, usize, op2.item [0], carry)
cy_limb := carry.item
target.item [usize] := cy_limb
if cy_limb /= 0 then
usize := usize + 1
end
if sign_product >= 0 then
target.count := usize
else
target.count := -usize
end
else
wsize := usize + vsize
if wsize <= 32 and target /= op1 and target /= op2 then
target.resize (wsize)
wp := target.item
if usize > vsize then
mul_basecase (wp, 0, op1.item, 0, usize, op2.item, 0, vsize)
else
mul_basecase (wp, 0, op2.item, 0, vsize, op1.item, 0, usize)
end
wsize := wsize - (wp [wp_offset + wsize - 1] = 0).to_integer
if sign_product >= 0 then
target.count := wsize
else
target.count := -wsize
end
else
if usize < vsize then
op_temp := op1
op1 := op2
op2 := op_temp
size_temp := usize
usize := vsize
vsize := size_temp
end
up := op1.item
up_offset := 0
vp := op2.item
vp_offset := 0
wp := target.item
wp_offset := 0
if target.capacity < wsize then
create wp.make_filled (0, wsize)
target.item := wp
else
if wp = up then
create up.make_filled (0, usize)
if wp = vp then
vp := up
end
up.copy_data (wp, 0, 0, usize)
elseif wp = vp then
create vp.make_filled (0, vsize)
vp.copy_data (wp, 0, 0, vsize)
end
end
mul_special (wp, 0, up, 0, usize, vp, 0, vsize, carry)
cy_limb := carry.item
wsize := usize + vsize
wsize := wsize - (cy_limb = 0).to_integer
if sign_product < 0 then
target.count := -wsize
else
target.count := wsize
end
end
end
end
end
mul_2exp (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; count_a: INTEGER)
local
usize: INTEGER
abs_usize: INTEGER
wsize: INTEGER
limb_count: INTEGER
wp: SPECIAL [NATURAL_32]
wp_offset: INTEGER
wlimb: NATURAL_32
count: INTEGER
carry: CELL [NATURAL_32]
do
create carry.put (0)
count := count_a
usize := op1.count
abs_usize := usize.abs
if usize = 0 then
target.count := 0
else
limb_count := count // limb_bits
wsize := abs_usize + limb_count + 1
target.resize (wsize)
wp := target.item
wsize := abs_usize + limb_count
count := count \\ limb_bits
if count /= 0 then
lshift (wp, wp_offset + limb_count, op1.item, 0, abs_usize, count, carry)
wlimb := carry.item
if wlimb /= 0 then
wp [wp_offset + wsize] := wlimb
wsize := wsize + 1
end
else
wp.copy_data (op1.item, 0, wp_offset + limb_count, abs_usize)
end
wp.fill_with (0, wp_offset, wp_offset + limb_count - 1)
if usize >= 0 then
target.count := wsize
else
target.count := -wsize
end
end
end
mul_si (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: INTEGER)
local
size: INTEGER
sign_product: INTEGER
sml: NATURAL_32
cy: NATURAL_32
pp: SPECIAL [NATURAL_32]
pp_offset: INTEGER
carry: CELL [NATURAL_32]
do
create carry.put (0)
size := op1.count
sign_product := size
if size = 0 or op2 = 0 then
target.count := 0
else
size := size.abs
sml := op2.abs.to_natural_32
target.resize (size + 1)
pp := target.item
mul_1 (pp, pp_offset, op1.item, 0, size, sml, carry)
cy := carry.item
pp [pp_offset + size] := cy
size := size + (cy /= 0).to_integer
end
if sign_product < 0 xor op2 < 0 then
target.count := -size
else
target.count := size
end
end
mul_ui (target: READABLE_INTEGER_X; op1: READABLE_INTEGER_X; op2: NATURAL_32)
local
size: INTEGER
sign_product: INTEGER
sml: NATURAL_32
cy: NATURAL_32
pp: SPECIAL [NATURAL_32]
pp_offset: INTEGER
carry: CELL [NATURAL_32]
do
create carry.put (0)
size := op1.count
sign_product := size
if size = 0 or op2 = 0 then
target.count := 0
else
size := size.abs
sml := op2
target.resize (size + 1)
pp := target.item
mul_1 (pp, pp_offset, op1.item, 0, size, sml, carry)
cy := carry.item
pp [pp_offset + size] := cy
size := size + (cy /= 0).to_integer
end
if sign_product < 0 xor op2 < 0 then
target.count := -size
else
target.count := size
end
end
neg (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X)
-- Set `rop' to -`op'.
local
usize: INTEGER_32
size: INTEGER_32
do
usize := op.count
if target /= op then
size := usize.abs
target.resize (size)
target.item.copy_data (op.item, 0, 0, size)
end
target.count := -usize
end
abs (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X)
-- Set `rop' to the absolute value of `op'.
local
size: INTEGER_32
do
size := op.count.abs
if op /= target then
target.resize (size)
target.item.copy_data (op.item, 0, 0, size)
end
target.count := size
end
end

View File

@@ -0,0 +1,155 @@
note
description: "Summary description for {INTEGER_X_ASSIGNMENT}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "The object and practice of liberty lies in the limitation of governmental power. - General Douglas MacArthur"
deferred class
INTEGER_X_ASSIGNMENT
inherit
INTEGER_X_FACILITIES
SPECIAL_ASSIGNMENT
rename
set_str as set_str_special
end
MP_BASES
feature
swap (target: READABLE_INTEGER_X; other_a: READABLE_INTEGER_X)
-- Swap the values `rop1' and `rop2' efficiently.
local
other_size: INTEGER_32
other_pointer: SPECIAL [NATURAL_32]
do
other_size := other_a.count
other_pointer := other_a.item
other_a.count := target.count
other_a.item := target.item
target.count := other_size
target.item := other_pointer
end
set_str (target: READABLE_INTEGER_X; str: READABLE_STRING_8; base_a: INTEGER)
-- Set the value of `rop' from `str', a null-terminated C string in base `base'.
-- White space is allowed in the string, and is simply ignored.
-- The base may vary from 2 to 62, or if base is 0, then the leading characters
-- are used: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, or
-- decimal otherwise.
-- For bases up to 36, case is ignored; upper-case and lower-case letters have
-- the same value.
-- For bases 37 to 62, upper-case letter represent the usual 10..35 while
-- lower-case letter represent 36..61.
-- This function returns 0 if the entire string is a valid number in base base.
-- Otherwise it returns -1.
require
base_a <= 62
base_a >= 2 or base_a = 0
local
base: INTEGER
str_offset: INTEGER
s: SPECIAL [NATURAL_8]
s_offset: INTEGER
begs: INTEGER
i: INTEGER
xsize: INTEGER
c: CHARACTER
negative: BOOLEAN
digit_value: CHARACTER_STRATEGY
str_size: INTEGER
dig: NATURAL_8
do
base := base_a
if base > 36 then
create {CASE_SENSITIVE_STRATEGY}digit_value
else
create {CASE_INSENSITIVE_STRATEGY}digit_value
end
from
str_offset := 1
c := ' '
until
not c.is_space or not str.valid_index (str_offset)
loop
c := str [str_offset]
str_offset := str_offset + 1
end
if c = '-' then
negative := True
c := str [str_offset]
str_offset := str_offset + 1
end
if base = 0 then
if digit_value.text_to_number (c.code.to_natural_8) >= 10 then
(create {INTEGER_X_STRING_EXCEPTION}).raise
end
else
if digit_value.text_to_number (c.code.to_natural_8) >= base then
(create {INTEGER_X_STRING_EXCEPTION}).raise
end
end
if base = 0 then
base := 10
if c = '0' then
base := 8
if str.valid_index (str_offset) then
c := str [str_offset]
end
str_offset := str_offset + 1
if c = 'x' or c = 'X' then
base := 16
c := str [str_offset]
str_offset := str_offset + 1
elseif c = 'b' or c = 'B' then
base := 2
c := str [str_offset]
str_offset := str_offset + 1
end
end
end
from
until
c /= '0' and not c.is_space or not str.valid_index (str_offset)
loop
c := str [str_offset]
str_offset := str_offset + 1
end
if c.code = 0 then
target.count := 0
target.item [0] := 0
else
str_size := str.count - str_offset + 2
create s.make_filled (0, str_size)
from
i := 0
until
i >= str_size
loop
if not c.is_space then
dig := digit_value.text_to_number (c.code.to_natural_8)
if dig.to_integer_32 >= base then
(create {INTEGER_X_STRING_EXCEPTION}).raise
end
s [s_offset] := dig
s_offset := s_offset + 1
end
if str.valid_index (str_offset) then
c := str [str_offset]
end
str_offset := str_offset + 1
i := i + 1
end
str_size := s_offset - begs
xsize := (str_size / chars_per_bit_exactly (base)).truncated_to_integer // 32 + 2
target.resize (xsize)
xsize := set_str_special (target.item, 0, s, begs, str_size, base)
if negative then
target.count := -xsize
else
target.count := xsize
end
end
end
end

View File

@@ -0,0 +1,200 @@
note
description: "Summary description for {INTEGER_X_COMPARISON}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "The marvel of all history is the patience with which men and women submit to burdens unnecessarily laid upon them by their governments. - U.S. Senator William Borah"
deferred class
INTEGER_X_COMPARISON
inherit
INTEGER_X_FACILITIES
SPECIAL_COMPARISON
rename
cmp as cmp_special
end
feature
compare (op1: READABLE_INTEGER_X; op2: READABLE_INTEGER_X): INTEGER
-- Compare `op1' and `op2'.
-- Return a positive value if `op1' > `op2', zero if `op1' = `op2', or a negative value if `op1' < `op2'.
local
usize: INTEGER_32
vsize: INTEGER_32
dsize: INTEGER_32
asize: INTEGER_32
cmp_l: INTEGER_32
do
usize := op1.count
vsize := op2.count
dsize := usize - vsize
if dsize /= 0 then
Result := dsize
else
asize := usize.abs
cmp_l := cmp_special (op1.item, 0, op2.item, 0, asize)
if usize >= 0 then
Result := cmp_l
else
Result := -cmp_l
end
end
end
cmp_si (op1: READABLE_INTEGER_X; op: INTEGER_32): INTEGER
-- Compare `op1' and `op2'.
-- Return a positive value if `op1' > `op2', zero if `op1' = `op2', or a negative value if `op1' < `op2'.
-- Is a macro and will evaluate their arguments more than once.
local
v_digit: INTEGER_32
usize: INTEGER_32
vsize: INTEGER_32
u_digit: NATURAL_32
do
v_digit := op
usize := op1.count
vsize := 0
if v_digit > 0 then
vsize := 1
elseif v_digit < 0 then
vsize := -1
v_digit := -v_digit
end
if usize /= vsize then
Result := usize - vsize
else
if usize = 0 then
Result := 0
else
u_digit := op1.item [0]
if u_digit = v_digit.to_natural_32 then
Result := 0
else
if u_digit > v_digit.to_natural_32 then
Result := usize
else
Result := -usize
end
end
end
end
end
cmp_ui (op1: READABLE_INTEGER_X; op: NATURAL): INTEGER
-- Compare `op1' and `op2'.
-- Return a positive value if `op1' > `op2', zero if `op1' = `op2', or a negative value if `op1' < `op2'.
-- Is a macro and will evaluate their arguments more than once.
local
un: INTEGER_32
ul: NATURAL_32
v_digit: NATURAL_32
do
v_digit := op
un := op1.count
if un = 0 then
if v_digit /= 0 then
Result := -1
else
Result := 0
end
else
if un = 1 then
ul := op1.item [0]
if ul > v_digit then
Result := 1
else
if ul < v_digit then
Result := -1
else
Result := 0
end
end
else
if un > 0 then
Result := 1
else
Result := -1
end
end
end
end
cmpabs (op1: READABLE_INTEGER_X ;op2: READABLE_INTEGER_X): INTEGER
-- Compare the absolute values of `op1' and `op2'.
-- Return a positive value if abs(`op1') > abs(`op2'), zero if abs(`op1') = abs(`op2'),
-- or a negative value if abs(`op1') < abs(`op2').
local
usize: INTEGER_32
vsize: INTEGER_32
dsize: INTEGER_32
cmp_l: INTEGER_32
i: INTEGER_32
x: NATURAL_32
y: NATURAL_32
do
usize := op1.count.abs
vsize := op2.count.abs
dsize := usize - vsize
if dsize /= 0 then
Result := dsize
else
cmp_l := 0
from
i := usize - 1
until
i < 0 or cmp_l /= 0
loop
x := op1.item [i]
y := op2.item [i]
if x /= y then
if x > y then
Result := 1
else
Result := -1
end
end
i := i - 1
variant
i + 2
end
end
end
cmpabs_ui (op1: READABLE_INTEGER_X; op: NATURAL_32): INTEGER
-- Compare the absolute values of `op1' and `op2'.
-- Return a positive value if abs(`op1') > abs(`op2'), zero if abs(`op1') = abs(`op2'),
-- or a negative value if abs(`op1') < abs(`op2').
local
un: INTEGER_32
ul: NATURAL_32
v_digit: NATURAL_32
do
v_digit := op
un := op1.count
if un = 0 then
if v_digit /= 0 then
Result := -1
else
Result := 0
end
else
un := un.abs
if un = 1 then
ul := op1.item [0]
if ul > v_digit then
Result := 1
else
if ul < v_digit then
Result := -1
else
Result := 0
end
end
else
Result := 1
end
end
end
end

View File

@@ -0,0 +1,429 @@
note
description: "Summary description for {INTEGER_X_DIVISION}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Collecting more taxes than is absolutely necessary is legalized robbery. - President Calvin Coolidge"
deferred class
INTEGER_X_DIVISION
inherit
INTEGER_X_FACILITIES
SPECIAL_UTILITY
export
{NONE}
all
end
SPECIAL_DIVISION
rename
add as add_special,
sub as sub_special,
mul as mul_special,
tdiv_qr as tdiv_qr_special
export
{NONE}
all
end
INTEGER_X_ARITHMETIC
INTEGER_X_ASSIGNMENT
rename
add as add_special,
sub as sub_special,
mul as mul_special
export
{NONE}
all
end
feature
fdiv_r_2exp (target: READABLE_INTEGER_X; u: READABLE_INTEGER_X; count: INTEGER)
do
cfdiv_r_2exp (target, u, count, -1)
end
cdiv_r_2exp (target: READABLE_INTEGER_X; u: READABLE_INTEGER_X; count: INTEGER)
do
cfdiv_r_2exp (target, u, count, 1)
end
cfdiv_r_2exp (target: READABLE_INTEGER_X; u: READABLE_INTEGER_X; count_a: INTEGER; direction: INTEGER)
local
usize: INTEGER
abs_usize: INTEGER
limb_count: INTEGER
i: INTEGER
up: SPECIAL [NATURAL_32]
up_offset: INTEGER
wp: SPECIAL [NATURAL_32]
wp_offset: INTEGER
high: NATURAL_32
count: INTEGER
returned: BOOLEAN
negate: BOOLEAN
do
create wp.make_empty (0)
count := count_a
usize := u.count
if usize = 0 then
target.count := 0
else
limb_count := count // 32
count := count \\ 32
abs_usize := usize.abs
up := u.item
if usize.bit_xor (direction) < 0 and Current = u and abs_usize <= limb_count then
returned := True
else
if usize.bit_xor (direction) < 0 then
if Current = u then
wp := target.item
else
i := abs_usize.min (limb_count + 1)
target.resize (i)
wp := target.item
wp.copy_data (up, up_offset, wp_offset, i)
if abs_usize <= limb_count then
target.count := usize
returned := True
end
end
else
if abs_usize <= limb_count then
negate := True
else
from
i := 0
until
i < limb_count or negate
loop
negate := up [up_offset + i] /= 0
i := i + 1
end
if not negate then
if up [up_offset + limb_count].bit_and (((1).to_natural_32 |<< count) - 1) /= 0 then
negate := True
else
target.count := 0
returned := True
end
end
end
if not returned and negate then
target.resize (limb_count + 1)
up := u.item
up_offset := 0
wp := target.item
wp_offset := 0
i := abs_usize.min (limb_count + 1)
com_n (wp, wp_offset, up, up_offset, i)
from
until
i > limb_count
loop
wp [wp_offset + i] := high.max_value
i := i + 1
end
incr_u (wp, wp_offset, 1)
usize := -usize
end
end
end
if not returned then
high := wp [wp_offset + limb_count]
high := high.bit_and (((1).to_natural_32 |<< count) - 1)
wp [wp_offset + limb_count] := high
from
limb_count := limb_count - 1
until
high /= 0 or limb_count < 0
loop
high := wp [wp_offset + limb_count]
end
if limb_count < 0 then
target.count := 0
else
limb_count := limb_count + 1
if usize >= 0 then
target.count := limb_count
else
target.count := -limb_count
end
end
end
end
end
mod (target: READABLE_INTEGER_X; dividend: READABLE_INTEGER_X; divisor_a: READABLE_INTEGER_X)
local
divisor_size: INTEGER
temp_divisor: INTEGER_X
divisor: READABLE_INTEGER_X
do
divisor := divisor_a
divisor_size := divisor.count
if target = divisor then
create temp_divisor.make_limbs (divisor_size.abs)
temp_divisor.set_from_other (divisor)
divisor := temp_divisor
end
tdiv_r (target, dividend, divisor)
if target.count /= 0 then
if dividend.count < 0 then
if divisor.count < 0 then
sub (target, target, divisor)
else
add (target, target, divisor)
end
end
end
end
tdiv_q (target: READABLE_INTEGER_X; numerator: READABLE_INTEGER_X; denominator: READABLE_INTEGER_X)
local
ql: INTEGER
ns: INTEGER
ds: INTEGER
nl: INTEGER
dl: INTEGER
np: SPECIAL [NATURAL_32]
np_offset: INTEGER
dp: SPECIAL [NATURAL_32]
dp_offset: INTEGER
qp: SPECIAL [NATURAL_32]
qp_offset: INTEGER
rp: SPECIAL [NATURAL_32]
rp_offset: INTEGER
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
do
ns := numerator.count
ds := denominator.count
nl := ns.abs
dl := ds.abs
ql := nl - dl + 1
if dl = 0 then
(create {DIVIDE_BY_ZERO}).raise
end
if ql <= 0 then
target.count := 0
else
target.resize (ql)
qp := target.item
create rp.make_filled (0, dl)
np := numerator.item
dp := denominator.item
if dp = qp then
create tp.make_filled (0, dl)
tp.copy_data (dp, dp_offset, tp_offset, dl)
dp := tp
end
if np = qp then
create tp.make_filled (0, nl)
tp.copy_data (np, np_offset, tp_offset, nl)
np := tp
end
tdiv_qr_special (qp, qp_offset, rp, rp_offset, np, np_offset, nl, dp, dp_offset, dl)
ql := ql - (qp [qp_offset + ql - 1] = 0).to_integer
if ns.bit_xor (ds) >= 0 then
target.count := ql
else
target.count := -ql
end
end
end
tdiv_q_2exp (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X; count_a: INTEGER_32)
local
usize: INTEGER
wsize: INTEGER
limb_count: INTEGER
wp: SPECIAL [NATURAL_32]
wp_offset: INTEGER
up: SPECIAL [NATURAL_32]
up_offset: INTEGER
junk: NATURAL_32
count: INTEGER_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
count := count_a
usize := op.count
limb_count := count // 32
wsize := usize.abs - limb_count
if wsize <= 0 then
target.count := 0
else
target.resize (wsize)
wp := target.item
up := op.item
count := count \\ 32
if count /= 0 then
rshift (wp, wp_offset, up, up_offset + limb_count, wsize, count, carry)
junk := carry.item
wsize := wsize - (wp [wp_offset + wsize - 1] = 0).to_integer
else
wp.copy_data (up, up_offset + limb_count, wp_offset, wsize)
end
if usize >= 0 then
target.count := wsize
else
target.count := -wsize
end
end
end
tdiv_qr (target: READABLE_INTEGER_X; remainder: READABLE_INTEGER_X; numerator: READABLE_INTEGER_X; denominator: READABLE_INTEGER_X)
local
ql: INTEGER_32
ns: INTEGER_32
ds: INTEGER_32
nl: INTEGER_32
dl: INTEGER_32
temp_dp: SPECIAL [NATURAL_32]
temp_np: SPECIAL [NATURAL_32]
do
ns := numerator.count
ds := denominator.count
nl := ns.abs
dl := ds.abs
ql := nl - dl + 1
if dl = 0 then
(create {DIVIDE_BY_ZERO}).raise
end
remainder.resize (dl)
if ql <= 0 then
if numerator /= remainder then
remainder.item.copy_data (numerator.item, 0, 0, nl)
remainder.count := numerator.count
end
target.count := 0
else
target.resize (ql)
if denominator = remainder or denominator = Current then
create temp_dp.make_empty (dl)
temp_dp.copy_data (denominator.item, 0, 0, dl)
else
temp_dp := denominator.item
end
if numerator = remainder or numerator = Current then
create temp_np.make_empty (nl)
temp_np.copy_data (numerator.item, 0, 0, nl)
else
temp_np := numerator.item
end
tdiv_qr_special (target.item, 0, remainder.item, 0, temp_np, 0, nl, temp_dp, 0, dl)
if target.item [ql - 1] = 0 then
ql := ql - 1
end
remainder.count := normalize (remainder.item, 0, remainder.count)
dl := remainder.count
if ns.bit_xor (ds) >= 0 then
target.count := ql
else
target.count := -ql
end
if ns >= 0 then
remainder.count := dl
else
remainder.count := -dl
end
end
end
tdiv_r (remainder: READABLE_INTEGER_X; numerator: READABLE_INTEGER_X; denominator: READABLE_INTEGER_X)
local
ql: INTEGER
ns: INTEGER
ds: INTEGER
nl: INTEGER
dl: INTEGER
np: SPECIAL [NATURAL_32]
np_offset: INTEGER
dp: SPECIAL [NATURAL_32]
dp_offset: INTEGER
qp: SPECIAL [NATURAL_32]
qp_offset: INTEGER
rp: SPECIAL [NATURAL_32]
rp_offset: INTEGER
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
do
ns := numerator.count
ds := denominator.count
nl := ns.abs
dl := ds.abs
ql := nl - dl + 1
if dl = 0 then
(create {DIVIDE_BY_ZERO}).raise
end
remainder.resize (dl)
if ql <= 0 then
if numerator /= remainder then
np := numerator.item
rp := remainder.item
rp.copy_data (np, 0, 0, nl)
remainder.count := numerator.count
end
else
create qp.make_filled (0, ql)
rp := remainder.item
np := numerator.item
dp := denominator.item
if dp = rp then
create tp.make_filled (0, nl)
tp.copy_data (np, np_offset, tp_offset, nl)
np := tp
np_offset := tp_offset
end
tdiv_qr_special (qp, qp_offset, rp, rp_offset, np, np_offset, nl, dp, dp_offset, dl)
dl := normalize (rp, rp_offset, dl)
if ns >= 0 then
remainder.count := dl
else
remainder.count := -dl
end
end
end
tdiv_r_2exp (target: READABLE_INTEGER_X; op: READABLE_INTEGER_X; count: INTEGER)
local
in_size: INTEGER
res_size: INTEGER
limb_count: INTEGER
in_ptr: SPECIAL [NATURAL_32]
in_ptr_offset: INTEGER
x: NATURAL_32
do
in_size := op.count.abs
limb_count := count // 32
in_ptr := op.item
if in_size > limb_count then
x := in_ptr [in_ptr_offset + limb_count].bit_and (((1).to_natural_32 |<< (count \\ 32)- 1))
if x /= 0 then
res_size := limb_count + 1
target.resize (res_size)
target.item [limb_count] := x
else
res_size := limb_count
res_size := normalize (in_ptr, in_ptr_offset, res_size)
target.resize (res_size)
limb_count := res_size
end
else
res_size := in_size
target.resize (res_size)
limb_count := res_size
end
if target /= op then
target.item.copy_data (op.item, 0, 0, limb_count)
end
if op.count >= 0 then
target.count := res_size
else
target.count := -res_size
end
end
end

View File

@@ -0,0 +1,11 @@
note
description: "Summary description for {INTEGER_X_FACILITIES}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Concentrated power is not rendered harmless by the good intentions of those who create it. - Milton Friedman, Nobel prize-winning economist"
deferred class
INTEGER_X_FACILITIES
end

View File

@@ -0,0 +1,145 @@
note
description: "Summary description for {INTEGER_X_GCD}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "'Need' now means wanting someone else's money. 'Greed' means wanting to keep your own. 'Compassion' is when a politician arranges the transfer. - Joseph Sobran, columnist."
deferred class
INTEGER_X_GCD
inherit
INTEGER_X_FACILITIES
SPECIAL_GCD
rename
gcd as gcd_special
export
{NONE}
all
end
feature
gcd (g: READABLE_INTEGER_X; u: READABLE_INTEGER_X; v: READABLE_INTEGER_X)
local
g_zero_bits: INTEGER
u_zero_bits: INTEGER
v_zero_bits: INTEGER
g_zero_limbs: INTEGER
u_zero_limbs: INTEGER
v_zero_limbs: INTEGER
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
up: SPECIAL [NATURAL_32]
up_offset: INTEGER
usize: INTEGER
vp: SPECIAL [NATURAL_32]
vp_offset: INTEGER
vsize: INTEGER
gsize: INTEGER
junk: NATURAL_32
cy_limb: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
up := u.item
usize := u.count.abs
vp := v.item
vsize := v.count.abs
if usize = 0 then
g.count := vsize
if g = v then
else
g.resize (vsize)
g.item.copy_data (vp, 0, 0, vsize)
end
elseif vsize = 0 then
g.count := usize
if g = u then
else
g.resize (usize)
g.item.copy_data (up, up_offset, 0, usize)
end
elseif usize = 1 then
g.count := 1
g.item [0] := gcd_1 (vp, vp_offset, vsize, up [up_offset])
elseif vsize = 1 then
g.count := 1
g.item [0] := gcd_1 (up, up_offset, usize, vp [vp_offset])
else
from
until
up [up_offset] /= 0
loop
up_offset := up_offset + 1
end
u_zero_limbs := up_offset - 0
usize := usize - u_zero_limbs
u_zero_bits := trailing_zeros (up [up_offset])
tp := up
tp_offset := up_offset
create up.make_filled (0, usize)
if u_zero_bits /= 0 then
rshift (up, up_offset, tp, tp_offset, usize, u_zero_bits, carry)
junk := carry.item
usize := usize - (up [up_offset + usize - 1] = 0).to_integer
else
up.copy_data (tp, tp_offset, up_offset, usize)
end
from
until
vp [vp_offset] /= 0
loop
vp_offset := vp_offset + 1
end
v_zero_limbs := vp_offset - 0
vsize := vsize - v_zero_limbs
v_zero_bits := trailing_zeros (vp [vp_offset])
tp := vp
tp_offset := vp_offset
create vp.make_filled (0, vsize)
if v_zero_bits /= 0 then
rshift (vp, vp_offset, tp, tp_offset, vsize, v_zero_bits, carry)
junk := carry.item
vsize := vsize - (vp [vp_offset + vsize - 1] = 0).to_integer
else
vp.copy_data (tp, tp_offset, vp_offset, vsize)
end
if u_zero_limbs > v_zero_limbs then
g_zero_limbs := v_zero_limbs
g_zero_bits := v_zero_bits
elseif u_zero_limbs < v_zero_limbs then
g_zero_limbs := u_zero_limbs
g_zero_bits := u_zero_bits
else
g_zero_limbs := u_zero_limbs
g_zero_bits := u_zero_bits.min (v_zero_bits)
end
if usize < vsize or (usize = vsize and up [up_offset + usize - 1] < vp [vp_offset + vsize - 1]) then
vsize := gcd_special (vp, vp_offset, vp, vp_offset, vsize, up, up_offset, usize)
else
vsize := gcd_special (vp, vp_offset, up, up_offset, usize, vp, vp_offset, vsize)
end
gsize := vsize + g_zero_limbs
if g_zero_bits /= 0 then
gsize := gsize + ((vp [vp_offset + vsize - 1] |>> (32 - g_zero_bits)) /= 0).to_integer
g.resize (gsize)
g.item.fill_with (0, 0, g_zero_limbs)
tp := g.item
tp_offset := g_zero_limbs
lshift (tp, tp_offset, vp, vp_offset, vsize, g_zero_bits, carry)
cy_limb := carry.item
if cy_limb /= 0 then
tp [tp_offset + vsize] := cy_limb
end
else
g.resize (gsize)
g.item.fill_with (0, 0, g_zero_limbs)
g.item.copy_data (vp, vp_offset, g_zero_limbs, vsize)
end
g.count := gsize
end
ensure
g.count /= 0
end
end

View File

@@ -0,0 +1,335 @@
note
description: "Summary description for {INTEGER_X_IO}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "I personally call the type of government which can be removed without violence 'democracy,' and the other, 'tyranny.' - Karl Popper"
deferred class
INTEGER_X_IO
inherit
INTEGER_X_FACILITIES
SPECIAL_SIZING
SPECIAL_UTILITY
LIMB_MANIPULATION
feature
output (target: SPECIAL [NATURAL_8]; target_offset: INTEGER; countp: TUPLE [countp: INTEGER]; order: INTEGER; size: INTEGER; endian_a: INTEGER; z: READABLE_INTEGER_X)
local
zsize: INTEGER
zp: SPECIAL [NATURAL_32]
zp_offset: INTEGER
count: INTEGER
numb: INTEGER
endian: INTEGER
i: INTEGER
j: INTEGER
limb: NATURAL_32
wbitsmask: NATURAL_32
wbytes: INTEGER
woffset: INTEGER
dp: SPECIAL [NATURAL_8]
dp_offset: INTEGER
lbits: INTEGER
wbits: INTEGER
zend: INTEGER
newlimb: NATURAL_32
done: BOOLEAN
do
endian := endian_a
zsize := z.count
if zsize = 0 then
countp.countp := 0
else
zsize := zsize.abs
zp := z.item
numb := 8 * size
count := sizeinbase_2exp (zp, zp_offset, zsize, numb)
countp.countp := count
if endian = 0 then
endian := -1
end
if size = 4 then
if order = -1 and endian = -1 then
from
i := target_offset
j := zp_offset
until
j >= zp_offset + count - 1
loop
write_limb (zp [zp_offset + j], target, target_offset + i)
i := i + 4
j := j + 1
end
done := True
elseif order = 1 and endian = -1 then
from
i := target_offset
j := zp_offset + count - 1
until
j < zp_offset
loop
write_limb (zp [zp_offset + j], target, target_offset + i)
j := j - 1
i := i + 4
end
done := True
elseif order = -1 and endian = 1 then
from
i := target_offset
j := zp_offset
until
j >= zp_offset + count - 1
loop
write_limb_be (zp [zp_offset + j], target, target_offset + i)
j := j + 1
i := i + 4
end
done := True
elseif order = 1 and endian = 1 then
from
i := target_offset
j := zp_offset + count - 1
until
j < zp_offset
loop
write_limb_be (zp [zp_offset + j], target, target_offset + i)
j := j - 1
i := i + 4
end
done := True
end
end
if not done then
numb := size * 8
wbytes := numb // 8
wbits := numb \\ 8
wbitsmask := ((1).to_natural_8 |<< wbits) - 1
if endian >= 0 then
woffset := size
else
woffset := -size
end
if order < 0 then
woffset := woffset + size
else
woffset := woffset + -size
end
dp := target
dp_offset := target_offset
if order >= 0 then
dp_offset := dp_offset + (count - 1) * size
else
dp_offset := dp_offset + 0
end
if endian >= 0 then
dp_offset := dp_offset + size - 1
else
dp_offset := dp_offset + 0
end
zend := zp_offset + zsize
lbits := 0
limb := 0
from
i := 0
until
i >= count
loop
from
j := 0
until
j >= wbytes
loop
if lbits >= 8 then
dp [dp_offset] := limb.to_natural_8
limb := limb |>> 8
lbits := lbits - 8
else
if zp_offset = zend then
newlimb := 0
else
newlimb := zp [zp_offset]
zp_offset := zp_offset + 1
end
dp [dp_offset] := (limb.bit_or (newlimb |<< lbits)).to_natural_8
limb := newlimb |>> (8 - lbits)
lbits := lbits + limb_bits - 8
end
dp_offset := dp_offset - endian
j := j + 1
end
if wbits /= 0 then
if lbits >= wbits then
dp [dp_offset] := limb.bit_and (wbitsmask).to_natural_8
limb := limb |>> wbits
lbits := lbits - wbits
else
if zp_offset = zend then
newlimb := 0
else
newlimb := zp [zp_offset]
zp_offset := zp_offset + 1
end
dp [dp_offset] := (limb.bit_or (newlimb |<< lbits)).bit_and (wbitsmask).to_natural_8
limb := newlimb |>> (wbits - lbits)
lbits := lbits + limb_bits - wbits
end
end
from
until
j >= size
loop
dp [dp_offset] := 0
dp_offset := dp_offset - endian
j := j + 1
end
dp_offset := dp_offset + woffset
i := i + 1
end
end
end
end
input (z: READABLE_INTEGER_X; count: INTEGER; order: INTEGER; size: INTEGER; endian_a: INTEGER; source: SPECIAL [NATURAL_8]; source_offset: INTEGER)
local
zsize: INTEGER
zp: SPECIAL [NATURAL_32]
zp_offset: INTEGER
i: INTEGER
j: INTEGER
done: BOOLEAN
limb: NATURAL_32
byte: NATURAL_32
wbitsmask: NATURAL_8
numb: INTEGER
wbytes: INTEGER
woffset: INTEGER
dp: SPECIAL [NATURAL_8]
dp_offset: INTEGER
lbits: INTEGER
wbits: INTEGER
endian: INTEGER
do
endian := endian_a
zsize := (count * (8 * size) + limb_bits - 1) // limb_bits
z.resize (zsize)
zp := z.item
if endian = 0 then
endian := -1
end
if order = -1 and size = 4 and endian = -1 then
from
i := zp_offset
j := source_offset
until
i >= count + zp_offset - 1
loop
zp [zp_offset + i] := read_limb (source, source_offset + j)
j := j + 4
i := i + 1
end
done := True
elseif order = -1 and size = 4 and endian = 1 then
from
i := zp_offset
j := source_offset
until
i >= count + zp_offset - 1
loop
zp [zp_offset + i] := read_limb_be (source, source_offset + j)
j := j + 4
i := i + 1
end
done := True
elseif order = 1 and size = 4 and endian = -1 then
from
i := zp_offset + count - 1
j := source_offset
until
i < zp_offset
loop
zp [zp_offset + i] := read_limb (source, source_offset + j)
j := j + 4
i := i - 1
end
done := True
end
if not done then
numb := size * 8
wbytes := numb // 8
wbits := numb \\ 8
wbitsmask := ((1).to_natural_8 |<< wbits) - 1
woffset := (numb + 7) // 8
if endian >= 0 then
woffset := woffset
else
woffset := -woffset
end
if order < 0 then
woffset := woffset + size
else
woffset := woffset + -size
end
dp := source
dp_offset := source_offset
if order >= 0 then
dp_offset := dp_offset + (count - 1) * size
else
dp_offset := dp_offset + 0
end
if endian >= 0 then
dp_offset := dp_offset + size - 1
else
dp_offset := dp_offset + 0
end
limb := 0
lbits := 0
from
i := 0
until
i >= count
loop
from
j := 0
until
j >= wbytes
loop
byte := dp [dp_offset]
dp_offset := dp_offset - endian
limb := limb.bit_or (byte |<< lbits)
lbits := lbits + 8
if lbits >= limb_bits then
zp [zp_offset] := limb
zp_offset := zp_offset + 1
lbits := lbits - limb_bits
limb := byte |>> (8 - lbits)
end
j := j + 1
end
if wbits /= 0 then
byte := dp [dp_offset].bit_and (wbitsmask)
dp_offset := dp_offset - endian
limb := limb.bit_or (byte |<< lbits)
lbits := lbits + wbits
if lbits >= limb_bits then
zp [zp_offset] := limb
zp_offset := zp_offset + 1
lbits := lbits - limb_bits
limb := byte |>> (wbits - lbits)
end
end
dp_offset := dp_offset + woffset
i := i + 1
end
if lbits /= 0 then
zp [zp_offset] := limb
zp_offset := zp_offset + 1
end
end
zp := z.item
zsize := normalize (zp, 0, zsize)
z.count := zsize
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,967 @@
note
description: "Summary description for {INTEGER_X_NUMBER_THEORY}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Gun registration is a gateway drug. - Mark Gilmore"
deferred class
INTEGER_X_NUMBER_THEORY
inherit
INTEGER_X_FACILITIES
SPECIAL_ARITHMETIC
rename
add as add_special,
sub as sub_special,
mul as mul_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
export
{NONE}
all
end
SPECIAL_DIVISION
rename
add as add_special,
sub as sub_special,
mul as mul_special,
cmp as cmp_special,
tdiv_qr as tdiv_qr_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
export
{NONE}
all
end
SPECIAL_NUMBER_THEORETIC
rename
add as add_special,
sub as sub_special,
mul as mul_special,
cmp as cmp_special,
tdiv_qr as tdiv_qr_special,
gcdext as gcdext_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special,
invert_gf as invert_gf_special
export
{NONE}
all
end
INTEGER_X_ACCESS
rename
add as add_special,
sub as sub_special,
mul as mul_special,
cmp as cmp_special,
tdiv_qr as tdiv_qr_special,
sizeinbase as sizeinbase_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
end
INTEGER_X_ARITHMETIC
rename
cmp as cmp_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
end
INTEGER_X_ASSIGNMENT
rename
add as add_special,
sub as sub_special,
mul as mul_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
end
INTEGER_X_COMPARISON
INTEGER_X_LOGIC
rename
add as add_special,
sub as sub_special,
mul as mul_special
end
INTEGER_X_DIVISION
rename
cmp as cmp_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
end
INTEGER_X_RANDOM
rename
add as add_special,
sub as sub_special,
mul as mul_special,
cmp as cmp_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
end
INTEGER_X_GCD
rename
add as add_special,
sub as sub_special,
mul as mul_special,
cmp as cmp_special,
tdiv_qr as tdiv_qr_special,
bit_xor_lshift as bit_xor_lshift_special,
bit_xor as bit_xor_special
end
INTEGER_X_SIZING
feature
millerrabin_test (n: READABLE_INTEGER_X; nm1: READABLE_INTEGER_X; x: READABLE_INTEGER_X; y: READABLE_INTEGER_X; q: READABLE_INTEGER_X; k: INTEGER): INTEGER
local
i: INTEGER
do
powm (y, x, q, n)
if cmp_ui (y, 1) = 0 or compare (y, nm1) = 0 then
Result := 1
else
from
i := 1
Result := -1
until
Result /= -1 or i >= k
loop
powm_ui (y, y, 2, n)
if compare (y, nm1) = 0 then
Result := 1
elseif cmp_ui (y, 1) = 0 then
Result := 0
end
i := i + 1
end
if Result = -1 then
Result := 0
end
end
end
bin_uiui (target: READABLE_INTEGER_X; n_a: NATURAL_32; k_a: NATURAL_32)
-- Compute the binomial coefficient `n' over `k' and store the result in `rop'.
local
i: NATURAL_32
j: NATURAL_32
cnt: NATURAL_32
n1: CELL [NATURAL_32]
n0: CELL [NATURAL_32]
k0: NATURAL_32
-- t: NATURAL_64
k: NATURAL_32
n: NATURAL_32
rsize: CELL [INTEGER]
ralloc: CELL [INTEGER]
nacc: CELL [NATURAL_32]
kacc: CELL [NATURAL_32]
do
create n0.put (0)
create n1.put (0)
create rsize.put (0)
create ralloc.put (0)
create nacc.put (0)
create kacc.put (0)
n := n_a
k := k_a
if n < k then
target.count := 0
else
k := k.min (n - k)
if k = 0 then
target.count := 1
target.item [0] := 1
else
j := n - k + 1
target.item [0] := j
target.count := 1
ralloc.put (target.capacity)
nacc.put (1)
kacc.put (1)
cnt := 0
from
i := 2
until
i > k
loop
j := j + 1
cnt := nacc.item.bit_or (kacc.item).bit_and (1).bit_xor (1)
nacc.put (nacc.item |>> cnt.to_integer_32)
kacc.put (kacc.item |>> cnt.to_integer_32)
umul_ppmm (n1, n0, nacc.item, j)
k0 := kacc.item * i
if n1.item /= 0 then
muldiv (target, 32, rsize, ralloc, nacc, kacc)
nacc.put (j)
kacc.put (i)
else
nacc.put (n0.item)
kacc.put (k0)
end
i := i + 1
end
muldiv (target, 1, rsize, ralloc, nacc, kacc)
target.count := rsize.item
end
end
end
gcdext (g: READABLE_INTEGER_X; s: detachable READABLE_INTEGER_X; t: detachable READABLE_INTEGER_X; a: READABLE_INTEGER_X; b: READABLE_INTEGER_X)
-- Set `g' to the greatest common divisor of `a' and `b', and in addition set `s' and `t' to
-- coefficients satisfying `a*s + b*t = g'.
-- `g' is always positive, even if one or both of `a' and `b' are negative.
-- If `t' is NULL then that value is not computed.
local
asize: INTEGER
bsize: INTEGER
usize: INTEGER
vsize: INTEGER
ap: SPECIAL [NATURAL_32]
ap_offset: INTEGER
bp: SPECIAL [NATURAL_32]
bp_offset: INTEGER
up: SPECIAL [NATURAL_32]
up_offset: INTEGER
vp: SPECIAL [NATURAL_32]
vp_offset: INTEGER
gsize: INTEGER
ssize: INTEGER
tmp_ssize: TUPLE [tmp_ssize: INTEGER]
gp: SPECIAL [NATURAL_32]
sp: SPECIAL [NATURAL_32]
tmp_gp: SPECIAL [NATURAL_32]
tmp_gp_offset: INTEGER
tmp_sp: SPECIAL [NATURAL_32]
tmp_sp_offset: INTEGER
u: READABLE_INTEGER_X
v: READABLE_INTEGER_X
ss: detachable READABLE_INTEGER_X
tt: detachable READABLE_INTEGER_X
gtmp: INTEGER_X
stmp: INTEGER_X
x: INTEGER_X
do
create tmp_ssize
asize := a.count.abs
bsize := b.count.abs
ap := a.item
bp := b.item
if asize > bsize or (asize = bsize and cmp_special (ap, ap_offset, bp, bp_offset, asize) > 0) then
usize := asize
vsize := bsize
create up.make_filled (0, usize + 1)
create vp.make_filled (0, vsize + 1)
up.copy_data (ap, ap_offset, up_offset, usize)
vp.copy_data (bp, bp_offset, vp_offset, vsize)
u := a
v := b
ss := s
tt := t
else
usize := bsize
vsize := asize
create up.make_filled (0, usize + 1)
create vp.make_filled (0, vsize + 1)
up.copy_data (bp, bp_offset, up_offset, usize)
vp.copy_data (ap, ap_offset, vp_offset, vsize)
u := b
v := a
ss := t
tt := s
end
create tmp_gp.make_filled (0, usize + 1)
create tmp_sp.make_filled (0, usize + 1)
if vsize = 0 then
tmp_sp [tmp_sp_offset] := 1
tmp_ssize.tmp_ssize := 1
tmp_gp.copy_data (up, up_offset, tmp_gp_offset, usize)
gsize := usize
else
gsize := gcdext_special (tmp_gp, tmp_gp_offset, tmp_sp, tmp_sp_offset, tmp_ssize, up, up_offset, usize, vp, vp_offset, vsize)
end
ssize := tmp_ssize.tmp_ssize.abs
create gtmp
gtmp.item := tmp_gp
gtmp.count := gsize
create stmp
stmp.item := tmp_sp
if tmp_ssize.tmp_ssize.bit_xor (u.count) >= 0 then
stmp.count := ssize
else
stmp.count := -ssize
end
if attached {READABLE_INTEGER_X} tt as tt_l then
if v.count = 0 then
tt_l.count := 0
else
create x.make_limbs (ssize + usize + 1)
mul (x, stmp, u)
sub (x, gtmp, x)
tdiv_q (tt_l, x, v)
end
end
if attached {READABLE_INTEGER_X} ss as ss_l then
ss_l.resize (ssize)
sp := ss_l.item
sp.copy_data (tmp_sp, tmp_sp_offset, 0, ssize)
ss_l.count := stmp.count
end
g.resize (gsize)
gp := g.item
gp.copy_data (tmp_gp, tmp_gp_offset, 0, gsize)
g.count := gsize
end
invert (target: READABLE_INTEGER_X; x: READABLE_INTEGER_X; n: READABLE_INTEGER_X): BOOLEAN
local
gcd_l: INTEGER_X
tmp: INTEGER_X
xsize: INTEGER_32
nsize: INTEGER_32
size: INTEGER_32
do
xsize := x.count.abs
nsize := n.count.abs
size := xsize.max (nsize) + 1
if xsize = 0 or (nsize = 1 and n.item [0] = 1) then
Result := False
else
create gcd_l.make_limbs (size)
create tmp.make_limbs (size)
gcdext (gcd_l, tmp, void, x, n)
if gcd_l.count /= 1 or gcd_l.item [0] /= 1 then
Result := False
else
if tmp.count < 0 then
if n.count < 0 then
sub (target, tmp, n)
else
add (target, tmp, n)
end
else
target.copy (tmp)
end
Result := True
end
end
end
millerrabin (source: READABLE_INTEGER_X; reps: INTEGER): INTEGER
local
r: INTEGER
nm1: INTEGER_X
nm3: INTEGER_X
x: INTEGER_X
y: INTEGER_X
q: INTEGER_X
k: INTEGER
is_prime: INTEGER
rstate: MERSENNE_TWISTER_RNG
do
create nm1.make_limbs (source.count + 1)
sub_ui (nm1, source, 1)
create x.make_limbs (source.count + 1)
create y.make_limbs (2 * source.count)
x.set_from_natural_32 (210)
powm (y, x, nm1, source)
if cmp_ui (y, 1) /= 0 then
Result := 0
else
create q.make_limbs (source.count)
k := bit_scan_1 (nm1, 0)
tdiv_q_2exp (q, nm1, k)
create nm3.make_limbs (source.count + 1)
sub_ui (nm3, source, 3)
create rstate.make
is_prime := 1
from
r := 0
until
r >= reps or is_prime = 0
loop
urandomm (x, rstate, nm3)
add_ui (x, x, 2)
is_prime := millerrabin_test (source, nm1, x, y, q, k)
r := r + 1
end
Result := is_prime
end
end
powm (r: READABLE_INTEGER_X; b_a: READABLE_INTEGER_X; e: READABLE_INTEGER_X; m: READABLE_INTEGER_X)
local
xp: SPECIAL [NATURAL_32]
xp_offset: INTEGER
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
qp: SPECIAL [NATURAL_32]
qp_offset: INTEGER
gp: SPECIAL [NATURAL_32]
gp_offset: INTEGER
this_gp: SPECIAL [NATURAL_32]
this_gp_offset: INTEGER
bp: SPECIAL [NATURAL_32]
bp_offset: INTEGER
ep: SPECIAL [NATURAL_32]
ep_offset: INTEGER
mp: SPECIAL [NATURAL_32]
mp_offset: INTEGER
bn: INTEGER
es: INTEGER
en: INTEGER
mn: INTEGER
xn: INTEGER
invm: NATURAL_32
c: NATURAL_32
enb: INTEGER
i: INTEGER
big_k: INTEGER
j: INTEGER
l: INTEGER
small_k: INTEGER
m_zero_cnt: INTEGER
e_zero_cnt: INTEGER
sh: INTEGER
use_redc: BOOLEAN
new_b: INTEGER_X
b: READABLE_INTEGER_X
new_mp: SPECIAL [NATURAL_32]
new_mp_offset: INTEGER
junk: NATURAL_32
cy: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
b := b_a
mp := m.item
mn := m.count.abs
if mn = 0 then
(create {DIVIDE_BY_ZERO}).raise
end
es := e.count
if es = 0 then
if mn = 1 and mp [mp_offset] = 1 then
r.count := 0
else
r.count := 1
end
r.item [0] := 1
else
if es < 0 then
create new_b.make_limbs (mn + 1)
if not invert (new_b, b, m) then
(create {INVERSE_EXCEPTION}).raise
end
b := new_b
es := -es
end
en := es
use_redc := (mn < 170) and (mp [mp_offset] \\ 2 /= 0)
if use_redc then
invm := modlimb_invert (mp [mp_offset])
invm := 0 - invm
else
m_zero_cnt := leading_zeros (mp [mp_offset + mn - 1])
if m_zero_cnt /= 0 then
create new_mp.make_filled (0, mn)
lshift (new_mp, new_mp_offset, mp, mp_offset, mn, m_zero_cnt, carry)
junk := carry.item
mp := new_mp
mp_offset := new_mp_offset
end
end
e_zero_cnt := leading_zeros (e.item [en - 1])
enb := en * limb_bits - e_zero_cnt
small_k := 1
big_k := 2
from
until
small_k = 10 or 2 * enb <= big_k * (2 + small_k * (3 + small_k))
loop
small_k := small_k + 1
big_k := big_k * 2
end
create tp.make_filled (0, 2 * mn)
create qp.make_filled (0, mn + 1)
create gp.make_filled (0, big_k // 2 * mn)
bn := b.count.abs
bp := b.item
if bn > mn or (bn = mn and cmp_special (bp, bp_offset, mp, mp_offset, mn) >= 0) then
if use_redc then
reduce (tp, tp_offset + mn, bp, bp_offset, bn, mp, mp_offset, mn)
tp.fill_with (0, tp_offset, mn - tp_offset - 1)
tdiv_qr_special (qp, qp_offset, gp, gp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
else
reduce (gp, gp_offset, bp, bp_offset, bn, mp, mp_offset, mn)
end
else
if use_redc then
tp.copy_data (bp, bp_offset, tp_offset + mn, bn)
tdiv_qr_special (qp, qp_offset, gp, gp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
else
gp.copy_data (bp, bp_offset, gp_offset, bn)
gp.fill_with (0, gp_offset + bn, mn - bn - gp_offset - 1)
end
end
create xp.make_filled (0, mn)
sqr_n (tp, tp_offset, gp, gp_offset, mn)
if use_redc then
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
this_gp := gp
this_gp_offset := gp_offset
from
i := 1
until
i >= big_k // 2
loop
mul_n (tp, tp_offset, this_gp, this_gp_offset, xp, xp_offset, mn)
this_gp_offset := this_gp_offset + mn
if use_redc then
redc_basecase (this_gp, this_gp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, this_gp, this_gp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
i := i + 1
end
ep := e.item
i := en - 1
c := ep [ep_offset + i]
sh := limb_bits - e_zero_cnt
sh := sh - small_k
if sh < 0 then
if i > 0 then
i := i - 1
c := c |<< (-sh)
sh := sh + limb_bits
c := c.bit_or (ep [ep_offset + i] |>> sh)
end
else
c := c |>> sh
end
from
j := 0
until
c \\ 2 /= 0
loop
c := c |>> 1
j := j + 1
end
xp.copy_data (gp, gp_offset + mn * (c |>> 1).to_integer_32, xp_offset, mn)
from
j := j - 1
until
j < 0
loop
sqr_n (tp, tp_offset, xp, xp_offset, mn)
if use_redc then
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
j := j - 1
end
from
until
i <= 0 and sh <= 0
loop
c := ep [ep_offset + i]
l := small_k
sh := sh - l
if sh < 0 then
if i > 0 then
i := i - 1
c := c |<< (-sh)
sh := sh + limb_bits
c := c.bit_or (ep [ep_offset + i] |>> sh)
else
l := l + sh
end
else
c := c |>> sh
end
c := c.bit_and (((1).to_natural_32 |<< l) - 1)
from
until
(c |>> (l - 1)) /= 0 or (i <= 0 and sh <= 0)
loop
sqr_n (tp, tp_offset, xp, xp_offset, mn)
if use_redc then
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
if sh /= 0 then
sh := sh - 1
c := (c |<< 1) + ((ep [ep_offset + i] |>> sh).bit_and (1))
else
i := i - 1
sh := limb_bits - 1
c := (c |<< 1) + (ep [ep_offset + i] |>> sh)
end
end
if c /= 0 then
from
j := 0
until
c \\ 2 /= 0
loop
c := c |>> 1
j := j + 1
end
l := l - j
from
l := l - 1
until
l < 0
loop
sqr_n (tp, tp_offset, xp, xp_offset, mn)
if use_redc then
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
l := l - 1
end
mul_n (tp, tp_offset, xp, xp_offset, gp, gp_offset + mn * (c |>> 1).to_integer_32, mn)
if use_redc then
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
else
j := l
end
from
j := j - 1
until
j < 0
loop
sqr_n (tp, tp_offset, xp, xp_offset, mn)
if use_redc then
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, 2 * mn, mp, mp_offset, mn)
end
j := j - 1
end
end
if use_redc then
tp.copy_data (xp, xp_offset, tp_offset, mn)
tp.fill_with (0, tp_offset + mn, tp_offset + mn + mn - 1)
redc_basecase (xp, xp_offset, mp, mp_offset, mn, invm, tp, tp_offset)
if cmp_special (xp, xp_offset, mp, mp_offset, mn) >= 0 then
sub_n (xp, xp_offset, xp, xp_offset, mp, mp_offset, mn, carry)
junk := carry.item
end
else
if m_zero_cnt /= 0 then
lshift (tp, tp_offset, xp, xp_offset, mn, m_zero_cnt, carry)
cy := carry.item
tp [tp_offset + mn] := cy
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, mn + (cy /= 0).to_integer, mp, mp_offset, mn)
rshift (xp, xp_offset, xp, xp_offset, mn, m_zero_cnt, carry)
junk := carry.item
end
end
xn := mn
xn := normalize (xp, xp_offset, xn)
if ep [ep_offset].bit_and (1) /= 0 and b.count < 0 and xn /= 0 then
mp := m.item
sub_special (xp, xp_offset, mp, mp_offset, mn, xp, xp_offset, xn, carry)
junk := carry.item
xn := mn
xn := normalize (xp, xp_offset, xn)
end
r.resize (xn)
r.count := xn
r.item.copy_data (xp, xp_offset, 0, xn)
end
end
powm_ui (target: READABLE_INTEGER_X; b: READABLE_INTEGER_X; el: NATURAL_32; m: READABLE_INTEGER_X)
local
xp: SPECIAL [NATURAL_32]
xp_offset: INTEGER
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
qp: SPECIAL [NATURAL_32]
qp_offset: INTEGER
mp: SPECIAL [NATURAL_32]
mp_offset: INTEGER
bp: SPECIAL [NATURAL_32]
bp_offset: INTEGER
xn: INTEGER
tn: INTEGER
mn: INTEGER
bn: INTEGER
m_zero_count: INTEGER
c: INTEGER
e: NATURAL_32
new_mp: SPECIAL [NATURAL_32]
junk: NATURAL_32
new_bp: SPECIAL [NATURAL_32]
cy: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
mp := m.item
mn := m.count.abs
if mn = 0 then
(create {DIVIDE_BY_ZERO}).raise
end
if el = 0 then
target.count := (not (mn = 1 and then mp [mp_offset] = 1)).to_integer
target.item [0] := 1
else
m_zero_count := leading_zeros (mp [mp_offset + mn - 1])
if m_zero_count /= 0 then
create new_mp.make_filled (0, mn)
lshift (new_mp, 0, mp, mp_offset, mn, m_zero_count, carry)
junk := carry.item
mp := new_mp
end
bn := b.count.abs
bp := b.item
if bn > mn then
create new_bp.make_filled (0, mn)
reduce (new_bp, 0, bp, bp_offset, bn, mp, mp_offset, mn)
bp := new_bp
bn := mn
bn := normalize (bp, 0, bn)
end
if bn = 0 then
target.count := 0
else
create tp.make_filled (0, 2 * mn + 1)
create xp.make_filled (0, mn)
create qp.make_filled (0, mn + 1)
xp.copy_data (bp, bp_offset, xp_offset, bn)
xn := bn
e := el
c := leading_zeros (e)
e := (e |<< c) |<< 1
c := limb_bits - 1 - c
if c = 0 and then xn = mn and cmp_special (xp, xp_offset, mp, mp_offset, mn) >= 0 then
sub_n (xp, xp_offset, xp, xp_offset, mp, mp_offset, mn, carry)
junk := carry.item
else
from
until
c = 0
loop
sqr_n (tp, tp_offset, xp, xp_offset, xn)
tn := 2 * xn
tn := tn - (tp [tp_offset + tn - 1] = 0).to_integer
if tn < mn then
xp.copy_data (tp, tp_offset, xp_offset, tn)
xn := tn
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, tn, mp, mp_offset, mn)
xn := mn
end
if e.to_integer_32 < 0 then
mul_special (tp, tp_offset, xp, xp_offset, xn, bp, bp_offset, bn, carry)
junk := carry.item
tn := xn + bn
tn := tn - (tp [tp_offset + tn - 1] = 0).to_integer
if tn < mn then
xp.copy_data (tp, tp_offset, xp_offset, tn)
xn := tn
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, tn, mp, mp_offset, mn)
xn := mn
end
end
e := e |<< 1
c := c - 1
end
end
if m_zero_count /= 0 then
lshift (tp, tp_offset, xp, xp_offset, xn, m_zero_count, carry)
cy := carry.item
tp [tp_offset + xn] := cy
xn := xn + (cy /= 0).to_integer
if xn < mn then
xp.copy_data (tp, tp_offset, xp_offset, xn)
else
tdiv_qr_special (qp, qp_offset, xp, xp_offset, tp, tp_offset, xn, mp, mp_offset, mn)
xn := mn
end
rshift (xp, xp_offset, xp, xp_offset, xn, m_zero_count, carry)
junk := carry.item
end
xn := normalize (xp, xp_offset, xn)
if el.bit_test (0) and b.count < 0 and xn /= 0 then
mp := m.item
mp_offset := 0
sub_special (xp, xp_offset, mp, mp_offset, mn, xp, xp_offset, xn, carry)
junk := carry.item
xn := mn
xn := normalize (xp, xp_offset, xn)
end
target.resize (xn)
target.count := xn
target.item.copy_data (xp, xp_offset, 0, xn)
end
end
end
probab_prime_isprime (t: NATURAL_32): BOOLEAN
local
q: NATURAL_32
r: NATURAL_32
d: NATURAL_32
do
if t < 3 or not t.bit_test (0) then
Result := t = 2
else
from
d := 3
r := 1
q := d
until
Result or r = 0
loop
q := t // d
r := t - q * d
Result := (q < d)
d := d + 2
end
end
end
probab_prime_p (op1_a: READABLE_INTEGER_X; reps: INTEGER): INTEGER
local
r: NATURAL_32
n2: INTEGER_X
is_prime: BOOLEAN
op1: READABLE_INTEGER_X
done: BOOLEAN
ln2: NATURAL_32
q: NATURAL_32
p1: CELL [NATURAL_32]
p0: CELL [NATURAL_32]
p: NATURAL_32
primes: SPECIAL [NATURAL_32]
nprimes: INTEGER
do
create p1.put (0)
create p0.put (0)
create primes.make_filled (0, 15)
op1 := op1_a
create n2
if cmp_ui (op1, 1_000_000) <= 0 then
if cmpabs_ui (op1, 1_000_000) <= 0 then
is_prime := probab_prime_isprime (op1.as_natural_32)
if is_prime then
Result := 2
else
Result := 0
end
done := True
else
n2.item := op1.item
n2.count := -op1.count
op1 := n2
end
end
if not done then
if not op1.as_natural_32.bit_test (0) then
done := True
end
end
if not done then
r := preinv_mod_1 (op1.item, 0, op1.count, pp, pp_inverted)
if r \\ 3 = 0 or r \\ 5 = 0 or r \\ 7 = 0 or r \\ 11 = 0 or r \\ 13 = 0 or r \\ 17 = 0 or r \\ 19 = 0 or r \\ 23 = 0 or r \\ 29 = 0 then
Result := 0
done := True
end
end
if not done then
nprimes := 0
p := 1
ln2 := sizeinbase (op1, 2).to_natural_32
from
q := pp_first_omitted.to_natural_32
until
q >= ln2 or done
loop
if probab_prime_isprime (q) then
umul_ppmm (p1, p0, p, q)
if p1.item /= 0 then
r := modexact_1c_odd (op1.item, 0, op1.count, p, 0)
from
nprimes := nprimes - 1
until
nprimes < 0 or done
loop
if r \\ primes [nprimes] = 0 then
Result := 0
done := True
end
nprimes := nprimes - 1
end
p := q
nprimes := 0
else
p := p0.item
end
primes [nprimes] := q
nprimes := nprimes + 1
end
q := q + 2
end
end
if not done then
Result := millerrabin (op1, reps)
end
end
pp: NATURAL_32 = 0xC0CFD797
pp_inverted: NATURAL_32 = 0x53E5645C
pp_first_omitted: INTEGER = 31
reduce (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; ap: SPECIAL [NATURAL_32]; ap_offset: INTEGER; ap_count: INTEGER; mp: SPECIAL [NATURAL_32]; mp_offset: INTEGER; mp_count: INTEGER)
local
tmp: SPECIAL [NATURAL_32]
do
create tmp.make_filled (0, ap_count - mp_count + 1)
tdiv_qr_special (tmp, 0, target, target_offset, ap, ap_offset, ap_count, mp, mp_offset, mp_count)
end
muldiv (target: READABLE_INTEGER_X; inc: INTEGER_32; rsize: CELL [INTEGER_32]; ralloc: CELL [INTEGER_32]; nacc: CELL [NATURAL_32]; kacc: CELL [NATURAL_32])
local
new_ralloc: INTEGER_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
if rsize.item <= ralloc.item then
new_ralloc := ralloc.item + inc
target.resize (new_ralloc)
ralloc.put (new_ralloc)
end
mul_1 (target.item, 0, target.item, 0, rsize.item, nacc.item, carry)
target.item [rsize.item] := carry.item
divexact_1 (target.item, 0, target.item, 0, rsize.item + 1, kacc.item)
if target.item [rsize.item] /= 0 then
rsize.put (rsize.item + 1)
end
end
invert_gf (target: READABLE_INTEGER_X op1: READABLE_INTEGER_X op2: READABLE_INTEGER_X)
require
not op1.is_negative
not op2.is_negative
local
target_special: SPECIAL [NATURAL_32]
op2_count: INTEGER
do
target.resize (op2.count)
op2_count := op2.count
target_special := target.item
invert_gf_special (target_special, 0, op1.item, 0, op1.count, op2.item, 0, op2_count)
target.count := normalize (target_special, 0, op2_count)
end
end

View File

@@ -0,0 +1,108 @@
note
description: "Summary description for {INTEGER_X_RANDOM}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Letting lawyers make laws is like letting doctors make diseases. - Anonymous"
deferred class
INTEGER_X_RANDOM
inherit
INTEGER_X_FACILITIES
LIMB_MANIPULATION
SPECIAL_COMPARISON
SPECIAL_ARITHMETIC
SPECIAL_UTILITY
feature
urandomb (target: READABLE_INTEGER_X; state: RANDOM_NUMBER_GENERATOR; nbits: INTEGER)
-- Generate a uniformly distributed random integer in the range 0 to 2^`n'-1, inclusive.
-- `state' must be initialized by calling one of the randinit functions before invoking this function.
local
size: INTEGER_32
do
size := bits_to_limbs (nbits)
target.resize (size)
state.randget (target.item, 0, nbits)
size := normalize (target.item, 0, size)
target.count := size
ensure
target.bits <= nbits
end
urandomm (target: READABLE_INTEGER_X; state: RANDOM_NUMBER_GENERATOR; n: READABLE_INTEGER_X)
-- Generate a uniform random integer in the range 0 to n-1, inclusive.
-- `state' must be initialized by calling one of the randinit functions before invoking this function.
local
rp: SPECIAL [NATURAL_32]
rp_offset: INTEGER
np: SPECIAL [NATURAL_32]
np_offset: INTEGER
nlast: INTEGER
nbits: INTEGER
size: INTEGER
count: INTEGER
pow2: BOOLEAN
cmp_l: INTEGER
overlap: BOOLEAN
junk: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
size := n.count.abs
if size = 0 then
(create {DIVIDE_BY_ZERO}).raise
end
np := n.item
nlast := size - 1
pow2 := pow2_p (n.item [nlast])
if pow2 then
from
np := n.item
until
not pow2 or np_offset >= nlast
loop
if np [np_offset] /= 0 then
pow2 := False
end
np_offset := np_offset + 1
end
end
count := leading_zeros (np [nlast])
nbits := size * limb_bits - (count) - pow2.to_integer
if nbits = 0 then
target.count := 0
else
np := n.item
np_offset := 0
rp := target.item
rp_offset := 0
if np = rp then
overlap := True
create np.make_filled (0, size)
np.copy_data (n.item, 0, 0, size)
end
target.resize (size)
rp := target.item
rp [rp_offset + size - 1] := 0
count := 80
from
cmp_l := 0
until
cmp_l < 0 or count = 0
loop
state.randget (rp, rp_offset, nbits)
cmp_l := cmp (rp, rp_offset, np, np_offset, size)
count := count - 1
end
if count = 0 then
sub_n (rp, rp_offset, rp, rp_offset, np, np_offset, size, carry)
junk := carry.item
end
size := normalize (rp, rp_offset, size)
target.count := size
end
end
end

View File

@@ -0,0 +1,49 @@
note
description: "Summary description for {INTEGER_X_SIZING}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "My freedom is more important than your great idea. - Anonymous"
deferred class
INTEGER_X_SIZING
inherit
INTEGER_X_FACILITIES
LIMB_BIT_SCANNING
LIMB_MANIPULATION
MP_BASES
feature
sizeinbase (op: READABLE_INTEGER_X; base: INTEGER): INTEGER_32
-- Return the size of `op' measured in number of digits in the given base.
-- `base' can vary from 2 to 62.
-- The sign of `op' is ignored, just the absolute value is used.
-- The result will be either exact or 1 too big.
-- If `base' is a power of 2, the result is always exact.
-- If `op' is zero the return value is always 1.
-- This function can be used to determine the space required when converting `op' to a string.
-- The right amount of allocation is normally two more than the value returned, one extra for
-- a minus sign and one for the null-terminator.
-- It will be noted that `sizeinbase(op,2)' can be used to locate the most significant 1
-- bit in `op', counting from 1. (Unlike the bitwise functions which start from 0.
local
lb_base: NATURAL_32
cnt: INTEGER_32
totbits: INTEGER_32
do
if op.count.abs = 0 then
Result := 1
else
cnt := leading_zeros (op.item [op.count.abs - 1])
totbits := op.count.abs * limb_bits - cnt
if pow2_p (base.to_natural_32) then
lb_base := big_base (base)
Result := (totbits + lb_base.to_integer_32 - 1) // lb_base.to_integer_32
else
Result := ((totbits.to_double * chars_per_bit_exactly (base)) + 1).truncated_to_integer
end
end
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
note
description: "Summary description for {POWERS}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Giving a politician access to your wallet is like giving a dog access to your refrigerator. - Tim Barber"
class
POWERS
create
make
feature
make (digits_in_base_a: INTEGER; p_a: SPECIAL [NATURAL_32]; p_offset_a: INTEGER; n_a: INTEGER; base_a: INTEGER)
do
digits_in_base := digits_in_base_a
p := p_a
p_offset := p_offset_a
n := n_a
base := base_a
end
feature
digits_in_base: INTEGER
p: SPECIAL [NATURAL_32]
p_offset: INTEGER
n: INTEGER
base: INTEGER
end

View File

@@ -0,0 +1,44 @@
note
description: "Summary description for {RAND_LC_STRUCT}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Everyone wants to save the planet but no one wants to help Mom clean the dishes. - P.J. O'Rourke, in All the Trouble in the World "
class
RAND_LC_STRUCT
inherit
INTEGER_X_DIVISION
LIMB_MANIPULATION
create
make
feature
make (m2exp_a: INTEGER; a_a: READABLE_INTEGER_X; seedn: INTEGER; c: NATURAL_32)
do
create cp.make_filled (0, 1)
m2exp := m2exp_a
create seed.make_limbs (bits_to_limbs (m2exp))
seed.count := seedn
seed.item [0] := 1
create a
fdiv_r_2exp (a, a_a, m2exp)
if a.count = 0 then
a.count := 1
a.item [0] := 0
end
cp [0] := c
cn := (c /= 0).to_integer
end
feature
seed: INTEGER_X
a: INTEGER_X
cn: INTEGER
cp: SPECIAL [NATURAL_32]
m2exp: INTEGER
end

View File

@@ -0,0 +1,262 @@
note
description: "Summary description for {NUMBER_ACCESS}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "State-mandated compassion produces, not love for ones fellow man, but hatred and resentment. - Lizard"
deferred class
SPECIAL_ACCESS
inherit
LIMB_MANIPULATION
MP_BASES
SPECIAL_ARITHMETIC
SPECIAL_DIVISION
feature
dc_get_str (target_a: STRING_8; target_offset_a: INTEGER; len_a: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; powtab: SPECIAL [POWERS]; powtab_offset: INTEGER; tmp: SPECIAL [NATURAL_32]; tmp_offset: INTEGER): INTEGER
local
target: STRING_8
len: INTEGER
pwp: SPECIAL [NATURAL_32]
pwp_offset: INTEGER
qp: SPECIAL [NATURAL_32]
qp_offset: INTEGER
rp: SPECIAL [NATURAL_32]
rp_offset: INTEGER
pwn: INTEGER
qn: INTEGER
target_offset: INTEGER
do
target := target_a
len := len_a
target_offset := target_offset_a
if op1_count < 15 then
if op1_count /= 0 then
target_offset := sb_get_str (target, target_offset, len, op1, op1_offset, op1_count, powtab, powtab_offset)
else
from
until
len /= 0
loop
target [target_offset] := '%U'
target_offset := target_offset + 1
len := len - 1
end
end
else
pwp := powtab [powtab_offset].p
pwn := powtab [powtab_offset].n
if op1_count < pwn or (op1_count = pwn and cmp (op1, op1_offset, pwp, pwp_offset, op1_count) < 0) then
target_offset := dc_get_str (target, target_offset, len, op1, op1_offset, op1_count, powtab, powtab_offset - 1, tmp, tmp_offset)
else
qp := tmp
qp_offset := tmp_offset
rp := op1
rp_offset := op1_offset
tdiv_qr (qp, qp_offset, rp, rp_offset, op1, op1_offset, op1_count, pwp, pwp_offset, pwn)
qn := op1_count - pwn
qn := qn + (qp [qp_offset + qn] /= 0).to_integer
if len /= 0 then
len := len - powtab [powtab_offset].digits_in_base
end
target_offset := dc_get_str (target, target_offset, len, qp, qp_offset, qn, powtab, powtab_offset - 1, tmp, tmp_offset + op1_count - pwn + 1)
target_offset := dc_get_str (target, target_offset, powtab [powtab_offset].digits_in_base, rp, rp_offset, pwn, powtab, powtab_offset - 1, tmp, tmp_offset)
end
end
Result := target_offset
end
get_str (target: STRING_8; target_offset: INTEGER; base: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER): INTEGER
local
powtab_mem_ptr: SPECIAL [NATURAL_32]
powtab_mem_ptr_offset: INTEGER
big_base_l: NATURAL_32
digits_in_base: INTEGER
powtab: SPECIAL [POWERS]
pi: INTEGER
n: INTEGER
t: INTEGER
p: SPECIAL [NATURAL_32]
p_offset: INTEGER
n1: NATURAL_32
n0: NATURAL_32
bits_per_digit: INTEGER
count: INTEGER
bit_pos: INTEGER
i: INTEGER
s: INTEGER
bits: INTEGER
do
if op1_count = 0 then
target [target_offset] := '%U'
Result := 1
else
if pow2_p (base.to_natural_32) then
bits_per_digit := big_base (base).to_integer_32
s := target_offset
n1 := op1 [op1_offset + op1_count - 1]
count := leading_zeros (n1)
bits := limb_bits * op1_count - count
count := bits \\ bits_per_digit
if count /= 0 then
bits := bits + bits_per_digit - count
end
bit_pos := bits - (op1_count - 1) * limb_bits
from
i := op1_count - 1
until
i < 0
loop
bit_pos := bit_pos - bits_per_digit
from
until
bit_pos < 0
loop
target [s] := ((n1 |>> bit_pos).bit_and (((1).to_natural_32 |<< bits_per_digit) - 1)).to_character_8
s := s + 1
bit_pos := bit_pos - bits_per_digit
end
i := i - 1
if i >= 0 then
n0 := (n1 |<< -bit_pos).bit_and (((1).to_natural_32 |<< bits_per_digit) - 1)
n1 := op1 [op1_offset + i]
bit_pos := bit_pos + limb_bits
target [s] := (n0.bit_or (n1 |>> bit_pos)).to_character_8
s := s + 1
end
end
Result := s - target_offset
else
if op1_count < 30 then
create powtab.make_empty (1)
create p.make_empty (0)
powtab.extend (create {POWERS}.make (0, p, 0, 0, base))
Result := sb_get_str (target, target_offset, 0, op1, op1_offset, op1_count, powtab, 0)
else
create powtab_mem_ptr.make_filled (0, 2 * op1_count + 30)
big_base_l := big_base (base)
digits_in_base := chars_per_limb (base)
create powtab.make_empty (30)
create p.make_filled (0, 0)
powtab.extend (create {POWERS}.make (0, p, 0, 0, base))
create p.make_filled (big_base_l, 1)
powtab.extend (create {POWERS}.make (digits_in_base, p, 0, 1, base))
create p.make_filled (big_base_l, 1)
powtab.extend (create {POWERS}.make (digits_in_base, p, 0, 1, base))
n := 1
pi := 2
create p.make_filled (big_base_l, 1)
p_offset := 0
from
until
2 * n > op1_count
loop
pi := pi + 1
t := powtab_mem_ptr_offset
powtab_mem_ptr_offset := powtab_mem_ptr_offset + 2 * n
sqr_n (powtab_mem_ptr, t, p, p_offset, n)
n := n * 2
n := n - (powtab_mem_ptr [t + n - 1] = 0).to_integer
digits_in_base := digits_in_base * 2
powtab_mem_ptr_offset := t
powtab.extend (create {POWERS}.make (digits_in_base, p, 0, n, base))
end
end
end
end
end
sb_get_str (target: STRING_8; target_offset_a: INTEGER; len_a: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count_a: INTEGER; powtab: SPECIAL [POWERS]; powtab_offset: INTEGER): INTEGER
local
rl: CELL [NATURAL_32]
ul: CELL [NATURAL_32]
s: INTEGER
base: INTEGER
l: INTEGER
buf: SPECIAL [NATURAL_8]
buf_offset: INTEGER
rp: SPECIAL [NATURAL_32]
rp_offset: INTEGER
buff_alloc: INTEGER
op1_count: INTEGER
i: INTEGER
frac: CELL [NATURAL_32]
digit: CELL [NATURAL_32]
junk: NATURAL_32
chars_per_limb_l: INTEGER
big_base_l: NATURAL_32
big_base_inverted_l: NATURAL_32
normalization_steps: INTEGER
target_offset: INTEGER
len: INTEGER
do
create digit.put (0)
create frac.put (0)
create ul.put (0)
create rl.put (0)
len := len_a
target_offset := target_offset_a
op1_count := op1_count_a
buff_alloc := 30 * 8 * 4 * 7 // 11
create buf.make_filled (0, buff_alloc)
create rp.make_filled (0, 30)
base := powtab [powtab_offset].base
chars_per_limb_l := chars_per_limb (base)
big_base_l := big_base (base)
big_base_inverted_l := big_base_inverted (base)
normalization_steps := leading_zeros (big_base_l)
rp.copy_data (op1, op1_offset, rp_offset + 1, op1_count)
s := buf_offset + buff_alloc
from
until
op1_count <= 1
loop
junk := preinv_divrem_1 (rp, rp_offset, 1, rp, rp_offset + 1, op1_count, big_base_l, big_base_inverted_l, normalization_steps)
op1_count := op1_count - (rp [rp_offset + op1_count] = 0).to_integer
frac.put (rp [rp_offset] + 1)
s := s - chars_per_limb_l
i := chars_per_limb_l
from
until
i = 0
loop
umul_ppmm (digit, frac, frac.item, base.to_natural_32)
buf [s] := digit.item.to_natural_8
s := s + 1
i := i - 1
end
s := s - chars_per_limb_l
end
ul.put (rp [rp_offset + 1])
from
until
ul.item = 0
loop
udiv_qrnd_unnorm (ul, rl, ul.item, base.to_natural_32)
s := s - 1
buf [s] := rl.item.to_natural_8
end
l := buf_offset + buff_alloc - s
from
until
l >= len
loop
target [target_offset] := '%U'
target_offset := target_offset + 1
len := len - 1
end
from
until
l = 0
loop
target [target_offset] := buf [s].to_character_8
s := s + 1
target_offset := target_offset + 1
l := l - 1
end
Result := target_offset - target_offset_a
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,159 @@
note
description: "Summary description for {NUMBER_ASSIGNMENT}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Concentrated political power is the most dangerous thing on earth. - Rudolph Rummel"
deferred class
SPECIAL_ASSIGNMENT
inherit
MP_BASES
LIMB_MANIPULATION
SPECIAL_ARITHMETIC
feature
set_str (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; str: SPECIAL [NATURAL_8]; str_offset_a: INTEGER; str_len: INTEGER; base: INTEGER): INTEGER
require
base >= 2
-- str_len >= 1
local
str_offset: INTEGER
size: INTEGER
big_base_l: NATURAL_32
chars_per_limb_l: INTEGER
res_digit: NATURAL_32
s: INTEGER
next_bitpos: INTEGER
bits_per_indigit: INTEGER
inp_digit: NATURAL_8
i: INTEGER
j: INTEGER
cy_limb: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
str_offset := str_offset_a
big_base_l := big_base (base)
chars_per_limb_l := chars_per_limb (base)
size := 0
if pow2_p (base.to_natural_32) then
bits_per_indigit := big_base_l.to_integer_32
res_digit := 0
next_bitpos := 0
from
s := str_offset + str_len - 1
until
s < str_offset
loop
inp_digit := str [s]
res_digit := res_digit.bit_or (inp_digit.to_natural_32 |<< next_bitpos)
next_bitpos := next_bitpos + bits_per_indigit
if next_bitpos >= limb_bits then
target [target_offset + size] := res_digit
size := size + 1
next_bitpos := next_bitpos - limb_bits
res_digit := inp_digit |>> (bits_per_indigit - next_bitpos)
end
s := s - 1
end
if res_digit /= 0 then
target [target_offset + size] := res_digit
size := size + 1
end
Result := size
else
if str_len < str_len.max_value then
from
i := chars_per_limb_l
until
i >= str_len
loop
res_digit := str [str_offset]
str_offset := str_offset + 1
if base = 10 then
from
j := 9 - 1
until
j = 0
loop
res_digit := res_digit * 10 + str [str_offset].to_natural_32
str_offset := str_offset + 1
j := j - 1
end
else
from
j := chars_per_limb_l - 1
until
j = 0
loop
res_digit := res_digit * base.to_natural_32 + str [str_offset].to_natural_32
str_offset := str_offset + 1
j := j - 1
end
end
if size = 0 then
if res_digit /= 0 then
target [target_offset] := res_digit
size := 1
end
else
mul_1 (target, target_offset, target, target_offset, size, big_base_l, carry)
cy_limb := carry.item
add_1 (target, target_offset, target, target_offset, size, res_digit, carry)
cy_limb := cy_limb + carry.item
if cy_limb /= 0 then
target [target_offset + size] := cy_limb
size := size + 1
end
end
i := i + chars_per_limb_l
end
big_base_l := base.to_natural_32
res_digit := str [str_offset]
str_offset := str_offset + 1
if base = 10 then
from
j := str_len - (i - 9) - 1
until
j <= 0
loop
res_digit := res_digit * 10 + str [str_offset]
str_offset := str_offset + 1
big_base_l := big_base_l * 10
j := j - 1
end
else
from
j := str_len - (i - chars_per_limb_l) - 1
until
j <= 0
loop
res_digit := res_digit * base.to_natural_32 + str [str_offset].to_natural_32
str_offset := str_offset + 1
big_base_l := big_base_l * base.to_natural_32
j := j - 1
end
end
if size = 0 then
if res_digit /= 0 then
target [target_offset] := res_digit
size := 1
end
else
mul_1 (target, target_offset, target, target_offset, size, big_base_l, carry)
cy_limb := carry.item
add_1 (target, target_offset, target, target_offset, size, res_digit, carry)
cy_limb := cy_limb + carry.item
if cy_limb /= 0 then
target [target_offset + size] := cy_limb
size := size + 1
end
end
Result := size
end
end
end
end

View File

@@ -0,0 +1,39 @@
note
description: "Summary description for {NUMBER_COMPARISON}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "No nation was ever ruined by trade. - Benjamin Franklin"
deferred class
SPECIAL_COMPARISON
feature
cmp (op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER; size: INTEGER): INTEGER
local
i: INTEGER
x: NATURAL_32
y: NATURAL_32
do
Result := 0
from
i := size - 1
until
i < 0 or Result /= 0
loop
x := op1 [op1_offset + i]
y := op2 [op2_offset + i]
if x /= y then
if x > y then
Result := 1
else
Result := -1
end
end
i := i - 1
variant
i + 2
end
end
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,332 @@
note
description: "Summary description for {NUMBER_LOGIC}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "It is a free market that makes monopolies impossible. - Ayn Rand"
deferred class
SPECIAL_LOGIC
inherit
LIMB_MANIPULATION
feature
com_n (target: SPECIAL [NATURAL_32]; target_offset_a: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER; op1_count_a: INTEGER)
require
op1_count_a >= 1
local
target_offset: INTEGER
op1_offset: INTEGER
op1_count: INTEGER
do
target_offset := target_offset_a
op1_offset := op1_offset_a
op1_count := op1_count_a
from
until
op1_count = 0
loop
target [target_offset] := op1 [op1_offset].bit_not
target_offset := target_offset + 1
op1_offset := op1_offset + 1
op1_count := op1_count - 1
end
end
hamdist (op1: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset_a: INTEGER; n_a: INTEGER): INTEGER
local
p0: NATURAL_32
p1: NATURAL_32
p2: NATURAL_32
p3: NATURAL_32
x: NATURAL_32
p01: NATURAL_32
p23: NATURAL_32
i: INTEGER
op1_offset: INTEGER
n: INTEGER
op2_offset: INTEGER
do
op2_offset := op2_offset_a
n := n_a
op1_offset := op1_offset_a
from
i := n |>> 2
until
i = 0
loop
p0 := op1 [op1_offset].bit_xor (op2 [op2_offset])
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
p1 := op1 [op1_offset + 1].bit_xor (op2 [op2_offset + 1])
p1 := p1 - (p1 |>> 1).bit_and (limb_max // 3)
p1 := (p1 |>> 2).bit_and (limb_max // 5) + p1.bit_and (limb_max // 5)
p01 := p0 + p1
p01 := (p01 |>> 4).bit_and (limb_max // 17) + p01.bit_and (limb_max // 17)
p2 := op1 [op1_offset + 2].bit_xor (op2 [op2_offset + 2])
p2 := p2 - (p2 |>> 1).bit_and (limb_max // 3)
p2 := (p2 |>> 2).bit_and (limb_max // 5) + p2.bit_and (limb_max // 5)
p3 := op1 [op1_offset + 3].bit_xor (op2 [op2_offset + 3])
p3 := p3 - (p3 |>> 1).bit_and (limb_max // 3)
p3 := (p3 |>> 2).bit_and (limb_max // 5) + p3.bit_and (limb_max // 5)
p23 := p2 + p3
p23 := (p23 |>> 4).bit_and (limb_max // 17) + p23.bit_and (limb_max // 17)
x := p01 + p23
x := (x |>> 8) + x
x := (x |>> 16) + x
Result := Result + x.bit_and (0xff).to_integer_32
op1_offset := op1_offset + 4
op2_offset := op2_offset + 4
i := i - 1
end
n := n.bit_and (3)
if n /= 0 then
x := 0
from
until
n = 0
loop
p0 := op1 [op1_offset].bit_xor (op2 [op2_offset])
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
p0 := ((p0 |>> 4) | p0).bit_and (limb_max // 17)
x := x + p0
op1_offset := op1_offset + 1
op2_offset := op2_offset + 1
n := n - 1
end
x := (x |>> 8) + x
x := (x |>> 16) + x
Result := Result + x.bit_and (0xff).to_integer_32
end
end
lshift (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER_32; n: INTEGER_32; count: INTEGER_32; carry: CELL [NATURAL_32])
require
target.valid_index (target_offset)
target.valid_index (target_offset + n - 1)
op1.valid_index (op1_offset)
op1.valid_index (op1_offset + n - 1)
count > 0
count < 32
local
high_limb: NATURAL_32
low_limb: NATURAL_32
tnc: INTEGER_32
i: INTEGER_32
up: INTEGER_32
rp: INTEGER_32
do
up := op1_offset + n
rp := target_offset + n
tnc := 32 - count
up := up - 1
low_limb := op1 [up]
carry.put (low_limb |>> tnc)
high_limb := low_limb |<< count
from
i := n - 1
until
i = 0
loop
up := up - 1
low_limb := op1 [up]
rp := rp - 1
target [rp] := high_limb.bit_or (low_limb |>> tnc)
high_limb := low_limb |<< count
i := i - 1
end
rp := rp - 1
target [rp] := high_limb
end
rshift (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER_32; n: INTEGER_32; count: INTEGER_32; carry: CELL [NATURAL_32])
local
high_limb: NATURAL_32
low_limb: NATURAL_32
tnc: INTEGER_32
i: INTEGER_32
op1_cursor: INTEGER_32
target_cursor: INTEGER_32
do
tnc := 32 - count
op1_cursor := op1_offset
high_limb := op1 [op1_cursor]
op1_cursor := op1_cursor + 1
carry.put (high_limb |<< tnc)
low_limb := high_limb |>> count
from
i := n - 1
until
i = 0
loop
high_limb := op1 [op1_cursor]
op1_cursor := op1_cursor + 1
target [target_cursor] := low_limb.bit_or (high_limb |<< tnc)
target_cursor := target_cursor + 1
low_limb := high_limb |>> count
i := i - 1
end
target [target_cursor] := low_limb
end
popcount (op1: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER; n_a: INTEGER): INTEGER
local
p0: NATURAL_32
p1: NATURAL_32
p2: NATURAL_32
p3: NATURAL_32
x: NATURAL_32
p01: NATURAL_32
p23: NATURAL_32
i: INTEGER
op1_offset: INTEGER
n: INTEGER
do
n := n_a
op1_offset := op1_offset_a
from
i := n |>> 2
until
i = 0
loop
p0 := op1 [op1_offset]
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
p1 := op1 [op1_offset + 1]
p1 := p1 - (p1 |>> 1).bit_and (limb_max // 3)
p1 := (p1 |>> 2).bit_and (limb_max // 5) + p1.bit_and (limb_max // 5)
p01 := p0 + p1
p01 := (p01 |>> 4).bit_and (limb_max // 17) + p01.bit_and (limb_max // 17)
p2 := op1 [op1_offset + 2]
p2 := p2 - (p2 |>> 1).bit_and (limb_max // 3)
p2 := (p2 |>> 2).bit_and (limb_max // 5) + p2.bit_and (limb_max // 5)
p3 := op1 [op1_offset + 3]
p3 := p3 - (p3 |>> 1).bit_and (limb_max // 3)
p3 := (p3 |>> 2).bit_and (limb_max // 5) + p3.bit_and (limb_max // 5)
p23 := p2 + p3
p23 := (p23 |>> 4).bit_and (limb_max // 17) + p23.bit_and (limb_max // 17)
x := p01 + p23
x := (x |>> 8) + x
x := (x |>> 16) + x
Result := Result + x.bit_and (0xff).to_integer_32
op1_offset := op1_offset + 4
i := i - 1
end
n := n.bit_and (3)
if n /= 0 then
x := 0
from
until
n = 0
loop
p0 := op1 [op1_offset]
p0 := p0 - (p0 |>> 1).bit_and (limb_max // 3)
p0 := (p0 |>> 2).bit_and (limb_max // 5) + p0.bit_and (limb_max // 5)
p0 := ((p0 |>> 4) | p0).bit_and (limb_max // 17)
x := x + p0
op1_offset := op1_offset + 1
n := n - 1
end
x := (x |>> 8) + x
x := (x |>> 16) + x
Result := Result + x.bit_and (0xff).to_integer_32
end
end
bit_xor_lshift (target: SPECIAL [NATURAL_32] target_offset: INTEGER op1: SPECIAL [NATURAL_32] op1_offset: INTEGER op1_count: INTEGER op2: SPECIAL [NATURAL_32] op2_offset: INTEGER op2_count: INTEGER op2_lshift: INTEGER)
require
op2_lshift >= 0
op1 /= op2
target /= op2
op1_count = 0 or op1.valid_index (op1_offset)
op1_count = 0 or op1.valid_index (op1_offset + op1_count - 1)
op2_count = 0 or op2.valid_index (op2_offset)
op2_count = 0 or op2.valid_index (op2_offset + op2_count - 1)
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset)
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset + op1_count.max (op2_count + bits_to_limbs (op2_lshift)) - 1)
local
op2_limb_high: NATURAL_32
op2_limb_low: NATURAL_32
op2_limb: NATURAL_32
cursor: INTEGER
shift_limbs: INTEGER
shift_bits: INTEGER
do
shift_limbs := op2_lshift // limb_bits
shift_bits := op2_lshift \\ limb_bits
target.copy_data (op1, op1_offset, target_offset, shift_limbs)
from
until
cursor >= op2_count or cursor >= op1_count - shift_limbs
loop
op2_limb_low := op2_limb_high
op2_limb_high := op2 [op2_offset + cursor]
op2_limb := extract_limb (shift_bits, op2_limb_high, op2_limb_low)
target [target_offset + shift_limbs + cursor] := op2_limb.bit_xor (op1 [op1_offset + shift_limbs + cursor])
cursor := cursor + 1
end
if cursor >= op2_count then
op2_limb_low := op2_limb_high
op2_limb := extract_limb (shift_bits, 0, op2_limb_low)
if cursor >= op1_count - shift_limbs then
target [target_offset + shift_limbs + cursor] := op2_limb
else
target [target_offset + shift_limbs + cursor] := op2_limb.bit_xor (op1 [op1_offset + shift_limbs + cursor])
cursor := cursor + 1
target.copy_data (op1, op1_offset + shift_limbs + cursor, target_offset + shift_limbs + cursor, op1_count - cursor - shift_limbs)
end
else
from
until
cursor >= op2_count
loop
op2_limb_low := op2_limb_high
op2_limb_high := op2 [op2_offset + cursor]
op2_limb := extract_limb (shift_bits, op2_limb_high, op2_limb_low)
target [target_offset + shift_limbs + cursor] := op2_limb
cursor := cursor + 1
end
op2_limb_low := op2_limb_high
op2_limb := extract_limb (shift_bits, 0, op2_limb_low)
target [target_offset + shift_limbs + cursor] := op2_limb
end
end
bit_xor (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER; op2_count: INTEGER)
require
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset)
(op1_count = 0 and op2_count = 0) or target.valid_index (target_offset + op1_count.max (op2_count) - 1)
local
cursor: INTEGER
min: INTEGER
do
from
min := op1_count.min (op2_count)
until
cursor >= min
loop
target [target_offset + cursor] := op1 [op1_offset + cursor].bit_xor (op2 [op2_offset + cursor])
cursor := cursor + 1
end
if op1_count > op2_count then
target.copy_data (op1, op1_offset + cursor, target_offset + cursor, op1_count - cursor)
elseif op2_count > op1_count then
target.copy_data (op2, op2_offset + cursor, target_offset + cursor, op2_count - cursor)
end
end
end

View File

@@ -0,0 +1,849 @@
note
description: "Summary description for {NUMBER_NUMBER_THEORETIC}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "The best argument against democracy is a five-minute conversation with the average voter. - Winston Churchill"
deferred class
SPECIAL_NUMBER_THEORETIC
inherit
SPECIAL_DIVISION
SPECIAL_UTILITY
SPECIAL_LOGIC
LIMB_MANIPULATION
feature
gcdext_div2 (n1_a: NATURAL_32; n0_a: NATURAL_32; d1_a: NATURAL_32; d0_a: NATURAL_32): NATURAL_32
require
d1_a /= 0 or d0_a /= 0
local
q: NATURAL_32
count: INTEGER
d1: NATURAL_32
d0: NATURAL_32
n1: CELL [NATURAL_32]
n0: CELL [NATURAL_32]
do
create n1.put (n1_a)
create n0.put (n0_a)
d1 := d1_a
d0 := d0_a
if n1.item.bit_test (limb_high_bit) then
from
count := 1
invariant
d1 /= 0 or d0 /= 0
until
d1.bit_test (limb_high_bit)
loop
d1 := (d1 |<< 1).bit_or (d0 |>> (limb_bits - 1))
d0 := d0 |<< 1
count := count + 1
end
q := 0
from
until
count = 0
loop
q := q |<< 1
if n1.item > d1 or (n1.item = d1 and n0.item >= d0) then
sub_ddmmss (n1, n0, n1.item, n0.item, d1, d0)
q := q.bit_or (1)
end
d0 := (d1 |<< (limb_bits - 1)).bit_or (d0 |>> 1)
d1 := d1 |>> 1
count := count - 1
end
Result := q
else
from
count := 0
until
n1.item <= d1 and (n1.item /= d1 or n0.item < d0)
loop
d1 := (d1 |<< 1).bit_or (d0 |>> (limb_bits - 1))
d0 := d0 |<< 1
count := count + 1
end
q := 0
from
until
count = 0
loop
d0 := (d1 |<< (limb_bits - 1)).bit_or (d0 |>> 1)
d1 := d1 |>> 1
q := q |<< 1
if n1.item > d1 or (n1.item = d1 and n0.item >= d0) then
sub_ddmmss (n1, n0, n1.item, n0.item, d1, d0)
q := q.bit_or (1)
end
count := count - 1
end
Result := q
end
end
basic_gcdext (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; cofactor: SPECIAL [NATURAL_32]; cofactor_offset: INTEGER_32; cofactor_count: TUPLE [cofactor_count: INTEGER_32]; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER_32; op1_count: INTEGER_32; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER_32; op2_count: INTEGER_32): INTEGER
require
op1_count >= op2_count
target.valid_index (target_offset)
target.valid_index (target_offset + op1_count - 1)
cofactor.valid_index (cofactor_offset)
cofactor.valid_index (cofactor_offset + op1_count - 1)
op1.valid_index (op1_offset)
op1.valid_index (op1_offset + op1_count - 0)
op1 [op1_offset + op1_count - 1] /= 0
op2.valid_index (op2_offset)
op2.valid_index (op2_offset + op2_count - 0)
op2 [op2_offset + op2_count - 1] /= 0
op2_count >= 1
local
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER_32
s1p: SPECIAL [NATURAL_32]
s1p_offset: INTEGER
do
create tp.make_filled (0, op1_count + 1)
tp_offset := 0
create s1p.make_filled (0, op1_count + 1)
s1p_offset := 0
cofactor.fill_with (0, cofactor_offset, cofactor_offset + op1_count - 1)
s1p.fill_with (0, s1p_offset, s1p_offset + op1_count - 1)
cofactor [cofactor_offset] := 1
s1p [s1p_offset] := 0
if op1_count > op2_count then
tdiv_qr (tp, tp_offset, op1, op1_offset, op1, op1_offset, op1_count, op2, op2_offset, op2_count)
cofactor [cofactor_offset] := 0
s1p [s1p_offset] := 1
Result := basic_gcdext_arranged (target, target_offset, cofactor, cofactor_offset, cofactor_count, op2, op2_offset, op2_count, op1, op1_offset, op1_count, -1, s1p, s1p_offset, tp, tp_offset)
else
Result := basic_gcdext_arranged (target, target_offset, cofactor, cofactor_offset, cofactor_count, op1, op1_offset, op1_count, op2, op2_offset, op2_count, 1, s1p, s1p_offset, tp, tp_offset)
end
end
basic_gcdext_arranged (target: SPECIAL [NATURAL_32]; target_offset: INTEGER_32; cofactor_a: SPECIAL [NATURAL_32]; cofactor_offset_a: INTEGER_32; cofactor_count: TUPLE [cofactor_count: INTEGER_32]; op1_a: SPECIAL [NATURAL_32]; op1_offset_a: INTEGER_32; op1_count_a: INTEGER_32; op2_a: SPECIAL [NATURAL_32]; op2_offset_a: INTEGER_32; op2_count_a: INTEGER_32; sign_a: INTEGER; s1p_a: SPECIAL [NATURAL_32]; s1p_offset_a: INTEGER; tp_a: SPECIAL [NATURAL_32]; tp_offset_a: INTEGER): INTEGER
local
a: NATURAL_32
b: NATURAL_32
c: NATURAL_32
d: NATURAL_32
wp: SPECIAL [NATURAL_32]
wp_offset: INTEGER_32
orig_s0p: SPECIAL [NATURAL_32]
orig_s0p_offset: INTEGER
use_double_flag: BOOLEAN
cnt: INTEGER_32
assign_l: NATURAL_32
op2_count: INTEGER
done: BOOLEAN
done_2: BOOLEAN
uh: NATURAL_32
vh: NATURAL_32
ul: NATURAL_32
vl: NATURAL_32
tac: NATURAL_32
tbd: NATURAL_32
q1: NATURAL_32
q2: NATURAL_32
nh: CELL [NATURAL_32]
nl: CELL [NATURAL_32]
dh: CELL [NATURAL_32]
dl: CELL [NATURAL_32]
t1: CELL [NATURAL_32]
t0: CELL [NATURAL_32]
thigh: CELL [NATURAL_32]
tlow: CELL [NATURAL_32]
sign: INTEGER
q: NATURAL_32
t: NATURAL_32
ssize: INTEGER_32
qsize: INTEGER_32
i: INTEGER_32
cy: NATURAL_32
cofactor: SPECIAL [NATURAL_32]
cofactor_offset: INTEGER_32
op1: SPECIAL [NATURAL_32]
op1_offset: INTEGER_32
op2: SPECIAL [NATURAL_32]
op2_offset: INTEGER_32
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER_32
s1p: SPECIAL [NATURAL_32]
s1p_offset: INTEGER_32
temp_special: SPECIAL [NATURAL_32]
temp_integer: INTEGER_32
op1_count: INTEGER
tsize: INTEGER
wsize: INTEGER
junk: NATURAL_32
cy1: NATURAL_32
cy2: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
cofactor := cofactor_a
cofactor_offset := cofactor_offset_a
op1 := op1_a
op1_offset := op1_offset_a
op1_count := op1_count_a
op2 := op2_a
op2_offset := op2_offset_a
tp := tp_a
tp_offset := tp_offset_a
s1p := s1p_a
s1p_offset := s1p_offset_a
ssize := 1
sign := sign_a
op2_count := op2_count_a
orig_s0p := cofactor
orig_s0p_offset := cofactor_offset
create wp.make_filled (0, op1_count + 1)
wp_offset := 0
use_double_flag := op1_count > 17
from
until
done
loop
op2_count := op1_count
op2_count := normalize (op2, op2_offset, op2_count)
if op2_count <= 1 then
done := True
else
if use_double_flag then
uh := op1 [op1_count - 1]
vh := op2 [op1_count - 1]
ul := op1 [op1_count - 2]
vl := op2 [op1_count - 2]
cnt := leading_zeros (uh)
if cnt /= 0 then
uh := (uh |<< cnt).bit_or (ul |>> (32 - cnt))
vh := (vh |<< cnt).bit_or (vl |>> (32 - cnt))
vl := vl |<< cnt
ul := ul |<< cnt
if op1_count >= 3 then
ul := ul.bit_or (op1 [op1_offset + op1_count - 3] |>> (32 - cnt))
vl := vl.bit_or (op2 [op2_offset + op1_count - 3] |>> (32 - cnt))
end
end
a := 1
b := 0
c := 0
d := 1
assign_l := 0
from
done_2 := False
create nh.put (0)
create nl.put (0)
create dh.put (0)
create dl.put (0)
create thigh.put (0)
create tlow.put (0)
create t1.put (0)
create t0.put (0)
until
done_2
loop
sub_ddmmss (dh, dl, vh, vl, 0, c)
if dh.item = 0 then
done_2 := True
else
add_ssaaaa (nh, nl, uh, ul, 0, a)
q1 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
add_ssaaaa (dh, dl, vh, vl, 0, d)
if dh.item = 0 then
done_2 := True
else
sub_ddmmss (nh, nl, uh, ul, 0, b)
q2 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
if q1 /= q2 then
done_2 := True
else
tac := a + q1 * c
tbd := b + q1 * d
a := c
c := tac
b := d
d := tbd
umul_ppmm (t1, t0, q1, vl)
t1.put (t1.item + q1 * vh)
sub_ddmmss (thigh, tlow, uh, ul, t1.item, t0.item)
uh := vh
ul := vl
vh := thigh.item
vl := tlow.item
assign_l := assign_l.bit_not
add_ssaaaa (dh, dl, vh, vl, 0, c)
sub_ddmmss (nh, nl, uh, ul, 0, a)
q1 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
sub_ddmmss (dh, dl, vh, vl, 0, d)
if dh.item = 0 then
done_2 := True
else
add_ssaaaa (nh, nl, uh, ul, 0, b)
q2 := gcdext_div2 (nh.item, nl.item, dh.item, dl.item)
if q1 /= q2 then
done_2 := True
else
tac := a + q1 * c
tbd := b + q1 * d
a := c
c := tac
b := d
d := tbd
umul_ppmm (t1, t0, q1, vl)
t1.put (t1.item + (q1 * vh))
sub_ddmmss (thigh, tlow, uh, ul, t1.item, t0.item)
uh := vh
ul := vl
vh := thigh.item
vl := tlow.item
assign_l := assign_l.bit_not
end
end
end
end
end
end
if assign_l /= 0 then
sign := -sign
end
else
uh := op1 [op1_offset + op1_count - 1]
vh := op2 [op2_offset + op1_count - 1]
cnt := leading_zeros (uh)
if cnt /= 0 then
uh := (uh |<< cnt).bit_or (op1 [op1_offset + op1_count - 2] |>> (limb_bits - cnt))
vh := (vh |<< cnt).bit_or (op2 [op2_offset + op1_count - 2] |>> (limb_bits - cnt))
end
a := 1
b := 0
c := 0
d := 1
assign_l := 0
from
done_2 := False
until
done_2
loop
if vh - c = 0 or vh + d = 0 then
done_2 := True
else
q := (uh + a) // (vh - c)
if q /= (uh - b) // (vh + d) then
done_2 := True
else
t := a + q * c
a := c
c := t
t := b + q * d
b := d
d := t
t := uh - q * vh
uh := vh
vh := t
assign_l := assign_l.bit_not
if vh - d = 0 then
done_2 := True
else
q := (uh - a) // (vh + c)
if q /= (uh + b) // (vh - d) then
done_2 := True
else
t := a + q * c
a := c
c := t
t := b + q * d
b := d
d := t
t := uh - q * vh
uh := vh
vh := t
assign_l := assign_l.bit_not
end
end
end
end
end
if assign_l /= 0 then
sign := -sign
end
end
if b = 0 then
tdiv_qr (wp, wp_offset, op1, op1_offset, op1, op1_offset, op1_count, op2, op2_offset, op2_count)
tp.copy_data (cofactor, cofactor_offset, tp_offset, ssize)
qsize := op1_count - op2_count + 1
s1p.fill_with (0, s1p_offset + ssize, s1p_offset + ssize + qsize - 1)
from
i := 0
until
i >= qsize
loop
addmul_1 (tp, tp_offset + i, s1p, s1p_offset, ssize, wp [wp_offset + i], carry)
cy := carry.item
tp [tp_offset + ssize + i] := cy
i := i + 1
end
ssize := ssize + qsize
ssize := ssize - (tp [tp_offset + ssize - 1] = 0).to_integer
sign := -sign
temp_special := cofactor
temp_integer := cofactor_offset
cofactor := s1p
cofactor_offset := s1p_offset
s1p := temp_special
s1p_offset := temp_integer
temp_special := s1p
temp_integer := s1p_offset
s1p := tp
s1p_offset := tp_offset
tp := temp_special
tp_offset := temp_integer
op1_count := op2_count
temp_special := op1
temp_integer := op1_offset
op1 := op2
op1_offset := op2_offset
op2 := temp_special
op2_offset := temp_integer
else
if a = 0 then
tp.copy_data (op2, op2_offset, tp_offset, op1_count)
wp.copy_data (op1, op1_offset, wp_offset, op1_count)
submul_1 (wp, wp_offset, op2, op2_offset, op1_count, d, carry)
junk := carry.item
temp_special := tp
temp_integer := tp_offset
tp := op1
tp_offset := op1_offset
op1 := temp_special
op1_offset := temp_integer
temp_special := wp
temp_integer := wp_offset
wp := op2
wp_offset := op2_offset
op2 := temp_special
op2_offset := temp_integer
tp.copy_data (s1p, s1p_offset, tp_offset, ssize)
tsize := ssize
tp [tp_offset + ssize] := 0
wp.copy_data (cofactor, cofactor_offset, wp_offset, ssize)
addmul_1 (wp, wp_offset, s1p, s1p_offset, ssize, d, carry)
cy := carry.item
wp [wp_offset + ssize] := cy
wsize := ssize + (cy /= 0).to_integer
temp_special := tp
temp_integer := tp_offset
tp := cofactor
tp_offset := cofactor_offset
cofactor := temp_special
cofactor_offset := temp_integer
temp_special := wp
temp_integer := wp_offset
wp := s1p
wp_offset := s1p_offset
s1p := temp_special
s1p_offset := temp_integer
ssize := wsize.max (tsize)
else
if assign_l /= 0 then
mul_1 (tp, tp_offset, op2, op2_offset, op1_count, b, carry)
junk := carry.item
submul_1 (tp, tp_offset, op1, op1_offset, op1_count, a, carry)
junk := carry.item
mul_1 (wp, wp_offset, op1, op1_offset, op1_count, c, carry)
junk := carry.item
submul_1 (wp, wp_offset, op2, op2_offset, op1_count, d, carry)
junk := carry.item
else
mul_1 (tp, tp_offset, op1, op1_offset, op1_count, a, carry)
junk := carry.item
submul_1 (tp, tp_offset, op2, op2_offset, op1_count, b, carry)
junk := carry.item
mul_1 (wp, wp_offset, op2, op2_offset, op1_count, d, carry)
junk := carry.item
submul_1 (wp, wp_offset, op1, op1_offset, op1_count, c, carry)
junk := carry.item
end
temp_special := tp
temp_integer := tp_offset
tp := op1
tp_offset := op1_offset
op1 := temp_special
op1_offset := temp_integer
temp_special := wp
temp_integer := wp_offset
wp := op2
wp_offset := op2_offset
op2 := temp_special
op2_offset := temp_integer
mul_1 (tp, tp_offset, cofactor, cofactor_offset, ssize, a, carry)
cy1 := carry.item
addmul_1 (tp, tp_offset, s1p, s1p_offset, ssize, b, carry)
cy2 := carry.item
cy := cy1 + cy2
tp [tp_offset + ssize] := cy
tsize := ssize + (cy /= 0).to_integer
if cy < cy1 then
tp [tp_offset + tsize] := 1
wp [wp_offset + tsize] := 0
tsize := tsize + 1
end
mul_1 (wp, wp_offset, s1p, s1p_offset, ssize, d, carry)
cy1 := carry.item
addmul_1 (wp, wp_offset, cofactor, cofactor_offset, ssize, c, carry)
cy2 := carry.item
cy := cy1 + cy2
wp [wp_offset + ssize] := cy
wsize := ssize + (cy /= 0).to_integer
if cy < cy1 then
wp [wp_offset + wsize] := 1
if wsize >= tsize then
tp [tp_offset + wsize] := 0
end
wsize := wsize + 1
end
temp_special := tp
temp_integer := tp_offset
tp := cofactor
tp_offset := cofactor_offset
cofactor := temp_special
cofactor_offset := temp_integer
temp_special := wp
temp_integer := wp_offset
wp := s1p
wp_offset := s1p_offset
s1p := temp_special
s1p_offset := temp_integer
ssize := wsize.max (tsize)
end
op1_count := op1_count - (op1 [op1_offset + op1_count - 1] = 0).to_integer
end
end
end
if op2_count = 0 then
if target /= op1 then
target.copy_data (op1, op1_offset, target_offset, op1_count)
end
ssize := normalize (cofactor, cofactor_offset, ssize)
if orig_s0p /= cofactor then
orig_s0p.copy_data (cofactor, cofactor_offset, orig_s0p_offset, ssize)
end
if sign >= 0 then
cofactor_count.cofactor_count := ssize
else
cofactor_count.cofactor_count := -ssize
end
Result := op1_count
else
vl := op2 [op2_offset]
t := divrem_1 (wp, wp_offset, op1, op1_offset, op1_count, vl)
tp.copy_data (cofactor, cofactor_offset, tp_offset, ssize)
qsize := op1_count - (wp [wp_offset + op1_count - 1] = 0).to_integer
if ssize < qsize then
tp.fill_with (0, tp_offset + ssize, qsize - ssize)
s1p.fill_with (0, s1p_offset + ssize, qsize)
from
i := 0
until
i >= ssize
loop
addmul_1 (tp, tp_offset + i, wp, wp_offset, qsize, s1p [s1p_offset + i], carry)
cy := carry.item
tp [tp_offset + qsize + i] := cy
i := i + 1
end
else
s1p.fill_with (0, s1p_offset + ssize, s1p_offset + ssize + qsize - 1)
from
i := 0
until
i >= qsize
loop
addmul_1 (tp, tp_offset + i, s1p, s1p_offset, ssize, wp [wp_offset + i], carry)
cy := carry.item
tp [tp_offset + ssize + i] := cy
i := i + 1
end
end
ssize := ssize + qsize
ssize := ssize - (tp [tp_offset + ssize - 1] = 0).to_integer
sign := -sign
temp_special := cofactor
temp_integer := cofactor_offset
cofactor := s1p
cofactor_offset := s1p_offset
s1p := temp_special
s1p_offset := temp_integer
temp_special := s1p
temp_integer := s1p_offset
s1p := tp
s1p_offset := tp_offset
tp := temp_special
tp_offset := temp_integer
ul := vl
vl := t
from
until
vl = 0
loop
q := ul // vl
t := ul - q * vl
tp.copy_data (cofactor, cofactor_offset, tp_offset, ssize)
s1p.fill_with (0, s1p_offset + ssize, s1p_offset + ssize)
addmul_1 (tp, tp_offset, s1p, s1p_offset, ssize, q, carry)
cy := carry.item
tp [tp_offset + ssize] := cy
ssize := ssize + 1
ssize := ssize - (tp [tp_offset + ssize - 1] = 0).to_integer
sign := -sign
temp_special := cofactor
temp_integer := cofactor_offset
cofactor := s1p
cofactor_offset := s1p_offset
s1p := temp_special
s1p_offset := temp_integer
temp_special := s1p
temp_integer := s1p_offset
s1p := tp
s1p_offset := tp_offset
tp := temp_special
tp_offset := temp_integer
ul := vl
vl := t
end
target [target_offset] := ul
ssize := normalize (cofactor, cofactor_offset, ssize)
if orig_s0p /= cofactor then
orig_s0p.copy_data (cofactor, cofactor_offset, orig_s0p_offset, ssize)
end
if sign >= 0 then
cofactor_count.cofactor_count := ssize
else
cofactor_count.cofactor_count := -ssize
end
Result := 1
end
end
gcdext (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; cofactor: SPECIAL [NATURAL_32]; cofactor_offset: INTEGER; cofactor_count: TUPLE [cofactor_count: INTEGER]; op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; op2: SPECIAL [NATURAL_32]; op2_offset: INTEGER; op2_count: INTEGER): INTEGER
require
op1_count >= op2_count
op2_count >= 0
op1.valid_index (op1_offset)
op1.valid_index (op1_offset + op1_count - 0)
op1 [op1_offset + op1_count - 1] /= 0
op2.valid_index (op2_offset)
op2.valid_index (op2_offset + op2_count - 0)
op1 [op1_offset + op1_count - 1] /= 0
target.valid_index (target_offset)
target.valid_index (target_offset + op1_count - 1)
cofactor.valid_index (cofactor_offset)
cofactor.valid_index (cofactor_offset + op1_count - 1)
local
orig_n: INTEGER
do
orig_n := op2_count
Result := basic_gcdext (target, target_offset, cofactor, cofactor_offset, cofactor_count, op1, op1_offset, op1_count, op2, op2_offset, op2_count)
end
modexact_1c_odd (op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER; d: NATURAL_32; orig_c: NATURAL_32): NATURAL_32
require
op1_count >= 1
d.bit_test (0)
local
s: NATURAL_32
h: CELL [NATURAL_32]
l: CELL [NATURAL_32]
inverse: NATURAL_32
dummy: CELL [NATURAL_32]
dmul: NATURAL_32
c: CELL [NATURAL_32]
i: INTEGER
do
create l.put (0)
create c.put (orig_c)
create h.put (0)
create dummy.put (0)
if op1_count = 1 then
s := op1 [op1_offset]
if s > c.item then
l.put (s - c.item)
h.put (l.item \\ d)
if h.item /= 0 then
h.put (d - h.item)
end
else
l.put (c.item - s)
h.put (l.item \\ d)
end
Result := h.item
else
inverse := modlimb_invert (d)
dmul := d
from
i := 0
until
i >= op1_count - 1
loop
s := op1 [op1_offset + i]
subc_limb (c, l, s, c.item)
l.put (l.item * inverse)
umul_ppmm (h, dummy, l.item, dmul)
c.put (c.item + h.item)
i := i + 1
end
s := op1 [op1_offset + i]
if s <= d then
l.put (c.item - s)
if c.item < s then
l.put (l.item + d)
end
Result := l.item
else
subc_limb (c, l, s, c.item)
l.put (l.item * inverse)
umul_ppmm (h, dummy, l.item, dmul)
c.put (c.item + h.item)
Result := c.item
end
end
ensure
orig_c < d implies Result < d
orig_c >= d implies Result <= d
end
preinv_mod_1 (up: SPECIAL [NATURAL_32]; up_offset: INTEGER; un: INTEGER; d: NATURAL_32; dinv: NATURAL_32): NATURAL_32
require
un >= 1
d.bit_test (31)
local
i: INTEGER
n0: NATURAL_32
r: CELL [NATURAL_32]
dummy: CELL [NATURAL_32]
do
create r.put (up [up_offset + un - 1])
create dummy.put (0)
if r.item >= d then
r.put (r.item - d)
end
from
i := un - 2
until
i < 0
loop
n0 := up [up_offset + i]
udiv_qrnnd_preinv (dummy, r, r.item, n0, d, dinv)
i := i - 1
end
Result := r.item
end
redc_basecase (cp: SPECIAL [NATURAL_32]; cp_offset: INTEGER; mp: SPECIAL [NATURAL_32]; mp_offset: INTEGER; n: INTEGER; n_prim: NATURAL_32; tp: SPECIAL [NATURAL_32]; tp_offset_a: INTEGER)
local
cy: NATURAL_32
q: NATURAL_32
j: INTEGER
tp_offset: INTEGER
junk: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
tp_offset := tp_offset_a
from
j := 0
until
j >= n
loop
q := tp [tp_offset] * n_prim
addmul_1 (tp, tp_offset, mp, mp_offset, n, q, carry)
tp [tp_offset] := carry.item
tp_offset := tp_offset + 1
j := j + 1
end
add_n (cp, cp_offset, tp, tp_offset, tp, tp_offset - n, n, carry)
cy := carry.item
if cy /= 0 then
sub_n (cp, cp_offset, cp, cp_offset, mp, mp_offset, n, carry)
junk := carry.item
end
end
subc_limb (cout: CELL [NATURAL_32]; w: CELL [NATURAL_32]; x: NATURAL_32; y: NATURAL_32)
do
w.put (x - y)
cout.put ((w.item > x).to_integer.to_natural_32)
end
invert_gf (target: SPECIAL [NATURAL_32] target_offset: INTEGER op1_a: SPECIAL [NATURAL_32] op1_offset: INTEGER op1_count_a: INTEGER op2_a: SPECIAL [NATURAL_32] op2_offset: INTEGER op2_count_a: INTEGER)
-- Invert `op1' over `op2' using the extended euclidian algorithm in F2M
require
op2_count_a > 0
op1_count_a >= 0
op1_count_a <= op2_count_a;
(op1_count_a = op2_count_a) implies cmp (op1_a, op1_offset, op2_a, op2_offset, op2_count_a) <= 0
local
op1: SPECIAL [NATURAL_32]
op1_count: INTEGER
op1_leading_zeros: INTEGER
op2: SPECIAL [NATURAL_32]
op2_count: INTEGER
op2_leading_zeros: INTEGER
tmp_special: SPECIAL [NATURAL_32]
tmp_integer: INTEGER
g1: SPECIAL [NATURAL_32]
g1_count: INTEGER
g2: SPECIAL [NATURAL_32]
g2_count: INTEGER
operand_sizes: INTEGER
left_shift_amount: INTEGER
do
operand_sizes := op2_count_a
op1_count := op1_count_a
op2_count := op2_count_a
create op1.make_filled (0, operand_sizes + operand_sizes)
create op2.make_filled (0, operand_sizes + operand_sizes)
op1.copy_data (op1_a, op1_offset, 0, op1_count.min (operand_sizes))
op2.copy_data (op2_a, op2_offset, 0, op2_count.min (operand_sizes))
create g1.make_filled (0, operand_sizes + operand_sizes)
create g2.make_filled (0, operand_sizes + operand_sizes)
g1 [0] := 1
g1_count := 1
g2_count := 0
from
until
op1_count = 0
loop
op1_leading_zeros := leading_zeros (op1 [op1_count - 1])
op2_leading_zeros := leading_zeros (op2 [op2_count - 1])
if op1_count < op2_count or (op1_count = op2_count and op1_leading_zeros > op2_leading_zeros) then
tmp_special := op1
op1 := op2
op2 := tmp_special
tmp_special := g1
g1 := g2
g2 := tmp_special
tmp_integer := op1_count
op1_count := op2_count
op2_count := tmp_integer
tmp_integer := op1_leading_zeros
op1_leading_zeros := op2_leading_zeros
op2_leading_zeros := tmp_integer
end
if op1_count /= op2_count or (op1_count = op2_count and op1_leading_zeros /= op2_leading_zeros) then
left_shift_amount := (op1_count - op2_count) * limb_bits + op2_leading_zeros - op1_leading_zeros
bit_xor_lshift (op1, 0, op1, 0, op1_count, op2, 0, op2_count, left_shift_amount)
bit_xor_lshift (g1, 0, g1, 0, operand_sizes, g2, 0, operand_sizes, left_shift_amount)
else
bit_xor (op1, 0, op1, 0, op1_count, op2, 0, op2_count)
bit_xor (g1, 0, g1, 0, operand_sizes, g2, 0, operand_sizes)
end
op1_count := normalize (op1, 0, op1_count)
op2_count := normalize (op2, 0, op2_count)
end
target.copy_data (g2, 0, target_offset, operand_sizes)
end
end

View File

@@ -0,0 +1,52 @@
note
description: "Summary description for {NUMBER_SIZING}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Whatever you do will be insignificant, but it is very important that you do it. - Mahatma Gandhi"
deferred class
SPECIAL_SIZING
inherit
LIMB_MANIPULATION
MP_BASES
feature
sizeinbase (source: SPECIAL [NATURAL_32]; source_offset: INTEGER; size: INTEGER; base: INTEGER): INTEGER
require
size >= 0
base >= 2
local
lb_base: INTEGER
count: INTEGER
total_bits: INTEGER
do
if size = 0 then
Result := 1
else
count := leading_zeros (source [source_offset + size - 1])
total_bits := size * limb_bits - count
if pow2_p (base.to_natural_32) then
lb_base := big_base (base).to_integer_32
Result := (total_bits + lb_base - 1) // lb_base
else
Result := ((total_bits * chars_per_bit_exactly (base)) + 1).truncated_to_integer
end
end
end
sizeinbase_2exp (ptr: SPECIAL [NATURAL_32]; ptr_offset: INTEGER; ptr_count: INTEGER; base2exp: INTEGER): INTEGER
require
ptr_count > 0
ptr [ptr_offset + ptr_count - 1] /= 0
local
count: INTEGER
totbits: INTEGER
do
count := leading_zeros (ptr [ptr_offset + ptr_count - 1])
totbits := ptr_count * limb_bits - count
Result := (totbits + base2exp - 1) // base2exp
end
end

View File

@@ -0,0 +1,37 @@
note
description: "Summary description for {NUMBER_UTILITY}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "If a law is unjust, a man is not only right to disobey it, he is obligated to do so. - Thomas Jefferson"
deferred class
SPECIAL_UTILITY
feature
normalize (op1: SPECIAL [NATURAL_32]; op1_offset: INTEGER; op1_count: INTEGER): INTEGER
do
from
Result := op1_count
until
Result <= 0 or op1 [op1_offset + Result - 1] /= 0
loop
Result := Result - 1
end
end
reverse (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; source: SPECIAL [NATURAL_32]; source_offset: INTEGER; count: INTEGER)
local
i: INTEGER
do
from
i := 0
until
i >= count
loop
target [target_offset + i] := source [source_offset + count - 1 - i]
i := i + 1
end
end
end

View File

@@ -0,0 +1,66 @@
note
description: "An INTEGER_X whos value cannot change"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Freedom is the emancipation from the arbitrary rule of other men. - Mortimer Adler (1902-2001)"
class
IMMUTABLE_INTEGER_X
inherit
READABLE_INTEGER_X
create
default_create,
make_from_integer,
make_from_integer_64,
make_from_integer_32,
make_from_integer_16,
make_from_integer_8,
make_from_natural,
make_from_natural_64,
make_from_natural_32,
make_from_natural_16,
make_from_natural_8,
make_from_string,
make_from_hex_string,
make_from_string_base,
make_random,
make_from_bytes,
make_random_prime,
make_random_max,
make_limbs,
make_bits,
make_set
convert
to_integer_64: {INTEGER_64},
to_integer_32: {INTEGER_32},
to_integer_16: {INTEGER_16},
to_integer_8: {INTEGER_8},
to_natural_64: {NATURAL_64},
to_natural_32: {NATURAL_32},
to_natural_16: {NATURAL_16},
to_natural_8: {NATURAL_8},
make_from_integer_64 ({INTEGER_64}),
make_from_integer_32 ({INTEGER_32}),
make_from_integer_16 ({INTEGER_16}),
make_from_integer_8 ({INTEGER_8}),
make_from_natural_64 ({NATURAL_64}),
make_from_natural_32 ({NATURAL_32}),
make_from_natural_16 ({NATURAL_16}),
make_from_natural_8 ({NATURAL_8}),
make_set ({READABLE_INTEGER_X})
feature
one: like Current
do
create Result.make_from_integer (1)
end
zero: like Current
do
create Result
end
end

View File

@@ -0,0 +1,89 @@
note
description: "An arbitrary precision integer"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "'For your own good' is a persuasive argument that will eventually make a man agree to his own destruction. - Janet Frame, Faces In The Water, 1982"
class
INTEGER_X
inherit
READABLE_INTEGER_X
export
{ANY}
abs,
plus,
minus,
product,
quotient,
opposite,
bit_complement,
bit_and,
bit_or,
bit_xor,
bit_not,
bit_xor_left_shift,
bit_shift_right,
bit_shift_left,
set_bit,
powm,
inverse,
modulo,
gcd,
invert_gf
end
create
default_create,
make_from_integer,
make_from_integer_64,
make_from_integer_32,
make_from_integer_16,
make_from_integer_8,
make_from_natural,
make_from_natural_64,
make_from_natural_32,
make_from_natural_16,
make_from_natural_8,
make_from_string,
make_from_hex_string,
make_from_string_base,
make_random,
make_from_bytes,
make_random_prime,
make_random_max,
make_limbs,
make_bits,
make_set
convert
to_integer_64: {INTEGER_64},
to_integer_32: {INTEGER_32},
to_integer_16: {INTEGER_16},
to_integer_8: {INTEGER_8},
to_natural_64: {NATURAL_64},
to_natural_32: {NATURAL_32},
to_natural_16: {NATURAL_16},
to_natural_8: {NATURAL_8},
make_from_integer_64 ({INTEGER_64}),
make_from_integer_32 ({INTEGER_32}),
make_from_integer_16 ({INTEGER_16}),
make_from_integer_8 ({INTEGER_8}),
make_from_natural_64 ({NATURAL_64}),
make_from_natural_32 ({NATURAL_32}),
make_from_natural_16 ({NATURAL_16}),
make_from_natural_8 ({NATURAL_8}),
make_set ({READABLE_INTEGER_X})
feature -- Constants
one: like Current
do
create Result.make_from_integer (1)
end
zero: like Current
do
create Result
end
end

View File

@@ -0,0 +1,20 @@
note
description: "An exception when a {STRING} couldn't be parsed in to a {INTEGER_X}"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Heresy is only another word for freedom of thought. - Graham Greene (1904-1991)"
class
INTEGER_X_STRING_EXCEPTION
inherit
DEVELOPER_EXCEPTION
redefine
internal_meaning
end
feature
internal_meaning: STRING = "Erorr parsing string as INTEGER_X"
end

View File

@@ -0,0 +1,19 @@
note
description: "An exception when an {INTEGER_X} doesn't have a modular inverse"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Whenever they burn books they will also, in the end, burn human beings. - Heinrich Heine (1797-1856), Almansor: A Tragedy, 1823"
class
INVERSE_EXCEPTION
inherit
DEVELOPER_EXCEPTION
redefine
internal_meaning
end
feature
internal_meaning: STRING = "No modular inverse"
end

View File

@@ -0,0 +1,17 @@
note
description: "Summary description for {LIMB_DEFINITION}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
deferred class
LIMB_DEFINITION
feature
limb_high_bit: INTEGER = 31
-- Index of the high bit of a limb
limb_bits: INTEGER = 32
-- Number of bits in a limb
end

View File

@@ -0,0 +1,458 @@
note
description: "Summary description for {LIMB_MANIPULATION}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
deferred class
LIMB_MANIPULATION
inherit
LIMB_BIT_SCANNING
LIMB_DEFINITION
feature
limb_low_bit: INTEGER = 0
-- Index of the low bit of a limb
limb_max: NATURAL_32 = 0xffffffff
-- Maximum value of limb type
integer_to_limb (integer: INTEGER): NATURAL_32
require
integer >= 0
do
Result := integer.to_natural_32
end
boolean_to_integer (boolean: BOOLEAN): INTEGER
do
Result := boolean.to_integer
ensure
boolean implies Result = 1
not boolean implies Result = 0
end
boolean_to_limb (boolean: BOOLEAN): NATURAL_32
do
Result := boolean_to_integer (boolean).to_natural_32
ensure
boolean implies Result = 1
not boolean implies Result = 0
end
extract_limb (count: INTEGER; xh: NATURAL_32; xl: NATURAL_32): NATURAL_32
require
count < limb_bits
count >= 0
do
if count = 0 then
Result := xh
else
Result := (xh |<< count).bit_or (xl |>> (limb_bits - count))
end
end
write_limb (limb_a: NATURAL_32; target: SPECIAL [NATURAL_8]; target_offset: INTEGER)
do
target [target_offset] := limb_a.to_natural_8
target [target_offset + 1] := (limb_a |>> 8).to_natural_8
target [target_offset + 2] := (limb_a |>> 16).to_natural_8
target [target_offset + 3] := (limb_a |>> 24).to_natural_8
end
write_limb_be (limb_a: NATURAL_32; target: SPECIAL [NATURAL_8]; target_offset: INTEGER)
do
target [target_offset] := (limb_a |>> 24).to_natural_8
target [target_offset + 1] := (limb_a |>> 16).to_natural_8
target [target_offset + 2] := (limb_a |>> 8).to_natural_8
target [target_offset + 3] := limb_a.to_natural_8
end
read_limb (source: SPECIAL [NATURAL_8]; source_offset: INTEGER): NATURAL_32
do
Result := source [source_offset + 3].to_natural_32 |<< 24
Result := Result.bit_or (source [source_offset + 2].to_natural_32 |<< 16)
Result := Result.bit_or (source [source_offset + 1].to_natural_32 |<< 8)
Result := Result.bit_or (source [source_offset].to_natural_32)
end
read_limb_be (source: SPECIAL [NATURAL_8]; source_offset: INTEGER): NATURAL_32
do
Result := source [source_offset].to_natural_32 |<< 24
Result := Result.bit_or (source [source_offset + 1].to_natural_32 |<< 16)
Result := Result.bit_or (source [source_offset + 2].to_natural_32 |<< 8)
Result := Result.bit_or (source [source_offset + 3].to_natural_32)
end
udiv_qrnnd (q: TUPLE [q: NATURAL_32]; r: TUPLE [r: NATURAL_32]; n1: NATURAL_32; n0: NATURAL_32; d: NATURAL_32)
require
d /= 0
n1 < d
local
d1: NATURAL_32
d0: NATURAL_32
q1: NATURAL_32
q0: NATURAL_32
r1: NATURAL_32
r0: NATURAL_32
m: NATURAL_32
do
d1 := d.bit_shift_right (16)
d0 := d.bit_and (0xffff)
q1 := n1 // d1
r1 := n1 - q1 * d1
m := q1 * d0
r1 := (r1 * 0x10000).bit_or (n0.bit_shift_right (16))
if r1 < m then
q1 := q1 - 1
r1 := r1 + d
if r1 >= d then
if r1 < m then
q1 := q1 - 1
r1 := r1 + d
end
end
end
r1 := r1 - m
q0 := r1 // d1
r0 := r1 - q0 * d1
m := q0 * d0
r0 := (r0 * 0x10000).bit_or (n0.bit_and (0xffff))
if r0 < m then
q0 := q0 - 1
r0 := r0 + d
if r0 >= d then
if r0 < m then
q0 := q0 - 1
r0 := r0 + d
end
end
end
r0 := r0 - m
q.q := (q1 * 0x10000).bit_or (q0)
r.r := r0
end
limb_inverse (limb_a: NATURAL_32): NATURAL_32
local
q: TUPLE [q: NATURAL_32]
r: TUPLE [r: NATURAL_32]
do
create q
create r
udiv_qrnnd (q, r, limb_a.bit_not, limb_max, limb_a)
Result := q.q
end
modlimb_invert (limb_a: NATURAL_32): NATURAL_32
require
limb_a.bit_test (0)
do
Result := modlimb_invert_table ((limb_a // 2).bit_and (0x7f).to_natural_8).to_natural_32
Result := 2 * Result - Result * Result * limb_a
Result := 2 * Result - Result * Result * limb_a
end
modlimb_invert_table (in: NATURAL_8): NATURAL_8
require
in >= 0
in <= 0x7f
do
inspect in
when 0 then
Result := 0x01
when 1 then
Result := 0xab
when 2 then
Result := 0xcd
when 3 then
Result := 0xb7
when 4 then
Result := 0x39
when 5 then
Result := 0xa3
when 6 then
Result := 0xc5
when 7 then
Result := 0xef
when 8 then
Result := 0xf1
when 9 then
Result := 0x1b
when 10 then
Result := 0x3d
when 11 then
Result := 0xa7
when 12 then
Result := 0x29
when 13 then
Result := 0x13
when 14 then
Result := 0x35
when 15 then
Result := 0xdf
when 16 then
Result := 0xe1
when 17 then
Result := 0x8b
when 18 then
Result := 0xad
when 19 then
Result := 0x97
when 20 then
Result := 0x19
when 21 then
Result := 0x83
when 22 then
Result := 0xa5
when 23 then
Result := 0xcf
when 24 then
Result := 0xd1
when 25 then
Result := 0xfb
when 26 then
Result := 0x1d
when 27 then
Result := 0x87
when 28 then
Result := 0x09
when 29 then
Result := 0xf4
when 30 then
Result := 0x15
when 31 then
Result := 0xbf
when 32 then
Result := 0xc1
when 33 then
Result := 0x6b
when 34 then
Result := 0x8d
when 35 then
Result := 0x77
when 36 then
Result := 0xf9
when 37 then
Result := 0x63
when 38 then
Result := 0x85
when 39 then
Result := 0xaf
when 40 then
Result := 0xb1
when 41 then
Result := 0xdb
when 42 then
Result := 0xfd
when 43 then
Result := 0x67
when 44 then
Result := 0xe9
when 45 then
Result := 0xd3
when 46 then
Result := 0xf5
when 47 then
Result := 0x9f
when 48 then
Result := 0xa1
when 49 then
Result := 0x4b
when 50 then
Result := 0x6d
when 51 then
Result := 0x57
when 52 then
Result := 0xd9
when 53 then
Result := 0x43
when 54 then
Result := 0x65
when 55 then
Result := 0x8f
when 56 then
Result := 0x91
when 57 then
Result := 0xbb
when 58 then
Result := 0xdd
when 59 then
Result := 0x47
when 60 then
Result := 0xc9
when 61 then
Result := 0xb3
when 62 then
Result := 0xd5
when 63 then
Result := 0x7f
when 64 then
Result := 0x81
when 65 then
Result := 0x2b
when 66 then
Result := 0x4d
when 67 then
Result := 0x37
when 68 then
Result := 0xb9
when 69 then
Result := 0x23
when 70 then
Result := 0x45
when 71 then
Result := 0x6f
when 72 then
Result := 0x71
when 73 then
Result := 0x9b
when 74 then
Result := 0xbd
when 75 then
Result := 0x27
when 76 then
Result := 0xa9
when 77 then
Result := 0x93
when 78 then
Result := 0xb5
when 79 then
Result := 0x5f
when 80 then
Result := 0x61
when 81 then
Result := 0x0b
when 82 then
Result := 0x2d
when 83 then
Result := 0x17
when 84 then
Result := 0x99
when 85 then
Result := 0x03
when 86 then
Result := 0x25
when 87 then
Result := 0x4f
when 88 then
Result := 0x51
when 89 then
Result := 0x7b
when 90 then
Result := 0x9d
when 91 then
Result := 0x07
when 92 then
Result := 0x89
when 93 then
Result := 0x73
when 94 then
Result := 0x95
when 95 then
Result := 0x3f
when 96 then
Result := 0x41
when 97 then
Result := 0xeb
when 98 then
Result := 0x0d
when 99 then
Result := 0xf7
when 100 then
Result := 0x79
when 101 then
Result := 0xe3
when 102 then
Result := 0x05
when 103 then
Result := 0x2f
when 104 then
Result := 0x31
when 105 then
Result := 0x5b
when 106 then
Result := 0x7d
when 107 then
Result := 0xe7
when 108 then
Result := 0x69
when 109 then
Result := 0x53
when 110 then
Result := 0x75
when 111 then
Result := 0x1f
when 112 then
Result := 0x21
when 113 then
Result := 0xcb
when 114 then
Result := 0xed
when 115 then
Result := 0xd7
when 116 then
Result := 0x59
when 117 then
Result := 0xc3
when 118 then
Result := 0xe5
when 119 then
Result := 0x0f
when 120 then
Result := 0x11
when 121 then
Result := 0x3b
when 122 then
Result := 0x5d
when 123 then
Result := 0xc7
when 124 then
Result := 0x49
when 125 then
Result := 0x33
when 126 then
Result := 0x55
when 127 then
Result := 0xff
end
end
bit_index_to_limb_index (bit_a: INTEGER): INTEGER
do
Result := bit_a // limb_bits
end
umul_ppmm (xh: CELL [NATURAL_32]; xl: CELL [NATURAL_32]; m0: NATURAL_32; m1: NATURAL_32)
local
t: NATURAL_64
do
t := limb_multiply (m0, m1)
xl.put (t.to_natural_32)
xh.put (t.bit_shift_right (limb_bits).to_natural_32)
end
bits_to_limbs (n: INTEGER): INTEGER
do
Result := (n + limb_bits - 1) // limb_bits
end
bits_top_limb (n: INTEGER): INTEGER
-- How many bits of the top limb would be occupied with n bits total
do
Result := (n + limb_bits - 1) \\ limb_bits
end
pow2_p (in: NATURAL_32): BOOLEAN
do
Result := in.bit_and (in - 1) = 0
end
limb_multiply (one: NATURAL_32 two: NATURAL_32): NATURAL_64
-- Return the lossless multiplication of `one' and `two'
do
Result := one.to_natural_64 * two.to_natural_64
end
end

View File

@@ -0,0 +1,249 @@
note
description: "A Linear congruential random number generator"
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "To limit the press is to insult a nation; to prohibit reading of certain books is to declare the inhabitants to be either fools or knaves. - Claude-Adrien Helvetius"
class
LINEAR_CONGRUENTIAL_RNG
inherit
RANDOM_NUMBER_GENERATOR
LIMB_MANIPULATION
SPECIAL_UTILITY
SPECIAL_ARITHMETIC
rename
add as add_special,
sub as sub_special,
mul as mul_special
export
{NONE}
all
end
INTEGER_X_DIVISION
create
make
feature
make (size: INTEGER)
require
size >= 0
size <= 128
local
a: INTEGER_X
m2exp: INTEGER
number: STRING_8
do
inspect size
when 0..16 then
m2exp := 32
number := "29cf535"
when 17 then
m2exp := 34
number := "A3D73AD"
when 18 then
m2exp := 36
number := "28f825c5"
when 19 then
m2exp := 38
number := "a3dd4cdd"
when 20 then
m2exp := 40
number := "28f5da175"
when 21..28 then
m2exp := 56
number := "AA7D735234C0DD"
when 29..32 then
m2exp := 64
number := "BAECD515DAF0B49D"
when 33..50 then
m2exp := 100
number := "292787EBD3329AD7E7575E2FD"
when 51..64 then
m2exp := 128
number := "48A74F367FA7B5C8ACBB36901308FA85"
when 65..78 then
m2exp := 156
number := "78A7FDDDC43611B527C3F1D760F36E5D7FC7C45"
when 79..98 then
m2exp := 196
number := "41BA2E104EE34C66B3520CE706A56498DE6D44721E5E24F5"
when 99..100 then
m2exp := 200
number := "4E5A24C38B981EAFE84CD9D0BEC48E83911362C114F30072C5"
when 101..238 then
m2exp := 256
number := "AF66BA932AAF58A071FD8F0742A99A0C76982D648509973DB802303128A14CB5"
end
create a.make_from_string_base (number, 16)
randinit_lc_2exp (a, 1, m2exp)
end
feature
randinit_lc_2exp (a: READABLE_INTEGER_X; c: NATURAL_32; m2exp: INTEGER)
local
seedn: INTEGER
do
seedn := bits_to_limbs (m2exp)
create seed.make (m2exp, a, seedn, c)
end
seed: RAND_LC_STRUCT
randseed (seed_a: READABLE_INTEGER_X)
local
seedz: READABLE_INTEGER_X
seedn: INTEGER
do
seedz := seed.seed
seedn := bits_to_limbs (seed.m2exp)
fdiv_r_2exp (seedz, seed_a, seed.m2exp)
seedz.item.fill_with (0, seedz.count, seedz.count - (seedn - seedz.count))
seedz.count := seedn
end
randget (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; nbits: INTEGER)
local
rbitpos: INTEGER
chunk_nbits: INTEGER
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
tn: INTEGER
r2p: SPECIAL [NATURAL_32]
r2p_offset: INTEGER
rcy: NATURAL_32
junk: INTEGER
last_nbits: INTEGER
savelimb: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
chunk_nbits := seed.m2exp // 2
tn := bits_to_limbs (chunk_nbits)
create tp.make_filled (0, tn)
from
rbitpos := 0
until
rbitpos + chunk_nbits > nbits
loop
r2p := target
r2p_offset := target_offset + rbitpos // limb_bits
if rbitpos \\ limb_bits /= 0 then
junk := lc (tp, tp_offset)
savelimb := r2p [r2p_offset]
lshift (r2p, r2p_offset, tp, tp_offset, tn, rbitpos \\ limb_bits, carry)
rcy := carry.item
r2p [r2p_offset] := r2p [r2p_offset].bit_or (savelimb)
if (chunk_nbits \\ limb_bits + rbitpos \\ limb_bits) > limb_bits then
r2p [r2p_offset + tn] := rcy
end
else
junk := lc (r2p, r2p_offset)
end
rbitpos := rbitpos + chunk_nbits
end
if rbitpos /= nbits then
r2p := target
r2p_offset := target_offset + rbitpos // limb_bits
last_nbits := nbits - rbitpos
tn := bits_to_limbs (last_nbits)
junk := lc (tp, tp_offset)
if rbitpos \\ limb_bits /= 0 then
savelimb := r2p [r2p_offset]
lshift (r2p, r2p_offset, tp, tp_offset, tn, rbitpos \\ limb_bits, carry)
rcy := carry.item
r2p [r2p_offset] := r2p [r2p_offset].bit_or (savelimb)
if rbitpos + tn * limb_bits - rbitpos \\ limb_bits < nbits then
r2p [r2p_offset + tn] := rcy
end
else
r2p.copy_data (tp, tp_offset, r2p_offset, tn)
end
if nbits \\ limb_bits /= 0 then
target [target_offset + nbits // limb_bits] := target [target_offset + nbits // limb_bits].bit_and (((0).to_natural_32.bit_not |<< (nbits \\ limb_bits)).bit_not)
end
end
end
lc (target: SPECIAL [NATURAL_32]; target_offset: INTEGER): INTEGER
local
tp: SPECIAL [NATURAL_32]
tp_offset: INTEGER
seedp: SPECIAL [NATURAL_32]
seedp_offset: INTEGER
ap: SPECIAL [NATURAL_32]
ap_offset: INTEGER
ta: INTEGER
tn: INTEGER
seedn: INTEGER
an: INTEGER
m2exp: INTEGER
bits: INTEGER
cy: INTEGER
xn: INTEGER
tmp: INTEGER
i: INTEGER
x: NATURAL_32
limb: NATURAL_32
count: INTEGER
junk: NATURAL_32
carry: CELL [NATURAL_32]
do
create carry.put (0)
m2exp := seed.m2exp
seedp := seed.seed.item
seedn := seed.seed.count
ap := seed.a.item
an := seed.a.count
ta := an + seedn + 1
tn := bits_to_limbs (m2exp)
if ta <= tn then
tmp := an + seedn
ta := tn + 1
end
create tp.make_filled (0, ta)
mul_special (tp, tp_offset, seedp, seedp_offset, seedn, ap, ap_offset, an, carry)
junk := carry.item
i := seed.cn
if i /= 0 then
add_n (tp, tp_offset, tp, tp_offset, seed.cp, 0, i, carry)
if carry.item /= 0 then
from
cy := 0
limb := 1
until
cy /= 0 or limb = 0
loop
if i >= tn then
cy := 1
else
x := tp [tp_offset + i]
limb := x + 1
tp [tp_offset + i] := limb
i := i + 1
end
end
end
end
tp [tp_offset + m2exp // limb_bits] := tp [tp_offset + m2exp // limb_bits].bit_and ((integer_to_limb (1) |<< m2exp \\ integer_to_limb (limb_bits)) - 1)
seed.seed.item.copy_data (tp, tp_offset, 0, tn)
bits := m2exp // 2
xn := bits // limb_bits
tn := tn - xn
if tn > 0 then
count := bits \\ limb_bits
if count /= 0 then
rshift (tp, tp_offset, tp, tp_offset + xn, tn, count, carry)
junk := carry.item
target.copy_data (tp, tp_offset, target_offset, xn + 1)
else
target.copy_data (tp, tp_offset + xn, target_offset, tn)
end
end
Result := (m2exp + 1) // 2
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
note
description: "Summary description for {RANDSTRUCT}."
author: "Colin LeMahieu"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
quote: "Where men cannot freely convey their thoughts to one another, no other liberty is secure. - William E. Hocking (1873-1966), Freedom of the Press, 1947"
deferred class
RANDOM_NUMBER_GENERATOR
inherit
LIMB_MANIPULATION
feature
randseed (seed: READABLE_INTEGER_X)
deferred
end
randget (target: SPECIAL [NATURAL_32]; target_offset: INTEGER; count: INTEGER)
require
count = 0 or target.valid_index (target_offset)
count = 0 or target.valid_index (target_offset + bits_to_limbs (count) - 1)
deferred
ensure
target [target_offset + bits_to_limbs (count) - 1] = 0 or else most_significant_one (target [target_offset + bits_to_limbs (count) - 1]) <= bits_top_limb (count)
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
Test suite order -
-Interfaces must be tested first (string conversions, Eiffel native construction conversions, etc, using known good large numbers verified by other big number libraries.
(If we don't have at least this then nothing else can be trusted)
-Integer Interfaces
-Real Interfaces
* Real MPF
* Real MPFR
-Rational
-Complex Integer
-Complex Complex Real
* Complex Real MPF
* Complex Real MPFR
-Complex Rational
-Test arithmetic functions for each eiffel MP constrcts using known values/solutions for "big" numbers and checking using previously tested known-good interfaces.
*Test arithmetic operations between similar types of MP constructs
*Test arithmetic operations between different types of MP constructs
TODO:
Reformat test suite order
Start testing interfaces
-Integer Interfaces
-Real Interfaces
* Real MPF
* Real MPFR
-Rational
-Complex Integer
-Complex Complex Real
* Complex Real MPF
* Complex Real MPFR
-Complex Rational

View File

@@ -0,0 +1,43 @@
note
description : "Library unit test root class"
date : "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision : "$Revision: 87787 $"
class
TEST
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
local
do
end
test1: detachable TEST_INTEGER_X
test2: detachable TEST_INTEGER_FUNCTIONS
test3: detachable TEST_INTEGER_X_ASSIGNMENT
test4: detachable TEST_SPECIAL_ARITHMETIC
test5: detachable TEST_SPECIAL_DIVISION
test6: detachable TEST_SPECIAL_LOGIC
test7: detachable TEST_SPECIAL_NUMBER_THEORETIC
test9: detachable TEST_RANDSTRUCT_LC
test10: detachable TEST_RANDSTRUCT_MT
test11: detachable TEST_INTEGER_X_RANDOM
test12: detachable TEST_INTEGER_X_ACCESS
test13: detachable TEST_INTEGER_X_IO
test14: detachable TEST_INTEGER_X_NUMBER_THEORY
test15: detachable TEST_INTEGER_X_ARITHMETIC
test16: detachable TEST_SPECIAL_GCD
test17: detachable TEST_INTEGER_X_DIVISION
test18: detachable TEST_INTEGER_X_GCD
test19: detachable TEST_INTEGER_X_LOGIC
test20: detachable TEST_LIMB_MANIPULATION
test21: detachable IMMUTABLE_INTEGER_X
test22: detachable INTEGER_X
end

View File

@@ -0,0 +1,19 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
testing: "type/manual"
class
TEST_INTEGER_FUNCTIONS
inherit
EQA_TEST_SET
feature -- Test routines
end

View File

@@ -0,0 +1,557 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
testing: "type/manual"
class
TEST_INTEGER_X
inherit
EQA_TEST_SET
INTEGER_X_ASSIGNMENT
undefine
default_create
end
feature -- Basic operations tests
test_init
local
one: INTEGER_X
do
create one
end
test_default_zero
local
one: INTEGER_X
do
create one
assert ("{INTEGER_X}.default_create", one.to_integer_32 = 0)
end
test_make_ui
local
one: INTEGER_X
do
create one.make_from_natural (0xffffffff)
assert ("{INTEGER_X}.make_ui", one.to_natural_32 = 0xffffffff)
end
test_as_natural
local
one: INTEGER_X
do
create one.make_from_natural (0xffffffff)
assert ("{INTEGER_X}.as_natural", one.to_natural_32 = 0xffffffff)
end
test_make_si
local
one: INTEGER_X
do
create one.make_from_integer (0x7fffffff)
assert ("{INTEGER_X}.make_si", one.to_integer_32 = 0x7fffffff)
end
test_as_integer
local
one: INTEGER_X
do
create one.make_from_integer (0x7fffffff)
assert ("{INTEGER_X}.as_integer", one.to_integer_32 = 0x7fffffff)
end
test_fits_natural_8_1
local
one: INTEGER_X
int: NATURAL_8
do
create one.make_from_string (int.max_value.out)
assert ("test fits natural 8 1", one.fits_natural_8)
end
test_fits_natural_8_2
local
one: INTEGER_X
int: NATURAL_8
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits natural 8 2", not one.fits_natural_8)
end
test_fits_natural_8_3
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits natural 8 3", one.fits_natural_8)
end
test_fits_natural_8_4
local
one: INTEGER_X
do
create one.make_from_integer (-1)
assert ("test fits natural 8 4", not one.fits_natural_8)
end
test_fits_natural_16_1
local
one: INTEGER_X
int: NATURAL_16
do
create one.make_from_string (int.max_value.out)
assert ("test fits natural 16 1", one.fits_natural_16)
end
test_fits_natural_16_2
local
one: INTEGER_X
int: NATURAL_16
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits natural 16 2", not one.fits_natural_16)
end
test_fits_natural_16_3
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits natural 16 3", one.fits_natural_16)
end
test_fits_natural_16_4
local
one: INTEGER_X
do
create one.make_from_integer (-1)
assert ("test fits natural 16 4", not one.fits_natural_16)
end
test_fits_natural_32_1
local
one: INTEGER_X
int: NATURAL_32
do
create one.make_from_string (int.max_value.out)
assert ("test fits natural 32 1", one.fits_natural_32)
end
test_fits_natural_32_2
local
one: INTEGER_X
int: NATURAL_32
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits natural 32 2", not one.fits_natural_32)
end
test_fits_natural_32_3
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits natural 32 3", one.fits_natural_32)
end
test_fits_natural_32_4
local
one: INTEGER_X
do
create one.make_from_integer (-1)
assert ("test fits natural 32 4", not one.fits_natural_32)
end
test_fits_natural_64_1
local
one: INTEGER_X
int: NATURAL_64
do
create one.make_from_string (int.max_value.out)
assert ("test fits natural 64 1", one.fits_natural_64)
end
test_fits_natural_64_2
local
one: INTEGER_X
int: NATURAL_64
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits natural 64 2", not one.fits_natural_64)
end
test_fits_natural_64_3
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits natural 64 3", one.fits_natural_64)
end
test_fits_natural_64_4
local
one: INTEGER_X
do
create one.make_from_integer (-1)
assert ("test fits natural 64 4", not one.fits_natural_64)
end
test_fits_integer_8_1
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.max_value.out)
assert ("test fits integer 8 1", one.fits_integer_8)
end
test_fits_integer_8_2
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.min_value.out)
assert ("test fits integer 8 2", one.fits_integer_8)
end
test_fits_integer_8_3
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits integer 8 3", not one.fits_integer_8)
end
test_fits_integer_8_4
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test fits integer 8 4", not one.fits_integer_8)
end
test_fits_integer_8_5
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits integer 8 5", one.fits_integer_8)
end
test_fits_integer_16_1
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.max_value.out)
assert ("test fits integer 16 1", one.fits_integer_16)
end
test_fits_integer_16_2
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.min_value.out)
assert ("test fits integer 16 2", one.fits_integer_16)
end
test_fits_integer_16_3
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits integer 16 3", not one.fits_integer_16)
end
test_fits_integer_16_4
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test fits integer 16 4", not one.fits_integer_16)
end
test_fits_integer_16_5
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits integer 16 5", one.fits_integer_16)
end
test_fits_integer_32_1
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.max_value.out)
assert ("test fits integer 32 1", one.fits_integer_32)
end
test_fits_integer_32_2
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.min_value.out)
assert ("test fits integer 32 2", one.fits_integer_32)
end
test_fits_integer_32_3
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits integer 32 3", not one.fits_integer_32)
end
test_fits_integer_32_4
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test fits integer 32 4", not one.fits_integer_32)
end
test_fits_integer_32_5
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits integer 32 5", one.fits_integer_32)
end
test_fits_integer_64_1
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.max_value.out)
assert ("test fits integer 64 1", one.fits_integer_64)
end
test_fits_integer_64_2
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.min_value.out)
assert ("test fits integer 64 2", one.fits_integer_64)
end
test_fits_integer_64_3
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test fits integer 64 3", not one.fits_integer_64)
end
test_fits_integer_64_4
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test fits integer 64 4", not one.fits_integer_64)
end
test_fits_integer_64_5
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.max_value.out)
assert ("test fits integer 64 5", one.fits_integer_64)
end
test_fits_integer_64_6
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.min_value.out)
assert ("test fits integer 64 6", one.fits_integer_64)
end
test_fits_integer_64_7
local
one: INTEGER_X
do
create one.make_from_integer (0)
assert ("test fits integer 64 7", one.fits_integer_64)
end
test_swap
local
one: INTEGER_X
two: INTEGER_X
do
create one.make_from_integer (1)
create two.make_from_integer (2)
swap (one, two)
assert ("{INTEGER_X}.swap 1", two.to_integer_32 = 1)
assert ("{INTEGER_X}.swap 2", one.to_integer_32 = 2)
end
test_init_set
local
one: INTEGER_X
two: INTEGER_X
do
create one.make_from_string ("0982430984230470238742037402394230948")
create two.make_set (one)
assert ("{INTEGER_X}.init_set", one ~ two)
end
test_sub
-- Test integer subtraction cases, ++ +- -+ --, 0 sum
local
posone: INTEGER_X
postwo: INTEGER_X
negone: INTEGER_X
negtwo: INTEGER_X
ans: INTEGER_X
do
create posone.make_from_integer (1000)
create postwo.make_from_integer (2000)
create negone.make_from_integer (-1000)
create negtwo.make_from_integer (-2000)
ans := posone - postwo
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = 1000 - 2000)
ans := postwo - negone
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = 2000 - -1000)
ans := negone - postwo
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = -1000 - 2000)
ans := negone - negtwo
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = -1000 - -2000)
ans := posone - posone
assert ("{INTEGER_X}.sub test", ans.to_integer_32 = 1000 - 1000)
end
test_negative
local
one: INTEGER_X
two: INTEGER_X
do
create one.make_from_integer (1)
create two.make_from_integer (-1)
assert ("test negative", one ~ two or one ~ -two)
end
test_mul
-- Test multiplication cases, +- -+
local
posone: INTEGER_X
negone: INTEGER_X
ans: INTEGER_X
do
create posone.make_from_integer (1000)
create negone.make_from_integer (-1000)
ans := posone * posone
assert ("{INTEGER_X}.mul test", ans.to_integer_32 = 1000 * 1000)
ans := posone * negone
assert ("{INTEGER_X}.mul test", ans.to_integer_32 = 1000 * -1000)
end
test_div
-- Test integer division cases, pp, ppr, np, npr, nn, nnr
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
four: INTEGER_X
quot: INTEGER_X
do
create one.make_from_integer (42)
create two.make_from_integer (2)
create three.make_from_integer (-42)
create four.make_from_integer (-2)
quot := one / two
assert ("{INTEGER_X}.div test", quot.to_integer_32 = 42 // 2)
quot := two / one
assert ("{INTEGER_X}.div test", quot.to_integer_32 = 2 // 42)
quot := three / two
assert ("{INTEGER_X}.div test", quot.to_integer_32 = -42 // 2)
quot := two / three
assert ("{INTEGER_X}.div test", quot.to_integer_32 = 2 // -42)
quot := three / four
assert ("{INTEGER_X}.div test", quot.to_integer_32 = -42 // -2)
quot := four / three
assert ("{INTEGER_X}.div test", quot.to_integer_32 = -2 // -42)
end
test_abs
-- Test absolute value cases
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
ans: INTEGER_X
do
create one.make_from_integer (1)
create two.make_from_integer (-1)
create three.make_from_integer (0)
ans := one.abs_value
assert ("INTEGER_X.abs positive", ans.to_integer_32 = 1)
ans := two.abs_value
assert ("INTEGER_X.abs negative", ans.to_integer_32 = 1)
ans := three.abs_value
assert ("INTEGER_X.abs zero", ans.to_integer_32 = 0)
end
test_comp
-- Test comparison function cases
local
one: INTEGER_X
two: INTEGER_X
three:INTEGER_X
do
create one.make_from_integer (1000)
create two.make_from_integer (2000)
create three.make_from_integer (1000)
assert ("INTEGER_X.comp eq", one.is_equal (three) = TRUE)
assert ("INTEGER_X.comp lt", one.is_less (two) = TRUE)
assert ("INTEGER_X.comp lt", two.is_less (one) = FALSE)
assert ("INTEGER_X.comp le", one.is_less_equal (two) = TRUE)
assert ("INTEGER_X.comp le", one.is_less_equal (three) = TRUE)
assert ("INTEGER_X.comp le", two.is_less_equal (one) = FALSE)
assert ("INTEGER_X.comp gt", one.is_greater (two) = FALSE)
assert ("INTEGER_X.comp gt", two.is_greater (one) = TRUE)
assert ("INTEGER_X.comp ge", one.is_greater_equal (two) = FALSE)
assert ("INTEGER_X.comp ge", one.is_greater_equal (three) = TRUE)
assert ("INTEGER_X.comp ge", two.is_greater_equal (one) = TRUE)
end
end

View File

@@ -0,0 +1,395 @@
note
description: "Summary description for {TEST_INTEGER_X_ACCESS}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
class
TEST_INTEGER_X_ACCESS
inherit
EQA_TEST_SET
INTEGER_X_ACCESS
undefine
default_create
end
feature
test_get_integer_64_1
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.max_value.out)
assert ("test get integer 64 1 1", one.fits_integer_64)
assert ("test get integer 64 1 2", one.as_integer_64 = int.max_value)
end
test_get_integer_64_2
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.min_value.out)
assert ("test get integer 64 2 1", one.fits_integer_64)
assert ("test get integer 64 2 2", one.as_integer_64 = int.min_value)
end
test_get_integer_64_3
local
one: INTEGER_X
do
create one.make_from_string ("0")
assert ("test get integer 64 3 1", one.fits_integer_64)
assert ("test get integer 64 3 2", one.as_integer_64 = 0)
end
test_get_integer_64_4
local
one: INTEGER_X
do
create one.make_from_string ("-1")
assert ("test get integer 64 4 1", one.fits_integer_64)
assert ("test get integer 64 4 2", one.as_integer_64 = -1)
end
test_get_integer_64_5
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test get integer 64 5 1", not one.fits_integer_64)
assert ("test get integer 64 5 2", one.as_integer_64 = 0)
end
test_get_integer_64_6
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test get integer 64 6 1", not one.fits_integer_64)
assert ("test get integer 64 6 2", one.as_integer_64 = -1)
end
test_get_integer_32_1
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.max_value.out)
assert ("test get integer 32 1 1", one.fits_integer_32)
assert ("test get integer 32 1 2", one.as_integer_32 = int.max_value)
end
test_get_integer_32_2
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.min_value.out)
assert ("test get integer 32 2 1", one.fits_integer_32)
assert ("test get integer 32 2 2", one.as_integer_32 = int.min_value)
end
test_get_integer_32_3
local
one: INTEGER_X
do
create one.make_from_string ("0")
assert ("test get integer 32 3 1", one.fits_integer_32)
assert ("test get integer 32 3 2", one.as_integer_32 = 0)
end
test_get_integer_32_4
local
one: INTEGER_X
do
create one.make_from_string ("-1")
assert ("test get integer 32 4 1", one.fits_integer_32)
assert ("test get integer 32 4 2", one.as_integer_32 = -1)
end
test_get_integer_32_5
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test get integer 32 5 1", not one.fits_integer_32)
assert ("test get integer 32 5 2", one.as_integer_32 = 0)
end
test_get_integer_32_6
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test get integer 32 6 1", not one.fits_integer_32)
assert ("test get integer 32 6 2", one.as_integer_32 = -1)
end
test_get_integer_16_1
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.max_value.out)
assert ("test get integer 16 1 1", one.fits_integer_16)
assert ("test get integer 16 1 2", one.as_integer_16 = int.max_value)
end
test_get_integer_16_2
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.min_value.out)
assert ("test get integer 16 2 1", one.fits_integer_16)
assert ("test get integer 16 2 2", one.as_integer_16 = int.min_value)
end
test_get_integer_16_3
local
one: INTEGER_X
do
create one.make_from_string ("0")
assert ("test get integer 16 3 1", one.fits_integer_16)
assert ("test get integer 16 3 2", one.as_integer_16 = 0)
end
test_get_integer_16_4
local
one: INTEGER_X
do
create one.make_from_string ("-1")
assert ("test get integer 16 4 1", one.fits_integer_16)
assert ("test get integer 16 4 2", one.as_integer_16 = -1)
end
test_get_integer_16_5
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test get integer 16 5 1", not one.fits_integer_16)
assert ("test get integer 16 5 2", one.as_integer_16 = 0)
end
test_get_integer_16_6
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test get integer 16 6 1", not one.fits_integer_16)
assert ("test get integer 16 6 2", one.as_integer_16 = -1)
end
test_get_integer_8_1
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.max_value.out)
assert ("test get integer 8 1 1", one.fits_integer_8)
assert ("test get integer 8 1 2", one.as_integer_8 = int.max_value)
end
test_get_integer_8_2
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.min_value.out)
assert ("test get integer 8 2 1", one.fits_integer_8)
assert ("test get integer 8 2 2", one.as_integer_8 = int.min_value)
end
test_get_integer_8_3
local
one: INTEGER_X
do
create one.make_from_string ("0")
assert ("test get integer 8 3 1", one.fits_integer_8)
assert ("test get integer 8 3 2", one.as_integer_8 = 0)
end
test_get_integer_8_4
local
one: INTEGER_X
do
create one.make_from_string ("-1")
assert ("test get integer 8 4 1", one.fits_integer_8)
assert ("test get integer 8 4 2", one.as_integer_8 = -1)
end
test_get_integer_8_5
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.max_value.out)
one.plus (one.one)
assert ("test get integer 8 5 1", not one.fits_integer_8)
assert ("test get integer 8 5 2", one.as_integer_8 = 0)
end
test_get_integer_8_6
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_string (int.min_value.out)
one.minus (one.one)
assert ("test get integer 8 6 1", not one.fits_integer_8)
assert ("test get integer 8 6 2", one.as_integer_8 = -1)
end
test_get_str_1
local
one: INTEGER_X
output: STRING
do
create one.make_limbs (4)
one.item [0] := 0x87654321
one.item [1] := 0xcccccccc
one.item [2] := 0x33333333
one.item [3] := 0xffffffff
one.count := 4
output := one.out_base (16)
assert ("test get str 1", "ffffffff33333333cccccccc87654321" ~ output)
end
test_get_str_2
local
one: INTEGER_X
output: STRING
do
create one.make_limbs (4)
one.item [0] := 0x87654321
one.item [1] := 0xcccccccc
one.item [2] := 0x33333333
one.item [3] := 0xffffffff
one.count := 4
output := one.out_base (10)
assert ("test get str 2", "340282366857555933463031183799994368801" ~ output)
end
test_get_str_3
local
one: INTEGER_X
two: INTEGER_X
output: STRING
i: INTEGER
base: INTEGER
do
from
i := 0
until
i > 1000
loop
base := i \\ 61 + 2
create one.make_random (256)
output := one.out_base (base)
create two.make_from_string_base (output, base)
assert ("test get str 3", one ~ two)
i := i + 1
end
end
test_get_str_4
local
one: INTEGER_X
output: STRING
do
create one.make_limbs (8)
one.item [0] := 0x99811941
one.item [1] := 0x841FD605
one.item [2] := 0xD960A1BF
one.item [3] := 0x5E433EFC
one.item [4] := 0x48C9BC93
one.item [5] := 0x1C8B6FB1
one.item [6] := 0x8CA06DE0
one.item [7] := 0xC6182337
one.count := 8
output := one.out_base (10)
assert ("test get str 4", output ~ "89600591407770348063754312463218194105764385355557091513583682190076098451777")
end
test_get_str_5
local
one: INTEGER_X
output: STRING
do
create one.make_limbs (8)
one.item [0] := 0x99811941
one.item [1] := 0x841FD605
one.item [2] := 0xD960A1BF
one.item [3] := 0x5E433EFC
one.item [4] := 0x48C9BC93
one.item [5] := 0x1C8B6FB1
one.item [6] := 0x8CA06DE0
one.item [7] := 0xC6182337
one.count := 8
output := one.out_base (3)
assert ("test get str 5", output ~ "110022012022022000201210111012211020111202020222100010210022020220110011011010201011020001011210101000122212110112010121211022120122101102102020102011202010010112")
end
test_get_str_6
local
one: INTEGER_X
output: STRING
do
create one.make_limbs (8)
one.item [7] := 0x8134b7f7
one.item [6] := 0x8d570cbf
one.item [5] := 0xeb5f7c66
one.item [4] := 0x7aa64334
one.item [3] := 0xbb6cd783
one.item [2] := 0x22792988
one.item [1] := 0x6ec0f7ac
one.item [0] := 0x4438ad87
one.count := 8
output := one.out_base (7)
assert ("test get str 6", output ~ "5050422450443414252030234161450453214063666050554216601312032162510626626621233550541413260")
end
test_get_str_7
local
one: INTEGER_X
output: STRING
do
create one.make_limbs (8)
one.item [0] := 0x8134b7f7
one.item [1] := 0x8d570cbf
one.item [2] := 0xeb5f7c66
one.item [3] := 0x7aa64334
one.item [4] := 0xbb6cd783
one.item [5] := 0x22792988
one.item [6] := 0x6ec0f7ac
one.item [7] := 0x4438ad87
one.count := 8
output := one.out_base (7)
assert ("test get str 7", output ~ "2460223246331335544520513341363224654146046636101125253015521231163466226621435340120452343")
end
test_get_str_8
local
one: INTEGER_X
output: STRING
do
create one.make_from_integer (-1)
output := one.out_hex
assert ("test get str 7", output ~ "-1")
end
end

View File

@@ -0,0 +1,208 @@
note
description: "Summary description for {TEST_INTEGER_ARITHMETIC}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
class
TEST_INTEGER_X_ARITHMETIC
inherit
EQA_TEST_SET
INTEGER_X_ARITHMETIC
undefine
default_create
end
feature
test_add_1
-- Test integer addition cases, ++ +- -+ --, 0 sum
local
posone: INTEGER_X
postwo: INTEGER_X
negone: INTEGER_X
negtwo: INTEGER_X
ans: INTEGER_X
do
create posone.make_from_integer (1000)
create postwo.make_from_integer (2000)
create negone.make_from_integer (-1000)
create negtwo.make_from_integer (-2000)
ans := posone + postwo
assert ("{INTEGER_X}.add test", ans.to_integer_32 = 1000 + 2000)
ans := postwo + negone
assert ("{INTEGER_X}.add test", ans.to_integer_32 = 2000 + -1000)
ans := negone + postwo
assert ("{INTEGER_X}.add test", ans.to_integer_32 = -1000 + 2000)
ans := negone + negtwo
assert ("{INTEGER_X}.add test", ans.to_integer_32 = -1000 + -2000)
ans := posone + negone
assert ("{INTEGER_X}.add test", ans.to_integer_32 = 1000 + -1000)
end
test_add_2
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one.make_limbs (6)
create two.make_from_hex_string ("343bd97a 7e17702a 800c8f10 54ad58f6 1f07c505")
create three.make_from_hex_string ("ffffffff ffffffff ffffffff ffffffff 7ffffffc")
create expected.make_from_hex_string ("1343bd97a7e17702a800c8f1054ad58f59f07c501")
add (one, two, three)
assert ("test add 2", one ~ expected)
end
test_add_3
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("a9993e364706816aba3e25717850c26c9cd0d89d")
create three.make_from_hex_string ("8913681113524c02ac9b2b8777f53c1feb356bfbc122bf1970d1ccc8fc43f9bb8aec1812ee98e4a2")
create expected.make_from_hex_string ("8913681113524c02ac9b2b8777f53c1feb356bfc6abbfd4fb7d84e33b6821f2d033cda7f8b69bd3f")
add (one, two, three)
assert ("test add 3", one ~ expected)
end
test_add_4
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("-7231ea35689f4fd7ce163d502a7e14c99947e909fb2a9d7cad460fb337fae053af6e5a5419a6800c19f28b09a3a1f005621dd631b6d93fcc32e4e6069e76fb15")
create three.make_from_hex_string ("1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
create expected.make_from_hex_string ("1ff8dce15ca9760b02831e9c2afd581eb3666b816f604d5628352b9f04cc8051fac5091a5abe6597ff3e60d74f65c5e0ffa9de229ce4926c033cd1b19f9618904ea")
add (one, two, three)
assert ("test add 4", one ~ expected)
end
test_sub_1
local
one_three: INTEGER_X
two: INTEGER_X
expected: INTEGER_X
do
create one_three.make_from_hex_string ("014fae42 56ad0915 2a7b2b66 fe887b52 e06ffa35 d359cd33 14156137 564096ef 90eb9c01 9ee82ea9")
create two.make_from_hex_string ("1")
create expected.make_from_hex_string ("-014fae42 56ad0915 2a7b2b66 fe887b52 e06ffa35 d359cd33 14156137 564096ef 90eb9c01 9ee82ea8")
sub (one_three, two, one_three)
assert ("test sub 1", one_three ~ expected)
end
test_sub_2
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("1429cb78799228669deb4a9025f308ab78be74ae")
create three.make_from_hex_string ("-f7c5cdcb7d66c16bbf17e81de30488c02078684")
create expected.make_from_hex_string ("23a628553168947d59dcc912042351377ac5fb32")
sub (one, two, three)
assert ("test sub 2", one ~ expected)
end
test_mul_1
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one.make_limbs (10)
create two.make_limbs (5)
create three.make_limbs (6)
create expected.make_from_hex_string ("30f2de49 bab11556 78be37e5 d4205117 663c6cc5 5fd1e2bd 41b4a8fd 35ce30b2 07939fb8 c29af9f6")
two.item [0] := 0x9f07c4ff
two.item [1] := 0xd4ad58f1
two.item [2] := 0x800c8f0e
two.item [3] := 0x7e17702a
two.item [4] := 0x343bd97a
two.count := 5
three.item [0] := 0xfb4ab80a
three.item [1] := 0x2077ac6a
three.item [2] := 0x5bdd4431
three.item [3] := 0x6672da8e
three.item [4] := 0xefe650c5
three.count := 5
mul (one, two, three)
assert ("test mul 1", expected ~ one)
end
test_mul_2
local
one_three: INTEGER_X
two: INTEGER_X
expected: INTEGER_X
do
create one_three.make_limbs (6)
create two.make_limbs (5)
create expected.make_from_hex_string ("30f2de49 bab11556 78be37e5 d4205117 663c6cc5 5fd1e2bd 41b4a8fd 35ce30b2 07939fb8 c29af9f6")
two.item [0] := 0x9f07c4ff
two.item [1] := 0xd4ad58f1
two.item [2] := 0x800c8f0e
two.item [3] := 0x7e17702a
two.item [4] := 0x343bd97a
two.count := 5
one_three.item [0] := 0xfb4ab80a
one_three.item [1] := 0x2077ac6a
one_three.item [2] := 0x5bdd4431
one_three.item [3] := 0x6672da8e
one_three.item [4] := 0xefe650c5
one_three.count := 5
mul (one_three, two, one_three)
assert ("test mul 1", expected ~ one_three)
end
test_mul_3
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("-e69e4c55 8d0e2ed0 10128582 48b54fe8 8e87802e c871b791 5347fc54 8fb749de 9bc6e6b7 1868a715 859bcde6 96d6f196 37ad0367 26bc4cea 65f0d20e 67321392")
create three.make_from_hex_string ("000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff")
create expected.make_from_hex_string ("-1cd3c98ab1a1c5da020250b04916a9fd11d0f005d90e36f22a68ff8a91f6e93bd378dcd6e30d14e2b0b379bcd2dade32c6f5a06ce4d7899d4cbe1a41cce642723ff1961b3aa72f1d12fefed7a7db74ab01771787fd1378e486eacb803ab7048b62164391948e79758ea7a64321969290e69c852fc98d943b3159a0f2df198cdec6e")
mul (one, two, three)
assert ("test mul 3", one ~ expected)
end
test_mul_2exp_1
local
one: INTEGER_X
two: INTEGER_X
expected: INTEGER_X
do
create one.make_limbs (7)
create two.make_from_hex_string ("2 fe13c053 7bbc11ac aa07d793 de4e6d5e 5c94eee8")
create expected.make_from_hex_string ("0000000b f84f014d eef046b2 a81f5e4f 7939b579 7253bba0")
mul_2exp (one, two, 2)
assert ("test mul 2exp 1", one ~ expected)
end
test_mul_2exp_2
local
one: INTEGER_X
two: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("8 00000000 00000000 00000000 00000000 00000000")
create expected.make_from_hex_string ("8 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000")
mul_2exp (one, two, 0x80)
assert ("test mul 2exp 2", one ~ expected)
end
end

View File

@@ -0,0 +1,217 @@
note
description: "Summary description for {TEST_INTEGER_X_ASSIGNMENT}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
class
TEST_INTEGER_X_ASSIGNMENT
inherit
EQA_TEST_SET
INTEGER_X_ASSIGNMENT
undefine
default_create
end
feature
test_set_str_1
local
target: INTEGER_X
do
create target
set_str (target, "100", 10)
assert ("test set str 1 1", target.item [0] = 100 and target.count = 1)
set_str (target, "10000000000", 10)
assert ("test set str 1 2", target.item [0] = 0x540be400 and target.item [1] = 0x00000002 and target.count = 2)
end
test_set_str_2
local
target: INTEGER_X
do
create target
set_str (target, "1000", 16)
assert ("test set str 1 1", target.item [0] = 0x1000 and target.count = 1)
set_str (target, "100000000000", 16)
assert ("test set str 1 2", target.item [0] = 0x00000000 and target.item [1] = 0x00001000 and target.count = 2)
end
test_set_str_3
local
target: INTEGER_X
do
create target
set_str (target, " 1 0 0 0 ", 16)
assert ("test set str 3 1", target.item [0] = 0x1000 and target.count = 1)
set_str (target, " 1 0 0 0 0 0 0 0 0 0 0 0 ", 16)
assert ("test set str 3 2", target.item [0] = 0x00000000 and target.item [1] = 0x00001000 and target.count = 2)
end
test_set_str_4
local
target: INTEGER_X
do
create target
set_str (target, " 0x 1 0 0 0 ", 0)
assert ("test set str 3 1", target.item [0] = 0x1000 and target.count = 1)
set_str (target, " 0", 0)
assert ("test set str 3 2", target.count = 0)
end
test_set_str_5
local
one: INTEGER_X
do
create one.make_from_string_base ("5050422450443414252030234161450453214063666050554216601312032162510626626621233550541413260", 7)
assert ("test set str 5", one.item [7] = 0x8134b7f7 and one.item [6] = 0x8d570cbf and one.item [5] = 0xeb5f7c66 and one.item [4] = 0x7aa64334 and one.item [3] = 0xbb6cd783 and one.item [2] = 0x22792988 and one.item [1] = 0x6ec0f7ac and one.item [0] = 0x4438ad87 and one.count = 8)
end
test_set_str_6
local
one: INTEGER_X
do
create one.make_from_string_base ("2460223246331335544520513341363224654146046636101125253015521231163466226621435340120452343", 7)
assert ("test set str 6", one.item [0] = 0x8134b7f7 and one.item [1] = 0x8d570cbf and one.item [2] = 0xeb5f7c66 and one.item [3] = 0x7aa64334 and one.item [4] = 0xbb6cd783 and one.item [5] = 0x22792988 and one.item [6] = 0x6ec0f7ac and one.item [7] = 0x4438ad87 and one.count = 8)
end
test_set_str_7
local
one: INTEGER_X
do
create one.make_from_hex_string ("1")
assert ("test set str 7", one.item [0] = 0x1 and one.count = 1)
end
test_set_1
local
one: INTEGER_X
two: INTEGER_X
do
create one.make_from_hex_string ("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff")
assert ("test set 1 1", one.item [0] = 0xfcfdfeff and one.item [1] = 0xf8f9fafb and one.item [2] = 0xf4f5f6f7 and one.item [3] = 0xf0f1f2f3 and one.count = 4)
create two
two.copy (one)
assert ("test set 1 2", one ~ two)
assert ("test set 1 3", one.item [0] = 0xfcfdfeff and one.item [1] = 0xf8f9fafb and one.item [2] = 0xf4f5f6f7 and one.item [3] = 0xf0f1f2f3 and one.count = 4)
assert ("test set 1 4", two.item [0] = 0xfcfdfeff and two.item [1] = 0xf8f9fafb and two.item [2] = 0xf4f5f6f7 and two.item [3] = 0xf0f1f2f3 and two.count = 4)
end
test_set_from_integer_64_1
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_integer_64 (int.min_value)
assert ("test set from integer 64 1 1", one.fits_integer_64)
assert ("test set from integer 64 1 2", one.to_integer_64 = int.min_value)
end
test_set_from_integer_64_2
local
one: INTEGER_X
do
create one.make_from_integer_64 (-1)
assert ("test set from integer 64 2 1", one.fits_integer_64)
assert ("test set from integer 64 2 2", one.to_integer_64 = -1)
end
test_set_from_integer_64_3
local
one: INTEGER_X
int: INTEGER_64
do
create one.make_from_integer_64 (int.max_value)
assert ("test set from integer 64 3 1", one.fits_integer_64)
assert ("test set from integer 64 3 2", one.to_integer_64 = int.max_value)
end
test_set_from_integer_32_1
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_integer_32 (int.min_value)
assert ("test set from integer 32 1 1", one.fits_integer_32)
assert ("test set from integer 32 1 2", one.to_integer_32 = int.min_value)
end
test_set_from_integer_32_2
local
one: INTEGER_X
do
create one.make_from_integer_32 (-1)
assert ("test set from integer 32 2 1", one.fits_integer_32)
assert ("test set from integer 32 2 2", one.to_integer_32 = -1)
end
test_set_from_integer_32_3
local
one: INTEGER_X
int: INTEGER_32
do
create one.make_from_integer_32 (int.max_value)
assert ("test set from integer 32 3 1", one.fits_integer_32)
assert ("test set from integer 32 3 2", one.to_integer_32 = int.max_value)
end
test_set_from_integer_16_1
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_integer_16 (int.min_value)
assert ("test set from integer 16 1 1", one.fits_integer_16)
assert ("test set from integer 16 1 2", one.to_integer_16 = int.min_value)
end
test_set_from_integer_16_2
local
one: INTEGER_X
do
create one.make_from_integer_16 (-1)
assert ("test set from integer 16 2 1", one.fits_integer_16)
assert ("test set from integer 16 2 2", one.to_integer_16 = -1)
end
test_set_from_integer_16_3
local
one: INTEGER_X
int: INTEGER_16
do
create one.make_from_integer_16 (int.max_value)
assert ("test set from integer 16 3 1", one.fits_integer_16)
assert ("test set from integer 16 3 2", one.to_integer_16 = int.max_value)
end
test_set_from_integer_8_1
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_integer_8 (int.min_value)
assert ("test set from integer 8 1 1", one.fits_integer_8)
assert ("test set from integer 8 1 2", one.to_integer_8 = int.min_value)
end
test_set_from_integer_8_2
local
one: INTEGER_X
do
create one.make_from_integer_8 (-1)
assert ("test set from integer 8 2 1", one.fits_integer_8)
assert ("test set from integer 8 2 2", one.to_integer_8 = -1)
end
test_set_from_integer_8_3
local
one: INTEGER_X
int: INTEGER_8
do
create one.make_from_integer_8 (int.max_value)
assert ("test set from integer 8 3 1", one.fits_integer_8)
assert ("test set from integer 8 3 2", one.to_integer_8 = int.max_value)
end
end

View File

@@ -0,0 +1,32 @@
note
description: "Summary description for {INTEGER_X_DIVISION}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
class
TEST_INTEGER_X_DIVISION
inherit
EQA_TEST_SET
INTEGER_X_DIVISION
undefine
default_create
end
feature
test_tdiv_q_1
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("-014fae42 56ad0915 2a7b2b66 fe887b52 e06ffa35 d359cd33 14156137 564096ef 90eb9c01 9ee82ea9")
create three.make_from_hex_string ("474c50aa 62d128fa b3b99224 0846a26e f58bf664")
create expected.make_from_hex_string ("-04b547f5 df885395 a422bbce 998d2570 9019af3a")
tdiv_q (one, two, three)
assert ("test tdiv q 1", one ~ expected)
end
end

View File

@@ -0,0 +1,92 @@
note
description: "Summary description for {TEST_INTEGER_X_GCD}."
author: ""
date: "$Date: 2011-11-11 18:13:16 +0100 (ven., 11 nov. 2011) $"
revision: "$Revision: 87787 $"
class
TEST_INTEGER_X_GCD
inherit
EQA_TEST_SET
INTEGER_X_GCD
undefine
default_create
end
feature
test_gcd_1
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("75bd a09fab66 22ddfba5 6141c975")
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
create expected.make_from_integer (1)
gcd (one, two, three)
assert ("test gcd 1", one ~ expected)
end
test_gcd_2
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("1f3e 0565ad11 0943df37 0be1f345")
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
create expected.make_from_integer (1)
gcd (one, two, three)
assert ("test gcd 2", one ~ expected)
end
test_gcd_3
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("b900 97df5038 7e2f36a6 2ed3a8f4")
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
create expected.make_from_integer (1)
gcd (one, two, three)
assert ("test gcd 3", one ~ expected)
end
test_gcd_4
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("905a 1c3f4cec 73b96934 ac732c70")
create three.make_from_hex_string ("db7c 2abf62e3 5e668076 bead208b")
create expected.make_from_integer (1)
gcd (one, two, three)
assert ("test gcd 4", one ~ expected)
end
test_gcd_5
local
one: INTEGER_X
two: INTEGER_X
three: INTEGER_X
expected: INTEGER_X
do
create one
create two.make_from_hex_string ("1ffb369d437c5d32145fd9a1223ab960e362ffd5545b675f7ead44be35a12c61699c05dd8ecafb643b9feb6912fb6df6c57eca1c0e4ff132ed5d77d6bb5d96a4395")
create three.make_from_hex_string ("1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
create expected.make_from_hex_string ("1")
gcd (one, two, three)
assert ("test gcd 5", one ~ expected)
end
end

Some files were not shown because too many files have changed in this diff Show More